@gedit/editor-2d 0.1.114 → 0.1.115
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/lib/browser/editor2d-context-key-service.js +24 -35
- package/lib/browser/editor2d-context-key-service.js.map +1 -1
- package/lib/browser/editor2d-contribution.js +89 -139
- package/lib/browser/editor2d-contribution.js.map +1 -1
- package/lib/browser/editor2d-frontend-module.js +20 -20
- package/lib/browser/editor2d-frontend-module.js.map +1 -1
- package/lib/browser/editor2d-label-provider.d.ts +0 -1
- package/lib/browser/editor2d-label-provider.d.ts.map +1 -1
- package/lib/browser/editor2d-label-provider.js +37 -58
- package/lib/browser/editor2d-label-provider.js.map +1 -1
- package/lib/browser/editor2d-model-provider.js +61 -127
- package/lib/browser/editor2d-model-provider.js.map +1 -1
- package/lib/browser/editor2d-ref-provider-contribution.js +44 -110
- package/lib/browser/editor2d-ref-provider-contribution.js.map +1 -1
- package/lib/browser/editor2d-service.js +66 -85
- package/lib/browser/editor2d-service.js.map +1 -1
- package/lib/browser/model/editor2d-document.d.ts +1 -1
- package/lib/browser/model/editor2d-document.d.ts.map +1 -1
- package/lib/browser/model/editor2d-document.js +358 -526
- package/lib/browser/model/editor2d-document.js.map +1 -1
- package/lib/browser/model/editor2d-iterator.js +27 -67
- package/lib/browser/model/editor2d-iterator.js.map +1 -1
- package/lib/browser/model/editor2d-model-container.js +10 -21
- package/lib/browser/model/editor2d-model-container.js.map +1 -1
- package/lib/browser/model/editor2d-model.js +77 -92
- package/lib/browser/model/editor2d-model.js.map +1 -1
- package/lib/browser/model/editor2d-selection.js +16 -43
- package/lib/browser/model/editor2d-selection.js.map +1 -1
- package/lib/browser/model/editor2d-widget.js +71 -90
- package/lib/browser/model/editor2d-widget.js.map +1 -1
- package/lib/browser/model/editor2d.js +41 -127
- package/lib/browser/model/editor2d.js.map +1 -1
- package/lib/browser/model/utils/anim.utils.js +14 -14
- package/lib/browser/model/utils/anim.utils.js.map +1 -1
- package/lib/browser/playground/canvas-draw-layer.js +45 -69
- package/lib/browser/playground/canvas-draw-layer.js.map +1 -1
- package/lib/browser/playground/canvas-draw.js +142 -244
- package/lib/browser/playground/canvas-draw.js.map +1 -1
- package/lib/browser/playground/canvas-layer.js +54 -101
- package/lib/browser/playground/canvas-layer.js.map +1 -1
- package/lib/browser/playground/entities/document-entity.js +8 -28
- package/lib/browser/playground/entities/document-entity.js.map +1 -1
- package/lib/browser/playground/entities/editor2d-entity.js +14 -37
- package/lib/browser/playground/entities/editor2d-entity.js.map +1 -1
- package/lib/browser/playground/playground-context.d.ts +3 -1
- package/lib/browser/playground/playground-context.d.ts.map +1 -1
- package/lib/browser/playground/playground-context.js +49 -47
- package/lib/browser/playground/playground-context.js.map +1 -1
- package/lib/browser/playground/playground-contribution.js +61 -65
- package/lib/browser/playground/playground-contribution.js.map +1 -1
- package/lib/browser/playground/selection-entity-manager.js +74 -132
- package/lib/browser/playground/selection-entity-manager.js.map +1 -1
- package/lib/browser/playground/selector-extend-icons.js +15 -16
- package/lib/browser/playground/selector-extend-icons.js.map +1 -1
- package/lib/browser/playground/selector-extend-renderer.d.ts +3 -2
- package/lib/browser/playground/selector-extend-renderer.d.ts.map +1 -1
- package/lib/browser/playground/selector-extend-renderer.js +67 -52
- package/lib/browser/playground/selector-extend-renderer.js.map +1 -1
- package/lib/browser/utils/snapshot.js +81 -172
- package/lib/browser/utils/snapshot.js.map +1 -1
- package/package.json +7 -7
- package/src/browser/editor2d-label-provider.ts +1 -15
- package/src/browser/model/editor2d-document.ts +6 -2
- package/src/browser/playground/playground-context.ts +2 -0
- package/src/browser/playground/selector-extend-renderer.tsx +43 -10
|
@@ -1,19 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
3
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
4
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -22,35 +7,23 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
22
7
|
};
|
|
23
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
9
|
exports.Editor2dSelection = void 0;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
10
|
+
const inversify_1 = require("inversify");
|
|
11
|
+
const tree_selection_impl_1 = require("@gedit/tree/lib/browser/tree-selection-impl");
|
|
12
|
+
const tree_1 = require("@gedit/tree");
|
|
28
13
|
var SelectionType = tree_1.TreeSelection.SelectionType;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
14
|
+
let Editor2dSelection = class Editor2dSelection extends tree_selection_impl_1.TreeSelectionServiceImpl {
|
|
15
|
+
get selectedNodes() {
|
|
16
|
+
return this.state.selection();
|
|
33
17
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return _this.addSelection({
|
|
45
|
-
node: node,
|
|
46
|
-
type: SelectionType.TOGGLE
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
Editor2dSelection = __decorate([
|
|
51
|
-
(0, inversify_1.injectable)()
|
|
52
|
-
], Editor2dSelection);
|
|
53
|
-
return Editor2dSelection;
|
|
54
|
-
}(tree_selection_impl_1.TreeSelectionServiceImpl));
|
|
18
|
+
clearSelection() {
|
|
19
|
+
this.selectedNodes.forEach(node => this.addSelection({
|
|
20
|
+
node: node,
|
|
21
|
+
type: SelectionType.TOGGLE
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
Editor2dSelection = __decorate([
|
|
26
|
+
(0, inversify_1.injectable)()
|
|
27
|
+
], Editor2dSelection);
|
|
55
28
|
exports.Editor2dSelection = Editor2dSelection;
|
|
56
29
|
//# sourceMappingURL=editor2d-selection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor2d-selection.js","sourceRoot":"","sources":["../../../src/browser/model/editor2d-selection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"editor2d-selection.js","sourceRoot":"","sources":["../../../src/browser/model/editor2d-selection.ts"],"names":[],"mappings":";;;;;;;;;AAAA,yCAAuC;AAEvC,qFAAuF;AAEvF,sCAAgE;AAChE,IAAO,aAAa,GAAG,oBAAa,CAAC,aAAa,CAAC;AAGnD,IAAa,iBAAiB,GAA9B,MAAa,iBAAkB,SAAQ,8CAAwB;IAC7D,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,EAAoB,CAAC;IAClD,CAAC;IACD,cAAc;QACZ,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAChC,IAAI,CAAC,YAAY,CAAC;YAChB,IAAI,EAAE,IAAoC;YAC1C,IAAI,EAAE,aAAa,CAAC,MAAM;SAC3B,CAAC,CACH,CAAC;IACJ,CAAC;CACF,CAAA;AAZY,iBAAiB;IAD7B,IAAA,sBAAU,GAAE;GACA,iBAAiB,CAY7B;AAZY,8CAAiB"}
|
|
@@ -1,19 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
3
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
4
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -28,46 +13,43 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
28
13
|
};
|
|
29
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
15
|
exports.Editor2dWidget = void 0;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
16
|
+
const inversify_1 = require("inversify");
|
|
17
|
+
const browser_1 = require("@gedit/application/lib/browser");
|
|
18
|
+
const editor2d_document_1 = require("./editor2d-document");
|
|
19
|
+
const playground_1 = require("../playground");
|
|
20
|
+
const render_engine_ide_1 = require("@gedit/render-engine-ide");
|
|
21
|
+
const app_config_1 = require("@gedit/app-config");
|
|
37
22
|
/**
|
|
38
23
|
* 画布渲染组件
|
|
39
24
|
*/
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
_this.node.onclick = function () {
|
|
25
|
+
let Editor2dWidget = class Editor2dWidget extends browser_1.BaseWidget {
|
|
26
|
+
constructor(playground, document, renderEngineService, appConfig) {
|
|
27
|
+
super();
|
|
28
|
+
this.playground = playground;
|
|
29
|
+
this.document = document;
|
|
30
|
+
this.renderEngineService = renderEngineService;
|
|
31
|
+
this.appConfig = appConfig;
|
|
32
|
+
this.configDataVersion = 0;
|
|
33
|
+
this.node.className = 'gedit-engine2d-widget';
|
|
34
|
+
this.node.appendChild(this.playground.node);
|
|
35
|
+
this.node.onclick = () => {
|
|
52
36
|
// 传递focus
|
|
53
|
-
|
|
37
|
+
this.node.parentElement.focus();
|
|
54
38
|
};
|
|
55
|
-
|
|
39
|
+
this.toDispose.push(this.playground);
|
|
56
40
|
// 注册编辑状态
|
|
57
|
-
renderEngineService.getGameObjectIDERegisters(document.engineName).forEach(
|
|
41
|
+
renderEngineService.getGameObjectIDERegisters(document.engineName).forEach(register => {
|
|
58
42
|
if (register.decoration.editorState) {
|
|
59
43
|
playground.editorState.registerState(register.decoration.editorState);
|
|
60
44
|
}
|
|
61
45
|
});
|
|
62
|
-
return _this;
|
|
63
46
|
}
|
|
64
|
-
|
|
47
|
+
updateVisible(visible) {
|
|
65
48
|
this.updateDocumentEntity({
|
|
66
49
|
visible: visible
|
|
67
50
|
});
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
var _this = this;
|
|
51
|
+
}
|
|
52
|
+
initModel(model) {
|
|
71
53
|
this.model = model;
|
|
72
54
|
// const snaplineConfigEntity = this.playground.getConfigEntity<SnaplineConfigEntity>(SnaplineConfigEntity)!;
|
|
73
55
|
this.toDispose.pushAll([
|
|
@@ -76,83 +58,82 @@ var Editor2dWidget = /** @class */ (function (_super) {
|
|
|
76
58
|
// model.document.snaplines = snaplineConfigEntity.toDataJSON().lines;
|
|
77
59
|
// }
|
|
78
60
|
// }),
|
|
79
|
-
model.onDocumentContentChanged(
|
|
61
|
+
model.onDocumentContentChanged(e => {
|
|
80
62
|
// if (e.document.loading) {
|
|
81
63
|
// snaplineConfigEntity.updateConfig({
|
|
82
64
|
// lines: model.document.snaplines || [],
|
|
83
65
|
// });
|
|
84
66
|
// }
|
|
85
|
-
|
|
86
|
-
|
|
67
|
+
this.updateDocument(e);
|
|
68
|
+
this.playground.focus();
|
|
87
69
|
}),
|
|
88
|
-
model.onSelectionChanged(
|
|
89
|
-
|
|
90
|
-
|
|
70
|
+
model.onSelectionChanged(e => {
|
|
71
|
+
this.updateSelection(e);
|
|
72
|
+
this.playground.focus();
|
|
91
73
|
}),
|
|
92
|
-
this.appConfig.onConfigChange(
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
74
|
+
this.appConfig.onConfigChange(config => {
|
|
75
|
+
this.configDataVersion++;
|
|
76
|
+
this.configData = config;
|
|
77
|
+
this.updateDocument({
|
|
96
78
|
document: model.document,
|
|
97
79
|
contentChanges: []
|
|
98
80
|
});
|
|
99
81
|
}),
|
|
100
82
|
]);
|
|
101
|
-
this.appConfig.getConfigData().then(
|
|
102
|
-
|
|
83
|
+
this.appConfig.getConfigData().then(config => {
|
|
84
|
+
this.configData = config;
|
|
103
85
|
// 第一次切换发送文档数据
|
|
104
|
-
|
|
105
|
-
|
|
86
|
+
this.updateDocument({ document: model.document, contentChanges: [] });
|
|
87
|
+
this.updateSelection((model.selection));
|
|
106
88
|
});
|
|
107
|
-
}
|
|
108
|
-
|
|
89
|
+
}
|
|
90
|
+
updateDocument(e) {
|
|
109
91
|
this.updateDocumentEntity({
|
|
110
92
|
document: e.document,
|
|
111
93
|
version: e.document.version,
|
|
112
94
|
appConfig: this.configData,
|
|
113
95
|
configVersion: this.configDataVersion,
|
|
114
96
|
});
|
|
115
|
-
}
|
|
116
|
-
|
|
97
|
+
}
|
|
98
|
+
updateSelection(e) {
|
|
117
99
|
this.updateDocumentEntity({ selectedNodes: e.selectedNodes });
|
|
118
|
-
}
|
|
119
|
-
|
|
100
|
+
}
|
|
101
|
+
updateDocumentEntity(data) {
|
|
120
102
|
this.playground.entityManager.updateConfigEntity(playground_1.DocumentEntity, data);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
103
|
+
}
|
|
104
|
+
refresh() {
|
|
105
|
+
const rect = this.node.getBoundingClientRect();
|
|
106
|
+
const resizeData = { clientX: rect.left, clientY: rect.top, width: rect.width, height: rect.height };
|
|
125
107
|
this.playground.resize(resizeData);
|
|
126
|
-
}
|
|
127
|
-
|
|
108
|
+
}
|
|
109
|
+
focus() {
|
|
128
110
|
// this.playground.focus();
|
|
129
|
-
}
|
|
130
|
-
|
|
111
|
+
}
|
|
112
|
+
blur() {
|
|
131
113
|
// this.playground.blur();
|
|
132
|
-
}
|
|
133
|
-
|
|
114
|
+
}
|
|
115
|
+
storeState() {
|
|
134
116
|
return this.playground.storeState();
|
|
135
|
-
}
|
|
136
|
-
|
|
117
|
+
}
|
|
118
|
+
isFocused() {
|
|
137
119
|
return this.playground.isFocused();
|
|
138
|
-
}
|
|
139
|
-
|
|
120
|
+
}
|
|
121
|
+
restoreState(oldState) {
|
|
140
122
|
return this.playground.restoreState(oldState);
|
|
141
|
-
}
|
|
142
|
-
|
|
123
|
+
}
|
|
124
|
+
resetState() {
|
|
143
125
|
this.playground.resetState();
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}(browser_1.BaseWidget));
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
Editor2dWidget = __decorate([
|
|
129
|
+
(0, inversify_1.injectable)(),
|
|
130
|
+
__param(0, (0, inversify_1.inject)(playground_1.Editor2dPlayGround)),
|
|
131
|
+
__param(1, (0, inversify_1.inject)(editor2d_document_1.Editor2dDocument)),
|
|
132
|
+
__param(2, (0, inversify_1.inject)(render_engine_ide_1.RenderEngineIDEService)),
|
|
133
|
+
__param(3, (0, inversify_1.inject)(app_config_1.AppConfigService)),
|
|
134
|
+
__metadata("design:paramtypes", [Object, editor2d_document_1.Editor2dDocument,
|
|
135
|
+
render_engine_ide_1.RenderEngineIDEService,
|
|
136
|
+
app_config_1.AppConfigService])
|
|
137
|
+
], Editor2dWidget);
|
|
157
138
|
exports.Editor2dWidget = Editor2dWidget;
|
|
158
139
|
//# sourceMappingURL=editor2d-widget.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor2d-widget.js","sourceRoot":"","sources":["../../../src/browser/model/editor2d-widget.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"editor2d-widget.js","sourceRoot":"","sources":["../../../src/browser/model/editor2d-widget.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,yCAA+C;AAC/C,4DAAgG;AAEhG,2DAAuD;AAGvD,8CAAiF;AACjF,gEAAkE;AAClE,kDAAoE;AAEpE;;GAEG;AAEH,IAAa,cAAc,GAA3B,MAAa,cAAe,SAAQ,oBAAU;IAK5C,YACuC,UAA8B,EAChC,QAA0B,EACpB,mBAA2C,EACjD,SAA2B;QAE9D,KAAK,EAAE,CAAC;QAL6B,eAAU,GAAV,UAAU,CAAoB;QAChC,aAAQ,GAAR,QAAQ,CAAkB;QACpB,wBAAmB,GAAnB,mBAAmB,CAAwB;QACjD,cAAS,GAAT,SAAS,CAAkB;QANxD,sBAAiB,GAAG,CAAC,CAAC;QAS5B,IAAI,CAAC,IAAI,CAAC,S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,CAAC;IAED,OAAO;QACL,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAC/C,MAAM,UAAU,GAAG,EAAC,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAC,CAAC;QACnG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACrC,CAAC;IAED,KAAK;QACH,2BAA2B;IAC7B,CAAC;IAED,IAAI;QACF,0BAA0B;IAC5B,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC;IACtC,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC;IACrC,CAAC;IAED,YAAY,CAAC,QAAgB;QAC3B,OAAO,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IAChD,CAAC;IAED,UAAU;QACR,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC;IAC/B,CAAC;CACF,CAAA;AAnHY,cAAc;IAD1B,IAAA,sBAAU,GAAE;IAOR,WAAA,IAAA,kBAAM,EAAC,+BAAkB,CAAC,CAAA;IAC1B,WAAA,IAAA,kBAAM,EAAC,oCAAgB,CAAC,CAAA;IACxB,WAAA,IAAA,kBAAM,EAAC,0CAAsB,CAAC,CAAA;IAC9B,WAAA,IAAA,kBAAM,EAAC,6BAAgB,CAAC,CAAA;6CAFoB,oCAAgB;QACC,0CAAsB;QACtC,6BAAgB;GATrD,cAAc,CAmH1B;AAnHY,wCAAc"}
|
|
@@ -1,103 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (_) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
50
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
51
|
-
if (!m) return o;
|
|
52
|
-
var i = m.call(o), r, ar = [], e;
|
|
53
|
-
try {
|
|
54
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
55
|
-
}
|
|
56
|
-
catch (error) { e = { error: error }; }
|
|
57
|
-
finally {
|
|
58
|
-
try {
|
|
59
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
60
|
-
}
|
|
61
|
-
finally { if (e) throw e.error; }
|
|
62
|
-
}
|
|
63
|
-
return ar;
|
|
64
|
-
};
|
|
65
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
66
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
67
|
-
if (ar || !(i in from)) {
|
|
68
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
69
|
-
ar[i] = from[i];
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
73
|
-
};
|
|
74
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
75
3
|
exports.checkDuplicateNodes = exports.getEditor2dModelOpts = exports.Editor2dModelOptions = exports.Editor2dNode = exports.Editor2dContent = exports.Editor2dDocumentContextMenuPath = void 0;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
4
|
+
const utils_1 = require("@gedit/utils");
|
|
5
|
+
const browser_1 = require("@gedit/resource/lib/browser");
|
|
6
|
+
const render_engine_1 = require("@gedit/render-engine");
|
|
7
|
+
const nanoid_1 = require("nanoid");
|
|
8
|
+
const stringify = require('json-stringify-pretty-compact');
|
|
81
9
|
// 文档内容菜单
|
|
82
10
|
exports.Editor2dDocumentContextMenuPath = ['editor2d-docuemnt-menu'];
|
|
83
11
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
84
|
-
function omitNode(node, omitKeys, assign) {
|
|
85
|
-
if (omitKeys === void 0) { omitKeys = []; }
|
|
12
|
+
function omitNode(node, omitKeys = [], assign) {
|
|
86
13
|
if (!node)
|
|
87
14
|
return node;
|
|
88
|
-
|
|
15
|
+
let result = (0, utils_1.omit)(node, [
|
|
89
16
|
'parent',
|
|
90
17
|
'previousSibling',
|
|
91
18
|
'nextSibling',
|
|
92
19
|
'version',
|
|
93
20
|
'selected',
|
|
94
|
-
'focus'
|
|
95
|
-
|
|
21
|
+
'focus',
|
|
22
|
+
...omitKeys
|
|
23
|
+
]);
|
|
96
24
|
if (assign)
|
|
97
25
|
result = assign(result);
|
|
98
26
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
99
27
|
if (result.children)
|
|
100
|
-
result.children = result.children.map(
|
|
28
|
+
result.children = result.children.map((n) => omitNode(n, omitKeys, assign));
|
|
101
29
|
return result;
|
|
102
30
|
}
|
|
103
31
|
var Editor2dContent;
|
|
@@ -105,7 +33,7 @@ var Editor2dContent;
|
|
|
105
33
|
function parseToJSON(contentData) {
|
|
106
34
|
return {
|
|
107
35
|
version: contentData.version,
|
|
108
|
-
content: omitNode(contentData.content, [],
|
|
36
|
+
content: omitNode(contentData.content, [], node => {
|
|
109
37
|
node.selected = false;
|
|
110
38
|
return node;
|
|
111
39
|
}),
|
|
@@ -124,7 +52,7 @@ var Editor2dNode;
|
|
|
124
52
|
Editor2dNode.GLOBAL_ADD_EVENT = 'global_add_event'; // 全局添加标记事件
|
|
125
53
|
function createNodeId(checks) {
|
|
126
54
|
// 用短id生成减少大小
|
|
127
|
-
|
|
55
|
+
const newId = (0, nanoid_1.nanoid)(10);
|
|
128
56
|
// id 冲突,重新生成
|
|
129
57
|
if (checks && checks.includes(newId)) {
|
|
130
58
|
return createNodeId(checks);
|
|
@@ -141,7 +69,7 @@ var Editor2dNode;
|
|
|
141
69
|
}
|
|
142
70
|
Editor2dNode.toContainerNode = toContainerNode;
|
|
143
71
|
function getNodePath(node) {
|
|
144
|
-
|
|
72
|
+
const path = [];
|
|
145
73
|
while (node) {
|
|
146
74
|
path.unshift(node.id);
|
|
147
75
|
node = node.parent;
|
|
@@ -150,7 +78,7 @@ var Editor2dNode;
|
|
|
150
78
|
}
|
|
151
79
|
Editor2dNode.getNodePath = getNodePath;
|
|
152
80
|
function getNodeNamePath(node) {
|
|
153
|
-
|
|
81
|
+
const path = [];
|
|
154
82
|
while (node && !Editor2dNode.isRootNode(node)) {
|
|
155
83
|
path.unshift(node.name || '');
|
|
156
84
|
node = node.parent;
|
|
@@ -159,7 +87,7 @@ var Editor2dNode;
|
|
|
159
87
|
}
|
|
160
88
|
Editor2dNode.getNodeNamePath = getNodeNamePath;
|
|
161
89
|
function getDepth(node) {
|
|
162
|
-
|
|
90
|
+
let depth = 0;
|
|
163
91
|
while (node && !Editor2dNode.isRootNode(node)) {
|
|
164
92
|
depth++;
|
|
165
93
|
node = node.parent;
|
|
@@ -190,8 +118,8 @@ var Editor2dNode;
|
|
|
190
118
|
function getURIByRootNode(workspaceURI, node) {
|
|
191
119
|
if (!isRootNode(node))
|
|
192
120
|
throw new Error('getURIByRootNode need a root node');
|
|
193
|
-
|
|
194
|
-
|
|
121
|
+
let path = '';
|
|
122
|
+
const displayType = node.displayType;
|
|
195
123
|
switch (displayType) {
|
|
196
124
|
case render_engine_1.GameObjectBaseType.COMPONENT:
|
|
197
125
|
path = 'gedit/component/' + node.name;
|
|
@@ -205,28 +133,26 @@ var Editor2dNode;
|
|
|
205
133
|
return new utils_1.URI(workspaceURI.path.join(path).toString());
|
|
206
134
|
}
|
|
207
135
|
Editor2dNode.getURIByRootNode = getURIByRootNode;
|
|
208
|
-
function clone(targetNode, omitKeys, checks) {
|
|
209
|
-
|
|
210
|
-
return (0, utils_1.deepClone)(omitNode(targetNode, __spreadArray(['id', 'selected'], __read(omitKeys), false), function (node) { return Object.assign(node, {
|
|
136
|
+
function clone(targetNode, omitKeys = [], checks) {
|
|
137
|
+
return (0, utils_1.deepClone)(omitNode(targetNode, ['id', 'selected', ...omitKeys], node => Object.assign(node, {
|
|
211
138
|
id: createNodeId(checks),
|
|
212
139
|
selected: false
|
|
213
|
-
})
|
|
140
|
+
})));
|
|
214
141
|
}
|
|
215
142
|
Editor2dNode.clone = clone;
|
|
216
143
|
/**
|
|
217
144
|
* 生成普通节点
|
|
218
145
|
*/
|
|
219
|
-
function createNode(members, displayType, id, checks) {
|
|
220
|
-
if (members === void 0) { members = {}; }
|
|
146
|
+
function createNode(members = {}, displayType, id, checks) {
|
|
221
147
|
id = id || createNodeId(checks);
|
|
222
|
-
return
|
|
148
|
+
return Object.assign(Object.assign({}, members), { displayType, parent: undefined, selected: false, locked: false, canvasHide: false, version: 0, id });
|
|
223
149
|
}
|
|
224
150
|
Editor2dNode.createNode = createNode;
|
|
225
151
|
/**
|
|
226
152
|
* 生成根节点
|
|
227
153
|
*/
|
|
228
154
|
function createRootNode(uri) {
|
|
229
|
-
|
|
155
|
+
let displayType;
|
|
230
156
|
switch (uri.path.ext) {
|
|
231
157
|
case '.comp':
|
|
232
158
|
displayType = render_engine_1.GameObjectBaseType.COMPONENT;
|
|
@@ -238,7 +164,7 @@ var Editor2dNode;
|
|
|
238
164
|
throw new Error('Cannot create root node by uri: ' + uri);
|
|
239
165
|
}
|
|
240
166
|
return {
|
|
241
|
-
displayType
|
|
167
|
+
displayType,
|
|
242
168
|
id: Editor2dNode.ROOT_NODE_ID,
|
|
243
169
|
parent: undefined,
|
|
244
170
|
name: uri.displayName,
|
|
@@ -253,10 +179,10 @@ var Editor2dNode;
|
|
|
253
179
|
}
|
|
254
180
|
Editor2dNode.createRootNode = createRootNode;
|
|
255
181
|
function registerTreeNodesDrop(node, onDrop, onDrag) {
|
|
256
|
-
|
|
257
|
-
handleEvent
|
|
258
|
-
|
|
259
|
-
|
|
182
|
+
const handle = {
|
|
183
|
+
handleEvent(event) {
|
|
184
|
+
const source = event.source;
|
|
185
|
+
const checkSource = source && source.length > 0 && Editor2dNode.is(source[0]);
|
|
260
186
|
if (checkSource) {
|
|
261
187
|
event.dropAction = event.proposedAction;
|
|
262
188
|
}
|
|
@@ -275,7 +201,7 @@ var Editor2dNode;
|
|
|
275
201
|
node.addEventListener('p-dragleave', handle);
|
|
276
202
|
node.addEventListener('p-drop', handle);
|
|
277
203
|
return {
|
|
278
|
-
dispose:
|
|
204
|
+
dispose: () => {
|
|
279
205
|
node.addEventListener('p-dragenter', handle);
|
|
280
206
|
node.addEventListener('p-dragover', handle);
|
|
281
207
|
node.addEventListener('p-dragleave', handle);
|
|
@@ -286,37 +212,25 @@ var Editor2dNode;
|
|
|
286
212
|
Editor2dNode.registerTreeNodesDrop = registerTreeNodesDrop;
|
|
287
213
|
})(Editor2dNode = exports.Editor2dNode || (exports.Editor2dNode = {}));
|
|
288
214
|
exports.Editor2dModelOptions = browser_1.ResourceAutoSaveOptions;
|
|
289
|
-
function getEditor2dModelOpts(resource, resourceService, encoding) {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
encoding: encoding,
|
|
298
|
-
resource: resource,
|
|
299
|
-
saveAsString: function (e) { return Editor2dContent.parseToString({ version: e.document.saveVersion, content: e.document.root, snaplines: e.document.snaplines }); }
|
|
300
|
-
};
|
|
301
|
-
return [4 /*yield*/, resourceService.createAutoSaveResource(options)];
|
|
302
|
-
case 1:
|
|
303
|
-
autoSaveService = _a.sent();
|
|
304
|
-
return [2 /*return*/, __assign(__assign({}, options), { autoSaveService: autoSaveService })];
|
|
305
|
-
}
|
|
306
|
-
});
|
|
307
|
-
});
|
|
215
|
+
async function getEditor2dModelOpts(resource, resourceService, encoding = 'utf8') {
|
|
216
|
+
const options = {
|
|
217
|
+
encoding,
|
|
218
|
+
resource,
|
|
219
|
+
saveAsString: e => Editor2dContent.parseToString({ version: e.document.saveVersion, content: e.document.root, snaplines: e.document.snaplines })
|
|
220
|
+
};
|
|
221
|
+
const autoSaveService = await resourceService.createAutoSaveResource(options);
|
|
222
|
+
return Object.assign(Object.assign({}, options), { autoSaveService });
|
|
308
223
|
}
|
|
309
224
|
exports.getEditor2dModelOpts = getEditor2dModelOpts;
|
|
310
225
|
/**
|
|
311
226
|
* 检测重复节点数据, 可能为误操作造成,避免对编辑态造成影响
|
|
312
227
|
* @param node
|
|
313
228
|
*/
|
|
314
|
-
function checkDuplicateNodes(node, map) {
|
|
315
|
-
if (map === void 0) { map = {}; }
|
|
229
|
+
function checkDuplicateNodes(node, map = {}) {
|
|
316
230
|
if (node.children) {
|
|
317
|
-
node.children.slice().forEach(
|
|
231
|
+
node.children.slice().forEach((c) => {
|
|
318
232
|
if (map[c.id]) {
|
|
319
|
-
|
|
233
|
+
const index = node.children.indexOf(c);
|
|
320
234
|
node.children.splice(index, 1);
|
|
321
235
|
console.log('>>> 清除重复数据: ', c.name);
|
|
322
236
|
}
|