@gedit/editor-2d 0.1.115 → 0.2.4
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.map +1 -1
- package/lib/browser/editor2d-contribution.js.map +1 -1
- package/lib/browser/editor2d-label-provider.js.map +1 -1
- package/lib/browser/editor2d-model-provider.js.map +1 -1
- package/lib/browser/editor2d-ref-provider-contribution.d.ts +1 -1
- package/lib/browser/editor2d-ref-provider-contribution.d.ts.map +1 -1
- package/lib/browser/editor2d-ref-provider-contribution.js +8 -8
- package/lib/browser/editor2d-ref-provider-contribution.js.map +1 -1
- package/lib/browser/editor2d-service.js.map +1 -1
- package/lib/browser/model/editor2d-document.d.ts +45 -19
- package/lib/browser/model/editor2d-document.d.ts.map +1 -1
- package/lib/browser/model/editor2d-document.js +291 -70
- package/lib/browser/model/editor2d-document.js.map +1 -1
- package/lib/browser/model/editor2d-model.js.map +1 -1
- package/lib/browser/model/editor2d-selection.js.map +1 -1
- package/lib/browser/model/editor2d-widget.js.map +1 -1
- package/lib/browser/model/editor2d.d.ts +8 -4
- package/lib/browser/model/editor2d.d.ts.map +1 -1
- package/lib/browser/model/editor2d.js +23 -4
- package/lib/browser/model/editor2d.js.map +1 -1
- package/lib/browser/model/utils/anim.utils.d.ts +3 -0
- package/lib/browser/model/utils/anim.utils.d.ts.map +1 -1
- package/lib/browser/model/utils/anim.utils.js +10 -4
- package/lib/browser/model/utils/anim.utils.js.map +1 -1
- package/lib/browser/playground/canvas-draw.d.ts +8 -0
- package/lib/browser/playground/canvas-draw.d.ts.map +1 -1
- package/lib/browser/playground/canvas-draw.js +29 -15
- package/lib/browser/playground/canvas-draw.js.map +1 -1
- package/lib/browser/playground/canvas-layer.d.ts +10 -2
- package/lib/browser/playground/canvas-layer.d.ts.map +1 -1
- package/lib/browser/playground/canvas-layer.js +25 -2
- package/lib/browser/playground/canvas-layer.js.map +1 -1
- package/lib/browser/playground/entities/extend-entity.d.ts +10 -0
- package/lib/browser/playground/entities/extend-entity.d.ts.map +1 -0
- package/lib/browser/playground/entities/extend-entity.js +34 -0
- package/lib/browser/playground/entities/extend-entity.js.map +1 -0
- package/lib/browser/playground/entities/index.d.ts +1 -0
- package/lib/browser/playground/entities/index.d.ts.map +1 -1
- package/lib/browser/playground/entities/index.js +1 -0
- package/lib/browser/playground/entities/index.js.map +1 -1
- package/lib/browser/playground/extend-edit-layer-point-event.d.ts +30 -0
- package/lib/browser/playground/extend-edit-layer-point-event.d.ts.map +1 -0
- package/lib/browser/playground/extend-edit-layer-point-event.js +50 -0
- package/lib/browser/playground/extend-edit-layer-point-event.js.map +1 -0
- package/lib/browser/playground/extend-edit-layer.d.ts +38 -0
- package/lib/browser/playground/extend-edit-layer.d.ts.map +1 -0
- package/lib/browser/playground/extend-edit-layer.js +335 -0
- package/lib/browser/playground/extend-edit-layer.js.map +1 -0
- package/lib/browser/playground/index.d.ts +1 -0
- package/lib/browser/playground/index.d.ts.map +1 -1
- package/lib/browser/playground/index.js +1 -0
- package/lib/browser/playground/index.js.map +1 -1
- package/lib/browser/playground/path-edit-layer-move-point.d.ts +15 -0
- package/lib/browser/playground/path-edit-layer-move-point.d.ts.map +1 -0
- package/lib/browser/playground/path-edit-layer-move-point.js +47 -0
- package/lib/browser/playground/path-edit-layer-move-point.js.map +1 -0
- package/lib/browser/playground/path-edit-layer-svg-path.d.ts +11 -0
- package/lib/browser/playground/path-edit-layer-svg-path.d.ts.map +1 -0
- package/lib/browser/playground/path-edit-layer-svg-path.js +21 -0
- package/lib/browser/playground/path-edit-layer-svg-path.js.map +1 -0
- package/lib/browser/playground/path-edit-layer.d.ts +36 -0
- package/lib/browser/playground/path-edit-layer.d.ts.map +1 -0
- package/lib/browser/playground/path-edit-layer.js +257 -0
- package/lib/browser/playground/path-edit-layer.js.map +1 -0
- package/lib/browser/playground/playground-context.js.map +1 -1
- package/lib/browser/playground/playground-contribution.d.ts +2 -0
- package/lib/browser/playground/playground-contribution.d.ts.map +1 -1
- package/lib/browser/playground/playground-contribution.js +40 -3
- package/lib/browser/playground/playground-contribution.js.map +1 -1
- package/lib/browser/utils/snapshot.d.ts.map +1 -1
- package/lib/browser/utils/snapshot.js +1 -1
- package/lib/browser/utils/snapshot.js.map +1 -1
- package/package.json +9 -7
- package/src/browser/editor2d-ref-provider-contribution.ts +8 -8
- package/src/browser/model/editor2d-document.ts +278 -49
- package/src/browser/model/editor2d.ts +22 -6
- package/src/browser/model/utils/anim.utils.ts +9 -2
- package/src/browser/playground/canvas-draw.ts +31 -17
- package/src/browser/playground/canvas-layer.ts +25 -3
- package/src/browser/playground/entities/extend-entity.ts +37 -0
- package/src/browser/playground/entities/index.ts +1 -0
- package/src/browser/playground/extend-edit-layer-point-event.tsx +71 -0
- package/src/browser/playground/extend-edit-layer.tsx +442 -0
- package/src/browser/playground/index.ts +1 -0
- package/src/browser/playground/path-edit-layer-move-point.tsx +71 -0
- package/src/browser/playground/path-edit-layer-svg-path.tsx +50 -0
- package/src/browser/playground/path-edit-layer.tsx +330 -0
- package/src/browser/playground/playground-contribution.ts +37 -3
- package/src/browser/style/canvas-layer.css +16 -0
- package/src/browser/style/extend-edit-layer.less +127 -0
- package/src/browser/style/index.less +2 -1
- package/src/browser/style/path-edit-layer.less +72 -0
- package/src/browser/svg/pen+.svg +24 -0
- package/src/browser/utils/snapshot.ts +1 -0
- package/lib/browser/playground/canvas-draw-layer.d.ts +0 -22
- package/lib/browser/playground/canvas-draw-layer.d.ts.map +0 -1
- package/lib/browser/playground/canvas-draw-layer.js +0 -102
- package/lib/browser/playground/canvas-draw-layer.js.map +0 -1
- package/src/browser/playground/canvas-draw-layer.tsx +0 -88
- package/src/browser/style/canvas-draw-layer.less +0 -24
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { EditorStateConfigEntity, Layer, PositionSchema } from '@gedit/playground';
|
|
3
|
-
import { DocumentEntity } from './entities/document-entity';
|
|
4
|
-
import { Editor2dDocument, Editor2dPathNode } from '../model';
|
|
5
|
-
/**
|
|
6
|
-
* 动态绘制层
|
|
7
|
-
*/
|
|
8
|
-
export declare class CanvasDrawLayer extends Layer {
|
|
9
|
-
node: HTMLDivElement;
|
|
10
|
-
protected editorState: EditorStateConfigEntity;
|
|
11
|
-
documentEntity: DocumentEntity;
|
|
12
|
-
currentPathNode?: Editor2dPathNode;
|
|
13
|
-
onReady(): void;
|
|
14
|
-
/**
|
|
15
|
-
* 创建路径
|
|
16
|
-
* @param pos - 当前鼠标点击的位置
|
|
17
|
-
*/
|
|
18
|
-
drawPath(pos: PositionSchema): void;
|
|
19
|
-
get document(): Editor2dDocument | undefined;
|
|
20
|
-
draw(): JSX.Element;
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=canvas-draw-layer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"canvas-draw-layer.d.ts","sourceRoot":"","sources":["../../../src/browser/playground/canvas-draw-layer.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,uBAAuB,EAAU,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC3F,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAG5D,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAG9D;;GAEG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IACxC,IAAI,iBAA0D;IAC7B,SAAS,CAAC,WAAW,EAAE,uBAAuB,CAAC;IACxD,cAAc,EAAE,cAAc,CAAC;IAEvD,eAAe,CAAC,EAAE,gBAAgB,CAAC;IAEnC,OAAO,IAAI,IAAI;IAoBf;;;OAGG;IACH,QAAQ,CAAC,GAAG,EAAE,cAAc,GAAG,IAAI;IAanC,IAAI,QAAQ,IAAI,gBAAgB,GAAG,SAAS,CAE3C;IAED,IAAI,IAAI,GAAG,CAAC,OAAO;CA4BpB"}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.CanvasDrawLayer = void 0;
|
|
13
|
-
const React = require("react");
|
|
14
|
-
const playground_1 = require("@gedit/playground");
|
|
15
|
-
const document_entity_1 = require("./entities/document-entity");
|
|
16
|
-
const browser_1 = require("@gedit/utils/lib/browser");
|
|
17
|
-
const render_engine_1 = require("@gedit/render-engine");
|
|
18
|
-
const EDIT_PATH_STATE = 'STATE_PATH';
|
|
19
|
-
/**
|
|
20
|
-
* 动态绘制层
|
|
21
|
-
*/
|
|
22
|
-
class CanvasDrawLayer extends playground_1.Layer {
|
|
23
|
-
constructor() {
|
|
24
|
-
super(...arguments);
|
|
25
|
-
this.node = browser_1.domUtils.createDivWithClass('gedit-canvas-draw-layer');
|
|
26
|
-
}
|
|
27
|
-
onReady() {
|
|
28
|
-
this.toDispose.pushAll([
|
|
29
|
-
// 退出路径编辑
|
|
30
|
-
this.editorState.onCancel(EDIT_PATH_STATE, () => {
|
|
31
|
-
var _a;
|
|
32
|
-
// 如果只有一个点代表绘制不成功,则删除
|
|
33
|
-
if (this.currentPathNode && this.currentPathNode.path.paths.length <= 1) {
|
|
34
|
-
(_a = this.document) === null || _a === void 0 ? void 0 : _a.delNode(this.currentPathNode);
|
|
35
|
-
}
|
|
36
|
-
this.currentPathNode = undefined;
|
|
37
|
-
}),
|
|
38
|
-
this.listenPlaygroundEvent('mousedown', (e) => {
|
|
39
|
-
// 当前编辑模式为路径编辑
|
|
40
|
-
if (this.editorState.is(EDIT_PATH_STATE)) {
|
|
41
|
-
const pos = this.getPosFromMouseEvent(e);
|
|
42
|
-
this.drawPath(pos);
|
|
43
|
-
}
|
|
44
|
-
}, 10)
|
|
45
|
-
]);
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* 创建路径
|
|
49
|
-
* @param pos - 当前鼠标点击的位置
|
|
50
|
-
*/
|
|
51
|
-
drawPath(pos) {
|
|
52
|
-
if (!this.document)
|
|
53
|
-
return;
|
|
54
|
-
// 创建一个空的路径节点,用于存储数据
|
|
55
|
-
if (!this.currentPathNode) {
|
|
56
|
-
this.currentPathNode = this.document.createDisplayNode(render_engine_1.GameObjectBaseType.PATH);
|
|
57
|
-
}
|
|
58
|
-
this.currentPathNode.path.paths.push({
|
|
59
|
-
x: pos.x,
|
|
60
|
-
y: pos.y,
|
|
61
|
-
});
|
|
62
|
-
this.document.updateNode(this.currentPathNode, {}, true);
|
|
63
|
-
}
|
|
64
|
-
get document() {
|
|
65
|
-
return this.documentEntity.config.document;
|
|
66
|
-
}
|
|
67
|
-
draw() {
|
|
68
|
-
if (!this.document)
|
|
69
|
-
return React.createElement(React.Fragment, null);
|
|
70
|
-
const allPoints = [];
|
|
71
|
-
const document = this.document;
|
|
72
|
-
this.document.queryNodesByTypes([render_engine_1.GameObjectBaseType.PATH]).forEach((node) => {
|
|
73
|
-
node.path.paths.forEach((p, i) => {
|
|
74
|
-
const onMouseDown = (e) => {
|
|
75
|
-
this.startDrag(e.clientX, e.clientY, {
|
|
76
|
-
// 拖动
|
|
77
|
-
onDrag(dragEvent) {
|
|
78
|
-
const pos = dragEvent.endPos;
|
|
79
|
-
p.x = pos.x;
|
|
80
|
-
p.y = pos.y;
|
|
81
|
-
document.updateNode(node, {}, true);
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
e.preventDefault();
|
|
85
|
-
e.stopPropagation();
|
|
86
|
-
};
|
|
87
|
-
allPoints.push(React.createElement("div", { className: "gedit-canvas-draw-layer-point", key: `${node.id}.${i}`, style: { left: p.x, top: p.y }, onMouseDown: onMouseDown }));
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
return React.createElement(React.Fragment, null, allPoints);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
__decorate([
|
|
94
|
-
(0, playground_1.entity)(playground_1.EditorStateConfigEntity),
|
|
95
|
-
__metadata("design:type", playground_1.EditorStateConfigEntity)
|
|
96
|
-
], CanvasDrawLayer.prototype, "editorState", void 0);
|
|
97
|
-
__decorate([
|
|
98
|
-
(0, playground_1.entity)(document_entity_1.DocumentEntity),
|
|
99
|
-
__metadata("design:type", document_entity_1.DocumentEntity)
|
|
100
|
-
], CanvasDrawLayer.prototype, "documentEntity", void 0);
|
|
101
|
-
exports.CanvasDrawLayer = CanvasDrawLayer;
|
|
102
|
-
//# sourceMappingURL=canvas-draw-layer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"canvas-draw-layer.js","sourceRoot":"","sources":["../../../src/browser/playground/canvas-draw-layer.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+BAA+B;AAC/B,kDAA2F;AAC3F,gEAA4D;AAC5D,sDAAoD;AACpD,wDAA0D;AAG1D,MAAM,eAAe,GAAG,YAAY,CAAC;AACrC;;GAEG;AACH,MAAa,eAAgB,SAAQ,kBAAK;IAA1C;;QACE,SAAI,GAAG,kBAAQ,CAAC,kBAAkB,CAAC,yBAAyB,CAAC,CAAC;IA2EhE,CAAC;IArEC,OAAO;QACL,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;YACrB,SAAS;YACT,IAAI,CAAC,WAAW,CAAC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C;QACH,OAAO,0CACJ,SAAS,CACT,CAAC;IACN,CAAC;CACF;AA1EkC;IAAhC,IAAA,mBAAM,EAAC,oCAAuB,CAAC;8BAAwB,oCAAuB;oDAAC;AACxD;IAAvB,IAAA,mBAAM,EAAC,gCAAc,CAAC;8BAAiB,gCAAc;uDAAC;AAHzD,0CA4EC"}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { EditorStateConfigEntity, entity, Layer, PositionSchema } from '@gedit/playground';
|
|
3
|
-
import { DocumentEntity } from './entities/document-entity';
|
|
4
|
-
import { domUtils } from '@gedit/utils/lib/browser';
|
|
5
|
-
import { GameObjectBaseType } from '@gedit/render-engine';
|
|
6
|
-
import { Editor2dDocument, Editor2dPathNode } from '../model';
|
|
7
|
-
|
|
8
|
-
const EDIT_PATH_STATE = 'STATE_PATH';
|
|
9
|
-
/**
|
|
10
|
-
* 动态绘制层
|
|
11
|
-
*/
|
|
12
|
-
export class CanvasDrawLayer extends Layer {
|
|
13
|
-
node = domUtils.createDivWithClass('gedit-canvas-draw-layer');
|
|
14
|
-
@entity(EditorStateConfigEntity) protected editorState: EditorStateConfigEntity;
|
|
15
|
-
@entity(DocumentEntity) documentEntity: DocumentEntity;
|
|
16
|
-
|
|
17
|
-
currentPathNode?: Editor2dPathNode;
|
|
18
|
-
|
|
19
|
-
onReady(): void {
|
|
20
|
-
this.toDispose.pushAll([
|
|
21
|
-
// 退出路径编辑
|
|
22
|
-
this.editorState.onCancel(EDIT_PATH_STATE, () => {
|
|
23
|
-
// 如果只有一个点代表绘制不成功,则删除
|
|
24
|
-
if (this.currentPathNode && this.currentPathNode.path.paths.length <= 1) {
|
|
25
|
-
this.document?.delNode(this.currentPathNode);
|
|
26
|
-
}
|
|
27
|
-
this.currentPathNode = undefined;
|
|
28
|
-
}),
|
|
29
|
-
this.listenPlaygroundEvent('mousedown', (e: MouseEvent) => {
|
|
30
|
-
// 当前编辑模式为路径编辑
|
|
31
|
-
if (this.editorState.is(EDIT_PATH_STATE)) {
|
|
32
|
-
const pos = this.getPosFromMouseEvent(e);
|
|
33
|
-
this.drawPath(pos);
|
|
34
|
-
}
|
|
35
|
-
}, 10)
|
|
36
|
-
]);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* 创建路径
|
|
41
|
-
* @param pos - 当前鼠标点击的位置
|
|
42
|
-
*/
|
|
43
|
-
drawPath(pos: PositionSchema): void {
|
|
44
|
-
if (!this.document) return;
|
|
45
|
-
// 创建一个空的路径节点,用于存储数据
|
|
46
|
-
if (!this.currentPathNode) {
|
|
47
|
-
this.currentPathNode = this.document.createDisplayNode<Editor2dPathNode>(GameObjectBaseType.PATH);
|
|
48
|
-
}
|
|
49
|
-
this.currentPathNode.path.paths.push({
|
|
50
|
-
x: pos.x,
|
|
51
|
-
y: pos.y,
|
|
52
|
-
});
|
|
53
|
-
this.document.updateNode(this.currentPathNode, {}, true);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
get document(): Editor2dDocument | undefined {
|
|
57
|
-
return this.documentEntity.config.document;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
draw(): JSX.Element {
|
|
61
|
-
if (!this.document) return <></>;
|
|
62
|
-
const allPoints: JSX.Element[] = [];
|
|
63
|
-
const document = this.document!;
|
|
64
|
-
this.document.queryNodesByTypes([GameObjectBaseType.PATH]).forEach((node: Editor2dPathNode) => {
|
|
65
|
-
node.path.paths.forEach((p, i) => {
|
|
66
|
-
const onMouseDown = (e: React.MouseEvent) => {
|
|
67
|
-
this.startDrag(e.clientX, e.clientY, {
|
|
68
|
-
// 拖动
|
|
69
|
-
onDrag(dragEvent): void {
|
|
70
|
-
const pos = dragEvent.endPos;
|
|
71
|
-
p.x = pos.x;
|
|
72
|
-
p.y = pos.y;
|
|
73
|
-
document.updateNode(node, {}, true);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
e.preventDefault();
|
|
77
|
-
e.stopPropagation();
|
|
78
|
-
};
|
|
79
|
-
allPoints.push(
|
|
80
|
-
<div className="gedit-canvas-draw-layer-point" key={`${node.id}.${i}`} style={{ left: p.x, top: p.y }}onMouseDown={onMouseDown}/>
|
|
81
|
-
);
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
return <>
|
|
85
|
-
{allPoints}
|
|
86
|
-
</>;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
.gedit-canvas-draw-layer {
|
|
2
|
-
position: absolute;
|
|
3
|
-
left: 0;
|
|
4
|
-
top: 0;
|
|
5
|
-
overflow: visible;
|
|
6
|
-
z-index: 20;
|
|
7
|
-
&-point {
|
|
8
|
-
position: absolute;
|
|
9
|
-
width: 8px;
|
|
10
|
-
height: 8px;
|
|
11
|
-
border-radius: var(--g-small-radius);
|
|
12
|
-
margin-top: -4px;
|
|
13
|
-
margin-left: -4px;
|
|
14
|
-
background-color: var(--g-playground-select);
|
|
15
|
-
cursor: pointer;
|
|
16
|
-
z-index: 50;
|
|
17
|
-
}
|
|
18
|
-
&-svg {
|
|
19
|
-
position: absolute;
|
|
20
|
-
overflow: visible;
|
|
21
|
-
left: 0;
|
|
22
|
-
top: 0;
|
|
23
|
-
}
|
|
24
|
-
}
|