@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.
Files changed (41) hide show
  1. package/DocNodeSpec.js +0 -2
  2. package/DocNodeSpec.js.flow +0 -2
  3. package/EditorCommands.js +0 -2
  4. package/EditorCommands.js.flow +0 -2
  5. package/EditorNodes.js +1 -3
  6. package/EditorNodes.js.flow +0 -3
  7. package/bom.xml +791 -728
  8. package/client/Licit.js +8 -0
  9. package/client/Licit.js.flow +9 -0
  10. package/index.d.ts +2 -0
  11. package/package.json +4 -6
  12. package/styles.css +0 -5
  13. package/ui/DocLayoutEditor.js +0 -10
  14. package/ui/DocLayoutEditor.js.flow +0 -12
  15. package/ui/Editor.js +2 -3
  16. package/ui/Editor.js.flow +1 -3
  17. package/ui/EditorToolbarConfig.js +7 -7
  18. package/ui/EditorToolbarConfig.js.flow +4 -6
  19. package/ui/czi-editor.css +0 -12
  20. package/MathEditCommand.js +0 -114
  21. package/MathEditCommand.js.flow +0 -119
  22. package/MathNodeSpec.js +0 -49
  23. package/MathNodeSpec.js.flow +0 -46
  24. package/ui/MathEditor.js +0 -86
  25. package/ui/MathEditor.js.flow +0 -70
  26. package/ui/MathInlineEditor.js +0 -121
  27. package/ui/MathInlineEditor.js.flow +0 -100
  28. package/ui/MathNodeView.js +0 -215
  29. package/ui/MathNodeView.js.flow +0 -175
  30. package/ui/mathquill-editor/MathQuillEditor.js +0 -183
  31. package/ui/mathquill-editor/MathQuillEditor.js.flow +0 -157
  32. package/ui/mathquill-editor/MathQuillEditorSymbols.js +0 -416
  33. package/ui/mathquill-editor/MathQuillEditorSymbols.js.flow +0 -483
  34. package/ui/mathquill-editor/MathQuillEditorSymbolsPanel.js +0 -67
  35. package/ui/mathquill-editor/MathQuillEditorSymbolsPanel.js.flow +0 -49
  36. package/ui/mathquill-editor/czi-mathquill-editor-symbols-panel.css +0 -39
  37. package/ui/mathquill-editor/czi-mathquill-editor.css +0 -50
  38. package/ui/mathquill-editor/mathquill-import-kludge.js +0 -13
  39. package/ui/mathquill-editor/mathquill-import-kludge.js.flow +0 -15
  40. package/ui/renderLaTeXAsHTML.js +0 -51
  41. package/ui/renderLaTeXAsHTML.js.flow +0 -42
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;
@@ -1,70 +0,0 @@
1
- // @flow
2
-
3
- import * as React from 'react';
4
- import PropTypes from 'prop-types';
5
- import { CustomButton, preventEventDefault } from '@modusoperandi/licit-ui-commands';
6
- import MathQuillEditor from './mathquill-editor/MathQuillEditor.js';
7
-
8
- class MathEditor extends React.PureComponent<any, any> {
9
- // [FS] IRAD-1005 2020-07-07
10
- // Upgrade outdated packages.
11
- // To take care of the property type declaration.
12
- static propsTypes = {
13
- initialValue: PropTypes.string,
14
- close: function (props: any, propName: string) {
15
- const fn = props[propName];
16
- if (
17
- !fn.prototype ||
18
- (typeof fn.prototype.constructor !== 'function' &&
19
- fn.prototype.constructor.length !== 1)
20
- ) {
21
- return new Error(
22
- propName + 'must be a function with 1 arg of type string'
23
- );
24
- }
25
- return null;
26
- },
27
- };
28
-
29
- state = {
30
- initialValue: this.props.initialValue,
31
- value: this.props.initialValue || '',
32
- };
33
-
34
- render(): React.Element<any> {
35
- const { initialValue, value } = this.state;
36
- return (
37
- <div className="czi-math-editor">
38
- <form className="czi-form" onSubmit={preventEventDefault}>
39
- <fieldset>
40
- <legend>Insert Math</legend>
41
- <MathQuillEditor onChange={this._onChange} value={value} />
42
- </fieldset>
43
- <div className="czi-form-buttons">
44
- <CustomButton label="Cancel" onClick={this._cancel} />
45
- <CustomButton
46
- active={true}
47
- disabled={!this.state.value}
48
- label={initialValue ? 'Update' : 'Insert'}
49
- onClick={this._insert}
50
- />
51
- </div>
52
- </form>
53
- </div>
54
- );
55
- }
56
-
57
- _onChange = (value: string): void => {
58
- this.setState({ value });
59
- };
60
-
61
- _cancel = (): void => {
62
- this.props.close();
63
- };
64
-
65
- _insert = (): void => {
66
- this.props.close(this.state.value);
67
- };
68
- }
69
-
70
- export default MathEditor;
@@ -1,121 +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 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
- 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 _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
5
- 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); } }
6
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
7
- function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
8
- 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); }
9
- function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
10
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
11
- function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
12
- 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); }
13
- function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
14
- 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; }
15
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
16
- 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); }
17
- import { CustomButton, createPopUp } from '@modusoperandi/licit-ui-commands';
18
- import CustomEditorView from './CustomEditorView.js';
19
- import MathEditor from './MathEditor.js';
20
- import * as React from 'react';
21
- var MathAlignValues = {
22
- NONE: {
23
- value: null,
24
- text: 'Inline'
25
- },
26
- CENTER: {
27
- value: 'center',
28
- text: 'Break text'
29
- }
30
- };
31
- var bpfrpt_proptype_MathInlineEditorValue = {
32
- "align": PropTypes.string,
33
- "latex": PropTypes.string.isRequired
34
- };
35
- var MathInlineEditor = /*#__PURE__*/function (_React$PureComponent) {
36
- function MathInlineEditor() {
37
- var _this;
38
- _classCallCheck(this, MathInlineEditor);
39
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
40
- args[_key] = arguments[_key];
41
- }
42
- _this = _callSuper(this, MathInlineEditor, [].concat(args));
43
- _defineProperty(_this, "props", void 0);
44
- _defineProperty(_this, "_popUp", null);
45
- _defineProperty(_this, "_onClick", function (align) {
46
- var value = _this.props.value || {};
47
- _this.props.onSelect(_objectSpread(_objectSpread({}, value), {}, {
48
- align: align
49
- }));
50
- });
51
- _defineProperty(_this, "_editLatex", function (latex) {
52
- if (_this._popUp) {
53
- return;
54
- }
55
- var _this$props = _this.props,
56
- editorView = _this$props.editorView,
57
- value = _this$props.value;
58
- var props = {
59
- runtime: editorView ? editorView.runtime : null,
60
- initialValue: (value === null || value === void 0 ? void 0 : value.latex) || ''
61
- };
62
- _this._popUp = createPopUp(MathEditor, props, {
63
- autoDismiss: false,
64
- modal: true,
65
- onClose: function onClose(latex) {
66
- if (_this._popUp) {
67
- _this._popUp = null;
68
- if (latex !== undefined) {
69
- var _value = _this.props.value || {};
70
- _this.props.onSelect(_objectSpread(_objectSpread({}, _value), {}, {
71
- latex: latex
72
- }));
73
- }
74
- _this.props.onEditEnd();
75
- }
76
- }
77
- });
78
- _this.props.onEditStart();
79
- });
80
- return _this;
81
- }
82
- _inherits(MathInlineEditor, _React$PureComponent);
83
- return _createClass(MathInlineEditor, [{
84
- key: "componentWillUnmount",
85
- value: function componentWillUnmount() {
86
- var _this$_popUp;
87
- (_this$_popUp = this._popUp) === null || _this$_popUp === void 0 || _this$_popUp.close();
88
- }
89
- }, {
90
- key: "render",
91
- value: function render() {
92
- var _ref = this.props.value || {},
93
- align = _ref.align,
94
- latex = _ref.latex;
95
- var onClick = this._onClick;
96
- var buttons = Object.keys(MathAlignValues).map(function (key) {
97
- var _MathAlignValues$key = MathAlignValues[key],
98
- value = _MathAlignValues$key.value,
99
- text = _MathAlignValues$key.text;
100
- return /*#__PURE__*/React.createElement(CustomButton, {
101
- active: align === value,
102
- key: key,
103
- label: text,
104
- onClick: onClick,
105
- value: value
106
- });
107
- });
108
- return /*#__PURE__*/React.createElement("div", {
109
- className: "czi-inline-editor"
110
- }, buttons, /*#__PURE__*/React.createElement(CustomButton, {
111
- key: "edit",
112
- label: "Edit",
113
- onClick: this._editLatex,
114
- value: latex || ''
115
- }));
116
- }
117
- }]);
118
- }(React.PureComponent);
119
- export default MathInlineEditor;
120
- import PropTypes from "prop-types";
121
- export { bpfrpt_proptype_MathInlineEditorValue };
@@ -1,100 +0,0 @@
1
- // @flow
2
-
3
- import { CustomButton, createPopUp } from '@modusoperandi/licit-ui-commands';
4
- import CustomEditorView from './CustomEditorView.js';
5
- import MathEditor from './MathEditor.js';
6
- import * as React from 'react';
7
-
8
- const MathAlignValues = {
9
- NONE: {
10
- value: null,
11
- text: 'Inline',
12
- },
13
- CENTER: {
14
- value: 'center',
15
- text: 'Break text',
16
- },
17
- };
18
-
19
- export type MathInlineEditorValue = {
20
- align: ?string,
21
- latex: string,
22
- };
23
-
24
- class MathInlineEditor extends React.PureComponent<any, any> {
25
- props: {
26
- onEditEnd: () => void,
27
- onEditStart: () => void,
28
- onSelect: (val: any) => void,
29
- value: ?MathInlineEditorValue,
30
- editorView: ?CustomEditorView,
31
- };
32
-
33
- _popUp = null;
34
-
35
- componentWillUnmount(): void {
36
- this._popUp?.close();
37
- }
38
-
39
- render(): React.Element<any> {
40
- const { align, latex } = this.props.value || {};
41
- const onClick = this._onClick;
42
- const buttons = Object.keys(MathAlignValues).map((key) => {
43
- const { value, text } = MathAlignValues[key];
44
- return (
45
- <CustomButton
46
- active={align === value}
47
- key={key}
48
- label={text}
49
- onClick={onClick}
50
- value={value}
51
- />
52
- );
53
- });
54
-
55
- return (
56
- <div className="czi-inline-editor">
57
- {buttons}
58
- <CustomButton
59
- key="edit"
60
- label="Edit"
61
- onClick={this._editLatex}
62
- value={latex || ''}
63
- />
64
- </div>
65
- );
66
- }
67
-
68
- _onClick = (align: ?string): void => {
69
- const value = this.props.value || {};
70
- this.props.onSelect({ ...value, align });
71
- };
72
-
73
- _editLatex = (latex: string): void => {
74
- if (this._popUp) {
75
- return;
76
- }
77
- const { editorView, value } = this.props;
78
- const props = {
79
- runtime: editorView ? editorView.runtime : null,
80
- initialValue: (value?.latex) || '',
81
- };
82
- this._popUp = createPopUp(MathEditor, props, {
83
- autoDismiss: false,
84
- modal: true,
85
- onClose: (latex) => {
86
- if (this._popUp) {
87
- this._popUp = null;
88
- if (latex !== undefined) {
89
- const value = this.props.value || {};
90
- this.props.onSelect({ ...value, latex });
91
- }
92
- this.props.onEditEnd();
93
- }
94
- },
95
- });
96
- this.props.onEditStart();
97
- };
98
- }
99
-
100
- export default MathInlineEditor;
@@ -1,215 +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 _superPropGet(t, o, e, r) { var p = _get(_getPrototypeOf(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
3
- function _get() { return _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) { var p = _superPropBase(e, t); if (p) { var n = Object.getOwnPropertyDescriptor(p, t); return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value; } }, _get.apply(null, arguments); }
4
- function _superPropBase(t, o) { for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t));); return t; }
5
- 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; }
6
- 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; }
7
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
8
- 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); } }
9
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
10
- function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
11
- 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); }
12
- function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
13
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
14
- function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
15
- 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); }
16
- function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
17
- 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; }
18
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
19
- 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); }
20
- import CustomNodeView from './CustomNodeView.js';
21
- import MathInlineEditor from './MathInlineEditor.js';
22
- import * as React from 'react';
23
- import { createPopUp, atAnchorBottomCenter } from '@modusoperandi/licit-ui-commands';
24
- import cx from 'classnames';
25
- import renderLaTeXAsHTML from './renderLaTeXAsHTML.js';
26
- import uuid from './uuid.js';
27
- import { Decoration } from 'prosemirror-view';
28
- import { FRAMESET_BODY_CLASSNAME } from './EditorFrameset.js';
29
- import { Node } from 'prosemirror-model';
30
- import { NodeSelection } from 'prosemirror-state';
31
- var EMPTY_SRC = 'data:image/gif;base64,' + 'R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
32
- var MathViewBody = /*#__PURE__*/function (_React$PureComponent) {
33
- function MathViewBody() {
34
- var _this;
35
- _classCallCheck(this, MathViewBody);
36
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
37
- args[_key] = arguments[_key];
38
- }
39
- _this = _callSuper(this, MathViewBody, [].concat(args));
40
- _defineProperty(_this, "props", void 0);
41
- _defineProperty(_this, "state", {
42
- isEditing: false
43
- });
44
- _defineProperty(_this, "_inlineEditor", null);
45
- _defineProperty(_this, "_id", uuid());
46
- _defineProperty(_this, "_mounted", false);
47
- _defineProperty(_this, "_onEditStart", function () {
48
- _this.setState({
49
- isEditing: true
50
- });
51
- });
52
- _defineProperty(_this, "_onEditEnd", function () {
53
- _this.setState({
54
- isEditing: false
55
- });
56
- });
57
- _defineProperty(_this, "_onChange", function (value) {
58
- if (!_this._mounted) {
59
- return;
60
- }
61
- var align = value ? value.align : null;
62
- var latex = value ? value.latex : null;
63
- var _this$props = _this.props,
64
- getPos = _this$props.getPos,
65
- node = _this$props.node,
66
- editorView = _this$props.editorView;
67
- var pos = getPos();
68
- var attrs = _objectSpread(_objectSpread({}, node.attrs), {}, {
69
- latex: latex,
70
- align: align
71
- });
72
- var tr = editorView.state.tr;
73
- var selection = editorView.state.selection;
74
- tr = tr.setNodeMarkup(pos, null, attrs);
75
- // [FS] IRAD-1005 2020-07-23
76
- // Upgrade outdated packages.
77
- // reset selection to original using the latest doc.
78
- var origSelection = NodeSelection.create(tr.doc, selection.from);
79
- tr = tr.setSelection(origSelection);
80
- editorView.dispatch(tr);
81
- });
82
- return _this;
83
- }
84
- _inherits(MathViewBody, _React$PureComponent);
85
- return _createClass(MathViewBody, [{
86
- key: "componentDidMount",
87
- value: function componentDidMount() {
88
- this._mounted = true;
89
- this._renderInlineEditor();
90
- }
91
- }, {
92
- key: "componentWillUnmount",
93
- value: function componentWillUnmount() {
94
- this._mounted = false;
95
- }
96
- }, {
97
- key: "componentDidUpdate",
98
- value: function componentDidUpdate(prevProps) {
99
- this._renderInlineEditor();
100
- }
101
- }, {
102
- key: "render",
103
- value: function render() {
104
- // TODO: Resolve `readOnly`;
105
- var readOnly = false;
106
- var _this$props2 = this.props,
107
- node = _this$props2.node,
108
- selected = _this$props2.selected,
109
- focused = _this$props2.focused;
110
- var attrs = node.attrs;
111
- var latex = attrs.latex;
112
- var isEditing = this.state.isEditing;
113
- var active = (focused || isEditing) && !readOnly;
114
- var className = cx('czi-math-view-body', {
115
- active: active,
116
- selected: selected
117
- });
118
- var html = renderLaTeXAsHTML(latex);
119
- return /*#__PURE__*/React.createElement("span", {
120
- className: className,
121
- "data-active": active ? 'true' : null,
122
- "data-latex": latex || '',
123
- id: this._id,
124
- title: latex
125
- }, /*#__PURE__*/React.createElement("img", {
126
- alt: latex,
127
- className: "czi-math-view-body-img",
128
- src: EMPTY_SRC,
129
- title: latex
130
- }), /*#__PURE__*/React.createElement("span", {
131
- className: "czi-math-view-body-content",
132
- dangerouslySetInnerHTML: {
133
- __html: html
134
- }
135
- }));
136
- }
137
- }, {
138
- key: "_renderInlineEditor",
139
- value: function _renderInlineEditor() {
140
- var _this2 = this;
141
- var el = document.getElementById(this._id);
142
- if (!el || el.getAttribute('data-active') !== 'true') {
143
- var _this$_inlineEditor;
144
- (_this$_inlineEditor = this._inlineEditor) === null || _this$_inlineEditor === void 0 || _this$_inlineEditor.close();
145
- return;
146
- }
147
- var node = this.props.node;
148
- var editorProps = {
149
- value: node.attrs,
150
- onSelect: this._onChange,
151
- onEditStart: this._onEditStart,
152
- onEditEnd: this._onEditEnd
153
- };
154
- if (this._inlineEditor) {
155
- this._inlineEditor.update(editorProps);
156
- } else {
157
- this._inlineEditor = createPopUp(MathInlineEditor, editorProps, {
158
- anchor: el,
159
- autoDismiss: false,
160
- container: el.closest(".".concat(FRAMESET_BODY_CLASSNAME)),
161
- position: atAnchorBottomCenter,
162
- onClose: function onClose() {
163
- _this2._inlineEditor = null;
164
- }
165
- });
166
- }
167
- }
168
- }]);
169
- }(React.PureComponent);
170
- var MathNodeView = /*#__PURE__*/function (_CustomNodeView) {
171
- function MathNodeView() {
172
- _classCallCheck(this, MathNodeView);
173
- return _callSuper(this, MathNodeView, arguments);
174
- }
175
- _inherits(MathNodeView, _CustomNodeView);
176
- return _createClass(MathNodeView, [{
177
- key: "createDOMElement",
178
- value:
179
- // @override
180
- function createDOMElement() {
181
- var el = document.createElement('span');
182
- el.className = 'czi-math-view';
183
- this._updateDOM(el);
184
- return el;
185
- }
186
-
187
- // @override
188
- }, {
189
- key: "update",
190
- value: function update(node, decorations) {
191
- _superPropGet(MathNodeView, "update", this, 3)([node, decorations]);
192
- this._updateDOM(this.dom);
193
- return true;
194
- }
195
-
196
- // @override
197
- }, {
198
- key: "renderReactComponent",
199
- value: function renderReactComponent() {
200
- return /*#__PURE__*/React.createElement(MathViewBody, this.props);
201
- }
202
- }, {
203
- key: "_updateDOM",
204
- value: function _updateDOM(el) {
205
- var align = this.props.node.attrs.align;
206
- var className = 'czi-math-view';
207
- if (align) {
208
- className += ' align-' + align;
209
- }
210
- el.className = className;
211
- }
212
- }]);
213
- }(CustomNodeView);
214
- export default MathNodeView;
215
- import { bpfrpt_proptype_NodeViewProps } from "./CustomNodeView.js";