@textbus/collaborate 3.1.6 → 3.1.13

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.
@@ -137,6 +137,7 @@ let Collaborate = class Collaborate {
137
137
  }
138
138
  });
139
139
  this.manager = manager;
140
+ // manager.on()
140
141
  manager.on('stack-item-added', event => {
141
142
  if (event.type === 'undo') {
142
143
  if (event.origin === manager) {
@@ -171,7 +172,10 @@ let Collaborate = class Collaborate {
171
172
  }
172
173
  this.selection.unSelect();
173
174
  });
174
- this.subscriptions.push(this.selection.onChange.subscribe(() => {
175
+ this.subscriptions.push(this.scheduler.onDocFirstChangeFromLocal.subscribe(() => {
176
+ this.historyItems.push(this.getRelativeCursorLocation());
177
+ this.index++;
178
+ }), this.selection.onChange.subscribe(() => {
175
179
  const paths = this.selection.getPaths();
176
180
  this.selectionChangeEvent.next(paths);
177
181
  }), this.scheduler.onDocChanged.pipe(map(item => {
@@ -230,8 +234,9 @@ let Collaborate = class Collaborate {
230
234
  }
231
235
  clear() {
232
236
  var _a;
233
- this.index = 0;
234
- this.historyItems = [];
237
+ const last = this.historyItems.pop();
238
+ this.historyItems = last ? [last] : [];
239
+ this.index = last ? 1 : 0;
235
240
  (_a = this.manager) === null || _a === void 0 ? void 0 : _a.clear();
236
241
  this.changeEvent.next();
237
242
  }
package/bundles/index.js CHANGED
@@ -139,6 +139,7 @@ exports.Collaborate = class Collaborate {
139
139
  }
140
140
  });
141
141
  this.manager = manager;
142
+ // manager.on()
142
143
  manager.on('stack-item-added', event => {
143
144
  if (event.type === 'undo') {
144
145
  if (event.origin === manager) {
@@ -173,7 +174,10 @@ exports.Collaborate = class Collaborate {
173
174
  }
174
175
  this.selection.unSelect();
175
176
  });
176
- this.subscriptions.push(this.selection.onChange.subscribe(() => {
177
+ this.subscriptions.push(this.scheduler.onDocFirstChangeFromLocal.subscribe(() => {
178
+ this.historyItems.push(this.getRelativeCursorLocation());
179
+ this.index++;
180
+ }), this.selection.onChange.subscribe(() => {
177
181
  const paths = this.selection.getPaths();
178
182
  this.selectionChangeEvent.next(paths);
179
183
  }), this.scheduler.onDocChanged.pipe(stream.map(item => {
@@ -232,8 +236,9 @@ exports.Collaborate = class Collaborate {
232
236
  }
233
237
  clear() {
234
238
  var _a;
235
- this.index = 0;
236
- this.historyItems = [];
239
+ const last = this.historyItems.pop();
240
+ this.historyItems = last ? [last] : [];
241
+ this.index = last ? 1 : 0;
237
242
  (_a = this.manager) === null || _a === void 0 ? void 0 : _a.clear();
238
243
  this.changeEvent.next();
239
244
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@textbus/collaborate",
3
- "version": "3.1.6",
3
+ "version": "3.1.13",
4
4
  "description": "Textbus is a rich text editor and framework that is highly customizable and extensible to achieve rich wysiwyg effects.",
5
5
  "main": "./bundles/index.js",
6
6
  "module": "./bundles/index.esm.js",
@@ -27,7 +27,7 @@
27
27
  "dependencies": {
28
28
  "@tanbo/di": "^1.1.4",
29
29
  "@tanbo/stream": "^1.1.9",
30
- "@textbus/core": "^3.1.6",
30
+ "@textbus/core": "^3.1.13",
31
31
  "reflect-metadata": "^0.1.13",
32
32
  "y-protocols": "^1.0.5",
33
33
  "yjs": "^13.5.39"
@@ -50,5 +50,5 @@
50
50
  "bugs": {
51
51
  "url": "https://github.com/textbus/textbus.git/issues"
52
52
  },
53
- "gitHead": "5e41cfd65f8f2331df69c26b80d8efe58f98a454"
53
+ "gitHead": "55f6225a13070e5dd341cff13a3afc9e43dc104e"
54
54
  }