@seafile/sdoc-editor 0.4.31 → 0.4.32

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.
@@ -37,7 +37,6 @@ const RevisionEditor = forwardRef((_ref, ref) => {
37
37
  editor.openConnection();
38
38
  return () => {
39
39
  editor.closeConnection();
40
- editor.selection = null;
41
40
  };
42
41
 
43
42
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -21,11 +21,11 @@ import { EventBus } from '../../basic-sdk';
21
21
  import { EXTERNAL_EVENT } from '../../constants';
22
22
  const SdocEditor = forwardRef((_ref, ref) => {
23
23
  let {
24
- editor,
24
+ editor: propsEditor,
25
25
  document,
26
26
  isReloading
27
27
  } = _ref;
28
- const validEditor = editor || useMemo(() => {
28
+ const validEditor = propsEditor || useMemo(() => {
29
29
  const defaultEditor = createDefaultEditor();
30
30
  const editorConfig = context.getEditorConfig();
31
31
  const newEditor = withNodeId(withSocketIO(defaultEditor, {
@@ -44,15 +44,19 @@ const SdocEditor = forwardRef((_ref, ref) => {
44
44
  const [slateValue, setSlateValue] = useState(document.children);
45
45
  useEffect(() => {
46
46
  validEditor.readonly = false;
47
- }, [validEditor.readonly]);
47
+ return () => {
48
+ validEditor.selection = null;
49
+ };
50
+
51
+ // eslint-disable-next-line react-hooks/exhaustive-deps
52
+ }, []);
48
53
 
49
54
  // useMount: init socket connection
50
55
  useEffect(() => {
51
- if (editor) return;
56
+ if (propsEditor) return;
52
57
  validEditor.openConnection();
53
58
  return () => {
54
59
  validEditor.closeConnection();
55
- validEditor.selection = null;
56
60
  };
57
61
 
58
62
  // eslint-disable-next-line react-hooks/exhaustive-deps
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "0.4.31",
3
+ "version": "0.4.32",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",