@seafile/seafile-editor 1.0.85-beta12 → 1.0.85-beta14

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.
@@ -2,10 +2,9 @@
2
2
  width: 100%;
3
3
  height: 100%;
4
4
  overflow: hidden;
5
- border: 1px solid rgba(0, 40, 100, 0.12);
6
5
  border-radius: 3px;
7
6
  cursor: pointer;
8
- padding: 16px;
7
+ padding: 0 12px;
9
8
  background-color: #FFF;
10
9
  }
11
10
 
@@ -31,7 +30,7 @@
31
30
  }
32
31
 
33
32
  .sf-long-text-inline-editor-container.preview .longtext-preview-container .article :first-child {
34
- margin-top: 0;
33
+ margin-top: 0.8em;
35
34
  }
36
35
 
37
36
  .sf-long-text-inline-editor-container.preview .longtext-preview-container ol,
@@ -27,24 +27,23 @@ const NormalEditor = _ref => {
27
27
  const editorContainerRef = (0, _react.useRef)(null);
28
28
  const editorRef = (0, _react.useRef)(null);
29
29
  const [style, setStyle] = (0, _react.useState)({});
30
- const [isValueChanged, setValueChanged] = (0, _react.useState)(false);
31
30
  const [showExpandEditor, setShowExpandEditor] = (0, _react.useState)(false);
32
- const [value, setValue] = (0, _react.useState)(typeof propsValue === 'string' ? {
31
+ const valueRef = (0, _react.useRef)(typeof propsValue === 'string' ? {
33
32
  text: propsValue
34
33
  } : propsValue);
34
+ const valueChangedRef = (0, _react.useRef)(false);
35
35
  const saveValue = (0, _react.useCallback)(function (value) {
36
36
  let save = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
37
- setValueChanged(true);
38
- setValue(value);
37
+ valueChangedRef.current = true;
39
38
  onEditorValueChanged && onEditorValueChanged(value);
40
39
  if (!save) return;
41
40
  onSaveEditorValue && onSaveEditorValue(value);
42
- setValueChanged(false);
41
+ valueChangedRef.current = false;
43
42
  }, [onSaveEditorValue, onEditorValueChanged]);
44
43
  const handelAutoSave = (0, _react.useCallback)(() => {
45
- if (!isValueChanged) return;
46
- saveValue(value, true);
47
- }, [isValueChanged, value, saveValue]);
44
+ if (!valueChangedRef.current) return;
45
+ saveValue(valueRef.current, true);
46
+ }, [saveValue]);
48
47
  const onContentChanged = (0, _react.useCallback)(() => {
49
48
  // delay to update editor's content
50
49
  setTimeout(() => {
@@ -58,14 +57,14 @@ const NormalEditor = _ref => {
58
57
  links,
59
58
  checklist
60
59
  } = (0, _getPreviewContent.default)(slateNodes, false);
61
- const value = {
60
+ valueRef.current = {
62
61
  text: markdownString,
63
62
  preview: previewText,
64
63
  images: images,
65
64
  links: links,
66
65
  checklist
67
66
  };
68
- saveValue(value);
67
+ saveValue(valueRef.current);
69
68
  }, 0);
70
69
  }, [saveValue]);
71
70
  const openEditorDialog = (0, _react.useCallback)(() => {
@@ -78,7 +77,8 @@ const NormalEditor = _ref => {
78
77
  setShowExpandEditor(true);
79
78
  }, [editorContainerRef]);
80
79
  const onCloseEditorDialog = (0, _react.useCallback)(value => {
81
- value && saveValue(value);
80
+ valueRef.current = value;
81
+ saveValue(value);
82
82
  setStyle({});
83
83
  setShowExpandEditor(false);
84
84
  }, [saveValue]);
@@ -101,7 +101,7 @@ const NormalEditor = _ref => {
101
101
  ref: editorRef,
102
102
  isInline: true,
103
103
  focusNodePath: focusNodePath,
104
- value: value.text,
104
+ value: valueRef.current.text,
105
105
  onSave: handelAutoSave,
106
106
  editorApi: editorApi,
107
107
  onContentChanged: onContentChanged,
@@ -113,13 +113,13 @@ const NormalEditor = _ref => {
113
113
  }), /*#__PURE__*/_react.default.createElement("div", {
114
114
  className: "sf-slate-editor-content"
115
115
  }, /*#__PURE__*/_react.default.createElement(_markdownPreview.default, {
116
- value: value.text,
116
+ value: valueRef.current.text,
117
117
  isShowOutline: false
118
118
  })))), showExpandEditor && /*#__PURE__*/_react.default.createElement(_longtextEditorDialog.default, {
119
119
  lang: lang,
120
120
  readOnly: false,
121
121
  headerName: headerName,
122
- value: value.text,
122
+ value: valueRef.current.text,
123
123
  autoSave: autoSave,
124
124
  saveDelay: saveDelay,
125
125
  isCheckBrowser: isCheckBrowser,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/seafile-editor",
3
- "version": "1.0.85beta12",
3
+ "version": "1.0.85beta14",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {