@seafile/seafile-editor 2.0.46 → 2.0.47-beta1

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.
@@ -29,8 +29,8 @@ function SlateViewer(_ref) {
29
29
  containerStyle
30
30
  } = (0, _useContainerStyle.default)(scrollRef, isShowOutline);
31
31
  const editor = (0, _react.useMemo)(() => {
32
- return (0, _extension.createSlateEditor)();
33
- }, []);
32
+ return (0, _extension.createSlateEditor)(value);
33
+ }, [value]);
34
34
  const containerScrollRef = externalScrollRef ? externalScrollRef : scrollRef;
35
35
  const decorate = (0, _extension.useHighlight)(editor);
36
36
  (0, _userLinkClick.default)(editor._id, onLinkClick);
@@ -30,7 +30,7 @@ const inlineEditor = () => {
30
30
  return editor;
31
31
  };
32
32
  exports.inlineEditor = inlineEditor;
33
- const createSlateEditor = () => {
33
+ const createSlateEditor = children => {
34
34
  const editor = _plugins.default.reduce((editor, pluginItem) => {
35
35
  const withPlugin = pluginItem.editorPlugin;
36
36
  if (withPlugin) {
@@ -39,6 +39,9 @@ const createSlateEditor = () => {
39
39
  return editor;
40
40
  }, (0, _slateHistory.withHistory)((0, _slateReact.withReact)((0, _slate.createEditor)())));
41
41
  editor._id = (0, _slugid.nice)();
42
+ if (children) {
43
+ editor.children = children;
44
+ }
42
45
  return editor;
43
46
  };
44
47
  exports.createSlateEditor = createSlateEditor;
@@ -31,6 +31,7 @@ var _slateViewer = _interopRequireDefault(require("../editors/slate-viewer"));
31
31
  function MarkdownViewer(_ref) {
32
32
  let {
33
33
  isFetching,
34
+ isTyping,
34
35
  value,
35
36
  mathJaxSource,
36
37
  isShowOutline,
@@ -40,22 +41,26 @@ function MarkdownViewer(_ref) {
40
41
  options
41
42
  } = _ref;
42
43
  const [richValue, setRichValue] = (0, _react.useState)([]);
43
- const [isLoading, setIsLoading] = (0, _react.useState)(true);
44
+ const [isLoading, setIsLoading] = (0, _react.useState)(isTyping ? false : true);
44
45
  const {
45
46
  isLoadingMathJax
46
47
  } = (0, _useMathjax.default)(mathJaxSource);
47
48
  (0, _react.useEffect)(() => {
48
49
  if (!isFetching) {
49
- setIsLoading(true);
50
+ if (!isTyping) {
51
+ setIsLoading(true);
52
+ }
50
53
  const richValue = (0, _slateConvert.mdStringToSlate)(value);
51
54
  beforeRenderCallback && beforeRenderCallback(richValue);
52
55
  setRichValue(richValue);
53
- setTimeout(() => {
54
- setIsLoading(false);
55
- }, 0);
56
+ if (!isTyping) {
57
+ setTimeout(() => {
58
+ setIsLoading(false);
59
+ }, 0);
60
+ }
56
61
  }
57
62
  // eslint-disable-next-line react-hooks/exhaustive-deps
58
- }, [isFetching, value]);
63
+ }, [isFetching, value, isTyping]);
59
64
  const props = {
60
65
  options,
61
66
  isSupportFormula: !!mathJaxSource,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/seafile-editor",
3
- "version": "2.0.46",
3
+ "version": "2.0.47-beta1",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {