1- import type {
2- ContainerID ,
3- Cursor ,
4- LoroDoc ,
5- LoroEventBatch ,
6- LoroMap ,
7- Subscription ,
8- } from "loro-crdt" ;
1+ import type { Cursor , LoroEventBatch , LoroMap } from "loro-crdt" ;
92import { Fragment , Slice } from "prosemirror-model" ;
10- import {
11- type EditorState ,
12- Plugin ,
13- PluginKey ,
14- type StateField ,
15- } from "prosemirror-state" ;
3+ import { type EditorState , Plugin , type StateField } from "prosemirror-state" ;
164import type { EditorView } from "prosemirror-view" ;
175
186import {
@@ -29,12 +17,13 @@ import {
2917 safeSetSelection ,
3018 updateLoroToPmState ,
3119} from "./lib" ;
20+ import {
21+ loroSyncPluginKey ,
22+ type LoroSyncPluginProps ,
23+ type LoroSyncPluginState ,
24+ } from "./sync-plugin-key" ;
3225import { configLoroTextStyle } from "./text-style" ;
33- import { loroUndoPluginKey } from "./undo-plugin" ;
34-
35- export const loroSyncPluginKey = new PluginKey < LoroSyncPluginState > (
36- "loro-sync" ,
37- ) ;
26+ import { loroUndoPluginKey } from "./undo-plugin-key" ;
3827
3928type PluginTransactionType =
4029 | {
@@ -48,21 +37,6 @@ type PluginTransactionType =
4837 state : Partial < LoroSyncPluginState > ;
4938 } ;
5039
51- export interface LoroSyncPluginProps {
52- doc : LoroDocType ;
53- mapping ?: LoroNodeMapping ;
54- containerId ?: ContainerID ;
55- }
56-
57- export interface LoroSyncPluginState extends LoroSyncPluginProps {
58- changedBy : "local" | "import" | "checkout" ;
59- mapping : LoroNodeMapping ;
60- snapshot ?: LoroDoc | null ;
61- view ?: EditorView ;
62- containerId ?: ContainerID ;
63- docSubscription ?: Subscription | null ;
64- }
65-
6640export const LoroSyncPlugin = ( props : LoroSyncPluginProps ) : Plugin => {
6741 return new Plugin ( {
6842 key : loroSyncPluginKey ,
0 commit comments