@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,9 +4,7 @@ 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
  const LinkMarkSpec = {
11
9
  attrs: {
12
10
  href: {
@@ -35,11 +33,9 @@ const LinkMarkSpec = {
35
33
  };
36
34
  }
37
35
  }],
38
-
39
36
  toDOM(node) {
40
37
  return ['a', node.attrs, 0];
41
38
  }
42
-
43
39
  };
44
40
  var _default = LinkMarkSpec;
45
41
  exports.default = _default;
@@ -4,72 +4,53 @@ 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 _MarkNames = require("./MarkNames");
15
-
16
11
  var _SelectionPlaceholderPlugin = require("./SelectionPlaceholderPlugin");
17
-
18
12
  var _licitUiCommands = require("@modusoperandi/licit-ui-commands");
19
-
20
13
  var _LinkURLEditor = _interopRequireDefault(require("./ui/LinkURLEditor"));
21
-
22
14
  var _licitDocAttrsStep = require("@modusoperandi/licit-doc-attrs-step");
23
-
24
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
-
26
- 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; }
27
-
16
+ 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; }
17
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
18
+ 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); }
28
19
  class LinkSetURLCommand extends _licitDocAttrsStep.UICommand {
29
20
  constructor() {
30
21
  super(...arguments);
31
-
32
22
  _defineProperty(this, "_popUp", null);
33
-
34
23
  _defineProperty(this, "isEnabled", state => {
35
24
  if (!(state.selection instanceof _prosemirrorState.TextSelection)) {
36
25
  // Could be a NodeSelection or CellSelection.
37
26
  return false;
38
27
  }
39
-
40
28
  const markType = state.schema.marks[_MarkNames.MARK_LINK];
41
-
42
29
  if (!markType) {
43
30
  return false;
44
31
  }
45
-
46
32
  const {
47
33
  from,
48
34
  to
49
35
  } = state.selection;
50
36
  return from < to;
51
37
  });
52
-
53
38
  _defineProperty(this, "waitForUserInput", (state, dispatch, view, event) => {
54
39
  if (this._popUp) {
55
40
  return Promise.resolve(undefined);
56
41
  }
57
-
58
42
  if (dispatch) {
59
43
  dispatch((0, _SelectionPlaceholderPlugin.showSelectionPlaceholder)(state));
60
44
  }
61
-
62
45
  const {
63
46
  doc,
64
47
  schema,
65
48
  selection
66
49
  } = state;
67
50
  const markType = schema.marks[_MarkNames.MARK_LINK];
68
-
69
51
  if (!markType) {
70
52
  return Promise.resolve(undefined);
71
53
  }
72
-
73
54
  const {
74
55
  from,
75
56
  to
@@ -90,7 +71,6 @@ class LinkSetURLCommand extends _licitDocAttrsStep.UICommand {
90
71
  });
91
72
  });
92
73
  });
93
-
94
74
  _defineProperty(this, "executeWithUserInput", (state, dispatch, view, href) => {
95
75
  if (dispatch) {
96
76
  const {
@@ -102,7 +82,6 @@ class LinkSetURLCommand extends _licitDocAttrsStep.UICommand {
102
82
  } = state;
103
83
  tr = view ? (0, _SelectionPlaceholderPlugin.hideSelectionPlaceholder)(view.state) : tr;
104
84
  tr = tr.setSelection(selection);
105
-
106
85
  if (href !== undefined) {
107
86
  const markType = schema.marks[_MarkNames.MARK_LINK];
108
87
  const attrs = href ? {
@@ -110,16 +89,12 @@ class LinkSetURLCommand extends _licitDocAttrsStep.UICommand {
110
89
  } : null;
111
90
  tr = (0, _licitUiCommands.applyMark)(tr.setSelection(state.selection), schema, markType, attrs);
112
91
  }
113
-
114
92
  dispatch(tr);
115
93
  }
116
-
117
94
  view && view.focus();
118
95
  return true;
119
96
  });
120
97
  }
121
-
122
98
  }
123
-
124
99
  var _default = LinkSetURLCommand;
125
100
  exports.default = _default;
@@ -4,72 +4,51 @@ 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 _prosemirrorView = require("prosemirror-view");
11
-
12
9
  var _MarkNames = require("./MarkNames");
13
-
14
10
  var _SelectionPlaceholderPlugin = require("./SelectionPlaceholderPlugin");
15
-
16
11
  var _licitUiCommands = require("@modusoperandi/licit-ui-commands");
17
-
18
12
  var _lookUpElement = _interopRequireDefault(require("./lookUpElement"));
19
-
20
13
  var _LinkTooltip = _interopRequireDefault(require("./ui/LinkTooltip"));
21
-
22
14
  var _LinkURLEditor = _interopRequireDefault(require("./ui/LinkURLEditor"));
23
-
24
15
  require("@modusoperandi/licit-ui-commands/dist/ui/czi-pop-up.css");
25
-
26
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
-
28
- 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; }
29
-
17
+ 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; }
18
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
19
+ 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); }
30
20
  // https://prosemirror.net/examples/tooltip/
31
21
  const SPEC = {
32
22
  // [FS] IRAD-1005 2020-07-07
33
23
  // Upgrade outdated packages.
34
24
  key: new _prosemirrorState.PluginKey('LinkTooltipPlugin'),
35
-
36
25
  view(editorView) {
37
26
  return new LinkTooltipView(editorView);
38
27
  }
39
-
40
28
  };
41
-
42
29
  class LinkTooltipPlugin extends _prosemirrorState.Plugin {
43
30
  constructor() {
44
31
  super(SPEC);
45
32
  }
46
-
47
33
  }
48
-
49
34
  class LinkTooltipView {
50
35
  constructor(editorView) {
51
36
  _defineProperty(this, "_anchorEl", null);
52
-
53
37
  _defineProperty(this, "_popup", null);
54
-
55
38
  _defineProperty(this, "_editor", null);
56
-
57
39
  _defineProperty(this, "_onCancel", view => {
58
40
  this.destroy();
59
41
  view.focus();
60
42
  });
61
-
62
43
  _defineProperty(this, "_onClose", () => {
63
44
  this._anchorEl = null;
64
45
  this._editor = null;
65
46
  this._popup = null;
66
47
  });
67
-
68
48
  _defineProperty(this, "_onEdit", view => {
69
49
  if (this._editor) {
70
50
  return;
71
51
  }
72
-
73
52
  const {
74
53
  state
75
54
  } = view;
@@ -84,74 +63,61 @@ class LinkTooltipView {
84
63
  } = selection;
85
64
  const markType = schema.marks[_MarkNames.MARK_LINK];
86
65
  const result = (0, _licitUiCommands.findNodesWithSameMark)(doc, from, to, markType);
87
-
88
66
  if (!result) {
89
67
  return;
90
68
  }
91
-
92
69
  const href = result.mark.attrs.href;
93
70
  this._editor = (0, _licitUiCommands.createPopUp)(_LinkURLEditor.default, {
94
71
  href
95
72
  }, {
96
73
  onClose: value => {
97
74
  this._editor = null;
98
-
99
75
  this._onEditEnd(view, selection, value);
100
76
  }
101
77
  });
102
78
  });
103
-
104
79
  _defineProperty(this, "_onRemove", view => {
105
80
  this._onEditEnd(view, view.state.selection, null);
106
81
  });
107
-
108
82
  _defineProperty(this, "_onEditEnd", (view, initialSelection, href) => {
109
83
  const {
110
84
  state,
111
85
  dispatch
112
86
  } = view;
113
87
  let tr = (0, _SelectionPlaceholderPlugin.hideSelectionPlaceholder)(state);
114
-
115
88
  if (href !== undefined) {
116
89
  const {
117
90
  schema
118
91
  } = state;
119
92
  const markType = schema.marks[_MarkNames.MARK_LINK];
120
-
121
93
  if (markType) {
122
94
  const result = (0, _licitUiCommands.findNodesWithSameMark)(tr.doc, initialSelection.from, initialSelection.to, markType);
123
-
124
95
  if (result) {
125
96
  const linkSelection = _prosemirrorState.TextSelection.create(tr.doc, result.from.pos, result.to.pos + 1);
126
-
127
97
  tr = tr.setSelection(linkSelection);
128
98
  const attrs = href ? {
129
99
  href
130
100
  } : null;
131
- tr = (0, _licitUiCommands.applyMark)(tr, schema, markType, attrs); // [FS] IRAD-1005 2020-07-09
101
+ tr = (0, _licitUiCommands.applyMark)(tr, schema, markType, attrs);
102
+
103
+ // [FS] IRAD-1005 2020-07-09
132
104
  // Upgrade outdated packages.
133
105
  // reset selection to original using the latest doc.
134
-
135
106
  const origSelection = _prosemirrorState.TextSelection.create(tr.doc, initialSelection.from, initialSelection.to);
136
-
137
107
  tr = tr.setSelection(origSelection);
138
108
  }
139
109
  }
140
110
  }
141
-
142
111
  dispatch(tr);
143
112
  view.focus();
144
113
  });
145
-
146
114
  this.update(editorView, null);
147
115
  }
148
-
149
116
  update(view, lastState) {
150
117
  if (view.readOnly) {
151
118
  this.destroy();
152
119
  return;
153
120
  }
154
-
155
121
  const {
156
122
  state
157
123
  } = view;
@@ -161,36 +127,28 @@ class LinkTooltipView {
161
127
  schema
162
128
  } = state;
163
129
  const markType = schema.marks[_MarkNames.MARK_LINK];
164
-
165
130
  if (!markType) {
166
131
  return;
167
132
  }
168
-
169
133
  const {
170
134
  from,
171
135
  to
172
136
  } = selection;
173
137
  const result = (0, _licitUiCommands.findNodesWithSameMark)(doc, from, to, markType);
174
-
175
138
  if (!result) {
176
139
  this.destroy();
177
140
  return;
178
141
  }
179
-
180
142
  const domFound = view.domAtPos(from);
181
-
182
143
  if (!domFound) {
183
144
  this.destroy();
184
145
  return;
185
146
  }
186
-
187
147
  const anchorEl = (0, _lookUpElement.default)(domFound.node, el => el.nodeName === 'A');
188
-
189
148
  if (!anchorEl) {
190
149
  this.destroy();
191
150
  return;
192
151
  }
193
-
194
152
  const popup = this._popup;
195
153
  const viewPops = {
196
154
  editorState: state,
@@ -200,7 +158,6 @@ class LinkTooltipView {
200
158
  onEdit: this._onEdit,
201
159
  onRemove: this._onRemove
202
160
  };
203
-
204
161
  if (popup && anchorEl === this._anchorEl) {
205
162
  popup.update(viewPops);
206
163
  } else {
@@ -214,13 +171,10 @@ class LinkTooltipView {
214
171
  });
215
172
  }
216
173
  }
217
-
218
174
  destroy() {
219
175
  this._popup && this._popup.close();
220
176
  this._editor && this._editor.close();
221
177
  }
222
-
223
178
  }
224
-
225
179
  var _default = LinkTooltipPlugin;
226
180
  exports.default = _default;
@@ -4,72 +4,54 @@ 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 _prosemirrorUtils = require("prosemirror-utils");
15
-
16
11
  var _prosemirrorView = require("prosemirror-view");
17
-
18
12
  var _NodeNames = require("./NodeNames");
19
-
20
13
  var _licitDocAttrsStep = require("@modusoperandi/licit-doc-attrs-step");
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
  // This handles the case when user press SHIFT + ENTER key to insert a new line
25
18
  // into list item.
26
19
  function insertNewLine(tr, schema) {
27
20
  const {
28
21
  selection
29
22
  } = tr;
30
-
31
23
  if (!selection) {
32
24
  return tr;
33
25
  }
34
-
35
26
  const {
36
27
  from,
37
28
  empty
38
29
  } = selection;
39
-
40
30
  if (!empty) {
41
31
  return tr;
42
32
  }
43
-
44
33
  const br = schema.nodes[_NodeNames.HARD_BREAK];
45
-
46
34
  if (!br) {
47
35
  return tr;
48
36
  }
49
-
50
37
  const blockquote = schema.nodes[_NodeNames.LIST_ITEM];
51
38
  const result = (0, _prosemirrorUtils.findParentNodeOfType)(blockquote)(selection);
52
-
53
39
  if (!result) {
54
40
  return tr;
55
41
  }
56
-
57
42
  tr = tr.insert(from, _prosemirrorModel.Fragment.from(br.create()));
58
43
  tr = tr.setSelection(_prosemirrorState.TextSelection.create(tr.doc, from + 1, from + 1));
59
44
  return tr;
60
45
  }
61
-
62
46
  class ListItemInsertNewLineCommand extends _licitDocAttrsStep.UICommand {
63
47
  constructor() {
64
48
  super(...arguments);
65
-
66
49
  _defineProperty(this, "execute", (state, dispatch, view) => {
67
50
  const {
68
51
  schema,
69
52
  selection
70
53
  } = state;
71
54
  const tr = insertNewLine(state.tr.setSelection(selection), schema);
72
-
73
55
  if (tr.docChanged) {
74
56
  dispatch && dispatch(tr);
75
57
  return true;
@@ -78,8 +60,6 @@ class ListItemInsertNewLineCommand extends _licitDocAttrsStep.UICommand {
78
60
  }
79
61
  });
80
62
  }
81
-
82
63
  }
83
-
84
64
  var _default = ListItemInsertNewLineCommand;
85
65
  exports.default = _default;
@@ -4,203 +4,157 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _nullthrows = _interopRequireDefault(require("nullthrows"));
9
-
10
8
  var _prosemirrorModel = require("prosemirror-model");
11
-
12
9
  var _prosemirrorState = require("prosemirror-state");
13
-
14
10
  var _prosemirrorTransform = require("prosemirror-transform");
15
-
16
11
  var _prosemirrorUtils = require("prosemirror-utils");
17
-
18
12
  var _prosemirrorView = require("prosemirror-view");
19
-
20
13
  var _NodeNames = require("./NodeNames");
21
-
22
14
  var _nodeAt = _interopRequireDefault(require("./nodeAt"));
23
-
24
15
  var _licitDocAttrsStep = require("@modusoperandi/licit-doc-attrs-step");
25
-
26
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
-
28
- 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; }
29
-
17
+ 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; }
18
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
19
+ 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); }
30
20
  function mergeListItemUp(tr, schema) {
31
21
  // This merge a list item to is previous list item of the selection is at the
32
22
  // beginning of the list item.
33
23
  const {
34
24
  selection
35
25
  } = tr;
36
-
37
26
  if (!selection) {
38
27
  return tr;
39
28
  }
40
-
41
29
  const nodeType = schema.nodes[_NodeNames.LIST_ITEM];
42
-
43
30
  if (!nodeType) {
44
31
  return tr;
45
32
  }
46
-
47
33
  const {
48
34
  from,
49
35
  empty
50
36
  } = selection;
51
-
52
37
  if (!empty) {
53
38
  // Selection is collapsed.
54
39
  return tr;
55
40
  }
56
-
57
41
  const result = (0, _prosemirrorUtils.findParentNodeOfType)(nodeType)(selection);
58
-
59
42
  if (!result) {
60
43
  return tr;
61
44
  }
62
-
63
45
  const {
64
46
  pos,
65
47
  node
66
48
  } = result;
67
-
68
49
  if (from !== pos + 2) {
69
50
  // Selection is not at the begining of the list item.
70
51
  return tr;
71
52
  }
72
-
73
53
  const $pos = tr.doc.resolve(pos);
74
54
  const prevNode = $pos.nodeBefore;
75
-
76
55
  if (!prevNode || prevNode.type !== nodeType) {
77
56
  return tr;
78
57
  }
79
-
80
58
  if (node.childCount !== 1) {
81
59
  // list item should only have one child (paragraph).
82
60
  return tr;
83
61
  }
84
-
85
62
  const paragraphNode = node.firstChild;
86
- const textNode = schema.text(' '); // Delete the list item
87
-
88
- tr = tr.delete(pos - 2, pos + node.nodeSize); // Append extra space character to its previous list item.
89
-
90
- tr = tr.insert(pos - 2, _prosemirrorModel.Fragment.from(textNode)); // Move the content to its previous list item.
63
+ const textNode = schema.text(' ');
91
64
 
65
+ // Delete the list item
66
+ tr = tr.delete(pos - 2, pos + node.nodeSize);
67
+ // Append extra space character to its previous list item.
68
+ tr = tr.insert(pos - 2, _prosemirrorModel.Fragment.from(textNode));
69
+ // Move the content to its previous list item.
92
70
  tr = tr.insert(pos - 1, _prosemirrorModel.Fragment.from(paragraphNode.content));
93
71
  tr = tr.setSelection(_prosemirrorState.TextSelection.create(tr.doc, pos - 1, pos - 1));
94
72
  return tr;
95
73
  }
96
-
97
74
  function mergeListItemDown(tr, schema) {
98
75
  // This merge a list item to is next list item of the selection is at the
99
76
  // beginning of the list item.
100
77
  const {
101
78
  selection
102
79
  } = tr;
103
-
104
80
  if (!selection) {
105
81
  return tr;
106
82
  }
107
-
108
83
  const listItem = schema.nodes[_NodeNames.LIST_ITEM];
109
-
110
84
  if (!listItem) {
111
85
  return tr;
112
86
  }
113
-
114
87
  const {
115
88
  from,
116
89
  empty
117
90
  } = selection;
118
-
119
91
  if (!empty) {
120
92
  // Selection is collapsed.
121
93
  return tr;
122
94
  }
123
-
124
95
  const result = (0, _prosemirrorUtils.findParentNodeOfType)(listItem)(selection);
125
-
126
96
  if (!result) {
127
97
  return tr;
128
98
  }
129
-
130
99
  const {
131
100
  pos,
132
101
  node
133
102
  } = result;
134
-
135
103
  if (from !== pos + node.content.size) {
136
104
  // Selection is not at the begining of the list item.
137
105
  return tr;
138
106
  }
139
-
140
107
  const $pos = tr.doc.resolve(pos);
141
108
  const list = $pos.parent.type;
142
109
  const listResult = (0, _prosemirrorUtils.findParentNodeOfType)(list)(selection);
143
-
144
110
  if (!listResult) {
145
111
  return tr;
146
112
  }
147
-
148
113
  const nextFrom = pos + node.nodeSize;
149
114
  let nextNode = (0, _nodeAt.default)(tr.doc, nextFrom);
150
115
  let deleteFrom = nextFrom;
151
-
152
116
  if (listResult.start + listResult.node.content.size === nextFrom) {
153
117
  // It's at the end of the last list item. It shall bring the content of the
154
118
  // block after the list.
155
119
  nextNode = (0, _nodeAt.default)(tr.doc, nextFrom + 1);
156
120
  deleteFrom += 1;
157
121
  }
158
-
159
122
  if (!nextNode) {
160
123
  return tr;
161
124
  }
162
-
163
125
  let nextContent;
164
-
165
126
  switch (nextNode.type) {
166
127
  case listItem:
167
128
  // List item should only have one child (paragraph).
168
129
  const paragraphNode = (0, _nullthrows.default)(nextNode.firstChild);
169
130
  nextContent = _prosemirrorModel.Fragment.from(paragraphNode.content);
170
131
  break;
171
-
172
132
  case schema.nodes[_NodeNames.HEADING]:
173
133
  case schema.nodes[_NodeNames.PARAGRAPH]:
174
134
  // Will bring in the content of the next block.
175
135
  nextContent = _prosemirrorModel.Fragment.from(nextNode.content);
176
136
  break;
177
137
  }
178
-
179
138
  if (!nextContent) {
180
139
  return tr;
181
140
  }
182
-
183
- const textNode = schema.text(' '); // Delete the next node.
184
-
185
- tr = tr.delete(deleteFrom, deleteFrom + nextNode.nodeSize); // Append extra space character to its previous list item.
186
-
187
- tr = tr.insert(nextFrom - 2, nextContent); // Move the content to the list item.
188
-
141
+ const textNode = schema.text(' ');
142
+ // Delete the next node.
143
+ tr = tr.delete(deleteFrom, deleteFrom + nextNode.nodeSize);
144
+ // Append extra space character to its previous list item.
145
+ tr = tr.insert(nextFrom - 2, nextContent);
146
+ // Move the content to the list item.
189
147
  tr = tr.insert(nextFrom - 2, _prosemirrorModel.Fragment.from(textNode));
190
148
  tr = tr.setSelection(_prosemirrorState.TextSelection.create(tr.doc, nextFrom - 2, nextFrom - 2));
191
149
  return tr;
192
150
  }
193
-
194
151
  class ListItemMergeCommand extends _licitDocAttrsStep.UICommand {
195
152
  constructor(_direction) {
196
153
  super();
197
-
198
154
  _defineProperty(this, "_direction", '');
199
-
200
155
  _defineProperty(this, "isActive", state => {
201
156
  return false;
202
157
  });
203
-
204
158
  _defineProperty(this, "execute", (state, dispatch, view) => {
205
159
  const {
206
160
  selection,
@@ -210,13 +164,11 @@ class ListItemMergeCommand extends _licitDocAttrsStep.UICommand {
210
164
  tr
211
165
  } = state;
212
166
  const direction = this._direction;
213
-
214
167
  if (direction === 'down') {
215
168
  tr = mergeListItemDown(tr.setSelection(selection), schema);
216
169
  } else if (direction === 'up') {
217
170
  tr = mergeListItemUp(tr.setSelection(selection), schema);
218
171
  }
219
-
220
172
  if (tr.docChanged) {
221
173
  dispatch && dispatch(tr);
222
174
  return true;
@@ -224,11 +176,8 @@ class ListItemMergeCommand extends _licitDocAttrsStep.UICommand {
224
176
  return false;
225
177
  }
226
178
  });
227
-
228
179
  this._direction = _direction;
229
180
  }
230
-
231
181
  }
232
-
233
182
  var _default = ListItemMergeCommand;
234
183
  exports.default = _default;