@modusoperandi/licit 0.13.25 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. package/.eslintrc.js +1 -1
  2. package/README.md +1 -0
  3. package/dist/BlockquoteInsertNewLineCommand.js +3 -23
  4. package/dist/BlockquoteNodeSpec.js +3 -13
  5. package/dist/BlockquoteToggleCommand.js +3 -16
  6. package/dist/BookmarkNodeSpec.js +0 -6
  7. package/dist/BulletListNodeSpec.js +2 -16
  8. package/dist/CZIProseMirror.js +3 -27
  9. package/dist/CodeBlockCommand.js +3 -19
  10. package/dist/CodeBlockNodeSpec.js +3 -4
  11. package/dist/CodeMarkSpec.js +0 -4
  12. package/dist/ContentPlaceholderPlugin.js +6 -58
  13. package/dist/CursorPlaceholderPlugin.js +2 -32
  14. package/dist/DocLayoutCommand.js +5 -28
  15. package/dist/DocNodeSpec.js +0 -9
  16. package/dist/EMMarkSpec.js +0 -4
  17. package/dist/EditorCommands.js +5 -33
  18. package/dist/EditorKeyMap.js +4 -18
  19. package/dist/EditorMarks.js +2 -26
  20. package/dist/EditorNodes.js +4 -22
  21. package/dist/EditorPageLayoutPlugin.js +3 -15
  22. package/dist/EditorPlugins.js +0 -4
  23. package/dist/EditorSchema.js +0 -5
  24. package/dist/EditorState.js +0 -2
  25. package/dist/FontSizeMarkSpec.js +0 -12
  26. package/dist/FontTypeMarkSpec.js +15 -19
  27. package/dist/HTMLMutator.js +5 -24
  28. package/dist/HardBreakNodeSpec.js +0 -2
  29. package/dist/HeadingNodeSpec.js +6 -15
  30. package/dist/HistoryRedoCommand.js +3 -11
  31. package/dist/HistoryUndoCommand.js +3 -11
  32. package/dist/HorizontalRuleCommand.js +3 -22
  33. package/dist/HorizontalRuleNodeSpec.js +0 -10
  34. package/dist/ImageFromURLCommand.js +0 -9
  35. package/dist/ImageNodeSpec.js +2 -14
  36. package/dist/ImageSourceCommand.js +3 -39
  37. package/dist/ImageUploadCommand.js +3 -21
  38. package/dist/ImageUploadPlaceholderPlugin.js +10 -48
  39. package/dist/LinkMarkSpec.js +0 -4
  40. package/dist/LinkSetURLCommand.js +3 -28
  41. package/dist/LinkTooltipPlugin.js +6 -52
  42. package/dist/ListItemInsertNewLineCommand.js +3 -23
  43. package/dist/ListItemMergeCommand.js +15 -66
  44. package/dist/ListItemNodeSpec.js +0 -11
  45. package/dist/ListSplitCommand.js +3 -14
  46. package/dist/ListToggleCommand.js +5 -26
  47. package/dist/MarksClearCommand.js +6 -17
  48. package/dist/MathEditCommand.js +3 -38
  49. package/dist/MathNodeSpec.js +0 -10
  50. package/dist/OrderedListNodeSpec.js +0 -24
  51. package/dist/ParagraphNodeSpec.js +5 -26
  52. package/dist/ParagraphSpacingCommand.js +3 -32
  53. package/dist/PrintCommand.js +3 -13
  54. package/dist/SelectionPlaceholderPlugin.js +2 -31
  55. package/dist/SpacerMarkSpec.js +2 -6
  56. package/dist/StrikeMarkSpec.js +0 -4
  57. package/dist/StrongMarkSpec.js +2 -5
  58. package/dist/StyleView.js +1 -7
  59. package/dist/TableBackgroundColorCommand.js +3 -24
  60. package/dist/TableBorderColorCommand.js +3 -24
  61. package/dist/TableCellColorCommand.js +3 -23
  62. package/dist/TableCellMenuPlugin.js +9 -45
  63. package/dist/TableInsertCommand.js +7 -39
  64. package/dist/TableMergeCellsCommand.js +5 -30
  65. package/dist/TableNodesSpecs.js +4 -23
  66. package/dist/TablePlugins.js +0 -5
  67. package/dist/TableResizePlugin.js +54 -138
  68. package/dist/TextColorMarkSpec.js +0 -9
  69. package/dist/TextHighlightMarkSpec.js +0 -8
  70. package/dist/TextInsertTabSpaceCommand.js +3 -28
  71. package/dist/TextNoWrapMarkSpec.js +0 -4
  72. package/dist/TextSelectionMarkSpec.js +0 -5
  73. package/dist/TextSubMarkSpec.js +0 -4
  74. package/dist/TextSuperMarkSpec.js +0 -4
  75. package/dist/TextUnderlineMarkSpec.js +0 -4
  76. package/dist/Types.js +0 -6
  77. package/dist/WebFontLoader.js +3 -8
  78. package/dist/blockQuoteInputRule.js +0 -13
  79. package/dist/bom.xml +1492 -1645
  80. package/dist/buildEditorPlugins.js +5 -27
  81. package/dist/buildInputRules.js +12 -24
  82. package/dist/client/CollabConnector.js +6 -30
  83. package/dist/client/EditorConnection.js +23 -69
  84. package/dist/client/Licit.js +79 -163
  85. package/dist/client/Licit.js.flow +16 -2
  86. package/dist/client/Licit.test.js +6 -13
  87. package/dist/client/Reporter.js +1 -8
  88. package/dist/client/SimpleConnector.js +6 -26
  89. package/dist/client/http.js +8 -15
  90. package/dist/client/throttle.js +0 -2
  91. package/dist/convertFromDOMElement.js +2 -10
  92. package/dist/convertFromHTML.js +0 -5
  93. package/dist/convertFromJSON.js +3 -13
  94. package/dist/convertToCSSPTValue.js +0 -6
  95. package/dist/convertToJSON.js +0 -2
  96. package/dist/createCommand.js +3 -11
  97. package/dist/createEditorKeyMap.js +0 -13
  98. package/dist/createEmptyEditorState.js +0 -7
  99. package/dist/createTableResizingPlugin.js +5 -16
  100. package/dist/findActionableCell.js +0 -19
  101. package/dist/findActiveMark.js +0 -11
  102. package/dist/hyphenize.js +2 -4
  103. package/dist/index.js +0 -9
  104. package/dist/insertTable.js +0 -16
  105. package/dist/isEditorStateEmpty.js +0 -6
  106. package/dist/isTableNode.js +0 -3
  107. package/dist/joinDown.js +0 -7
  108. package/dist/joinListNode.js +0 -15
  109. package/dist/joinUp.js +0 -9
  110. package/dist/keymaps.js +0 -15
  111. package/dist/lookUpElement.js +0 -3
  112. package/dist/nodeAt.js +0 -3
  113. package/dist/normalizeHTML.js +9 -25
  114. package/dist/patchAnchorElements.js +5 -12
  115. package/dist/patchBreakElements.js +0 -6
  116. package/dist/patchElementInlineStyles.js +5 -15
  117. package/dist/patchListElements.js +20 -54
  118. package/dist/patchMathElements.js +11 -21
  119. package/dist/patchParagraphElements.js +0 -5
  120. package/dist/patchStyleElements.js +12 -41
  121. package/dist/patchTableElements.js +9 -37
  122. package/dist/rebaseDocWithSteps.js +0 -6
  123. package/dist/sanitizeURL.js +0 -3
  124. package/dist/splitListItem.js +12 -43
  125. package/dist/toClosestFontPtSize.js +1 -5
  126. package/dist/toSafeHTMLDocument.js +0 -1
  127. package/dist/toggleBlockquote.js +2 -19
  128. package/dist/toggleCodeBlock.js +2 -22
  129. package/dist/ui/AlertInfo.js +6 -22
  130. package/dist/ui/BookmarkNodeView.js +7 -28
  131. package/dist/ui/CommandButton.js +3 -19
  132. package/dist/ui/CommandMenu.js +3 -25
  133. package/dist/ui/CommandMenuButton.js +3 -36
  134. package/dist/ui/CustomEditorView.js +3 -16
  135. package/dist/ui/CustomMenu.js +0 -8
  136. package/dist/ui/CustomMenuItem.js +4 -18
  137. package/dist/ui/CustomNodeView.js +21 -67
  138. package/dist/ui/CustomRadioButton.js +14 -33
  139. package/dist/ui/DocLayoutEditor.js +5 -27
  140. package/dist/ui/Editor.js +18 -79
  141. package/dist/ui/EditorFrameset.js +3 -18
  142. package/dist/ui/EditorToolbar.js +10 -46
  143. package/dist/ui/EditorToolbarConfig.js +10 -20
  144. package/dist/ui/FontSizeCommandMenuButton.js +5 -19
  145. package/dist/ui/FontTypeCommandMenuButton.js +5 -22
  146. package/dist/ui/Frag.js +0 -7
  147. package/dist/ui/Icon.js +5 -25
  148. package/dist/ui/ImageAlignEditor.js +3 -16
  149. package/dist/ui/ImageInlineEditor.js +3 -16
  150. package/dist/ui/ImageNodeView.js +20 -109
  151. package/dist/ui/ImageResizeBox.js +3 -53
  152. package/dist/ui/ImageURLEditor.js +3 -28
  153. package/dist/ui/ImageUploadEditor.js +3 -35
  154. package/dist/ui/LinkTooltip.js +5 -25
  155. package/dist/ui/LinkURLEditor.js +3 -29
  156. package/dist/ui/ListItemNodeView.js +15 -30
  157. package/dist/ui/ListTypeButton.js +5 -37
  158. package/dist/ui/ListTypeCommandButton.js +3 -19
  159. package/dist/ui/ListTypeMenu.js +4 -25
  160. package/dist/ui/LoadingIndicator.js +0 -7
  161. package/dist/ui/MathEditor.js +3 -24
  162. package/dist/ui/MathInlineEditor.js +3 -26
  163. package/dist/ui/MathNodeView.js +9 -59
  164. package/dist/ui/PasteMenu.js +4 -20
  165. package/dist/ui/ResizeObserver.js +0 -18
  166. package/dist/ui/RichTextEditor.js +5 -27
  167. package/dist/ui/SelectionObserver.js +3 -29
  168. package/dist/ui/TableCellMenu.js +3 -18
  169. package/dist/ui/TableGridSizeEditor.js +5 -51
  170. package/dist/ui/TableNodeView.js +0 -11
  171. package/dist/ui/bindScrollHandler.js +2 -9
  172. package/dist/ui/canUseCSSFont.js +2 -8
  173. package/dist/ui/czi-icon.css +4 -4
  174. package/dist/ui/findActiveFontSize.js +2 -18
  175. package/dist/ui/findActiveFontType.js +0 -12
  176. package/dist/ui/handleEditorDrop.js +0 -9
  177. package/dist/ui/handleEditorKeyDown.js +0 -7
  178. package/dist/ui/handleEditorPaste.js +0 -9
  179. package/dist/ui/htmlElementToRect.js +0 -4
  180. package/dist/ui/injectStyleSheet.js +0 -10
  181. package/dist/ui/isElementFullyVisible.js +2 -8
  182. package/dist/ui/isOffline.js +0 -2
  183. package/dist/ui/isReactClass.js +0 -4
  184. package/dist/ui/mathquill-editor/MathQuillEditor.js +9 -44
  185. package/dist/ui/mathquill-editor/MathQuillEditorSymbols.js +1 -3
  186. package/dist/ui/mathquill-editor/MathQuillEditorSymbolsPanel.js +3 -16
  187. package/dist/ui/mathquill-editor/mathquill-import-kludge.js +5 -7
  188. package/dist/ui/renderLaTeXAsHTML.js +2 -13
  189. package/dist/ui/resolveImage.js +7 -32
  190. package/dist/ui/toCSSColor.js +0 -14
  191. package/dist/ui/toCSSLineSpacing.js +10 -11
  192. package/dist/ui/toHexColor.js +0 -8
  193. package/dist/ui/uuid.js +0 -2
  194. package/dist/uuid.js +0 -2
  195. package/package-lock.json.old +32889 -0
  196. package/package.json +45 -69
  197. package/src/client/Licit.js +16 -2
  198. package/src/ui/czi-icon.css +4 -4
  199. package/utils/build_web_server.js +1 -7
  200. package/webpack.config.js +3 -3
@@ -4,15 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = exports.ATTRIBUTE_LIST_STYLE_TYPE = void 0;
7
-
8
7
  var _prosemirrorModel = require("prosemirror-model");
9
-
10
8
  var _Types = require("./Types");
11
-
12
9
  const ATTRIBUTE_LIST_STYLE_TYPE = 'data-list-style-type';
13
10
  exports.ATTRIBUTE_LIST_STYLE_TYPE = ATTRIBUTE_LIST_STYLE_TYPE;
14
11
  const ALIGN_PATTERN = /(left|right|center|justify)/;
15
-
16
12
  function getAttrs(dom) {
17
13
  const attrs = {};
18
14
  const {
@@ -20,14 +16,11 @@ function getAttrs(dom) {
20
16
  } = dom.style;
21
17
  let align = dom.getAttribute('data-align') || textAlign || '';
22
18
  align = ALIGN_PATTERN.test(align) ? align : null;
23
-
24
19
  if (align) {
25
20
  attrs.align = align;
26
21
  }
27
-
28
22
  return attrs;
29
23
  }
30
-
31
24
  const ListItemNodeSpec = {
32
25
  attrs: {
33
26
  align: {
@@ -44,7 +37,6 @@ const ListItemNodeSpec = {
44
37
  tag: 'li',
45
38
  getAttrs
46
39
  }],
47
-
48
40
  // NOTE:
49
41
  // This method only defines the minimum HTML attributes needed when the node
50
42
  // is serialized to HTML string. Usually this is called when user copies
@@ -55,14 +47,11 @@ const ListItemNodeSpec = {
55
47
  const {
56
48
  align
57
49
  } = node.attrs;
58
-
59
50
  if (align) {
60
51
  attrs['data-align'] = align;
61
52
  }
62
-
63
53
  return ['li', attrs, 0];
64
54
  }
65
-
66
55
  };
67
56
  var _default = ListItemNodeSpec;
68
57
  exports.default = _default;
@@ -4,34 +4,25 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _prosemirrorModel = require("prosemirror-model");
9
-
10
8
  var _prosemirrorState = require("prosemirror-state");
11
-
12
9
  var _prosemirrorTransform = require("prosemirror-transform");
13
-
14
10
  var _prosemirrorView = require("prosemirror-view");
15
-
16
11
  var _splitListItem = _interopRequireDefault(require("./splitListItem"));
17
-
18
12
  var _licitDocAttrsStep = require("@modusoperandi/licit-doc-attrs-step");
19
-
20
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
22
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
23
-
14
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
16
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
24
17
  class ListSplitCommand extends _licitDocAttrsStep.UICommand {
25
18
  constructor(_schema) {
26
19
  super();
27
-
28
20
  _defineProperty(this, "execute", (state, dispatch, view) => {
29
21
  const {
30
22
  selection,
31
23
  schema
32
24
  } = state;
33
25
  const tr = (0, _splitListItem.default)(state.tr.setSelection(selection), schema);
34
-
35
26
  if (tr.docChanged) {
36
27
  dispatch && dispatch(tr);
37
28
  return true;
@@ -40,8 +31,6 @@ class ListSplitCommand extends _licitDocAttrsStep.UICommand {
40
31
  }
41
32
  });
42
33
  }
43
-
44
34
  }
45
-
46
35
  var _default = ListSplitCommand;
47
36
  exports.default = _default;
@@ -5,49 +5,35 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.ListToggleCommand = void 0;
7
7
  exports.hasImageNode = hasImageNode;
8
-
9
8
  var _prosemirrorState = require("prosemirror-state");
10
-
11
9
  var _prosemirrorTransform = require("prosemirror-transform");
12
-
13
10
  var _prosemirrorUtils = require("prosemirror-utils");
14
-
15
11
  var _prosemirrorView = require("prosemirror-view");
16
-
17
12
  var _NodeNames = require("./NodeNames");
18
-
19
13
  var _licitUiCommands = require("@modusoperandi/licit-ui-commands");
20
-
21
14
  var _licitDocAttrsStep = require("@modusoperandi/licit-doc-attrs-step");
22
-
23
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
24
-
15
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
16
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
17
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
25
18
  class ListToggleCommand extends _licitDocAttrsStep.UICommand {
26
19
  constructor(ordered, type) {
27
20
  super();
28
-
29
21
  _defineProperty(this, "_ordered", void 0);
30
-
31
22
  _defineProperty(this, "_orderedListType", void 0);
32
-
33
23
  _defineProperty(this, "isActive", state => {
34
24
  let bOK = false;
35
-
36
25
  if (this._ordered) {
37
26
  bOK = !!this._findList(state, _NodeNames.ORDERED_LIST);
38
27
  } else {
39
28
  bOK = !!this._findList(state, _NodeNames.BULLET_LIST);
40
29
  }
41
-
42
30
  return bOK;
43
31
  });
44
-
45
32
  _defineProperty(this, "isEnabled", (state, view) => {
46
33
  let bOK = false;
47
34
  bOK = hasImageNode(state);
48
35
  return !bOK;
49
36
  });
50
-
51
37
  _defineProperty(this, "execute", (state, dispatch, view) => {
52
38
  const {
53
39
  selection,
@@ -58,13 +44,10 @@ class ListToggleCommand extends _licitDocAttrsStep.UICommand {
58
44
  tr
59
45
  } = state;
60
46
  tr = tr.setSelection(selection);
61
-
62
47
  if (!nodeType) {
63
48
  return tr;
64
49
  }
65
-
66
50
  tr = (0, _licitUiCommands.toggleList)(tr, schema, nodeType, this._orderedListType);
67
-
68
51
  if (tr.docChanged) {
69
52
  dispatch && dispatch(tr);
70
53
  return true;
@@ -72,11 +55,9 @@ class ListToggleCommand extends _licitDocAttrsStep.UICommand {
72
55
  return false;
73
56
  }
74
57
  });
75
-
76
58
  this._ordered = ordered;
77
59
  this._orderedListType = type;
78
60
  }
79
-
80
61
  _findList(state, type) {
81
62
  const {
82
63
  nodes
@@ -85,13 +66,11 @@ class ListToggleCommand extends _licitDocAttrsStep.UICommand {
85
66
  const findList = list ? (0, _prosemirrorUtils.findParentNodeOfType)(list) : _licitUiCommands.noop;
86
67
  return findList(state.selection);
87
68
  }
69
+ }
88
70
 
89
- } // [FS] IRAD-1317 2021-05-06
71
+ // [FS] IRAD-1317 2021-05-06
90
72
  // To disable the list menu in toolbar when select an image
91
-
92
-
93
73
  exports.ListToggleCommand = ListToggleCommand;
94
-
95
74
  function hasImageNode(state) {
96
75
  const {
97
76
  selection,
@@ -4,50 +4,39 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _prosemirrorState = require("prosemirror-state");
9
-
10
8
  var _prosemirrorTransform = require("prosemirror-transform");
11
-
12
9
  var _prosemirrorView = require("prosemirror-view");
13
-
14
10
  var _licitUiCommands = require("@modusoperandi/licit-ui-commands");
15
-
16
11
  var _licitDocAttrsStep = require("@modusoperandi/licit-doc-attrs-step");
17
-
18
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
19
-
12
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
14
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
20
15
  class MarksClearCommand extends _licitDocAttrsStep.UICommand {
21
16
  constructor() {
22
17
  super(...arguments);
23
-
24
18
  _defineProperty(this, "isActive", state => {
25
19
  return false;
26
20
  });
27
-
28
21
  _defineProperty(this, "isEnabled", state => {
29
22
  const {
30
23
  selection
31
24
  } = state;
32
25
  return !selection.empty && (selection instanceof _prosemirrorState.TextSelection || selection instanceof _prosemirrorState.AllSelection);
33
26
  });
34
-
35
27
  _defineProperty(this, "execute", (state, dispatch, view) => {
36
- let tr = (0, _licitUiCommands.clearMarks)(state.tr.setSelection(state.selection), state.schema); // [FS] IRAD-948 2021-02-22
37
- // Clear Header formatting
28
+ let tr = (0, _licitUiCommands.clearMarks)(state.tr.setSelection(state.selection), state.schema);
29
+ // [FS] IRAD-948 2021-02-22
38
30
 
31
+ // Clear Header formatting
39
32
  tr = (0, _licitUiCommands.clearHeading)(tr, state.schema);
40
-
41
33
  if (dispatch && tr.docChanged) {
42
34
  dispatch(tr);
43
35
  return true;
44
36
  }
45
-
46
37
  return false;
47
38
  });
48
39
  }
49
-
50
40
  }
51
-
52
41
  var _default = MarksClearCommand;
53
42
  exports.default = _default;
@@ -4,98 +4,69 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _prosemirrorModel = require("prosemirror-model");
9
-
10
8
  var _prosemirrorState = require("prosemirror-state");
11
-
12
9
  var _prosemirrorTransform = require("prosemirror-transform");
13
-
14
10
  var _prosemirrorView = require("prosemirror-view");
15
-
16
11
  var React = _interopRequireWildcard(require("react"));
17
-
18
12
  var _CursorPlaceholderPlugin = require("./CursorPlaceholderPlugin");
19
-
20
13
  var _NodeNames = require("./NodeNames");
21
-
22
14
  var _MathEditor = _interopRequireDefault(require("./ui/MathEditor"));
23
-
24
15
  var _licitDocAttrsStep = require("@modusoperandi/licit-doc-attrs-step");
25
-
26
16
  var _licitUiCommands = require("@modusoperandi/licit-ui-commands");
27
-
28
17
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
-
30
18
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
31
-
32
19
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
33
-
34
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
35
-
20
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
21
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
22
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
36
23
  function insertMath(tr, schema, latex) {
37
24
  const {
38
25
  selection
39
26
  } = tr;
40
-
41
27
  if (!selection) {
42
28
  return tr;
43
29
  }
44
-
45
30
  const {
46
31
  from,
47
32
  to
48
33
  } = selection;
49
-
50
34
  if (from !== to) {
51
35
  return tr;
52
36
  }
53
-
54
37
  const image = schema.nodes[_NodeNames.MATH];
55
-
56
38
  if (!image) {
57
39
  return tr;
58
40
  }
59
-
60
41
  const attrs = {
61
42
  latex
62
43
  };
63
44
  const node = image.create(attrs, null, null);
64
-
65
45
  const frag = _prosemirrorModel.Fragment.from(node);
66
-
67
46
  tr = tr.insert(from, frag);
68
47
  return tr;
69
48
  }
70
-
71
49
  class MathEditCommand extends _licitDocAttrsStep.UICommand {
72
50
  constructor() {
73
51
  super(...arguments);
74
-
75
52
  _defineProperty(this, "_popUp", null);
76
-
77
53
  _defineProperty(this, "isEnabled", (state, view) => {
78
54
  const tr = state;
79
55
  const {
80
56
  selection
81
57
  } = tr;
82
-
83
58
  if (selection instanceof _prosemirrorState.TextSelection) {
84
59
  return selection.from === selection.to;
85
60
  }
86
-
87
61
  return false;
88
62
  });
89
-
90
63
  _defineProperty(this, "waitForUserInput", (state, dispatch, view, event) => {
91
64
  if (this._popUp) {
92
65
  return Promise.resolve(undefined);
93
66
  }
94
-
95
67
  if (dispatch) {
96
68
  dispatch((0, _CursorPlaceholderPlugin.showCursorPlaceholder)(state));
97
69
  }
98
-
99
70
  return new Promise(resolve => {
100
71
  const props = {
101
72
  runtime: view ? view.runtime : null,
@@ -112,7 +83,6 @@ class MathEditCommand extends _licitDocAttrsStep.UICommand {
112
83
  });
113
84
  });
114
85
  });
115
-
116
86
  _defineProperty(this, "executeWithUserInput", (state, dispatch, view, latex) => {
117
87
  if (dispatch) {
118
88
  const {
@@ -124,20 +94,15 @@ class MathEditCommand extends _licitDocAttrsStep.UICommand {
124
94
  } = state;
125
95
  tr = view ? (0, _CursorPlaceholderPlugin.hideCursorPlaceholder)(view.state) : tr;
126
96
  tr = tr.setSelection(selection);
127
-
128
97
  if (latex) {
129
98
  tr = insertMath(tr, schema, latex);
130
99
  }
131
-
132
100
  dispatch(tr);
133
101
  view && view.focus();
134
102
  }
135
-
136
103
  return false;
137
104
  });
138
105
  }
139
-
140
106
  }
141
-
142
107
  var _default = MathEditCommand;
143
108
  exports.default = _default;
@@ -4,22 +4,17 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _Types = require("./Types");
9
-
10
8
  function getAttrs(dom) {
11
9
  let align = dom.getAttribute('data-align') || dom.getAttribute('align');
12
-
13
10
  if (align) {
14
11
  align = /(left|right|center)/.test(align) ? align : null;
15
12
  }
16
-
17
13
  return {
18
14
  align,
19
15
  latex: dom.getAttribute('data-latex') || null
20
16
  };
21
17
  }
22
-
23
18
  const MathNodeSpec = {
24
19
  inline: true,
25
20
  attrs: {
@@ -39,7 +34,6 @@ const MathNodeSpec = {
39
34
  tag: 'span[data-latex]',
40
35
  getAttrs
41
36
  }],
42
-
43
37
  toDOM(node) {
44
38
  // Normally, the DOM structure of the math node is rendered by
45
39
  // `MathNodeView`. This method is only called when user selects a
@@ -50,18 +44,14 @@ const MathNodeSpec = {
50
44
  latex
51
45
  } = node.attrs;
52
46
  const domAttrs = {};
53
-
54
47
  if (align) {
55
48
  domAttrs.align = align;
56
49
  }
57
-
58
50
  if (latex) {
59
51
  domAttrs['data-latex'] = latex;
60
52
  }
61
-
62
53
  return ['span', domAttrs];
63
54
  }
64
-
65
55
  };
66
56
  var _default = MathNodeSpec;
67
57
  exports.default = _default;
@@ -4,17 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = exports.ATTRIBUTE_FOLLOWING = exports.ATTRIBUTE_COUNTER_RESET = void 0;
7
-
8
7
  var _prosemirrorModel = require("prosemirror-model");
9
-
10
8
  var _ListItemNodeSpec = require("./ListItemNodeSpec");
11
-
12
9
  var _NodeNames = require("./NodeNames");
13
-
14
10
  var _ParagraphNodeSpec = require("./ParagraphNodeSpec");
15
-
16
11
  var _Types = require("./Types");
17
-
18
12
  const ATTRIBUTE_COUNTER_RESET = 'data-counter-reset';
19
13
  exports.ATTRIBUTE_COUNTER_RESET = ATTRIBUTE_COUNTER_RESET;
20
14
  const ATTRIBUTE_FOLLOWING = 'data-following';
@@ -54,7 +48,6 @@ const OrderedListNodeSpec = {
54
48
  content: _NodeNames.LIST_ITEM + '+',
55
49
  parseDOM: [{
56
50
  tag: 'ol',
57
-
58
51
  getAttrs(dom) {
59
52
  const listStyleType = dom.getAttribute(_ListItemNodeSpec.ATTRIBUTE_LIST_STYLE_TYPE);
60
53
  const counterReset = dom.getAttribute(ATTRIBUTE_COUNTER_RESET) || undefined;
@@ -73,9 +66,7 @@ const OrderedListNodeSpec = {
73
66
  type
74
67
  };
75
68
  }
76
-
77
69
  }],
78
-
79
70
  toDOM(node) {
80
71
  const {
81
72
  start,
@@ -89,35 +80,26 @@ const OrderedListNodeSpec = {
89
80
  const attrs = {
90
81
  [_ParagraphNodeSpec.ATTRIBUTE_INDENT]: indent
91
82
  };
92
-
93
83
  if (counterReset === 'none') {
94
84
  attrs[ATTRIBUTE_COUNTER_RESET] = counterReset;
95
85
  }
96
-
97
86
  if (following) {
98
87
  attrs[ATTRIBUTE_FOLLOWING] = following;
99
88
  }
100
-
101
89
  if (listStyleType) {
102
90
  attrs[_ListItemNodeSpec.ATTRIBUTE_LIST_STYLE_TYPE] = listStyleType;
103
91
  }
104
-
105
92
  if (start !== 1) {
106
93
  attrs.start = start;
107
94
  }
108
-
109
95
  if (name) {
110
96
  attrs.name = name;
111
97
  }
112
-
113
98
  let htmlListStyleType = listStyleType;
114
-
115
99
  if (!htmlListStyleType || htmlListStyleType === 'decimal') {
116
100
  htmlListStyleType = AUTO_LIST_STYLE_TYPES[indent % AUTO_LIST_STYLE_TYPES.length];
117
101
  }
118
-
119
102
  const cssCounterName = `czi-counter-${indent}`;
120
-
121
103
  if ('x.x.x' === type) {
122
104
  if (_ParagraphNodeSpec.RESERVED_STYLE_NONE !== node.attrs.styleName) {
123
105
  attrs.style = buildStyleClass(indent, node.attrs.start);
@@ -127,23 +109,17 @@ const OrderedListNodeSpec = {
127
109
  } else {
128
110
  attrs.style = `--czi-counter-name: ${cssCounterName};` + `--czi-counter-reset: ${following ? 'none' : start - 1};` + `--czi-list-style-type: ${htmlListStyleType}`;
129
111
  }
130
-
131
112
  attrs.type = type;
132
113
  return ['ol', attrs, 0];
133
114
  }
134
-
135
115
  };
136
-
137
116
  function buildStyleClass(indent, start) {
138
117
  const cssCounterName = `czi-counter-${indent}`;
139
118
  let cssCounterReset = `czi-counter-${indent} ${start - 1} `;
140
-
141
119
  for (let index = 0; index < indent; index++) {
142
120
  cssCounterReset += `czi-counter-${index} 1 `;
143
121
  }
144
-
145
122
  return `--czi-counter-name: ${cssCounterName}; counter-reset: ${cssCounterReset};`;
146
123
  }
147
-
148
124
  var _default = OrderedListNodeSpec;
149
125
  exports.default = _default;
@@ -6,17 +6,11 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.RESERVED_STYLE_NONE_NUMBERING = exports.RESERVED_STYLE_NONE = exports.MIN_INDENT_LEVEL = exports.MAX_INDENT_LEVEL = exports.INDENT_MARGIN_PT_SIZE = exports.EMPTY_CSS_VALUE = exports.ATTRIBUTE_STYLE_LEVEL = exports.ATTRIBUTE_INDENT = void 0;
7
7
  exports.convertMarginLeftToIndentValue = convertMarginLeftToIndentValue;
8
8
  exports.toParagraphDOM = exports.getParagraphStyle = exports.getParagraphNodeAttrs = exports.default = void 0;
9
-
10
9
  var _convertToCSSPTValue = _interopRequireDefault(require("./convertToCSSPTValue"));
11
-
12
10
  var _toCSSLineSpacing = _interopRequireDefault(require("./ui/toCSSLineSpacing"));
13
-
14
11
  var _prosemirrorModel = require("prosemirror-model");
15
-
16
12
  var _Types = require("./Types");
17
-
18
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
-
20
14
  // This assumes that every 36pt maps to one indent level.
21
15
  const INDENT_MARGIN_PT_SIZE = 36;
22
16
  exports.INDENT_MARGIN_PT_SIZE = INDENT_MARGIN_PT_SIZE;
@@ -35,10 +29,11 @@ exports.RESERVED_STYLE_NONE_NUMBERING = RESERVED_STYLE_NONE_NUMBERING;
35
29
  const cssVal = new Set(['', '0%', '0pt', '0px']);
36
30
  const EMPTY_CSS_VALUE = cssVal;
37
31
  exports.EMPTY_CSS_VALUE = EMPTY_CSS_VALUE;
38
- const ALIGN_PATTERN = /(left|right|center|justify)/; // https://github.com/ProseMirror/prosemirror-schema-basic/blob/master/src/schema-basic.js
32
+ const ALIGN_PATTERN = /(left|right|center|justify)/;
33
+
34
+ // https://github.com/ProseMirror/prosemirror-schema-basic/blob/master/src/schema-basic.js
39
35
  // :: NodeSpec A plain paragraph textblock. Represented in the DOM
40
36
  // as a `<p>` element.
41
-
42
37
  const ParagraphNodeSpec = {
43
38
  attrs: {
44
39
  align: {
@@ -73,7 +68,6 @@ const ParagraphNodeSpec = {
73
68
  }],
74
69
  toDOM
75
70
  };
76
-
77
71
  function getAttrs(dom) {
78
72
  const {
79
73
  lineHeight,
@@ -85,11 +79,9 @@ function getAttrs(dom) {
85
79
  let align = dom.getAttribute('align') || textAlign || '';
86
80
  align = ALIGN_PATTERN.test(align) ? align : null;
87
81
  let indent = parseInt(dom.getAttribute(ATTRIBUTE_INDENT), 10);
88
-
89
82
  if (!indent && marginLeft) {
90
83
  indent = convertMarginLeftToIndentValue(marginLeft);
91
84
  }
92
-
93
85
  indent = indent || MIN_INDENT_LEVEL;
94
86
  const lineSpacing = lineHeight ? (0, _toCSSLineSpacing.default)(lineHeight) : null;
95
87
  const id = dom.getAttribute('id') || '';
@@ -102,38 +94,31 @@ function getAttrs(dom) {
102
94
  id
103
95
  };
104
96
  }
105
-
106
97
  function getStyle(attrs) {
107
98
  return getStyleEx(attrs.align, attrs.lineSpacing, attrs.paddingTop, attrs.paddingBottom);
108
99
  }
109
-
110
100
  function getStyleEx(align, lineSpacing, paddingTop, paddingBottom) {
111
101
  let style = '';
112
-
113
102
  if (align && align !== 'left') {
114
103
  style += `text-align: ${align};`;
115
104
  }
116
-
117
105
  if (lineSpacing) {
118
106
  const cssLineSpacing = (0, _toCSSLineSpacing.default)(lineSpacing);
119
- style += `line-height: ${cssLineSpacing};` + // This creates the local css variable `--czi-content-line-height`
107
+ style += `line-height: ${cssLineSpacing};` +
108
+ // This creates the local css variable `--czi-content-line-height`
120
109
  // that its children may apply.
121
110
  `--czi-content-line-height: ${cssLineSpacing};`;
122
111
  }
123
-
124
112
  if (paddingTop && !EMPTY_CSS_VALUE.has(paddingTop)) {
125
113
  style += `padding-top: ${paddingTop};`;
126
114
  }
127
-
128
115
  if (paddingBottom && !EMPTY_CSS_VALUE.has(paddingBottom)) {
129
116
  style += `padding-bottom: ${paddingBottom};`;
130
117
  }
131
-
132
118
  return {
133
119
  style
134
120
  };
135
121
  }
136
-
137
122
  function toDOM(node) {
138
123
  const {
139
124
  indent,
@@ -144,29 +129,23 @@ function toDOM(node) {
144
129
  style
145
130
  } = getStyle(node.attrs);
146
131
  style && (attrs.style = style);
147
-
148
132
  if (indent) {
149
133
  attrs[ATTRIBUTE_INDENT] = String(indent);
150
134
  }
151
-
152
135
  if (id) {
153
136
  attrs.id = id;
154
137
  }
155
-
156
138
  return ['p', attrs, 0];
157
139
  }
158
-
159
140
  const toParagraphDOM = toDOM;
160
141
  exports.toParagraphDOM = toParagraphDOM;
161
142
  const getParagraphNodeAttrs = getAttrs;
162
143
  exports.getParagraphNodeAttrs = getParagraphNodeAttrs;
163
144
  const getParagraphStyle = getStyle;
164
145
  exports.getParagraphStyle = getParagraphStyle;
165
-
166
146
  function convertMarginLeftToIndentValue(marginLeft) {
167
147
  const ptValue = (0, _convertToCSSPTValue.default)(marginLeft);
168
148
  return Math.min(Math.max(Math.floor(ptValue / INDENT_MARGIN_PT_SIZE), MIN_INDENT_LEVEL), MAX_INDENT_LEVEL);
169
149
  }
170
-
171
150
  var _default = ParagraphNodeSpec;
172
151
  exports.default = _default;