@remirror/extension-yjs 1.0.20 → 1.0.24

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.
@@ -3,6 +3,8 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var _applyDecoratedDescriptor = require('@babel/runtime/helpers/applyDecoratedDescriptor');
6
+ var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
7
+ var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
6
8
  var yProsemirror = require('y-prosemirror');
7
9
  var yjs = require('yjs');
8
10
  var core = require('@remirror/core');
@@ -10,6 +12,98 @@ var extensionAnnotation = require('@remirror/extension-annotation');
10
12
  var messages = require('@remirror/messages');
11
13
 
12
14
  var _dec, _dec2, _dec3, _dec4, _dec5, _class, _class2;
15
+
16
+ var _excluded = ["from", "to"],
17
+ _excluded2 = ["from", "to"];
18
+
19
+ class YjsAnnotationStore {
20
+ constructor(doc, pmName, mapName, getMapping) {
21
+ this.doc = doc;
22
+ this.getMapping = getMapping;
23
+ this.type = doc.getXmlFragment(pmName);
24
+ this.map = doc.getMap(mapName);
25
+ }
26
+
27
+ addAnnotation(_ref) {
28
+ var from = _ref.from,
29
+ to = _ref.to,
30
+ data = _objectWithoutProperties(_ref, _excluded);
31
+
32
+ // XXX: Why is this cast needed?
33
+ var storedData = _objectSpread(_objectSpread({}, data), {}, {
34
+ from: this.absolutePositionToRelativePosition(from),
35
+ to: this.absolutePositionToRelativePosition(to)
36
+ });
37
+
38
+ this.map.set(data.id, storedData);
39
+ }
40
+
41
+ updateAnnotation(id, updateData) {
42
+ var existing = this.map.get(id);
43
+
44
+ if (!existing) {
45
+ return;
46
+ }
47
+
48
+ this.map.set(id, _objectSpread(_objectSpread({}, updateData), {}, {
49
+ from: existing.from,
50
+ to: existing.to
51
+ }));
52
+ }
53
+
54
+ removeAnnotations(ids) {
55
+ yjs.transact(this.doc, () => {
56
+ ids.forEach(id => this.map.delete(id));
57
+ });
58
+ }
59
+
60
+ setAnnotations(annotations) {
61
+ yjs.transact(this.doc, () => {
62
+ this.map.clear();
63
+ annotations.forEach(annotation => this.addAnnotation(annotation));
64
+ });
65
+ }
66
+
67
+ formatAnnotations() {
68
+ var result = [];
69
+ this.map.forEach(_ref2 => {
70
+ var relFrom = _ref2.from,
71
+ relTo = _ref2.to,
72
+ data = _objectWithoutProperties(_ref2, _excluded2);
73
+
74
+ var from = this.relativePositionToAbsolutePosition(relFrom);
75
+ var to = this.relativePositionToAbsolutePosition(relTo);
76
+
77
+ if (!from || !to) {
78
+ return;
79
+ } // XXX: Why is this cast needed?
80
+
81
+
82
+ result.push(_objectSpread(_objectSpread({}, data), {}, {
83
+ from,
84
+ to
85
+ }));
86
+ });
87
+ return result;
88
+ }
89
+
90
+ absolutePositionToRelativePosition(pos) {
91
+ var mapping = this.getMapping();
92
+ return yProsemirror.absolutePositionToRelativePosition(pos, this.type, mapping);
93
+ }
94
+
95
+ relativePositionToAbsolutePosition(relPos) {
96
+ var mapping = this.getMapping();
97
+ return yProsemirror.relativePositionToAbsolutePosition(this.doc, this.type, relPos, mapping);
98
+ }
99
+
100
+ }
101
+ /**
102
+ * The YJS extension is the recommended extension for creating a collaborative
103
+ * editor.
104
+ */
105
+
106
+
13
107
  var YjsExtension = (_dec = core.extension({
14
108
  defaultOptions: {
15
109
  getProvider: () => {
@@ -23,29 +117,31 @@ var YjsExtension = (_dec = core.extension({
23
117
  cursorBuilder: yProsemirror.defaultCursorBuilder,
24
118
  cursorStateField: 'cursor',
25
119
  getSelection: state => state.selection,
120
+ disableUndo: false,
26
121
  protectedNodes: new Set('paragraph'),
27
122
  trackedOrigins: []
28
123
  },
124
+ staticKeys: ['disableUndo', 'protectedNodes', 'trackedOrigins'],
29
125
  defaultPriority: core.ExtensionPriority.High
30
126
  }), _dec2 = core.command({
31
127
  disableChaining: true,
32
- description: _ref => {
33
- var t = _ref.t;
128
+ description: _ref3 => {
129
+ var t = _ref3.t;
34
130
  return t(messages.ExtensionHistoryMessages.UNDO_DESCRIPTION);
35
131
  },
36
- label: _ref2 => {
37
- var t = _ref2.t;
132
+ label: _ref4 => {
133
+ var t = _ref4.t;
38
134
  return t(messages.ExtensionHistoryMessages.UNDO_LABEL);
39
135
  },
40
136
  icon: 'arrowGoBackFill'
41
137
  }), _dec3 = core.command({
42
138
  disableChaining: true,
43
- description: _ref3 => {
44
- var t = _ref3.t;
139
+ description: _ref5 => {
140
+ var t = _ref5.t;
45
141
  return t(messages.ExtensionHistoryMessages.REDO_DESCRIPTION);
46
142
  },
47
- label: _ref4 => {
48
- var t = _ref4.t;
143
+ label: _ref6 => {
144
+ var t = _ref6.t;
49
145
  return t(messages.ExtensionHistoryMessages.REDO_LABEL);
50
146
  },
51
147
  icon: 'arrowGoForwardFill'
@@ -70,12 +166,24 @@ var YjsExtension = (_dec = core.extension({
70
166
  return (_this$_provider = this._provider) !== null && _this$_provider !== void 0 ? _this$_provider : this._provider = getLazyValue(getProvider);
71
167
  }
72
168
 
169
+ getBinding() {
170
+ var state = this.store.getState();
171
+
172
+ var _ySyncPluginKey$getSt = yProsemirror.ySyncPluginKey.getState(state),
173
+ binding = _ySyncPluginKey$getSt.binding;
174
+
175
+ return binding;
176
+ }
177
+
73
178
  onView() {
74
179
  try {
180
+ var annotationStore = new YjsAnnotationStore(this.provider.doc, 'prosemirror', 'annotations', () => {
181
+ var _this$getBinding;
182
+
183
+ return (_this$getBinding = this.getBinding()) === null || _this$getBinding === void 0 ? void 0 : _this$getBinding.mapping;
184
+ });
75
185
  this.store.manager.getExtension(extensionAnnotation.AnnotationExtension).setOptions({
76
- getMap: () => this.provider.doc.getMap('annotations'),
77
- transformPosition: this.absolutePositionToRelativePosition.bind(this),
78
- transformPositionBeforeRender: this.relativePositionToAbsolutePosition.bind(this)
186
+ getStore: () => annotationStore
79
187
  });
80
188
 
81
189
  var handler = (_update, _origin, _doc, yjsTr) => {
@@ -107,21 +215,28 @@ var YjsExtension = (_dec = core.extension({
107
215
  cursorBuilder = _this$options.cursorBuilder,
108
216
  getSelection = _this$options.getSelection,
109
217
  cursorStateField = _this$options.cursorStateField,
218
+ disableUndo = _this$options.disableUndo,
110
219
  protectedNodes = _this$options.protectedNodes,
111
220
  trackedOrigins = _this$options.trackedOrigins;
112
221
  var yDoc = this.provider.doc;
113
222
  var type = yDoc.getXmlFragment('prosemirror');
114
- var undoManager = new yjs.UndoManager(type, {
115
- trackedOrigins: new Set([yProsemirror.ySyncPluginKey, ...trackedOrigins]),
116
- deleteFilter: item => yProsemirror.defaultDeleteFilter(item, protectedNodes)
117
- });
118
- return [yProsemirror.ySyncPlugin(type, syncPluginOptions), yProsemirror.yCursorPlugin(this.provider.awareness, {
223
+ var plugins = [yProsemirror.ySyncPlugin(type, syncPluginOptions), yProsemirror.yCursorPlugin(this.provider.awareness, {
119
224
  cursorBuilder,
120
225
  cursorStateField,
121
226
  getSelection
122
- }, cursorStateField), yProsemirror.yUndoPlugin({
123
- undoManager
124
- })];
227
+ }, cursorStateField)];
228
+
229
+ if (!disableUndo) {
230
+ var undoManager = new yjs.UndoManager(type, {
231
+ trackedOrigins: new Set([yProsemirror.ySyncPluginKey, ...trackedOrigins]),
232
+ deleteFilter: item => yProsemirror.defaultDeleteFilter(item, protectedNodes)
233
+ });
234
+ plugins.push(yProsemirror.yUndoPlugin({
235
+ undoManager
236
+ }));
237
+ }
238
+
239
+ return plugins;
125
240
  }
126
241
  /**
127
242
  * This managers the updates of the collaboration provider.
@@ -131,14 +246,7 @@ var YjsExtension = (_dec = core.extension({
131
246
  onSetOptions(props) {
132
247
  var changes = props.changes,
133
248
  pickChanged = props.pickChanged;
134
- var changedPluginOptions = pickChanged(['cursorBuilder', 'cursorStateField', 'getProvider', 'getSelection', 'syncPluginOptions', 'protectedNodes', 'trackedOrigins']);
135
-
136
- if (changes.protectedNodes.changed || changes.trackedOrigins.changed) {
137
- // Cannot change these, as we would need a new undo manager instance, and for that
138
- // we would need to unregister the previous instance from the document to avoid
139
- // memory leaks.
140
- throw new Error("Cannot change \"protectedNodes\" or \"trackedOrigins\" options");
141
- }
249
+ var changedPluginOptions = pickChanged(['cursorBuilder', 'cursorStateField', 'getProvider', 'getSelection', 'syncPluginOptions']);
142
250
 
143
251
  if (changes.getProvider.changed) {
144
252
  this._provider = undefined;
@@ -171,16 +279,19 @@ var YjsExtension = (_dec = core.extension({
171
279
  this._provider = undefined;
172
280
  }
173
281
  /**
174
- * Undo within a collaborative editor.
175
- *
176
- * This should be used instead of the built in `undo` command.
282
+ * Undo that last Yjs transaction(s)
177
283
  *
178
284
  * This command does **not** support chaining.
285
+ * This command is a no-op and always returns `false` when the `disableUndo` option is set.
179
286
  */
180
287
 
181
288
 
182
289
  yUndo() {
183
290
  return core.nonChainable(props => {
291
+ if (this.options.disableUndo) {
292
+ return false;
293
+ }
294
+
184
295
  var state = props.state,
185
296
  dispatch = props.dispatch;
186
297
  var undoManager = yProsemirror.yUndoPluginKey.getState(state).undoManager;
@@ -197,16 +308,19 @@ var YjsExtension = (_dec = core.extension({
197
308
  });
198
309
  }
199
310
  /**
200
- * Redo, within a collaborative editor.
201
- *
202
- * This should be used instead of the built in `redo` command.
311
+ * Redo the last transaction undone with a previous `yUndo` command.
203
312
  *
204
313
  * This command does **not** support chaining.
314
+ * This command is a no-op and always returns `false` when the `disableUndo` option is set.
205
315
  */
206
316
 
207
317
 
208
318
  yRedo() {
209
319
  return core.nonChainable(props => {
320
+ if (this.options.disableUndo) {
321
+ return false;
322
+ }
323
+
210
324
  var state = props.state,
211
325
  dispatch = props.dispatch;
212
326
  var undoManager = yProsemirror.yUndoPluginKey.getState(state).undoManager;
@@ -239,26 +353,6 @@ var YjsExtension = (_dec = core.extension({
239
353
  return this.yRedo()(props);
240
354
  }
241
355
 
242
- absolutePositionToRelativePosition(pos) {
243
- var state = this.store.getState();
244
-
245
- var _ySyncPluginKey$getSt = yProsemirror.ySyncPluginKey.getState(state),
246
- type = _ySyncPluginKey$getSt.type,
247
- binding = _ySyncPluginKey$getSt.binding;
248
-
249
- return yProsemirror.absolutePositionToRelativePosition(pos, type, binding.mapping);
250
- }
251
-
252
- relativePositionToAbsolutePosition(relPos) {
253
- var state = this.store.getState();
254
-
255
- var _ySyncPluginKey$getSt2 = yProsemirror.ySyncPluginKey.getState(state),
256
- type = _ySyncPluginKey$getSt2.type,
257
- binding = _ySyncPluginKey$getSt2.binding;
258
-
259
- return yProsemirror.relativePositionToAbsolutePosition(this.provider.doc, type, relPos, binding.mapping);
260
- }
261
-
262
356
  }, (_applyDecoratedDescriptor(_class2.prototype, "yUndo", [_dec2], Object.getOwnPropertyDescriptor(_class2.prototype, "yUndo"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "yRedo", [_dec3], Object.getOwnPropertyDescriptor(_class2.prototype, "yRedo"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "undoShortcut", [_dec4], Object.getOwnPropertyDescriptor(_class2.prototype, "undoShortcut"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "redoShortcut", [_dec5], Object.getOwnPropertyDescriptor(_class2.prototype, "redoShortcut"), _class2.prototype)), _class2)) || _class);
263
357
  /**
264
358
  * The default destroy provider method.
@@ -3,6 +3,8 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var _applyDecoratedDescriptor = require('@babel/runtime/helpers/applyDecoratedDescriptor');
6
+ var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
7
+ var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
6
8
  var yProsemirror = require('y-prosemirror');
7
9
  var yjs = require('yjs');
8
10
  var core = require('@remirror/core');
@@ -10,6 +12,98 @@ var extensionAnnotation = require('@remirror/extension-annotation');
10
12
  var messages = require('@remirror/messages');
11
13
 
12
14
  var _dec, _dec2, _dec3, _dec4, _dec5, _class, _class2;
15
+
16
+ var _excluded = ["from", "to"],
17
+ _excluded2 = ["from", "to"];
18
+
19
+ class YjsAnnotationStore {
20
+ constructor(doc, pmName, mapName, getMapping) {
21
+ this.doc = doc;
22
+ this.getMapping = getMapping;
23
+ this.type = doc.getXmlFragment(pmName);
24
+ this.map = doc.getMap(mapName);
25
+ }
26
+
27
+ addAnnotation(_ref) {
28
+ var from = _ref.from,
29
+ to = _ref.to,
30
+ data = _objectWithoutProperties(_ref, _excluded);
31
+
32
+ // XXX: Why is this cast needed?
33
+ var storedData = _objectSpread(_objectSpread({}, data), {}, {
34
+ from: this.absolutePositionToRelativePosition(from),
35
+ to: this.absolutePositionToRelativePosition(to)
36
+ });
37
+
38
+ this.map.set(data.id, storedData);
39
+ }
40
+
41
+ updateAnnotation(id, updateData) {
42
+ var existing = this.map.get(id);
43
+
44
+ if (!existing) {
45
+ return;
46
+ }
47
+
48
+ this.map.set(id, _objectSpread(_objectSpread({}, updateData), {}, {
49
+ from: existing.from,
50
+ to: existing.to
51
+ }));
52
+ }
53
+
54
+ removeAnnotations(ids) {
55
+ yjs.transact(this.doc, () => {
56
+ ids.forEach(id => this.map.delete(id));
57
+ });
58
+ }
59
+
60
+ setAnnotations(annotations) {
61
+ yjs.transact(this.doc, () => {
62
+ this.map.clear();
63
+ annotations.forEach(annotation => this.addAnnotation(annotation));
64
+ });
65
+ }
66
+
67
+ formatAnnotations() {
68
+ var result = [];
69
+ this.map.forEach(_ref2 => {
70
+ var relFrom = _ref2.from,
71
+ relTo = _ref2.to,
72
+ data = _objectWithoutProperties(_ref2, _excluded2);
73
+
74
+ var from = this.relativePositionToAbsolutePosition(relFrom);
75
+ var to = this.relativePositionToAbsolutePosition(relTo);
76
+
77
+ if (!from || !to) {
78
+ return;
79
+ } // XXX: Why is this cast needed?
80
+
81
+
82
+ result.push(_objectSpread(_objectSpread({}, data), {}, {
83
+ from,
84
+ to
85
+ }));
86
+ });
87
+ return result;
88
+ }
89
+
90
+ absolutePositionToRelativePosition(pos) {
91
+ var mapping = this.getMapping();
92
+ return yProsemirror.absolutePositionToRelativePosition(pos, this.type, mapping);
93
+ }
94
+
95
+ relativePositionToAbsolutePosition(relPos) {
96
+ var mapping = this.getMapping();
97
+ return yProsemirror.relativePositionToAbsolutePosition(this.doc, this.type, relPos, mapping);
98
+ }
99
+
100
+ }
101
+ /**
102
+ * The YJS extension is the recommended extension for creating a collaborative
103
+ * editor.
104
+ */
105
+
106
+
13
107
  var YjsExtension = (_dec = core.extension({
14
108
  defaultOptions: {
15
109
  getProvider: () => {
@@ -20,29 +114,31 @@ var YjsExtension = (_dec = core.extension({
20
114
  cursorBuilder: yProsemirror.defaultCursorBuilder,
21
115
  cursorStateField: 'cursor',
22
116
  getSelection: state => state.selection,
117
+ disableUndo: false,
23
118
  protectedNodes: new Set('paragraph'),
24
119
  trackedOrigins: []
25
120
  },
121
+ staticKeys: ['disableUndo', 'protectedNodes', 'trackedOrigins'],
26
122
  defaultPriority: core.ExtensionPriority.High
27
123
  }), _dec2 = core.command({
28
124
  disableChaining: true,
29
- description: _ref => {
30
- var t = _ref.t;
125
+ description: _ref3 => {
126
+ var t = _ref3.t;
31
127
  return t(messages.ExtensionHistoryMessages.UNDO_DESCRIPTION);
32
128
  },
33
- label: _ref2 => {
34
- var t = _ref2.t;
129
+ label: _ref4 => {
130
+ var t = _ref4.t;
35
131
  return t(messages.ExtensionHistoryMessages.UNDO_LABEL);
36
132
  },
37
133
  icon: 'arrowGoBackFill'
38
134
  }), _dec3 = core.command({
39
135
  disableChaining: true,
40
- description: _ref3 => {
41
- var t = _ref3.t;
136
+ description: _ref5 => {
137
+ var t = _ref5.t;
42
138
  return t(messages.ExtensionHistoryMessages.REDO_DESCRIPTION);
43
139
  },
44
- label: _ref4 => {
45
- var t = _ref4.t;
140
+ label: _ref6 => {
141
+ var t = _ref6.t;
46
142
  return t(messages.ExtensionHistoryMessages.REDO_LABEL);
47
143
  },
48
144
  icon: 'arrowGoForwardFill'
@@ -67,12 +163,24 @@ var YjsExtension = (_dec = core.extension({
67
163
  return (_this$_provider = this._provider) !== null && _this$_provider !== void 0 ? _this$_provider : this._provider = getLazyValue(getProvider);
68
164
  }
69
165
 
166
+ getBinding() {
167
+ var state = this.store.getState();
168
+
169
+ var _ySyncPluginKey$getSt = yProsemirror.ySyncPluginKey.getState(state),
170
+ binding = _ySyncPluginKey$getSt.binding;
171
+
172
+ return binding;
173
+ }
174
+
70
175
  onView() {
71
176
  try {
177
+ var annotationStore = new YjsAnnotationStore(this.provider.doc, 'prosemirror', 'annotations', () => {
178
+ var _this$getBinding;
179
+
180
+ return (_this$getBinding = this.getBinding()) === null || _this$getBinding === void 0 ? void 0 : _this$getBinding.mapping;
181
+ });
72
182
  this.store.manager.getExtension(extensionAnnotation.AnnotationExtension).setOptions({
73
- getMap: () => this.provider.doc.getMap('annotations'),
74
- transformPosition: this.absolutePositionToRelativePosition.bind(this),
75
- transformPositionBeforeRender: this.relativePositionToAbsolutePosition.bind(this)
183
+ getStore: () => annotationStore
76
184
  });
77
185
 
78
186
  var handler = (_update, _origin, _doc, yjsTr) => {
@@ -104,21 +212,28 @@ var YjsExtension = (_dec = core.extension({
104
212
  cursorBuilder = _this$options.cursorBuilder,
105
213
  getSelection = _this$options.getSelection,
106
214
  cursorStateField = _this$options.cursorStateField,
215
+ disableUndo = _this$options.disableUndo,
107
216
  protectedNodes = _this$options.protectedNodes,
108
217
  trackedOrigins = _this$options.trackedOrigins;
109
218
  var yDoc = this.provider.doc;
110
219
  var type = yDoc.getXmlFragment('prosemirror');
111
- var undoManager = new yjs.UndoManager(type, {
112
- trackedOrigins: new Set([yProsemirror.ySyncPluginKey, ...trackedOrigins]),
113
- deleteFilter: item => yProsemirror.defaultDeleteFilter(item, protectedNodes)
114
- });
115
- return [yProsemirror.ySyncPlugin(type, syncPluginOptions), yProsemirror.yCursorPlugin(this.provider.awareness, {
220
+ var plugins = [yProsemirror.ySyncPlugin(type, syncPluginOptions), yProsemirror.yCursorPlugin(this.provider.awareness, {
116
221
  cursorBuilder,
117
222
  cursorStateField,
118
223
  getSelection
119
- }, cursorStateField), yProsemirror.yUndoPlugin({
120
- undoManager
121
- })];
224
+ }, cursorStateField)];
225
+
226
+ if (!disableUndo) {
227
+ var undoManager = new yjs.UndoManager(type, {
228
+ trackedOrigins: new Set([yProsemirror.ySyncPluginKey, ...trackedOrigins]),
229
+ deleteFilter: item => yProsemirror.defaultDeleteFilter(item, protectedNodes)
230
+ });
231
+ plugins.push(yProsemirror.yUndoPlugin({
232
+ undoManager
233
+ }));
234
+ }
235
+
236
+ return plugins;
122
237
  }
123
238
  /**
124
239
  * This managers the updates of the collaboration provider.
@@ -128,14 +243,7 @@ var YjsExtension = (_dec = core.extension({
128
243
  onSetOptions(props) {
129
244
  var changes = props.changes,
130
245
  pickChanged = props.pickChanged;
131
- var changedPluginOptions = pickChanged(['cursorBuilder', 'cursorStateField', 'getProvider', 'getSelection', 'syncPluginOptions', 'protectedNodes', 'trackedOrigins']);
132
-
133
- if (changes.protectedNodes.changed || changes.trackedOrigins.changed) {
134
- // Cannot change these, as we would need a new undo manager instance, and for that
135
- // we would need to unregister the previous instance from the document to avoid
136
- // memory leaks.
137
- throw new Error("Cannot change \"protectedNodes\" or \"trackedOrigins\" options");
138
- }
246
+ var changedPluginOptions = pickChanged(['cursorBuilder', 'cursorStateField', 'getProvider', 'getSelection', 'syncPluginOptions']);
139
247
 
140
248
  if (changes.getProvider.changed) {
141
249
  this._provider = undefined;
@@ -168,16 +276,19 @@ var YjsExtension = (_dec = core.extension({
168
276
  this._provider = undefined;
169
277
  }
170
278
  /**
171
- * Undo within a collaborative editor.
172
- *
173
- * This should be used instead of the built in `undo` command.
279
+ * Undo that last Yjs transaction(s)
174
280
  *
175
281
  * This command does **not** support chaining.
282
+ * This command is a no-op and always returns `false` when the `disableUndo` option is set.
176
283
  */
177
284
 
178
285
 
179
286
  yUndo() {
180
287
  return core.nonChainable(props => {
288
+ if (this.options.disableUndo) {
289
+ return false;
290
+ }
291
+
181
292
  var state = props.state,
182
293
  dispatch = props.dispatch;
183
294
  var undoManager = yProsemirror.yUndoPluginKey.getState(state).undoManager;
@@ -194,16 +305,19 @@ var YjsExtension = (_dec = core.extension({
194
305
  });
195
306
  }
196
307
  /**
197
- * Redo, within a collaborative editor.
198
- *
199
- * This should be used instead of the built in `redo` command.
308
+ * Redo the last transaction undone with a previous `yUndo` command.
200
309
  *
201
310
  * This command does **not** support chaining.
311
+ * This command is a no-op and always returns `false` when the `disableUndo` option is set.
202
312
  */
203
313
 
204
314
 
205
315
  yRedo() {
206
316
  return core.nonChainable(props => {
317
+ if (this.options.disableUndo) {
318
+ return false;
319
+ }
320
+
207
321
  var state = props.state,
208
322
  dispatch = props.dispatch;
209
323
  var undoManager = yProsemirror.yUndoPluginKey.getState(state).undoManager;
@@ -236,26 +350,6 @@ var YjsExtension = (_dec = core.extension({
236
350
  return this.yRedo()(props);
237
351
  }
238
352
 
239
- absolutePositionToRelativePosition(pos) {
240
- var state = this.store.getState();
241
-
242
- var _ySyncPluginKey$getSt = yProsemirror.ySyncPluginKey.getState(state),
243
- type = _ySyncPluginKey$getSt.type,
244
- binding = _ySyncPluginKey$getSt.binding;
245
-
246
- return yProsemirror.absolutePositionToRelativePosition(pos, type, binding.mapping);
247
- }
248
-
249
- relativePositionToAbsolutePosition(relPos) {
250
- var state = this.store.getState();
251
-
252
- var _ySyncPluginKey$getSt2 = yProsemirror.ySyncPluginKey.getState(state),
253
- type = _ySyncPluginKey$getSt2.type,
254
- binding = _ySyncPluginKey$getSt2.binding;
255
-
256
- return yProsemirror.relativePositionToAbsolutePosition(this.provider.doc, type, relPos, binding.mapping);
257
- }
258
-
259
353
  }, (_applyDecoratedDescriptor(_class2.prototype, "yUndo", [_dec2], Object.getOwnPropertyDescriptor(_class2.prototype, "yUndo"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "yRedo", [_dec3], Object.getOwnPropertyDescriptor(_class2.prototype, "yRedo"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "undoShortcut", [_dec4], Object.getOwnPropertyDescriptor(_class2.prototype, "undoShortcut"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "redoShortcut", [_dec5], Object.getOwnPropertyDescriptor(_class2.prototype, "redoShortcut"), _class2.prototype)), _class2)) || _class);
260
354
  /**
261
355
  * The default destroy provider method.