@seafile/seafile-editor 1.0.32-3 → 1.0.32-5
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/index.js
CHANGED
|
@@ -5,10 +5,11 @@ import MarkdownEditor from './pages/markdown-editor';
|
|
|
5
5
|
import MarkdownViewer from './pages/markdown-view';
|
|
6
6
|
import SimpleEditor from './pages/simple-editor';
|
|
7
7
|
import LongTextEditorDialog from './pages/longtext-editor-dialog';
|
|
8
|
+
import MarkdownPreview from './pages/markdown-preview';
|
|
8
9
|
import SeaTableEditor from './pages/seatable-editor';
|
|
9
10
|
import SeaTableViewer from './pages/seatable-viewer';
|
|
10
11
|
import EventBus from './utils/event-bus';
|
|
11
12
|
import { mdStringToSlate, slateToMdString, deserializeHtml, processor } from './slate-convert';
|
|
12
13
|
import { replaceColumnData } from './utils/replace-slate-nodes';
|
|
13
14
|
import getPreviewContent from './utils/get-preview-content';
|
|
14
|
-
export { MarkdownEditor, PlainMarkdownEditor, RichMarkdownEditor, MarkdownViewer, SimpleEditor, SeaTableEditor, SeaTableViewer, LongTextEditorDialog, EXTERNAL_EVENTS, EventBus, mdStringToSlate, slateToMdString, deserializeHtml, processor, replaceColumnData, getPreviewContent };
|
|
15
|
+
export { MarkdownEditor, PlainMarkdownEditor, RichMarkdownEditor, MarkdownViewer, SimpleEditor, SeaTableEditor, SeaTableViewer, LongTextEditorDialog, MarkdownPreview, EXTERNAL_EVENTS, EventBus, mdStringToSlate, slateToMdString, deserializeHtml, processor, replaceColumnData, getPreviewContent };
|
|
@@ -19,29 +19,24 @@ export default function LongTextEditorDialog(_ref) {
|
|
|
19
19
|
editorApi,
|
|
20
20
|
onSaveEditorValue,
|
|
21
21
|
onEditorValueChanged,
|
|
22
|
-
onCloseEditorDialog
|
|
23
|
-
valueLimitCallback
|
|
22
|
+
onCloseEditorDialog
|
|
24
23
|
} = _ref;
|
|
25
24
|
const editorRef = useRef(null);
|
|
26
25
|
const [isValueChanged, setValueChanged] = useState(false);
|
|
27
26
|
const [isFullScreen, setIsFullScreen] = useState(false);
|
|
28
27
|
const [dialogStyle, setDialogStyle] = useState({});
|
|
29
28
|
const onUpdateEditorValue = useCallback(() => {
|
|
30
|
-
var _editorRef$current;
|
|
31
|
-
if (!isValueChanged) return;
|
|
29
|
+
var _editorRef$current, _editorRef$current2;
|
|
30
|
+
if (!isValueChanged || readOnly) return;
|
|
32
31
|
const markdownString = (_editorRef$current = editorRef.current) === null || _editorRef$current === void 0 ? void 0 : _editorRef$current.getValue();
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
});
|
|
42
|
-
setValueChanged(false);
|
|
43
|
-
}
|
|
44
|
-
}, [isValueChanged, onSaveEditorValue, valueLimitCallback]);
|
|
32
|
+
const slateNodes = (_editorRef$current2 = editorRef.current) === null || _editorRef$current2 === void 0 ? void 0 : _editorRef$current2.getSlateValue();
|
|
33
|
+
const value = getPreviewContent(slateNodes);
|
|
34
|
+
onSaveEditorValue({
|
|
35
|
+
...value,
|
|
36
|
+
text: markdownString
|
|
37
|
+
});
|
|
38
|
+
setValueChanged(false);
|
|
39
|
+
}, [isValueChanged, onSaveEditorValue, readOnly]);
|
|
45
40
|
const onCloseToggle = useCallback(() => {
|
|
46
41
|
onUpdateEditorValue();
|
|
47
42
|
onCloseEditorDialog();
|
|
@@ -86,18 +81,21 @@ export default function LongTextEditorDialog(_ref) {
|
|
|
86
81
|
setDialogStyle(containerStyle);
|
|
87
82
|
}, [isFullScreen]);
|
|
88
83
|
const onContentChanged = useCallback(() => {
|
|
89
|
-
// update
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
84
|
+
// delay to update editor's content
|
|
85
|
+
setTimeout(() => {
|
|
86
|
+
// update parent's component cache value
|
|
87
|
+
if (onEditorValueChanged && typeof onEditorValueChanged === 'function') {
|
|
88
|
+
var _editorRef$current3, _editorRef$current4;
|
|
89
|
+
const markdownString = (_editorRef$current3 = editorRef.current) === null || _editorRef$current3 === void 0 ? void 0 : _editorRef$current3.getValue();
|
|
90
|
+
const slateNodes = (_editorRef$current4 = editorRef.current) === null || _editorRef$current4 === void 0 ? void 0 : _editorRef$current4.getSlateValue();
|
|
91
|
+
const value = getPreviewContent(slateNodes);
|
|
92
|
+
onEditorValueChanged({
|
|
93
|
+
...value,
|
|
94
|
+
text: markdownString
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
setValueChanged(true);
|
|
98
|
+
}, 0);
|
|
101
99
|
}, [onEditorValueChanged]);
|
|
102
100
|
const onContainerKeyDown = event => {
|
|
103
101
|
if (event.keyCode === 27) {
|