@modusoperandi/licit 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -1,6 +1,165 @@
1
- export { EditorState } from "prosemirror-state";
2
- export { default as isEditorStateEmpty } from "./isEditorStateEmpty";
3
- export { default as uuid } from "./ui/uuid";
4
- export { default as Licit, DataType } from "./client/Licit.js";
5
- export { ImageLike, EditorRuntime } from "./Types";
6
- export { GET, POST, DELETE, PATCH } from "./client/http";
1
+ // from "./isEditorStateEmpty"
2
+ import { EditorState, Plugin } from 'prosemirror-state';
3
+ import { Node, Schema } from 'prosemirror-model';
4
+ import { Transform } from 'prosemirror-transform';
5
+ import { EditorView } from 'prosemirror-view';
6
+ import * as React from 'react';
7
+
8
+ export default function isEditorStateEmpty(editorState: EditorState): boolean;
9
+
10
+ // from "./ui/uuid";
11
+ export default function uuid(): string;
12
+
13
+ // from './client/Licit.js';
14
+
15
+ export type DataType = Readonly<{
16
+ JSON: symbol;
17
+ HTML: symbol;
18
+ }>;
19
+
20
+ export class Licit extends React.Component<any, any> {
21
+ runtime: any;
22
+
23
+ constructor(props: any, context: any);
24
+
25
+ /**
26
+ * Provides access to prosemirror view.
27
+ */
28
+ get editorView(): EditorView;
29
+
30
+ initialize(props: any);
31
+
32
+ initEditorState(plugins: Array<Plugin>, dataType: DataType, data: any);
33
+
34
+ getEffectivePlugins(
35
+ schema: Schema,
36
+ defaultPlugins: Array<Plugin>,
37
+ plugins: Array<Plugin>
38
+ ): { plugins: Array<Plugin>; schema: Schema; pasteJSONPlugin: Plugin };
39
+
40
+ onReady(state: EditorState);
41
+
42
+ showAlert();
43
+
44
+ resetCounters(transaction: Transform);
45
+
46
+ setCounterFlags(transaction: Transform, reset: boolean);
47
+
48
+ getDeletedArtifactIds();
49
+
50
+ isNodeHasAttribute(node: Node, attrName: string);
51
+
52
+ getDocument(content: any, editorState: EditorState, dataType: DataType);
53
+
54
+ insertJSON(json: { [key: string]: any } | string): void;
55
+
56
+ setContent(content: any, dataType: DataType): void;
57
+
58
+ hasDataChanged(nextData: any, nextDataType: DataType);
59
+
60
+ changeContent(data: any, dataType: DataType);
61
+
62
+ shouldComponentUpdate(nextProps: any, nextState: any);
63
+
64
+ setDocID(nextState: any);
65
+
66
+ render(): React.ReactElement<any>;
67
+
68
+ _onChange(data: { state: EditorState; transaction: Transform }): void;
69
+
70
+ closeOpenedPopupModels();
71
+
72
+ _onReady(editorView: EditorView): void;
73
+
74
+ /**
75
+ * LICIT properties:
76
+ * docID {number} [0] Collaborative Doument ID
77
+ * debug {boolean} [false] To enable/disable ProseMirror Debug Tools, available only in development.
78
+ * width {string} [100%] Width of the editor.
79
+ * height {height} [100%] Height of the editor.
80
+ * readOnly {boolean} [false] To enable/disable editing mode.
81
+ * onChange {@callback} [null] Fires after each significant change.
82
+ * @param data {JSON} Modified document data.
83
+ * onReady {@callback} [null] Fires when the editor is fully ready.
84
+ * @param ref {LICIT} Rerefence of the editor.
85
+ * data {JSON} [null] Document data to be loaded into the editor.
86
+ * disabled {boolean} [false] Disable the editor.
87
+ * embedded {boolean} [false] Disable/Enable inline behaviour.
88
+ */
89
+ setProps(props: any): void;
90
+
91
+ exportPDF();
92
+
93
+ goToEnd(): void;
94
+ }
95
+
96
+ // from './Types';
97
+ export type NodeSpec = {
98
+ attrs?: { [key: string]: any };
99
+ content?: string;
100
+ draggable?: boolean;
101
+ group?: string;
102
+ inline?: boolean;
103
+ name?: string;
104
+ parseDOM?: Array<any>;
105
+ toDOM?: (node: any) => Array<any>;
106
+ };
107
+
108
+ export type MarkSpec = {
109
+ attrs?: { [key: string]: any };
110
+ name?: string;
111
+ parseDOM: Array<any>;
112
+ toDOM: (node: any) => Array<any>;
113
+ };
114
+
115
+ export type EditorProps = {
116
+ // TODO: Fill the interface.
117
+ // https://github.com/ProseMirror/prosemirror-view/blob/master/src/index.js
118
+ };
119
+
120
+ export type DirectEditorProps = EditorProps & {
121
+ // TODO: Fill the interface.
122
+ // https://github.com/ProseMirror/prosemirror-view/blob/master/src/index.js
123
+ };
124
+
125
+ export type RenderCommentProps = {
126
+ commentThreadId: string;
127
+ isActive: boolean;
128
+ requestCommentThreadDeletion: Function;
129
+ requestCommentThreadReflow: Function;
130
+ };
131
+
132
+ export type ImageLike = {
133
+ height: number;
134
+ id: string;
135
+ src: string;
136
+ width: number;
137
+ };
138
+
139
+ export type EditorRuntime = {
140
+ // Image Proxy
141
+ canProxyImageSrc?: (src: string) => boolean;
142
+ getProxyImageSrc?: (src: string) => string;
143
+
144
+ // Image Upload
145
+ canUploadImage?: () => boolean;
146
+ uploadImage?: (obj: Blob) => Promise<ImageLike>;
147
+
148
+ // Comments
149
+ canComment?: () => boolean;
150
+ createCommentThreadID?: () => string;
151
+ renderComment?: (
152
+ props: RenderCommentProps
153
+ ) => React.ReactElement<any> | undefined;
154
+
155
+ // External HTML
156
+ canLoadHTML?: () => boolean;
157
+ loadHTML?: () => Promise<string>;
158
+ };
159
+
160
+ // from './client/http';
161
+ export function GET(url);
162
+ export function POST(url, body, type);
163
+ export function PUT(url, body, type);
164
+ export function DELETE(url, type);
165
+ export function PATCH(url, body, type);
package/index.js CHANGED
@@ -4,5 +4,5 @@ export { default as uuid } from './ui/uuid';
4
4
  // [FS] IRAD-978 2020-06-05
5
5
  // Export Licit as a component
6
6
  export { default as Licit, DataType } from './client/Licit.js';
7
- export { ImageLike, EditorRuntime } from './Types';
7
+ // export { ImageLike, EditorRuntime } from './Types'; //Flow garbles these types beyond use for now
8
8
  export { GET, POST, DELETE, PATCH } from './client/http';
package/index.js.flow CHANGED
@@ -6,5 +6,5 @@ export { default as uuid } from './ui/uuid';
6
6
  // [FS] IRAD-978 2020-06-05
7
7
  // Export Licit as a component
8
8
  export { default as Licit, DataType } from './client/Licit.js';
9
- export { ImageLike, EditorRuntime } from './Types';
9
+ // export { ImageLike, EditorRuntime } from './Types'; //Flow garbles these types beyond use for now
10
10
  export { GET, POST, DELETE, PATCH } from './client/http';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modusoperandi/licit",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "type": "module",
5
5
  "subversion": "1",
6
6
  "description": "Rich text editor built with React and ProseMirror",
@@ -57,7 +57,7 @@
57
57
  "@babel/preset-react": "^7.18.6",
58
58
  "@cyclonedx/cyclonedx-npm": "^1.11.0",
59
59
  "babel-jest": "^29.2.0",
60
- "babel-loader": "^8.2.5",
60
+ "babel-loader": "^9.1.3",
61
61
  "babel-plugin-flow-react-proptypes": "^26.0.0",
62
62
  "babel-plugin-transform-react-remove-prop-types": "^0.4.24",
63
63
  "clean-webpack-plugin": "^4.0.0",
@@ -75,22 +75,26 @@
75
75
  "flow-bin": "^0.228.0",
76
76
  "flow-copy-source": "^2.0.9",
77
77
  "flow-webpack-plugin": "^1.2.0",
78
- "html-loader": "^1.1.0",
78
+ "html-loader": "^5.0.0",
79
79
  "html-webpack-inline-source-plugin": "1.0.0-beta.2",
80
80
  "html-webpack-plugin": "^5.5.0",
81
- "husky": "^8.0.1",
81
+ "husky": "^9.0.10",
82
82
  "identity-obj-proxy": "^3.0.0",
83
83
  "jest": "^29.2.0",
84
84
  "jest-environment-jsdom": "^29.3.1",
85
- "jest-prosemirror": "^1.0.3",
85
+ "jest-junit": "^14.0.1",
86
+ "jest-prosemirror": "^2.1.5",
86
87
  "jest-sonar-reporter": "^2.0.0",
87
88
  "lint-staged": "^13.0.3",
88
89
  "mkdirp": "^3.0.1",
89
90
  "prettier": "^2.1.2",
90
91
  "stylelint": "^15.6.0",
91
- "stylelint-config-standard": "^33.0.0",
92
+ "stylelint-config-standard": "^34.0.0",
92
93
  "stylelint-prettier": "^3.0.0",
93
- "terser-webpack-plugin": "^3.1.0",
94
+ "terser-webpack-plugin": "^5.3.10",
95
+ "ts-jest": "^29.1.2",
96
+ "ts-loader": "^9.5.0",
97
+ "ts-node": "^10.9.2",
94
98
  "webpack": "^5.74.0",
95
99
  "webpack-cli": "^5.1.4",
96
100
  "webpack-dev-server": "^4.11.1",
@@ -99,6 +103,7 @@
99
103
  "dependencies": {
100
104
  "@cfaester/enzyme-adapter-react-18": "^0.7.1",
101
105
  "body-parser": "^1.19.0",
106
+ "browserkeymap": "^2.0.2",
102
107
  "cors": "^2.8.5",
103
108
  "express": "^4.17.1",
104
109
  "flatted": "^3.1.0",
@@ -115,7 +120,8 @@
115
120
  "resize-observer-polyfill": "^1.5.1",
116
121
  "smooth-scroll-into-view-if-needed": "^1.1.28",
117
122
  "style-loader": "^3.3.3",
118
- "url": "^0.11.0"
123
+ "url": "^0.11.0",
124
+ "webfontloader": "^1.6.28"
119
125
  },
120
126
  "peerDependencies": {
121
127
  "@modusoperandi/licit-ui-commands": "^1.0.0",
@@ -97,7 +97,7 @@ export default function patchStyleElements(doc: Document): void {
97
97
  // Sort selector by
98
98
  selectorTextToCSSTexts
99
99
  .sort(sortBySpecificity)
100
- .reduce(buildElementToCSSTexts.bind(null, doc), new Map<any, any>())
100
+ .reduce(buildElementToCSSTexts.bind(null, doc), new Map())
101
101
  .forEach(applyInlineStyleSheetCSSTexts);
102
102
  }
103
103
 
@@ -7,14 +7,14 @@ import nullthrows from 'nullthrows';
7
7
  // https://github.com/que-etc/resize-observer-polyfill/blob/master/src/index.js.flow
8
8
 
9
9
  type ClientRectLikeReadOnly = {
10
- +x: number,
11
- +y: number,
12
- +width: number,
13
- +height: number,
14
- +top: number,
15
- +right: number,
16
- +bottom: number,
17
- +left: number,
10
+ x: number,
11
+ y: number,
12
+ width: number,
13
+ height: number,
14
+ top: number,
15
+ right: number,
16
+ bottom: number,
17
+ left: number,
18
18
  };
19
19
 
20
20
  type ResizeCallback = (r: ResizeObserverEntry) => void;
@@ -29,13 +29,13 @@ type Entries = $ReadOnlyArray<ResizeObserverEntry>;
29
29
  // `ResizeObserver.unobserve(element)`
30
30
 
31
31
  export type ResizeObserverEntry = {
32
- +target: Element,
33
- +contentRect: ClientRectLikeReadOnly,
32
+ target: Element,
33
+ contentRect: ClientRectLikeReadOnly,
34
34
  };
35
35
 
36
36
  let instance: ?ResizeObserver = null;
37
37
 
38
- const nodesObserving: Map<Element, Array<ResizeCallback>> = new Map<any, any>();
38
+ const nodesObserving: Map<Element, Array<ResizeCallback>> = new Map();
39
39
 
40
40
  function onResizeObserve(entries: Entries): void {
41
41
  entries.forEach(handleResizeObserverEntry);
@@ -2,7 +2,7 @@
2
2
 
3
3
  import url from 'url';
4
4
 
5
- const addedElements = new Map<any, any>();
5
+ const addedElements = new Map();
6
6
 
7
7
  function createElement(tag: string, attrs: Object): Element {
8
8
  const el: any = document.createElement(tag);