@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,64 +4,42 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _prosemirrorCommands = require("prosemirror-commands");
9
-
10
8
  var _prosemirrorDropcursor = require("prosemirror-dropcursor");
11
-
12
9
  var _prosemirrorGapcursor = require("prosemirror-gapcursor");
13
-
14
10
  var _prosemirrorHistory = require("prosemirror-history");
15
-
16
11
  var _prosemirrorKeymap = require("prosemirror-keymap");
17
-
18
12
  var _prosemirrorModel = require("prosemirror-model");
19
-
20
13
  var _prosemirrorState = require("prosemirror-state");
21
-
22
14
  var _ContentPlaceholderPlugin = _interopRequireDefault(require("./ContentPlaceholderPlugin"));
23
-
24
15
  var _CursorPlaceholderPlugin = _interopRequireDefault(require("./CursorPlaceholderPlugin"));
25
-
26
16
  var _EditorPageLayoutPlugin = _interopRequireDefault(require("./EditorPageLayoutPlugin"));
27
-
28
17
  var _ImageUploadPlaceholderPlugin = _interopRequireDefault(require("./ImageUploadPlaceholderPlugin"));
29
-
30
18
  var _LinkTooltipPlugin = _interopRequireDefault(require("./LinkTooltipPlugin"));
31
-
32
19
  var _SelectionPlaceholderPlugin = _interopRequireDefault(require("./SelectionPlaceholderPlugin"));
33
-
34
20
  var _TablePlugins = _interopRequireDefault(require("./TablePlugins"));
35
-
36
21
  var _buildInputRules = _interopRequireDefault(require("./buildInputRules"));
37
-
38
22
  var _createEditorKeyMap = _interopRequireDefault(require("./createEditorKeyMap"));
39
-
40
23
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
41
-
42
- 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; }
43
-
24
+ 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; }
25
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
26
+ 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); }
44
27
  // Creates the default plugin for the editor.
45
28
  class DefaultEditorPlugins {
46
29
  constructor(schema) {
47
30
  _defineProperty(this, "plugins", void 0);
48
-
49
31
  this.plugins = [new _ContentPlaceholderPlugin.default(), new _CursorPlaceholderPlugin.default(), new _EditorPageLayoutPlugin.default(), new _ImageUploadPlaceholderPlugin.default(), new _LinkTooltipPlugin.default(), new _SelectionPlaceholderPlugin.default(), this.setPluginKey((0, _buildInputRules.default)(schema), 'InputRules'), this.setPluginKey((0, _prosemirrorDropcursor.dropCursor)(), 'DropCursor'), this.setPluginKey((0, _prosemirrorGapcursor.gapCursor)(), 'GapCursor'), (0, _prosemirrorHistory.history)(), this.setPluginKey((0, _prosemirrorKeymap.keymap)((0, _createEditorKeyMap.default)()), 'EditorKeyMap'), this.setPluginKey((0, _prosemirrorKeymap.keymap)(_prosemirrorCommands.baseKeymap), 'BaseKeymap')].concat(_TablePlugins.default);
50
- } // [FS] IRAD-1005 2020-07-07
32
+ }
33
+ // [FS] IRAD-1005 2020-07-07
51
34
  // Upgrade outdated packages.
52
35
  // set plugin keys so that to avoid duplicate key error when keys are assigned automatically.
53
-
54
-
55
36
  setPluginKey(plugin, key) {
56
37
  plugin.spec.key = new _prosemirrorState.PluginKey(key + 'Plugin');
57
38
  plugin.key = plugin.spec.key.key;
58
39
  return plugin;
59
40
  }
60
-
61
41
  get() {
62
42
  return this.plugins;
63
43
  }
64
-
65
44
  }
66
-
67
45
  exports.default = DefaultEditorPlugins;
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = buildInputRules;
7
-
8
7
  var _prosemirrorInputrules = require("prosemirror-inputrules");
9
-
10
8
  var _prosemirrorModel = require("prosemirror-model");
11
-
12
9
  var _blockQuoteInputRule = _interopRequireDefault(require("./blockQuoteInputRule"));
13
-
14
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
11
  // This file is forked from
17
12
  // // https://github.com/ProseMirror/prosemirror-example-setup/blob/master/src/inputrules.js
18
13
  // : (NodeType) → InputRule
@@ -22,62 +17,55 @@ function orderedListRule(nodeType) {
22
17
  return (0, _prosemirrorInputrules.wrappingInputRule)(/^(\d+)\.\s$/, nodeType, match => ({
23
18
  order: +match[1]
24
19
  }), (match, node) => node.childCount + node.attrs.order == +match[1]);
25
- } // : (NodeType) → InputRule
20
+ }
21
+
22
+ // : (NodeType) → InputRule
26
23
  // Given a list node type, returns an input rule that turns a bullet
27
24
  // (dash, plush, or asterisk) at the start of a textblock into a
28
25
  // bullet list.
29
-
30
-
31
26
  function bulletListRule(nodeType) {
32
27
  return (0, _prosemirrorInputrules.wrappingInputRule)(/^\s*([-+*])\s$/, nodeType);
33
- } // : (NodeType) → InputRule
28
+ }
29
+
30
+ // : (NodeType) → InputRule
34
31
  // Given a code block node type, returns an input rule that turns a
35
32
  // textblock starting with three backticks into a code block.
36
-
37
-
38
33
  function codeBlockRule(nodeType) {
39
34
  return (0, _prosemirrorInputrules.textblockTypeInputRule)(/^```$/, nodeType);
40
- } // : (NodeType, number) → InputRule
35
+ }
36
+
37
+ // : (NodeType, number) → InputRule
41
38
  // Given a node type and a maximum level, creates an input rule that
42
39
  // turns up to that number of `#` characters followed by a space at
43
40
  // the start of a textblock into a heading whose level corresponds to
44
41
  // the number of `#` signs.
45
-
46
-
47
42
  function headingRule(nodeType, maxLevel) {
48
43
  return (0, _prosemirrorInputrules.textblockTypeInputRule)(new RegExp('^(#{1,' + maxLevel + '})\\s$'), nodeType, match => ({
49
44
  level: match[1].length
50
45
  }));
51
- } // : (Schema) → Plugin
46
+ }
47
+
48
+ // : (Schema) → Plugin
52
49
  // A set of input rules for creating the basic block quotes, lists,
53
50
  // code blocks, and heading.
54
-
55
-
56
51
  function buildInputRules(schema) {
57
52
  const rules = _prosemirrorInputrules.smartQuotes.concat(_prosemirrorInputrules.ellipsis, _prosemirrorInputrules.emDash);
58
-
59
53
  let type;
60
-
61
54
  if (schema.nodes.blockquote) {
62
55
  rules.push((0, _blockQuoteInputRule.default)());
63
56
  }
64
-
65
57
  if (type = schema.nodes.ordered_list) {
66
58
  rules.push(orderedListRule(type));
67
59
  }
68
-
69
60
  if (type = schema.nodes.bullet_list) {
70
61
  rules.push(bulletListRule(type));
71
62
  }
72
-
73
63
  if (type = schema.nodes.code_block) {
74
64
  rules.push(codeBlockRule(type));
75
65
  }
76
-
77
66
  if (type = schema.nodes.heading) {
78
67
  rules.push(headingRule(type, 6));
79
68
  }
80
-
81
69
  return (0, _prosemirrorInputrules.inputRules)({
82
70
  rules
83
71
  });
@@ -4,64 +4,44 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _prosemirrorTransform = require("prosemirror-transform");
9
-
10
8
  var _prosemirrorModel = require("prosemirror-model");
11
-
12
9
  var _prosemirrorState = require("prosemirror-state");
13
-
14
10
  var _SimpleConnector = _interopRequireWildcard(require("./SimpleConnector"));
15
-
16
11
  var _EditorConnection = _interopRequireDefault(require("./EditorConnection"));
17
-
18
12
  var _Reporter = _interopRequireDefault(require("./Reporter"));
19
-
20
13
  var _reactDom = _interopRequireDefault(require("react-dom"));
21
-
22
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
-
24
15
  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); }
25
-
26
16
  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; }
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
  class CollabConnector extends _SimpleConnector.default {
31
21
  constructor(editorState, setState, config, _schema, plugins, onReady) {
32
22
  super(editorState, setState);
33
-
34
23
  _defineProperty(this, "_clientID", void 0);
35
-
36
24
  _defineProperty(this, "_connected", void 0);
37
-
38
25
  _defineProperty(this, "_connection", void 0);
39
-
40
26
  _defineProperty(this, "_docID", void 0);
41
-
42
27
  _defineProperty(this, "_stepKeys", void 0);
43
-
44
28
  _defineProperty(this, "cleanUp", () => {
45
29
  // remove collab plugin
46
30
  if (this._connection) {
47
31
  const cpIdx = this._editorState.plugins.findIndex(plugin => {
48
32
  return 'collab$' === plugin.spec.key.key;
49
33
  });
50
-
51
34
  if (-1 != cpIdx) {
52
35
  this._editorState.plugins.splice(cpIdx, 1);
53
36
  }
54
-
55
37
  this._connection.close();
56
38
  }
57
39
  });
58
-
59
40
  _defineProperty(this, "onEdit", transaction => {
60
41
  if (!this._connection.ready) {
61
42
  console.warn('not ready');
62
43
  return;
63
44
  }
64
-
65
45
  _reactDom.default.unstable_batchedUpdates(() => {
66
46
  this._connection.dispatch({
67
47
  type: 'transaction',
@@ -69,22 +49,20 @@ class CollabConnector extends _SimpleConnector.default {
69
49
  });
70
50
  });
71
51
  });
72
-
73
52
  _defineProperty(this, "updateSchema", (schema, data) => {
74
53
  this._connection.updateSchema(schema, data, this._dataDefined);
75
54
  });
76
-
77
55
  _defineProperty(this, "updateContent", data => {
78
56
  this._connection.start(data, this._dataDefined);
79
57
  });
80
-
81
58
  const {
82
59
  docID,
83
60
  collabServiceURL
84
61
  } = config;
85
- this._docID = docID; // [FS] IRAD-1553 2021-08-26
86
- // Configurable Collaboration Service URL.
62
+ this._docID = docID;
87
63
 
64
+ // [FS] IRAD-1553 2021-08-26
65
+ // Configurable Collaboration Service URL.
88
66
  const url = collabServiceURL + '/docs/' + docID;
89
67
  this._connection = new _EditorConnection.default(onReady, new _Reporter.default(), url, plugins, _schema);
90
68
  this._connection.view = {
@@ -95,8 +73,6 @@ class CollabConnector extends _SimpleConnector.default {
95
73
  }
96
74
  };
97
75
  }
98
-
99
76
  }
100
-
101
77
  var _default = CollabConnector;
102
78
  exports.default = _default;
@@ -4,70 +4,44 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _prosemirrorCollab = require("prosemirror-collab");
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 _uuid = _interopRequireDefault(require("../uuid"));
17
-
18
12
  var _http = require("./http");
19
-
20
13
  var _prosemirrorModel = require("prosemirror-model");
21
-
22
14
  var _flatted = require("flatted");
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
  function badVersion(err) {
29
20
  return err.status == 400 && /invalid version/i.test(String(err));
30
21
  }
31
-
32
22
  class State {
33
23
  constructor(edit, comm) {
34
24
  _defineProperty(this, "edit", void 0);
35
-
36
25
  _defineProperty(this, "comm", void 0);
37
-
38
26
  this.edit = edit;
39
27
  this.comm = comm;
40
28
  }
41
-
42
29
  }
43
-
44
30
  class EditorConnection {
45
31
  constructor(onReady, report, url, plugins, defaultSchema) {
46
32
  _defineProperty(this, "backOff", void 0);
47
-
48
33
  _defineProperty(this, "onReady", void 0);
49
-
50
34
  _defineProperty(this, "ready", void 0);
51
-
52
35
  _defineProperty(this, "report", void 0);
53
-
54
36
  _defineProperty(this, "request", void 0);
55
-
56
37
  _defineProperty(this, "state", void 0);
57
-
58
38
  _defineProperty(this, "url", void 0);
59
-
60
39
  _defineProperty(this, "view", void 0);
61
-
62
40
  _defineProperty(this, "schema", void 0);
63
-
64
41
  _defineProperty(this, "plugins", void 0);
65
-
66
42
  _defineProperty(this, "defaultSchema", void 0);
67
-
68
43
  _defineProperty(this, "dispatch", action => {
69
44
  let newEditState = null;
70
-
71
45
  if (action.type == 'loaded') {
72
46
  const editState = _prosemirrorState.EditorState.create({
73
47
  doc: action.doc,
@@ -76,7 +50,6 @@ class EditorConnection {
76
50
  version: action.version
77
51
  })])
78
52
  });
79
-
80
53
  this.state = new State(editState, 'poll');
81
54
  this.ready = true;
82
55
  this.onReady(editState);
@@ -98,15 +71,12 @@ class EditorConnection {
98
71
  } else if (action.type == 'transaction') {
99
72
  newEditState = this.state.edit ? this.state.edit.apply(action.transaction) : null;
100
73
  }
101
-
102
74
  if (newEditState) {
103
75
  let sendable;
104
-
105
76
  if (newEditState.doc.content.size > 4000000000000) {
106
77
  if (this.state.comm !== 'detached') {
107
78
  this.report.failure('Document too big. Detached.');
108
79
  }
109
-
110
80
  this.state = new State(newEditState, 'detached');
111
81
  } else if ((this.state.comm == 'poll' || action.requestDone) && (sendable = this.sendable(newEditState))) {
112
82
  this.closeRequest();
@@ -118,14 +88,13 @@ class EditorConnection {
118
88
  } else {
119
89
  this.state = new State(newEditState, this.state.comm);
120
90
  }
121
- } // Sync the editor with this.state.edit
122
-
91
+ }
123
92
 
93
+ // Sync the editor with this.state.edit
124
94
  if (this.state.edit && this.view) {
125
95
  this.view.updateState(this.state.edit);
126
96
  }
127
97
  });
128
-
129
98
  this.schema = null;
130
99
  this.report = report;
131
100
  this.url = url;
@@ -138,13 +107,14 @@ class EditorConnection {
138
107
  this.onReady = onReady;
139
108
  this.plugins = plugins;
140
109
  this.defaultSchema = defaultSchema;
141
- } // [FS] IRAD-1040 2020-09-08
142
-
110
+ }
143
111
 
112
+ // [FS] IRAD-1040 2020-09-08
144
113
  getEffectiveSchema() {
145
114
  return null != this.schema ? this.schema : this.defaultSchema;
146
- } // All state changes go through this
115
+ }
147
116
 
117
+ // All state changes go through this
148
118
 
149
119
  dispatchData(data) {
150
120
  this.report.success();
@@ -155,9 +125,9 @@ class EditorConnection {
155
125
  version: data.version,
156
126
  users: data.users
157
127
  });
158
- } // Load the document from the server and start up
159
-
128
+ }
160
129
 
130
+ // Load the document from the server and start up
161
131
  start(input, dataDefined) {
162
132
  const query = '?dataDefined=' + dataDefined;
163
133
  this.run(input ? (0, _http.PUT)(this.url + query, JSON.stringify(input), 'application/json') : (0, _http.GET)(this.url, 'application/json')).then(data => {
@@ -173,19 +143,18 @@ class EditorConnection {
173
143
  }, err => {
174
144
  this.report.failure(err);
175
145
  });
176
- } // Send a request for events that have happened since the version
146
+ }
147
+
148
+ // Send a request for events that have happened since the version
177
149
  // of the document that the client knows about. This request waits
178
150
  // for a new version of the document to be created if the client
179
151
  // is already up-to-date.
180
-
181
-
182
152
  poll() {
183
153
  const query = 'version=' + (0, _prosemirrorCollab.getVersion)(this.state.edit);
184
154
  this.run((0, _http.GET)(this.url + '/events?' + query)).then(data => {
185
155
  this.report.success();
186
156
  data = JSON.parse(data);
187
157
  this.backOff = 0;
188
-
189
158
  if (data.steps && data.steps.length) {
190
159
  const tr = (0, _prosemirrorCollab.receiveTransaction)(this.state.edit, data.steps.map(j => _prosemirrorTransform.Step.fromJSON(this.getEffectiveSchema(), j)), data.clientIDs);
191
160
  this.dispatch({
@@ -211,20 +180,17 @@ class EditorConnection {
211
180
  }
212
181
  });
213
182
  }
214
-
215
183
  sendable(editState) {
216
184
  const steps = (0, _prosemirrorCollab.sendableSteps)(editState);
217
-
218
185
  if (steps) {
219
186
  return {
220
187
  steps
221
188
  };
222
189
  }
223
-
224
190
  return null;
225
- } // Send the given steps to the server
226
-
191
+ }
227
192
 
193
+ // Send the given steps to the server
228
194
  send(editState, sendable) {
229
195
  const {
230
196
  steps
@@ -263,31 +229,29 @@ class EditorConnection {
263
229
  });
264
230
  }
265
231
  });
266
- } // [FS] IRAD-1040 2020-09-02
267
- // Send the modified schema to server
268
-
232
+ }
269
233
 
234
+ // [FS] IRAD-1040 2020-09-02
235
+ // Send the modified schema to server
270
236
  updateSchema(schema, input, dataDefined) {
271
237
  // to avoid cyclic reference error, use flatted string.
272
238
  const schemaFlatted = (0, _flatted.stringify)(schema);
273
239
  this.run((0, _http.POST)(this.url + '/schema/', schemaFlatted, 'text/plain')).then(data => {
274
- console.log("collab server's schema updated"); // [FS] IRAD-1040 2020-09-08
275
-
240
+ console.log("collab server's schema updated");
241
+ // [FS] IRAD-1040 2020-09-08
276
242
  this.schema = schema;
277
243
  this.start(input, dataDefined);
278
244
  }, err => {
279
245
  this.report.failure(err);
280
246
  });
281
- } // Try to recover from an error
282
-
247
+ }
283
248
 
249
+ // Try to recover from an error
284
250
  recover(err) {
285
251
  const newBackOff = this.backOff ? Math.min(this.backOff * 2, 6e4) : 200;
286
-
287
252
  if (newBackOff > 1000 && this.backOff < 1000) {
288
253
  this.report.delay(err);
289
254
  }
290
-
291
255
  this.backOff = newBackOff;
292
256
  setTimeout(() => {
293
257
  if (this.state.comm == 'recover') {
@@ -297,42 +261,32 @@ class EditorConnection {
297
261
  }
298
262
  }, this.backOff);
299
263
  }
300
-
301
264
  closeRequest() {
302
265
  if (this.request) {
303
266
  this.request.abort();
304
267
  this.request = null;
305
268
  }
306
269
  }
307
-
308
270
  run(request) {
309
271
  return this.request = request;
310
272
  }
311
-
312
273
  close() {
313
274
  this.closeRequest();
314
275
  this.setView(null);
315
276
  }
316
-
317
277
  setView(view) {
318
278
  if (this.view) {
319
279
  this.view.destroy();
320
280
  }
321
-
322
281
  this.view = window.view = view;
323
282
  }
324
-
325
283
  }
326
-
327
284
  function repeat(val, n) {
328
285
  const result = [];
329
-
330
286
  for (let i = 0; i < n; i++) {
331
287
  result.push(val);
332
288
  }
333
-
334
289
  return result;
335
290
  }
336
-
337
291
  var _default = EditorConnection;
338
292
  exports.default = _default;