@modusoperandi/licit 0.13.10 → 0.13.18
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/dist/bom.xml +546 -546
- package/dist/client/CollabConnector.js +5 -1
- package/dist/client/CollabConnector.js.flow +6 -2
- package/dist/client/EditorConnection.js +5 -4
- package/dist/client/EditorConnection.js.flow +9 -4
- package/dist/client/Licit.js +42 -15
- package/dist/client/Licit.js.flow +39 -12
- package/dist/client/SimpleConnector.js +7 -0
- package/dist/client/SimpleConnector.js.flow +6 -0
- package/dist/convertFromHTML.js +9 -1
- package/dist/convertFromHTML.js.flow +13 -1
- package/dist/ui/czi-link-tooltip.css +1 -1
- package/dist/ui/czi-vars.css +1 -1
- package/licit/server/collab/instance.js +16 -4
- package/licit/server/collab/server.js +17 -2
- package/licit/server/collab/start.js +1 -1
- package/package.json +1 -1
- package/src/client/CollabConnector.js +6 -2
- package/src/client/EditorConnection.js +9 -4
- package/src/client/Licit.js +39 -12
- package/src/client/SimpleConnector.js +6 -0
- package/src/convertFromHTML.js +13 -1
- package/src/ui/czi-link-tooltip.css +1 -1
- package/src/ui/czi-vars.css +1 -1
- package/utils/build_licit_collab_server.js +1 -1
- package/webpack.config.js +1 -1
package/src/client/Licit.js
CHANGED
|
@@ -51,7 +51,7 @@ export const DataType = Object.freeze({
|
|
|
51
51
|
*/
|
|
52
52
|
class Licit extends React.Component<any, any> {
|
|
53
53
|
_runtime: EditorRuntime;
|
|
54
|
-
_connector:
|
|
54
|
+
_connector: SimpleConnector;
|
|
55
55
|
_clientID: string;
|
|
56
56
|
_editorView: EditorView; // This will be handy in updating document's content.
|
|
57
57
|
_skipSCU: boolean; // Flag to decide whether to skip shouldComponentUpdate
|
|
@@ -107,6 +107,9 @@ class Licit extends React.Component<any, any> {
|
|
|
107
107
|
// Handle Image Upload from Angular App
|
|
108
108
|
const runtime = props.runtime || null;
|
|
109
109
|
const plugins = props.plugins || null;
|
|
110
|
+
// This flag decides whether DataType.HTML check is needed when
|
|
111
|
+
// changing document. If it forcefully done, it is not needed, otherwise needed.
|
|
112
|
+
this.skipDataTypeCheck = false;
|
|
110
113
|
|
|
111
114
|
this._defaultEditorSchema = new Schema({
|
|
112
115
|
nodes: EditorNodes,
|
|
@@ -135,6 +138,8 @@ class Licit extends React.Component<any, any> {
|
|
|
135
138
|
)
|
|
136
139
|
: new SimpleConnector(editorState, setState);
|
|
137
140
|
|
|
141
|
+
this._connector._dataDefined = !!props.data;
|
|
142
|
+
|
|
138
143
|
// FS IRAD-989 2020-18-06
|
|
139
144
|
// updating properties should automatically render the changes
|
|
140
145
|
|
|
@@ -152,6 +157,7 @@ class Licit extends React.Component<any, any> {
|
|
|
152
157
|
disabled,
|
|
153
158
|
embedded,
|
|
154
159
|
runtime,
|
|
160
|
+
dataType,
|
|
155
161
|
};
|
|
156
162
|
|
|
157
163
|
// FS IRAD-1040 2020-26-08
|
|
@@ -313,13 +319,33 @@ class Licit extends React.Component<any, any> {
|
|
|
313
319
|
return node.attrs && node.attrs[attrName];
|
|
314
320
|
}
|
|
315
321
|
|
|
316
|
-
|
|
322
|
+
getDocument(content: any, editorState: EditorState, dataType: DataType) {
|
|
323
|
+
let document = null;
|
|
324
|
+
const { schema } = editorState;
|
|
325
|
+
|
|
326
|
+
if (DataType.JSON === dataType || this.skipDataTypeCheck) {
|
|
327
|
+
document = schema.nodeFromJSON(content ? content : EMPTY_DOC_JSON);
|
|
328
|
+
} else {
|
|
329
|
+
const tempEState = convertFromHTML(
|
|
330
|
+
content ? content : '',
|
|
331
|
+
schema,
|
|
332
|
+
editorState.plugins
|
|
333
|
+
);
|
|
334
|
+
document = tempEState.doc;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
return document;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
setContent = (content: any = {}, dataType: DataType): void => {
|
|
341
|
+
this.skipDataTypeCheck = false;
|
|
317
342
|
// [FS] IRAD-1571 2021-09-27
|
|
318
343
|
// dispatch a transaction that MUST start from the views current state;
|
|
319
344
|
const editorState = this._editorView.state;
|
|
320
|
-
const { doc
|
|
345
|
+
const { doc } = editorState;
|
|
321
346
|
let { tr } = editorState;
|
|
322
|
-
const document =
|
|
347
|
+
const document = this.getDocument(content, editorState, dataType);
|
|
348
|
+
this.skipDataTypeCheck = true;
|
|
323
349
|
|
|
324
350
|
// [FS] IRAD-1593 2021-10-12
|
|
325
351
|
// Reset lastKeyCode since the content is set dynamically and so lastKeyCode is invalid now.
|
|
@@ -339,7 +365,7 @@ class Licit extends React.Component<any, any> {
|
|
|
339
365
|
this._editorView.dispatch(tr);
|
|
340
366
|
};
|
|
341
367
|
|
|
342
|
-
hasDataChanged(nextData: any) {
|
|
368
|
+
hasDataChanged(nextData: any, nextDataType: DataType) {
|
|
343
369
|
let dataChanged = false;
|
|
344
370
|
|
|
345
371
|
// [FS] IRAD-1571 2021-09-27
|
|
@@ -348,21 +374,19 @@ class Licit extends React.Component<any, any> {
|
|
|
348
374
|
// Do a proper circular JSON comparison.
|
|
349
375
|
if (stringify(this.state.data) !== stringify(nextData)) {
|
|
350
376
|
const editorState = this._editorView.state;
|
|
351
|
-
const nextDoc =
|
|
352
|
-
nextData ? nextData : EMPTY_DOC_JSON
|
|
353
|
-
);
|
|
377
|
+
const nextDoc = this.getDocument(nextData, editorState, nextDataType);
|
|
354
378
|
dataChanged = !nextDoc.eq(editorState.doc);
|
|
355
379
|
}
|
|
356
380
|
|
|
357
381
|
return dataChanged;
|
|
358
382
|
}
|
|
359
383
|
|
|
360
|
-
changeContent(data: any) {
|
|
361
|
-
if (this.hasDataChanged(data)) {
|
|
384
|
+
changeContent(data: any, dataType: DataType) {
|
|
385
|
+
if (this.hasDataChanged(data, dataType)) {
|
|
362
386
|
// FS IRAD-1592 2021-11-10
|
|
363
387
|
// Release here quickly, so that update doesn't care about at this point.
|
|
364
388
|
// data changed, so update document content
|
|
365
|
-
setTimeout(this.setContent.bind(this, data), 1);
|
|
389
|
+
setTimeout(this.setContent.bind(this, data, dataType), 1);
|
|
366
390
|
}
|
|
367
391
|
}
|
|
368
392
|
|
|
@@ -371,13 +395,15 @@ class Licit extends React.Component<any, any> {
|
|
|
371
395
|
if (!this._skipSCU) {
|
|
372
396
|
this._skipSCU = false;
|
|
373
397
|
|
|
374
|
-
this.changeContent(nextState.data);
|
|
398
|
+
this.changeContent(nextState.data, nextState.dataType);
|
|
375
399
|
|
|
376
400
|
if (this.state.docID !== nextState.docID) {
|
|
377
401
|
setTimeout(this.setDocID.bind(this, nextState), 1);
|
|
378
402
|
}
|
|
379
403
|
}
|
|
380
404
|
|
|
405
|
+
this.skipDataTypeCheck = true;
|
|
406
|
+
|
|
381
407
|
return true;
|
|
382
408
|
}
|
|
383
409
|
|
|
@@ -628,6 +654,7 @@ class Licit extends React.Component<any, any> {
|
|
|
628
654
|
delete propsCopy.data;
|
|
629
655
|
this.setState(propsCopy);
|
|
630
656
|
}
|
|
657
|
+
this.skipDataTypeCheck = false;
|
|
631
658
|
// Need to go through shouldComponentUpdate lifecycle here, when updated from outside,
|
|
632
659
|
// so that content is modified gracefully using transaction so that undo/redo works too.
|
|
633
660
|
this._skipSCU = false;
|
|
@@ -14,6 +14,10 @@ export type SetStateCall = (
|
|
|
14
14
|
class SimpleConnector {
|
|
15
15
|
_setState: SetStateCall;
|
|
16
16
|
_editorState: EditorState;
|
|
17
|
+
// This flag is used to deteremine if data passed in or not
|
|
18
|
+
// If not passed in, use the data from collab server when in collab mode.
|
|
19
|
+
// else use empty content.
|
|
20
|
+
_dataDefined: boolean;
|
|
17
21
|
|
|
18
22
|
constructor(editorState: EditorState, setState: SetStateCall) {
|
|
19
23
|
this._editorState = editorState;
|
|
@@ -49,6 +53,8 @@ class SimpleConnector {
|
|
|
49
53
|
// Send the modified schema to server
|
|
50
54
|
updateSchema = (schema: Schema, data: any) => {};
|
|
51
55
|
|
|
56
|
+
updateContent = (data: any) => {};
|
|
57
|
+
|
|
52
58
|
cleanUp = () => {};
|
|
53
59
|
}
|
|
54
60
|
|
package/src/convertFromHTML.js
CHANGED
|
@@ -12,6 +12,18 @@ export default function convertFromHTML(
|
|
|
12
12
|
plugins: Array<Plugin>
|
|
13
13
|
): EditorState {
|
|
14
14
|
const root = document.createElement('html');
|
|
15
|
-
root.innerHTML = html;
|
|
15
|
+
root.innerHTML = unEscape(html ? html : ' ');
|
|
16
16
|
return convertFromDOMElement(root, schema, plugins);
|
|
17
17
|
}
|
|
18
|
+
|
|
19
|
+
function unEscape(htmlStr) {
|
|
20
|
+
if (htmlStr) {
|
|
21
|
+
htmlStr = htmlStr
|
|
22
|
+
.replace(/</g, '<')
|
|
23
|
+
.replace(/>/g, '>')
|
|
24
|
+
.replace(/"/g, '"')
|
|
25
|
+
.replace(/'/g, "'")
|
|
26
|
+
.replace(/&/g, '&');
|
|
27
|
+
}
|
|
28
|
+
return htmlStr;
|
|
29
|
+
}
|
package/src/ui/czi-vars.css
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
@import '
|
|
1
|
+
@import '~@modusoperandi/licit-ui-commands/dist/ui/czi-vars.css';
|
|
2
2
|
|
|
@@ -8,7 +8,7 @@ const env = require('./env');
|
|
|
8
8
|
const path = require('path');
|
|
9
9
|
|
|
10
10
|
const config = {
|
|
11
|
-
mode:
|
|
11
|
+
mode: env.NODE_ENV,
|
|
12
12
|
entry: {// [FS] IRAD-901 2020-07-15 New collab server reusing base PM collab server
|
|
13
13
|
run_licit_collab_server: path.join(__dirname, '../licit', 'server/collab', 'start.js'),
|
|
14
14
|
},
|