@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/index.js
CHANGED
|
@@ -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 {
|
|
@@ -7661,7 +7662,7 @@ const ensureNode = (node, document) => {
|
|
|
7661
7662
|
return nodeInstance;
|
|
7662
7663
|
};
|
|
7663
7664
|
|
|
7664
|
-
let _initProto$c, _init__opened, _init_extra__opened, _init_nodes, _init_extra_nodes, _init__dropLocation, _init_extra__dropLocation;
|
|
7665
|
+
let _initProto$c, _init__opened, _init_extra__opened, _init__suspended, _init_extra__suspended, _init_nodes, _init_extra_nodes, _init__dropLocation, _init_extra__dropLocation;
|
|
7665
7666
|
let DOCUMENT_EVENT = /*#__PURE__*/function (DOCUMENT_EVENT) {
|
|
7666
7667
|
DOCUMENT_EVENT["ADD"] = "document:add";
|
|
7667
7668
|
DOCUMENT_EVENT["REMOVE"] = "document:remove";
|
|
@@ -7671,7 +7672,7 @@ let DOCUMENT_EVENT = /*#__PURE__*/function (DOCUMENT_EVENT) {
|
|
|
7671
7672
|
}({});
|
|
7672
7673
|
class Document {
|
|
7673
7674
|
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, "
|
|
7675
|
+
[_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
7676
|
}
|
|
7676
7677
|
isDocument = (_initProto$c(this), true);
|
|
7677
7678
|
emitter = createEventBus('Document');
|
|
@@ -7682,7 +7683,20 @@ class Document {
|
|
|
7682
7683
|
set _opened(v) {
|
|
7683
7684
|
this.#A = v;
|
|
7684
7685
|
}
|
|
7685
|
-
|
|
7686
|
+
#B = (_init_extra__opened(this), _init__suspended(this, false));
|
|
7687
|
+
get _suspended() {
|
|
7688
|
+
return this.#B;
|
|
7689
|
+
}
|
|
7690
|
+
set _suspended(v) {
|
|
7691
|
+
this.#B = v;
|
|
7692
|
+
}
|
|
7693
|
+
get suspended() {
|
|
7694
|
+
return this._suspended || !this._opened;
|
|
7695
|
+
}
|
|
7696
|
+
get active() {
|
|
7697
|
+
return !this.suspended;
|
|
7698
|
+
}
|
|
7699
|
+
_blank = (_init_extra__suspended(this), true);
|
|
7686
7700
|
rootNode = null;
|
|
7687
7701
|
get root() {
|
|
7688
7702
|
return this.rootNode;
|
|
@@ -7703,12 +7717,12 @@ class Document {
|
|
|
7703
7717
|
set fileName(fileName) {
|
|
7704
7718
|
this.rootNode?.getExtraProp('fileName', true)?.setValue(fileName);
|
|
7705
7719
|
}
|
|
7706
|
-
#
|
|
7720
|
+
#C = _init_nodes(this, new Set());
|
|
7707
7721
|
get nodes() {
|
|
7708
|
-
return this.#
|
|
7722
|
+
return this.#C;
|
|
7709
7723
|
}
|
|
7710
7724
|
set nodes(v) {
|
|
7711
|
-
this.#
|
|
7725
|
+
this.#C = v;
|
|
7712
7726
|
}
|
|
7713
7727
|
get opened() {
|
|
7714
7728
|
return this._opened;
|
|
@@ -7720,12 +7734,12 @@ class Document {
|
|
|
7720
7734
|
getHistory() {
|
|
7721
7735
|
return this.history;
|
|
7722
7736
|
}
|
|
7723
|
-
#
|
|
7737
|
+
#D = _init__dropLocation(this, null);
|
|
7724
7738
|
get _dropLocation() {
|
|
7725
|
-
return this.#
|
|
7739
|
+
return this.#D;
|
|
7726
7740
|
}
|
|
7727
7741
|
set _dropLocation(v) {
|
|
7728
|
-
this.#
|
|
7742
|
+
this.#D = v;
|
|
7729
7743
|
}
|
|
7730
7744
|
set dropLocation(loc) {
|
|
7731
7745
|
this._dropLocation = loc;
|
|
@@ -7770,6 +7784,7 @@ class Document {
|
|
|
7770
7784
|
return this.rootNode.export(stage);
|
|
7771
7785
|
}
|
|
7772
7786
|
remove() {
|
|
7787
|
+
this.history.destroy();
|
|
7773
7788
|
this.designer.postEvent(DOCUMENT_EVENT.REMOVE, {
|
|
7774
7789
|
id: this.id
|
|
7775
7790
|
});
|
|
@@ -7862,38 +7877,39 @@ class Document {
|
|
|
7862
7877
|
insertNodes(parent, nodes, at, copy) {
|
|
7863
7878
|
return insertChildren(parent, nodes, at, copy);
|
|
7864
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
|
+
}
|
|
7865
7896
|
open() {
|
|
7866
7897
|
const originState = this._opened;
|
|
7867
7898
|
this._opened = true;
|
|
7868
7899
|
if (originState === false) {
|
|
7869
7900
|
this.designer.postEvent(DOCUMENT_EVENT.OPEN, this);
|
|
7870
7901
|
}
|
|
7871
|
-
if (this.
|
|
7872
|
-
this.
|
|
7902
|
+
if (this._suspended) {
|
|
7903
|
+
this.setSuspense(false);
|
|
7873
7904
|
} else {
|
|
7874
|
-
this.
|
|
7905
|
+
this.project.checkExclusive(this);
|
|
7875
7906
|
}
|
|
7876
7907
|
return this;
|
|
7877
7908
|
}
|
|
7878
7909
|
close() {
|
|
7879
|
-
this.
|
|
7910
|
+
this.setSuspense(true);
|
|
7880
7911
|
this._opened = false;
|
|
7881
7912
|
}
|
|
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
7913
|
isModified() {
|
|
7898
7914
|
return this.history.isSavePoint();
|
|
7899
7915
|
}
|
|
@@ -7986,7 +8002,7 @@ class Project {
|
|
|
7986
8002
|
}
|
|
7987
8003
|
documentsMap = (_init_extra_documents(this), new Map());
|
|
7988
8004
|
get currentDocument() {
|
|
7989
|
-
return this.documents.find(document => document.
|
|
8005
|
+
return this.documents.find(document => document.active);
|
|
7990
8006
|
}
|
|
7991
8007
|
#B = _init__config(this);
|
|
7992
8008
|
get _config() {
|
|
@@ -8085,13 +8101,15 @@ class Project {
|
|
|
8085
8101
|
if (index < 0) {
|
|
8086
8102
|
return logger.warn('document not found', idOrDoc);
|
|
8087
8103
|
}
|
|
8088
|
-
document.remove();
|
|
8089
8104
|
this.documents.splice(index, 1);
|
|
8090
8105
|
this.documentsMap.delete(document.id);
|
|
8091
8106
|
}
|
|
8092
8107
|
getDocument(id) {
|
|
8093
8108
|
return this.documents.find(doc => doc.id === id);
|
|
8094
8109
|
}
|
|
8110
|
+
getDocumentByFileName(fileName) {
|
|
8111
|
+
return this.documents.find(doc => doc.fileName === fileName);
|
|
8112
|
+
}
|
|
8095
8113
|
open(idOrDoc) {
|
|
8096
8114
|
if (!idOrDoc) {
|
|
8097
8115
|
const got = this.documents.find(item => item.isBlank());
|
|
@@ -8100,14 +8118,15 @@ class Project {
|
|
|
8100
8118
|
}
|
|
8101
8119
|
return this.createDocument().open();
|
|
8102
8120
|
}
|
|
8103
|
-
if (typeof idOrDoc === 'string') {
|
|
8104
|
-
const got = this.documents.find(
|
|
8121
|
+
if (typeof idOrDoc === 'string' || typeof idOrDoc === 'number') {
|
|
8122
|
+
const got = this.documents.find(item => item.fileName === String(idOrDoc) || String(item.id) === String(idOrDoc));
|
|
8105
8123
|
if (got) {
|
|
8106
8124
|
return got.open();
|
|
8107
8125
|
}
|
|
8108
|
-
const data = this.data.componentsTree.find(data => data.fileName === idOrDoc);
|
|
8126
|
+
const data = this.data.componentsTree.find(data => data.fileName === String(idOrDoc));
|
|
8109
8127
|
if (data) {
|
|
8110
|
-
|
|
8128
|
+
const doc = this.createDocument(data);
|
|
8129
|
+
return doc.open();
|
|
8111
8130
|
}
|
|
8112
8131
|
return null;
|
|
8113
8132
|
}
|
|
@@ -8559,6 +8578,9 @@ class Simulator {
|
|
|
8559
8578
|
data: snippet.schema
|
|
8560
8579
|
}));
|
|
8561
8580
|
}
|
|
8581
|
+
setSuspense(suspended) {
|
|
8582
|
+
return false;
|
|
8583
|
+
}
|
|
8562
8584
|
setupEvents() {
|
|
8563
8585
|
this.setupDragAndClick();
|
|
8564
8586
|
this.setupDetecting();
|
|
@@ -33,6 +33,7 @@ export declare class Project {
|
|
|
33
33
|
createDocument(schema?: RootSchema): Document;
|
|
34
34
|
removeDocument(idOrDoc: string | Document): void;
|
|
35
35
|
getDocument(id: string): Document | undefined;
|
|
36
|
+
getDocumentByFileName(fileName: string): Document | undefined;
|
|
36
37
|
/**
|
|
37
38
|
* open or create a document
|
|
38
39
|
*/
|
|
@@ -74,6 +74,7 @@ export declare class Simulator {
|
|
|
74
74
|
getComponent(componentName: string): any;
|
|
75
75
|
postEvent(eventName: string, ...data: any[]): void;
|
|
76
76
|
linkSnippet(ref: HTMLElement, snippet: Snippet): () => void;
|
|
77
|
+
setSuspense(suspended: boolean): boolean;
|
|
77
78
|
setupEvents(): void;
|
|
78
79
|
setupDragAndClick(): void;
|
|
79
80
|
setupDetecting(): void;
|