@modusoperandi/licit 1.0.8 → 1.0.10
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 +789 -608
- package/package.json +2 -4
- package/styles.css +1 -6
- 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 +1 -3
- package/ui/EditorToolbarConfig.js.flow +0 -2
- 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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modusoperandi/licit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
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",
|
|
@@ -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",
|
package/styles.css
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
@import './ui/czi-indent.css';
|
|
4
4
|
@import './ui/czi-list.css';
|
|
5
5
|
@import './ui/czi-table.css';
|
|
6
|
-
@import '
|
|
6
|
+
@import '~@modusoperandi/licit-ui-commands/styles.css';
|
|
7
7
|
@import './ui/czi-bookmark-view.css';
|
|
8
8
|
@import './ui/czi-body-layout-editor.css';
|
|
9
9
|
@import './ui/czi-cursor-placeholder.css';
|
|
@@ -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
|
});
|
|
@@ -39,7 +39,6 @@ var CLEAR_FORMAT = EditorCommands.CLEAR_FORMAT,
|
|
|
39
39
|
INDENT_LESS = EditorCommands.INDENT_LESS,
|
|
40
40
|
INDENT_MORE = EditorCommands.INDENT_MORE,
|
|
41
41
|
LINK_SET_URL = EditorCommands.LINK_SET_URL,
|
|
42
|
-
MATH_EDIT = EditorCommands.MATH_EDIT,
|
|
43
42
|
STRIKE = EditorCommands.STRIKE,
|
|
44
43
|
STRONG = EditorCommands.STRONG,
|
|
45
44
|
SUPER = EditorCommands.SUPER,
|
|
@@ -128,8 +127,7 @@ export var COMMAND_GROUPS = [{
|
|
|
128
127
|
}, {
|
|
129
128
|
'[link] Apply link': LINK_SET_URL,
|
|
130
129
|
'[grid_on] Table...': TABLE_COMMANDS_GROUP,
|
|
131
|
-
'[hr] Horizontal line': HR
|
|
132
|
-
'[functions] Math': MATH_EDIT
|
|
130
|
+
'[hr] Horizontal line': HR
|
|
133
131
|
|
|
134
132
|
// [FS][07-MAY-2020][IRAD-956]
|
|
135
133
|
// '[format_quote] Block quote': BLOCKQUOTE_TOGGLE,
|
|
@@ -43,7 +43,6 @@ const {
|
|
|
43
43
|
INDENT_LESS,
|
|
44
44
|
INDENT_MORE,
|
|
45
45
|
LINK_SET_URL,
|
|
46
|
-
MATH_EDIT,
|
|
47
46
|
STRIKE,
|
|
48
47
|
STRONG,
|
|
49
48
|
SUPER,
|
|
@@ -149,7 +148,6 @@ export const COMMAND_GROUPS = [
|
|
|
149
148
|
'[link] Apply link': LINK_SET_URL,
|
|
150
149
|
'[grid_on] Table...': TABLE_COMMANDS_GROUP,
|
|
151
150
|
'[hr] Horizontal line': HR,
|
|
152
|
-
'[functions] Math': MATH_EDIT,
|
|
153
151
|
|
|
154
152
|
// [FS][07-MAY-2020][IRAD-956]
|
|
155
153
|
// '[format_quote] Block quote': BLOCKQUOTE_TOGGLE,
|
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;
|
package/ui/MathEditor.js
DELETED
|
@@ -1,86 +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 * as React from 'react';
|
|
16
|
-
import PropTypes from 'prop-types';
|
|
17
|
-
import { CustomButton, preventEventDefault } from '@modusoperandi/licit-ui-commands';
|
|
18
|
-
import MathQuillEditor from './mathquill-editor/MathQuillEditor.js';
|
|
19
|
-
var MathEditor = /*#__PURE__*/function (_React$PureComponent) {
|
|
20
|
-
function MathEditor() {
|
|
21
|
-
var _this;
|
|
22
|
-
_classCallCheck(this, MathEditor);
|
|
23
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
24
|
-
args[_key] = arguments[_key];
|
|
25
|
-
}
|
|
26
|
-
_this = _callSuper(this, MathEditor, [].concat(args));
|
|
27
|
-
_defineProperty(_this, "state", {
|
|
28
|
-
initialValue: _this.props.initialValue,
|
|
29
|
-
value: _this.props.initialValue || ''
|
|
30
|
-
});
|
|
31
|
-
_defineProperty(_this, "_onChange", function (value) {
|
|
32
|
-
_this.setState({
|
|
33
|
-
value: value
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
_defineProperty(_this, "_cancel", function () {
|
|
37
|
-
_this.props.close();
|
|
38
|
-
});
|
|
39
|
-
_defineProperty(_this, "_insert", function () {
|
|
40
|
-
_this.props.close(_this.state.value);
|
|
41
|
-
});
|
|
42
|
-
return _this;
|
|
43
|
-
}
|
|
44
|
-
_inherits(MathEditor, _React$PureComponent);
|
|
45
|
-
return _createClass(MathEditor, [{
|
|
46
|
-
key: "render",
|
|
47
|
-
value: function render() {
|
|
48
|
-
var _this$state = this.state,
|
|
49
|
-
initialValue = _this$state.initialValue,
|
|
50
|
-
value = _this$state.value;
|
|
51
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
52
|
-
className: "czi-math-editor"
|
|
53
|
-
}, /*#__PURE__*/React.createElement("form", {
|
|
54
|
-
className: "czi-form",
|
|
55
|
-
onSubmit: preventEventDefault
|
|
56
|
-
}, /*#__PURE__*/React.createElement("fieldset", null, /*#__PURE__*/React.createElement("legend", null, "Insert Math"), /*#__PURE__*/React.createElement(MathQuillEditor, {
|
|
57
|
-
onChange: this._onChange,
|
|
58
|
-
value: value
|
|
59
|
-
})), /*#__PURE__*/React.createElement("div", {
|
|
60
|
-
className: "czi-form-buttons"
|
|
61
|
-
}, /*#__PURE__*/React.createElement(CustomButton, {
|
|
62
|
-
label: "Cancel",
|
|
63
|
-
onClick: this._cancel
|
|
64
|
-
}), /*#__PURE__*/React.createElement(CustomButton, {
|
|
65
|
-
active: true,
|
|
66
|
-
disabled: !this.state.value,
|
|
67
|
-
label: initialValue ? 'Update' : 'Insert',
|
|
68
|
-
onClick: this._insert
|
|
69
|
-
}))));
|
|
70
|
-
}
|
|
71
|
-
}]);
|
|
72
|
-
}(React.PureComponent);
|
|
73
|
-
// [FS] IRAD-1005 2020-07-07
|
|
74
|
-
// Upgrade outdated packages.
|
|
75
|
-
// To take care of the property type declaration.
|
|
76
|
-
_defineProperty(MathEditor, "propsTypes", {
|
|
77
|
-
initialValue: PropTypes.string,
|
|
78
|
-
close: function close(props, propName) {
|
|
79
|
-
var fn = props[propName];
|
|
80
|
-
if (!fn.prototype || typeof fn.prototype.constructor !== 'function' && fn.prototype.constructor.length !== 1) {
|
|
81
|
-
return new Error(propName + 'must be a function with 1 arg of type string');
|
|
82
|
-
}
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
export default MathEditor;
|