@remirror/extension-yjs 1.0.8 → 1.0.12
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.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type { YjsOptions } from './yjs-extension';
|
|
2
|
-
export { defaultDestroyProvider, YjsExtension } from './yjs-extension';
|
|
1
|
+
export type { YjsOptions } from './yjs-extension';
|
|
2
|
+
export { defaultDestroyProvider, YjsExtension } from './yjs-extension';
|
|
@@ -1,127 +1,127 @@
|
|
|
1
|
-
import type { Doc } from 'yjs';
|
|
2
|
-
import { AcceptUndefined, EditorState, KeyBindingProps, NonChainableCommandFunction, OnSetOptionsProps, PlainExtension, ProsemirrorPlugin, Selection, Shape } from '@remirror/core';
|
|
3
|
-
export interface ColorDef {
|
|
4
|
-
light: string;
|
|
5
|
-
dark: string;
|
|
6
|
-
}
|
|
7
|
-
export interface YSyncOpts {
|
|
8
|
-
colors?: ColorDef[];
|
|
9
|
-
colorMapping?: Map<string, ColorDef>;
|
|
10
|
-
permanentUserData?: any | null;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* yjs typings are very rough; so we define here the interface that we require
|
|
14
|
-
* (y-webrtc and y-websocket providers are both compatible with this interface;
|
|
15
|
-
* no other providers have been checked).
|
|
16
|
-
*/
|
|
17
|
-
interface YjsRealtimeProvider {
|
|
18
|
-
doc: Doc;
|
|
19
|
-
awareness: any;
|
|
20
|
-
destroy: () => void;
|
|
21
|
-
disconnect: () => void;
|
|
22
|
-
}
|
|
23
|
-
export interface YjsOptions<Provider extends YjsRealtimeProvider = YjsRealtimeProvider> {
|
|
24
|
-
/**
|
|
25
|
-
* Get the provider for this extension.
|
|
26
|
-
*/
|
|
27
|
-
getProvider: Provider | (() => Provider);
|
|
28
|
-
/**
|
|
29
|
-
* Remove the active provider. This should only be set at initial construction
|
|
30
|
-
* of the editor.
|
|
31
|
-
*/
|
|
32
|
-
destroyProvider?: (provider: Provider) => void;
|
|
33
|
-
/**
|
|
34
|
-
* The options which are passed through to the Yjs sync plugin.
|
|
35
|
-
*/
|
|
36
|
-
syncPluginOptions?: AcceptUndefined<YSyncOpts>;
|
|
37
|
-
/**
|
|
38
|
-
* Take the user data and transform it into a html element which is used for
|
|
39
|
-
* the cursor. This is passed into the cursor builder.
|
|
40
|
-
*
|
|
41
|
-
* See https://github.com/yjs/y-prosemirror#remote-cursors
|
|
42
|
-
*/
|
|
43
|
-
cursorBuilder?: (user: Shape) => HTMLElement;
|
|
44
|
-
/**
|
|
45
|
-
* By default all editor bindings use the awareness 'cursor' field to
|
|
46
|
-
* propagate cursor information.
|
|
47
|
-
*
|
|
48
|
-
* @default 'cursor'
|
|
49
|
-
*/
|
|
50
|
-
cursorStateField?: string;
|
|
51
|
-
/**
|
|
52
|
-
* Get the current editor selection.
|
|
53
|
-
*
|
|
54
|
-
* @default `(state) => state.selection`
|
|
55
|
-
*/
|
|
56
|
-
getSelection?: (state: EditorState) => Selection;
|
|
57
|
-
/**
|
|
58
|
-
* Names of nodes in the editor which should be protected.
|
|
59
|
-
*
|
|
60
|
-
* @default `new Set('paragraph')`
|
|
61
|
-
*/
|
|
62
|
-
protectedNodes?: Set<string>;
|
|
63
|
-
trackedOrigins?: any[];
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* The YJS extension is the recommended extension for creating a collaborative
|
|
67
|
-
* editor.
|
|
68
|
-
*/
|
|
69
|
-
export declare class YjsExtension extends PlainExtension<YjsOptions> {
|
|
70
|
-
get name(): "yjs";
|
|
71
|
-
private _provider?;
|
|
72
|
-
/**
|
|
73
|
-
* The provider that is being used for the editor.
|
|
74
|
-
*/
|
|
75
|
-
get provider(): YjsRealtimeProvider;
|
|
76
|
-
onView(): void;
|
|
77
|
-
/**
|
|
78
|
-
* Create the yjs plugins.
|
|
79
|
-
*/
|
|
80
|
-
createExternalPlugins(): ProsemirrorPlugin[];
|
|
81
|
-
/**
|
|
82
|
-
* This managers the updates of the collaboration provider.
|
|
83
|
-
*/
|
|
84
|
-
onSetOptions(props: OnSetOptionsProps<YjsOptions>): void;
|
|
85
|
-
/**
|
|
86
|
-
* Remove the provider from the manager.
|
|
87
|
-
*/
|
|
88
|
-
onDestroy(): void;
|
|
89
|
-
/**
|
|
90
|
-
* Undo within a collaborative editor.
|
|
91
|
-
*
|
|
92
|
-
* This should be used instead of the built in `undo` command.
|
|
93
|
-
*
|
|
94
|
-
* This command does **not** support chaining.
|
|
95
|
-
*/
|
|
96
|
-
yUndo(): NonChainableCommandFunction;
|
|
97
|
-
/**
|
|
98
|
-
* Redo, within a collaborative editor.
|
|
99
|
-
*
|
|
100
|
-
* This should be used instead of the built in `redo` command.
|
|
101
|
-
*
|
|
102
|
-
* This command does **not** support chaining.
|
|
103
|
-
*/
|
|
104
|
-
yRedo(): NonChainableCommandFunction;
|
|
105
|
-
/**
|
|
106
|
-
* Handle the undo keybinding.
|
|
107
|
-
*/
|
|
108
|
-
undoShortcut(props: KeyBindingProps): boolean;
|
|
109
|
-
/**
|
|
110
|
-
* Handle the redo keybinding for the editor.
|
|
111
|
-
*/
|
|
112
|
-
redoShortcut(props: KeyBindingProps): boolean;
|
|
113
|
-
private absolutePositionToRelativePosition;
|
|
114
|
-
private relativePositionToAbsolutePosition;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* The default destroy provider method.
|
|
118
|
-
*/
|
|
119
|
-
export declare function defaultDestroyProvider(provider: YjsRealtimeProvider): void;
|
|
120
|
-
declare global {
|
|
121
|
-
namespace Remirror {
|
|
122
|
-
interface AllExtensions {
|
|
123
|
-
yjs: YjsExtension;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
export {};
|
|
1
|
+
import type { Doc } from 'yjs';
|
|
2
|
+
import { AcceptUndefined, EditorState, KeyBindingProps, NonChainableCommandFunction, OnSetOptionsProps, PlainExtension, ProsemirrorPlugin, Selection, Shape } from '@remirror/core';
|
|
3
|
+
export interface ColorDef {
|
|
4
|
+
light: string;
|
|
5
|
+
dark: string;
|
|
6
|
+
}
|
|
7
|
+
export interface YSyncOpts {
|
|
8
|
+
colors?: ColorDef[];
|
|
9
|
+
colorMapping?: Map<string, ColorDef>;
|
|
10
|
+
permanentUserData?: any | null;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* yjs typings are very rough; so we define here the interface that we require
|
|
14
|
+
* (y-webrtc and y-websocket providers are both compatible with this interface;
|
|
15
|
+
* no other providers have been checked).
|
|
16
|
+
*/
|
|
17
|
+
interface YjsRealtimeProvider {
|
|
18
|
+
doc: Doc;
|
|
19
|
+
awareness: any;
|
|
20
|
+
destroy: () => void;
|
|
21
|
+
disconnect: () => void;
|
|
22
|
+
}
|
|
23
|
+
export interface YjsOptions<Provider extends YjsRealtimeProvider = YjsRealtimeProvider> {
|
|
24
|
+
/**
|
|
25
|
+
* Get the provider for this extension.
|
|
26
|
+
*/
|
|
27
|
+
getProvider: Provider | (() => Provider);
|
|
28
|
+
/**
|
|
29
|
+
* Remove the active provider. This should only be set at initial construction
|
|
30
|
+
* of the editor.
|
|
31
|
+
*/
|
|
32
|
+
destroyProvider?: (provider: Provider) => void;
|
|
33
|
+
/**
|
|
34
|
+
* The options which are passed through to the Yjs sync plugin.
|
|
35
|
+
*/
|
|
36
|
+
syncPluginOptions?: AcceptUndefined<YSyncOpts>;
|
|
37
|
+
/**
|
|
38
|
+
* Take the user data and transform it into a html element which is used for
|
|
39
|
+
* the cursor. This is passed into the cursor builder.
|
|
40
|
+
*
|
|
41
|
+
* See https://github.com/yjs/y-prosemirror#remote-cursors
|
|
42
|
+
*/
|
|
43
|
+
cursorBuilder?: (user: Shape) => HTMLElement;
|
|
44
|
+
/**
|
|
45
|
+
* By default all editor bindings use the awareness 'cursor' field to
|
|
46
|
+
* propagate cursor information.
|
|
47
|
+
*
|
|
48
|
+
* @default 'cursor'
|
|
49
|
+
*/
|
|
50
|
+
cursorStateField?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Get the current editor selection.
|
|
53
|
+
*
|
|
54
|
+
* @default `(state) => state.selection`
|
|
55
|
+
*/
|
|
56
|
+
getSelection?: (state: EditorState) => Selection;
|
|
57
|
+
/**
|
|
58
|
+
* Names of nodes in the editor which should be protected.
|
|
59
|
+
*
|
|
60
|
+
* @default `new Set('paragraph')`
|
|
61
|
+
*/
|
|
62
|
+
protectedNodes?: Set<string>;
|
|
63
|
+
trackedOrigins?: any[];
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The YJS extension is the recommended extension for creating a collaborative
|
|
67
|
+
* editor.
|
|
68
|
+
*/
|
|
69
|
+
export declare class YjsExtension extends PlainExtension<YjsOptions> {
|
|
70
|
+
get name(): "yjs";
|
|
71
|
+
private _provider?;
|
|
72
|
+
/**
|
|
73
|
+
* The provider that is being used for the editor.
|
|
74
|
+
*/
|
|
75
|
+
get provider(): YjsRealtimeProvider;
|
|
76
|
+
onView(): void;
|
|
77
|
+
/**
|
|
78
|
+
* Create the yjs plugins.
|
|
79
|
+
*/
|
|
80
|
+
createExternalPlugins(): ProsemirrorPlugin[];
|
|
81
|
+
/**
|
|
82
|
+
* This managers the updates of the collaboration provider.
|
|
83
|
+
*/
|
|
84
|
+
onSetOptions(props: OnSetOptionsProps<YjsOptions>): void;
|
|
85
|
+
/**
|
|
86
|
+
* Remove the provider from the manager.
|
|
87
|
+
*/
|
|
88
|
+
onDestroy(): void;
|
|
89
|
+
/**
|
|
90
|
+
* Undo within a collaborative editor.
|
|
91
|
+
*
|
|
92
|
+
* This should be used instead of the built in `undo` command.
|
|
93
|
+
*
|
|
94
|
+
* This command does **not** support chaining.
|
|
95
|
+
*/
|
|
96
|
+
yUndo(): NonChainableCommandFunction;
|
|
97
|
+
/**
|
|
98
|
+
* Redo, within a collaborative editor.
|
|
99
|
+
*
|
|
100
|
+
* This should be used instead of the built in `redo` command.
|
|
101
|
+
*
|
|
102
|
+
* This command does **not** support chaining.
|
|
103
|
+
*/
|
|
104
|
+
yRedo(): NonChainableCommandFunction;
|
|
105
|
+
/**
|
|
106
|
+
* Handle the undo keybinding.
|
|
107
|
+
*/
|
|
108
|
+
undoShortcut(props: KeyBindingProps): boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Handle the redo keybinding for the editor.
|
|
111
|
+
*/
|
|
112
|
+
redoShortcut(props: KeyBindingProps): boolean;
|
|
113
|
+
private absolutePositionToRelativePosition;
|
|
114
|
+
private relativePositionToAbsolutePosition;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* The default destroy provider method.
|
|
118
|
+
*/
|
|
119
|
+
export declare function defaultDestroyProvider(provider: YjsRealtimeProvider): void;
|
|
120
|
+
declare global {
|
|
121
|
+
namespace Remirror {
|
|
122
|
+
interface AllExtensions {
|
|
123
|
+
yjs: YjsExtension;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remirror/extension-yjs",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"description": "Realtime collaboration with yjs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"remirror",
|
|
@@ -44,19 +44,19 @@
|
|
|
44
44
|
],
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@babel/runtime": "^7.13.10",
|
|
47
|
-
"@remirror/core": "^1.
|
|
48
|
-
"@remirror/extension-annotation": "^1.1.
|
|
49
|
-
"@remirror/messages": "^1.0.
|
|
47
|
+
"@remirror/core": "^1.2.2",
|
|
48
|
+
"@remirror/extension-annotation": "^1.1.4",
|
|
49
|
+
"@remirror/messages": "^1.0.5",
|
|
50
50
|
"y-prosemirror": "^1.0.9",
|
|
51
51
|
"y-protocols": "^1.0.5"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@remirror/pm": "^1.0.
|
|
54
|
+
"@remirror/pm": "^1.0.6",
|
|
55
55
|
"y-webrtc": "^10.2.0",
|
|
56
56
|
"yjs": "^13.5.11"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"@remirror/pm": "^1.0.
|
|
59
|
+
"@remirror/pm": "^1.0.6",
|
|
60
60
|
"yjs": "^13.4.0"
|
|
61
61
|
},
|
|
62
62
|
"publishConfig": {
|