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