@easy-editor/core 0.0.12 → 0.0.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.
@@ -24,6 +24,7 @@ export declare class History<T = RootSchema> {
24
24
  private timeGap;
25
25
  private serialization;
26
26
  setSerialization(serialization: Serialization<T, string>): void;
27
+ private disposer;
27
28
  constructor(dataFn: () => T | null, redoer: (data: T) => void, document?: Document | undefined);
28
29
  /**
29
30
  * check if there is unsaved change for history
@@ -5675,7 +5675,7 @@ class History {
5675
5675
  this.document = document;
5676
5676
  this.session = new Session(0, '', this.timeGap);
5677
5677
  this.records = [this.session];
5678
- reaction(() => {
5678
+ this.disposer = reaction(() => {
5679
5679
  return dataFn();
5680
5680
  }, data => {
5681
5681
  if (this.asleep) return;
@@ -5762,6 +5762,7 @@ class History {
5762
5762
  }
5763
5763
  destroy() {
5764
5764
  this.records = [];
5765
+ this.disposer();
5765
5766
  }
5766
5767
  getState() {
5767
5768
  const {
@@ -7783,6 +7784,7 @@ class Document {
7783
7784
  return this.rootNode.export(stage);
7784
7785
  }
7785
7786
  remove() {
7787
+ this.history.destroy();
7786
7788
  this.designer.postEvent(DOCUMENT_EVENT.REMOVE, {
7787
7789
  id: this.id
7788
7790
  });
@@ -8099,13 +8101,15 @@ class Project {
8099
8101
  if (index < 0) {
8100
8102
  return logger.warn('document not found', idOrDoc);
8101
8103
  }
8102
- document.remove();
8103
8104
  this.documents.splice(index, 1);
8104
8105
  this.documentsMap.delete(document.id);
8105
8106
  }
8106
8107
  getDocument(id) {
8107
8108
  return this.documents.find(doc => doc.id === id);
8108
8109
  }
8110
+ getDocumentByFileName(fileName) {
8111
+ return this.documents.find(doc => doc.fileName === fileName);
8112
+ }
8109
8113
  open(idOrDoc) {
8110
8114
  if (!idOrDoc) {
8111
8115
  const got = this.documents.find(item => item.isBlank());