@knotx/plugins-history 0.2.9 → 0.2.11

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.
package/dist/index.cjs CHANGED
@@ -78,9 +78,9 @@ class History extends (_a = core.BasePlugin, _canUndo_dec = [decorators.register
78
78
  super(...arguments);
79
79
  __runInitializers(_init, 5, this);
80
80
  __publicField(this, "name", "history");
81
+ __publicField(this, "isUndoRedo", false);
81
82
  __publicField(this, "history", []);
82
83
  __publicField(this, "currentIndex", -1);
83
- __publicField(this, "isUndoRedo", false);
84
84
  __publicField(this, "maxHistory");
85
85
  __publicField(this, "tagMap", /* @__PURE__ */ new Map());
86
86
  __publicField(this, "operationBuffer", {});
@@ -180,6 +180,9 @@ class History extends (_a = core.BasePlugin, _canUndo_dec = [decorators.register
180
180
  return operation;
181
181
  }
182
182
  pushHistory(state) {
183
+ if (Object.values(state.value).every((operations) => operations.every(core.isEmptyBatchOperation))) {
184
+ return;
185
+ }
183
186
  if (this.currentIndex < this.history.length - 1) {
184
187
  this.history = this.history.slice(0, this.currentIndex + 1);
185
188
  }
package/dist/index.d.cts CHANGED
@@ -11,6 +11,7 @@ declare module '@knotx/core' {
11
11
  }
12
12
  }
13
13
  interface IHistory {
14
+ isUndoRedo: boolean;
14
15
  undo: () => void;
15
16
  redo: () => void;
16
17
  addTag: (tag: string) => void;
@@ -33,9 +34,9 @@ interface HistoryConfig {
33
34
  }
34
35
  declare class History<T extends Record<string, IData> = Record<string, any>> extends BasePlugin<'history', HistoryConfig> {
35
36
  name: "history";
37
+ isUndoRedo: boolean;
36
38
  private history;
37
39
  private currentIndex;
38
- private isUndoRedo;
39
40
  private maxHistory;
40
41
  private tagMap;
41
42
  private operationBuffer;
package/dist/index.d.mts CHANGED
@@ -11,6 +11,7 @@ declare module '@knotx/core' {
11
11
  }
12
12
  }
13
13
  interface IHistory {
14
+ isUndoRedo: boolean;
14
15
  undo: () => void;
15
16
  redo: () => void;
16
17
  addTag: (tag: string) => void;
@@ -33,9 +34,9 @@ interface HistoryConfig {
33
34
  }
34
35
  declare class History<T extends Record<string, IData> = Record<string, any>> extends BasePlugin<'history', HistoryConfig> {
35
36
  name: "history";
37
+ isUndoRedo: boolean;
36
38
  private history;
37
39
  private currentIndex;
38
- private isUndoRedo;
39
40
  private maxHistory;
40
41
  private tagMap;
41
42
  private operationBuffer;
package/dist/index.d.ts CHANGED
@@ -11,6 +11,7 @@ declare module '@knotx/core' {
11
11
  }
12
12
  }
13
13
  interface IHistory {
14
+ isUndoRedo: boolean;
14
15
  undo: () => void;
15
16
  redo: () => void;
16
17
  addTag: (tag: string) => void;
@@ -33,9 +34,9 @@ interface HistoryConfig {
33
34
  }
34
35
  declare class History<T extends Record<string, IData> = Record<string, any>> extends BasePlugin<'history', HistoryConfig> {
35
36
  name: "history";
37
+ isUndoRedo: boolean;
36
38
  private history;
37
39
  private currentIndex;
38
- private isUndoRedo;
39
40
  private maxHistory;
40
41
  private tagMap;
41
42
  private operationBuffer;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { isDraftOperation, isInitOperation, flattenOperations, BasePlugin } from '@knotx/core';
1
+ import { isDraftOperation, isInitOperation, isEmptyBatchOperation, flattenOperations, BasePlugin } from '@knotx/core';
2
2
  import { register, inject, OnInit, OnDestroy } from '@knotx/decorators';
3
3
  import { Subject, tap, debounceTime, pipe } from 'rxjs';
4
4
 
@@ -76,9 +76,9 @@ class History extends (_a = BasePlugin, _canUndo_dec = [register("canUndo")], _c
76
76
  super(...arguments);
77
77
  __runInitializers(_init, 5, this);
78
78
  __publicField(this, "name", "history");
79
+ __publicField(this, "isUndoRedo", false);
79
80
  __publicField(this, "history", []);
80
81
  __publicField(this, "currentIndex", -1);
81
- __publicField(this, "isUndoRedo", false);
82
82
  __publicField(this, "maxHistory");
83
83
  __publicField(this, "tagMap", /* @__PURE__ */ new Map());
84
84
  __publicField(this, "operationBuffer", {});
@@ -178,6 +178,9 @@ class History extends (_a = BasePlugin, _canUndo_dec = [register("canUndo")], _c
178
178
  return operation;
179
179
  }
180
180
  pushHistory(state) {
181
+ if (Object.values(state.value).every((operations) => operations.every(isEmptyBatchOperation))) {
182
+ return;
183
+ }
181
184
  if (this.currentIndex < this.history.length - 1) {
182
185
  this.history = this.history.slice(0, this.currentIndex + 1);
183
186
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knotx/plugins-history",
3
- "version": "0.2.9",
3
+ "version": "0.2.11",
4
4
  "description": "History Plugin for Knotx",
5
5
  "author": "boenfu",
6
6
  "license": "MIT",
@@ -29,13 +29,13 @@
29
29
  ],
30
30
  "dependencies": {
31
31
  "rxjs": "^7.8.1",
32
- "@knotx/decorators": "0.2.7",
33
- "@knotx/core": "0.2.7"
32
+ "@knotx/core": "0.2.9",
33
+ "@knotx/decorators": "0.2.9"
34
34
  },
35
35
  "devDependencies": {
36
- "@knotx/eslint-config": "0.2.7",
37
- "@knotx/typescript-config": "0.2.7",
38
- "@knotx/build-config": "0.2.7"
36
+ "@knotx/build-config": "0.2.9",
37
+ "@knotx/eslint-config": "0.2.9",
38
+ "@knotx/typescript-config": "0.2.9"
39
39
  },
40
40
  "scripts": {
41
41
  "build": "unbuild",