@seafile/seafile-editor 1.0.4-3 → 1.0.4-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.
|
@@ -28,10 +28,14 @@ export default function SlateEditor(_ref) {
|
|
|
28
28
|
}, [editor]);
|
|
29
29
|
const onChange = useCallback(value => {
|
|
30
30
|
setSlateValue(value);
|
|
31
|
-
|
|
31
|
+
const operations = editor.operations;
|
|
32
|
+
const modifyOps = operations.filter(o => o.type !== 'set_selection');
|
|
33
|
+
if (modifyOps.length > 0) {
|
|
34
|
+
onSave && onSave(value);
|
|
35
|
+
}
|
|
32
36
|
const eventBus = EventBus.getInstance();
|
|
33
37
|
eventBus.dispatch('change');
|
|
34
|
-
}, [onSave]);
|
|
38
|
+
}, [editor.operations, onSave]);
|
|
35
39
|
|
|
36
40
|
// useMount: focus editor
|
|
37
41
|
useEffect(() => {
|
|
@@ -7,15 +7,17 @@ import './style.css';
|
|
|
7
7
|
export default function SlateViewer(_ref) {
|
|
8
8
|
let {
|
|
9
9
|
value,
|
|
10
|
-
isShowOutline
|
|
10
|
+
isShowOutline,
|
|
11
|
+
scrollRef: externalScrollRef
|
|
11
12
|
} = _ref;
|
|
12
13
|
const scrollRef = useRef(null);
|
|
14
|
+
const containerScrollRef = externalScrollRef ? externalScrollRef : scrollRef;
|
|
13
15
|
return /*#__PURE__*/React.createElement(Slate, {
|
|
14
16
|
editor: baseEditor,
|
|
15
17
|
initialValue: value
|
|
16
18
|
}, /*#__PURE__*/React.createElement(ScrollContext.Provider, {
|
|
17
19
|
value: {
|
|
18
|
-
scrollRef
|
|
20
|
+
scrollRef: containerScrollRef
|
|
19
21
|
}
|
|
20
22
|
}, /*#__PURE__*/React.createElement("div", {
|
|
21
23
|
ref: scrollRef,
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
min-width: 0;
|
|
6
6
|
overflow: auto;
|
|
7
7
|
background: #f4f4f4;
|
|
8
|
-
border: 1px solid #ededed;
|
|
9
8
|
padding: 30px 0 15px;
|
|
10
9
|
}
|
|
11
10
|
|
|
@@ -37,6 +36,12 @@
|
|
|
37
36
|
background: #fff;
|
|
38
37
|
}
|
|
39
38
|
|
|
39
|
+
@media (max-width: 991.98px) {
|
|
40
|
+
.sf-slate-viewer-outline {
|
|
41
|
+
display: none !important;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
40
45
|
@media (max-width: 768px) {
|
|
41
46
|
.sf-slate-viewer-article-container {
|
|
42
47
|
padding: 0 10px;
|
|
@@ -92,12 +92,12 @@ export const insertLink = props => {
|
|
|
92
92
|
const isCollapsed = Range.isCollapsed(selection);
|
|
93
93
|
if (isCollapsed) {
|
|
94
94
|
// If selection is collapsed, we insert a space and then insert link node that help operation easier
|
|
95
|
-
editor.insertText('
|
|
95
|
+
editor.insertText('');
|
|
96
96
|
Editor.insertFragment(editor, [linkNode]);
|
|
97
97
|
// Using insertText directly causes the added Spaces to be added to the linked text, as in the issue above, so replaced by insertFragment
|
|
98
98
|
Editor.insertFragment(editor, [{
|
|
99
99
|
id: slugid.nice(),
|
|
100
|
-
text: '
|
|
100
|
+
text: ''
|
|
101
101
|
}]);
|
|
102
102
|
focusEditor(editor);
|
|
103
103
|
return;
|