@easy-editor/core 0.0.10 → 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
@@ -6907,9 +6907,6 @@ class NodeChildren {
6907
6907
  if (i === index) {
6908
6908
  return;
6909
6909
  }
6910
- if (index === i) {
6911
- return;
6912
- }
6913
6910
  children.splice(index, 1);
6914
6911
  children.splice(i, 0, node);
6915
6912
  }
@@ -7385,7 +7382,7 @@ let Node$1 = class Node {
7385
7382
  return false;
7386
7383
  }
7387
7384
  insert(node, ref, useMutator = true) {
7388
- if (ref && typeof ref === 'number') {
7385
+ if (ref !== undefined && typeof ref === 'number') {
7389
7386
  const nodeInstance = ensureNode(node, this.document);
7390
7387
  this.children?.internalInsert(nodeInstance, ref, useMutator);
7391
7388
  } else {
@@ -7664,7 +7661,7 @@ const ensureNode = (node, document) => {
7664
7661
  return nodeInstance;
7665
7662
  };
7666
7663
 
7667
- 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;
7668
7665
  let DOCUMENT_EVENT = /*#__PURE__*/function (DOCUMENT_EVENT) {
7669
7666
  DOCUMENT_EVENT["ADD"] = "document:add";
7670
7667
  DOCUMENT_EVENT["REMOVE"] = "document:remove";
@@ -7674,7 +7671,7 @@ let DOCUMENT_EVENT = /*#__PURE__*/function (DOCUMENT_EVENT) {
7674
7671
  }({});
7675
7672
  class Document {
7676
7673
  static {
7677
- [_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;
7678
7675
  }
7679
7676
  isDocument = (_initProto$c(this), true);
7680
7677
  emitter = createEventBus('Document');
@@ -7685,7 +7682,20 @@ class Document {
7685
7682
  set _opened(v) {
7686
7683
  this.#A = v;
7687
7684
  }
7688
- _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);
7689
7699
  rootNode = null;
7690
7700
  get root() {
7691
7701
  return this.rootNode;
@@ -7706,12 +7716,12 @@ class Document {
7706
7716
  set fileName(fileName) {
7707
7717
  this.rootNode?.getExtraProp('fileName', true)?.setValue(fileName);
7708
7718
  }
7709
- #B = _init_nodes(this, new Set());
7719
+ #C = _init_nodes(this, new Set());
7710
7720
  get nodes() {
7711
- return this.#B;
7721
+ return this.#C;
7712
7722
  }
7713
7723
  set nodes(v) {
7714
- this.#B = v;
7724
+ this.#C = v;
7715
7725
  }
7716
7726
  get opened() {
7717
7727
  return this._opened;
@@ -7723,12 +7733,12 @@ class Document {
7723
7733
  getHistory() {
7724
7734
  return this.history;
7725
7735
  }
7726
- #C = _init__dropLocation(this, null);
7736
+ #D = _init__dropLocation(this, null);
7727
7737
  get _dropLocation() {
7728
- return this.#C;
7738
+ return this.#D;
7729
7739
  }
7730
7740
  set _dropLocation(v) {
7731
- this.#C = v;
7741
+ this.#D = v;
7732
7742
  }
7733
7743
  set dropLocation(loc) {
7734
7744
  this._dropLocation = loc;
@@ -7865,38 +7875,39 @@ class Document {
7865
7875
  insertNodes(parent, nodes, at, copy) {
7866
7876
  return insertChildren(parent, nodes, at, copy);
7867
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
+ }
7868
7894
  open() {
7869
7895
  const originState = this._opened;
7870
7896
  this._opened = true;
7871
7897
  if (originState === false) {
7872
7898
  this.designer.postEvent(DOCUMENT_EVENT.OPEN, this);
7873
7899
  }
7874
- if (this._opened) {
7875
- this.project.checkExclusive(this);
7900
+ if (this._suspended) {
7901
+ this.setSuspense(false);
7876
7902
  } else {
7877
- this.setOpened(false);
7903
+ this.project.checkExclusive(this);
7878
7904
  }
7879
7905
  return this;
7880
7906
  }
7881
7907
  close() {
7882
- this.setOpened(false);
7908
+ this.setSuspense(true);
7883
7909
  this._opened = false;
7884
7910
  }
7885
- setOpened(flag) {
7886
- if (!this._opened && !flag) {
7887
- return;
7888
- }
7889
- this._opened = flag;
7890
- if (!flag) {
7891
- this.project.checkExclusive(this);
7892
- }
7893
- }
7894
- suspense() {
7895
- this.setOpened(false);
7896
- }
7897
- activate() {
7898
- this.setOpened(true);
7899
- }
7900
7911
  isModified() {
7901
7912
  return this.history.isSavePoint();
7902
7913
  }
@@ -7989,7 +8000,7 @@ class Project {
7989
8000
  }
7990
8001
  documentsMap = (_init_extra_documents(this), new Map());
7991
8002
  get currentDocument() {
7992
- return this.documents.find(document => document.opened);
8003
+ return this.documents.find(document => document.active);
7993
8004
  }
7994
8005
  #B = _init__config(this);
7995
8006
  get _config() {
@@ -8103,14 +8114,15 @@ class Project {
8103
8114
  }
8104
8115
  return this.createDocument().open();
8105
8116
  }
8106
- if (typeof idOrDoc === 'string') {
8107
- 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));
8108
8119
  if (got) {
8109
8120
  return got.open();
8110
8121
  }
8111
- const data = this.data.componentsTree.find(data => data.fileName === idOrDoc);
8122
+ const data = this.data.componentsTree.find(data => data.fileName === String(idOrDoc));
8112
8123
  if (data) {
8113
- return this.createDocument(data).open();
8124
+ const doc = this.createDocument(data);
8125
+ return doc.open();
8114
8126
  }
8115
8127
  return null;
8116
8128
  }
@@ -8562,6 +8574,9 @@ class Simulator {
8562
8574
  data: snippet.schema
8563
8575
  }));
8564
8576
  }
8577
+ setSuspense(suspended) {
8578
+ return false;
8579
+ }
8565
8580
  setupEvents() {
8566
8581
  this.setupDragAndClick();
8567
8582
  this.setupDetecting();