@seafile/sdoc-editor 0.1.55 → 0.1.56
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/basic-sdk/editor.js
CHANGED
|
@@ -42,10 +42,6 @@ var SDocEditor = function SDocEditor(_ref) {
|
|
|
42
42
|
setMenuPosition = _useState6[1];
|
|
43
43
|
var _useCursors = useCursors(editor),
|
|
44
44
|
cursors = _useCursors.cursors;
|
|
45
|
-
var _useState7 = useState({}),
|
|
46
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
47
|
-
forceUpdateValue = _useState8[0],
|
|
48
|
-
setForceUpdateValue = _useState8[1];
|
|
49
45
|
|
|
50
46
|
// init eventHandler
|
|
51
47
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -94,14 +90,10 @@ var SDocEditor = function SDocEditor(_ref) {
|
|
|
94
90
|
}
|
|
95
91
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
96
92
|
}, []);
|
|
97
|
-
var onSelect = useCallback(function () {
|
|
98
|
-
setForceUpdateValue({});
|
|
99
|
-
}, []);
|
|
100
93
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
101
94
|
className: "sdoc-editor-container"
|
|
102
95
|
}, /*#__PURE__*/React.createElement(Toolbar, {
|
|
103
|
-
editor: editor
|
|
104
|
-
forceUpdateValue: forceUpdateValue
|
|
96
|
+
editor: editor
|
|
105
97
|
}), /*#__PURE__*/React.createElement("div", {
|
|
106
98
|
className: "sdoc-editor-content"
|
|
107
99
|
}, /*#__PURE__*/React.createElement(SDocOutline, {
|
|
@@ -121,8 +113,7 @@ var SDocEditor = function SDocEditor(_ref) {
|
|
|
121
113
|
onKeyDown: eventProxy.onKeyDown,
|
|
122
114
|
cursors: cursors,
|
|
123
115
|
onContextMenu: onContextMenu,
|
|
124
|
-
onMouseDown: onMouseDown
|
|
125
|
-
onSelect: onSelect
|
|
116
|
+
onMouseDown: onMouseDown
|
|
126
117
|
})))))), isShowContextMenu && /*#__PURE__*/React.createElement(ContextMenu, {
|
|
127
118
|
editor: editor,
|
|
128
119
|
contextMenuPosition: menuPosition
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import React, { useEffect, useState } from 'react';
|
|
2
3
|
import { ORDERED_LIST, UNORDERED_LIST } from '../constants';
|
|
3
4
|
import { MenuGroup } from '../menu';
|
|
4
5
|
import QuoteMenu from '../plugins/blockquote/menu';
|
|
@@ -11,8 +12,22 @@ import TextStyleMenuList from '../plugins/text-style/menu';
|
|
|
11
12
|
import CodeBlockMenu from '../plugins/code-block/menu';
|
|
12
13
|
import HistoryMenu from './redo-undo';
|
|
13
14
|
import { TableMenu, ActiveTableMenu } from '../plugins/table/menu';
|
|
15
|
+
import EventBus from '../../utils/event-bus';
|
|
14
16
|
var Toolbar = function Toolbar(_ref) {
|
|
15
17
|
var editor = _ref.editor;
|
|
18
|
+
var _useState = useState({}),
|
|
19
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
20
|
+
update = _useState2[1];
|
|
21
|
+
useEffect(function () {
|
|
22
|
+
var onChange = function onChange() {
|
|
23
|
+
return update({});
|
|
24
|
+
};
|
|
25
|
+
var eventBus = EventBus.getInstance();
|
|
26
|
+
var unsubscribe = eventBus.subscribe('change', onChange);
|
|
27
|
+
return function () {
|
|
28
|
+
unsubscribe();
|
|
29
|
+
};
|
|
30
|
+
}, []);
|
|
16
31
|
return /*#__PURE__*/React.createElement("div", {
|
|
17
32
|
className: "sdoc-editor-toolbar"
|
|
18
33
|
}, /*#__PURE__*/React.createElement(MenuGroup, null, /*#__PURE__*/React.createElement(HistoryMenu, {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
var _this = this;
|
|
2
2
|
import { generateCursorData } from '../cursor/helper';
|
|
3
|
+
import EventBus from '../utils/event-bus';
|
|
3
4
|
import SocketManager from './socket-manager';
|
|
4
5
|
var withSocketIO = function withSocketIO(editor, options) {
|
|
5
6
|
var onChange = editor.onChange;
|
|
@@ -33,6 +34,10 @@ var withSocketIO = function withSocketIO(editor, options) {
|
|
|
33
34
|
}
|
|
34
35
|
_socketManager.sendCursorLocation(editor.selection);
|
|
35
36
|
}
|
|
37
|
+
|
|
38
|
+
// dispatch editor change event
|
|
39
|
+
var eventBus = EventBus.getInstance();
|
|
40
|
+
eventBus.dispatch('change');
|
|
36
41
|
onChange();
|
|
37
42
|
};
|
|
38
43
|
return newEditor;
|