@modusoperandi/licit 0.13.3 → 0.13.20
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 +59 -55
- package/README.md +15 -1
- package/dist/ListItemNodeSpec.js +1 -1
- package/dist/ListItemNodeSpec.js.flow +1 -1
- package/dist/bom.xml +5147 -8743
- 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 +10 -5
- package/dist/client/Licit.js +105 -30
- package/dist/client/Licit.js.flow +120 -47
- package/dist/client/Licit.test.js +29 -2
- package/dist/client/Licit.test.js.flow +33 -2
- package/dist/client/SimpleConnector.js +7 -0
- package/dist/client/SimpleConnector.js.flow +6 -0
- package/dist/client/http.js +12 -0
- package/dist/client/http.js.flow +4 -0
- package/dist/convertFromDOMElement.js.flow +2 -2
- package/dist/convertFromHTML.js +1 -4
- package/dist/convertFromHTML.js.flow +3 -5
- package/dist/convertFromJSON.js +12 -28
- package/dist/convertFromJSON.js.flow +9 -31
- package/dist/createEmptyEditorState.js +3 -6
- package/dist/createEmptyEditorState.js.flow +4 -8
- package/dist/index.js +11 -1
- package/dist/index.js.flow +1 -1
- package/dist/patchStyleElements.js +1 -3
- package/dist/patchStyleElements.js.flow +2 -2
- package/dist/ui/czi-link-tooltip.css +1 -1
- package/dist/ui/czi-vars.css +1 -1
- package/licit/client/index.js +2 -1
- package/licit/server/collab/instance.js +21 -6
- package/licit/server/collab/server.js +25 -5
- package/licit/server/collab/start.js +1 -1
- package/package.json +5 -10
- package/src/ListItemNodeSpec.js +1 -1
- package/src/client/CollabConnector.js +6 -2
- package/src/client/EditorConnection.js +10 -5
- package/src/client/Licit.js +120 -47
- package/src/client/Licit.test.js +33 -2
- package/src/client/SimpleConnector.js +6 -0
- package/src/client/http.js +4 -0
- package/src/convertFromDOMElement.js +2 -2
- package/src/convertFromHTML.js +3 -5
- package/src/convertFromJSON.js +9 -31
- package/src/createEmptyEditorState.js +4 -8
- package/src/index.js +1 -1
- package/src/patchStyleElements.js +2 -2
- 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/node_modules/prosemirror-utils/LICENSE +0 -13
- package/node_modules/prosemirror-utils/README.md +0 -0
- package/node_modules/prosemirror-utils/dist/helpers.js +0 -119
- package/node_modules/prosemirror-utils/dist/index.js +0 -17
- package/node_modules/prosemirror-utils/dist/index.js.map +0 -1
- package/node_modules/prosemirror-utils/dist/node.js +0 -106
- package/node_modules/prosemirror-utils/dist/selection.js +0 -168
- package/node_modules/prosemirror-utils/dist/transforms.js +0 -257
- package/node_modules/prosemirror-utils/package.json +0 -81
- package/node_modules/prosemirror-utils/typings.d.ts +0 -79
|
@@ -6,12 +6,16 @@ var _enzyme = require("enzyme");
|
|
|
6
6
|
|
|
7
7
|
var _enzymeAdapterReact = _interopRequireDefault(require("@wojtekmaj/enzyme-adapter-react-17"));
|
|
8
8
|
|
|
9
|
-
var _Licit =
|
|
9
|
+
var _Licit = _interopRequireWildcard(require("./Licit"));
|
|
10
10
|
|
|
11
11
|
var _RichTextEditor = _interopRequireDefault(require("../ui/RichTextEditor"));
|
|
12
12
|
|
|
13
13
|
var _licitUiCommands = require("@modusoperandi/licit-ui-commands");
|
|
14
14
|
|
|
15
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
16
|
+
|
|
17
|
+
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; }
|
|
18
|
+
|
|
15
19
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
20
|
|
|
17
21
|
/**
|
|
@@ -45,7 +49,10 @@ describe('<Licit />', () => {
|
|
|
45
49
|
},
|
|
46
50
|
resolve: () => ({
|
|
47
51
|
min: () => 0,
|
|
48
|
-
max: () => 10
|
|
52
|
+
max: () => 10,
|
|
53
|
+
parent: {
|
|
54
|
+
inlineContent: true
|
|
55
|
+
}
|
|
49
56
|
}),
|
|
50
57
|
toJSON: () => data
|
|
51
58
|
},
|
|
@@ -75,4 +82,24 @@ describe('<Licit />', () => {
|
|
|
75
82
|
expect(licit.editorView).toBe(fakeEditorView);
|
|
76
83
|
});
|
|
77
84
|
});
|
|
85
|
+
});
|
|
86
|
+
describe('<Licit with HTML input/>', () => {
|
|
87
|
+
let wrapper;
|
|
88
|
+
let licit;
|
|
89
|
+
const HELLO = 'Hello ';
|
|
90
|
+
const WORLD = 'World';
|
|
91
|
+
const data = '<p stylename="None">' + HELLO + '<strong overridden="false">' + WORLD + '</strong></p>';
|
|
92
|
+
beforeEach(() => {
|
|
93
|
+
wrapper = (0, _enzyme.shallow)( /*#__PURE__*/_react.default.createElement(_Licit.default, {
|
|
94
|
+
data: data,
|
|
95
|
+
dataType: _Licit.DataType.HTML
|
|
96
|
+
}));
|
|
97
|
+
licit = wrapper.instance();
|
|
98
|
+
});
|
|
99
|
+
it('should render a <RichTextEditor /> ', () => {
|
|
100
|
+
expect(wrapper.find(_RichTextEditor.default)).toBeTruthy();
|
|
101
|
+
});
|
|
102
|
+
it('should match state text content with the passed in text ', () => {
|
|
103
|
+
expect(licit.state.editorState.doc.textContent).toBe(HELLO + WORLD);
|
|
104
|
+
});
|
|
78
105
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { configure, shallow } from 'enzyme';
|
|
3
3
|
import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
|
|
4
|
-
import Licit from './Licit';
|
|
4
|
+
import Licit, { DataType } from './Licit';
|
|
5
5
|
import RichTextEditor from '../ui/RichTextEditor';
|
|
6
6
|
import { noop } from '@modusoperandi/licit-ui-commands';
|
|
7
7
|
|
|
@@ -34,7 +34,11 @@ describe('<Licit />', () => {
|
|
|
34
34
|
state: {
|
|
35
35
|
doc: {
|
|
36
36
|
content: { size: 10 },
|
|
37
|
-
resolve: () => ({
|
|
37
|
+
resolve: () => ({
|
|
38
|
+
min: () => 0,
|
|
39
|
+
max: () => 10,
|
|
40
|
+
parent: { inlineContent: true },
|
|
41
|
+
}),
|
|
38
42
|
toJSON: () => data,
|
|
39
43
|
},
|
|
40
44
|
tr: {
|
|
@@ -65,3 +69,30 @@ describe('<Licit />', () => {
|
|
|
65
69
|
});
|
|
66
70
|
});
|
|
67
71
|
});
|
|
72
|
+
|
|
73
|
+
describe('<Licit with HTML input/>', () => {
|
|
74
|
+
let wrapper;
|
|
75
|
+
let licit;
|
|
76
|
+
|
|
77
|
+
const HELLO = 'Hello ';
|
|
78
|
+
const WORLD = 'World';
|
|
79
|
+
const data =
|
|
80
|
+
'<p stylename="None">' +
|
|
81
|
+
HELLO +
|
|
82
|
+
'<strong overridden="false">' +
|
|
83
|
+
WORLD +
|
|
84
|
+
'</strong></p>';
|
|
85
|
+
|
|
86
|
+
beforeEach(() => {
|
|
87
|
+
wrapper = shallow(<Licit data={data} dataType={DataType.HTML} />);
|
|
88
|
+
licit = wrapper.instance();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('should render a <RichTextEditor /> ', () => {
|
|
92
|
+
expect(wrapper.find(RichTextEditor)).toBeTruthy();
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('should match state text content with the passed in text ', () => {
|
|
96
|
+
expect(licit.state.editorState.doc.textContent).toBe(HELLO + WORLD);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
@@ -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/client/http.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.DELETE = DELETE;
|
|
|
7
7
|
exports.GET = GET;
|
|
8
8
|
exports.PATCH = PATCH;
|
|
9
9
|
exports.POST = POST;
|
|
10
|
+
exports.PUT = PUT;
|
|
10
11
|
exports.req = req;
|
|
11
12
|
|
|
12
13
|
/* eslint-disable */
|
|
@@ -68,6 +69,17 @@ function POST(url, body, type) {
|
|
|
68
69
|
'Content-Type': type
|
|
69
70
|
}
|
|
70
71
|
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function PUT(url, body, type) {
|
|
75
|
+
return req({
|
|
76
|
+
url,
|
|
77
|
+
method: 'PUT',
|
|
78
|
+
body,
|
|
79
|
+
headers: {
|
|
80
|
+
'Content-Type': type
|
|
81
|
+
}
|
|
82
|
+
});
|
|
71
83
|
} // [FS] IRAD-1128 2021-02-03
|
|
72
84
|
// http DELETE request overrided
|
|
73
85
|
|
package/dist/client/http.js.flow
CHANGED
|
@@ -53,6 +53,10 @@ export function POST(url, body, type) {
|
|
|
53
53
|
return req({ url, method: 'POST', body, headers: { 'Content-Type': type } });
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
export function PUT(url, body, type) {
|
|
57
|
+
return req({ url, method: 'PUT', body, headers: { 'Content-Type': type } });
|
|
58
|
+
}
|
|
59
|
+
|
|
56
60
|
// [FS] IRAD-1128 2021-02-03
|
|
57
61
|
// http DELETE request overrided
|
|
58
62
|
export function DELETE(url, type) {
|
|
@@ -11,8 +11,8 @@ import EditorSchema from './EditorSchema';
|
|
|
11
11
|
|
|
12
12
|
export default function convertFromDOMElement(
|
|
13
13
|
el: HTMLElement,
|
|
14
|
-
schema:
|
|
15
|
-
plugins:
|
|
14
|
+
schema: Schema,
|
|
15
|
+
plugins: Array<Plugin>
|
|
16
16
|
): EditorState {
|
|
17
17
|
const effectiveSchema = schema || EditorSchema;
|
|
18
18
|
const effectivePlugins = plugins || EditorPlugins;
|
package/dist/convertFromHTML.js
CHANGED
|
@@ -11,13 +11,10 @@ var _prosemirrorState = require("prosemirror-state");
|
|
|
11
11
|
|
|
12
12
|
var _convertFromDOMElement = _interopRequireDefault(require("./convertFromDOMElement"));
|
|
13
13
|
|
|
14
|
-
var _normalizeHTML = _interopRequireDefault(require("./normalizeHTML"));
|
|
15
|
-
|
|
16
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
15
|
|
|
18
16
|
function convertFromHTML(html, schema, plugins) {
|
|
19
17
|
const root = document.createElement('html');
|
|
20
|
-
|
|
21
|
-
root.innerHTML = newHTML;
|
|
18
|
+
root.innerHTML = html ? html : ' ';
|
|
22
19
|
return (0, _convertFromDOMElement.default)(root, schema, plugins);
|
|
23
20
|
}
|
|
@@ -5,15 +5,13 @@ import { EditorState } from 'prosemirror-state';
|
|
|
5
5
|
import { Plugin } from 'prosemirror-state';
|
|
6
6
|
|
|
7
7
|
import convertFromDOMElement from './convertFromDOMElement';
|
|
8
|
-
import normalizeHTML from './normalizeHTML';
|
|
9
8
|
|
|
10
9
|
export default function convertFromHTML(
|
|
11
10
|
html: string,
|
|
12
|
-
schema:
|
|
13
|
-
plugins:
|
|
11
|
+
schema: Schema,
|
|
12
|
+
plugins: Array<Plugin>
|
|
14
13
|
): EditorState {
|
|
15
14
|
const root = document.createElement('html');
|
|
16
|
-
|
|
17
|
-
root.innerHTML = newHTML;
|
|
15
|
+
root.innerHTML = html ? html : ' ';
|
|
18
16
|
return convertFromDOMElement(root, schema, plugins);
|
|
19
17
|
}
|
package/dist/convertFromJSON.js
CHANGED
|
@@ -13,44 +13,28 @@ var _createEmptyEditorState = _interopRequireDefault(require("./createEmptyEdito
|
|
|
13
13
|
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
|
|
16
|
-
function convertFromJSON(json, schema, defaultSchema,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const effectivePlugins = defaultPlugins;
|
|
21
|
-
|
|
22
|
-
if (plugins) {
|
|
23
|
-
for (const p of plugins) {
|
|
24
|
-
if (!effectivePlugins.includes(p)) {
|
|
25
|
-
effectivePlugins.push(p);
|
|
26
|
-
|
|
27
|
-
if (p.getEffectiveSchema) {
|
|
28
|
-
editorSchema = p.getEffectiveSchema(editorSchema);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (p.initKeyCommands) {
|
|
32
|
-
effectivePlugins.push(p.initKeyCommands());
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
16
|
+
function convertFromJSON(json, schema, defaultSchema, effectivePlugins) {
|
|
17
|
+
const editorSchema = schema || defaultSchema;
|
|
18
|
+
let error = false;
|
|
37
19
|
|
|
38
20
|
if (typeof json === 'string') {
|
|
39
21
|
try {
|
|
40
22
|
json = JSON.parse(json);
|
|
41
23
|
} catch (ex) {
|
|
42
|
-
console.error('convertFromJSON:', ex);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return (0, _createEmptyEditorState.default)(schema, defaultSchema, plugins, defaultPlugins);
|
|
24
|
+
console.error('convertFromJSON:', ex);
|
|
25
|
+
error = true;
|
|
46
26
|
}
|
|
47
27
|
}
|
|
48
28
|
|
|
49
29
|
if (!json || typeof json !== 'object') {
|
|
50
|
-
console.error('convertFromJSON: invalid object', json);
|
|
51
|
-
|
|
30
|
+
console.error('convertFromJSON: invalid object', json);
|
|
31
|
+
error = true;
|
|
32
|
+
}
|
|
52
33
|
|
|
53
|
-
|
|
34
|
+
if (error) {
|
|
35
|
+
// [FS] IRAD-1455 2021-06-16
|
|
36
|
+
// Use the effectivePlugins, editor hangs, b'coz of missing default core plugins
|
|
37
|
+
return (0, _createEmptyEditorState.default)(schema, defaultSchema, effectivePlugins);
|
|
54
38
|
} // [FS] IRAD-1067 2020-09-19
|
|
55
39
|
// Handle gracefully when error thrown on invalid json
|
|
56
40
|
|
|
@@ -9,54 +9,32 @@ export default function convertFromJSON(
|
|
|
9
9
|
json: Object | string,
|
|
10
10
|
schema: ?Schema,
|
|
11
11
|
defaultSchema: Schema,
|
|
12
|
-
|
|
13
|
-
defaultPlugins: Array<Plugin>
|
|
12
|
+
effectivePlugins: Array<Plugin>
|
|
14
13
|
): EditorState {
|
|
15
|
-
|
|
14
|
+
const editorSchema = schema || defaultSchema;
|
|
15
|
+
let error = false;
|
|
16
16
|
|
|
17
|
-
// [FS][IRAD-???? 2020-08-17]
|
|
18
|
-
// Loads plugins and its corresponding schema in editor
|
|
19
|
-
const effectivePlugins = defaultPlugins;
|
|
20
|
-
|
|
21
|
-
if (plugins) {
|
|
22
|
-
for (const p of plugins) {
|
|
23
|
-
if (!effectivePlugins.includes(p)) {
|
|
24
|
-
effectivePlugins.push(p);
|
|
25
|
-
if (p.getEffectiveSchema) {
|
|
26
|
-
editorSchema = p.getEffectiveSchema(editorSchema);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (p.initKeyCommands) {
|
|
30
|
-
effectivePlugins.push(p.initKeyCommands());
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
17
|
if (typeof json === 'string') {
|
|
36
18
|
try {
|
|
37
19
|
json = JSON.parse(json);
|
|
38
20
|
} catch (ex) {
|
|
39
21
|
console.error('convertFromJSON:', ex);
|
|
40
|
-
|
|
41
|
-
// Use the effectivePlugins, editor hangs, b'coz of missing default core plugins
|
|
42
|
-
return createEmptyEditorState(
|
|
43
|
-
schema,
|
|
44
|
-
defaultSchema,
|
|
45
|
-
plugins,
|
|
46
|
-
defaultPlugins
|
|
47
|
-
);
|
|
22
|
+
error = true;
|
|
48
23
|
}
|
|
49
24
|
}
|
|
50
25
|
|
|
51
26
|
if (!json || typeof json !== 'object') {
|
|
52
27
|
console.error('convertFromJSON: invalid object', json);
|
|
28
|
+
error = true;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if(error) {
|
|
53
32
|
// [FS] IRAD-1455 2021-06-16
|
|
54
33
|
// Use the effectivePlugins, editor hangs, b'coz of missing default core plugins
|
|
55
34
|
return createEmptyEditorState(
|
|
56
35
|
schema,
|
|
57
36
|
defaultSchema,
|
|
58
|
-
|
|
59
|
-
defaultPlugins
|
|
37
|
+
effectivePlugins
|
|
60
38
|
);
|
|
61
39
|
}
|
|
62
40
|
|
|
@@ -10,8 +10,6 @@ var _prosemirrorModel = require("prosemirror-model");
|
|
|
10
10
|
|
|
11
11
|
var _prosemirrorState = require("prosemirror-state");
|
|
12
12
|
|
|
13
|
-
var _buildEditorPlugins = _interopRequireDefault(require("./buildEditorPlugins"));
|
|
14
|
-
|
|
15
13
|
var _convertFromJSON = _interopRequireDefault(require("./convertFromJSON"));
|
|
16
14
|
|
|
17
15
|
var _EditorSchema = _interopRequireDefault(require("./EditorSchema"));
|
|
@@ -27,8 +25,7 @@ const EMPTY_DOC_JSON = {
|
|
|
27
25
|
};
|
|
28
26
|
exports.EMPTY_DOC_JSON = EMPTY_DOC_JSON;
|
|
29
27
|
|
|
30
|
-
function createEmptyEditorState(schema, defaultSchema, plugins
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return (0, _convertFromJSON.default)(EMPTY_DOC_JSON, schema, defaultSchema ? defaultSchema : _EditorSchema.default, plugins, defaultPlugins ? defaultPlugins : new _buildEditorPlugins.default(newSchema).get());
|
|
28
|
+
function createEmptyEditorState(schema, defaultSchema, plugins) {
|
|
29
|
+
// TODO: Check if schema support doc and paragraph nodes.
|
|
30
|
+
return (0, _convertFromJSON.default)(EMPTY_DOC_JSON, schema, defaultSchema ? defaultSchema : _EditorSchema.default, plugins);
|
|
34
31
|
}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import { Schema } from 'prosemirror-model';
|
|
4
4
|
import { EditorState } from 'prosemirror-state';
|
|
5
5
|
import { Plugin } from 'prosemirror-state';
|
|
6
|
-
import DefaultEditorPlugins from './buildEditorPlugins';
|
|
7
6
|
|
|
8
7
|
import convertFromJSON from './convertFromJSON';
|
|
9
8
|
import EditorSchema from './EditorSchema';
|
|
@@ -12,24 +11,21 @@ export const EMPTY_DOC_JSON = {
|
|
|
12
11
|
type: 'doc',
|
|
13
12
|
content: [
|
|
14
13
|
{
|
|
15
|
-
type: 'paragraph'
|
|
16
|
-
}
|
|
14
|
+
type: 'paragraph',
|
|
15
|
+
}, // [FS] IRAD-1710 2022-03-04 - No text content needed
|
|
17
16
|
],
|
|
18
17
|
};
|
|
19
18
|
|
|
20
19
|
export default function createEmptyEditorState(
|
|
21
20
|
schema: ?Schema,
|
|
22
21
|
defaultSchema: ?Schema,
|
|
23
|
-
plugins:
|
|
24
|
-
defaultPlugins: ?Array<Plugin>
|
|
22
|
+
plugins: Array<Plugin>
|
|
25
23
|
): EditorState {
|
|
26
|
-
const newSchema = schema || (defaultSchema ? defaultSchema : EditorSchema);
|
|
27
24
|
// TODO: Check if schema support doc and paragraph nodes.
|
|
28
25
|
return convertFromJSON(
|
|
29
26
|
EMPTY_DOC_JSON,
|
|
30
27
|
schema,
|
|
31
28
|
defaultSchema ? defaultSchema : EditorSchema,
|
|
32
|
-
plugins
|
|
33
|
-
defaultPlugins ? defaultPlugins : new DefaultEditorPlugins(newSchema).get()
|
|
29
|
+
plugins
|
|
34
30
|
);
|
|
35
31
|
}
|
package/dist/index.js
CHANGED
|
@@ -9,6 +9,12 @@ Object.defineProperty(exports, "DELETE", {
|
|
|
9
9
|
return _http.DELETE;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
+
Object.defineProperty(exports, "DataType", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _Licit.DataType;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
12
18
|
Object.defineProperty(exports, "EditorRuntime", {
|
|
13
19
|
enumerable: true,
|
|
14
20
|
get: function () {
|
|
@@ -70,10 +76,14 @@ var _isEditorStateEmpty = _interopRequireDefault(require("./isEditorStateEmpty")
|
|
|
70
76
|
|
|
71
77
|
var _uuid = _interopRequireDefault(require("./ui/uuid"));
|
|
72
78
|
|
|
73
|
-
var _Licit =
|
|
79
|
+
var _Licit = _interopRequireWildcard(require("./client/Licit.js"));
|
|
74
80
|
|
|
75
81
|
var _Types = require("./Types");
|
|
76
82
|
|
|
77
83
|
var _http = require("./client/http");
|
|
78
84
|
|
|
85
|
+
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); }
|
|
86
|
+
|
|
87
|
+
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; }
|
|
88
|
+
|
|
79
89
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
package/dist/index.js.flow
CHANGED
|
@@ -5,6 +5,6 @@ export { default as isEditorStateEmpty } from './isEditorStateEmpty';
|
|
|
5
5
|
export { default as uuid } from './ui/uuid';
|
|
6
6
|
// [FS] IRAD-978 2020-06-05
|
|
7
7
|
// Export Licit as a component
|
|
8
|
-
export { default as Licit } from './client/Licit.js';
|
|
8
|
+
export { default as Licit, DataType } from './client/Licit.js';
|
|
9
9
|
export { ImageLike, EditorRuntime } from './Types';
|
|
10
10
|
export { GET, POST, DELETE, PATCH } from './client/http';
|
|
@@ -6,8 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.ATTRIBUTE_CSS_BEFORE_CONTENT = void 0;
|
|
7
7
|
exports.default = patchStyleElements;
|
|
8
8
|
|
|
9
|
-
var _stable = _interopRequireDefault(require("stable"));
|
|
10
|
-
|
|
11
9
|
var _toCSSColor = _interopRequireDefault(require("./ui/toCSSColor"));
|
|
12
10
|
|
|
13
11
|
var _licitUiCommands = require("@modusoperandi/licit-ui-commands");
|
|
@@ -99,7 +97,7 @@ function patchStyleElements(doc) {
|
|
|
99
97
|
});
|
|
100
98
|
}); // Sort selector by
|
|
101
99
|
|
|
102
|
-
|
|
100
|
+
selectorTextToCSSTexts.sort(sortBySpecificity).reduce(buildElementToCSSTexts.bind(null, doc), new Map()).forEach(applyInlineStyleSheetCSSTexts);
|
|
103
101
|
}
|
|
104
102
|
|
|
105
103
|
function buildElementToCSSTexts(doc, elementToCSSTexts, bag) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
|
|
3
|
-
import stable from 'stable';
|
|
4
3
|
import toCSSColor from './ui/toCSSColor';
|
|
5
4
|
import { toCSSLineSpacing } from '@modusoperandi/licit-ui-commands';
|
|
6
5
|
|
|
@@ -94,7 +93,8 @@ export default function patchStyleElements(doc: Document): void {
|
|
|
94
93
|
});
|
|
95
94
|
|
|
96
95
|
// Sort selector by
|
|
97
|
-
|
|
96
|
+
selectorTextToCSSTexts
|
|
97
|
+
.sort(sortBySpecificity)
|
|
98
98
|
.reduce(buildElementToCSSTexts.bind(null, doc), new Map<any, any>())
|
|
99
99
|
.forEach(applyInlineStyleSheetCSSTexts);
|
|
100
100
|
}
|
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
|
|
package/licit/client/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import ReactDOM from 'react-dom';
|
|
5
5
|
|
|
6
|
-
import Licit from '../../src/client/Licit';
|
|
6
|
+
import Licit, { DataType } from '../../src/client/Licit';
|
|
7
7
|
import CustomLicitRuntime from './CustomLicitRuntime';
|
|
8
8
|
|
|
9
9
|
function main(): void {
|
|
@@ -341,6 +341,7 @@ function main(): void {
|
|
|
341
341
|
<Licit
|
|
342
342
|
collabServiceURL={'http://localhost:3002'}
|
|
343
343
|
data={docJSON}
|
|
344
|
+
dataType={DataType.JSON}
|
|
344
345
|
debug={true}
|
|
345
346
|
docID={'0000-0000-0000-0000'}
|
|
346
347
|
embedded={false}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
|
|
3
|
-
const {readFileSync, writeFile} = require('fs');
|
|
3
|
+
const { readFileSync, writeFile } = require('fs');
|
|
4
4
|
|
|
5
5
|
// [FS] IRAD-1040 2020-09-02
|
|
6
|
-
import {Schema} from 'prosemirror-model';
|
|
6
|
+
import { Schema } from 'prosemirror-model';
|
|
7
7
|
|
|
8
8
|
let _editorSchema: Schema = null;
|
|
9
9
|
|
|
@@ -65,7 +65,7 @@ export class Instance {
|
|
|
65
65
|
}
|
|
66
66
|
this.sendUpdates();
|
|
67
67
|
scheduleSave();
|
|
68
|
-
return {version: this.version};
|
|
68
|
+
return { version: this.version };
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
sendUpdates() {
|
|
@@ -98,7 +98,7 @@ export class Instance {
|
|
|
98
98
|
|
|
99
99
|
const steps: any[] = this.steps.slice(startIndex);
|
|
100
100
|
const users = this.userCount;
|
|
101
|
-
return {steps: steps, users: users};
|
|
101
|
+
return { steps: steps, users: users };
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
collectUsers() {
|
|
@@ -156,7 +156,8 @@ function scheduleSave() {
|
|
|
156
156
|
function doSave() {
|
|
157
157
|
saveTimeout = null;
|
|
158
158
|
const out = {};
|
|
159
|
-
for (const prop in instances)
|
|
159
|
+
for (const prop in instances)
|
|
160
|
+
out[prop] = { doc: instances[prop].doc.toJSON() };
|
|
160
161
|
writeFile(saveFile, JSON.stringify(out), () => {});
|
|
161
162
|
}
|
|
162
163
|
|
|
@@ -205,10 +206,24 @@ function newInstance(id: any, doc: any) {
|
|
|
205
206
|
return (instances[id] = new Instance(id, doc));
|
|
206
207
|
}
|
|
207
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
|
+
|
|
208
223
|
export function instanceInfo() {
|
|
209
224
|
const found = [];
|
|
210
225
|
for (const id in instances)
|
|
211
|
-
found.push({id: id, users: instances[id].userCount});
|
|
226
|
+
found.push({ id: id, users: instances[id].userCount });
|
|
212
227
|
return found;
|
|
213
228
|
}
|
|
214
229
|
export class CustomError extends Error {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
|
|
3
|
-
import {Step} from 'prosemirror-transform';
|
|
4
|
-
import {Schema} from 'prosemirror-model';
|
|
3
|
+
import { Step } from 'prosemirror-transform';
|
|
4
|
+
import { Schema } from 'prosemirror-model';
|
|
5
5
|
import Router from './route';
|
|
6
6
|
import EditorSchema from '../../../src/EditorSchema';
|
|
7
7
|
import {
|
|
@@ -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.
|
|
@@ -41,7 +42,7 @@ function handleCollabRequest(req: any, resp: any) {
|
|
|
41
42
|
resp.writeHead(200, headers);
|
|
42
43
|
resp.end();
|
|
43
44
|
} else {
|
|
44
|
-
resp.writeHead(404, {'Content-Type': TXT_PLAIN});
|
|
45
|
+
resp.writeHead(404, { 'Content-Type': TXT_PLAIN });
|
|
45
46
|
resp.end('Not found');
|
|
46
47
|
}
|
|
47
48
|
}
|
|
@@ -92,7 +93,12 @@ function readStreamAsJSON(stream, callback) {
|
|
|
92
93
|
stream.on('end', () => {
|
|
93
94
|
let result, error;
|
|
94
95
|
try {
|
|
95
|
-
|
|
96
|
+
if (typeof data === 'string') {
|
|
97
|
+
result = JSON.parse(data);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
result = data;
|
|
101
|
+
}
|
|
96
102
|
} catch (e) {
|
|
97
103
|
error = e;
|
|
98
104
|
}
|
|
@@ -152,6 +158,20 @@ handle('GET', [DOCS], () => {
|
|
|
152
158
|
return Output.json(instanceInfo());
|
|
153
159
|
});
|
|
154
160
|
|
|
161
|
+
// Save & Output the current state of a document instance.
|
|
162
|
+
handle('PUT', [DOCS, null], (data, id, req) => {
|
|
163
|
+
const inst = updateInstance(
|
|
164
|
+
id,
|
|
165
|
+
reqIP(req),
|
|
166
|
+
req.query.dataDefined === 'false' ? null : data
|
|
167
|
+
);
|
|
168
|
+
return Output.json({
|
|
169
|
+
doc_json: inst.doc.toJSON(),
|
|
170
|
+
users: inst.userCount,
|
|
171
|
+
version: inst.version,
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
|
|
155
175
|
// Output the current state of a document instance.
|
|
156
176
|
handle('GET', [DOCS, null], (id, req) => {
|
|
157
177
|
const inst = getInstance(id, reqIP(req));
|
|
@@ -275,7 +295,7 @@ handle(
|
|
|
275
295
|
});
|
|
276
296
|
setEditorSchema(effectiveSchema);
|
|
277
297
|
}
|
|
278
|
-
return Output.json({result: 'success'});
|
|
298
|
+
return Output.json({ result: 'success' });
|
|
279
299
|
},
|
|
280
300
|
true
|
|
281
301
|
);
|