@easy-editor/core 0.0.11 → 0.0.12

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/esm/index.js CHANGED
@@ -7661,7 +7661,7 @@ const ensureNode = (node, document) => {
7661
7661
  return nodeInstance;
7662
7662
  };
7663
7663
 
7664
- let _initProto$c, _init__opened, _init_extra__opened, _init_nodes, _init_extra_nodes, _init__dropLocation, _init_extra__dropLocation;
7664
+ let _initProto$c, _init__opened, _init_extra__opened, _init__suspended, _init_extra__suspended, _init_nodes, _init_extra_nodes, _init__dropLocation, _init_extra__dropLocation;
7665
7665
  let DOCUMENT_EVENT = /*#__PURE__*/function (DOCUMENT_EVENT) {
7666
7666
  DOCUMENT_EVENT["ADD"] = "document:add";
7667
7667
  DOCUMENT_EVENT["REMOVE"] = "document:remove";
@@ -7671,7 +7671,7 @@ let DOCUMENT_EVENT = /*#__PURE__*/function (DOCUMENT_EVENT) {
7671
7671
  }({});
7672
7672
  class Document {
7673
7673
  static {
7674
- [_init__opened, _init_extra__opened, _init_nodes, _init_extra_nodes, _init__dropLocation, _init_extra__dropLocation, _initProto$c] = _applyDecs2311(this, [], [[[observable, observable.ref], 17, "_opened"], [[observable, observable.shallow], 17, "nodes"], [[observable, observable.ref], 17, "_dropLocation"], [action, 4, "dropLocation"], [action, 2, "import"], [action, 2, "remove"], [action, 2, "purge"], [action, 2, "createNode"], [action, 2, "internalRemoveNode"], [action, 2, "unlinkNode"], [action, 2, "open"], [action, 2, "close"], [action, 2, "setOpened"]]).e;
7674
+ [_init__opened, _init_extra__opened, _init__suspended, _init_extra__suspended, _init_nodes, _init_extra_nodes, _init__dropLocation, _init_extra__dropLocation, _initProto$c] = _applyDecs2311(this, [], [[[observable, observable.ref], 17, "_opened"], [[observable, observable.ref], 17, "_suspended"], [[observable, observable.shallow], 17, "nodes"], [[observable, observable.ref], 17, "_dropLocation"], [action, 4, "dropLocation"], [action, 2, "import"], [action, 2, "remove"], [action, 2, "purge"], [action, 2, "createNode"], [action, 2, "internalRemoveNode"], [action, 2, "unlinkNode"], [action, 2, "setSuspense"], [action, 2, "open"], [action, 2, "close"]]).e;
7675
7675
  }
7676
7676
  isDocument = (_initProto$c(this), true);
7677
7677
  emitter = createEventBus('Document');
@@ -7682,7 +7682,20 @@ class Document {
7682
7682
  set _opened(v) {
7683
7683
  this.#A = v;
7684
7684
  }
7685
- _blank = (_init_extra__opened(this), true);
7685
+ #B = (_init_extra__opened(this), _init__suspended(this, false));
7686
+ get _suspended() {
7687
+ return this.#B;
7688
+ }
7689
+ set _suspended(v) {
7690
+ this.#B = v;
7691
+ }
7692
+ get suspended() {
7693
+ return this._suspended || !this._opened;
7694
+ }
7695
+ get active() {
7696
+ return !this.suspended;
7697
+ }
7698
+ _blank = (_init_extra__suspended(this), true);
7686
7699
  rootNode = null;
7687
7700
  get root() {
7688
7701
  return this.rootNode;
@@ -7703,12 +7716,12 @@ class Document {
7703
7716
  set fileName(fileName) {
7704
7717
  this.rootNode?.getExtraProp('fileName', true)?.setValue(fileName);
7705
7718
  }
7706
- #B = _init_nodes(this, new Set());
7719
+ #C = _init_nodes(this, new Set());
7707
7720
  get nodes() {
7708
- return this.#B;
7721
+ return this.#C;
7709
7722
  }
7710
7723
  set nodes(v) {
7711
- this.#B = v;
7724
+ this.#C = v;
7712
7725
  }
7713
7726
  get opened() {
7714
7727
  return this._opened;
@@ -7720,12 +7733,12 @@ class Document {
7720
7733
  getHistory() {
7721
7734
  return this.history;
7722
7735
  }
7723
- #C = _init__dropLocation(this, null);
7736
+ #D = _init__dropLocation(this, null);
7724
7737
  get _dropLocation() {
7725
- return this.#C;
7738
+ return this.#D;
7726
7739
  }
7727
7740
  set _dropLocation(v) {
7728
- this.#C = v;
7741
+ this.#D = v;
7729
7742
  }
7730
7743
  set dropLocation(loc) {
7731
7744
  this._dropLocation = loc;
@@ -7862,38 +7875,39 @@ class Document {
7862
7875
  insertNodes(parent, nodes, at, copy) {
7863
7876
  return insertChildren(parent, nodes, at, copy);
7864
7877
  }
7878
+ setSuspense(flag) {
7879
+ if (!this._opened && !flag) {
7880
+ return;
7881
+ }
7882
+ this._suspended = flag;
7883
+ this.simulator?.setSuspense(flag);
7884
+ if (!flag) {
7885
+ this.project.checkExclusive(this);
7886
+ }
7887
+ }
7888
+ suspense() {
7889
+ this.setSuspense(true);
7890
+ }
7891
+ activate() {
7892
+ this.setSuspense(false);
7893
+ }
7865
7894
  open() {
7866
7895
  const originState = this._opened;
7867
7896
  this._opened = true;
7868
7897
  if (originState === false) {
7869
7898
  this.designer.postEvent(DOCUMENT_EVENT.OPEN, this);
7870
7899
  }
7871
- if (this._opened) {
7872
- this.project.checkExclusive(this);
7900
+ if (this._suspended) {
7901
+ this.setSuspense(false);
7873
7902
  } else {
7874
- this.setOpened(false);
7903
+ this.project.checkExclusive(this);
7875
7904
  }
7876
7905
  return this;
7877
7906
  }
7878
7907
  close() {
7879
- this.setOpened(false);
7908
+ this.setSuspense(true);
7880
7909
  this._opened = false;
7881
7910
  }
7882
- setOpened(flag) {
7883
- if (!this._opened && !flag) {
7884
- return;
7885
- }
7886
- this._opened = flag;
7887
- if (!flag) {
7888
- this.project.checkExclusive(this);
7889
- }
7890
- }
7891
- suspense() {
7892
- this.setOpened(false);
7893
- }
7894
- activate() {
7895
- this.setOpened(true);
7896
- }
7897
7911
  isModified() {
7898
7912
  return this.history.isSavePoint();
7899
7913
  }
@@ -7986,7 +8000,7 @@ class Project {
7986
8000
  }
7987
8001
  documentsMap = (_init_extra_documents(this), new Map());
7988
8002
  get currentDocument() {
7989
- return this.documents.find(document => document.opened);
8003
+ return this.documents.find(document => document.active);
7990
8004
  }
7991
8005
  #B = _init__config(this);
7992
8006
  get _config() {
@@ -8100,14 +8114,15 @@ class Project {
8100
8114
  }
8101
8115
  return this.createDocument().open();
8102
8116
  }
8103
- if (typeof idOrDoc === 'string') {
8104
- const got = this.documents.find(doc => doc.id === idOrDoc);
8117
+ if (typeof idOrDoc === 'string' || typeof idOrDoc === 'number') {
8118
+ const got = this.documents.find(item => item.fileName === String(idOrDoc) || String(item.id) === String(idOrDoc));
8105
8119
  if (got) {
8106
8120
  return got.open();
8107
8121
  }
8108
- const data = this.data.componentsTree.find(data => data.fileName === idOrDoc);
8122
+ const data = this.data.componentsTree.find(data => data.fileName === String(idOrDoc));
8109
8123
  if (data) {
8110
- return this.createDocument(data).open();
8124
+ const doc = this.createDocument(data);
8125
+ return doc.open();
8111
8126
  }
8112
8127
  return null;
8113
8128
  }
@@ -8559,6 +8574,9 @@ class Simulator {
8559
8574
  data: snippet.schema
8560
8575
  }));
8561
8576
  }
8577
+ setSuspense(suspended) {
8578
+ return false;
8579
+ }
8562
8580
  setupEvents() {
8563
8581
  this.setupDragAndClick();
8564
8582
  this.setupDetecting();