note.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. "use strict";
  2. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  3. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  5. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6. var _ = require('../utils/under-dash');
  7. var Note = /*#__PURE__*/function () {
  8. function Note(note) {
  9. _classCallCheck(this, Note);
  10. this.note = note;
  11. }
  12. _createClass(Note, [{
  13. key: "model",
  14. get: function get() {
  15. var value = null;
  16. switch (_typeof(this.note)) {
  17. case 'string':
  18. value = {
  19. type: 'note',
  20. note: {
  21. texts: [{
  22. text: this.note
  23. }]
  24. }
  25. };
  26. break;
  27. default:
  28. value = {
  29. type: 'note',
  30. note: this.note
  31. };
  32. break;
  33. } // Suitable for all cell comments
  34. return _.deepMerge({}, Note.DEFAULT_CONFIGS, value);
  35. },
  36. set: function set(value) {
  37. var note = value.note;
  38. var texts = note.texts;
  39. if (texts.length === 1 && Object.keys(texts[0]).length === 1) {
  40. this.note = texts[0].text;
  41. } else {
  42. this.note = note;
  43. }
  44. }
  45. }], [{
  46. key: "fromModel",
  47. value: function fromModel(model) {
  48. var note = new Note();
  49. note.model = model;
  50. return note;
  51. }
  52. }]);
  53. return Note;
  54. }();
  55. Note.DEFAULT_CONFIGS = {
  56. note: {
  57. margins: {
  58. insetmode: 'auto',
  59. inset: [0.13, 0.13, 0.25, 0.25]
  60. },
  61. protection: {
  62. locked: 'True',
  63. lockText: 'True'
  64. },
  65. editAs: 'absolute'
  66. }
  67. };
  68. module.exports = Note;
  69. //# sourceMappingURL=note.js.map