Yuki Takei 1 год назад
Родитель
Сommit
e0016e8624

+ 2 - 2
packages/editor/src/client/services-internal/unified-merge-view/use-unified-merge-view.ts

@@ -7,9 +7,9 @@ import {
 } from '@codemirror/merge';
 import { StateField, ChangeSet } from '@codemirror/state';
 
+import { CollaborativeChange } from '../../../consts/collaborative-change';
 import { deltaToChangeSpecs } from '../../../utils/delta-to-changespecs';
 import type { UseCodeMirrorEditor } from '../../services';
-import { collaborativeChange } from '../../stores/use-collaborative-editor-mode';
 
 
 export const useUnifiedMergeView = (
@@ -46,7 +46,7 @@ export const useUnifiedMergeView = (
         }
 
         for (const e of tr.effects) {
-          if (e.is(collaborativeChange)) {
+          if (e.is(CollaborativeChange)) {
             const changeSpecs = deltaToChangeSpecs(e.value);
             const changeSet = ChangeSet.of(changeSpecs, getOriginalDoc(tr.state).length);
             const effect = originalDocChangeEffect(tr.state, changeSet);

+ 2 - 6
packages/editor/src/client/stores/use-collaborative-editor-mode.ts

@@ -1,6 +1,5 @@
 import { useEffect, useState } from 'react';
 
-import { StateEffect } from '@codemirror/state';
 import { keymap } from '@codemirror/view';
 import type { IUserHasId } from '@growi/core/dist/interfaces';
 import { useGlobalSocket } from '@growi/core/dist/swr';
@@ -9,7 +8,7 @@ import { SocketIOProvider } from 'y-socket.io';
 import * as Y from 'yjs';
 
 import { userColor } from '../../consts';
-import type { Delta } from '../../interfaces';
+import { CollaborativeChange } from '../../consts/collaborative-change';
 import type { UseCodeMirrorEditor } from '../services';
 
 type UserLocalState = {
@@ -19,9 +18,6 @@ type UserLocalState = {
   colorLight: string;
 }
 
-// collaborative changesを通知するための StateEffect
-export const collaborativeChange = StateEffect.define<Delta>();
-
 export const useCollaborativeEditorMode = (
     isEnabled: boolean,
     user?: IUserHasId,
@@ -136,7 +132,7 @@ export const useCollaborativeEditorMode = (
 
       // 外部からの変更があったことを通知
       codeMirrorEditor.view?.dispatch({
-        effects: collaborativeChange.of(event.delta),
+        effects: CollaborativeChange.of(event.delta),
       });
     });
 

+ 5 - 0
packages/editor/src/consts/collaborative-change.ts

@@ -0,0 +1,5 @@
+import { StateEffect } from '@codemirror/state';
+
+import type { Delta } from '../interfaces';
+
+export const CollaborativeChange = StateEffect.define<Delta>();