@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.
- package/.eslintrc.js +1 -1
- package/README.md +1 -0
- package/dist/BlockquoteInsertNewLineCommand.js +3 -23
- package/dist/BlockquoteNodeSpec.js +3 -13
- package/dist/BlockquoteToggleCommand.js +3 -16
- package/dist/BookmarkNodeSpec.js +0 -6
- package/dist/BulletListNodeSpec.js +2 -16
- package/dist/CZIProseMirror.js +3 -27
- package/dist/CodeBlockCommand.js +3 -19
- package/dist/CodeBlockNodeSpec.js +3 -4
- package/dist/CodeMarkSpec.js +0 -4
- package/dist/ContentPlaceholderPlugin.js +6 -58
- package/dist/CursorPlaceholderPlugin.js +2 -32
- package/dist/DocLayoutCommand.js +5 -28
- package/dist/DocNodeSpec.js +0 -9
- package/dist/EMMarkSpec.js +0 -4
- package/dist/EditorCommands.js +5 -33
- package/dist/EditorKeyMap.js +4 -18
- package/dist/EditorMarks.js +2 -26
- package/dist/EditorNodes.js +4 -22
- package/dist/EditorPageLayoutPlugin.js +3 -15
- package/dist/EditorPlugins.js +0 -4
- package/dist/EditorSchema.js +0 -5
- package/dist/EditorState.js +0 -2
- package/dist/FontSizeMarkSpec.js +0 -12
- package/dist/FontTypeMarkSpec.js +15 -19
- package/dist/HTMLMutator.js +5 -24
- package/dist/HardBreakNodeSpec.js +0 -2
- package/dist/HeadingNodeSpec.js +6 -15
- package/dist/HistoryRedoCommand.js +3 -11
- package/dist/HistoryUndoCommand.js +3 -11
- package/dist/HorizontalRuleCommand.js +3 -22
- package/dist/HorizontalRuleNodeSpec.js +0 -10
- package/dist/ImageFromURLCommand.js +0 -9
- package/dist/ImageNodeSpec.js +2 -14
- package/dist/ImageSourceCommand.js +3 -39
- package/dist/ImageUploadCommand.js +3 -21
- package/dist/ImageUploadPlaceholderPlugin.js +10 -48
- package/dist/LinkMarkSpec.js +0 -4
- package/dist/LinkSetURLCommand.js +3 -28
- package/dist/LinkTooltipPlugin.js +6 -52
- package/dist/ListItemInsertNewLineCommand.js +3 -23
- package/dist/ListItemMergeCommand.js +15 -66
- package/dist/ListItemNodeSpec.js +0 -11
- package/dist/ListSplitCommand.js +3 -14
- package/dist/ListToggleCommand.js +5 -26
- package/dist/MarksClearCommand.js +6 -17
- package/dist/MathEditCommand.js +3 -38
- package/dist/MathNodeSpec.js +0 -10
- package/dist/OrderedListNodeSpec.js +0 -24
- package/dist/ParagraphNodeSpec.js +5 -26
- package/dist/ParagraphSpacingCommand.js +3 -32
- package/dist/PrintCommand.js +3 -13
- package/dist/SelectionPlaceholderPlugin.js +2 -31
- package/dist/SpacerMarkSpec.js +2 -6
- package/dist/StrikeMarkSpec.js +0 -4
- package/dist/StrongMarkSpec.js +2 -5
- package/dist/StyleView.js +1 -7
- package/dist/TableBackgroundColorCommand.js +3 -24
- package/dist/TableBorderColorCommand.js +3 -24
- package/dist/TableCellColorCommand.js +3 -23
- package/dist/TableCellMenuPlugin.js +9 -45
- package/dist/TableInsertCommand.js +7 -39
- package/dist/TableMergeCellsCommand.js +5 -30
- package/dist/TableNodesSpecs.js +4 -23
- package/dist/TablePlugins.js +0 -5
- package/dist/TableResizePlugin.js +54 -138
- package/dist/TextColorMarkSpec.js +0 -9
- package/dist/TextHighlightMarkSpec.js +0 -8
- package/dist/TextInsertTabSpaceCommand.js +3 -28
- package/dist/TextNoWrapMarkSpec.js +0 -4
- package/dist/TextSelectionMarkSpec.js +0 -5
- package/dist/TextSubMarkSpec.js +0 -4
- package/dist/TextSuperMarkSpec.js +0 -4
- package/dist/TextUnderlineMarkSpec.js +0 -4
- package/dist/Types.js +0 -6
- package/dist/WebFontLoader.js +3 -8
- package/dist/blockQuoteInputRule.js +0 -13
- package/dist/bom.xml +1492 -1645
- package/dist/buildEditorPlugins.js +5 -27
- package/dist/buildInputRules.js +12 -24
- package/dist/client/CollabConnector.js +6 -30
- package/dist/client/EditorConnection.js +23 -69
- package/dist/client/Licit.js +79 -163
- package/dist/client/Licit.js.flow +16 -2
- package/dist/client/Licit.test.js +6 -13
- package/dist/client/Reporter.js +1 -8
- package/dist/client/SimpleConnector.js +6 -26
- package/dist/client/http.js +8 -15
- package/dist/client/throttle.js +0 -2
- package/dist/convertFromDOMElement.js +2 -10
- package/dist/convertFromHTML.js +0 -5
- package/dist/convertFromJSON.js +3 -13
- package/dist/convertToCSSPTValue.js +0 -6
- package/dist/convertToJSON.js +0 -2
- package/dist/createCommand.js +3 -11
- package/dist/createEditorKeyMap.js +0 -13
- package/dist/createEmptyEditorState.js +0 -7
- package/dist/createTableResizingPlugin.js +5 -16
- package/dist/findActionableCell.js +0 -19
- package/dist/findActiveMark.js +0 -11
- package/dist/hyphenize.js +2 -4
- package/dist/index.js +0 -9
- package/dist/insertTable.js +0 -16
- package/dist/isEditorStateEmpty.js +0 -6
- package/dist/isTableNode.js +0 -3
- package/dist/joinDown.js +0 -7
- package/dist/joinListNode.js +0 -15
- package/dist/joinUp.js +0 -9
- package/dist/keymaps.js +0 -15
- package/dist/lookUpElement.js +0 -3
- package/dist/nodeAt.js +0 -3
- package/dist/normalizeHTML.js +9 -25
- package/dist/patchAnchorElements.js +5 -12
- package/dist/patchBreakElements.js +0 -6
- package/dist/patchElementInlineStyles.js +5 -15
- package/dist/patchListElements.js +20 -54
- package/dist/patchMathElements.js +11 -21
- package/dist/patchParagraphElements.js +0 -5
- package/dist/patchStyleElements.js +12 -41
- package/dist/patchTableElements.js +9 -37
- package/dist/rebaseDocWithSteps.js +0 -6
- package/dist/sanitizeURL.js +0 -3
- package/dist/splitListItem.js +12 -43
- package/dist/toClosestFontPtSize.js +1 -5
- package/dist/toSafeHTMLDocument.js +0 -1
- package/dist/toggleBlockquote.js +2 -19
- package/dist/toggleCodeBlock.js +2 -22
- package/dist/ui/AlertInfo.js +6 -22
- package/dist/ui/BookmarkNodeView.js +7 -28
- package/dist/ui/CommandButton.js +3 -19
- package/dist/ui/CommandMenu.js +3 -25
- package/dist/ui/CommandMenuButton.js +3 -36
- package/dist/ui/CustomEditorView.js +3 -16
- package/dist/ui/CustomMenu.js +0 -8
- package/dist/ui/CustomMenuItem.js +4 -18
- package/dist/ui/CustomNodeView.js +21 -67
- package/dist/ui/CustomRadioButton.js +14 -33
- package/dist/ui/DocLayoutEditor.js +5 -27
- package/dist/ui/Editor.js +18 -79
- package/dist/ui/EditorFrameset.js +3 -18
- package/dist/ui/EditorToolbar.js +10 -46
- package/dist/ui/EditorToolbarConfig.js +10 -20
- package/dist/ui/FontSizeCommandMenuButton.js +5 -19
- package/dist/ui/FontTypeCommandMenuButton.js +5 -22
- package/dist/ui/Frag.js +0 -7
- package/dist/ui/Icon.js +5 -25
- package/dist/ui/ImageAlignEditor.js +3 -16
- package/dist/ui/ImageInlineEditor.js +3 -16
- package/dist/ui/ImageNodeView.js +20 -109
- package/dist/ui/ImageResizeBox.js +3 -53
- package/dist/ui/ImageURLEditor.js +3 -28
- package/dist/ui/ImageUploadEditor.js +3 -35
- package/dist/ui/LinkTooltip.js +5 -25
- package/dist/ui/LinkURLEditor.js +3 -29
- package/dist/ui/ListItemNodeView.js +15 -30
- package/dist/ui/ListTypeButton.js +5 -37
- package/dist/ui/ListTypeCommandButton.js +3 -19
- package/dist/ui/ListTypeMenu.js +4 -25
- package/dist/ui/LoadingIndicator.js +0 -7
- package/dist/ui/MathEditor.js +3 -24
- package/dist/ui/MathInlineEditor.js +3 -26
- package/dist/ui/MathNodeView.js +9 -59
- package/dist/ui/PasteMenu.js +4 -20
- package/dist/ui/ResizeObserver.js +0 -18
- package/dist/ui/RichTextEditor.js +5 -27
- package/dist/ui/SelectionObserver.js +3 -29
- package/dist/ui/TableCellMenu.js +3 -18
- package/dist/ui/TableGridSizeEditor.js +5 -51
- package/dist/ui/TableNodeView.js +0 -11
- package/dist/ui/bindScrollHandler.js +2 -9
- package/dist/ui/canUseCSSFont.js +2 -8
- package/dist/ui/czi-icon.css +4 -4
- package/dist/ui/findActiveFontSize.js +2 -18
- package/dist/ui/findActiveFontType.js +0 -12
- package/dist/ui/handleEditorDrop.js +0 -9
- package/dist/ui/handleEditorKeyDown.js +0 -7
- package/dist/ui/handleEditorPaste.js +0 -9
- package/dist/ui/htmlElementToRect.js +0 -4
- package/dist/ui/injectStyleSheet.js +0 -10
- package/dist/ui/isElementFullyVisible.js +2 -8
- package/dist/ui/isOffline.js +0 -2
- package/dist/ui/isReactClass.js +0 -4
- package/dist/ui/mathquill-editor/MathQuillEditor.js +9 -44
- package/dist/ui/mathquill-editor/MathQuillEditorSymbols.js +1 -3
- package/dist/ui/mathquill-editor/MathQuillEditorSymbolsPanel.js +3 -16
- package/dist/ui/mathquill-editor/mathquill-import-kludge.js +5 -7
- package/dist/ui/renderLaTeXAsHTML.js +2 -13
- package/dist/ui/resolveImage.js +7 -32
- package/dist/ui/toCSSColor.js +0 -14
- package/dist/ui/toCSSLineSpacing.js +10 -11
- package/dist/ui/toHexColor.js +0 -8
- package/dist/ui/uuid.js +0 -2
- package/dist/uuid.js +0 -2
- package/package-lock.json.old +32889 -0
- package/package.json +45 -69
- package/src/client/Licit.js +16 -2
- package/src/ui/czi-icon.css +4 -4
- package/utils/build_web_server.js +1 -7
- 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
|
|
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
|
-
}
|
|
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;
|
package/dist/buildInputRules.js
CHANGED
|
@@ -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
|
-
}
|
|
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
|
-
}
|
|
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
|
-
}
|
|
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
|
-
}
|
|
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
|
|
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;
|
|
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
|
|
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
|
-
}
|
|
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
|
-
}
|
|
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
|
-
}
|
|
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
|
-
}
|
|
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
|
-
}
|
|
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
|
-
}
|
|
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
|
-
}
|
|
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");
|
|
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
|
-
}
|
|
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;
|