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