@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
|
@@ -71,7 +71,11 @@ class CollabConnector extends _SimpleConnector.default {
|
|
|
71
71
|
});
|
|
72
72
|
|
|
73
73
|
_defineProperty(this, "updateSchema", (schema, data) => {
|
|
74
|
-
this._connection.updateSchema(schema, data);
|
|
74
|
+
this._connection.updateSchema(schema, data, this._dataDefined);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
_defineProperty(this, "updateContent", data => {
|
|
78
|
+
this._connection.start(data, this._dataDefined);
|
|
75
79
|
});
|
|
76
80
|
|
|
77
81
|
const {
|
|
@@ -14,7 +14,7 @@ type IdStrict = string;
|
|
|
14
14
|
class CollabConnector extends SimpleConnector {
|
|
15
15
|
_clientID: string;
|
|
16
16
|
_connected: boolean;
|
|
17
|
-
_connection:
|
|
17
|
+
_connection: EditorConnection;
|
|
18
18
|
_docID: IdStrict;
|
|
19
19
|
_stepKeys: Object;
|
|
20
20
|
|
|
@@ -79,7 +79,11 @@ class CollabConnector extends SimpleConnector {
|
|
|
79
79
|
// FS IRAD-1040 2020-09-02
|
|
80
80
|
// Send the modified schema to server
|
|
81
81
|
updateSchema = (schema: Schema, data: any) => {
|
|
82
|
-
this._connection.updateSchema(schema, data);
|
|
82
|
+
this._connection.updateSchema(schema, data, this._dataDefined);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
updateContent = (data: any) => {
|
|
86
|
+
this._connection.start(data, this._dataDefined);
|
|
83
87
|
};
|
|
84
88
|
}
|
|
85
89
|
|
|
@@ -158,8 +158,9 @@ class EditorConnection {
|
|
|
158
158
|
} // Load the document from the server and start up
|
|
159
159
|
|
|
160
160
|
|
|
161
|
-
start(input) {
|
|
162
|
-
|
|
161
|
+
start(input, dataDefined) {
|
|
162
|
+
const query = '?dataDefined=' + dataDefined;
|
|
163
|
+
this.run(input ? (0, _http.PUT)(this.url + query, JSON.stringify(input), 'application/json') : (0, _http.GET)(this.url, 'application/json')).then(data => {
|
|
163
164
|
data = JSON.parse(data);
|
|
164
165
|
this.report.success();
|
|
165
166
|
this.backOff = 0;
|
|
@@ -266,14 +267,14 @@ class EditorConnection {
|
|
|
266
267
|
// Send the modified schema to server
|
|
267
268
|
|
|
268
269
|
|
|
269
|
-
updateSchema(schema, input) {
|
|
270
|
+
updateSchema(schema, input, dataDefined) {
|
|
270
271
|
// to avoid cyclic reference error, use flatted string.
|
|
271
272
|
const schemaFlatted = (0, _flatted.stringify)(schema);
|
|
272
273
|
this.run((0, _http.POST)(this.url + '/schema/', schemaFlatted, 'text/plain')).then(data => {
|
|
273
274
|
console.log("collab server's schema updated"); // [FS] IRAD-1040 2020-09-08
|
|
274
275
|
|
|
275
276
|
this.schema = schema;
|
|
276
|
-
this.start(input);
|
|
277
|
+
this.start(input, dataDefined);
|
|
277
278
|
}, err => {
|
|
278
279
|
this.report.failure(err);
|
|
279
280
|
});
|
|
@@ -144,8 +144,13 @@ class EditorConnection {
|
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
// Load the document from the server and start up
|
|
147
|
-
start(input: any): void {
|
|
148
|
-
|
|
147
|
+
start(input: any, dataDefined: boolean): void {
|
|
148
|
+
const query = '?dataDefined=' + dataDefined;
|
|
149
|
+
this.run(
|
|
150
|
+
input
|
|
151
|
+
? PUT(this.url + query, JSON.stringify(input), 'application/json')
|
|
152
|
+
: GET(this.url, 'application/json')
|
|
153
|
+
).then(
|
|
149
154
|
(data) => {
|
|
150
155
|
data = JSON.parse(data);
|
|
151
156
|
this.report.success();
|
|
@@ -253,7 +258,7 @@ class EditorConnection {
|
|
|
253
258
|
|
|
254
259
|
// [FS] IRAD-1040 2020-09-02
|
|
255
260
|
// Send the modified schema to server
|
|
256
|
-
updateSchema(schema: Schema, input: any) {
|
|
261
|
+
updateSchema(schema: Schema, input: any, dataDefined: boolean) {
|
|
257
262
|
// to avoid cyclic reference error, use flatted string.
|
|
258
263
|
const schemaFlatted = stringify(schema);
|
|
259
264
|
this.run(POST(this.url + '/schema/', schemaFlatted, 'text/plain')).then(
|
|
@@ -261,7 +266,7 @@ class EditorConnection {
|
|
|
261
266
|
console.log("collab server's schema updated");
|
|
262
267
|
// [FS] IRAD-1040 2020-09-08
|
|
263
268
|
this.schema = schema;
|
|
264
|
-
this.start(input);
|
|
269
|
+
this.start(input, dataDefined);
|
|
265
270
|
},
|
|
266
271
|
(err) => {
|
|
267
272
|
this.report.failure(err);
|
package/dist/client/Licit.js
CHANGED
|
@@ -121,17 +121,21 @@ class Licit extends React.Component {
|
|
|
121
121
|
|
|
122
122
|
_defineProperty(this, "setContent", function () {
|
|
123
123
|
let content = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
124
|
-
|
|
124
|
+
let dataType = arguments.length > 1 ? arguments[1] : undefined;
|
|
125
|
+
_this.skipDataTypeCheck = false; // [FS] IRAD-1571 2021-09-27
|
|
125
126
|
// dispatch a transaction that MUST start from the views current state;
|
|
127
|
+
|
|
126
128
|
const editorState = _this._editorView.state;
|
|
127
129
|
const {
|
|
128
|
-
doc
|
|
129
|
-
schema
|
|
130
|
+
doc
|
|
130
131
|
} = editorState;
|
|
131
132
|
let {
|
|
132
133
|
tr
|
|
133
134
|
} = editorState;
|
|
134
|
-
|
|
135
|
+
|
|
136
|
+
const document = _this.getDocument(content, editorState, dataType);
|
|
137
|
+
|
|
138
|
+
_this.skipDataTypeCheck = true; // [FS] IRAD-1593 2021-10-12
|
|
135
139
|
// Reset lastKeyCode since the content is set dynamically and so lastKeyCode is invalid now.
|
|
136
140
|
|
|
137
141
|
_this._editorView.lastKeyCode = null;
|
|
@@ -252,9 +256,10 @@ class Licit extends React.Component {
|
|
|
252
256
|
propsCopy.readOnly = false;
|
|
253
257
|
delete propsCopy.data;
|
|
254
258
|
this.setState(propsCopy);
|
|
255
|
-
}
|
|
256
|
-
// so that content is modified gracefully using transaction so that undo/redo works too.
|
|
259
|
+
}
|
|
257
260
|
|
|
261
|
+
this.skipDataTypeCheck = false; // Need to go through shouldComponentUpdate lifecycle here, when updated from outside,
|
|
262
|
+
// so that content is modified gracefully using transaction so that undo/redo works too.
|
|
258
263
|
|
|
259
264
|
this._skipSCU = false;
|
|
260
265
|
this.setState(props);
|
|
@@ -295,7 +300,10 @@ class Licit extends React.Component {
|
|
|
295
300
|
// Handle Image Upload from Angular App
|
|
296
301
|
|
|
297
302
|
const runtime = props.runtime || null;
|
|
298
|
-
const plugins = props.plugins || null;
|
|
303
|
+
const plugins = props.plugins || null; // This flag decides whether DataType.HTML check is needed when
|
|
304
|
+
// changing document. If it forcefully done, it is not needed, otherwise needed.
|
|
305
|
+
|
|
306
|
+
this.skipDataTypeCheck = false;
|
|
299
307
|
this._defaultEditorSchema = new _prosemirrorModel.Schema({
|
|
300
308
|
nodes: _EditorNodes.default,
|
|
301
309
|
marks: _EditorMarks.default
|
|
@@ -308,7 +316,8 @@ class Licit extends React.Component {
|
|
|
308
316
|
docID,
|
|
309
317
|
collabServiceURL
|
|
310
318
|
}, this._defaultEditorSchema, this._defaultEditorPlugins, // [FS] IRAD-1578 2021-09-27
|
|
311
|
-
this.onReady.bind(this)) : new _SimpleConnector.default(editorState, setState);
|
|
319
|
+
this.onReady.bind(this)) : new _SimpleConnector.default(editorState, setState);
|
|
320
|
+
this._connector._dataDefined = !!props.data; // FS IRAD-989 2020-18-06
|
|
312
321
|
// updating properties should automatically render the changes
|
|
313
322
|
|
|
314
323
|
this.state = {
|
|
@@ -324,7 +333,8 @@ class Licit extends React.Component {
|
|
|
324
333
|
debug,
|
|
325
334
|
disabled,
|
|
326
335
|
embedded,
|
|
327
|
-
runtime
|
|
336
|
+
runtime,
|
|
337
|
+
dataType
|
|
328
338
|
}; // FS IRAD-1040 2020-26-08
|
|
329
339
|
// Get the modified schema from editorstate and send it to collab server
|
|
330
340
|
|
|
@@ -474,7 +484,23 @@ class Licit extends React.Component {
|
|
|
474
484
|
return node.attrs && node.attrs[attrName];
|
|
475
485
|
}
|
|
476
486
|
|
|
477
|
-
|
|
487
|
+
getDocument(content, editorState, dataType) {
|
|
488
|
+
let document = null;
|
|
489
|
+
const {
|
|
490
|
+
schema
|
|
491
|
+
} = editorState;
|
|
492
|
+
|
|
493
|
+
if (DataType.JSON === dataType || this.skipDataTypeCheck) {
|
|
494
|
+
document = schema.nodeFromJSON(content ? content : _createEmptyEditorState.EMPTY_DOC_JSON);
|
|
495
|
+
} else {
|
|
496
|
+
const tempEState = (0, _convertFromHTML.default)(content ? content : '', schema, editorState.plugins);
|
|
497
|
+
document = tempEState.doc;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
return document;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
hasDataChanged(nextData, nextDataType) {
|
|
478
504
|
let dataChanged = false; // [FS] IRAD-1571 2021-09-27
|
|
479
505
|
// dispatch a transaction that MUST start from the views current state;
|
|
480
506
|
// [FS] IRAD-1589 2021-10-04
|
|
@@ -482,19 +508,19 @@ class Licit extends React.Component {
|
|
|
482
508
|
|
|
483
509
|
if ((0, _flatted.stringify)(this.state.data) !== (0, _flatted.stringify)(nextData)) {
|
|
484
510
|
const editorState = this._editorView.state;
|
|
485
|
-
const nextDoc =
|
|
511
|
+
const nextDoc = this.getDocument(nextData, editorState, nextDataType);
|
|
486
512
|
dataChanged = !nextDoc.eq(editorState.doc);
|
|
487
513
|
}
|
|
488
514
|
|
|
489
515
|
return dataChanged;
|
|
490
516
|
}
|
|
491
517
|
|
|
492
|
-
changeContent(data) {
|
|
493
|
-
if (this.hasDataChanged(data)) {
|
|
518
|
+
changeContent(data, dataType) {
|
|
519
|
+
if (this.hasDataChanged(data, dataType)) {
|
|
494
520
|
// FS IRAD-1592 2021-11-10
|
|
495
521
|
// Release here quickly, so that update doesn't care about at this point.
|
|
496
522
|
// data changed, so update document content
|
|
497
|
-
setTimeout(this.setContent.bind(this, data), 1);
|
|
523
|
+
setTimeout(this.setContent.bind(this, data, dataType), 1);
|
|
498
524
|
}
|
|
499
525
|
}
|
|
500
526
|
|
|
@@ -502,13 +528,14 @@ class Licit extends React.Component {
|
|
|
502
528
|
// Only interested if properties are set from outside.
|
|
503
529
|
if (!this._skipSCU) {
|
|
504
530
|
this._skipSCU = false;
|
|
505
|
-
this.changeContent(nextState.data);
|
|
531
|
+
this.changeContent(nextState.data, nextState.dataType);
|
|
506
532
|
|
|
507
533
|
if (this.state.docID !== nextState.docID) {
|
|
508
534
|
setTimeout(this.setDocID.bind(this, nextState), 1);
|
|
509
535
|
}
|
|
510
536
|
}
|
|
511
537
|
|
|
538
|
+
this.skipDataTypeCheck = true;
|
|
512
539
|
return true;
|
|
513
540
|
}
|
|
514
541
|
|
|
@@ -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;
|
|
@@ -25,11 +25,16 @@ var bpfrpt_proptype_SetStateCall = _propTypes.default.func;
|
|
|
25
25
|
exports.bpfrpt_proptype_SetStateCall = bpfrpt_proptype_SetStateCall;
|
|
26
26
|
|
|
27
27
|
class SimpleConnector {
|
|
28
|
+
// This flag is used to deteremine if data passed in or not
|
|
29
|
+
// If not passed in, use the data from collab server when in collab mode.
|
|
30
|
+
// else use empty content.
|
|
28
31
|
constructor(_editorState, setState) {
|
|
29
32
|
_defineProperty(this, "_setState", void 0);
|
|
30
33
|
|
|
31
34
|
_defineProperty(this, "_editorState", void 0);
|
|
32
35
|
|
|
36
|
+
_defineProperty(this, "_dataDefined", void 0);
|
|
37
|
+
|
|
33
38
|
_defineProperty(this, "onEdit", (transaction, view) => {
|
|
34
39
|
_reactDom.default.unstable_batchedUpdates(() => {
|
|
35
40
|
const editorState = this._editorState.apply(transaction); // [FS] IRAD-1236 2020-03-05
|
|
@@ -57,6 +62,8 @@ class SimpleConnector {
|
|
|
57
62
|
|
|
58
63
|
_defineProperty(this, "updateSchema", (schema, data) => {});
|
|
59
64
|
|
|
65
|
+
_defineProperty(this, "updateContent", data => {});
|
|
66
|
+
|
|
60
67
|
_defineProperty(this, "cleanUp", () => {});
|
|
61
68
|
|
|
62
69
|
this._editorState = _editorState;
|
|
@@ -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/dist/convertFromHTML.js
CHANGED
|
@@ -15,6 +15,14 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
15
15
|
|
|
16
16
|
function convertFromHTML(html, schema, plugins) {
|
|
17
17
|
const root = document.createElement('html');
|
|
18
|
-
root.innerHTML = html;
|
|
18
|
+
root.innerHTML = unEscape(html ? html : ' ');
|
|
19
19
|
return (0, _convertFromDOMElement.default)(root, schema, plugins);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function unEscape(htmlStr) {
|
|
23
|
+
if (htmlStr) {
|
|
24
|
+
htmlStr = htmlStr.replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, "'").replace(/&/g, '&');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return htmlStr;
|
|
20
28
|
}
|
|
@@ -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/dist/ui/czi-vars.css
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
@import '
|
|
1
|
+
@import '~@modusoperandi/licit-ui-commands/dist/ui/czi-vars.css';
|
|
2
2
|
|
|
@@ -183,10 +183,8 @@ export function initEditorSchema(effectiveSchema: Schema) {
|
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
-
export function getInstance(id: any, ip: any
|
|
187
|
-
const inst =
|
|
188
|
-
instances[id] ||
|
|
189
|
-
newInstance(id, !doc ? undefined : _editorSchema.nodeFromJSON(doc));
|
|
186
|
+
export function getInstance(id: any, ip: any) {
|
|
187
|
+
const inst = instances[id] || newInstance(id);
|
|
190
188
|
if (ip) inst.registerUser(ip);
|
|
191
189
|
inst.lastActive = Date.now();
|
|
192
190
|
return inst;
|
|
@@ -208,6 +206,20 @@ function newInstance(id: any, doc: any) {
|
|
|
208
206
|
return (instances[id] = new Instance(id, doc));
|
|
209
207
|
}
|
|
210
208
|
|
|
209
|
+
export function updateInstance(id: any, ip: any, doc: any) {
|
|
210
|
+
let inst = instances[id];
|
|
211
|
+
if (inst) {
|
|
212
|
+
if (doc) {
|
|
213
|
+
inst.doc = _editorSchema.nodeFromJSON(doc);
|
|
214
|
+
}
|
|
215
|
+
} else {
|
|
216
|
+
inst = newInstance(id, !doc ? undefined : _editorSchema.nodeFromJSON(doc));
|
|
217
|
+
}
|
|
218
|
+
if (ip) inst.registerUser(ip);
|
|
219
|
+
inst.lastActive = Date.now();
|
|
220
|
+
return inst;
|
|
221
|
+
}
|
|
222
|
+
|
|
211
223
|
export function instanceInfo() {
|
|
212
224
|
const found = [];
|
|
213
225
|
for (const id in instances)
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
instanceInfo,
|
|
10
10
|
setEditorSchema,
|
|
11
11
|
initEditorSchema,
|
|
12
|
+
updateInstance,
|
|
12
13
|
} from './instance';
|
|
13
14
|
// [FS] IRAD-899 2020-03-13
|
|
14
15
|
// This is for Capcomode document attribute. Shared Step, so that capcomode can be dealt collaboratively.
|
|
@@ -152,9 +153,23 @@ handle('GET', [DOCS], () => {
|
|
|
152
153
|
return Output.json(instanceInfo());
|
|
153
154
|
});
|
|
154
155
|
|
|
155
|
-
// Output the current state of a document instance.
|
|
156
|
+
// Save & Output the current state of a document instance.
|
|
156
157
|
handle('PUT', [DOCS, null], (data, id, req) => {
|
|
157
|
-
const inst =
|
|
158
|
+
const inst = updateInstance(
|
|
159
|
+
id,
|
|
160
|
+
reqIP(req),
|
|
161
|
+
req.query.dataDefined === 'false' ? null : data
|
|
162
|
+
);
|
|
163
|
+
return Output.json({
|
|
164
|
+
doc_json: inst.doc.toJSON(),
|
|
165
|
+
users: inst.userCount,
|
|
166
|
+
version: inst.version,
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
// Output the current state of a document instance.
|
|
171
|
+
handle('GET', [DOCS, null], (id, req) => {
|
|
172
|
+
const inst = getInstance(id, reqIP(req));
|
|
158
173
|
return Output.json({
|
|
159
174
|
doc_json: inst.doc.toJSON(),
|
|
160
175
|
users: inst.userCount,
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@ type IdStrict = string;
|
|
|
14
14
|
class CollabConnector extends SimpleConnector {
|
|
15
15
|
_clientID: string;
|
|
16
16
|
_connected: boolean;
|
|
17
|
-
_connection:
|
|
17
|
+
_connection: EditorConnection;
|
|
18
18
|
_docID: IdStrict;
|
|
19
19
|
_stepKeys: Object;
|
|
20
20
|
|
|
@@ -79,7 +79,11 @@ class CollabConnector extends SimpleConnector {
|
|
|
79
79
|
// FS IRAD-1040 2020-09-02
|
|
80
80
|
// Send the modified schema to server
|
|
81
81
|
updateSchema = (schema: Schema, data: any) => {
|
|
82
|
-
this._connection.updateSchema(schema, data);
|
|
82
|
+
this._connection.updateSchema(schema, data, this._dataDefined);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
updateContent = (data: any) => {
|
|
86
|
+
this._connection.start(data, this._dataDefined);
|
|
83
87
|
};
|
|
84
88
|
}
|
|
85
89
|
|
|
@@ -144,8 +144,13 @@ class EditorConnection {
|
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
// Load the document from the server and start up
|
|
147
|
-
start(input: any): void {
|
|
148
|
-
|
|
147
|
+
start(input: any, dataDefined: boolean): void {
|
|
148
|
+
const query = '?dataDefined=' + dataDefined;
|
|
149
|
+
this.run(
|
|
150
|
+
input
|
|
151
|
+
? PUT(this.url + query, JSON.stringify(input), 'application/json')
|
|
152
|
+
: GET(this.url, 'application/json')
|
|
153
|
+
).then(
|
|
149
154
|
(data) => {
|
|
150
155
|
data = JSON.parse(data);
|
|
151
156
|
this.report.success();
|
|
@@ -253,7 +258,7 @@ class EditorConnection {
|
|
|
253
258
|
|
|
254
259
|
// [FS] IRAD-1040 2020-09-02
|
|
255
260
|
// Send the modified schema to server
|
|
256
|
-
updateSchema(schema: Schema, input: any) {
|
|
261
|
+
updateSchema(schema: Schema, input: any, dataDefined: boolean) {
|
|
257
262
|
// to avoid cyclic reference error, use flatted string.
|
|
258
263
|
const schemaFlatted = stringify(schema);
|
|
259
264
|
this.run(POST(this.url + '/schema/', schemaFlatted, 'text/plain')).then(
|
|
@@ -261,7 +266,7 @@ class EditorConnection {
|
|
|
261
266
|
console.log("collab server's schema updated");
|
|
262
267
|
// [FS] IRAD-1040 2020-09-08
|
|
263
268
|
this.schema = schema;
|
|
264
|
-
this.start(input);
|
|
269
|
+
this.start(input, dataDefined);
|
|
265
270
|
},
|
|
266
271
|
(err) => {
|
|
267
272
|
this.report.failure(err);
|