@modusoperandi/licit 0.1.9 → 0.13.2
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/.github/workflows/build.yml +1 -7
- package/.github/workflows/lint.yml +1 -1
- package/README.md +1 -1
- package/babel.config.json +54 -0
- package/dist/BlockquoteNodeSpec.js +2 -2
- package/dist/CZIProseMirror.js +4 -4
- package/dist/CodeBlockCommand.js +2 -2
- package/dist/CodeBlockCommand.js.flow +1 -1
- package/dist/CursorPlaceholderPlugin.js +2 -2
- package/dist/DocLayoutCommand.js +2 -4
- package/dist/DocLayoutCommand.js.flow +1 -1
- package/dist/DocNodeSpec.js +1 -1
- package/dist/EditorCommands.js +23 -35
- package/dist/EditorCommands.js.flow +7 -7
- package/dist/EditorKeyMap.js +3 -3
- package/dist/FontTypeMarkSpec.js +1 -1
- package/dist/HeadingNodeSpec.js +2 -2
- package/dist/ImageSourceCommand.js +2 -4
- package/dist/ImageSourceCommand.js.flow +1 -1
- package/dist/ImageUploadPlaceholderPlugin.js +1 -1
- package/dist/LinkSetURLCommand.js +4 -8
- package/dist/LinkSetURLCommand.js.flow +3 -3
- package/dist/LinkTooltipPlugin.js +9 -15
- package/dist/LinkTooltipPlugin.js.flow +5 -5
- package/dist/ListToggleCommand.js +5 -11
- package/dist/ListToggleCommand.js.flow +3 -3
- package/dist/MarkNames.js +1 -1
- package/dist/MarksClearCommand.js +3 -3
- package/dist/MarksClearCommand.js.flow +1 -1
- package/dist/MathEditCommand.js +2 -2
- package/dist/MathEditCommand.js.flow +1 -1
- package/dist/ParagraphNodeSpec.js +3 -4
- package/dist/ParagraphNodeSpec.js.flow +2 -6
- package/dist/ParagraphSpacingCommand.js +3 -3
- package/dist/SelectionPlaceholderPlugin.js +2 -2
- package/dist/SpacerMarkSpec.js +1 -1
- package/dist/TableBackgroundColorCommand.js +3 -7
- package/dist/TableBackgroundColorCommand.js.flow +3 -3
- package/dist/TableBorderColorCommand.js +3 -7
- package/dist/TableBorderColorCommand.js.flow +3 -3
- package/dist/TableCellColorCommand.js +3 -7
- package/dist/TableCellColorCommand.js.flow +3 -3
- package/dist/TableCellMenuPlugin.js +4 -6
- package/dist/TableCellMenuPlugin.js.flow +3 -3
- package/dist/TableInsertCommand.js +3 -5
- package/dist/TableInsertCommand.js.flow +2 -2
- package/dist/TableResizePlugin.js +2 -2
- package/dist/TextInsertTabSpaceCommand.js +2 -4
- package/dist/TextInsertTabSpaceCommand.js.flow +1 -1
- package/dist/Types.js +1 -1
- package/dist/bom.xml +4970 -4167
- package/dist/client/CollabConnector.js +17 -2
- package/dist/client/CollabConnector.js.flow +17 -2
- package/dist/client/EditorConnection.js +15 -4
- package/dist/client/EditorConnection.js.flow +14 -3
- package/dist/client/Licit.js +73 -58
- package/dist/client/Licit.js.flow +101 -85
- package/dist/client/Licit.test.js +18 -17
- package/dist/client/Licit.test.js.flow +13 -11
- package/dist/client/SimpleConnector.js +4 -2
- package/dist/client/SimpleConnector.js.flow +3 -1
- package/dist/client/http.js +3 -3
- package/dist/convertToCSSPTValue.js +1 -1
- package/dist/createEmptyEditorState.js +1 -1
- package/dist/index.js +16 -16
- package/dist/joinListNode.js +2 -2
- package/dist/joinListNode.js.flow +1 -1
- package/dist/keymaps.js +2 -2
- package/dist/patchStyleElements.js +3 -3
- package/dist/patchStyleElements.js.flow +1 -1
- package/dist/splitListItem.js +2 -2
- package/dist/styles.css +2 -2
- package/dist/styles0.css +3 -3
- package/dist/toggleBlockquote.js +6 -14
- package/dist/toggleBlockquote.js.flow +4 -4
- package/dist/toggleCodeBlock.js +4 -10
- package/dist/toggleCodeBlock.js.flow +3 -3
- package/dist/ui/AlertInfo.js +2 -2
- package/dist/ui/CommandButton.js +2 -4
- package/dist/ui/CommandButton.js.flow +1 -1
- package/dist/ui/CommandMenuButton.js +5 -7
- package/dist/ui/CommandMenuButton.js.flow +2 -2
- package/dist/ui/CustomMenuItem.js +3 -5
- package/dist/ui/CustomMenuItem.js.flow +1 -1
- package/dist/ui/CustomNodeView.js +3 -3
- package/dist/ui/CustomRadioButton.js +8 -6
- package/dist/ui/CustomRadioButton.js.flow +3 -3
- package/dist/ui/DocLayoutEditor.js +5 -7
- package/dist/ui/DocLayoutEditor.js.flow +2 -2
- package/dist/ui/Editor.js +1 -2
- package/dist/ui/Editor.js.flow +1 -2
- package/dist/ui/EditorFrameset.js +1 -1
- package/dist/ui/EditorToolbar.js +4 -4
- package/dist/ui/EditorToolbar.js.flow +1 -1
- package/dist/ui/EditorToolbarConfig.js +1 -1
- package/dist/ui/FontSizeCommandMenuButton.js +3 -3
- package/dist/ui/FontSizeCommandMenuButton.js.flow +1 -1
- package/dist/ui/FontTypeCommandMenuButton.js +3 -3
- package/dist/ui/FontTypeCommandMenuButton.js.flow +1 -1
- package/dist/ui/ImageAlignEditor.js +5 -5
- package/dist/ui/ImageAlignEditor.js.flow +1 -1
- package/dist/ui/ImageInlineEditor.js +5 -5
- package/dist/ui/ImageInlineEditor.js.flow +1 -1
- package/dist/ui/ImageNodeView.js +5 -7
- package/dist/ui/ImageNodeView.js.flow +2 -2
- package/dist/ui/ImageResizeBox.js +4 -4
- package/dist/ui/ImageResizeBox.js.flow +1 -1
- package/dist/ui/ImageURLEditor.js +6 -8
- package/dist/ui/ImageURLEditor.js.flow +2 -2
- package/dist/ui/ImageUploadEditor.js +3 -5
- package/dist/ui/ImageUploadEditor.js.flow +2 -2
- package/dist/ui/LinkTooltip.js +4 -4
- package/dist/ui/LinkTooltip.js.flow +1 -1
- package/dist/ui/LinkURLEditor.js +4 -6
- package/dist/ui/LinkURLEditor.js.flow +2 -2
- package/dist/ui/ListTypeButton.js +5 -7
- package/dist/ui/ListTypeButton.js.flow +2 -2
- package/dist/ui/MathEditor.js +4 -6
- package/dist/ui/MathEditor.js.flow +2 -2
- package/dist/ui/MathInlineEditor.js +7 -9
- package/dist/ui/MathInlineEditor.js.flow +2 -2
- package/dist/ui/MathNodeView.js +5 -7
- package/dist/ui/MathNodeView.js.flow +2 -2
- package/dist/ui/ResizeObserver.js +1 -1
- package/dist/ui/TableGridSizeEditor.js +7 -9
- package/dist/ui/TableGridSizeEditor.js.flow +2 -2
- package/dist/ui/czi-link-tooltip.css +1 -1
- package/dist/ui/czi-vars.css +1 -45
- package/dist/ui/findActiveFontType.js +1 -1
- package/dist/ui/htmlElementToRect.js +1 -1
- package/dist/ui/isElementFullyVisible.js +2 -2
- package/dist/ui/isElementFullyVisible.js.flow +1 -1
- package/dist/ui/mathquill-editor/MathQuillEditorSymbols.js +1 -1
- package/dist/ui/mathquill-editor/MathQuillEditorSymbolsPanel.js +2 -2
- package/dist/ui/mathquill-editor/MathQuillEditorSymbolsPanel.js.flow +1 -1
- package/dist/ui/resolveImage.js +3 -3
- package/dist/ui/toCSSColor.js +1 -1
- package/dist/ui/toCSSLineSpacing.js +1 -36
- package/dist/ui/toCSSLineSpacing.js.flow +0 -27
- package/flow-typed/@modusoperandilicit-ui-commands.js +5 -0
- package/jest.config.js +207 -0
- package/lint.sh +0 -0
- package/node_modules/prosemirror-utils/LICENSE +13 -0
- package/{dist/ui/PopUpTypes.js.flow → node_modules/prosemirror-utils/README.md} +0 -0
- package/node_modules/prosemirror-utils/dist/helpers.js +119 -0
- package/node_modules/prosemirror-utils/dist/index.js +17 -0
- package/node_modules/prosemirror-utils/dist/index.js.map +1 -0
- package/node_modules/prosemirror-utils/dist/node.js +106 -0
- package/node_modules/prosemirror-utils/dist/selection.js +168 -0
- package/node_modules/prosemirror-utils/dist/transforms.js +257 -0
- package/node_modules/prosemirror-utils/package.json +81 -0
- package/node_modules/prosemirror-utils/typings.d.ts +79 -0
- package/package.json +14 -8
- package/scripts/build_bin.py +0 -0
- package/scripts/ci_check_dist.sh +0 -0
- package/src/CodeBlockCommand.js +1 -1
- package/src/DocLayoutCommand.js +1 -1
- package/src/EditorCommands.js +7 -7
- package/src/ImageSourceCommand.js +1 -1
- package/src/LinkSetURLCommand.js +3 -3
- package/src/LinkTooltipPlugin.js +5 -5
- package/src/ListToggleCommand.js +3 -3
- package/src/MarksClearCommand.js +1 -1
- package/src/MathEditCommand.js +1 -1
- package/src/ParagraphNodeSpec.js +2 -6
- package/src/TableBackgroundColorCommand.js +3 -3
- package/src/TableBorderColorCommand.js +3 -3
- package/src/TableCellColorCommand.js +3 -3
- package/src/TableCellMenuPlugin.js +3 -3
- package/src/TableInsertCommand.js +2 -2
- package/src/TextInsertTabSpaceCommand.js +1 -1
- package/src/client/CollabConnector.js +17 -2
- package/src/client/EditorConnection.js +14 -3
- package/src/client/Licit.js +101 -85
- package/src/client/Licit.test.js +13 -11
- package/src/client/SimpleConnector.js +3 -1
- package/src/joinListNode.js +1 -1
- package/src/patchStyleElements.js +1 -1
- package/src/styles.css +2 -2
- package/src/styles0.css +3 -3
- package/src/toggleBlockquote.js +4 -4
- package/src/toggleCodeBlock.js +3 -3
- package/src/ui/CommandButton.js +1 -1
- package/src/ui/CommandMenuButton.js +2 -2
- package/src/ui/CustomMenuItem.js +1 -1
- package/src/ui/CustomRadioButton.js +3 -3
- package/src/ui/DocLayoutEditor.js +2 -2
- package/src/ui/Editor.js +1 -2
- package/src/ui/EditorToolbar.js +1 -1
- package/src/ui/FontSizeCommandMenuButton.js +1 -1
- package/src/ui/FontTypeCommandMenuButton.js +1 -1
- package/src/ui/ImageAlignEditor.js +1 -1
- package/src/ui/ImageInlineEditor.js +1 -1
- package/src/ui/ImageNodeView.js +2 -2
- package/src/ui/ImageResizeBox.js +1 -1
- package/src/ui/ImageURLEditor.js +2 -2
- package/src/ui/ImageUploadEditor.js +2 -2
- package/src/ui/LinkTooltip.js +1 -1
- package/src/ui/LinkURLEditor.js +2 -2
- package/src/ui/ListTypeButton.js +2 -2
- package/src/ui/MathEditor.js +2 -2
- package/src/ui/MathInlineEditor.js +2 -2
- package/src/ui/MathNodeView.js +2 -2
- package/src/ui/TableGridSizeEditor.js +2 -2
- package/src/ui/czi-link-tooltip.css +1 -1
- package/src/ui/czi-vars.css +1 -45
- package/src/ui/isElementFullyVisible.js +1 -1
- package/src/ui/mathquill-editor/MathQuillEditorSymbolsPanel.js +1 -1
- package/src/ui/toCSSLineSpacing.js +0 -27
- package/build_customstyle_server.py +0 -7
- package/dist/FontSizeCommand.js +0 -80
- package/dist/FontSizeCommand.js.flow +0 -57
- package/dist/FontTypeCommand.js +0 -137
- package/dist/FontTypeCommand.js.flow +0 -100
- package/dist/HeadingCommand.js +0 -65
- package/dist/HeadingCommand.js.flow +0 -51
- package/dist/IndentCommand.js +0 -57
- package/dist/IndentCommand.js.flow +0 -41
- package/dist/MarkToggleCommand.js +0 -90
- package/dist/MarkToggleCommand.js.flow +0 -66
- package/dist/TextAlignCommand.js +0 -151
- package/dist/TextAlignCommand.js.flow +0 -122
- package/dist/TextColorCommand.js +0 -114
- package/dist/TextColorCommand.js.flow +0 -87
- package/dist/TextHighlightCommand.js +0 -118
- package/dist/TextHighlightCommand.js.flow +0 -91
- package/dist/TextLineSpacingCommand.js +0 -177
- package/dist/TextLineSpacingCommand.js.flow +0 -157
- package/dist/applyMark.js +0 -84
- package/dist/applyMark.js.flow +0 -61
- package/dist/clearMarks.js +0 -160
- package/dist/clearMarks.js.flow +0 -128
- package/dist/compareNumber.js +0 -18
- package/dist/compareNumber.js.flow +0 -11
- package/dist/consolidateListNodes.js +0 -291
- package/dist/consolidateListNodes.js.flow +0 -281
- package/dist/coverage/lcov-report/block-navigation.js +0 -77
- package/dist/coverage/lcov-report/block-navigation.js.flow +0 -79
- package/dist/coverage/lcov-report/prettify.js +0 -994
- package/dist/coverage/lcov-report/prettify.js.flow +0 -2
- package/dist/coverage/lcov-report/sorter.js +0 -187
- package/dist/coverage/lcov-report/sorter.js.flow +0 -170
- package/dist/findNodesWithSameMark.js +0 -89
- package/dist/findNodesWithSameMark.js.flow +0 -89
- package/dist/isBulletListNode.js +0 -14
- package/dist/isBulletListNode.js.flow +0 -9
- package/dist/isInsideListItem.js +0 -19
- package/dist/isInsideListItem.js.flow +0 -13
- package/dist/isListNode.js +0 -22
- package/dist/isListNode.js.flow +0 -13
- package/dist/isNodeSelectionForNodeType.js +0 -19
- package/dist/isNodeSelectionForNodeType.js.flow +0 -15
- package/dist/isOrderedListNode.js +0 -14
- package/dist/isOrderedListNode.js.flow +0 -9
- package/dist/isTextStyleMarkCommandEnabled.js +0 -59
- package/dist/isTextStyleMarkCommandEnabled.js.flow +0 -49
- package/dist/noop.js +0 -11
- package/dist/noop.js.flow +0 -5
- package/dist/toggleHeading.js +0 -135
- package/dist/toggleHeading.js.flow +0 -113
- package/dist/toggleList.js +0 -431
- package/dist/toggleList.js.flow +0 -450
- package/dist/transformAndPreserveTextSelection.js +0 -173
- package/dist/transformAndPreserveTextSelection.js.flow +0 -151
- package/dist/ui/ColorEditor.js +0 -118
- package/dist/ui/ColorEditor.js.flow +0 -101
- package/dist/ui/CustomButton.js +0 -62
- package/dist/ui/CustomButton.js.flow +0 -33
- package/dist/ui/PointerSurface.js +0 -173
- package/dist/ui/PointerSurface.js.flow +0 -141
- package/dist/ui/PopUp.js +0 -129
- package/dist/ui/PopUp.js.flow +0 -77
- package/dist/ui/PopUpManager.js +0 -266
- package/dist/ui/PopUpManager.js.flow +0 -213
- package/dist/ui/PopUpPosition.js +0 -156
- package/dist/ui/PopUpPosition.js.flow +0 -104
- package/dist/ui/PopUpTypes.js +0 -1
- package/dist/ui/TooltipSurface.js +0 -99
- package/dist/ui/TooltipSurface.js.flow +0 -76
- package/dist/ui/clamp.js +0 -18
- package/dist/ui/clamp.js.flow +0 -11
- package/dist/ui/createPopUp.js +0 -199
- package/dist/ui/createPopUp.js.flow +0 -205
- package/dist/ui/czi-animations.css +0 -15
- package/dist/ui/czi-color-editor.css +0 -56
- package/dist/ui/czi-custom-button.css +0 -93
- package/dist/ui/czi-pop-up.css +0 -32
- package/dist/ui/czi-tooltip-surface.css +0 -45
- package/dist/ui/preventEventDefault.js +0 -10
- package/dist/ui/preventEventDefault.js.flow +0 -5
- package/dist/ui/rects.js +0 -58
- package/dist/ui/rects.js.flow +0 -47
- package/dist/updateIndentLevel.js +0 -232
- package/dist/updateIndentLevel.js.flow +0 -211
- package/flow-typed/@molicit-citation.js +0 -5
- package/licit/server/customstyles/start.js +0 -184
- package/run_customstyle_server.py +0 -20
- package/src/FontSizeCommand.js +0 -57
- package/src/FontTypeCommand.js +0 -100
- package/src/HeadingCommand.js +0 -51
- package/src/IndentCommand.js +0 -41
- package/src/MarkToggleCommand.js +0 -66
- package/src/TextAlignCommand.js +0 -122
- package/src/TextColorCommand.js +0 -87
- package/src/TextHighlightCommand.js +0 -91
- package/src/TextLineSpacingCommand.js +0 -157
- package/src/applyMark.js +0 -61
- package/src/clearMarks.js +0 -128
- package/src/compareNumber.js +0 -11
- package/src/consolidateListNodes.js +0 -281
- package/src/findNodesWithSameMark.js +0 -89
- package/src/isBulletListNode.js +0 -9
- package/src/isInsideListItem.js +0 -13
- package/src/isListNode.js +0 -13
- package/src/isNodeSelectionForNodeType.js +0 -15
- package/src/isOrderedListNode.js +0 -9
- package/src/isTextStyleMarkCommandEnabled.js +0 -49
- package/src/noop.js +0 -5
- package/src/toggleHeading.js +0 -113
- package/src/toggleList.js +0 -450
- package/src/transformAndPreserveTextSelection.js +0 -151
- package/src/ui/ColorEditor.js +0 -101
- package/src/ui/CustomButton.js +0 -33
- package/src/ui/PointerSurface.js +0 -141
- package/src/ui/PopUp.js +0 -77
- package/src/ui/PopUpManager.js +0 -213
- package/src/ui/PopUpPosition.js +0 -104
- package/src/ui/PopUpTypes.js +0 -0
- package/src/ui/TooltipSurface.js +0 -76
- package/src/ui/clamp.js +0 -11
- package/src/ui/createPopUp.js +0 -205
- package/src/ui/czi-animations.css +0 -15
- package/src/ui/czi-color-editor.css +0 -56
- package/src/ui/czi-custom-button.css +0 -93
- package/src/ui/czi-pop-up.css +0 -32
- package/src/ui/czi-tooltip-surface.css +0 -45
- package/src/ui/preventEventDefault.js +0 -5
- package/src/ui/rects.js +0 -47
- package/src/updateIndentLevel.js +0 -211
- package/utils/build_customstyle_server.js +0 -72
|
@@ -41,6 +41,21 @@ class CollabConnector extends _SimpleConnector.default {
|
|
|
41
41
|
|
|
42
42
|
_defineProperty(this, "_stepKeys", void 0);
|
|
43
43
|
|
|
44
|
+
_defineProperty(this, "cleanUp", () => {
|
|
45
|
+
// remove collab plugin
|
|
46
|
+
if (this._connection) {
|
|
47
|
+
const cpIdx = this._editorState.plugins.findIndex(plugin => {
|
|
48
|
+
return 'collab$' === plugin.spec.key.key;
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
if (-1 != cpIdx) {
|
|
52
|
+
this._editorState.plugins.splice(cpIdx, 1);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
this._connection.close();
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
44
59
|
_defineProperty(this, "onEdit", transaction => {
|
|
45
60
|
if (!this._connection.ready) {
|
|
46
61
|
console.warn('not ready');
|
|
@@ -55,8 +70,8 @@ class CollabConnector extends _SimpleConnector.default {
|
|
|
55
70
|
});
|
|
56
71
|
});
|
|
57
72
|
|
|
58
|
-
_defineProperty(this, "updateSchema", schema => {
|
|
59
|
-
this._connection.updateSchema(schema);
|
|
73
|
+
_defineProperty(this, "updateSchema", (schema, data) => {
|
|
74
|
+
this._connection.updateSchema(schema, data);
|
|
60
75
|
});
|
|
61
76
|
|
|
62
77
|
const {
|
|
@@ -51,6 +51,21 @@ class CollabConnector extends SimpleConnector {
|
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
cleanUp = () => {
|
|
55
|
+
// remove collab plugin
|
|
56
|
+
if (this._connection) {
|
|
57
|
+
const cpIdx = this._editorState.plugins.findIndex((plugin) => {
|
|
58
|
+
return 'collab$' === plugin.spec.key.key;
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
if (-1 != cpIdx) {
|
|
62
|
+
this._editorState.plugins.splice(cpIdx, 1);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
this._connection.close();
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
54
69
|
onEdit = (transaction: Transform): void => {
|
|
55
70
|
if (!this._connection.ready) {
|
|
56
71
|
console.warn('not ready');
|
|
@@ -63,8 +78,8 @@ class CollabConnector extends SimpleConnector {
|
|
|
63
78
|
|
|
64
79
|
// FS IRAD-1040 2020-09-02
|
|
65
80
|
// Send the modified schema to server
|
|
66
|
-
updateSchema = (schema: Schema) => {
|
|
67
|
-
this._connection.updateSchema(schema);
|
|
81
|
+
updateSchema = (schema: Schema, data: any) => {
|
|
82
|
+
this._connection.updateSchema(schema, data);
|
|
68
83
|
};
|
|
69
84
|
}
|
|
70
85
|
|
|
@@ -102,7 +102,7 @@ class EditorConnection {
|
|
|
102
102
|
if (newEditState) {
|
|
103
103
|
let sendable;
|
|
104
104
|
|
|
105
|
-
if (newEditState.doc.content.size >
|
|
105
|
+
if (newEditState.doc.content.size > 4000000000000) {
|
|
106
106
|
if (this.state.comm !== 'detached') {
|
|
107
107
|
this.report.failure('Document too big. Detached.');
|
|
108
108
|
}
|
|
@@ -146,7 +146,18 @@ class EditorConnection {
|
|
|
146
146
|
} // All state changes go through this
|
|
147
147
|
|
|
148
148
|
|
|
149
|
-
|
|
149
|
+
dispatchData(data) {
|
|
150
|
+
this.report.success();
|
|
151
|
+
this.backOff = 0;
|
|
152
|
+
this.dispatch({
|
|
153
|
+
type: 'loaded',
|
|
154
|
+
doc: this.getEffectiveSchema().nodeFromJSON(data),
|
|
155
|
+
version: data.version,
|
|
156
|
+
users: data.users
|
|
157
|
+
});
|
|
158
|
+
} // Load the document from the server and start up
|
|
159
|
+
|
|
160
|
+
|
|
150
161
|
start() {
|
|
151
162
|
this.run((0, _http.GET)(this.url)).then(data => {
|
|
152
163
|
data = JSON.parse(data);
|
|
@@ -255,14 +266,14 @@ class EditorConnection {
|
|
|
255
266
|
// Send the modified schema to server
|
|
256
267
|
|
|
257
268
|
|
|
258
|
-
updateSchema(schema) {
|
|
269
|
+
updateSchema(schema, input) {
|
|
259
270
|
// to avoid cyclic reference error, use flatted string.
|
|
260
271
|
const schemaFlatted = (0, _flatted.stringify)(schema);
|
|
261
272
|
this.run((0, _http.POST)(this.url + '/schema/', schemaFlatted, 'text/plain')).then(data => {
|
|
262
273
|
console.log("collab server's schema updated"); // [FS] IRAD-1040 2020-09-08
|
|
263
274
|
|
|
264
275
|
this.schema = schema;
|
|
265
|
-
this.start();
|
|
276
|
+
this.start(input);
|
|
266
277
|
}, err => {
|
|
267
278
|
this.report.failure(err);
|
|
268
279
|
});
|
|
@@ -106,7 +106,7 @@ class EditorConnection {
|
|
|
106
106
|
|
|
107
107
|
if (newEditState) {
|
|
108
108
|
let sendable;
|
|
109
|
-
if (newEditState.doc.content.size >
|
|
109
|
+
if (newEditState.doc.content.size > 4000000000000) {
|
|
110
110
|
if (this.state.comm !== 'detached') {
|
|
111
111
|
this.report.failure('Document too big. Detached.');
|
|
112
112
|
}
|
|
@@ -132,6 +132,17 @@ class EditorConnection {
|
|
|
132
132
|
}
|
|
133
133
|
};
|
|
134
134
|
|
|
135
|
+
dispatchData(data: any) {
|
|
136
|
+
this.report.success();
|
|
137
|
+
this.backOff = 0;
|
|
138
|
+
this.dispatch({
|
|
139
|
+
type: 'loaded',
|
|
140
|
+
doc: this.getEffectiveSchema().nodeFromJSON(data),
|
|
141
|
+
version: data.version,
|
|
142
|
+
users: data.users,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
135
146
|
// Load the document from the server and start up
|
|
136
147
|
start(): void {
|
|
137
148
|
this.run(GET(this.url)).then(
|
|
@@ -242,7 +253,7 @@ class EditorConnection {
|
|
|
242
253
|
|
|
243
254
|
// [FS] IRAD-1040 2020-09-02
|
|
244
255
|
// Send the modified schema to server
|
|
245
|
-
updateSchema(schema: Schema) {
|
|
256
|
+
updateSchema(schema: Schema, input: any) {
|
|
246
257
|
// to avoid cyclic reference error, use flatted string.
|
|
247
258
|
const schemaFlatted = stringify(schema);
|
|
248
259
|
this.run(POST(this.url + '/schema/', schemaFlatted, 'text/plain')).then(
|
|
@@ -250,7 +261,7 @@ class EditorConnection {
|
|
|
250
261
|
console.log("collab server's schema updated");
|
|
251
262
|
// [FS] IRAD-1040 2020-09-08
|
|
252
263
|
this.schema = schema;
|
|
253
|
-
this.start();
|
|
264
|
+
this.start(input);
|
|
254
265
|
},
|
|
255
266
|
(err) => {
|
|
256
267
|
this.report.failure(err);
|
package/dist/client/Licit.js
CHANGED
|
@@ -31,9 +31,7 @@ var _CollabConnector = _interopRequireDefault(require("./CollabConnector"));
|
|
|
31
31
|
|
|
32
32
|
var _createEmptyEditorState = require("../createEmptyEditorState");
|
|
33
33
|
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
var _PopUpPosition = require("../ui/PopUpPosition");
|
|
34
|
+
var _licitUiCommands = require("@modusoperandi/licit-ui-commands");
|
|
37
35
|
|
|
38
36
|
var _AlertInfo = _interopRequireDefault(require("../ui/AlertInfo"));
|
|
39
37
|
|
|
@@ -117,7 +115,7 @@ class Licit extends React.Component {
|
|
|
117
115
|
_defineProperty(this, "setContent", function () {
|
|
118
116
|
let content = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
119
117
|
// [FS] IRAD-1571 2021-09-27
|
|
120
|
-
// dispatch a transaction that MUST start from the view
|
|
118
|
+
// dispatch a transaction that MUST start from the views current state;
|
|
121
119
|
const editorState = _this._editorView.state;
|
|
122
120
|
const {
|
|
123
121
|
doc,
|
|
@@ -126,7 +124,10 @@ class Licit extends React.Component {
|
|
|
126
124
|
let {
|
|
127
125
|
tr
|
|
128
126
|
} = editorState;
|
|
129
|
-
const document = schema.nodeFromJSON(content ? content : _createEmptyEditorState.EMPTY_DOC_JSON);
|
|
127
|
+
const document = schema.nodeFromJSON(content ? content : _createEmptyEditorState.EMPTY_DOC_JSON); // [FS] IRAD-1593 2021-10-12
|
|
128
|
+
// Reset lastKeyCode since the content is set dynamically and so lastKeyCode is invalid now.
|
|
129
|
+
|
|
130
|
+
_this._editorView.lastKeyCode = null;
|
|
130
131
|
|
|
131
132
|
const selection = _prosemirrorState.TextSelection.create(doc, 0, doc.content.size);
|
|
132
133
|
|
|
@@ -173,7 +174,14 @@ class Licit extends React.Component {
|
|
|
173
174
|
|
|
174
175
|
if (transaction.docChanged) {
|
|
175
176
|
const docJson = transaction.doc.toJSON();
|
|
176
|
-
|
|
177
|
+
let isEmpty = false;
|
|
178
|
+
|
|
179
|
+
if (docJson.content && docJson.content.length === 1) {
|
|
180
|
+
if (!docJson.content[0].content || docJson.content[0].content && docJson.content[0].content[0].text && '' === docJson.content[0].content[0].text.trim()) {
|
|
181
|
+
isEmpty = true;
|
|
182
|
+
}
|
|
183
|
+
} // setCFlags is/was always the opposite of isEmpty.
|
|
184
|
+
|
|
177
185
|
|
|
178
186
|
if (isEmpty) {
|
|
179
187
|
this.resetCounters(transaction);
|
|
@@ -199,15 +207,11 @@ class Licit extends React.Component {
|
|
|
199
207
|
} = editorView;
|
|
200
208
|
this._editorView = editorView;
|
|
201
209
|
const tr = state.tr;
|
|
202
|
-
const doc = state.doc;
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
const trx = tr.setSelection(_prosemirrorState.TextSelection.create(doc, 0, doc.content.size));
|
|
206
|
-
dispatch(trx.scrollIntoView());
|
|
207
|
-
} // [FS] IRAD-1578 2021-09-27
|
|
210
|
+
const doc = state.doc;
|
|
211
|
+
const trx = tr.setSelection(_prosemirrorState.TextSelection.create(doc, 0, doc.content.size));
|
|
212
|
+
dispatch(trx.scrollIntoView()); // [FS] IRAD-1578 2021-09-27
|
|
208
213
|
// In collab mode, fire onRead only after getting the response from collab server.
|
|
209
214
|
|
|
210
|
-
|
|
211
215
|
if (this.state.onReadyCB && this.state.docID === '') {
|
|
212
216
|
editorView.focus();
|
|
213
217
|
this.state.onReadyCB(this);
|
|
@@ -322,7 +326,7 @@ class Licit extends React.Component {
|
|
|
322
326
|
|
|
323
327
|
if (this._connector.updateSchema) {
|
|
324
328
|
// Use known editorState to update schema.
|
|
325
|
-
this._connector.updateSchema(editorState.schema);
|
|
329
|
+
this._connector.updateSchema(editorState.schema, data);
|
|
326
330
|
}
|
|
327
331
|
} // [FS] IRAD-1578 2021-09-27
|
|
328
332
|
|
|
@@ -343,9 +347,9 @@ class Licit extends React.Component {
|
|
|
343
347
|
|
|
344
348
|
showAlert() {
|
|
345
349
|
const anchor = null;
|
|
346
|
-
this._popUp = (0,
|
|
350
|
+
this._popUp = (0, _licitUiCommands.createPopUp)(_AlertInfo.default, null, {
|
|
347
351
|
anchor,
|
|
348
|
-
position:
|
|
352
|
+
position: _licitUiCommands.atViewportCenter,
|
|
349
353
|
onClose: val => {
|
|
350
354
|
if (this._popUp) {
|
|
351
355
|
this._popUp = null;
|
|
@@ -422,45 +426,70 @@ class Licit extends React.Component {
|
|
|
422
426
|
return node.attrs && node.attrs[attrName];
|
|
423
427
|
}
|
|
424
428
|
|
|
429
|
+
hasDataChanged(nextData) {
|
|
430
|
+
let dataChanged = false; // [FS] IRAD-1571 2021-09-27
|
|
431
|
+
// dispatch a transaction that MUST start from the views current state;
|
|
432
|
+
// [FS] IRAD-1589 2021-10-04
|
|
433
|
+
// Do a proper circular JSON comparison.
|
|
434
|
+
|
|
435
|
+
if ((0, _flatted.stringify)(this.state.data) !== (0, _flatted.stringify)(nextData)) {
|
|
436
|
+
const editorState = this._editorView.state;
|
|
437
|
+
const nextDoc = editorState.schema.nodeFromJSON(nextData ? nextData : _createEmptyEditorState.EMPTY_DOC_JSON);
|
|
438
|
+
dataChanged = !nextDoc.eq(editorState.doc);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
return dataChanged;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
changeContent(data) {
|
|
445
|
+
if (this.hasDataChanged(data)) {
|
|
446
|
+
// FS IRAD-1592 2021-11-10
|
|
447
|
+
// Release here quickly, so that update doesn't care about at this point.
|
|
448
|
+
// data changed, so update document content
|
|
449
|
+
setTimeout(this.setContent.bind(this, data), 1);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
425
453
|
shouldComponentUpdate(nextProps, nextState) {
|
|
426
454
|
// Only interested if properties are set from outside.
|
|
427
455
|
if (!this._skipSCU) {
|
|
428
456
|
this._skipSCU = false;
|
|
429
|
-
|
|
430
|
-
// dispatch a transaction that MUST start from the view�s current state;
|
|
431
|
-
// [FS] IRAD-1589 2021-10-04
|
|
432
|
-
// Do a proper circular JSON comparison.
|
|
433
|
-
|
|
434
|
-
if ((0, _flatted.stringify)(this.state.data) !== (0, _flatted.stringify)(nextState.data)) {
|
|
435
|
-
const editorState = this._editorView.state;
|
|
436
|
-
const nextDoc = editorState.schema.nodeFromJSON(nextState.data ? nextState.data : _createEmptyEditorState.EMPTY_DOC_JSON);
|
|
437
|
-
dataChanged = !nextDoc.eq(editorState.doc);
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
if (dataChanged) {
|
|
441
|
-
// data changed, so update document content
|
|
442
|
-
this.setContent(nextState.data);
|
|
443
|
-
}
|
|
457
|
+
this.changeContent(nextState.data);
|
|
444
458
|
|
|
445
459
|
if (this.state.docID !== nextState.docID) {
|
|
446
|
-
|
|
447
|
-
const collabEditing = nextState.docID !== '';
|
|
448
|
-
const editorState = this._editorView.state;
|
|
449
|
-
const setState = this.setState.bind(this);
|
|
450
|
-
const docID = nextState.docID || '';
|
|
451
|
-
const collabServiceURL = nextState.collabServiceURL || '/collaboration-service'; // create new connector
|
|
452
|
-
|
|
453
|
-
this._connector = collabEditing ? new _CollabConnector.default(editorState, setState, {
|
|
454
|
-
docID,
|
|
455
|
-
collabServiceURL
|
|
456
|
-
}, this._defaultEditorSchema, this._defaultEditorPlugins, // [FS] IRAD-1578 2021-09-27
|
|
457
|
-
this.onReady.bind(this)) : new _SimpleConnector.default(editorState, setState);
|
|
460
|
+
setTimeout(this.setDocID.bind(this, nextState), 1);
|
|
458
461
|
}
|
|
459
462
|
}
|
|
460
463
|
|
|
461
464
|
return true;
|
|
462
465
|
}
|
|
463
466
|
|
|
467
|
+
setDocID(nextState) {
|
|
468
|
+
// Collaborative mode changed
|
|
469
|
+
const collabEditing = nextState.docID !== '';
|
|
470
|
+
const editorState = this._editorView.state;
|
|
471
|
+
const setState = this.setState.bind(this);
|
|
472
|
+
const docID = nextState.docID || '';
|
|
473
|
+
const collabServiceURL = nextState.collabServiceURL || '/collaboration-service';
|
|
474
|
+
|
|
475
|
+
if (this._connector) {
|
|
476
|
+
this._connector.cleanUp();
|
|
477
|
+
} // create new connector
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
this._connector = collabEditing ? new _CollabConnector.default(editorState, setState, {
|
|
481
|
+
docID,
|
|
482
|
+
collabServiceURL
|
|
483
|
+
}, this._defaultEditorSchema, this._defaultEditorPlugins, // [FS] IRAD-1578 2021-09-27
|
|
484
|
+
this.onReady.bind(this)) : new _SimpleConnector.default(editorState, setState); // FS IRAD-1592 2021-11-10
|
|
485
|
+
// Notify collab server
|
|
486
|
+
|
|
487
|
+
if (this._connector.updateSchema) {
|
|
488
|
+
// Use known editorState to update schema.
|
|
489
|
+
this._connector.updateSchema(editorState.schema);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
464
493
|
render() {
|
|
465
494
|
const {
|
|
466
495
|
editorState,
|
|
@@ -487,22 +516,8 @@ class Licit extends React.Component {
|
|
|
487
516
|
});
|
|
488
517
|
}
|
|
489
518
|
|
|
490
|
-
|
|
491
|
-
let isEmpty = false;
|
|
492
|
-
|
|
493
|
-
if (docJson.content && docJson.content.length === 1) {
|
|
494
|
-
if (!docJson.content[0].content || docJson.content[0].content && // [FS] IRAD-1710 2022-03-04
|
|
495
|
-
// Empty if no content OR when the one & only text content is empty.
|
|
496
|
-
1 === docJson.content[0].content.length && 'text' === docJson.content[0].content[0].type && docJson.content[0].content[0].text && '' === docJson.content[0].content[0].text) {
|
|
497
|
-
isEmpty = true;
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
return isEmpty;
|
|
502
|
-
} // [FS] IRAD-1173 2021-02-25
|
|
519
|
+
// [FS] IRAD-1173 2021-02-25
|
|
503
520
|
// Bug fix: Transaction mismatch error when a dialog is opened and keep typing.
|
|
504
|
-
|
|
505
|
-
|
|
506
521
|
closeOpenedPopupModels() {
|
|
507
522
|
const element = document.getElementsByClassName('czi-pop-up-element')[0];
|
|
508
523
|
|
|
@@ -14,8 +14,8 @@ import SimpleConnector from './SimpleConnector';
|
|
|
14
14
|
import CollabConnector from './CollabConnector';
|
|
15
15
|
import { EMPTY_DOC_JSON } from '../createEmptyEditorState';
|
|
16
16
|
import type { EditorRuntime } from '../Types';
|
|
17
|
-
import createPopUp from '
|
|
18
|
-
import { atViewportCenter } from '
|
|
17
|
+
import { createPopUp } from '@modusoperandi/licit-ui-commands';
|
|
18
|
+
import { atViewportCenter } from '@modusoperandi/licit-ui-commands';
|
|
19
19
|
import AlertInfo from '../ui/AlertInfo';
|
|
20
20
|
import { SetDocAttrStep } from '@modusoperandi/licit-doc-attrs-step';
|
|
21
21
|
import './licit.css';
|
|
@@ -73,7 +73,7 @@ class Licit extends React.Component<any, any> {
|
|
|
73
73
|
this._editorView = null;
|
|
74
74
|
this._skipSCU = true;
|
|
75
75
|
|
|
76
|
-
const noop = function () {
|
|
76
|
+
const noop = function () {};
|
|
77
77
|
|
|
78
78
|
// [FS] IRAD-981 2020-06-10
|
|
79
79
|
// Component's configurations.
|
|
@@ -132,17 +132,17 @@ class Licit extends React.Component<any, any> {
|
|
|
132
132
|
const setState = this.setState.bind(this);
|
|
133
133
|
this._connector = collaborative
|
|
134
134
|
? new CollabConnector(
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
135
|
+
editorState,
|
|
136
|
+
setState,
|
|
137
|
+
{
|
|
138
|
+
docID,
|
|
139
|
+
collabServiceURL,
|
|
140
|
+
},
|
|
141
|
+
this._defaultEditorSchema,
|
|
142
|
+
this._defaultEditorPlugins,
|
|
143
|
+
// [FS] IRAD-1578 2021-09-27
|
|
144
|
+
this.onReady.bind(this)
|
|
145
|
+
)
|
|
146
146
|
: new SimpleConnector(editorState, setState);
|
|
147
147
|
|
|
148
148
|
// FS IRAD-989 2020-18-06
|
|
@@ -168,7 +168,7 @@ class Licit extends React.Component<any, any> {
|
|
|
168
168
|
// Get the modified schema from editorstate and send it to collab server
|
|
169
169
|
if (this._connector.updateSchema) {
|
|
170
170
|
// Use known editorState to update schema.
|
|
171
|
-
this._connector.updateSchema(editorState.schema);
|
|
171
|
+
this._connector.updateSchema(editorState.schema, data);
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
174
|
|
|
@@ -265,12 +265,16 @@ class Licit extends React.Component<any, any> {
|
|
|
265
265
|
|
|
266
266
|
setContent = (content: any = {}): void => {
|
|
267
267
|
// [FS] IRAD-1571 2021-09-27
|
|
268
|
-
// dispatch a transaction that MUST start from the view
|
|
268
|
+
// dispatch a transaction that MUST start from the views current state;
|
|
269
269
|
const editorState = this._editorView.state;
|
|
270
270
|
const { doc, schema } = editorState;
|
|
271
271
|
let { tr } = editorState;
|
|
272
272
|
const document = schema.nodeFromJSON(content ? content : EMPTY_DOC_JSON);
|
|
273
273
|
|
|
274
|
+
// [FS] IRAD-1593 2021-10-12
|
|
275
|
+
// Reset lastKeyCode since the content is set dynamically and so lastKeyCode is invalid now.
|
|
276
|
+
this._editorView.lastKeyCode = null;
|
|
277
|
+
|
|
274
278
|
const selection = TextSelection.create(doc, 0, doc.content.size);
|
|
275
279
|
|
|
276
280
|
tr = tr.setSelection(selection).replaceSelectionWith(document, false);
|
|
@@ -278,8 +282,8 @@ class Licit extends React.Component<any, any> {
|
|
|
278
282
|
// set the value for object metadata and objectId
|
|
279
283
|
tr = this.isNodeHasAttribute(document, ATTR_OBJMETADATA)
|
|
280
284
|
? tr.step(
|
|
281
|
-
|
|
282
|
-
|
|
285
|
+
new SetDocAttrStep(ATTR_OBJMETADATA, document.attrs.objectMetaData)
|
|
286
|
+
)
|
|
283
287
|
: tr;
|
|
284
288
|
tr = this.isNodeHasAttribute(document, ATTR_OBJID)
|
|
285
289
|
? tr.step(new SetDocAttrStep(ATTR_OBJID, document.attrs.objectId))
|
|
@@ -289,58 +293,84 @@ class Licit extends React.Component<any, any> {
|
|
|
289
293
|
this._editorView.dispatch(tr);
|
|
290
294
|
};
|
|
291
295
|
|
|
296
|
+
hasDataChanged(nextData: any) {
|
|
297
|
+
let dataChanged = false;
|
|
298
|
+
|
|
299
|
+
// [FS] IRAD-1571 2021-09-27
|
|
300
|
+
// dispatch a transaction that MUST start from the views current state;
|
|
301
|
+
// [FS] IRAD-1589 2021-10-04
|
|
302
|
+
// Do a proper circular JSON comparison.
|
|
303
|
+
if (stringify(this.state.data) !== stringify(nextData)) {
|
|
304
|
+
const editorState = this._editorView.state;
|
|
305
|
+
const nextDoc = editorState.schema.nodeFromJSON(
|
|
306
|
+
nextData ? nextData : EMPTY_DOC_JSON
|
|
307
|
+
);
|
|
308
|
+
dataChanged = !nextDoc.eq(editorState.doc);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
return dataChanged;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
changeContent(data: any) {
|
|
315
|
+
if (this.hasDataChanged(data)) {
|
|
316
|
+
// FS IRAD-1592 2021-11-10
|
|
317
|
+
// Release here quickly, so that update doesn't care about at this point.
|
|
318
|
+
// data changed, so update document content
|
|
319
|
+
setTimeout(this.setContent.bind(this, data), 1);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
292
323
|
shouldComponentUpdate(nextProps: any, nextState: any) {
|
|
293
324
|
// Only interested if properties are set from outside.
|
|
294
325
|
if (!this._skipSCU) {
|
|
295
326
|
this._skipSCU = false;
|
|
296
|
-
let dataChanged = false;
|
|
297
|
-
|
|
298
|
-
// [FS] IRAD-1571 2021-09-27
|
|
299
|
-
// dispatch a transaction that MUST start from the view�s current state;
|
|
300
|
-
// [FS] IRAD-1589 2021-10-04
|
|
301
|
-
// Do a proper circular JSON comparison.
|
|
302
|
-
if (stringify(this.state.data) !== stringify(nextState.data)) {
|
|
303
|
-
const editorState = this._editorView.state;
|
|
304
|
-
const nextDoc = editorState.schema.nodeFromJSON(
|
|
305
|
-
nextState.data ? nextState.data : EMPTY_DOC_JSON
|
|
306
|
-
);
|
|
307
|
-
dataChanged = !nextDoc.eq(editorState.doc);
|
|
308
|
-
}
|
|
309
327
|
|
|
310
|
-
|
|
311
|
-
// data changed, so update document content
|
|
312
|
-
this.setContent(nextState.data);
|
|
313
|
-
}
|
|
328
|
+
this.changeContent(nextState.data);
|
|
314
329
|
|
|
315
330
|
if (this.state.docID !== nextState.docID) {
|
|
316
|
-
|
|
317
|
-
const collabEditing = nextState.docID !== '';
|
|
318
|
-
const editorState = this._editorView.state;
|
|
319
|
-
const setState = this.setState.bind(this);
|
|
320
|
-
const docID = nextState.docID || '';
|
|
321
|
-
const collabServiceURL =
|
|
322
|
-
nextState.collabServiceURL || '/collaboration-service';
|
|
323
|
-
// create new connector
|
|
324
|
-
this._connector = collabEditing
|
|
325
|
-
? new CollabConnector(
|
|
326
|
-
editorState,
|
|
327
|
-
setState,
|
|
328
|
-
{
|
|
329
|
-
docID,
|
|
330
|
-
collabServiceURL,
|
|
331
|
-
},
|
|
332
|
-
this._defaultEditorSchema,
|
|
333
|
-
this._defaultEditorPlugins,
|
|
334
|
-
// [FS] IRAD-1578 2021-09-27
|
|
335
|
-
this.onReady.bind(this)
|
|
336
|
-
)
|
|
337
|
-
: new SimpleConnector(editorState, setState);
|
|
331
|
+
setTimeout(this.setDocID.bind(this, nextState), 1);
|
|
338
332
|
}
|
|
339
333
|
}
|
|
340
334
|
|
|
341
335
|
return true;
|
|
342
336
|
}
|
|
343
337
|
|
|
338
|
+
setDocID(nextState: any) {
|
|
339
|
+
// Collaborative mode changed
|
|
340
|
+
const collabEditing = nextState.docID !== '';
|
|
341
|
+
const editorState = this._editorView.state;
|
|
342
|
+
const setState = this.setState.bind(this);
|
|
343
|
+
const docID = nextState.docID || '';
|
|
344
|
+
const collabServiceURL =
|
|
345
|
+
nextState.collabServiceURL || '/collaboration-service';
|
|
346
|
+
|
|
347
|
+
if (this._connector) {
|
|
348
|
+
this._connector.cleanUp();
|
|
349
|
+
}
|
|
350
|
+
// create new connector
|
|
351
|
+
this._connector = collabEditing
|
|
352
|
+
? new CollabConnector(
|
|
353
|
+
editorState,
|
|
354
|
+
setState,
|
|
355
|
+
{
|
|
356
|
+
docID,
|
|
357
|
+
collabServiceURL,
|
|
358
|
+
},
|
|
359
|
+
this._defaultEditorSchema,
|
|
360
|
+
this._defaultEditorPlugins,
|
|
361
|
+
// [FS] IRAD-1578 2021-09-27
|
|
362
|
+
this.onReady.bind(this)
|
|
363
|
+
)
|
|
364
|
+
: new SimpleConnector(editorState, setState);
|
|
365
|
+
|
|
366
|
+
// FS IRAD-1592 2021-11-10
|
|
367
|
+
// Notify collab server
|
|
368
|
+
if (this._connector.updateSchema) {
|
|
369
|
+
// Use known editorState to update schema.
|
|
370
|
+
this._connector.updateSchema(editorState.schema);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
344
374
|
render(): React.Element<any> {
|
|
345
375
|
const {
|
|
346
376
|
editorState,
|
|
@@ -401,7 +431,18 @@ class Licit extends React.Component<any, any> {
|
|
|
401
431
|
|
|
402
432
|
if (transaction.docChanged) {
|
|
403
433
|
const docJson = transaction.doc.toJSON();
|
|
404
|
-
|
|
434
|
+
let isEmpty = false;
|
|
435
|
+
|
|
436
|
+
if (docJson.content && docJson.content.length === 1) {
|
|
437
|
+
if (
|
|
438
|
+
!docJson.content[0].content ||
|
|
439
|
+
(docJson.content[0].content &&
|
|
440
|
+
docJson.content[0].content[0].text &&
|
|
441
|
+
'' === docJson.content[0].content[0].text.trim())
|
|
442
|
+
) {
|
|
443
|
+
isEmpty = true;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
405
446
|
|
|
406
447
|
// setCFlags is/was always the opposite of isEmpty.
|
|
407
448
|
if (isEmpty) {
|
|
@@ -419,27 +460,6 @@ class Licit extends React.Component<any, any> {
|
|
|
419
460
|
}
|
|
420
461
|
}
|
|
421
462
|
};
|
|
422
|
-
|
|
423
|
-
isDocEmpty(docJson: Object) {
|
|
424
|
-
let isEmpty = false;
|
|
425
|
-
|
|
426
|
-
if (docJson.content && docJson.content.length === 1) {
|
|
427
|
-
if (
|
|
428
|
-
!docJson.content[0].content ||
|
|
429
|
-
(docJson.content[0].content &&
|
|
430
|
-
// [FS] IRAD-1710 2022-03-04
|
|
431
|
-
// Empty if no content OR when the one & only text content is empty.
|
|
432
|
-
1 === docJson.content[0].content.length &&
|
|
433
|
-
'text' === docJson.content[0].content[0].type &&
|
|
434
|
-
docJson.content[0].content[0].text &&
|
|
435
|
-
'' === docJson.content[0].content[0].text)
|
|
436
|
-
) {
|
|
437
|
-
isEmpty = true;
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
return isEmpty;
|
|
441
|
-
}
|
|
442
|
-
|
|
443
463
|
// [FS] IRAD-1173 2021-02-25
|
|
444
464
|
// Bug fix: Transaction mismatch error when a dialog is opened and keep typing.
|
|
445
465
|
closeOpenedPopupModels() {
|
|
@@ -456,12 +476,8 @@ class Licit extends React.Component<any, any> {
|
|
|
456
476
|
this._editorView = editorView;
|
|
457
477
|
const tr = state.tr;
|
|
458
478
|
const doc = state.doc;
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
if (!this.isDocEmpty(doc.toJSON())) {
|
|
462
|
-
const trx = tr.setSelection(TextSelection.create(doc, 0, doc.content.size));
|
|
463
|
-
dispatch(trx.scrollIntoView());
|
|
464
|
-
}
|
|
479
|
+
const trx = tr.setSelection(TextSelection.create(doc, 0, doc.content.size));
|
|
480
|
+
dispatch(trx.scrollIntoView());
|
|
465
481
|
|
|
466
482
|
// [FS] IRAD-1578 2021-09-27
|
|
467
483
|
// In collab mode, fire onRead only after getting the response from collab server.
|