@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
package/dist/client/Licit.js
CHANGED
|
@@ -4,63 +4,39 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.DataType = void 0;
|
|
7
|
-
|
|
8
7
|
var _prosemirrorState = require("prosemirror-state");
|
|
9
|
-
|
|
10
8
|
var _prosemirrorModel = require("prosemirror-model");
|
|
11
|
-
|
|
12
9
|
var _prosemirrorTransform = require("prosemirror-transform");
|
|
13
|
-
|
|
14
10
|
var _prosemirrorView = require("prosemirror-view");
|
|
15
|
-
|
|
16
11
|
var React = _interopRequireWildcard(require("react"));
|
|
17
|
-
|
|
18
12
|
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
19
|
-
|
|
20
13
|
var _flatted = require("flatted");
|
|
21
|
-
|
|
22
14
|
var _convertFromJSON = _interopRequireDefault(require("../convertFromJSON"));
|
|
23
|
-
|
|
24
15
|
var _RichTextEditor = _interopRequireDefault(require("../ui/RichTextEditor"));
|
|
25
|
-
|
|
26
16
|
var _uuid = _interopRequireDefault(require("../uuid"));
|
|
27
|
-
|
|
28
17
|
var _SimpleConnector = _interopRequireDefault(require("./SimpleConnector"));
|
|
29
|
-
|
|
30
18
|
var _CollabConnector = _interopRequireDefault(require("./CollabConnector"));
|
|
31
|
-
|
|
32
19
|
var _createEmptyEditorState = require("../createEmptyEditorState");
|
|
33
|
-
|
|
34
20
|
var _licitUiCommands = require("@modusoperandi/licit-ui-commands");
|
|
35
|
-
|
|
36
21
|
var _AlertInfo = _interopRequireDefault(require("../ui/AlertInfo"));
|
|
37
|
-
|
|
38
22
|
var _licitDocAttrsStep = require("@modusoperandi/licit-doc-attrs-step");
|
|
39
|
-
|
|
40
23
|
require("./licit.css");
|
|
41
|
-
|
|
42
24
|
var _buildEditorPlugins = _interopRequireDefault(require("../buildEditorPlugins"));
|
|
43
|
-
|
|
44
25
|
var _EditorMarks = _interopRequireDefault(require("../EditorMarks"));
|
|
45
|
-
|
|
46
26
|
var _EditorNodes = _interopRequireDefault(require("../EditorNodes"));
|
|
47
|
-
|
|
48
27
|
var _convertFromHTML = _interopRequireDefault(require("../convertFromHTML"));
|
|
49
|
-
|
|
50
28
|
var _Types = require("../Types");
|
|
51
|
-
|
|
52
29
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
53
|
-
|
|
54
30
|
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); }
|
|
55
|
-
|
|
56
31
|
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; }
|
|
57
|
-
|
|
58
|
-
function
|
|
59
|
-
|
|
32
|
+
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; }
|
|
33
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
34
|
+
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); }
|
|
60
35
|
const DataType = Object.freeze({
|
|
61
36
|
JSON: Symbol('json'),
|
|
62
37
|
HTML: Symbol('html')
|
|
63
38
|
});
|
|
39
|
+
|
|
64
40
|
/**
|
|
65
41
|
* LICIT properties:
|
|
66
42
|
* docID {string} [] Collaborative Doument ID
|
|
@@ -79,9 +55,7 @@ const DataType = Object.freeze({
|
|
|
79
55
|
* embedded {boolean} [false] Disable/Enable inline behaviour.
|
|
80
56
|
* plugins [plugins] External Plugins into the editor.
|
|
81
57
|
*/
|
|
82
|
-
|
|
83
58
|
exports.DataType = DataType;
|
|
84
|
-
|
|
85
59
|
class Licit extends React.Component {
|
|
86
60
|
// This will be handy in updating document's content.
|
|
87
61
|
// Flag to decide whether to skip shouldComponentUpdate
|
|
@@ -92,39 +66,32 @@ class Licit extends React.Component {
|
|
|
92
66
|
get editorView() {
|
|
93
67
|
return this._editorView;
|
|
94
68
|
}
|
|
95
|
-
|
|
96
69
|
constructor(_props, context) {
|
|
97
70
|
var _this;
|
|
98
|
-
|
|
99
71
|
super(_props, context);
|
|
100
72
|
_this = this;
|
|
101
|
-
|
|
102
73
|
_defineProperty(this, "_runtime", void 0);
|
|
103
|
-
|
|
104
74
|
_defineProperty(this, "_connector", void 0);
|
|
105
|
-
|
|
106
75
|
_defineProperty(this, "_clientID", void 0);
|
|
107
|
-
|
|
108
76
|
_defineProperty(this, "_editorView", void 0);
|
|
109
|
-
|
|
110
77
|
_defineProperty(this, "_skipSCU", void 0);
|
|
111
|
-
|
|
112
78
|
_defineProperty(this, "_defaultEditorSchema", void 0);
|
|
113
|
-
|
|
114
79
|
_defineProperty(this, "_defaultEditorPlugins", void 0);
|
|
115
|
-
|
|
80
|
+
_defineProperty(this, "_pasteJSONPlugin", void 0);
|
|
116
81
|
_defineProperty(this, "_devTools", void 0);
|
|
117
|
-
|
|
118
82
|
_defineProperty(this, "_applyDevTools", void 0);
|
|
119
|
-
|
|
120
83
|
_defineProperty(this, "_popUp", null);
|
|
121
|
-
|
|
84
|
+
_defineProperty(this, "insertJSON", json => {
|
|
85
|
+
if (this._pasteJSONPlugin && this._pasteJSONPlugin.insert) {
|
|
86
|
+
this._pasteJSONPlugin.insert(json, this._editorView);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
122
89
|
_defineProperty(this, "setContent", function () {
|
|
123
90
|
let content = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
124
91
|
let dataType = arguments.length > 1 ? arguments[1] : undefined;
|
|
125
|
-
_this.skipDataTypeCheck = false;
|
|
92
|
+
_this.skipDataTypeCheck = false;
|
|
93
|
+
// [FS] IRAD-1571 2021-09-27
|
|
126
94
|
// dispatch a transaction that MUST start from the views current state;
|
|
127
|
-
|
|
128
95
|
const editorState = _this._editorView.state;
|
|
129
96
|
const {
|
|
130
97
|
doc
|
|
@@ -132,32 +99,28 @@ class Licit extends React.Component {
|
|
|
132
99
|
let {
|
|
133
100
|
tr
|
|
134
101
|
} = editorState;
|
|
135
|
-
|
|
136
102
|
const document = _this.getDocument(content, editorState, dataType);
|
|
103
|
+
_this.skipDataTypeCheck = true;
|
|
137
104
|
|
|
138
|
-
|
|
105
|
+
// [FS] IRAD-1593 2021-10-12
|
|
139
106
|
// Reset lastKeyCode since the content is set dynamically and so lastKeyCode is invalid now.
|
|
140
|
-
|
|
141
107
|
_this._editorView.lastKeyCode = null;
|
|
142
|
-
|
|
143
108
|
const selection = _prosemirrorState.TextSelection.create(doc, 0, doc.content.size);
|
|
144
|
-
|
|
145
|
-
|
|
109
|
+
tr = tr.setSelection(selection).replaceSelectionWith(document, false);
|
|
110
|
+
// [FS] IRAD-1092 2020-12-03
|
|
146
111
|
// set the value for object metadata and objectId
|
|
147
112
|
// Should update all document attributes.
|
|
148
|
-
|
|
149
113
|
Object.keys(document.attrs).forEach(attr => {
|
|
150
114
|
tr = tr.step(new _licitDocAttrsStep.SetDocAttrStep(attr, document.attrs[attr]));
|
|
151
115
|
});
|
|
152
116
|
_this._skipSCU = true;
|
|
153
|
-
|
|
154
117
|
_this._editorView.dispatch(tr);
|
|
155
118
|
});
|
|
156
|
-
|
|
157
119
|
_defineProperty(this, "_onChange", data => {
|
|
158
120
|
const {
|
|
159
121
|
transaction
|
|
160
122
|
} = data;
|
|
123
|
+
|
|
161
124
|
/*
|
|
162
125
|
** ProseMirror Debug Tool's Snapshot creates a new state and sets that to editor view's state.
|
|
163
126
|
** This results in the connector's state as an orphan and thus transaction mismatch error.
|
|
@@ -167,7 +130,6 @@ class Licit extends React.Component {
|
|
|
167
130
|
if (this._editorView) {
|
|
168
131
|
const isSameState = this._connector._editorState == this._editorView.state;
|
|
169
132
|
let invokeOnEdit = false;
|
|
170
|
-
|
|
171
133
|
if (!isSameState) {
|
|
172
134
|
this._connector._editorState = this._editorView.state;
|
|
173
135
|
invokeOnEdit = true;
|
|
@@ -178,39 +140,35 @@ class Licit extends React.Component {
|
|
|
178
140
|
invokeOnEdit = true;
|
|
179
141
|
}
|
|
180
142
|
}
|
|
181
|
-
|
|
182
143
|
if (invokeOnEdit) {
|
|
183
144
|
// [FS] IRAD-1236 2020-03-05
|
|
184
145
|
// Only need to call if there is any difference in collab mode OR always in non-collab mode.
|
|
185
146
|
this._connector.onEdit(transaction, this._editorView);
|
|
186
147
|
}
|
|
187
|
-
|
|
188
148
|
if (transaction.docChanged) {
|
|
189
149
|
const docJson = transaction.doc.toJSON();
|
|
190
150
|
let isEmpty = false;
|
|
191
|
-
|
|
192
151
|
if (docJson.content && docJson.content.length === 1) {
|
|
193
152
|
if (!docJson.content[0].content || docJson.content[0].content && docJson.content[0].content[0].text && '' === docJson.content[0].content[0].text.trim()) {
|
|
194
153
|
isEmpty = true;
|
|
195
154
|
}
|
|
196
|
-
}
|
|
197
|
-
|
|
155
|
+
}
|
|
198
156
|
|
|
157
|
+
// setCFlags is/was always the opposite of isEmpty.
|
|
199
158
|
if (isEmpty) {
|
|
200
159
|
this.resetCounters(transaction);
|
|
201
160
|
} else {
|
|
202
161
|
this.setCounterFlags(transaction, false);
|
|
203
|
-
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Changing 2nd parameter from boolean to object was not in any way
|
|
204
165
|
// backwards compatible. Any conditional logic placed on isEmpty was
|
|
205
166
|
// broken. Reverting that change, then adding view as a 3rd parameter.
|
|
206
|
-
|
|
207
|
-
|
|
208
167
|
this.state.onChangeCB(docJson, isEmpty, this._editorView);
|
|
209
168
|
this.closeOpenedPopupModels();
|
|
210
169
|
}
|
|
211
170
|
}
|
|
212
171
|
});
|
|
213
|
-
|
|
214
172
|
_defineProperty(this, "_onReady", editorView => {
|
|
215
173
|
// [FS][06-APR-2020][IRAD-922]
|
|
216
174
|
// Showing focus in the editor.
|
|
@@ -222,17 +180,16 @@ class Licit extends React.Component {
|
|
|
222
180
|
const tr = state.tr;
|
|
223
181
|
const doc = state.doc;
|
|
224
182
|
const trx = tr.setSelection(_prosemirrorState.TextSelection.create(doc, 0, doc.content.size));
|
|
225
|
-
dispatch(trx.scrollIntoView());
|
|
226
|
-
// In collab mode, fire onRead only after getting the response from collab server.
|
|
183
|
+
dispatch(trx.scrollIntoView());
|
|
227
184
|
|
|
185
|
+
// [FS] IRAD-1578 2021-09-27
|
|
186
|
+
// In collab mode, fire onRead only after getting the response from collab server.
|
|
228
187
|
if (this.state.onReadyCB && this.state.docID === '') {
|
|
229
188
|
editorView.focus();
|
|
230
189
|
this.state.onReadyCB(this);
|
|
231
190
|
}
|
|
232
|
-
|
|
233
191
|
this.initDevTool(this.state.debug, editorView);
|
|
234
192
|
});
|
|
235
|
-
|
|
236
193
|
_defineProperty(this, "setProps", props => {
|
|
237
194
|
// [FS] IRAD-1571 2021-10-08
|
|
238
195
|
// Since the debug lies outside the editor,
|
|
@@ -245,26 +202,23 @@ class Licit extends React.Component {
|
|
|
245
202
|
this.destroyDevTool();
|
|
246
203
|
}
|
|
247
204
|
}
|
|
248
|
-
|
|
249
205
|
if (this.state.readOnly) {
|
|
250
206
|
// It should be possible to load content into the editor in readonly as well.
|
|
251
207
|
// It should not be necessary to make the component writable any time during the process
|
|
252
208
|
const propsCopy = {};
|
|
253
209
|
this._skipSCU = true;
|
|
254
|
-
Object.assign(propsCopy, props);
|
|
255
|
-
|
|
210
|
+
Object.assign(propsCopy, props);
|
|
211
|
+
// make writable without content change
|
|
256
212
|
propsCopy.readOnly = false;
|
|
257
213
|
delete propsCopy.data;
|
|
258
214
|
this.setState(propsCopy);
|
|
259
215
|
}
|
|
260
|
-
|
|
261
|
-
|
|
216
|
+
this.skipDataTypeCheck = false;
|
|
217
|
+
// Need to go through shouldComponentUpdate lifecycle here, when updated from outside,
|
|
262
218
|
// so that content is modified gracefully using transaction so that undo/redo works too.
|
|
263
|
-
|
|
264
219
|
this._skipSCU = false;
|
|
265
220
|
this.setState(props);
|
|
266
221
|
});
|
|
267
|
-
|
|
268
222
|
_defineProperty(this, "exportPDF", () => {
|
|
269
223
|
new Promise(async (resolve, reject) => {
|
|
270
224
|
try {
|
|
@@ -286,29 +240,25 @@ class Licit extends React.Component {
|
|
|
286
240
|
}
|
|
287
241
|
});
|
|
288
242
|
});
|
|
289
|
-
|
|
290
243
|
this.initialize(_props);
|
|
291
244
|
}
|
|
292
|
-
|
|
293
245
|
initialize(props) {
|
|
294
246
|
this._clientID = (0, _uuid.default)();
|
|
295
247
|
this._editorView = null;
|
|
296
248
|
this._skipSCU = true;
|
|
249
|
+
const noop = function () {};
|
|
297
250
|
|
|
298
|
-
|
|
251
|
+
// [FS] IRAD-981 2020-06-10
|
|
299
252
|
// Component's configurations.
|
|
300
253
|
// [FS] IRAD-1552 2021-08-26
|
|
301
254
|
// Collaboration server / client should allow string values for document identifiers.
|
|
302
|
-
|
|
303
|
-
|
|
304
255
|
const docID = props.docID || ''; // Empty means collaborative.
|
|
305
|
-
|
|
306
|
-
|
|
256
|
+
const collaborative = docID !== '';
|
|
257
|
+
// [FS] IRAD-1553 2021-08-26
|
|
307
258
|
// Configurable Collaboration Service URL.
|
|
308
|
-
|
|
309
259
|
const collabServiceURL = props.collabServiceURL || '/collaboration-service';
|
|
310
|
-
const debug = props.debug || false;
|
|
311
|
-
|
|
260
|
+
const debug = props.debug || false;
|
|
261
|
+
// Default width and height to undefined
|
|
312
262
|
const width = props.width || undefined;
|
|
313
263
|
const height = props.height || undefined;
|
|
314
264
|
const onChangeCB = typeof props.onChange === 'function' ? props.onChange : noop;
|
|
@@ -320,26 +270,29 @@ class Licit extends React.Component {
|
|
|
320
270
|
const embedded = props.embedded || false; // [FS] IRAD-996 2020-06-30
|
|
321
271
|
// [FS] 2020-07-03
|
|
322
272
|
// Handle Image Upload from Angular App
|
|
323
|
-
|
|
324
273
|
const runtime = props.runtime || null;
|
|
325
|
-
const plugins = props.plugins || null;
|
|
274
|
+
const plugins = props.plugins || null;
|
|
275
|
+
// This flag decides whether DataType.HTML check is needed when
|
|
326
276
|
// changing document. If it forcefully done, it is not needed, otherwise needed.
|
|
327
|
-
|
|
328
277
|
this.skipDataTypeCheck = false;
|
|
329
278
|
this._defaultEditorSchema = new _prosemirrorModel.Schema({
|
|
330
279
|
nodes: _EditorNodes.default,
|
|
331
280
|
marks: _EditorMarks.default
|
|
332
281
|
});
|
|
333
282
|
this._defaultEditorPlugins = new _buildEditorPlugins.default(this._defaultEditorSchema).get();
|
|
283
|
+
this._pasteJSONPlugin = null;
|
|
334
284
|
const editorState = this.initEditorState(plugins, dataType, data);
|
|
335
285
|
data = editorState.doc;
|
|
336
286
|
const setState = this.setState.bind(this);
|
|
337
287
|
this._connector = collaborative ? new _CollabConnector.default(editorState, setState, {
|
|
338
288
|
docID,
|
|
339
289
|
collabServiceURL
|
|
340
|
-
}, this._defaultEditorSchema, this._defaultEditorPlugins,
|
|
290
|
+
}, this._defaultEditorSchema, this._defaultEditorPlugins,
|
|
291
|
+
// [FS] IRAD-1578 2021-09-27
|
|
341
292
|
this.onReady.bind(this)) : new _SimpleConnector.default(editorState, setState);
|
|
342
|
-
this._connector._dataDefined = !!props.data;
|
|
293
|
+
this._connector._dataDefined = !!props.data;
|
|
294
|
+
|
|
295
|
+
// FS IRAD-989 2020-18-06
|
|
343
296
|
// updating properties should automatically render the changes
|
|
344
297
|
|
|
345
298
|
this.state = {
|
|
@@ -357,23 +310,23 @@ class Licit extends React.Component {
|
|
|
357
310
|
embedded,
|
|
358
311
|
runtime,
|
|
359
312
|
dataType
|
|
360
|
-
};
|
|
361
|
-
// Get the modified schema from editorstate and send it to collab server
|
|
313
|
+
};
|
|
362
314
|
|
|
315
|
+
// FS IRAD-1040 2020-26-08
|
|
316
|
+
// Get the modified schema from editorstate and send it to collab server
|
|
363
317
|
if (this._connector.updateSchema) {
|
|
364
318
|
// Use known editorState to update schema.
|
|
365
319
|
this._connector.updateSchema(editorState.schema, data);
|
|
366
320
|
}
|
|
367
321
|
}
|
|
368
|
-
|
|
369
322
|
initEditorState(plugins, dataType, data) {
|
|
370
323
|
let editorState = null;
|
|
371
324
|
const effectivePlugins = this.getEffectivePlugins(this._defaultEditorSchema, this._defaultEditorPlugins, plugins);
|
|
372
|
-
|
|
325
|
+
this._pasteJSONPlugin = effectivePlugins.pasteJSONPlugin;
|
|
373
326
|
if (DataType.JSON === dataType) {
|
|
374
|
-
editorState = (0, _convertFromJSON.default)(data, null, effectivePlugins.schema, effectivePlugins.plugins);
|
|
327
|
+
editorState = (0, _convertFromJSON.default)(data, null, effectivePlugins.schema, effectivePlugins.plugins);
|
|
328
|
+
// [FS] IRAD-1067 2020-09-19
|
|
375
329
|
// The editorState will return null if the doc Json is mal-formed
|
|
376
|
-
|
|
377
330
|
if (null === editorState) {
|
|
378
331
|
editorState = (0, _convertFromJSON.default)(_createEmptyEditorState.EMPTY_DOC_JSON, null, effectivePlugins.schema, effectivePlugins.plugins);
|
|
379
332
|
this.showAlert();
|
|
@@ -381,50 +334,47 @@ class Licit extends React.Component {
|
|
|
381
334
|
} else {
|
|
382
335
|
editorState = (0, _convertFromHTML.default)(data, effectivePlugins.schema, effectivePlugins.plugins);
|
|
383
336
|
}
|
|
384
|
-
|
|
385
337
|
return editorState;
|
|
386
338
|
}
|
|
387
|
-
|
|
388
339
|
getEffectivePlugins(schema, defaultPlugins, plugins) {
|
|
389
340
|
const effectivePlugins = defaultPlugins;
|
|
390
|
-
|
|
341
|
+
let pasteJSONPlugin = null;
|
|
391
342
|
if (plugins) {
|
|
392
343
|
for (const p of plugins) {
|
|
393
344
|
if (!effectivePlugins.includes(p)) {
|
|
394
345
|
effectivePlugins.push(p);
|
|
395
|
-
|
|
396
346
|
if (p.getEffectiveSchema) {
|
|
397
347
|
schema = p.getEffectiveSchema(schema);
|
|
398
348
|
}
|
|
399
|
-
|
|
400
349
|
if (p.initKeyCommands) {
|
|
401
350
|
effectivePlugins.push(p.initKeyCommands());
|
|
402
351
|
}
|
|
352
|
+
if (p.insert) {
|
|
353
|
+
pasteJSONPlugin = p;
|
|
354
|
+
}
|
|
403
355
|
}
|
|
404
356
|
}
|
|
405
357
|
}
|
|
406
|
-
|
|
407
358
|
return {
|
|
408
359
|
plugins: effectivePlugins,
|
|
409
|
-
schema
|
|
360
|
+
schema,
|
|
361
|
+
pasteJSONPlugin
|
|
410
362
|
};
|
|
411
|
-
}
|
|
412
|
-
|
|
363
|
+
}
|
|
413
364
|
|
|
365
|
+
// [FS] IRAD-1578 2021-09-27
|
|
414
366
|
onReady(state) {
|
|
415
367
|
const collabEditing = this.state.docID !== '';
|
|
416
|
-
|
|
417
368
|
if (collabEditing) {
|
|
418
369
|
this._editorView && this._editorView.focus();
|
|
419
|
-
|
|
420
370
|
if (this.state.onReadyCB) {
|
|
421
371
|
this.state.onReadyCB(this);
|
|
422
372
|
}
|
|
423
373
|
}
|
|
424
|
-
}
|
|
425
|
-
// Alert funtion to show document is corrupted
|
|
426
|
-
|
|
374
|
+
}
|
|
427
375
|
|
|
376
|
+
// [FS] IRAD-1067 2020-09-19
|
|
377
|
+
// Alert funtion to show document is corrupted
|
|
428
378
|
showAlert() {
|
|
429
379
|
const anchor = null;
|
|
430
380
|
this._popUp = (0, _licitUiCommands.createPopUp)(_AlertInfo.default, null, {
|
|
@@ -437,45 +387,35 @@ class Licit extends React.Component {
|
|
|
437
387
|
}
|
|
438
388
|
});
|
|
439
389
|
}
|
|
440
|
-
|
|
441
390
|
resetCounters(transaction) {
|
|
442
391
|
for (let index = 1; index <= 10; index++) {
|
|
443
392
|
const counterVar = 'set-cust-style-counter-' + index;
|
|
444
393
|
const setCounterVal = window[counterVar];
|
|
445
|
-
|
|
446
394
|
if (setCounterVal) {
|
|
447
395
|
delete window[counterVar];
|
|
448
396
|
}
|
|
449
397
|
}
|
|
450
|
-
|
|
451
398
|
this.setCounterFlags(transaction, true);
|
|
452
399
|
}
|
|
453
|
-
|
|
454
400
|
setCounterFlags(transaction, reset) {
|
|
455
401
|
let modified = false;
|
|
456
402
|
let counterFlags = null;
|
|
457
403
|
const existingCFlags = transaction.doc.attrs.counterFlags;
|
|
458
|
-
|
|
459
404
|
if (reset && !existingCFlags) {
|
|
460
405
|
return;
|
|
461
406
|
}
|
|
462
|
-
|
|
463
407
|
for (let index = 1; index <= 10; index++) {
|
|
464
408
|
const counterVar = 'set-cust-style-counter-' + index;
|
|
465
409
|
const setCounterVal = window[counterVar];
|
|
466
|
-
|
|
467
410
|
if (setCounterVal) {
|
|
468
411
|
if (!counterFlags) {
|
|
469
412
|
counterFlags = {};
|
|
470
413
|
}
|
|
471
|
-
|
|
472
414
|
counterFlags[counterVar] = true;
|
|
473
|
-
|
|
474
415
|
if (!existingCFlags) {
|
|
475
416
|
modified = true;
|
|
476
417
|
}
|
|
477
418
|
}
|
|
478
|
-
|
|
479
419
|
if (!modified) {
|
|
480
420
|
if (existingCFlags) {
|
|
481
421
|
if (setCounterVal) {
|
|
@@ -488,55 +428,46 @@ class Licit extends React.Component {
|
|
|
488
428
|
}
|
|
489
429
|
}
|
|
490
430
|
}
|
|
491
|
-
|
|
492
431
|
if (modified) {
|
|
493
432
|
const tr = this._editorView.state.tr.step(new _licitDocAttrsStep.SetDocAttrStep('counterFlags', counterFlags));
|
|
494
|
-
|
|
495
433
|
this._editorView.dispatch(tr);
|
|
496
434
|
}
|
|
497
435
|
}
|
|
498
|
-
|
|
499
436
|
getDeletedArtifactIds() {
|
|
500
437
|
if (this._connector.getDeletedArtifactIds) {
|
|
501
438
|
this._connector.getDeletedArtifactIds(this.state.editorState.schema);
|
|
502
439
|
}
|
|
503
440
|
}
|
|
504
|
-
|
|
505
441
|
isNodeHasAttribute(node, attrName) {
|
|
506
442
|
return node.attrs && node.attrs[attrName];
|
|
507
443
|
}
|
|
508
|
-
|
|
509
444
|
getDocument(content, editorState, dataType) {
|
|
510
445
|
let document = null;
|
|
511
446
|
const {
|
|
512
447
|
schema
|
|
513
448
|
} = editorState;
|
|
514
|
-
|
|
515
449
|
if (DataType.JSON === dataType || this.skipDataTypeCheck) {
|
|
516
450
|
document = schema.nodeFromJSON(content ? content : _createEmptyEditorState.EMPTY_DOC_JSON);
|
|
517
451
|
} else {
|
|
518
452
|
const tempEState = (0, _convertFromHTML.default)(content ? content : '', schema, editorState.plugins);
|
|
519
453
|
document = tempEState.doc;
|
|
520
454
|
}
|
|
521
|
-
|
|
522
455
|
return document;
|
|
523
456
|
}
|
|
524
|
-
|
|
525
457
|
hasDataChanged(nextData, nextDataType) {
|
|
526
|
-
let dataChanged = false;
|
|
458
|
+
let dataChanged = false;
|
|
459
|
+
|
|
460
|
+
// [FS] IRAD-1571 2021-09-27
|
|
527
461
|
// dispatch a transaction that MUST start from the views current state;
|
|
528
462
|
// [FS] IRAD-1589 2021-10-04
|
|
529
463
|
// Do a proper circular JSON comparison.
|
|
530
|
-
|
|
531
464
|
if ((0, _flatted.stringify)(this.state.data) !== (0, _flatted.stringify)(nextData)) {
|
|
532
465
|
const editorState = this._editorView.state;
|
|
533
466
|
const nextDoc = this.getDocument(nextData, editorState, nextDataType);
|
|
534
467
|
dataChanged = !nextDoc.eq(editorState.doc);
|
|
535
468
|
}
|
|
536
|
-
|
|
537
469
|
return dataChanged;
|
|
538
470
|
}
|
|
539
|
-
|
|
540
471
|
changeContent(data, dataType) {
|
|
541
472
|
if (this.hasDataChanged(data, dataType)) {
|
|
542
473
|
// FS IRAD-1592 2021-11-10
|
|
@@ -545,22 +476,18 @@ class Licit extends React.Component {
|
|
|
545
476
|
setTimeout(this.setContent.bind(this, data, dataType), 1);
|
|
546
477
|
}
|
|
547
478
|
}
|
|
548
|
-
|
|
549
479
|
shouldComponentUpdate(nextProps, nextState) {
|
|
550
480
|
// Only interested if properties are set from outside.
|
|
551
481
|
if (!this._skipSCU) {
|
|
552
482
|
this._skipSCU = false;
|
|
553
483
|
this.changeContent(nextState.data, nextState.dataType);
|
|
554
|
-
|
|
555
484
|
if (this.state.docID !== nextState.docID) {
|
|
556
485
|
setTimeout(this.setDocID.bind(this, nextState), 1);
|
|
557
486
|
}
|
|
558
487
|
}
|
|
559
|
-
|
|
560
488
|
this.skipDataTypeCheck = true;
|
|
561
489
|
return true;
|
|
562
490
|
}
|
|
563
|
-
|
|
564
491
|
setDocID(nextState) {
|
|
565
492
|
// Collaborative mode changed
|
|
566
493
|
const collabEditing = nextState.docID !== '';
|
|
@@ -568,25 +495,24 @@ class Licit extends React.Component {
|
|
|
568
495
|
const setState = this.setState.bind(this);
|
|
569
496
|
const docID = nextState.docID || '';
|
|
570
497
|
const collabServiceURL = nextState.collabServiceURL || '/collaboration-service';
|
|
571
|
-
|
|
572
498
|
if (this._connector) {
|
|
573
499
|
this._connector.cleanUp();
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
|
|
500
|
+
}
|
|
501
|
+
// create new connector
|
|
577
502
|
this._connector = collabEditing ? new _CollabConnector.default(editorState, setState, {
|
|
578
503
|
docID,
|
|
579
504
|
collabServiceURL
|
|
580
|
-
}, this._defaultEditorSchema, this._defaultEditorPlugins,
|
|
581
|
-
|
|
582
|
-
|
|
505
|
+
}, this._defaultEditorSchema, this._defaultEditorPlugins,
|
|
506
|
+
// [FS] IRAD-1578 2021-09-27
|
|
507
|
+
this.onReady.bind(this)) : new _SimpleConnector.default(editorState, setState);
|
|
583
508
|
|
|
509
|
+
// FS IRAD-1592 2021-11-10
|
|
510
|
+
// Notify collab server
|
|
584
511
|
if (this._connector.updateSchema) {
|
|
585
512
|
// Use known editorState to update schema.
|
|
586
513
|
this._connector.updateSchema(editorState.schema);
|
|
587
514
|
}
|
|
588
515
|
}
|
|
589
|
-
|
|
590
516
|
render() {
|
|
591
517
|
const {
|
|
592
518
|
editorState,
|
|
@@ -596,10 +522,10 @@ class Licit extends React.Component {
|
|
|
596
522
|
disabled,
|
|
597
523
|
embedded,
|
|
598
524
|
runtime
|
|
599
|
-
} = this.state;
|
|
525
|
+
} = this.state;
|
|
526
|
+
// [FS] IRAD-978 2020-06-05
|
|
600
527
|
// Using 100vw & 100vh (100% viewport) is not ideal for a component which is expected to be a part of a page,
|
|
601
528
|
// so changing it to 100% width & height which will occupy the area relative to its parent.
|
|
602
|
-
|
|
603
529
|
return /*#__PURE__*/React.createElement(_RichTextEditor.default, {
|
|
604
530
|
disabled: disabled,
|
|
605
531
|
editorState: editorState,
|
|
@@ -612,17 +538,14 @@ class Licit extends React.Component {
|
|
|
612
538
|
width: width
|
|
613
539
|
});
|
|
614
540
|
}
|
|
615
|
-
|
|
616
541
|
// [FS] IRAD-1173 2021-02-25
|
|
617
542
|
// Bug fix: Transaction mismatch error when a dialog is opened and keep typing.
|
|
618
543
|
closeOpenedPopupModels() {
|
|
619
544
|
const element = document.getElementsByClassName('czi-pop-up-element')[0];
|
|
620
|
-
|
|
621
545
|
if (element && element.parentElement) {
|
|
622
546
|
element.parentElement.removeChild(element);
|
|
623
547
|
}
|
|
624
548
|
}
|
|
625
|
-
|
|
626
549
|
initDevTool(debug, editorView) {
|
|
627
550
|
// [FS] IRAD-1575 2021-09-27
|
|
628
551
|
if (debug) {
|
|
@@ -633,21 +556,18 @@ class Licit extends React.Component {
|
|
|
633
556
|
// for clarity and future proofing.
|
|
634
557
|
const {
|
|
635
558
|
applyDevTools
|
|
636
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require('prosemirror-dev-tools')));
|
|
637
|
-
|
|
638
|
-
this._applyDevTools = applyDevTools;
|
|
639
|
-
|
|
559
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require('prosemirror-dev-tools')));
|
|
560
|
+
// got the pm dev tools instance.
|
|
561
|
+
this._applyDevTools = applyDevTools;
|
|
562
|
+
// Attach debug tools to current editor instance.
|
|
640
563
|
this._applyDevTools(editorView);
|
|
641
|
-
|
|
642
564
|
resolve(() => {
|
|
643
565
|
// [FS] IRAD-1571 2021-10-08
|
|
644
566
|
// Prosemirror Dev Tools handles as if one only instance is used in a page and
|
|
645
567
|
// hence handling removal here gracefully.
|
|
646
568
|
const place = document.querySelector('.'.concat('__prosemirror-dev-tools__'));
|
|
647
|
-
|
|
648
569
|
if (place) {
|
|
649
570
|
_reactDom.default.unmountComponentAtNode(place);
|
|
650
|
-
|
|
651
571
|
place.innerHTML = '';
|
|
652
572
|
}
|
|
653
573
|
});
|
|
@@ -655,15 +575,14 @@ class Licit extends React.Component {
|
|
|
655
575
|
reject();
|
|
656
576
|
}
|
|
657
577
|
});
|
|
658
|
-
}
|
|
659
|
-
|
|
578
|
+
}
|
|
660
579
|
|
|
580
|
+
// Attach debug tools to current editor instance.
|
|
661
581
|
if (this._devTools && this._applyDevTools) {
|
|
662
582
|
this._applyDevTools(editorView);
|
|
663
583
|
}
|
|
664
584
|
}
|
|
665
585
|
}
|
|
666
|
-
|
|
667
586
|
destroyDevTool() {
|
|
668
587
|
// [FS] IRAD-1569 2021-09-15
|
|
669
588
|
// Unmount dev tools when component is destroyed,
|
|
@@ -675,10 +594,10 @@ class Licit extends React.Component {
|
|
|
675
594
|
this._devTools.then(removeDevTools => removeDevTools());
|
|
676
595
|
}
|
|
677
596
|
}
|
|
678
|
-
|
|
679
597
|
componentWillUnmount() {
|
|
680
598
|
this.destroyDevTool();
|
|
681
599
|
}
|
|
600
|
+
|
|
682
601
|
/**
|
|
683
602
|
* LICIT properties:
|
|
684
603
|
* docID {number} [0] Collaborative Doument ID
|
|
@@ -694,9 +613,6 @@ class Licit extends React.Component {
|
|
|
694
613
|
* disabled {boolean} [false] Disable the editor.
|
|
695
614
|
* embedded {boolean} [false] Disable/Enable inline behaviour.
|
|
696
615
|
*/
|
|
697
|
-
|
|
698
|
-
|
|
699
616
|
}
|
|
700
|
-
|
|
701
617
|
var _default = Licit;
|
|
702
618
|
exports.default = _default;
|