@seafile/seafile-editor 1.0.85-beta13 → 1.0.85-beta15
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,7 +2,6 @@
|
|
|
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
7
|
padding: 16px 12px;
|
|
@@ -30,10 +29,6 @@
|
|
|
30
29
|
color: #212529;
|
|
31
30
|
}
|
|
32
31
|
|
|
33
|
-
.sf-long-text-inline-editor-container.preview .longtext-preview-container .article :first-child {
|
|
34
|
-
margin-top: 0;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
32
|
.sf-long-text-inline-editor-container.preview .longtext-preview-container ol,
|
|
38
33
|
.sf-long-text-inline-editor-container.preview .longtext-preview-container ul {
|
|
39
34
|
padding-inline-start: 40px;
|
|
@@ -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
|
|
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
|
-
|
|
38
|
-
setValue(value);
|
|
37
|
+
valueChangedRef.current = true;
|
|
39
38
|
onEditorValueChanged && onEditorValueChanged(value);
|
|
40
39
|
if (!save) return;
|
|
41
40
|
onSaveEditorValue && onSaveEditorValue(value);
|
|
42
|
-
|
|
41
|
+
valueChangedRef.current = false;
|
|
43
42
|
}, [onSaveEditorValue, onEditorValueChanged]);
|
|
44
43
|
const handelAutoSave = (0, _react.useCallback)(() => {
|
|
45
|
-
if (!
|
|
46
|
-
saveValue(
|
|
47
|
-
}, [
|
|
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
|
-
|
|
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(
|
|
67
|
+
saveValue(valueRef.current);
|
|
69
68
|
}, 0);
|
|
70
69
|
}, [saveValue]);
|
|
71
70
|
const openEditorDialog = (0, _react.useCallback)(() => {
|
|
@@ -78,7 +77,10 @@ const NormalEditor = _ref => {
|
|
|
78
77
|
setShowExpandEditor(true);
|
|
79
78
|
}, [editorContainerRef]);
|
|
80
79
|
const onCloseEditorDialog = (0, _react.useCallback)(value => {
|
|
81
|
-
|
|
80
|
+
if (value) {
|
|
81
|
+
valueRef.current = value;
|
|
82
|
+
saveValue(value);
|
|
83
|
+
}
|
|
82
84
|
setStyle({});
|
|
83
85
|
setShowExpandEditor(false);
|
|
84
86
|
}, [saveValue]);
|
|
@@ -101,7 +103,7 @@ const NormalEditor = _ref => {
|
|
|
101
103
|
ref: editorRef,
|
|
102
104
|
isInline: true,
|
|
103
105
|
focusNodePath: focusNodePath,
|
|
104
|
-
value:
|
|
106
|
+
value: valueRef.current.text,
|
|
105
107
|
onSave: handelAutoSave,
|
|
106
108
|
editorApi: editorApi,
|
|
107
109
|
onContentChanged: onContentChanged,
|
|
@@ -113,13 +115,13 @@ const NormalEditor = _ref => {
|
|
|
113
115
|
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
114
116
|
className: "sf-slate-editor-content"
|
|
115
117
|
}, /*#__PURE__*/_react.default.createElement(_markdownPreview.default, {
|
|
116
|
-
value:
|
|
118
|
+
value: valueRef.current.text,
|
|
117
119
|
isShowOutline: false
|
|
118
120
|
})))), showExpandEditor && /*#__PURE__*/_react.default.createElement(_longtextEditorDialog.default, {
|
|
119
121
|
lang: lang,
|
|
120
122
|
readOnly: false,
|
|
121
123
|
headerName: headerName,
|
|
122
|
-
value:
|
|
124
|
+
value: valueRef.current.text,
|
|
123
125
|
autoSave: autoSave,
|
|
124
126
|
saveDelay: saveDelay,
|
|
125
127
|
isCheckBrowser: isCheckBrowser,
|