@seafile/seafile-editor 1.0.85-beta4 → 1.0.85-beta5
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/dist/editors/inline-editor/index.js +160 -0
- package/dist/editors/inline-editor/style.css +87 -0
- package/dist/editors/inline-editor/with-props-editor.js +21 -0
- package/dist/editors/simple-slate-editor/index.js +5 -15
- package/dist/extension/editor.js +10 -6
- package/dist/pages/longtext-inline-editor/editor.js +1 -1
- package/dist/pages/longtext-inline-editor/index.js +0 -10
- package/dist/pages/longtext-inline-editor/simple-editor.js +65 -0
- package/dist/pages/simple-editor.js +0 -2
- package/package.json +1 -1
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _slateReact = require("slate-react");
|
|
11
|
+
var _slate = require("slate");
|
|
12
|
+
var _extension = require("../../extension");
|
|
13
|
+
var _eventBus = _interopRequireDefault(require("../../utils/event-bus"));
|
|
14
|
+
var _eventHandler = _interopRequireDefault(require("../../utils/event-handler"));
|
|
15
|
+
var _withPropsEditor = _interopRequireDefault(require("./with-props-editor"));
|
|
16
|
+
var _core = require("../../extension/core");
|
|
17
|
+
var _common = require("../../utils/common");
|
|
18
|
+
require("./style.css");
|
|
19
|
+
const isMacOS = (0, _common.isMac)();
|
|
20
|
+
const InlineEditor = _ref => {
|
|
21
|
+
let {
|
|
22
|
+
showTitle,
|
|
23
|
+
focusNodePath,
|
|
24
|
+
value,
|
|
25
|
+
editorApi,
|
|
26
|
+
onSave,
|
|
27
|
+
columns,
|
|
28
|
+
onContentChanged,
|
|
29
|
+
isSupportFormula,
|
|
30
|
+
onExpandEditorToggle
|
|
31
|
+
} = _ref;
|
|
32
|
+
const [slateValue, setSlateValue] = (0, _react.useState)(value);
|
|
33
|
+
const editor = (0, _react.useMemo)(() => {
|
|
34
|
+
if (showTitle) return (0, _withPropsEditor.default)(_extension.inlineEditor, {
|
|
35
|
+
editorApi,
|
|
36
|
+
onSave,
|
|
37
|
+
columns
|
|
38
|
+
});
|
|
39
|
+
return (0, _extension.createSlateEditor)();
|
|
40
|
+
}, [columns, editorApi, onSave, showTitle]);
|
|
41
|
+
const eventProxy = (0, _react.useMemo)(() => {
|
|
42
|
+
return new _eventHandler.default(editor);
|
|
43
|
+
}, [editor]);
|
|
44
|
+
const decorate = (0, _extension.useHighlight)(editor);
|
|
45
|
+
const onChange = (0, _react.useCallback)(value => {
|
|
46
|
+
setSlateValue(value);
|
|
47
|
+
if (editor.forceNormalize) return;
|
|
48
|
+
const operations = editor.operations;
|
|
49
|
+
const modifyOps = operations.filter(o => o.type !== 'set_selection');
|
|
50
|
+
if (modifyOps.length > 0) {
|
|
51
|
+
onContentChanged && onContentChanged(value);
|
|
52
|
+
}
|
|
53
|
+
const eventBus = _eventBus.default.getInstance();
|
|
54
|
+
eventBus.dispatch('change');
|
|
55
|
+
}, [editor, onContentChanged]);
|
|
56
|
+
const focusNode = (0, _react.useCallback)((editor, focusNodePath) => {
|
|
57
|
+
const [firstNode] = editor.children;
|
|
58
|
+
if (!firstNode) return;
|
|
59
|
+
if (focusNodePath) {
|
|
60
|
+
const customFocusNodePath = (0, _core.getNode)(editor, focusNodePath);
|
|
61
|
+
if (customFocusNodePath) {
|
|
62
|
+
const startOfFirstNode = _slate.Editor.start(editor, focusNodePath);
|
|
63
|
+
const range = {
|
|
64
|
+
anchor: startOfFirstNode,
|
|
65
|
+
focus: startOfFirstNode
|
|
66
|
+
};
|
|
67
|
+
(0, _core.focusEditor)(editor, range);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const [firstNodeFirstChild] = firstNode.children;
|
|
72
|
+
if (firstNodeFirstChild) {
|
|
73
|
+
const startOfFirstNode = _slate.Editor.start(editor, [0, 0]);
|
|
74
|
+
const range = {
|
|
75
|
+
anchor: startOfFirstNode,
|
|
76
|
+
focus: startOfFirstNode
|
|
77
|
+
};
|
|
78
|
+
(0, _core.focusEditor)(editor, range);
|
|
79
|
+
}
|
|
80
|
+
}, []);
|
|
81
|
+
|
|
82
|
+
// const focusEndNode = useCallback((editor) => {
|
|
83
|
+
// const lastChildIndex = editor.children.length - 1;
|
|
84
|
+
// if (lastChildIndex < 0) return;
|
|
85
|
+
// const lastNode = editor.children[lastChildIndex];
|
|
86
|
+
// if (!lastNode) return;
|
|
87
|
+
// const [lastNodeFirstChild] = lastNode.children;
|
|
88
|
+
// if (lastNodeFirstChild) {
|
|
89
|
+
// const endOfFirstNode = Editor.end(editor, [lastChildIndex, 0]);
|
|
90
|
+
// const range = {
|
|
91
|
+
// anchor: endOfFirstNode,
|
|
92
|
+
// focus: endOfFirstNode,
|
|
93
|
+
// };
|
|
94
|
+
// focusEditor(editor, range);
|
|
95
|
+
// }
|
|
96
|
+
// }, []);
|
|
97
|
+
|
|
98
|
+
// useMount: focus editor
|
|
99
|
+
(0, _react.useEffect)(() => {
|
|
100
|
+
editor.forceNormalize = true;
|
|
101
|
+
_slate.Editor.normalize(editor, {
|
|
102
|
+
force: true
|
|
103
|
+
});
|
|
104
|
+
const timer = setTimeout(() => {
|
|
105
|
+
editor.forceNormalize = false;
|
|
106
|
+
focusNode(editor, focusNodePath);
|
|
107
|
+
}, 300);
|
|
108
|
+
return () => {
|
|
109
|
+
editor.forceNormalize = false;
|
|
110
|
+
clearTimeout(timer);
|
|
111
|
+
};
|
|
112
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
113
|
+
}, []);
|
|
114
|
+
|
|
115
|
+
// willUnmount
|
|
116
|
+
(0, _react.useEffect)(() => {
|
|
117
|
+
return () => {
|
|
118
|
+
editor.selection = null;
|
|
119
|
+
editor.history = {
|
|
120
|
+
redos: [],
|
|
121
|
+
undos: []
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
125
|
+
}, []);
|
|
126
|
+
const onEditorClick = (0, _react.useCallback)(() => {
|
|
127
|
+
const value = editor.children;
|
|
128
|
+
if (value.length === 1 && _slate.Node.string(value[0]).length === 0) {
|
|
129
|
+
focusNode(editor);
|
|
130
|
+
}
|
|
131
|
+
}, [editor, focusNode]);
|
|
132
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
133
|
+
className: "sf-simple-slate-editor-container"
|
|
134
|
+
}, showTitle && /*#__PURE__*/_react.default.createElement(_extension.InlineToolbar, {
|
|
135
|
+
editor: editor,
|
|
136
|
+
isSupportFormula: isSupportFormula,
|
|
137
|
+
isSupportColumn: !!columns,
|
|
138
|
+
onExpandEditorToggle: onExpandEditorToggle
|
|
139
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
140
|
+
className: "sf-slate-editor-content",
|
|
141
|
+
onClick: onEditorClick
|
|
142
|
+
}, /*#__PURE__*/_react.default.createElement(_slateReact.Slate, {
|
|
143
|
+
editor: editor,
|
|
144
|
+
initialValue: slateValue,
|
|
145
|
+
onChange: onChange
|
|
146
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
147
|
+
className: "sf-slate-scroll-container ".concat(isMacOS ? '' : 'isWin')
|
|
148
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
149
|
+
className: "sf-slate-article-container"
|
|
150
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
151
|
+
className: "article"
|
|
152
|
+
}, /*#__PURE__*/_react.default.createElement(_extension.SetNodeToDecorations, null), /*#__PURE__*/_react.default.createElement(_slateReact.Editable, {
|
|
153
|
+
decorate: decorate,
|
|
154
|
+
renderElement: _extension.renderElement,
|
|
155
|
+
renderLeaf: _extension.renderLeaf,
|
|
156
|
+
onKeyDown: eventProxy.onKeyDown,
|
|
157
|
+
onCopy: eventProxy.onCopy
|
|
158
|
+
})))))));
|
|
159
|
+
};
|
|
160
|
+
var _default = exports.default = InlineEditor;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
.sf-simple-slate-editor-container {
|
|
2
|
+
flex: 1;
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
min-height: 0;
|
|
6
|
+
min-width: 0;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.sf-simple-slate-editor-container .sf-slate-editor-toolbar {
|
|
10
|
+
display: flex;
|
|
11
|
+
justify-content: flex-start;
|
|
12
|
+
height: 44px;
|
|
13
|
+
align-items: center;
|
|
14
|
+
padding: 0 10px;
|
|
15
|
+
background-color: #fff;
|
|
16
|
+
user-select: none;
|
|
17
|
+
border-bottom: 1px solid #e5e6e8;
|
|
18
|
+
position: relative;
|
|
19
|
+
z-index: 102;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.sf-simple-slate-editor-container .sf-slate-editor-content {
|
|
23
|
+
width: 100%;
|
|
24
|
+
height: calc(100% - 44px);
|
|
25
|
+
display: flex;
|
|
26
|
+
background: #f5f5f5;
|
|
27
|
+
position: relative;
|
|
28
|
+
min-height: 0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.sf-simple-slate-editor-container .sf-slate-scroll-container {
|
|
32
|
+
height: 100%;
|
|
33
|
+
width: 100%;
|
|
34
|
+
overflow: auto;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.sf-simple-slate-editor-container .sf-slate-scroll-container.isWin::-webkit-scrollbar {
|
|
38
|
+
width: 8px;
|
|
39
|
+
height: 8px;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.sf-simple-slate-editor-container .sf-slate-scroll-container.isWin::-webkit-scrollbar-button {
|
|
43
|
+
display: none;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.sf-simple-slate-editor-container .sf-slate-scroll-container.isWin::-webkit-scrollbar-thumb {
|
|
47
|
+
background-color: rgb(206, 206, 212);
|
|
48
|
+
border-radius: 10px;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* .sf-simple-slate-editor-container .sf-slate-article-container {
|
|
52
|
+
flex: 1;
|
|
53
|
+
position: relative;
|
|
54
|
+
max-width: 950px;
|
|
55
|
+
min-width: 400px;
|
|
56
|
+
margin: 0 auto;
|
|
57
|
+
padding-top: 20px;
|
|
58
|
+
padding-bottom: 20px;
|
|
59
|
+
} */
|
|
60
|
+
|
|
61
|
+
.sf-simple-slate-editor-container .sf-slate-article-container {
|
|
62
|
+
height: 100%;
|
|
63
|
+
width: 100%;
|
|
64
|
+
overflow: auto;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.sf-simple-slate-editor-container .sf-slate-editor-content .article {
|
|
68
|
+
margin: 0;
|
|
69
|
+
padding: 10px;
|
|
70
|
+
border: none;
|
|
71
|
+
background-color: #fff;
|
|
72
|
+
min-height: 100%;
|
|
73
|
+
color: #212529;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.sf-simple-slate-editor-container .sf-slate-editor-content .article h1,
|
|
77
|
+
.sf-simple-slate-editor-container .sf-slate-editor-content .article h2,
|
|
78
|
+
.sf-simple-slate-editor-container .sf-slate-editor-content .article h3,
|
|
79
|
+
.sf-simple-slate-editor-container .sf-slate-editor-content .article h4,
|
|
80
|
+
.sf-simple-slate-editor-container .sf-slate-editor-content .article h5,
|
|
81
|
+
.sf-simple-slate-editor-container .sf-slate-editor-content .article h6 {
|
|
82
|
+
color: #212529;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.sf-simple-slate-editor-container .sf-slate-editor-content .article div:first-child {
|
|
86
|
+
outline: none;
|
|
87
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
const withPropsEditor = function (editor) {
|
|
8
|
+
let props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
9
|
+
let newEditor = editor;
|
|
10
|
+
if (props.editorApi) {
|
|
11
|
+
newEditor.api = props.editorApi;
|
|
12
|
+
}
|
|
13
|
+
if (props.onSave) {
|
|
14
|
+
newEditor.onSave = props.onSave;
|
|
15
|
+
}
|
|
16
|
+
if (props.columns) {
|
|
17
|
+
newEditor.columns = props.columns;
|
|
18
|
+
}
|
|
19
|
+
return newEditor;
|
|
20
|
+
};
|
|
21
|
+
var _default = exports.default = withPropsEditor;
|
|
@@ -19,29 +19,23 @@ require("./style.css");
|
|
|
19
19
|
const isMacOS = (0, _common.isMac)();
|
|
20
20
|
const SimpleSlateEditor = _ref => {
|
|
21
21
|
let {
|
|
22
|
-
isInline,
|
|
23
|
-
showTitle,
|
|
24
22
|
focusNodePath,
|
|
25
23
|
value,
|
|
26
24
|
editorApi,
|
|
27
25
|
onSave,
|
|
28
26
|
columns,
|
|
29
27
|
onContentChanged,
|
|
30
|
-
isSupportFormula
|
|
31
|
-
onExpandEditorToggle
|
|
28
|
+
isSupportFormula
|
|
32
29
|
} = _ref;
|
|
33
30
|
const [slateValue, setSlateValue] = (0, _react.useState)(value);
|
|
34
|
-
const editor = (0, _react.useMemo)(() => (0, _withPropsEditor.default)(
|
|
31
|
+
const editor = (0, _react.useMemo)(() => (0, _withPropsEditor.default)(_extension.baseEditor, {
|
|
35
32
|
editorApi,
|
|
36
33
|
onSave,
|
|
37
34
|
columns
|
|
38
|
-
}), [columns, editorApi, onSave
|
|
35
|
+
}), [columns, editorApi, onSave]);
|
|
39
36
|
const eventProxy = (0, _react.useMemo)(() => {
|
|
40
37
|
return new _eventHandler.default(editor);
|
|
41
38
|
}, [editor]);
|
|
42
|
-
const ToolbarComponent = (0, _react.useMemo)(() => {
|
|
43
|
-
return isInline ? _extension.InlineToolbar : _extension.Toolbar;
|
|
44
|
-
}, [isInline]);
|
|
45
39
|
const decorate = (0, _extension.useHighlight)(editor);
|
|
46
40
|
const onChange = (0, _react.useCallback)(value => {
|
|
47
41
|
setSlateValue(value);
|
|
@@ -132,11 +126,10 @@ const SimpleSlateEditor = _ref => {
|
|
|
132
126
|
}, [editor, focusNode]);
|
|
133
127
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
134
128
|
className: "sf-simple-slate-editor-container"
|
|
135
|
-
},
|
|
129
|
+
}, /*#__PURE__*/_react.default.createElement(_extension.Toolbar, {
|
|
136
130
|
editor: editor,
|
|
137
131
|
isSupportFormula: isSupportFormula,
|
|
138
|
-
isSupportColumn: !!columns
|
|
139
|
-
onExpandEditorToggle: onExpandEditorToggle
|
|
132
|
+
isSupportColumn: !!columns
|
|
140
133
|
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
141
134
|
className: "sf-slate-editor-content",
|
|
142
135
|
onClick: onEditorClick
|
|
@@ -158,7 +151,4 @@ const SimpleSlateEditor = _ref => {
|
|
|
158
151
|
onCopy: eventProxy.onCopy
|
|
159
152
|
})))))));
|
|
160
153
|
};
|
|
161
|
-
SimpleSlateEditor.defaultProps = {
|
|
162
|
-
isInline: false
|
|
163
|
-
};
|
|
164
154
|
var _default = exports.default = SimpleSlateEditor;
|
package/dist/extension/editor.js
CHANGED
|
@@ -16,13 +16,17 @@ const baseEditor = exports.baseEditor = _plugins.default.reduce((editor, pluginI
|
|
|
16
16
|
}
|
|
17
17
|
return editor;
|
|
18
18
|
}, (0, _slateHistory.withHistory)((0, _slateReact.withReact)((0, _slate.createEditor)())));
|
|
19
|
-
const inlineEditor =
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
const inlineEditor = () => {
|
|
20
|
+
const editor = _plugins.default.reduce((editor, pluginItem) => {
|
|
21
|
+
const withPlugin = pluginItem.editorPlugin;
|
|
22
|
+
if (withPlugin) {
|
|
23
|
+
return withPlugin(editor);
|
|
24
|
+
}
|
|
25
|
+
return editor;
|
|
26
|
+
}, (0, _slateHistory.withHistory)((0, _slateReact.withReact)((0, _slate.createEditor)())));
|
|
24
27
|
return editor;
|
|
25
|
-
}
|
|
28
|
+
};
|
|
29
|
+
exports.inlineEditor = inlineEditor;
|
|
26
30
|
const createSlateEditor = () => {
|
|
27
31
|
const editor = _plugins.default.reduce((editor, pluginItem) => {
|
|
28
32
|
const withPlugin = pluginItem.editorPlugin;
|
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _simpleEditor = _interopRequireDefault(require("
|
|
10
|
+
var _simpleEditor = _interopRequireDefault(require("./simple-editor"));
|
|
11
11
|
var _getPreviewContent = _interopRequireDefault(require("../../utils/get-preview-content"));
|
|
12
12
|
var _markdownPreview = _interopRequireDefault(require("../markdown-preview"));
|
|
13
13
|
var _longtextEditorDialog = _interopRequireDefault(require("../longtext-editor-dialog"));
|
|
@@ -83,16 +83,6 @@ const LongTextInlineEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) =>
|
|
|
83
83
|
closeEditor: closeEditor
|
|
84
84
|
};
|
|
85
85
|
}, [openEditor, closeEditor]);
|
|
86
|
-
|
|
87
|
-
// if (!isShowEditor) {
|
|
88
|
-
// const richValue = mdStringToSlate(valueRef.current.text);
|
|
89
|
-
// return (
|
|
90
|
-
// <div className="sf-long-text-inline-editor-container preview" onClick={(event) => previewClick(event, richValue)} >
|
|
91
|
-
// <Formatter value={isWindowsWechat ? valueRef.current : richValue} />
|
|
92
|
-
// </div>
|
|
93
|
-
// );
|
|
94
|
-
// }
|
|
95
|
-
|
|
96
86
|
const onClick = (0, _react.useCallback)(() => {
|
|
97
87
|
if (isShowEditor) return;
|
|
98
88
|
setShowEditor(true);
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _loading = _interopRequireDefault(require("../../containers/loading"));
|
|
11
|
+
var _slateConvert = require("../../slate-convert");
|
|
12
|
+
var _useMathjax = _interopRequireDefault(require("../../hooks/use-mathjax"));
|
|
13
|
+
var _inlineEditor = _interopRequireDefault(require("../../editors/inline-editor"));
|
|
14
|
+
const SimpleEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
15
|
+
let {
|
|
16
|
+
isFetching,
|
|
17
|
+
value,
|
|
18
|
+
editorApi,
|
|
19
|
+
mathJaxSource,
|
|
20
|
+
onSave: propsOnSave,
|
|
21
|
+
onContentChanged: propsOnContentChanged,
|
|
22
|
+
...otherProps
|
|
23
|
+
} = _ref;
|
|
24
|
+
const [richValue, setRichValue] = (0, _react.useState)([]);
|
|
25
|
+
const [isLoading, setIsLoading] = (0, _react.useState)(true);
|
|
26
|
+
const {
|
|
27
|
+
isLoadingMathJax
|
|
28
|
+
} = (0, _useMathjax.default)(mathJaxSource);
|
|
29
|
+
(0, _react.useImperativeHandle)(ref, () => {
|
|
30
|
+
return {
|
|
31
|
+
getValue: () => {
|
|
32
|
+
const mdStringValue = (0, _slateConvert.slateToMdString)(richValue);
|
|
33
|
+
return mdStringValue;
|
|
34
|
+
},
|
|
35
|
+
getSlateValue: () => {
|
|
36
|
+
return richValue;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}, [richValue]);
|
|
40
|
+
(0, _react.useEffect)(() => {
|
|
41
|
+
if (!isFetching) {
|
|
42
|
+
const richValue = (0, _slateConvert.mdStringToSlate)(value);
|
|
43
|
+
setRichValue(richValue);
|
|
44
|
+
setIsLoading(false);
|
|
45
|
+
}
|
|
46
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
47
|
+
}, [isFetching]);
|
|
48
|
+
const onContentChanged = (0, _react.useCallback)(content => {
|
|
49
|
+
setRichValue(content);
|
|
50
|
+
propsOnContentChanged && propsOnContentChanged();
|
|
51
|
+
}, [propsOnContentChanged]);
|
|
52
|
+
const props = {
|
|
53
|
+
isSupportFormula: !!mathJaxSource,
|
|
54
|
+
value: richValue,
|
|
55
|
+
editorApi: editorApi,
|
|
56
|
+
onSave: propsOnSave,
|
|
57
|
+
onContentChanged: onContentChanged,
|
|
58
|
+
...otherProps
|
|
59
|
+
};
|
|
60
|
+
if (isFetching || isLoading || isLoadingMathJax) {
|
|
61
|
+
return /*#__PURE__*/_react.default.createElement(_loading.default, null);
|
|
62
|
+
}
|
|
63
|
+
return /*#__PURE__*/_react.default.createElement(_inlineEditor.default, props);
|
|
64
|
+
});
|
|
65
|
+
var _default = exports.default = SimpleEditor;
|
|
@@ -13,7 +13,6 @@ var _useMathjax = _interopRequireDefault(require("../hooks/use-mathjax"));
|
|
|
13
13
|
var _simpleSlateEditor = _interopRequireDefault(require("../editors/simple-slate-editor"));
|
|
14
14
|
const SimpleEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
15
15
|
let {
|
|
16
|
-
isInline,
|
|
17
16
|
isFetching,
|
|
18
17
|
value,
|
|
19
18
|
editorApi,
|
|
@@ -51,7 +50,6 @@ const SimpleEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
51
50
|
propsOnContentChanged && propsOnContentChanged();
|
|
52
51
|
}, [propsOnContentChanged]);
|
|
53
52
|
const props = {
|
|
54
|
-
isInline,
|
|
55
53
|
isSupportFormula: !!mathJaxSource,
|
|
56
54
|
value: richValue,
|
|
57
55
|
editorApi: editorApi,
|