@modusoperandi/licit 1.0.5 → 1.0.8
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/BlockquoteInsertNewLineCommand.js +10 -11
- package/BlockquoteInsertNewLineCommand.js.flow +1 -2
- package/BlockquoteNodeSpec.js +2 -3
- package/BlockquoteNodeSpec.js.flow +1 -2
- package/BlockquoteToggleCommand.js +9 -9
- package/BookmarkNodeSpec.js +1 -1
- package/CodeBlockCommand.js +10 -10
- package/CodeBlockCommand.js.flow +1 -1
- package/ContentPlaceholderPlugin.js +17 -18
- package/ContentPlaceholderPlugin.js.flow +10 -14
- package/CursorPlaceholderPlugin.js +8 -9
- package/CursorPlaceholderPlugin.js.flow +0 -2
- package/DocLayoutCommand.js +10 -12
- package/DocLayoutCommand.js.flow +1 -3
- package/EditorKeyMap.js +0 -1
- package/EditorKeyMap.js.flow +0 -2
- package/EditorMarks.js +1 -1
- package/EditorNodes.js +1 -2
- package/EditorNodes.js.flow +0 -1
- package/EditorPageLayoutPlugin.js +8 -8
- package/FontTypeMarkSpec.js +1 -1
- package/FontTypeMarkSpec.js.flow +1 -1
- package/HTMLMutator.js +6 -7
- package/HTMLMutator.js.flow +2 -3
- package/HeadingNodeSpec.js +2 -12
- package/HeadingNodeSpec.js.flow +4 -14
- package/HistoryRedoCommand.js +9 -9
- package/HistoryUndoCommand.js +9 -9
- package/HorizontalRuleCommand.js +9 -9
- package/ImageUploadPlaceholderPlugin.js +14 -18
- package/ImageUploadPlaceholderPlugin.js.flow +6 -11
- package/LinkMarkSpec.js +6 -1
- package/LinkMarkSpec.js.flow +5 -0
- package/LinkSetURLCommand.js +126 -55
- package/LinkSetURLCommand.js.flow +61 -37
- package/LinkTooltipPlugin.js +119 -31
- package/LinkTooltipPlugin.js.flow +91 -22
- package/ListItemInsertNewLineCommand.js +10 -11
- package/ListItemInsertNewLineCommand.js.flow +1 -2
- package/ListItemMergeCommand.js +17 -16
- package/ListItemMergeCommand.js.flow +4 -6
- package/ListSplitCommand.js +9 -9
- package/ListToggleCommand.js +9 -9
- package/MarksClearCommand.js +9 -9
- package/MathEditCommand.js +10 -11
- package/MathEditCommand.js.flow +1 -2
- package/OrderedListNodeSpec.js +1 -1
- package/ParagraphNodeSpec.js +11 -2
- package/ParagraphNodeSpec.js.flow +9 -2
- package/ParagraphSpacingCommand.js +13 -14
- package/ParagraphSpacingCommand.js.flow +4 -9
- package/PrintCommand.js +9 -9
- package/SelectionPlaceholderPlugin.js +8 -9
- package/SelectionPlaceholderPlugin.js.flow +0 -2
- package/SpacerMarkSpec.js +1 -1
- package/StyleView.js +3 -4
- package/StyleView.js.flow +0 -1
- package/TableBackgroundColorCommand.js +13 -16
- package/TableBackgroundColorCommand.js.flow +14 -18
- package/TableBorderColorCommand.js +13 -16
- package/TableBorderColorCommand.js.flow +14 -20
- package/TableCellColorCommand.js +11 -13
- package/TableCellColorCommand.js.flow +2 -4
- package/TableCellMenuPlugin.js +16 -16
- package/TableCellMenuPlugin.js.flow +5 -8
- package/TableInsertCommand.js +12 -15
- package/TableInsertCommand.js.flow +3 -6
- package/TableMergeCellsCommand.js +13 -12
- package/TableMergeCellsCommand.js.flow +4 -3
- package/TableNodesSpecs.js +4 -2
- package/TableNodesSpecs.js.flow +4 -2
- package/TableResizePlugin.js +18 -18
- package/TableResizePlugin.js.flow +2 -3
- package/TextInsertTabSpaceCommand.js +9 -9
- package/Types.js +1 -0
- package/Types.js.flow +2 -5
- package/WebFontLoader.js +4 -4
- package/bom.xml +20047 -28206
- package/buildEditorPlugins.js +4 -4
- package/buildInputRules.js +8 -4
- package/buildInputRules.js.flow +8 -4
- package/client/CollabConnector.js +9 -9
- package/client/EditorConnection.js +8 -6
- package/client/EditorConnection.js.flow +3 -2
- package/client/Licit.js +22 -59
- package/client/Licit.js.flow +12 -45
- package/client/Licit.test.js +49 -39
- package/client/Licit.test.js.flow +40 -34
- package/client/Reporter.js +3 -3
- package/client/SimpleConnector.js +4 -4
- package/client/http.js +0 -6
- package/client/http.js.flow +0 -8
- package/client/throttle.js +8 -2
- package/client/throttle.js.flow +2 -2
- package/convertFromDOMElement.js +2 -4
- package/convertFromDOMElement.js.flow +2 -5
- package/convertFromHTML.js +2 -3
- package/convertFromHTML.js.flow +2 -4
- package/convertFromJSON.js +1 -2
- package/convertFromJSON.js.flow +1 -2
- package/convertToCSSPTValue.js +6 -10
- package/convertToCSSPTValue.js.flow +8 -11
- package/createCommand.js +9 -9
- package/createEditorKeyMap.js +1 -1
- package/createEmptyEditorState.js +2 -3
- package/createEmptyEditorState.js.flow +2 -4
- package/createTableResizingPlugin.js +6 -6
- package/createTableResizingPlugin.js.flow +1 -1
- package/findActiveMark.js +1 -1
- package/findActiveMark.js.flow +1 -1
- package/insertTable.js +0 -3
- package/insertTable.js.flow +0 -2
- package/joinDown.js +1 -3
- package/joinDown.js.flow +1 -3
- package/joinUp.js +1 -3
- package/joinUp.js.flow +1 -3
- package/lookUpElement.js +2 -1
- package/lookUpElement.js.flow +1 -1
- package/normalizeHTML.js +3 -1
- package/normalizeHTML.js.flow +3 -1
- package/package.json +23 -17
- package/patchAnchorElements.js +1 -1
- package/patchAnchorElements.js.flow +1 -1
- package/patchBreakElements.js +3 -2
- package/patchBreakElements.js.flow +2 -2
- package/patchElementInlineStyles.js +1 -1
- package/patchElementInlineStyles.js.flow +1 -1
- package/patchListElements.js +6 -7
- package/patchListElements.js.flow +7 -8
- package/patchMathElements.js +5 -7
- package/patchMathElements.js.flow +2 -4
- package/patchStyleElements.js +1 -1
- package/patchStyleElements.js.flow +7 -6
- package/patchTableElements.js +2 -3
- package/patchTableElements.js.flow +2 -3
- package/sanitizeURL.js +1 -1
- package/sanitizeURL.js.flow +1 -1
- package/splitListItem.js +2 -2
- package/splitListItem.js.flow +1 -1
- package/styles.css +32 -3
- package/toggleBlockquote.js +4 -5
- package/toggleBlockquote.js.flow +5 -12
- package/toggleCodeBlock.js +6 -6
- package/toggleCodeBlock.js.flow +10 -10
- package/ui/AlertInfo.js +9 -10
- package/ui/AlertInfo.js.flow +0 -1
- package/ui/BookmarkNodeView.js +13 -13
- package/ui/BookmarkNodeView.js.flow +0 -2
- package/ui/CommandButton.js +9 -9
- package/ui/CommandMenu.js +12 -12
- package/ui/CommandMenu.js.flow +1 -1
- package/ui/CommandMenuButton.js +11 -13
- package/ui/CommandMenuButton.js.flow +2 -5
- package/ui/CustomEditorView.js +13 -12
- package/ui/CustomEditorView.js.flow +1 -0
- package/ui/CustomMenu.js +8 -10
- package/ui/CustomMenu.js.flow +0 -3
- package/ui/CustomMenuItem.js +10 -11
- package/ui/CustomMenuItem.js.flow +0 -1
- package/ui/CustomNodeView.js +27 -16
- package/ui/CustomNodeView.js.flow +16 -9
- package/ui/CustomRadioButton.js +13 -16
- package/ui/CustomRadioButton.js.flow +2 -4
- package/ui/DocLayoutEditor.js +10 -13
- package/ui/DocLayoutEditor.js.flow +1 -5
- package/ui/Editor.js +16 -16
- package/ui/Editor.js.flow +7 -12
- package/ui/EditorFrameset.js +9 -10
- package/ui/EditorFrameset.js.flow +0 -2
- package/ui/EditorToolbar.js +24 -30
- package/ui/EditorToolbar.js.flow +22 -43
- package/ui/EditorToolbarConfig.js +5 -5
- package/ui/EditorToolbarConfig.js.flow +1 -1
- package/ui/FontSizeCommandMenuButton.js +10 -10
- package/ui/FontSizeCommandMenuButton.js.flow +1 -1
- package/ui/FontTypeCommandMenuButton.js +11 -12
- package/ui/FontTypeCommandMenuButton.js.flow +4 -5
- package/ui/Frag.js +8 -9
- package/ui/Frag.js.flow +0 -2
- package/ui/Icon.js +12 -18
- package/ui/Icon.js.flow +0 -7
- package/ui/ImageInlineEditor.js +9 -10
- package/ui/ImageInlineEditor.js.flow +0 -1
- package/ui/LinkTooltip.js +62 -28
- package/ui/LinkTooltip.js.flow +55 -24
- package/ui/LinkURLEditor.js +151 -36
- package/ui/LinkURLEditor.js.flow +176 -54
- package/ui/ListItemNodeView.js +4 -4
- package/ui/ListTypeButton.js +11 -15
- package/ui/ListTypeButton.js.flow +2 -6
- package/ui/ListTypeCommandButton.js +10 -10
- package/ui/ListTypeCommandButton.js.flow +1 -1
- package/ui/ListTypeMenu.js +11 -12
- package/ui/ListTypeMenu.js.flow +1 -2
- package/ui/LoadingIndicator.js +8 -9
- package/ui/LoadingIndicator.js.flow +0 -1
- package/ui/MathEditor.js +10 -15
- package/ui/MathEditor.js.flow +1 -9
- package/ui/MathInlineEditor.js +13 -14
- package/ui/MathInlineEditor.js.flow +3 -5
- package/ui/MathNodeView.js +16 -16
- package/ui/MathNodeView.js.flow +10 -21
- package/ui/PasteMenu.js +11 -15
- package/ui/PasteMenu.js.flow +0 -5
- package/ui/ResizeObserver.js +4 -4
- package/ui/ResizeObserver.js.flow +3 -4
- package/ui/RichTextEditor.js +9 -9
- package/ui/SelectionObserver.js +6 -6
- package/ui/SelectionObserver.js.flow +2 -2
- package/ui/TableCellMenu.js +9 -10
- package/ui/TableCellMenu.js.flow +0 -2
- package/ui/TableGridSizeEditor.js +12 -15
- package/ui/TableGridSizeEditor.js.flow +7 -6
- package/ui/TableNodeView.js +15 -13
- package/ui/TableNodeView.js.flow +3 -3
- package/ui/bindScrollHandler.js +2 -1
- package/ui/bindScrollHandler.js.flow +1 -1
- package/ui/canUseCSSFont.js +5 -4
- package/ui/canUseCSSFont.js.flow +4 -5
- package/ui/czi-editor.css +1 -4
- package/ui/czi-form.css +102 -8
- package/ui/czi-image-view.css +1 -5
- package/ui/czi-link-tooltip.css +41 -0
- package/ui/czi-list.css +0 -4
- package/ui/czi-loading-indicator.css +1 -46
- package/ui/czi-table-cell-menu.css +3 -1
- package/ui/findActiveFontSize.js +2 -1
- package/ui/findActiveFontSize.js.flow +1 -4
- package/ui/findActiveFontType.js +4 -3
- package/ui/findActiveFontType.js.flow +3 -6
- package/ui/handleEditorDrop.js +1 -1
- package/ui/handleEditorDrop.js.flow +1 -1
- package/ui/handleEditorKeyDown.js +1 -1
- package/ui/handleEditorKeyDown.js.flow +1 -1
- package/ui/handleEditorPaste.js +1 -1
- package/ui/handleEditorPaste.js.flow +1 -1
- package/ui/injectStyleSheet.js +2 -2
- package/ui/injectStyleSheet.js.flow +2 -4
- package/ui/isElementFullyVisible.js +1 -10
- package/ui/isElementFullyVisible.js.flow +1 -13
- package/ui/mathquill-editor/MathQuillEditor.js +12 -14
- package/ui/mathquill-editor/MathQuillEditor.js.flow +0 -2
- package/ui/mathquill-editor/MathQuillEditorSymbolsPanel.js +9 -10
- package/ui/mathquill-editor/MathQuillEditorSymbolsPanel.js.flow +0 -1
- package/ui/mathquill-editor/mathquill-import-kludge.js +1 -9
- package/ui/mathquill-editor/mathquill-import-kludge.js.flow +0 -9
- package/ui/renderLaTeXAsHTML.js +3 -7
- package/ui/renderLaTeXAsHTML.js.flow +0 -4
- package/ui/resolveImage.js +4 -5
- package/ui/resolveImage.js.flow +3 -5
- package/ui/toCSSLineSpacing.js +2 -3
- package/ui/toCSSLineSpacing.js.flow +2 -4
- package/styles0.css +0 -29
package/normalizeHTML.js.flow
CHANGED
|
@@ -20,7 +20,7 @@ const LONG_UNDERLINE_PATTERN = /_+/g;
|
|
|
20
20
|
|
|
21
21
|
// This is a workround to convert " ...... " into wider tab
|
|
22
22
|
// tab spacers. For every 6 " ", they will be converted into tab spacers.
|
|
23
|
-
const LONG_TAB_SPACE_PATTERN = /(
|
|
23
|
+
const LONG_TAB_SPACE_PATTERN = /( ){6}/g;
|
|
24
24
|
|
|
25
25
|
const TAB_SPACER_HTML = new Array(6).join(
|
|
26
26
|
`<span ${DOM_ATTRIBUTE_SIZE}="${SPACER_SIZE_TAB}">${HAIR_SPACE_CHAR}</span>`
|
|
@@ -44,6 +44,8 @@ export default function normalizeHTML(html: string): string {
|
|
|
44
44
|
|
|
45
45
|
// Convert every two consecutive " " into a spacer tab.
|
|
46
46
|
html = html.replace(LONG_TAB_SPACE_PATTERN, TAB_SPACER_HTML);
|
|
47
|
+
// fix for jspdf copy paste text, from jspdf its always getting transparent
|
|
48
|
+
html = html.replace(/color:\s*transparent;/g, 'color: black;');
|
|
47
49
|
const doc = toSafeHTMLDocument(html);
|
|
48
50
|
if (doc) {
|
|
49
51
|
// styles.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modusoperandi/licit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"subversion": "1",
|
|
6
6
|
"description": "Rich text editor built with React and ProseMirror",
|
|
@@ -27,11 +27,12 @@
|
|
|
27
27
|
"ci:build": "npm run build:clean && npm run build:babel && npm run build:flow && npm run build:css && npm run build:fonts && npm run build:bom && copyfiles --up 1 \"src/**/*.d.ts\" dist/ && copyfiles --up 1 \"src/**/*.css\" dist && copyfiles package.json dist",
|
|
28
28
|
"flow": "flow --show-all-errors",
|
|
29
29
|
"lint:css": "stylelint \"**/*.css\"",
|
|
30
|
-
"lint:js": "eslint \"src/**/*.js\"
|
|
30
|
+
"lint:js": "eslint \"src/**/*.js\"",
|
|
31
31
|
"lint": "npm run lint:css & npm run lint:js",
|
|
32
32
|
"start": "node scripts/webserver.js",
|
|
33
33
|
"prebuild:style-service-docker": "node utils/build_customstyle_server.js",
|
|
34
|
-
"build:style-service-docker": "docker build . -f style-service.Dockerfile -t style-service:latest"
|
|
34
|
+
"build:style-service-docker": "docker build . -f style-service.Dockerfile -t style-service:latest",
|
|
35
|
+
"verify": "npm run lint -- --fix && npm run ci:build && npm run test:coverage && echo 'All Tests Passed!'"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
38
|
"@babel/cli": "^7.19.3",
|
|
@@ -60,34 +61,41 @@
|
|
|
60
61
|
"babel-loader": "^9.1.3",
|
|
61
62
|
"babel-plugin-flow-react-proptypes": "^26.0.0",
|
|
62
63
|
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
|
|
64
|
+
"body-parser": "^1.19.0",
|
|
63
65
|
"clean-webpack-plugin": "^4.0.0",
|
|
64
66
|
"copy-webpack-plugin": "^12.0.2",
|
|
65
|
-
"css-loader": "^7.1.1",
|
|
66
67
|
"copyfiles": "^2.4.1",
|
|
67
|
-
"
|
|
68
|
-
"
|
|
68
|
+
"cors": "^2.8.5",
|
|
69
|
+
"css-loader": "^7.1.1",
|
|
70
|
+
"eslint": "^8.0.0",
|
|
69
71
|
"eslint-config-prettier": "^9.0.0",
|
|
70
72
|
"eslint-plugin-jest": "^28.2.0",
|
|
71
73
|
"eslint-plugin-prettier": "^5.1.3",
|
|
72
74
|
"eslint-plugin-react": "^7.33.2",
|
|
73
75
|
"exports-loader": "^5.0.0",
|
|
76
|
+
"express": "^4.17.1",
|
|
74
77
|
"file-loader": "^6.2.0",
|
|
75
|
-
"flow-bin": "^0.
|
|
78
|
+
"flow-bin": "^0.254.2",
|
|
76
79
|
"flow-copy-source": "^2.0.9",
|
|
80
|
+
"flow-typed": "^4.0.0",
|
|
77
81
|
"flow-webpack-plugin": "^1.2.0",
|
|
82
|
+
"formidable": "^3.5.1",
|
|
78
83
|
"html-loader": "^5.0.0",
|
|
79
84
|
"html-webpack-inline-source-plugin": "1.0.0-beta.2",
|
|
80
85
|
"html-webpack-plugin": "^5.5.0",
|
|
81
86
|
"husky": "^9.0.10",
|
|
82
87
|
"identity-obj-proxy": "^3.0.0",
|
|
88
|
+
"invariant": "^2.2.4",
|
|
83
89
|
"jest": "^29.2.0",
|
|
84
90
|
"jest-environment-jsdom": "^29.3.1",
|
|
85
91
|
"jest-junit": "^16.0.0",
|
|
86
|
-
"jest-prosemirror": "^
|
|
92
|
+
"jest-prosemirror": "^3.0.0",
|
|
87
93
|
"jest-sonar-reporter": "^2.0.0",
|
|
88
94
|
"lint-staged": "^15.2.2",
|
|
89
95
|
"mkdirp": "^3.0.1",
|
|
96
|
+
"mv": "^2.1.1",
|
|
90
97
|
"prettier": "^3.2.5",
|
|
98
|
+
"style-loader": "^4.0.0",
|
|
91
99
|
"stylelint": "^16.2.1",
|
|
92
100
|
"stylelint-config-standard": "^36.0.0",
|
|
93
101
|
"stylelint-prettier": "^5.0.0",
|
|
@@ -95,29 +103,24 @@
|
|
|
95
103
|
"ts-jest": "^29.1.2",
|
|
96
104
|
"ts-loader": "^9.5.0",
|
|
97
105
|
"ts-node": "^10.9.2",
|
|
106
|
+
"typescript": "5.5.4",
|
|
98
107
|
"webpack": "^5.74.0",
|
|
99
108
|
"webpack-cli": "^5.1.4",
|
|
100
109
|
"webpack-dev-server": "^5.0.2",
|
|
101
110
|
"write-file-webpack-plugin": "^4.5.1"
|
|
102
111
|
},
|
|
103
112
|
"dependencies": {
|
|
104
|
-
"@cfaester/enzyme-adapter-react-18": "^0.7.1",
|
|
105
113
|
"@modusoperandi/color-picker": "^1.0.1",
|
|
106
114
|
"body-parser": "^1.19.0",
|
|
107
115
|
"browserkeymap": "^2.0.2",
|
|
108
|
-
"cors": "^2.8.5",
|
|
109
|
-
"express": "^4.17.1",
|
|
110
116
|
"flatted": "^3.1.0",
|
|
111
|
-
"flow-typed": "^
|
|
117
|
+
"flow-typed": "^4.0.0",
|
|
112
118
|
"formidable": "^3.5.1",
|
|
113
119
|
"invariant": "^2.2.4",
|
|
114
120
|
"jquery": "^3.5.1",
|
|
115
121
|
"katex": "^0.16.9",
|
|
116
|
-
"mv": "^2.1.1",
|
|
117
122
|
"node-mathquill": "^0.10.2",
|
|
118
|
-
"
|
|
119
|
-
"prosemirror-tables": "^1.2.5",
|
|
120
|
-
"query-string": "^9.0.0",
|
|
123
|
+
"react-tooltip": "^5.28.0",
|
|
121
124
|
"resize-observer-polyfill": "^1.5.1",
|
|
122
125
|
"smooth-scroll-into-view-if-needed": "^2.0.2",
|
|
123
126
|
"style-loader": "^4.0.0",
|
|
@@ -126,11 +129,14 @@
|
|
|
126
129
|
},
|
|
127
130
|
"peerDependencies": {
|
|
128
131
|
"@modusoperandi/licit-ui-commands": "^1.0.0",
|
|
132
|
+
"jquery": "^3.5.1",
|
|
129
133
|
"prosemirror-collab": "^1.2.2",
|
|
130
134
|
"prosemirror-tables": "^1.2.5"
|
|
131
135
|
},
|
|
132
136
|
"overrides": {
|
|
133
|
-
"
|
|
137
|
+
"libxmljs2": "^1.0.0",
|
|
138
|
+
"react": "^18.3.1",
|
|
139
|
+
"react-dom": "^18.3.1"
|
|
134
140
|
},
|
|
135
141
|
"importSort": {
|
|
136
142
|
".js": {
|
package/patchAnchorElements.js
CHANGED
|
@@ -15,7 +15,7 @@ function patchAnchorElement(node) {
|
|
|
15
15
|
// <a id="t.0"></a>
|
|
16
16
|
// <table class="c23">
|
|
17
17
|
// and these anchor link should not be visible.
|
|
18
|
-
var visible = node.id.
|
|
18
|
+
var visible = !node.id.startsWith('t.');
|
|
19
19
|
visible && node.setAttribute(ATTRIBUTE_BOOKMARK_VISIBLE, 'true');
|
|
20
20
|
}
|
|
21
21
|
var nextNode = node.nextElementSibling;
|
|
@@ -23,7 +23,7 @@ function patchAnchorElement(node: HTMLElement): void {
|
|
|
23
23
|
// <a id="t.0"></a>
|
|
24
24
|
// <table class="c23">
|
|
25
25
|
// and these anchor link should not be visible.
|
|
26
|
-
const visible = node.id.
|
|
26
|
+
const visible = !node.id.startsWith('t.');
|
|
27
27
|
|
|
28
28
|
visible && node.setAttribute(ATTRIBUTE_BOOKMARK_VISIBLE, 'true');
|
|
29
29
|
}
|
package/patchBreakElements.js
CHANGED
|
@@ -6,15 +6,16 @@ export default function patchBreakElements(doc) {
|
|
|
6
6
|
Array.from(doc.querySelectorAll(selector)).forEach(patchBreakElement);
|
|
7
7
|
}
|
|
8
8
|
function patchBreakElement(brElement) {
|
|
9
|
+
var _brElement$parentElem, _div$parentElement;
|
|
9
10
|
var ownerDocument = brElement.ownerDocument,
|
|
10
11
|
parentElement = brElement.parentElement;
|
|
11
12
|
if (!ownerDocument || !parentElement) {
|
|
12
13
|
return;
|
|
13
14
|
}
|
|
14
|
-
var div = brElement.parentElement
|
|
15
|
+
var div = (_brElement$parentElem = brElement.parentElement) === null || _brElement$parentElem === void 0 ? void 0 : _brElement$parentElem.parentElement;
|
|
15
16
|
if (!div) {
|
|
16
17
|
return;
|
|
17
18
|
}
|
|
18
19
|
var pp = ownerDocument.createElement('p');
|
|
19
|
-
|
|
20
|
+
(_div$parentElement = div.parentElement) === null || _div$parentElement === void 0 || _div$parentElement.replaceChild(pp, div);
|
|
20
21
|
}
|
|
@@ -13,10 +13,10 @@ function patchBreakElement(brElement: HTMLElement): void {
|
|
|
13
13
|
if (!ownerDocument || !parentElement) {
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
|
-
const div = brElement.parentElement
|
|
16
|
+
const div = brElement.parentElement?.parentElement;
|
|
17
17
|
if (!div) {
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
20
|
const pp = ownerDocument.createElement('p');
|
|
21
|
-
div.parentElement
|
|
21
|
+
div.parentElement?.replaceChild(pp, div);
|
|
22
22
|
}
|
|
@@ -23,7 +23,7 @@ function patchBlockElement(el) {
|
|
|
23
23
|
function patchBlockElementStyle(el, inlineStyleName) {
|
|
24
24
|
var element = el;
|
|
25
25
|
var elementStyle = element.style;
|
|
26
|
-
var value = elementStyle
|
|
26
|
+
var value = elementStyle === null || elementStyle === void 0 ? void 0 : elementStyle[inlineStyleName];
|
|
27
27
|
if (inlineStyleName === 'textIndent' && value) {
|
|
28
28
|
// This is the workaround to fix the issue that people with mix both
|
|
29
29
|
// text-indent and margin-left together.
|
|
@@ -49,7 +49,7 @@ function patchBlockElementStyle(
|
|
|
49
49
|
): void {
|
|
50
50
|
const element: any = el;
|
|
51
51
|
const elementStyle = element.style;
|
|
52
|
-
const value = elementStyle
|
|
52
|
+
const value = elementStyle?.[inlineStyleName];
|
|
53
53
|
|
|
54
54
|
if (inlineStyleName === 'textIndent' && value) {
|
|
55
55
|
// This is the workaround to fix the issue that people with mix both
|
package/patchListElements.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import HTMLMutator from './HTMLMutator.js';
|
|
2
|
-
import nullthrows from 'nullthrows';
|
|
3
2
|
import uuid from './ui/uuid.js';
|
|
4
3
|
import { ATTRIBUTE_LIST_STYLE_TYPE } from './ListItemNodeSpec.js';
|
|
5
4
|
import { ATTRIBUTE_INDENT, EMPTY_CSS_VALUE, convertMarginLeftToIndentValue } from './ParagraphNodeSpec.js';
|
|
@@ -23,12 +22,12 @@ var CHAR_CIRCLE = "\u25CB";
|
|
|
23
22
|
var CHAR_SQUARE = "\u25A0";
|
|
24
23
|
var CHAR_BOX = "\u274F";
|
|
25
24
|
var CHAR_ZERO_SPACE = "\u200B";
|
|
26
|
-
var INLINE_NODE_NAME_PATTERN = /^(#text
|
|
25
|
+
var INLINE_NODE_NAME_PATTERN = /^(#text|(A|SPAN|B|STRONG))$/;
|
|
27
26
|
function patchListElementsElement(listElement) {
|
|
28
27
|
// If the children of `listElement` all have teh same marginLeft, assume
|
|
29
28
|
// it to be indented.
|
|
30
|
-
var marginLeft
|
|
31
|
-
var beforeContent
|
|
29
|
+
var marginLeft;
|
|
30
|
+
var beforeContent;
|
|
32
31
|
var parentElement = listElement.parentElement,
|
|
33
32
|
children = listElement.children;
|
|
34
33
|
|
|
@@ -50,7 +49,7 @@ function patchListElementsElement(listElement) {
|
|
|
50
49
|
if (beforeContent !== bc) {
|
|
51
50
|
beforeContent = null;
|
|
52
51
|
}
|
|
53
|
-
var ml = style
|
|
52
|
+
var ml = (style === null || style === void 0 ? void 0 : style.marginLeft) || '';
|
|
54
53
|
if (marginLeft === undefined) {
|
|
55
54
|
marginLeft = ml;
|
|
56
55
|
}
|
|
@@ -174,8 +173,8 @@ function liftNestedListElements(doc) {
|
|
|
174
173
|
els.forEach(function (list) {
|
|
175
174
|
var indent = findIndentLevel(list);
|
|
176
175
|
list.setAttribute('data-indent', String(indent));
|
|
177
|
-
var parentListItem =
|
|
178
|
-
var parentList =
|
|
176
|
+
var parentListItem = list === null || list === void 0 ? void 0 : list.parentElement;
|
|
177
|
+
var parentList = parentListItem === null || parentListItem === void 0 ? void 0 : parentListItem.parentElement;
|
|
179
178
|
var parentListNodeName = parentList.nodeName.toLowerCase();
|
|
180
179
|
var isLast = parentList.lastElementChild === parentListItem;
|
|
181
180
|
var style = parentList.getAttribute('style') || '';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
|
|
3
3
|
import HTMLMutator from './HTMLMutator.js';
|
|
4
|
-
import nullthrows from 'nullthrows';
|
|
5
4
|
import uuid from './ui/uuid.js';
|
|
6
5
|
|
|
7
6
|
import { ATTRIBUTE_LIST_STYLE_TYPE } from './ListItemNodeSpec.js';
|
|
@@ -34,13 +33,13 @@ const CHAR_CIRCLE = '\u25cb';
|
|
|
34
33
|
const CHAR_SQUARE = '\u25a0';
|
|
35
34
|
const CHAR_BOX = '\u274f';
|
|
36
35
|
const CHAR_ZERO_SPACE = '\u200B';
|
|
37
|
-
const INLINE_NODE_NAME_PATTERN = /^(#text
|
|
36
|
+
const INLINE_NODE_NAME_PATTERN = /^(#text|(A|SPAN|B|STRONG))$/;
|
|
38
37
|
|
|
39
38
|
function patchListElementsElement(listElement: HTMLElement): void {
|
|
40
39
|
// If the children of `listElement` all have teh same marginLeft, assume
|
|
41
40
|
// it to be indented.
|
|
42
|
-
let marginLeft
|
|
43
|
-
let beforeContent
|
|
41
|
+
let marginLeft;
|
|
42
|
+
let beforeContent;
|
|
44
43
|
const { parentElement, children } = listElement;
|
|
45
44
|
|
|
46
45
|
// A workaround to patch the issue when <ul /> or <ol /> is pasted as the
|
|
@@ -68,7 +67,7 @@ function patchListElementsElement(listElement: HTMLElement): void {
|
|
|
68
67
|
beforeContent = null;
|
|
69
68
|
}
|
|
70
69
|
|
|
71
|
-
const ml = (style
|
|
70
|
+
const ml = (style?.marginLeft) || '';
|
|
72
71
|
if (marginLeft === undefined) {
|
|
73
72
|
marginLeft = ml;
|
|
74
73
|
}
|
|
@@ -211,8 +210,8 @@ function liftNestedListElements(doc: Document): void {
|
|
|
211
210
|
const indent = findIndentLevel(list);
|
|
212
211
|
list.setAttribute('data-indent', String(indent));
|
|
213
212
|
|
|
214
|
-
const parentListItem =
|
|
215
|
-
const parentList =
|
|
213
|
+
const parentListItem = list?.parentElement;
|
|
214
|
+
const parentList = parentListItem?.parentElement;
|
|
216
215
|
const parentListNodeName = parentList.nodeName.toLowerCase();
|
|
217
216
|
const isLast = parentList.lastElementChild === parentListItem;
|
|
218
217
|
const style = parentList.getAttribute('style') || '';
|
|
@@ -238,7 +237,7 @@ function liftNestedListElements(doc: Document): void {
|
|
|
238
237
|
// <ol><li>CCC</li></ol>
|
|
239
238
|
|
|
240
239
|
// Close the parent list before the list.
|
|
241
|
-
htmlMutator.insertHTMLBefore(
|
|
240
|
+
htmlMutator.insertHTMLBefore(`</${parentListNodeName}>`, list);
|
|
242
241
|
// Open a new list after list.
|
|
243
242
|
htmlMutator.insertHTMLAfter(
|
|
244
243
|
`<${parentListNodeName}
|
package/patchMathElements.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import queryString from 'query-string';
|
|
2
|
-
import url from 'url';
|
|
3
1
|
export default function patchMathElements(doc) {
|
|
4
2
|
Array.from(doc.querySelectorAll('img')).forEach(patchGoogleEquationElement);
|
|
5
3
|
}
|
|
@@ -39,14 +37,14 @@ function getGoogleEquationContent(src) {
|
|
|
39
37
|
if (!src) {
|
|
40
38
|
return null;
|
|
41
39
|
}
|
|
42
|
-
var
|
|
43
|
-
host =
|
|
44
|
-
pathname =
|
|
45
|
-
query =
|
|
40
|
+
var _URL = new URL(src),
|
|
41
|
+
host = _URL.host,
|
|
42
|
+
pathname = _URL.pathname,
|
|
43
|
+
query = _URL.query;
|
|
46
44
|
if (host !== 'www.google.com' || pathname !== '/chart') {
|
|
47
45
|
return null;
|
|
48
46
|
}
|
|
49
|
-
var params =
|
|
47
|
+
var params = new URL(query);
|
|
50
48
|
var chartType = params[PARAM_CHART_CHART_TYPE];
|
|
51
49
|
var label = params[PARAM_CHART_LABEL];
|
|
52
50
|
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
|
|
3
|
-
import queryString from 'query-string';
|
|
4
|
-
import url from 'url';
|
|
5
3
|
export default function patchMathElements(doc: Document): void {
|
|
6
4
|
Array.from(doc.querySelectorAll('img')).forEach(patchGoogleEquationElement);
|
|
7
5
|
}
|
|
@@ -41,12 +39,12 @@ function getGoogleEquationContent(src: ?string): ?string {
|
|
|
41
39
|
if (!src) {
|
|
42
40
|
return null;
|
|
43
41
|
}
|
|
44
|
-
const { host, pathname, query } =
|
|
42
|
+
const { host, pathname, query } = new URL(src);
|
|
45
43
|
if (host !== 'www.google.com' || pathname !== '/chart') {
|
|
46
44
|
return null;
|
|
47
45
|
}
|
|
48
46
|
|
|
49
|
-
const params =
|
|
47
|
+
const params = new URL(query);
|
|
50
48
|
const chartType = params[PARAM_CHART_CHART_TYPE];
|
|
51
49
|
const label = params[PARAM_CHART_LABEL];
|
|
52
50
|
|
package/patchStyleElements.js
CHANGED
|
@@ -64,7 +64,7 @@ export default function patchStyleElements(doc) {
|
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
66
|
if (selectorText.indexOf(',') > -1) {
|
|
67
|
-
selectorText.split(
|
|
67
|
+
selectorText.split('.').trim().forEach(function (st) {
|
|
68
68
|
buildSelectorTextToCSSText(selectorTextToCSSTexts, st, cssText);
|
|
69
69
|
});
|
|
70
70
|
} else {
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
|
|
3
3
|
import toCSSColor from './ui/toCSSColor.js';
|
|
4
|
-
import {
|
|
5
|
-
toCSSLineSpacing
|
|
6
|
-
} from '@modusoperandi/licit-ui-commands';
|
|
4
|
+
import { toCSSLineSpacing } from '@modusoperandi/licit-ui-commands';
|
|
7
5
|
|
|
8
6
|
const LIST_ITEM_PSEUDO_ELEMENT_BEFORE = /li:+before/;
|
|
9
7
|
const NODE_NAME_SELECTOR = /^[a-zA-Z]+\d*$/;
|
|
@@ -81,9 +79,12 @@ export default function patchStyleElements(doc: Document): void {
|
|
|
81
79
|
}
|
|
82
80
|
});
|
|
83
81
|
if (selectorText.indexOf(',') > -1) {
|
|
84
|
-
selectorText
|
|
85
|
-
|
|
86
|
-
|
|
82
|
+
selectorText
|
|
83
|
+
.split('.')
|
|
84
|
+
.trim()
|
|
85
|
+
.forEach((st) => {
|
|
86
|
+
buildSelectorTextToCSSText(selectorTextToCSSTexts, st, cssText);
|
|
87
|
+
});
|
|
87
88
|
} else {
|
|
88
89
|
buildSelectorTextToCSSText(
|
|
89
90
|
selectorTextToCSSTexts,
|
package/patchTableElements.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { PT_TO_PX_RATIO } from './convertToCSSPTValue.js';
|
|
2
|
-
import convertToCSSPTValue from './convertToCSSPTValue.js';
|
|
1
|
+
import convertToCSSPTValue, { PT_TO_PX_RATIO } from './convertToCSSPTValue.js';
|
|
3
2
|
import toHexColor from './ui/toHexColor.js';
|
|
4
3
|
export default function patchTableElements(doc) {
|
|
5
4
|
Array.from(doc.querySelectorAll('td')).forEach(patchTableCell);
|
|
@@ -25,7 +24,7 @@ function patchTableCell(tdElement) {
|
|
|
25
24
|
spans.some(function (spanElement) {
|
|
26
25
|
var retVal = true;
|
|
27
26
|
var spanStyle = spanElement.style;
|
|
28
|
-
if (!spanStyle
|
|
27
|
+
if (!(spanStyle !== null && spanStyle !== void 0 && spanStyle.backgroundColor)) {
|
|
29
28
|
retVal = false;
|
|
30
29
|
} else {
|
|
31
30
|
var spanBgColor = toHexColor(spanStyle.backgroundColor);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// @flow
|
|
2
|
-
import { PT_TO_PX_RATIO } from './convertToCSSPTValue.js';
|
|
3
|
-
import convertToCSSPTValue from './convertToCSSPTValue.js';
|
|
2
|
+
import convertToCSSPTValue, { PT_TO_PX_RATIO } from './convertToCSSPTValue.js';
|
|
4
3
|
import toHexColor from './ui/toHexColor.js';
|
|
5
4
|
|
|
6
5
|
export default function patchTableElements(doc: Document): void {
|
|
@@ -26,7 +25,7 @@ function patchTableCell(tdElement: HTMLElement): void {
|
|
|
26
25
|
spans.some((spanElement) => {
|
|
27
26
|
let retVal = true;
|
|
28
27
|
const spanStyle = spanElement.style;
|
|
29
|
-
if (!spanStyle
|
|
28
|
+
if (!spanStyle?.backgroundColor) {
|
|
30
29
|
retVal = false;
|
|
31
30
|
} else {
|
|
32
31
|
const spanBgColor = toHexColor(spanStyle.backgroundColor);
|
package/sanitizeURL.js
CHANGED
package/sanitizeURL.js.flow
CHANGED
package/splitListItem.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
function _defineProperty(
|
|
4
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
5
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
6
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
7
|
import uuid from './ui/uuid.js';
|
|
@@ -71,7 +71,7 @@ export default function splitListItem(tr, schema) {
|
|
|
71
71
|
var $from = selection.$from,
|
|
72
72
|
$to = selection.$to,
|
|
73
73
|
node = selection.node;
|
|
74
|
-
if (node && node.isBlock || $from.depth < 2 || !$from.sameParent($to)) {
|
|
74
|
+
if (node !== null && node !== void 0 && node.isBlock || $from.depth < 2 || !$from.sameParent($to)) {
|
|
75
75
|
return tr;
|
|
76
76
|
}
|
|
77
77
|
var grandParent = $from.node(-1);
|
package/splitListItem.js.flow
CHANGED
|
@@ -69,7 +69,7 @@ export default function splitListItem(
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
const { $from, $to, node } = selection;
|
|
72
|
-
if ((node
|
|
72
|
+
if ((node?.isBlock) || $from.depth < 2 || !$from.sameParent($to)) {
|
|
73
73
|
return tr;
|
|
74
74
|
}
|
|
75
75
|
|
package/styles.css
CHANGED
|
@@ -1,11 +1,35 @@
|
|
|
1
|
-
@import './
|
|
1
|
+
@import './ui/czi-vars.css';
|
|
2
|
+
@import './ui/czi-heading.css';
|
|
3
|
+
@import './ui/czi-indent.css';
|
|
4
|
+
@import './ui/czi-list.css';
|
|
5
|
+
@import './ui/czi-table.css';
|
|
6
|
+
@import '~modusoperandi/licit-ui-commands/styles.css';
|
|
7
|
+
@import './ui/czi-bookmark-view.css';
|
|
8
|
+
@import './ui/czi-body-layout-editor.css';
|
|
9
|
+
@import './ui/czi-cursor-placeholder.css';
|
|
10
|
+
@import './ui/czi-custom-menu.css';
|
|
11
|
+
@import './ui/czi-custom-menu-button.css';
|
|
12
|
+
@import './ui/czi-custom-menu-item.css';
|
|
13
|
+
@import './ui/czi-custom-radio-button.css';
|
|
14
|
+
@import './ui/czi-custom-scrollbar.css';
|
|
15
|
+
@import './ui/czi-editor.css';
|
|
16
|
+
@import './ui/czi-editor-frameset.css';
|
|
17
|
+
@import './ui/czi-editor-toolbar.css';
|
|
18
|
+
@import './ui/czi-form.css';
|
|
19
|
+
@import './ui/czi-frag.css';
|
|
20
|
+
@import './ui/czi-icon.css';
|
|
21
|
+
@import './ui/czi-image-resize-box.css';
|
|
22
|
+
@import './ui/czi-image-upload-editor.css';
|
|
23
|
+
@import './ui/czi-image-upload-placeholder.css';
|
|
24
|
+
@import './ui/czi-image-url-editor.css';
|
|
25
|
+
@import './ui/czi-image-view.css';
|
|
26
|
+
@import './ui/czi-inline-editor.css';
|
|
27
|
+
@import './ui/czi-link-tooltip.css';
|
|
2
28
|
@import './ui/czi-loading-indicator.css';
|
|
3
29
|
@import './ui/czi-math-view.css';
|
|
4
|
-
@import '@modusoperandi/licit-ui-commands/ui/czi-pop-up.css';
|
|
5
30
|
@import './ui/czi-selection-placeholder.css';
|
|
6
31
|
@import './ui/czi-table-cell-menu.css';
|
|
7
32
|
@import './ui/czi-table-grid-size-editor.css';
|
|
8
|
-
@import '@modusoperandi/licit-ui-commands/ui/czi-tooltip-surface.css';
|
|
9
33
|
@import './ui/mathquill-editor/czi-mathquill-editor.css';
|
|
10
34
|
@import './ui/mathquill-editor/czi-mathquill-editor-symbols-panel.css';
|
|
11
35
|
@import './client/licit.css';
|
|
@@ -17,3 +41,8 @@
|
|
|
17
41
|
@import './ui/icon-font.css';
|
|
18
42
|
@import '~node-mathquill/build/mathquill.css';
|
|
19
43
|
@import '~katex/dist/katex.min.css';
|
|
44
|
+
|
|
45
|
+
@import '~prosemirror-gapcursor/style/gapcursor.css';
|
|
46
|
+
@import '~prosemirror-view/style/prosemirror.css';
|
|
47
|
+
@import '~react-tooltip/dist/react-tooltip.css';
|
|
48
|
+
@import './ui/listType.css';
|
package/toggleBlockquote.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { Schema } from 'prosemirror-model';
|
|
2
2
|
import { Transform } from 'prosemirror-transform';
|
|
3
3
|
import { BLOCKQUOTE, HEADING, LIST_ITEM, PARAGRAPH } from './NodeNames.js';
|
|
4
|
-
import { compareNumber } from '@modusoperandi/licit-ui-commands';
|
|
5
|
-
import { isInsideListItem } from '@modusoperandi/licit-ui-commands';
|
|
6
|
-
import { isListNode } from '@modusoperandi/licit-ui-commands';
|
|
7
|
-
import { unwrapNodesFromList } from '@modusoperandi/licit-ui-commands';
|
|
4
|
+
import { compareNumber, isInsideListItem, isListNode, unwrapNodesFromList } from '@modusoperandi/licit-ui-commands';
|
|
8
5
|
export default function toggleBlockquote(tr, schema) {
|
|
9
6
|
var nodes = schema.nodes;
|
|
10
7
|
var _tr = tr,
|
|
@@ -34,7 +31,9 @@ export default function toggleBlockquote(tr, schema) {
|
|
|
34
31
|
return !isListNode(node);
|
|
35
32
|
});
|
|
36
33
|
// Update from the bottom to avoid disruptive changes in pos.
|
|
37
|
-
|
|
34
|
+
var sortedPoses = [].concat(poses); // Create a shallow copy of poses
|
|
35
|
+
sortedPoses.sort(compareNumber);
|
|
36
|
+
sortedPoses.sort(compareNumber).reverse().forEach(function (pos) {
|
|
38
37
|
tr = setBlockquoteNode(tr, schema, pos);
|
|
39
38
|
});
|
|
40
39
|
return tr;
|
package/toggleBlockquote.js.flow
CHANGED
|
@@ -14,16 +14,7 @@ import {
|
|
|
14
14
|
PARAGRAPH
|
|
15
15
|
} from './NodeNames.js';
|
|
16
16
|
import {
|
|
17
|
-
compareNumber
|
|
18
|
-
} from '@modusoperandi/licit-ui-commands';
|
|
19
|
-
import {
|
|
20
|
-
isInsideListItem
|
|
21
|
-
} from '@modusoperandi/licit-ui-commands';
|
|
22
|
-
import {
|
|
23
|
-
isListNode
|
|
24
|
-
} from '@modusoperandi/licit-ui-commands';
|
|
25
|
-
import {
|
|
26
|
-
unwrapNodesFromList
|
|
17
|
+
compareNumber, isInsideListItem, isListNode, unwrapNodesFromList
|
|
27
18
|
} from '@modusoperandi/licit-ui-commands';
|
|
28
19
|
|
|
29
20
|
export default function toggleBlockquote(
|
|
@@ -58,8 +49,10 @@ export default function toggleBlockquote(
|
|
|
58
49
|
return !isListNode(node);
|
|
59
50
|
});
|
|
60
51
|
// Update from the bottom to avoid disruptive changes in pos.
|
|
61
|
-
poses
|
|
62
|
-
|
|
52
|
+
const sortedPoses = [...poses]; // Create a shallow copy of poses
|
|
53
|
+
sortedPoses.sort(compareNumber);
|
|
54
|
+
|
|
55
|
+
sortedPoses.sort(compareNumber)
|
|
63
56
|
.reverse()
|
|
64
57
|
.forEach((pos) => {
|
|
65
58
|
tr = setBlockquoteNode(tr, schema, pos);
|
package/toggleCodeBlock.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
+
function _readOnlyError(r) { throw new TypeError('"' + r + '" is read-only'); }
|
|
1
2
|
import { Schema } from 'prosemirror-model';
|
|
2
3
|
import { TextSelection } from 'prosemirror-state';
|
|
3
4
|
import { Transform } from 'prosemirror-transform';
|
|
4
5
|
import { MARK_LINK } from './MarkNames';
|
|
5
6
|
import { BLOCKQUOTE, CODE_BLOCK, HEADING, PARAGRAPH } from './NodeNames';
|
|
6
|
-
import { clearMarks } from '@modusoperandi/licit-ui-commands';
|
|
7
|
-
import { compareNumber } from '@modusoperandi/licit-ui-commands';
|
|
8
|
-
import { isListNode } from '@modusoperandi/licit-ui-commands';
|
|
7
|
+
import { clearMarks, compareNumber, isListNode } from '@modusoperandi/licit-ui-commands';
|
|
9
8
|
export default function toggleCodeBlock(tr, schema) {
|
|
10
9
|
var nodes = schema.nodes;
|
|
11
10
|
var _tr = tr,
|
|
@@ -37,10 +36,11 @@ export default function toggleCodeBlock(tr, schema) {
|
|
|
37
36
|
}
|
|
38
37
|
return isBlock;
|
|
39
38
|
});
|
|
40
|
-
|
|
39
|
+
var sortedPoses = [].concat(poses); // Create a shallow copy of poses
|
|
41
40
|
// Update from the bottom to avoid disruptive changes in pos.
|
|
42
|
-
allowed
|
|
43
|
-
|
|
41
|
+
allowed ? poses.toSorted(compareNumber) : poses, _readOnlyError("sortedPoses");
|
|
42
|
+
allowed && sortedPoses.sort(compareNumber).reverse().forEach(function (pos) {
|
|
43
|
+
tr = setCodeBlockNodeEnabled(tr, schema, pos, !startWithCodeBlock);
|
|
44
44
|
});
|
|
45
45
|
return tr;
|
|
46
46
|
}
|
package/toggleCodeBlock.js.flow
CHANGED
|
@@ -6,9 +6,11 @@ import { Transform } from 'prosemirror-transform';
|
|
|
6
6
|
|
|
7
7
|
import { MARK_LINK } from './MarkNames';
|
|
8
8
|
import { BLOCKQUOTE, CODE_BLOCK, HEADING, PARAGRAPH } from './NodeNames';
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
import {
|
|
10
|
+
clearMarks,
|
|
11
|
+
compareNumber,
|
|
12
|
+
isListNode,
|
|
13
|
+
} from '@modusoperandi/licit-ui-commands';
|
|
12
14
|
|
|
13
15
|
export default function toggleCodeBlock(
|
|
14
16
|
tr: Transform,
|
|
@@ -47,18 +49,16 @@ export default function toggleCodeBlock(
|
|
|
47
49
|
return isBlock;
|
|
48
50
|
});
|
|
49
51
|
|
|
52
|
+
const sortedPoses = [...poses]; // Create a shallow copy of poses
|
|
50
53
|
// Update from the bottom to avoid disruptive changes in pos.
|
|
54
|
+
sortedPoses = allowed ? poses.toSorted(compareNumber) : poses;
|
|
55
|
+
|
|
51
56
|
allowed &&
|
|
52
|
-
|
|
57
|
+
sortedPoses
|
|
53
58
|
.sort(compareNumber)
|
|
54
59
|
.reverse()
|
|
55
60
|
.forEach((pos) => {
|
|
56
|
-
tr = setCodeBlockNodeEnabled(
|
|
57
|
-
tr,
|
|
58
|
-
schema,
|
|
59
|
-
pos,
|
|
60
|
-
startWithCodeBlock ? false : true
|
|
61
|
-
);
|
|
61
|
+
tr = setCodeBlockNodeEnabled(tr, schema, pos, !startWithCodeBlock);
|
|
62
62
|
});
|
|
63
63
|
return tr;
|
|
64
64
|
}
|