@remirror/extension-yjs 3.0.14 → 4.0.0-beta.0

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.
@@ -0,0 +1,154 @@
1
+ import { AcceptUndefined } from '@remirror/core';
2
+ import { DecorationAttrs } from '@remirror/pm/view';
3
+ import type { Doc } from 'yjs';
4
+ import { EditorState } from '@remirror/core';
5
+ import { KeyBindingProps } from '@remirror/core';
6
+ import { NonChainableCommandFunction } from '@remirror/core';
7
+ import { OnSetOptionsProps } from '@remirror/core';
8
+ import { PlainExtension } from '@remirror/core';
9
+ import { ProsemirrorPlugin } from '@remirror/core';
10
+ import { Selection as Selection_2 } from '@remirror/core';
11
+ import { Shape } from '@remirror/core';
12
+ import { Static } from '@remirror/core';
13
+
14
+ export declare interface ColorDef {
15
+ light: string;
16
+ dark: string;
17
+ }
18
+
19
+ /**
20
+ * The default destroy provider method.
21
+ */
22
+ declare function defaultDestroyProvider(provider: YjsRealtimeProvider): void;
23
+ export { defaultDestroyProvider }
24
+ export { defaultDestroyProvider as defaultDestroyProvider_alias_1 }
25
+
26
+ /**
27
+ * The YJS extension is the recommended extension for creating a collaborative
28
+ * editor.
29
+ */
30
+ declare class YjsExtension extends PlainExtension<YjsOptions> {
31
+ get name(): "yjs";
32
+ private _provider?;
33
+ /**
34
+ * The provider that is being used for the editor.
35
+ */
36
+ get provider(): YjsRealtimeProvider;
37
+ getBinding(): {
38
+ mapping: Map<any, any>;
39
+ } | undefined;
40
+ /**
41
+ * Create the yjs plugins.
42
+ */
43
+ createExternalPlugins(): ProsemirrorPlugin[];
44
+ /**
45
+ * This managers the updates of the collaboration provider.
46
+ */
47
+ onSetOptions(props: OnSetOptionsProps<YjsOptions>): void;
48
+ /**
49
+ * Remove the provider from the manager.
50
+ */
51
+ onDestroy(): void;
52
+ /**
53
+ * Undo that last Yjs transaction(s)
54
+ *
55
+ * This command does **not** support chaining.
56
+ * This command is a no-op and always returns `false` when the `disableUndo` option is set.
57
+ */
58
+ yUndo(): NonChainableCommandFunction;
59
+ /**
60
+ * Redo the last transaction undone with a previous `yUndo` command.
61
+ *
62
+ * This command does **not** support chaining.
63
+ * This command is a no-op and always returns `false` when the `disableUndo` option is set.
64
+ */
65
+ yRedo(): NonChainableCommandFunction;
66
+ /**
67
+ * Handle the undo keybinding.
68
+ */
69
+ undoShortcut(props: KeyBindingProps): boolean;
70
+ /**
71
+ * Handle the redo keybinding for the editor.
72
+ */
73
+ redoShortcut(props: KeyBindingProps): boolean;
74
+ }
75
+ export { YjsExtension }
76
+ export { YjsExtension as YjsExtension_alias_1 }
77
+
78
+ declare interface YjsOptions<Provider extends YjsRealtimeProvider = YjsRealtimeProvider> {
79
+ /**
80
+ * Get the provider for this extension.
81
+ */
82
+ getProvider: Provider | (() => Provider);
83
+ /**
84
+ * Remove the active provider. This should only be set at initial construction
85
+ * of the editor.
86
+ */
87
+ destroyProvider?: (provider: Provider) => void;
88
+ /**
89
+ * The options which are passed through to the Yjs sync plugin.
90
+ */
91
+ syncPluginOptions?: AcceptUndefined<YSyncOpts>;
92
+ /**
93
+ * Take the user data and transform it into a html element which is used for
94
+ * the cursor. This is passed into the cursor builder.
95
+ *
96
+ * See https://github.com/yjs/y-prosemirror#remote-cursors
97
+ */
98
+ cursorBuilder?: (user: Shape) => HTMLElement;
99
+ /**
100
+ * Generator for the selection attributes
101
+ */
102
+ selectionBuilder?: (user: Shape) => DecorationAttrs;
103
+ /**
104
+ * By default all editor bindings use the awareness 'cursor' field to
105
+ * propagate cursor information.
106
+ *
107
+ * @defaultValue 'cursor'
108
+ */
109
+ cursorStateField?: string;
110
+ /**
111
+ * Get the current editor selection.
112
+ *
113
+ * @defaultValue `(state) => state.selection`
114
+ */
115
+ getSelection?: (state: EditorState) => Selection_2;
116
+ disableUndo?: Static<boolean>;
117
+ /**
118
+ * Names of nodes in the editor which should be protected.
119
+ *
120
+ * @defaultValue `new Set('paragraph')`
121
+ */
122
+ protectedNodes?: Static<Set<string>>;
123
+ trackedOrigins?: Static<any[]>;
124
+ }
125
+ export { YjsOptions }
126
+ export { YjsOptions as YjsOptions_alias_1 }
127
+
128
+ /**
129
+ * yjs typings are very rough; so we define here the interface that we require
130
+ * (y-webrtc and y-websocket providers are both compatible with this interface;
131
+ * no other providers have been checked).
132
+ */
133
+ declare interface YjsRealtimeProvider {
134
+ doc: Doc;
135
+ awareness: any;
136
+ destroy: () => void;
137
+ disconnect: () => void;
138
+ }
139
+
140
+ export declare interface YSyncOpts {
141
+ colors?: ColorDef[];
142
+ colorMapping?: Map<string, ColorDef>;
143
+ permanentUserData?: any | null;
144
+ }
145
+
146
+ export { }
147
+
148
+ declare global {
149
+ namespace Remirror {
150
+ interface AllExtensions {
151
+ yjs: YjsExtension;
152
+ }
153
+ }
154
+ }
@@ -0,0 +1,154 @@
1
+ import { AcceptUndefined } from '@remirror/core';
2
+ import { DecorationAttrs } from '@remirror/pm/view';
3
+ import type { Doc } from 'yjs';
4
+ import { EditorState } from '@remirror/core';
5
+ import { KeyBindingProps } from '@remirror/core';
6
+ import { NonChainableCommandFunction } from '@remirror/core';
7
+ import { OnSetOptionsProps } from '@remirror/core';
8
+ import { PlainExtension } from '@remirror/core';
9
+ import { ProsemirrorPlugin } from '@remirror/core';
10
+ import { Selection as Selection_2 } from '@remirror/core';
11
+ import { Shape } from '@remirror/core';
12
+ import { Static } from '@remirror/core';
13
+
14
+ export declare interface ColorDef {
15
+ light: string;
16
+ dark: string;
17
+ }
18
+
19
+ /**
20
+ * The default destroy provider method.
21
+ */
22
+ declare function defaultDestroyProvider(provider: YjsRealtimeProvider): void;
23
+ export { defaultDestroyProvider }
24
+ export { defaultDestroyProvider as defaultDestroyProvider_alias_1 }
25
+
26
+ /**
27
+ * The YJS extension is the recommended extension for creating a collaborative
28
+ * editor.
29
+ */
30
+ declare class YjsExtension extends PlainExtension<YjsOptions> {
31
+ get name(): "yjs";
32
+ private _provider?;
33
+ /**
34
+ * The provider that is being used for the editor.
35
+ */
36
+ get provider(): YjsRealtimeProvider;
37
+ getBinding(): {
38
+ mapping: Map<any, any>;
39
+ } | undefined;
40
+ /**
41
+ * Create the yjs plugins.
42
+ */
43
+ createExternalPlugins(): ProsemirrorPlugin[];
44
+ /**
45
+ * This managers the updates of the collaboration provider.
46
+ */
47
+ onSetOptions(props: OnSetOptionsProps<YjsOptions>): void;
48
+ /**
49
+ * Remove the provider from the manager.
50
+ */
51
+ onDestroy(): void;
52
+ /**
53
+ * Undo that last Yjs transaction(s)
54
+ *
55
+ * This command does **not** support chaining.
56
+ * This command is a no-op and always returns `false` when the `disableUndo` option is set.
57
+ */
58
+ yUndo(): NonChainableCommandFunction;
59
+ /**
60
+ * Redo the last transaction undone with a previous `yUndo` command.
61
+ *
62
+ * This command does **not** support chaining.
63
+ * This command is a no-op and always returns `false` when the `disableUndo` option is set.
64
+ */
65
+ yRedo(): NonChainableCommandFunction;
66
+ /**
67
+ * Handle the undo keybinding.
68
+ */
69
+ undoShortcut(props: KeyBindingProps): boolean;
70
+ /**
71
+ * Handle the redo keybinding for the editor.
72
+ */
73
+ redoShortcut(props: KeyBindingProps): boolean;
74
+ }
75
+ export { YjsExtension }
76
+ export { YjsExtension as YjsExtension_alias_1 }
77
+
78
+ declare interface YjsOptions<Provider extends YjsRealtimeProvider = YjsRealtimeProvider> {
79
+ /**
80
+ * Get the provider for this extension.
81
+ */
82
+ getProvider: Provider | (() => Provider);
83
+ /**
84
+ * Remove the active provider. This should only be set at initial construction
85
+ * of the editor.
86
+ */
87
+ destroyProvider?: (provider: Provider) => void;
88
+ /**
89
+ * The options which are passed through to the Yjs sync plugin.
90
+ */
91
+ syncPluginOptions?: AcceptUndefined<YSyncOpts>;
92
+ /**
93
+ * Take the user data and transform it into a html element which is used for
94
+ * the cursor. This is passed into the cursor builder.
95
+ *
96
+ * See https://github.com/yjs/y-prosemirror#remote-cursors
97
+ */
98
+ cursorBuilder?: (user: Shape) => HTMLElement;
99
+ /**
100
+ * Generator for the selection attributes
101
+ */
102
+ selectionBuilder?: (user: Shape) => DecorationAttrs;
103
+ /**
104
+ * By default all editor bindings use the awareness 'cursor' field to
105
+ * propagate cursor information.
106
+ *
107
+ * @defaultValue 'cursor'
108
+ */
109
+ cursorStateField?: string;
110
+ /**
111
+ * Get the current editor selection.
112
+ *
113
+ * @defaultValue `(state) => state.selection`
114
+ */
115
+ getSelection?: (state: EditorState) => Selection_2;
116
+ disableUndo?: Static<boolean>;
117
+ /**
118
+ * Names of nodes in the editor which should be protected.
119
+ *
120
+ * @defaultValue `new Set('paragraph')`
121
+ */
122
+ protectedNodes?: Static<Set<string>>;
123
+ trackedOrigins?: Static<any[]>;
124
+ }
125
+ export { YjsOptions }
126
+ export { YjsOptions as YjsOptions_alias_1 }
127
+
128
+ /**
129
+ * yjs typings are very rough; so we define here the interface that we require
130
+ * (y-webrtc and y-websocket providers are both compatible with this interface;
131
+ * no other providers have been checked).
132
+ */
133
+ declare interface YjsRealtimeProvider {
134
+ doc: Doc;
135
+ awareness: any;
136
+ destroy: () => void;
137
+ disconnect: () => void;
138
+ }
139
+
140
+ export declare interface YSyncOpts {
141
+ colors?: ColorDef[];
142
+ colorMapping?: Map<string, ColorDef>;
143
+ permanentUserData?: any | null;
144
+ }
145
+
146
+ export { }
147
+
148
+ declare global {
149
+ namespace Remirror {
150
+ interface AllExtensions {
151
+ yjs: YjsExtension;
152
+ }
153
+ }
154
+ }
@@ -1,31 +1,45 @@
1
+ "use strict";
2
+
3
+ var _initClass, _YjsExtension, _dec, _dec2, _dec3, _dec4, _dec5, _initProto;
4
+ function createAddInitializerMethod(e, t) { return function (r) { assertNotFinished(t, "addInitializer"), assertCallable(r, "An initializer"), e.push(r); }; }
5
+ function assertInstanceIfPrivate(e, t) { if (!e(t)) throw new TypeError("Attempted to access private element on non-instance"); }
6
+ function memberDec(e, t, r, a, n, i, s, o, c, l, u) { var f; switch (i) { case 1: f = "accessor"; break; case 2: f = "method"; break; case 3: f = "getter"; break; case 4: f = "setter"; break; default: f = "field"; } var d, p, h = { kind: f, name: o ? "#" + r : r, static: s, private: o, metadata: u }, v = { v: !1 }; if (0 !== i && (h.addInitializer = createAddInitializerMethod(n, v)), o || 0 !== i && 2 !== i) { if (2 === i) d = function (e) { return assertInstanceIfPrivate(l, e), a.value; };else { var y = 0 === i || 1 === i; (y || 3 === i) && (d = o ? function (e) { return assertInstanceIfPrivate(l, e), a.get.call(e); } : function (e) { return a.get.call(e); }), (y || 4 === i) && (p = o ? function (e, t) { assertInstanceIfPrivate(l, e), a.set.call(e, t); } : function (e, t) { a.set.call(e, t); }); } } else d = function (e) { return e[r]; }, 0 === i && (p = function (e, t) { e[r] = t; }); var m = o ? l.bind() : function (e) { return r in e; }; h.access = d && p ? { get: d, set: p, has: m } : d ? { get: d, has: m } : { set: p, has: m }; try { return e.call(t, c, h); } finally { v.v = !0; } }
7
+ function assertNotFinished(e, t) { if (e.v) throw new Error("attempted to call " + t + " after decoration was finished"); }
8
+ function assertCallable(e, t) { if ("function" != typeof e) throw new TypeError(t + " must be a function"); }
9
+ function assertValidReturnValue(e, t) { var r = typeof t; if (1 === e) { if ("object" !== r || null === t) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0"); void 0 !== t.get && assertCallable(t.get, "accessor.get"), void 0 !== t.set && assertCallable(t.set, "accessor.set"), void 0 !== t.init && assertCallable(t.init, "accessor.init"); } else if ("function" !== r) { var a; throw a = 0 === e ? "field" : 5 === e ? "class" : "method", new TypeError(a + " decorators must return a function or void 0"); } }
10
+ function curryThis1(e) { return function () { return e(this); }; }
11
+ function curryThis2(e) { return function (t) { e(this, t); }; }
12
+ function applyMemberDec(e, t, r, a, n, i, s, o, c, l, u) { var f, d, p, h, v, y, m = r[0]; a || Array.isArray(m) || (m = [m]), o ? f = 0 === i || 1 === i ? { get: curryThis1(r[3]), set: curryThis2(r[4]) } : 3 === i ? { get: r[3] } : 4 === i ? { set: r[3] } : { value: r[3] } : 0 !== i && (f = Object.getOwnPropertyDescriptor(t, n)), 1 === i ? p = { get: f.get, set: f.set } : 2 === i ? p = f.value : 3 === i ? p = f.get : 4 === i && (p = f.set); for (var g = a ? 2 : 1, b = m.length - 1; b >= 0; b -= g) { var I; if (void 0 !== (h = memberDec(m[b], a ? m[b - 1] : void 0, n, f, c, i, s, o, p, l, u))) assertValidReturnValue(i, h), 0 === i ? I = h : 1 === i ? (I = h.init, v = h.get || p.get, y = h.set || p.set, p = { get: v, set: y }) : p = h, void 0 !== I && (void 0 === d ? d = I : "function" == typeof d ? d = [d, I] : d.push(I)); } if (0 === i || 1 === i) { if (void 0 === d) d = function (e, t) { return t; };else if ("function" != typeof d) { var w = d; d = function (e, t) { for (var r = t, a = w.length - 1; a >= 0; a--) r = w[a].call(e, r); return r; }; } else { var M = d; d = function (e, t) { return M.call(e, t); }; } e.push(d); } 0 !== i && (1 === i ? (f.get = p.get, f.set = p.set) : 2 === i ? f.value = p : 3 === i ? f.get = p : 4 === i && (f.set = p), o ? 1 === i ? (e.push(function (e, t) { return p.get.call(e, t); }), e.push(function (e, t) { return p.set.call(e, t); })) : 2 === i ? e.push(p) : e.push(function (e, t) { return p.call(e, t); }) : Object.defineProperty(t, n, f)); }
13
+ function applyMemberDecs(e, t, r, a) { for (var n, i, s, o = [], c = new Map(), l = new Map(), u = 0; u < t.length; u++) { var f = t[u]; if (Array.isArray(f)) { var d, p, h = f[1], v = f[2], y = f.length > 3, m = 16 & h, g = !!(8 & h), b = r; if (h &= 7, g ? (d = e, 0 !== h && (p = i = i || []), y && !s && (s = function (t) { return _checkInRHS(t) === e; }), b = s) : (d = e.prototype, 0 !== h && (p = n = n || [])), 0 !== h && !y) { var I = g ? l : c, w = I.get(v) || 0; if (!0 === w || 3 === w && 4 !== h || 4 === w && 3 !== h) throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + v); I.set(v, !(!w && h > 2) || h); } applyMemberDec(o, d, f, m, v, h, g, y, p, b, a); } } return pushInitializers(o, n), pushInitializers(o, i), o; }
14
+ function pushInitializers(e, t) { t && e.push(function (e) { for (var r = 0; r < t.length; r++) t[r].call(e); return e; }); }
15
+ function applyClassDecs(e, t, r, a) { if (t.length) { for (var n = [], i = e, s = e.name, o = r ? 2 : 1, c = t.length - 1; c >= 0; c -= o) { var l = { v: !1 }; try { var u = t[c].call(r ? t[c - 1] : void 0, i, { kind: "class", name: s, addInitializer: createAddInitializerMethod(n, l), metadata: a }); } finally { l.v = !0; } void 0 !== u && (assertValidReturnValue(5, u), i = u); } return [defineMetadata(i, a), function () { for (var e = 0; e < n.length; e++) n[e].call(i); }]; } }
16
+ function defineMetadata(e, t) { return Object.defineProperty(e, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: t }); }
17
+ function _applyDecs(e, t, r, a, n, i) { if (arguments.length >= 6) var s = i[Symbol.metadata || Symbol.for("Symbol.metadata")]; var o = Object.create(void 0 === s ? null : s), c = applyMemberDecs(e, t, n, o); return r.length || defineMetadata(e, o), { e: c, get c() { return applyClassDecs(e, r, a, o); } }; }
18
+ function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
1
19
  var __defProp = Object.defineProperty;
2
20
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
21
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
22
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
23
  var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
24
+ for (var name in all) __defProp(target, name, {
25
+ get: all[name],
26
+ enumerable: true
27
+ });
8
28
  };
9
29
  var __copyProps = (to, from, except, desc) => {
10
30
  if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
31
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
32
+ get: () => from[key],
33
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
34
+ });
14
35
  }
15
36
  return to;
16
37
  };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var __decorateClass = (decorators, target, key, kind) => {
19
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
20
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
21
- if (decorator = decorators[i])
22
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
23
- if (kind && result)
24
- __defProp(target, key, result);
25
- return result;
26
- };
38
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
39
+ value: true
40
+ }), mod);
27
41
 
28
- // packages/remirror__extension-yjs/src/index.ts
42
+ // src/index.ts
29
43
  var src_exports = {};
30
44
  __export(src_exports, {
31
45
  YjsExtension: () => YjsExtension,
@@ -33,25 +47,84 @@ __export(src_exports, {
33
47
  });
34
48
  module.exports = __toCommonJS(src_exports);
35
49
 
36
- // packages/remirror__extension-yjs/src/yjs-extension.ts
50
+ // src/yjs-extension.ts
37
51
  var import_y_prosemirror = require("y-prosemirror");
38
52
  var import_yjs = require("yjs");
39
53
  var import_core = require("@remirror/core");
40
54
  var import_messages = require("@remirror/messages");
41
- var YjsExtension = class extends import_core.PlainExtension {
55
+ var YjsExtension = ((_dec = (0, import_core.extension)({
56
+ defaultOptions: {
57
+ getProvider: () => {
58
+ (0, import_core.invariant)(false, {
59
+ code: import_core.ErrorConstant.EXTENSION,
60
+ message: "You must provide a YJS Provider to the `YjsExtension`."
61
+ });
62
+ },
63
+ destroyProvider: defaultDestroyProvider,
64
+ syncPluginOptions: void 0,
65
+ cursorBuilder: import_y_prosemirror.defaultCursorBuilder,
66
+ selectionBuilder: import_y_prosemirror.defaultSelectionBuilder,
67
+ cursorStateField: "cursor",
68
+ getSelection: state => state.selection,
69
+ disableUndo: false,
70
+ protectedNodes: new Set("paragraph"),
71
+ trackedOrigins: []
72
+ },
73
+ staticKeys: ["disableUndo", "protectedNodes", "trackedOrigins"],
74
+ defaultPriority: import_core.ExtensionPriority.High
75
+ }), _dec2 = (0, import_core.command)({
76
+ disableChaining: true,
77
+ description: ({
78
+ t
79
+ }) => t(import_messages.ExtensionHistoryMessages.UNDO_DESCRIPTION),
80
+ label: ({
81
+ t
82
+ }) => t(import_messages.ExtensionHistoryMessages.UNDO_LABEL),
83
+ icon: "arrowGoBackFill"
84
+ }), _dec3 = (0, import_core.command)({
85
+ disableChaining: true,
86
+ description: ({
87
+ t
88
+ }) => t(import_messages.ExtensionHistoryMessages.REDO_DESCRIPTION),
89
+ label: ({
90
+ t
91
+ }) => t(import_messages.ExtensionHistoryMessages.REDO_LABEL),
92
+ icon: "arrowGoForwardFill"
93
+ }), _dec4 = (0, import_core.keyBinding)({
94
+ shortcut: import_core.NamedShortcut.Undo,
95
+ command: "yUndo"
96
+ }), _dec5 = (0, import_core.keyBinding)({
97
+ shortcut: import_core.NamedShortcut.Redo,
98
+ command: "yRedo"
99
+ }), class YjsExtension extends import_core.PlainExtension {
100
+ static {
101
+ ({
102
+ e: [_initProto],
103
+ c: [_YjsExtension, _initClass]
104
+ } = _applyDecs(this, [[_dec2, 2, "yUndo"], [_dec3, 2, "yRedo"], [_dec4, 2, "undoShortcut"], [_dec5, 2, "redoShortcut"]], [_dec]));
105
+ }
106
+ constructor(...args) {
107
+ super(...args);
108
+ _initProto(this);
109
+ }
42
110
  get name() {
43
111
  return "yjs";
44
112
  }
113
+ _provider;
45
114
  /**
46
115
  * The provider that is being used for the editor.
47
116
  */
48
117
  get provider() {
49
- const { getProvider } = this.options;
50
- return this._provider ?? (this._provider = getLazyValue(getProvider));
118
+ const {
119
+ getProvider
120
+ } = this.options;
121
+ return this._provider ??= getLazyValue(getProvider);
51
122
  }
52
123
  getBinding() {
53
124
  const state = this.store.getState();
54
- const { binding } = import_y_prosemirror.ySyncPluginKey.getState(state);
125
+ const {
126
+ binding
127
+ } = import_y_prosemirror.ySyncPluginKey.getState(state);
55
128
  return binding;
56
129
  }
57
130
  /**
@@ -70,20 +143,19 @@ var YjsExtension = class extends import_core.PlainExtension {
70
143
  } = this.options;
71
144
  const yDoc = this.provider.doc;
72
145
  const type = yDoc.getXmlFragment("prosemirror");
73
- const plugins = [
74
- (0, import_y_prosemirror.ySyncPlugin)(type, syncPluginOptions),
75
- (0, import_y_prosemirror.yCursorPlugin)(
76
- this.provider.awareness,
77
- { cursorBuilder, getSelection, selectionBuilder },
78
- cursorStateField
79
- )
80
- ];
146
+ const plugins = [(0, import_y_prosemirror.ySyncPlugin)(type, syncPluginOptions), (0, import_y_prosemirror.yCursorPlugin)(this.provider.awareness, {
147
+ cursorBuilder,
148
+ getSelection,
149
+ selectionBuilder
150
+ }, cursorStateField)];
81
151
  if (!disableUndo) {
82
152
  const undoManager = new import_yjs.UndoManager(type, {
83
- trackedOrigins: /* @__PURE__ */ new Set([import_y_prosemirror.ySyncPluginKey, ...trackedOrigins]),
84
- deleteFilter: (item) => (0, import_y_prosemirror.defaultDeleteFilter)(item, protectedNodes)
153
+ trackedOrigins: /* @__PURE__ */new Set([import_y_prosemirror.ySyncPluginKey, ...trackedOrigins]),
154
+ deleteFilter: item => (0, import_y_prosemirror.defaultDeleteFilter)(item, protectedNodes)
85
155
  });
86
- plugins.push((0, import_y_prosemirror.yUndoPlugin)({ undoManager }));
156
+ plugins.push((0, import_y_prosemirror.yUndoPlugin)({
157
+ undoManager
158
+ }));
87
159
  }
88
160
  return plugins;
89
161
  }
@@ -91,20 +163,16 @@ var YjsExtension = class extends import_core.PlainExtension {
91
163
  * This managers the updates of the collaboration provider.
92
164
  */
93
165
  onSetOptions(props) {
94
- var _a, _b;
95
- const { changes, pickChanged } = props;
96
- const changedPluginOptions = pickChanged([
97
- "cursorBuilder",
98
- "cursorStateField",
99
- "getProvider",
100
- "getSelection",
101
- "syncPluginOptions"
102
- ]);
166
+ const {
167
+ changes,
168
+ pickChanged
169
+ } = props;
170
+ const changedPluginOptions = pickChanged(["cursorBuilder", "cursorStateField", "getProvider", "getSelection", "syncPluginOptions"]);
103
171
  if (changes.getProvider.changed) {
104
172
  this._provider = void 0;
105
173
  const previousProvider = getLazyValue(changes.getProvider.previousValue);
106
174
  if (changes.destroyProvider.changed) {
107
- (_b = (_a = changes.destroyProvider).previousValue) == null ? void 0 : _b.call(_a, previousProvider);
175
+ changes.destroyProvider.previousValue?.(previousProvider);
108
176
  } else {
109
177
  this.options.destroyProvider(previousProvider);
110
178
  }
@@ -124,11 +192,14 @@ var YjsExtension = class extends import_core.PlainExtension {
124
192
  this._provider = void 0;
125
193
  }
126
194
  yUndo() {
127
- return (0, import_core.nonChainable)((props) => {
195
+ return (0, import_core.nonChainable)(props => {
128
196
  if (this.options.disableUndo) {
129
197
  return false;
130
198
  }
131
- const { state, dispatch } = props;
199
+ const {
200
+ state,
201
+ dispatch
202
+ } = props;
132
203
  const undoManager = import_y_prosemirror.yUndoPluginKey.getState(state).undoManager;
133
204
  if (undoManager.undoStack.length === 0) {
134
205
  return false;
@@ -140,11 +211,14 @@ var YjsExtension = class extends import_core.PlainExtension {
140
211
  });
141
212
  }
142
213
  yRedo() {
143
- return (0, import_core.nonChainable)((props) => {
214
+ return (0, import_core.nonChainable)(props => {
144
215
  if (this.options.disableUndo) {
145
216
  return false;
146
217
  }
147
- const { state, dispatch } = props;
218
+ const {
219
+ state,
220
+ dispatch
221
+ } = props;
148
222
  const undoManager = import_y_prosemirror.yUndoPluginKey.getState(state).undoManager;
149
223
  if (undoManager.redoStack.length === 0) {
150
224
  return false;
@@ -161,54 +235,14 @@ var YjsExtension = class extends import_core.PlainExtension {
161
235
  redoShortcut(props) {
162
236
  return this.yRedo()(props);
163
237
  }
164
- };
165
- __decorateClass([
166
- (0, import_core.command)({
167
- disableChaining: true,
168
- description: ({ t }) => t(import_messages.ExtensionHistoryMessages.UNDO_DESCRIPTION),
169
- label: ({ t }) => t(import_messages.ExtensionHistoryMessages.UNDO_LABEL),
170
- icon: "arrowGoBackFill"
171
- })
172
- ], YjsExtension.prototype, "yUndo", 1);
173
- __decorateClass([
174
- (0, import_core.command)({
175
- disableChaining: true,
176
- description: ({ t }) => t(import_messages.ExtensionHistoryMessages.REDO_DESCRIPTION),
177
- label: ({ t }) => t(import_messages.ExtensionHistoryMessages.REDO_LABEL),
178
- icon: "arrowGoForwardFill"
179
- })
180
- ], YjsExtension.prototype, "yRedo", 1);
181
- __decorateClass([
182
- (0, import_core.keyBinding)({ shortcut: import_core.NamedShortcut.Undo, command: "yUndo" })
183
- ], YjsExtension.prototype, "undoShortcut", 1);
184
- __decorateClass([
185
- (0, import_core.keyBinding)({ shortcut: import_core.NamedShortcut.Redo, command: "yRedo" })
186
- ], YjsExtension.prototype, "redoShortcut", 1);
187
- YjsExtension = __decorateClass([
188
- (0, import_core.extension)({
189
- defaultOptions: {
190
- getProvider: () => {
191
- (0, import_core.invariant)(false, {
192
- code: import_core.ErrorConstant.EXTENSION,
193
- message: "You must provide a YJS Provider to the `YjsExtension`."
194
- });
195
- },
196
- destroyProvider: defaultDestroyProvider,
197
- syncPluginOptions: void 0,
198
- cursorBuilder: import_y_prosemirror.defaultCursorBuilder,
199
- selectionBuilder: import_y_prosemirror.defaultSelectionBuilder,
200
- cursorStateField: "cursor",
201
- getSelection: (state) => state.selection,
202
- disableUndo: false,
203
- protectedNodes: new Set("paragraph"),
204
- trackedOrigins: []
205
- },
206
- staticKeys: ["disableUndo", "protectedNodes", "trackedOrigins"],
207
- defaultPriority: import_core.ExtensionPriority.High
208
- })
209
- ], YjsExtension);
238
+ static {
239
+ _initClass();
240
+ }
241
+ }), _YjsExtension);
210
242
  function defaultDestroyProvider(provider) {
211
- const { doc } = provider;
243
+ const {
244
+ doc
245
+ } = provider;
212
246
  provider.disconnect();
213
247
  provider.destroy();
214
248
  doc.destroy();
@@ -220,4 +254,4 @@ function getLazyValue(lazyValue) {
220
254
  0 && (module.exports = {
221
255
  YjsExtension,
222
256
  defaultDestroyProvider
223
- });
257
+ });
@@ -0,0 +1,5 @@
1
+ export { YjsOptions } from './_tsup-dts-rollup';
2
+ export { defaultDestroyProvider } from './_tsup-dts-rollup';
3
+ export { YjsExtension } from './_tsup-dts-rollup';
4
+ export { ColorDef } from './_tsup-dts-rollup';
5
+ export { YSyncOpts } from './_tsup-dts-rollup';