@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 isValueValid = valueLimitCallback ? valueLimitCallback(markdownString) : true;
34
- if (isValueValid) {
35
- var _editorRef$current2;
36
- const slateNodes = (_editorRef$current2 = editorRef.current) === null || _editorRef$current2 === void 0 ? void 0 : _editorRef$current2.getSlateValue();
37
- const value = getPreviewContent(slateNodes);
38
- onSaveEditorValue({
39
- ...value,
40
- text: markdownString
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 parent's component cache value
90
- if (onEditorValueChanged && typeof onEditorValueChanged === 'function') {
91
- var _editorRef$current3, _editorRef$current4;
92
- const markdownString = (_editorRef$current3 = editorRef.current) === null || _editorRef$current3 === void 0 ? void 0 : _editorRef$current3.getValue();
93
- const slateNodes = (_editorRef$current4 = editorRef.current) === null || _editorRef$current4 === void 0 ? void 0 : _editorRef$current4.getSlateValue();
94
- const value = getPreviewContent(slateNodes);
95
- onEditorValueChanged({
96
- ...value,
97
- text: markdownString
98
- });
99
- }
100
- setValueChanged(true);
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) {
@@ -1,7 +1,7 @@
1
1
  const getBrowserInfo = isCheckBrowser => {
2
2
  if (!isCheckBrowser) return {
3
3
  isValidBrowser: true,
4
- isWindowsWechat: true
4
+ isWindowsWechat: false
5
5
  };
6
6
  let isValidBrowser = false;
7
7
  let isWindowsWechat = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/seafile-editor",
3
- "version": "1.0.32-3",
3
+ "version": "1.0.32-5",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {