@easy-editor/core 0.0.11 → 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.
- package/dist/cjs/index.development.js +57 -35
- package/dist/cjs/index.development.js.map +1 -1
- package/dist/cjs/index.js +57 -35
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.production.js +57 -35
- package/dist/cjs/index.production.js.map +1 -1
- package/dist/document/document.d.ts +15 -4
- package/dist/document/history.d.ts +1 -0
- package/dist/esm/index.development.js +57 -35
- package/dist/esm/index.development.js.map +1 -1
- package/dist/esm/index.js +57 -35
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.production.js +57 -35
- package/dist/esm/index.production.js.map +1 -1
- package/dist/index.js +57 -35
- package/dist/project/project.d.ts +1 -0
- package/dist/simulator/simulator.d.ts +1 -0
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -5677,7 +5677,7 @@ class History {
|
|
|
5677
5677
|
this.document = document;
|
|
5678
5678
|
this.session = new Session(0, '', this.timeGap);
|
|
5679
5679
|
this.records = [this.session];
|
|
5680
|
-
reaction(() => {
|
|
5680
|
+
this.disposer = reaction(() => {
|
|
5681
5681
|
return dataFn();
|
|
5682
5682
|
}, data => {
|
|
5683
5683
|
if (this.asleep) return;
|
|
@@ -5764,6 +5764,7 @@ class History {
|
|
|
5764
5764
|
}
|
|
5765
5765
|
destroy() {
|
|
5766
5766
|
this.records = [];
|
|
5767
|
+
this.disposer();
|
|
5767
5768
|
}
|
|
5768
5769
|
getState() {
|
|
5769
5770
|
const {
|
|
@@ -7663,7 +7664,7 @@ const ensureNode = (node, document) => {
|
|
|
7663
7664
|
return nodeInstance;
|
|
7664
7665
|
};
|
|
7665
7666
|
|
|
7666
|
-
let _initProto$c, _init__opened, _init_extra__opened, _init_nodes, _init_extra_nodes, _init__dropLocation, _init_extra__dropLocation;
|
|
7667
|
+
let _initProto$c, _init__opened, _init_extra__opened, _init__suspended, _init_extra__suspended, _init_nodes, _init_extra_nodes, _init__dropLocation, _init_extra__dropLocation;
|
|
7667
7668
|
let DOCUMENT_EVENT = /*#__PURE__*/function (DOCUMENT_EVENT) {
|
|
7668
7669
|
DOCUMENT_EVENT["ADD"] = "document:add";
|
|
7669
7670
|
DOCUMENT_EVENT["REMOVE"] = "document:remove";
|
|
@@ -7673,7 +7674,7 @@ let DOCUMENT_EVENT = /*#__PURE__*/function (DOCUMENT_EVENT) {
|
|
|
7673
7674
|
}({});
|
|
7674
7675
|
class Document {
|
|
7675
7676
|
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, "
|
|
7677
|
+
[_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
7678
|
}
|
|
7678
7679
|
isDocument = (_initProto$c(this), true);
|
|
7679
7680
|
emitter = createEventBus('Document');
|
|
@@ -7684,7 +7685,20 @@ class Document {
|
|
|
7684
7685
|
set _opened(v) {
|
|
7685
7686
|
this.#A = v;
|
|
7686
7687
|
}
|
|
7687
|
-
|
|
7688
|
+
#B = (_init_extra__opened(this), _init__suspended(this, false));
|
|
7689
|
+
get _suspended() {
|
|
7690
|
+
return this.#B;
|
|
7691
|
+
}
|
|
7692
|
+
set _suspended(v) {
|
|
7693
|
+
this.#B = v;
|
|
7694
|
+
}
|
|
7695
|
+
get suspended() {
|
|
7696
|
+
return this._suspended || !this._opened;
|
|
7697
|
+
}
|
|
7698
|
+
get active() {
|
|
7699
|
+
return !this.suspended;
|
|
7700
|
+
}
|
|
7701
|
+
_blank = (_init_extra__suspended(this), true);
|
|
7688
7702
|
rootNode = null;
|
|
7689
7703
|
get root() {
|
|
7690
7704
|
return this.rootNode;
|
|
@@ -7705,12 +7719,12 @@ class Document {
|
|
|
7705
7719
|
set fileName(fileName) {
|
|
7706
7720
|
this.rootNode?.getExtraProp('fileName', true)?.setValue(fileName);
|
|
7707
7721
|
}
|
|
7708
|
-
#
|
|
7722
|
+
#C = _init_nodes(this, new Set());
|
|
7709
7723
|
get nodes() {
|
|
7710
|
-
return this.#
|
|
7724
|
+
return this.#C;
|
|
7711
7725
|
}
|
|
7712
7726
|
set nodes(v) {
|
|
7713
|
-
this.#
|
|
7727
|
+
this.#C = v;
|
|
7714
7728
|
}
|
|
7715
7729
|
get opened() {
|
|
7716
7730
|
return this._opened;
|
|
@@ -7722,12 +7736,12 @@ class Document {
|
|
|
7722
7736
|
getHistory() {
|
|
7723
7737
|
return this.history;
|
|
7724
7738
|
}
|
|
7725
|
-
#
|
|
7739
|
+
#D = _init__dropLocation(this, null);
|
|
7726
7740
|
get _dropLocation() {
|
|
7727
|
-
return this.#
|
|
7741
|
+
return this.#D;
|
|
7728
7742
|
}
|
|
7729
7743
|
set _dropLocation(v) {
|
|
7730
|
-
this.#
|
|
7744
|
+
this.#D = v;
|
|
7731
7745
|
}
|
|
7732
7746
|
set dropLocation(loc) {
|
|
7733
7747
|
this._dropLocation = loc;
|
|
@@ -7772,6 +7786,7 @@ class Document {
|
|
|
7772
7786
|
return this.rootNode.export(stage);
|
|
7773
7787
|
}
|
|
7774
7788
|
remove() {
|
|
7789
|
+
this.history.destroy();
|
|
7775
7790
|
this.designer.postEvent(DOCUMENT_EVENT.REMOVE, {
|
|
7776
7791
|
id: this.id
|
|
7777
7792
|
});
|
|
@@ -7864,38 +7879,39 @@ class Document {
|
|
|
7864
7879
|
insertNodes(parent, nodes, at, copy) {
|
|
7865
7880
|
return insertChildren(parent, nodes, at, copy);
|
|
7866
7881
|
}
|
|
7882
|
+
setSuspense(flag) {
|
|
7883
|
+
if (!this._opened && !flag) {
|
|
7884
|
+
return;
|
|
7885
|
+
}
|
|
7886
|
+
this._suspended = flag;
|
|
7887
|
+
this.simulator?.setSuspense(flag);
|
|
7888
|
+
if (!flag) {
|
|
7889
|
+
this.project.checkExclusive(this);
|
|
7890
|
+
}
|
|
7891
|
+
}
|
|
7892
|
+
suspense() {
|
|
7893
|
+
this.setSuspense(true);
|
|
7894
|
+
}
|
|
7895
|
+
activate() {
|
|
7896
|
+
this.setSuspense(false);
|
|
7897
|
+
}
|
|
7867
7898
|
open() {
|
|
7868
7899
|
const originState = this._opened;
|
|
7869
7900
|
this._opened = true;
|
|
7870
7901
|
if (originState === false) {
|
|
7871
7902
|
this.designer.postEvent(DOCUMENT_EVENT.OPEN, this);
|
|
7872
7903
|
}
|
|
7873
|
-
if (this.
|
|
7874
|
-
this.
|
|
7904
|
+
if (this._suspended) {
|
|
7905
|
+
this.setSuspense(false);
|
|
7875
7906
|
} else {
|
|
7876
|
-
this.
|
|
7907
|
+
this.project.checkExclusive(this);
|
|
7877
7908
|
}
|
|
7878
7909
|
return this;
|
|
7879
7910
|
}
|
|
7880
7911
|
close() {
|
|
7881
|
-
this.
|
|
7912
|
+
this.setSuspense(true);
|
|
7882
7913
|
this._opened = false;
|
|
7883
7914
|
}
|
|
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
7915
|
isModified() {
|
|
7900
7916
|
return this.history.isSavePoint();
|
|
7901
7917
|
}
|
|
@@ -7988,7 +8004,7 @@ class Project {
|
|
|
7988
8004
|
}
|
|
7989
8005
|
documentsMap = (_init_extra_documents(this), new Map());
|
|
7990
8006
|
get currentDocument() {
|
|
7991
|
-
return this.documents.find(document => document.
|
|
8007
|
+
return this.documents.find(document => document.active);
|
|
7992
8008
|
}
|
|
7993
8009
|
#B = _init__config(this);
|
|
7994
8010
|
get _config() {
|
|
@@ -8087,13 +8103,15 @@ class Project {
|
|
|
8087
8103
|
if (index < 0) {
|
|
8088
8104
|
return logger.warn('document not found', idOrDoc);
|
|
8089
8105
|
}
|
|
8090
|
-
document.remove();
|
|
8091
8106
|
this.documents.splice(index, 1);
|
|
8092
8107
|
this.documentsMap.delete(document.id);
|
|
8093
8108
|
}
|
|
8094
8109
|
getDocument(id) {
|
|
8095
8110
|
return this.documents.find(doc => doc.id === id);
|
|
8096
8111
|
}
|
|
8112
|
+
getDocumentByFileName(fileName) {
|
|
8113
|
+
return this.documents.find(doc => doc.fileName === fileName);
|
|
8114
|
+
}
|
|
8097
8115
|
open(idOrDoc) {
|
|
8098
8116
|
if (!idOrDoc) {
|
|
8099
8117
|
const got = this.documents.find(item => item.isBlank());
|
|
@@ -8102,14 +8120,15 @@ class Project {
|
|
|
8102
8120
|
}
|
|
8103
8121
|
return this.createDocument().open();
|
|
8104
8122
|
}
|
|
8105
|
-
if (typeof idOrDoc === 'string') {
|
|
8106
|
-
const got = this.documents.find(
|
|
8123
|
+
if (typeof idOrDoc === 'string' || typeof idOrDoc === 'number') {
|
|
8124
|
+
const got = this.documents.find(item => item.fileName === String(idOrDoc) || String(item.id) === String(idOrDoc));
|
|
8107
8125
|
if (got) {
|
|
8108
8126
|
return got.open();
|
|
8109
8127
|
}
|
|
8110
|
-
const data = this.data.componentsTree.find(data => data.fileName === idOrDoc);
|
|
8128
|
+
const data = this.data.componentsTree.find(data => data.fileName === String(idOrDoc));
|
|
8111
8129
|
if (data) {
|
|
8112
|
-
|
|
8130
|
+
const doc = this.createDocument(data);
|
|
8131
|
+
return doc.open();
|
|
8113
8132
|
}
|
|
8114
8133
|
return null;
|
|
8115
8134
|
}
|
|
@@ -8561,6 +8580,9 @@ class Simulator {
|
|
|
8561
8580
|
data: snippet.schema
|
|
8562
8581
|
}));
|
|
8563
8582
|
}
|
|
8583
|
+
setSuspense(suspended) {
|
|
8584
|
+
return false;
|
|
8585
|
+
}
|
|
8564
8586
|
setupEvents() {
|
|
8565
8587
|
this.setupDragAndClick();
|
|
8566
8588
|
this.setupDetecting();
|