@modusoperandi/licit 1.0.9 → 1.0.11
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/DocNodeSpec.js +0 -2
- package/DocNodeSpec.js.flow +0 -2
- package/EditorCommands.js +0 -2
- package/EditorCommands.js.flow +0 -2
- package/EditorNodes.js +1 -3
- package/EditorNodes.js.flow +0 -3
- package/bom.xml +791 -728
- package/client/Licit.js +8 -0
- package/client/Licit.js.flow +9 -0
- package/index.d.ts +2 -0
- package/package.json +4 -6
- package/styles.css +0 -5
- package/ui/DocLayoutEditor.js +0 -10
- package/ui/DocLayoutEditor.js.flow +0 -12
- package/ui/Editor.js +2 -3
- package/ui/Editor.js.flow +1 -3
- package/ui/EditorToolbarConfig.js +7 -7
- package/ui/EditorToolbarConfig.js.flow +4 -6
- package/ui/czi-editor.css +0 -12
- package/MathEditCommand.js +0 -114
- package/MathEditCommand.js.flow +0 -119
- package/MathNodeSpec.js +0 -49
- package/MathNodeSpec.js.flow +0 -46
- package/ui/MathEditor.js +0 -86
- package/ui/MathEditor.js.flow +0 -70
- package/ui/MathInlineEditor.js +0 -121
- package/ui/MathInlineEditor.js.flow +0 -100
- package/ui/MathNodeView.js +0 -215
- package/ui/MathNodeView.js.flow +0 -175
- package/ui/mathquill-editor/MathQuillEditor.js +0 -183
- package/ui/mathquill-editor/MathQuillEditor.js.flow +0 -157
- package/ui/mathquill-editor/MathQuillEditorSymbols.js +0 -416
- package/ui/mathquill-editor/MathQuillEditorSymbols.js.flow +0 -483
- package/ui/mathquill-editor/MathQuillEditorSymbolsPanel.js +0 -67
- package/ui/mathquill-editor/MathQuillEditorSymbolsPanel.js.flow +0 -49
- package/ui/mathquill-editor/czi-mathquill-editor-symbols-panel.css +0 -39
- package/ui/mathquill-editor/czi-mathquill-editor.css +0 -50
- package/ui/mathquill-editor/mathquill-import-kludge.js +0 -13
- package/ui/mathquill-editor/mathquill-import-kludge.js.flow +0 -15
- package/ui/renderLaTeXAsHTML.js +0 -51
- package/ui/renderLaTeXAsHTML.js.flow +0 -42
package/client/Licit.js
CHANGED
|
@@ -34,6 +34,7 @@ import DefaultEditorPlugins from '../buildEditorPlugins.js';
|
|
|
34
34
|
import EditorMarks from '../EditorMarks.js';
|
|
35
35
|
import EditorNodes from '../EditorNodes.js';
|
|
36
36
|
import convertFromHTML from '../convertFromHTML.js';
|
|
37
|
+
import DocLayoutCommand from '../DocLayoutCommand.js';
|
|
37
38
|
export var DataType = Object.freeze({
|
|
38
39
|
JSON: Symbol('json'),
|
|
39
40
|
HTML: Symbol('html')
|
|
@@ -211,6 +212,13 @@ var Licit = /*#__PURE__*/function (_React$Component) {
|
|
|
211
212
|
view.dispatch(tr.setSelection(TextSelection.atEnd(view.state.doc)).scrollIntoView());
|
|
212
213
|
view.focus();
|
|
213
214
|
});
|
|
215
|
+
/**
|
|
216
|
+
* Method to open page layout
|
|
217
|
+
*/
|
|
218
|
+
_defineProperty(_this, "pageLayout", function (state) {
|
|
219
|
+
var DOC_LAYOUT = new DocLayoutCommand();
|
|
220
|
+
DOC_LAYOUT.waitForUserInput(state);
|
|
221
|
+
});
|
|
214
222
|
_this.initialize(_props);
|
|
215
223
|
return _this;
|
|
216
224
|
}
|
package/client/Licit.js.flow
CHANGED
|
@@ -23,6 +23,7 @@ import DefaultEditorPlugins from '../buildEditorPlugins.js';
|
|
|
23
23
|
import EditorMarks from '../EditorMarks.js';
|
|
24
24
|
import EditorNodes from '../EditorNodes.js';
|
|
25
25
|
import convertFromHTML from '../convertFromHTML.js';
|
|
26
|
+
import DocLayoutCommand from '../DocLayoutCommand.js';
|
|
26
27
|
|
|
27
28
|
export const DataType = Object.freeze({
|
|
28
29
|
JSON: Symbol('json'),
|
|
@@ -605,6 +606,14 @@ class Licit extends React.Component<any, any> {
|
|
|
605
606
|
);
|
|
606
607
|
view.focus();
|
|
607
608
|
};
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
* Method to open page layout
|
|
612
|
+
*/
|
|
613
|
+
pageLayout = (state: EditorState): void => {
|
|
614
|
+
const DOC_LAYOUT = new DocLayoutCommand();
|
|
615
|
+
DOC_LAYOUT.waitForUserInput(state);
|
|
616
|
+
};
|
|
608
617
|
}
|
|
609
618
|
|
|
610
619
|
export default Licit;
|
package/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modusoperandi/licit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"subversion": "1",
|
|
6
6
|
"description": "Rich text editor built with React and ProseMirror",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"test:coverage": "jest --coverage",
|
|
18
18
|
"build:bom": "cyclonedx-npm --ignore-npm-errors --short-PURLs --output-format XML --output-file dist/bom.xml",
|
|
19
19
|
"build:clean": "rm -rf dist/ && rm -f modusoperandi-licit-*.*.*.tgz",
|
|
20
|
-
"build:css": "cp src/ui/*.css dist/ui && cp src/
|
|
20
|
+
"build:css": "cp src/ui/*.css dist/ui && cp src/client/*.css dist/client && cp src/*.css dist",
|
|
21
21
|
"build:fonts": "mkdirp ./dist/fonts && cp -r src/fonts/* dist/fonts",
|
|
22
22
|
"build:babel": "babel src --out-dir dist",
|
|
23
23
|
"build:flow": "flow-copy-source -v -i '**/__tests__/**' src dist",
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
"write-file-webpack-plugin": "^4.5.1"
|
|
111
111
|
},
|
|
112
112
|
"dependencies": {
|
|
113
|
-
"@modusoperandi/color-picker": "^1.0.
|
|
113
|
+
"@modusoperandi/color-picker": "^1.0.4",
|
|
114
114
|
"body-parser": "^1.19.0",
|
|
115
115
|
"browserkeymap": "^2.0.2",
|
|
116
116
|
"flatted": "^3.1.0",
|
|
@@ -118,8 +118,6 @@
|
|
|
118
118
|
"formidable": "^3.5.1",
|
|
119
119
|
"invariant": "^2.2.4",
|
|
120
120
|
"jquery": "^3.5.1",
|
|
121
|
-
"katex": "^0.16.9",
|
|
122
|
-
"node-mathquill": "^0.10.2",
|
|
123
121
|
"react-tooltip": "^5.28.0",
|
|
124
122
|
"resize-observer-polyfill": "^1.5.1",
|
|
125
123
|
"smooth-scroll-into-view-if-needed": "^2.0.2",
|
|
@@ -128,7 +126,7 @@
|
|
|
128
126
|
"webfontloader": "^1.6.28"
|
|
129
127
|
},
|
|
130
128
|
"peerDependencies": {
|
|
131
|
-
"@modusoperandi/licit-ui-commands": "^1.0.
|
|
129
|
+
"@modusoperandi/licit-ui-commands": "^1.0.8",
|
|
132
130
|
"jquery": "^3.5.1",
|
|
133
131
|
"prosemirror-collab": "^1.2.2",
|
|
134
132
|
"prosemirror-tables": "^1.2.5"
|
package/styles.css
CHANGED
|
@@ -30,8 +30,6 @@
|
|
|
30
30
|
@import './ui/czi-selection-placeholder.css';
|
|
31
31
|
@import './ui/czi-table-cell-menu.css';
|
|
32
32
|
@import './ui/czi-table-grid-size-editor.css';
|
|
33
|
-
@import './ui/mathquill-editor/czi-mathquill-editor.css';
|
|
34
|
-
@import './ui/mathquill-editor/czi-mathquill-editor-symbols-panel.css';
|
|
35
33
|
@import './client/licit.css';
|
|
36
34
|
|
|
37
35
|
/* [FS] IRAD-1061 2020-09-19 */
|
|
@@ -39,9 +37,6 @@
|
|
|
39
37
|
/* Now loaded locally, so that it work in closed network as well. */
|
|
40
38
|
@import './ui/fonts.css';
|
|
41
39
|
@import './ui/icon-font.css';
|
|
42
|
-
@import '~node-mathquill/build/mathquill.css';
|
|
43
|
-
@import '~katex/dist/katex.min.css';
|
|
44
|
-
|
|
45
40
|
@import '~prosemirror-gapcursor/style/gapcursor.css';
|
|
46
41
|
@import '~prosemirror-view/style/prosemirror.css';
|
|
47
42
|
@import '~react-tooltip/dist/react-tooltip.css';
|
package/ui/DocLayoutEditor.js
CHANGED
|
@@ -98,16 +98,6 @@ var DocLayoutEditor = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
98
98
|
label: "A4 - Landscape",
|
|
99
99
|
onSelect: this._onSelect,
|
|
100
100
|
value: LAYOUT.A4_LANDSCAPE
|
|
101
|
-
}), /*#__PURE__*/React.createElement(CustomRadioButton, {
|
|
102
|
-
checked: selectedValue === LAYOUT.DESKTOP_SCREEN_4_3,
|
|
103
|
-
label: "4:3 Desktop Screen",
|
|
104
|
-
onSelect: this._onSelect,
|
|
105
|
-
value: LAYOUT.DESKTOP_SCREEN_4_3
|
|
106
|
-
}), /*#__PURE__*/React.createElement(CustomRadioButton, {
|
|
107
|
-
checked: selectedValue === LAYOUT.DESKTOP_SCREEN_16_9,
|
|
108
|
-
label: "16:9 Desktop Screen",
|
|
109
|
-
onSelect: this._onSelect,
|
|
110
|
-
value: LAYOUT.DESKTOP_SCREEN_16_9
|
|
111
101
|
}), customOption), /*#__PURE__*/React.createElement("hr", null), /*#__PURE__*/React.createElement("div", {
|
|
112
102
|
className: "czi-form-buttons"
|
|
113
103
|
}, /*#__PURE__*/React.createElement(CustomButton, {
|
|
@@ -97,18 +97,6 @@ class DocLayoutEditor extends React.PureComponent<any, any> {
|
|
|
97
97
|
onSelect={this._onSelect}
|
|
98
98
|
value={LAYOUT.A4_LANDSCAPE}
|
|
99
99
|
/>
|
|
100
|
-
<CustomRadioButton
|
|
101
|
-
checked={selectedValue === LAYOUT.DESKTOP_SCREEN_4_3}
|
|
102
|
-
label="4:3 Desktop Screen"
|
|
103
|
-
onSelect={this._onSelect}
|
|
104
|
-
value={LAYOUT.DESKTOP_SCREEN_4_3}
|
|
105
|
-
/>
|
|
106
|
-
<CustomRadioButton
|
|
107
|
-
checked={selectedValue === LAYOUT.DESKTOP_SCREEN_16_9}
|
|
108
|
-
label="16:9 Desktop Screen"
|
|
109
|
-
onSelect={this._onSelect}
|
|
110
|
-
value={LAYOUT.DESKTOP_SCREEN_16_9}
|
|
111
|
-
/>
|
|
112
100
|
{customOption}
|
|
113
101
|
</fieldset>
|
|
114
102
|
<hr />
|
package/ui/Editor.js
CHANGED
|
@@ -22,7 +22,7 @@ import { EditorView } from 'prosemirror-view';
|
|
|
22
22
|
import * as React from 'react';
|
|
23
23
|
import webfontloader from 'webfontloader';
|
|
24
24
|
import { exportJSON, registerEditorView, registeryKeys, releaseEditorView } from '../CZIProseMirror.js';
|
|
25
|
-
import { BOOKMARK, LIST_ITEM
|
|
25
|
+
import { BOOKMARK, LIST_ITEM } from '../NodeNames.js';
|
|
26
26
|
import WebFontLoader from '../WebFontLoader.js';
|
|
27
27
|
import { preLoadFonts } from '../FontTypeMarkSpec.js';
|
|
28
28
|
import createEmptyEditorState from '../createEmptyEditorState.js';
|
|
@@ -31,7 +31,6 @@ import BookmarkNodeView from './BookmarkNodeView.js';
|
|
|
31
31
|
import CustomEditorView from './CustomEditorView.js';
|
|
32
32
|
import CustomNodeView from './CustomNodeView.js';
|
|
33
33
|
import ListItemNodeView from './ListItemNodeView.js';
|
|
34
|
-
import MathNodeView from './MathNodeView.js';
|
|
35
34
|
import handleEditorDrop from './handleEditorDrop.js';
|
|
36
35
|
import handleEditorKeyDown from './handleEditorKeyDown.js';
|
|
37
36
|
import handleEditorPaste from './handleEditorPaste.js';
|
|
@@ -66,7 +65,7 @@ window.CZIProseMirror = {
|
|
|
66
65
|
var AUTO_FOCUS_DELAY = 350;
|
|
67
66
|
|
|
68
67
|
// Default custom node views.
|
|
69
|
-
export var DEFAULT_NODE_VIEWS = Object.freeze(_defineProperty(_defineProperty(
|
|
68
|
+
export var DEFAULT_NODE_VIEWS = Object.freeze(_defineProperty(_defineProperty({}, BOOKMARK, BookmarkNodeView), LIST_ITEM, ListItemNodeView));
|
|
70
69
|
var EDITOR_EMPTY_STATE = Object.freeze(createEmptyEditorState());
|
|
71
70
|
|
|
72
71
|
// Monkey patch the `scrollIntoView` mathod of 'Transaction'.
|
package/ui/Editor.js.flow
CHANGED
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
registeryKeys,
|
|
15
15
|
releaseEditorView,
|
|
16
16
|
} from '../CZIProseMirror.js';
|
|
17
|
-
import { BOOKMARK, LIST_ITEM
|
|
17
|
+
import { BOOKMARK, LIST_ITEM } from '../NodeNames.js';
|
|
18
18
|
import WebFontLoader from '../WebFontLoader.js';
|
|
19
19
|
import { preLoadFonts } from '../FontTypeMarkSpec.js';
|
|
20
20
|
import createEmptyEditorState from '../createEmptyEditorState.js';
|
|
@@ -23,7 +23,6 @@ import BookmarkNodeView from './BookmarkNodeView.js';
|
|
|
23
23
|
import CustomEditorView from './CustomEditorView.js';
|
|
24
24
|
import CustomNodeView from './CustomNodeView.js';
|
|
25
25
|
import ListItemNodeView from './ListItemNodeView.js';
|
|
26
|
-
import MathNodeView from './MathNodeView.js';
|
|
27
26
|
import handleEditorDrop from './handleEditorDrop.js';
|
|
28
27
|
import handleEditorKeyDown from './handleEditorKeyDown.js';
|
|
29
28
|
import handleEditorPaste from './handleEditorPaste.js';
|
|
@@ -57,7 +56,6 @@ const AUTO_FOCUS_DELAY = 350;
|
|
|
57
56
|
|
|
58
57
|
// Default custom node views.
|
|
59
58
|
export const DEFAULT_NODE_VIEWS = Object.freeze({
|
|
60
|
-
[MATH]: MathNodeView,
|
|
61
59
|
[BOOKMARK]: BookmarkNodeView,
|
|
62
60
|
[LIST_ITEM]: ListItemNodeView,
|
|
63
61
|
});
|
|
@@ -31,7 +31,6 @@ export function parseLabel(input) {
|
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
var CLEAR_FORMAT = EditorCommands.CLEAR_FORMAT,
|
|
34
|
-
DOC_LAYOUT = EditorCommands.DOC_LAYOUT,
|
|
35
34
|
EM = EditorCommands.EM,
|
|
36
35
|
HISTORY_REDO = EditorCommands.HISTORY_REDO,
|
|
37
36
|
HISTORY_UNDO = EditorCommands.HISTORY_UNDO,
|
|
@@ -39,7 +38,6 @@ var CLEAR_FORMAT = EditorCommands.CLEAR_FORMAT,
|
|
|
39
38
|
INDENT_LESS = EditorCommands.INDENT_LESS,
|
|
40
39
|
INDENT_MORE = EditorCommands.INDENT_MORE,
|
|
41
40
|
LINK_SET_URL = EditorCommands.LINK_SET_URL,
|
|
42
|
-
MATH_EDIT = EditorCommands.MATH_EDIT,
|
|
43
41
|
STRIKE = EditorCommands.STRIKE,
|
|
44
42
|
STRONG = EditorCommands.STRONG,
|
|
45
43
|
SUPER = EditorCommands.SUPER,
|
|
@@ -128,14 +126,16 @@ export var COMMAND_GROUPS = [{
|
|
|
128
126
|
}, {
|
|
129
127
|
'[link] Apply link': LINK_SET_URL,
|
|
130
128
|
'[grid_on] Table...': TABLE_COMMANDS_GROUP,
|
|
131
|
-
'[hr] Horizontal line': HR
|
|
132
|
-
'[functions] Math': MATH_EDIT
|
|
129
|
+
'[hr] Horizontal line': HR
|
|
133
130
|
|
|
134
131
|
// [FS][07-MAY-2020][IRAD-956]
|
|
135
132
|
// '[format_quote] Block quote': BLOCKQUOTE_TOGGLE,
|
|
136
|
-
},
|
|
137
|
-
|
|
138
|
-
|
|
133
|
+
},
|
|
134
|
+
// Removed page layout icon from Editor
|
|
135
|
+
// {
|
|
136
|
+
// '[settings_overscan] Page layout': DOC_LAYOUT,
|
|
137
|
+
// },
|
|
138
|
+
{
|
|
139
139
|
'[undo] Undo': HISTORY_UNDO,
|
|
140
140
|
'[redo] Redo': HISTORY_REDO
|
|
141
141
|
}];
|
|
@@ -35,7 +35,6 @@ const {
|
|
|
35
35
|
// [FS][07-MAY-2020][IRAD-956]
|
|
36
36
|
// BLOCKQUOTE_TOGGLE,
|
|
37
37
|
CLEAR_FORMAT,
|
|
38
|
-
DOC_LAYOUT,
|
|
39
38
|
EM,
|
|
40
39
|
HISTORY_REDO,
|
|
41
40
|
HISTORY_UNDO,
|
|
@@ -43,7 +42,6 @@ const {
|
|
|
43
42
|
INDENT_LESS,
|
|
44
43
|
INDENT_MORE,
|
|
45
44
|
LINK_SET_URL,
|
|
46
|
-
MATH_EDIT,
|
|
47
45
|
STRIKE,
|
|
48
46
|
STRONG,
|
|
49
47
|
SUPER,
|
|
@@ -149,14 +147,14 @@ export const COMMAND_GROUPS = [
|
|
|
149
147
|
'[link] Apply link': LINK_SET_URL,
|
|
150
148
|
'[grid_on] Table...': TABLE_COMMANDS_GROUP,
|
|
151
149
|
'[hr] Horizontal line': HR,
|
|
152
|
-
'[functions] Math': MATH_EDIT,
|
|
153
150
|
|
|
154
151
|
// [FS][07-MAY-2020][IRAD-956]
|
|
155
152
|
// '[format_quote] Block quote': BLOCKQUOTE_TOGGLE,
|
|
156
153
|
},
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
154
|
+
// Removed page layout icon from Editor
|
|
155
|
+
// {
|
|
156
|
+
// '[settings_overscan] Page layout': DOC_LAYOUT,
|
|
157
|
+
// },
|
|
160
158
|
{
|
|
161
159
|
'[undo] Undo': HISTORY_UNDO,
|
|
162
160
|
'[redo] Redo': HISTORY_REDO,
|
package/ui/czi-editor.css
CHANGED
|
@@ -102,18 +102,6 @@
|
|
|
102
102
|
width: var(--czi-doc-width-a4-landscape);
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
.ProseMirror[data-layout='desktop_screen_4_3'] {
|
|
106
|
-
min-height: 90vh;
|
|
107
|
-
padding: var(--czi-doc-padding-default);
|
|
108
|
-
width: var(--czi-doc-width-us-desktop-screen-4-3);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
.ProseMirror[data-layout='desktop_screen_16_9'] {
|
|
112
|
-
min-height: 80vh;
|
|
113
|
-
padding: var(--czi-doc-padding-default);
|
|
114
|
-
width: var(--czi-doc-width-us-desktop-screen-16-9);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
105
|
.prosemirror-editor-wrapper.embedded .ProseMirror {
|
|
118
106
|
background: unset;
|
|
119
107
|
border-radius: unset;
|
package/MathEditCommand.js
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
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
|
-
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
3
|
-
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
4
|
-
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
5
|
-
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
6
|
-
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
7
|
-
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
8
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
9
|
-
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
10
|
-
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
11
|
-
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
12
|
-
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; }
|
|
13
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
14
|
-
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); }
|
|
15
|
-
import { Fragment, Schema } from 'prosemirror-model';
|
|
16
|
-
import { EditorState, TextSelection } from 'prosemirror-state';
|
|
17
|
-
import { Transform } from 'prosemirror-transform';
|
|
18
|
-
import { EditorView } from 'prosemirror-view';
|
|
19
|
-
// eslint-disable-next-line no-unused-vars
|
|
20
|
-
import * as React from 'react';
|
|
21
|
-
import { hideCursorPlaceholder, showCursorPlaceholder } from './CursorPlaceholderPlugin.js';
|
|
22
|
-
import { MATH } from './NodeNames.js';
|
|
23
|
-
import MathEditor from './ui/MathEditor.js';
|
|
24
|
-
import { UICommand } from '@modusoperandi/licit-doc-attrs-step';
|
|
25
|
-
import { createPopUp } from '@modusoperandi/licit-ui-commands';
|
|
26
|
-
function insertMath(tr, schema, latex) {
|
|
27
|
-
var _tr = tr,
|
|
28
|
-
selection = _tr.selection;
|
|
29
|
-
if (!selection) {
|
|
30
|
-
return tr;
|
|
31
|
-
}
|
|
32
|
-
var from = selection.from,
|
|
33
|
-
to = selection.to;
|
|
34
|
-
if (from !== to) {
|
|
35
|
-
return tr;
|
|
36
|
-
}
|
|
37
|
-
var image = schema.nodes[MATH];
|
|
38
|
-
if (!image) {
|
|
39
|
-
return tr;
|
|
40
|
-
}
|
|
41
|
-
var attrs = {
|
|
42
|
-
latex: latex
|
|
43
|
-
};
|
|
44
|
-
var node = image.create(attrs, null, null);
|
|
45
|
-
var frag = Fragment.from(node);
|
|
46
|
-
tr = tr.insert(from, frag);
|
|
47
|
-
return tr;
|
|
48
|
-
}
|
|
49
|
-
var MathEditCommand = /*#__PURE__*/function (_UICommand) {
|
|
50
|
-
function MathEditCommand() {
|
|
51
|
-
var _this;
|
|
52
|
-
_classCallCheck(this, MathEditCommand);
|
|
53
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
54
|
-
args[_key] = arguments[_key];
|
|
55
|
-
}
|
|
56
|
-
_this = _callSuper(this, MathEditCommand, [].concat(args));
|
|
57
|
-
_defineProperty(_this, "_popUp", null);
|
|
58
|
-
_defineProperty(_this, "isEnabled", function (state, view) {
|
|
59
|
-
var tr = state;
|
|
60
|
-
var selection = tr.selection;
|
|
61
|
-
if (selection instanceof TextSelection) {
|
|
62
|
-
return selection.from === selection.to;
|
|
63
|
-
}
|
|
64
|
-
return false;
|
|
65
|
-
});
|
|
66
|
-
_defineProperty(_this, "waitForUserInput", function (state, dispatch, view, event) {
|
|
67
|
-
if (_this._popUp) {
|
|
68
|
-
return Promise.resolve(undefined);
|
|
69
|
-
}
|
|
70
|
-
if (dispatch) {
|
|
71
|
-
dispatch(showCursorPlaceholder(state));
|
|
72
|
-
}
|
|
73
|
-
return new Promise(function (resolve) {
|
|
74
|
-
var props = {
|
|
75
|
-
runtime: view ? view.runtime : null,
|
|
76
|
-
initialValue: null
|
|
77
|
-
};
|
|
78
|
-
_this._popUp = createPopUp(MathEditor, props, {
|
|
79
|
-
modal: true,
|
|
80
|
-
onClose: function onClose(val) {
|
|
81
|
-
if (_this._popUp) {
|
|
82
|
-
_this._popUp = null;
|
|
83
|
-
resolve(val);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
_defineProperty(_this, "executeWithUserInput", function (state, dispatch, view, latex) {
|
|
90
|
-
if (dispatch) {
|
|
91
|
-
var selection = state.selection,
|
|
92
|
-
schema = state.schema;
|
|
93
|
-
var _tr2 = state.tr;
|
|
94
|
-
_tr2 = view ? hideCursorPlaceholder(view.state) : _tr2;
|
|
95
|
-
_tr2 = _tr2.setSelection(selection);
|
|
96
|
-
if (latex) {
|
|
97
|
-
_tr2 = insertMath(_tr2, schema, latex);
|
|
98
|
-
}
|
|
99
|
-
dispatch(_tr2);
|
|
100
|
-
view && view.focus();
|
|
101
|
-
}
|
|
102
|
-
return false;
|
|
103
|
-
});
|
|
104
|
-
return _this;
|
|
105
|
-
}
|
|
106
|
-
_inherits(MathEditCommand, _UICommand);
|
|
107
|
-
return _createClass(MathEditCommand, [{
|
|
108
|
-
key: "cancel",
|
|
109
|
-
value: function cancel() {
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
}]);
|
|
113
|
-
}(UICommand);
|
|
114
|
-
export default MathEditCommand;
|
package/MathEditCommand.js.flow
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
import { Fragment, Schema } from 'prosemirror-model';
|
|
4
|
-
import { EditorState, TextSelection } from 'prosemirror-state';
|
|
5
|
-
import { Transform } from 'prosemirror-transform';
|
|
6
|
-
import { EditorView } from 'prosemirror-view';
|
|
7
|
-
// eslint-disable-next-line no-unused-vars
|
|
8
|
-
import * as React from 'react';
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
hideCursorPlaceholder,
|
|
12
|
-
showCursorPlaceholder,
|
|
13
|
-
} from './CursorPlaceholderPlugin.js';
|
|
14
|
-
import {
|
|
15
|
-
MATH
|
|
16
|
-
} from './NodeNames.js';
|
|
17
|
-
import MathEditor from './ui/MathEditor.js';
|
|
18
|
-
import {
|
|
19
|
-
UICommand
|
|
20
|
-
} from '@modusoperandi/licit-doc-attrs-step';
|
|
21
|
-
import {
|
|
22
|
-
createPopUp
|
|
23
|
-
} from '@modusoperandi/licit-ui-commands';
|
|
24
|
-
|
|
25
|
-
function insertMath(tr: Transform, schema: Schema, latex: ?string): Transform {
|
|
26
|
-
const { selection } = tr;
|
|
27
|
-
if (!selection) {
|
|
28
|
-
return tr;
|
|
29
|
-
}
|
|
30
|
-
const { from, to } = selection;
|
|
31
|
-
if (from !== to) {
|
|
32
|
-
return tr;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const image = schema.nodes[MATH];
|
|
36
|
-
if (!image) {
|
|
37
|
-
return tr;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const attrs = {
|
|
41
|
-
latex,
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const node = image.create(attrs, null, null);
|
|
45
|
-
const frag = Fragment.from(node);
|
|
46
|
-
tr = tr.insert(from, frag);
|
|
47
|
-
return tr;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
class MathEditCommand extends UICommand {
|
|
51
|
-
_popUp = null;
|
|
52
|
-
|
|
53
|
-
isEnabled = (state: EditorState, view: ?EditorView): boolean => {
|
|
54
|
-
const tr = state;
|
|
55
|
-
const { selection } = tr;
|
|
56
|
-
if (selection instanceof TextSelection) {
|
|
57
|
-
return selection.from === selection.to;
|
|
58
|
-
}
|
|
59
|
-
return false;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
waitForUserInput = (
|
|
63
|
-
state: EditorState,
|
|
64
|
-
dispatch: ?(tr: Transform) => void,
|
|
65
|
-
view: ?EditorView,
|
|
66
|
-
event: ?SyntheticEvent<>
|
|
67
|
-
): Promise<any> => {
|
|
68
|
-
if (this._popUp) {
|
|
69
|
-
return Promise.resolve(undefined);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (dispatch) {
|
|
73
|
-
dispatch(showCursorPlaceholder(state));
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return new Promise((resolve) => {
|
|
77
|
-
const props = {
|
|
78
|
-
runtime: view ? view.runtime : null,
|
|
79
|
-
initialValue: null,
|
|
80
|
-
};
|
|
81
|
-
this._popUp = createPopUp(MathEditor, props, {
|
|
82
|
-
modal: true,
|
|
83
|
-
onClose: (val) => {
|
|
84
|
-
if (this._popUp) {
|
|
85
|
-
this._popUp = null;
|
|
86
|
-
resolve(val);
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
executeWithUserInput = (
|
|
94
|
-
state: EditorState,
|
|
95
|
-
dispatch: ?(tr: Transform) => void,
|
|
96
|
-
view: ?EditorView,
|
|
97
|
-
latex: ?string
|
|
98
|
-
): boolean => {
|
|
99
|
-
if (dispatch) {
|
|
100
|
-
const { selection, schema } = state;
|
|
101
|
-
let { tr } = state;
|
|
102
|
-
tr = view ? hideCursorPlaceholder(view.state) : tr;
|
|
103
|
-
tr = tr.setSelection(selection);
|
|
104
|
-
if (latex) {
|
|
105
|
-
tr = insertMath(tr, schema, latex);
|
|
106
|
-
}
|
|
107
|
-
dispatch(tr);
|
|
108
|
-
view && view.focus();
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return false;
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
cancel(): void {
|
|
115
|
-
return null;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export default MathEditCommand;
|
package/MathNodeSpec.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
function getAttrs(dom) {
|
|
2
|
-
var align = dom.getAttribute('data-align') || dom.getAttribute('align');
|
|
3
|
-
if (align) {
|
|
4
|
-
align = /(left|right|center)/.test(align) ? align : null;
|
|
5
|
-
}
|
|
6
|
-
return {
|
|
7
|
-
align: align,
|
|
8
|
-
latex: dom.getAttribute('data-latex') || null
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
var MathNodeSpec = {
|
|
12
|
-
inline: true,
|
|
13
|
-
attrs: {
|
|
14
|
-
align: {
|
|
15
|
-
"default": null
|
|
16
|
-
},
|
|
17
|
-
latex: {
|
|
18
|
-
"default": ''
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
group: 'inline',
|
|
22
|
-
draggable: true,
|
|
23
|
-
parseDOM: [{
|
|
24
|
-
tag: 'math[data-latex]',
|
|
25
|
-
getAttrs: getAttrs
|
|
26
|
-
}, {
|
|
27
|
-
tag: 'span[data-latex]',
|
|
28
|
-
getAttrs: getAttrs
|
|
29
|
-
}],
|
|
30
|
-
toDOM: function toDOM(node) {
|
|
31
|
-
// Normally, the DOM structure of the math node is rendered by
|
|
32
|
-
// `MathNodeView`. This method is only called when user selects a
|
|
33
|
-
// math node and copies it, which triggers the "serialize to HTML" flow that
|
|
34
|
-
// calles this method.
|
|
35
|
-
var _node$attrs = node.attrs,
|
|
36
|
-
align = _node$attrs.align,
|
|
37
|
-
latex = _node$attrs.latex;
|
|
38
|
-
var domAttrs = {};
|
|
39
|
-
if (align) {
|
|
40
|
-
domAttrs.align = align;
|
|
41
|
-
}
|
|
42
|
-
if (latex) {
|
|
43
|
-
domAttrs['data-latex'] = latex;
|
|
44
|
-
}
|
|
45
|
-
return ['span', domAttrs];
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
export default MathNodeSpec;
|
|
49
|
-
import { bpfrpt_proptype_NodeSpec } from "./Types.js";
|
package/MathNodeSpec.js.flow
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
import type { NodeSpec } from './Types.js';
|
|
4
|
-
|
|
5
|
-
function getAttrs(dom: HTMLElement) {
|
|
6
|
-
let align = dom.getAttribute('data-align') || dom.getAttribute('align');
|
|
7
|
-
if (align) {
|
|
8
|
-
align = /(left|right|center)/.test(align) ? align : null;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
return {
|
|
12
|
-
align,
|
|
13
|
-
latex: dom.getAttribute('data-latex') || null,
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const MathNodeSpec: NodeSpec = {
|
|
18
|
-
inline: true,
|
|
19
|
-
attrs: {
|
|
20
|
-
align: { default: null },
|
|
21
|
-
latex: { default: '' },
|
|
22
|
-
},
|
|
23
|
-
group: 'inline',
|
|
24
|
-
draggable: true,
|
|
25
|
-
parseDOM: [
|
|
26
|
-
{ tag: 'math[data-latex]', getAttrs },
|
|
27
|
-
{ tag: 'span[data-latex]', getAttrs },
|
|
28
|
-
],
|
|
29
|
-
toDOM(node) {
|
|
30
|
-
// Normally, the DOM structure of the math node is rendered by
|
|
31
|
-
// `MathNodeView`. This method is only called when user selects a
|
|
32
|
-
// math node and copies it, which triggers the "serialize to HTML" flow that
|
|
33
|
-
// calles this method.
|
|
34
|
-
const { align, latex } = node.attrs;
|
|
35
|
-
const domAttrs = {};
|
|
36
|
-
if (align) {
|
|
37
|
-
domAttrs.align = align;
|
|
38
|
-
}
|
|
39
|
-
if (latex) {
|
|
40
|
-
domAttrs['data-latex'] = latex;
|
|
41
|
-
}
|
|
42
|
-
return ['span', domAttrs];
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export default MathNodeSpec;
|