@gedit/editor-2d 0.2.46 → 0.2.48
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/model/editor2d-document.d.ts +11 -2
- package/lib/browser/model/editor2d-document.d.ts.map +1 -1
- package/lib/browser/model/editor2d-document.js +44 -8
- package/lib/browser/model/editor2d-document.js.map +1 -1
- package/lib/browser/model/editor2d-model-container.d.ts.map +1 -1
- package/lib/browser/model/editor2d-model-container.js +1 -1
- package/lib/browser/model/editor2d-model-container.js.map +1 -1
- package/lib/browser/model/editor2d-model.d.ts +2 -0
- package/lib/browser/model/editor2d-model.d.ts.map +1 -1
- package/lib/browser/model/editor2d-model.js +5 -0
- package/lib/browser/model/editor2d-model.js.map +1 -1
- package/lib/browser/model/editor2d.d.ts +2 -0
- package/lib/browser/model/editor2d.d.ts.map +1 -1
- package/lib/browser/model/editor2d.js +4 -2
- package/lib/browser/model/editor2d.js.map +1 -1
- package/lib/browser/playground/canvas-draw.d.ts +6 -2
- package/lib/browser/playground/canvas-draw.d.ts.map +1 -1
- package/lib/browser/playground/canvas-draw.js +174 -49
- package/lib/browser/playground/canvas-draw.js.map +1 -1
- package/lib/browser/playground/canvas-layer.d.ts +15 -3
- package/lib/browser/playground/canvas-layer.d.ts.map +1 -1
- package/lib/browser/playground/canvas-layer.js +134 -72
- package/lib/browser/playground/canvas-layer.js.map +1 -1
- package/lib/browser/playground/index.d.ts +2 -0
- package/lib/browser/playground/index.d.ts.map +1 -1
- package/lib/browser/playground/index.js +2 -0
- package/lib/browser/playground/index.js.map +1 -1
- package/lib/browser/playground/path-edit/index.d.ts +4 -0
- package/lib/browser/playground/path-edit/index.d.ts.map +1 -0
- package/lib/browser/playground/path-edit/index.js +20 -0
- package/lib/browser/playground/path-edit/index.js.map +1 -0
- package/lib/browser/playground/path-edit/path-edit-layer-move-point.d.ts +18 -0
- package/lib/browser/playground/path-edit/path-edit-layer-move-point.d.ts.map +1 -0
- package/lib/browser/playground/path-edit/path-edit-layer-move-point.js +52 -0
- package/lib/browser/playground/path-edit/path-edit-layer-move-point.js.map +1 -0
- package/lib/browser/playground/path-edit/path-edit-layer-svg-path.d.ts +21 -0
- package/lib/browser/playground/path-edit/path-edit-layer-svg-path.d.ts.map +1 -0
- package/lib/browser/playground/path-edit/path-edit-layer-svg-path.js +158 -0
- package/lib/browser/playground/path-edit/path-edit-layer-svg-path.js.map +1 -0
- package/lib/browser/playground/path-edit/utils.d.ts +37 -0
- package/lib/browser/playground/path-edit/utils.d.ts.map +1 -0
- package/lib/browser/playground/path-edit/utils.js +236 -0
- package/lib/browser/playground/path-edit/utils.js.map +1 -0
- package/lib/browser/playground/path-edit-layer.d.ts +32 -12
- package/lib/browser/playground/path-edit-layer.d.ts.map +1 -1
- package/lib/browser/playground/path-edit-layer.js +460 -146
- package/lib/browser/playground/path-edit-layer.js.map +1 -1
- package/lib/browser/playground/playground-context.d.ts +5 -2
- package/lib/browser/playground/playground-context.d.ts.map +1 -1
- package/lib/browser/playground/playground-context.js +13 -2
- package/lib/browser/playground/playground-context.js.map +1 -1
- package/lib/browser/playground/playground-contribution.d.ts +4 -1
- package/lib/browser/playground/playground-contribution.d.ts.map +1 -1
- package/lib/browser/playground/playground-contribution.js +23 -23
- package/lib/browser/playground/playground-contribution.js.map +1 -1
- package/lib/browser/playground/selection-entity-manager.d.ts +1 -1
- package/lib/browser/playground/selection-entity-manager.d.ts.map +1 -1
- package/lib/browser/playground/selection-entity-manager.js +40 -10
- package/lib/browser/playground/selection-entity-manager.js.map +1 -1
- package/lib/browser/playground/selector-extend-renderer.d.ts +2 -1
- package/lib/browser/playground/selector-extend-renderer.d.ts.map +1 -1
- package/lib/browser/playground/selector-extend-renderer.js +50 -21
- package/lib/browser/playground/selector-extend-renderer.js.map +1 -1
- package/lib/browser/utils/snapshot.d.ts +1 -0
- package/lib/browser/utils/snapshot.d.ts.map +1 -1
- package/lib/browser/utils/snapshot.js +12 -1
- package/lib/browser/utils/snapshot.js.map +1 -1
- package/package.json +9 -7
- package/src/browser/model/editor2d-document.ts +44 -6
- package/src/browser/model/editor2d-model-container.ts +2 -0
- package/src/browser/model/editor2d-model.ts +2 -0
- package/src/browser/model/editor2d.ts +4 -1
- package/src/browser/playground/canvas-draw.ts +331 -112
- package/src/browser/playground/canvas-layer.ts +120 -59
- package/src/browser/playground/index.ts +2 -0
- package/src/browser/playground/path-edit/index.ts +3 -0
- package/src/browser/playground/path-edit/path-edit-layer-move-point.tsx +108 -0
- package/src/browser/playground/path-edit/path-edit-layer-svg-path.tsx +283 -0
- package/src/browser/playground/path-edit/utils.tsx +285 -0
- package/src/browser/playground/path-edit-layer.tsx +563 -216
- package/src/browser/playground/playground-context.ts +7 -1
- package/src/browser/playground/playground-contribution.ts +17 -24
- package/src/browser/playground/selection-entity-manager.tsx +48 -8
- package/src/browser/playground/selector-extend-renderer.tsx +69 -37
- package/src/browser/style/index.less +6 -0
- package/src/browser/style/path-edit-layer.less +17 -30
- package/src/browser/svg/pen_close.svg +24 -0
- package/src/browser/utils/snapshot.ts +12 -1
- package/LICENSE +0 -21
- package/lib/browser/playground/path-edit-layer-move-point.d.ts +0 -15
- package/lib/browser/playground/path-edit-layer-move-point.d.ts.map +0 -1
- package/lib/browser/playground/path-edit-layer-move-point.js +0 -47
- package/lib/browser/playground/path-edit-layer-move-point.js.map +0 -1
- package/lib/browser/playground/path-edit-layer-svg-path.d.ts +0 -11
- package/lib/browser/playground/path-edit-layer-svg-path.d.ts.map +0 -1
- package/lib/browser/playground/path-edit-layer-svg-path.js +0 -21
- package/lib/browser/playground/path-edit-layer-svg-path.js.map +0 -1
- package/src/browser/playground/path-edit-layer-move-point.tsx +0 -71
- package/src/browser/playground/path-edit-layer-svg-path.tsx +0 -50
|
@@ -5,7 +5,7 @@ import { AppConfigService } from '@gedit/app-config';
|
|
|
5
5
|
import { debounce, Emitter, URI } from '@gedit/utils';
|
|
6
6
|
import { Editor2dEntity } from './entities/editor2d-entity';
|
|
7
7
|
import type { SelectionEntityManager } from './selection-entity-manager';
|
|
8
|
-
import { Playground } from '@gedit/playground';
|
|
8
|
+
import { PathPointSelectionService, PathSelectMode, Playground } from '@gedit/playground';
|
|
9
9
|
import { Editor2dDocument } from '../model/editor2d-document';
|
|
10
10
|
import { Editor2dSelection } from '../model/editor2d-selection';
|
|
11
11
|
import { Editor2dModelOptions, Editor2dNode } from '../model/editor2d';
|
|
@@ -16,6 +16,7 @@ import SelectionType = TreeSelection.SelectionType;
|
|
|
16
16
|
import { FormService } from '@gedit/ui';
|
|
17
17
|
import { OpenerService } from '@gedit/application-common/lib/browser';
|
|
18
18
|
import { WorkspaceService } from '@gedit/workspace-2d';
|
|
19
|
+
import { HistoryService } from '@gedit/history';
|
|
19
20
|
|
|
20
21
|
export const Editor2dPlayGround = Symbol('Editor2dPlayGround');
|
|
21
22
|
|
|
@@ -41,6 +42,8 @@ export class PlaygroundContext2d {
|
|
|
41
42
|
@inject(OpenerService) readonly openerService: OpenerService,
|
|
42
43
|
@inject(WorkspaceService)
|
|
43
44
|
protected readonly workspaceService: WorkspaceService,
|
|
45
|
+
@inject(PathPointSelectionService) readonly pathPointSelection: PathPointSelectionService,
|
|
46
|
+
@inject(HistoryService) readonly historyService: HistoryService
|
|
44
47
|
) {
|
|
45
48
|
this.rootURI = new URI(this.workspaceService.currentRoot!.uri);
|
|
46
49
|
this.document.toDispose.push(this.onCanvasDataChangedEmitter);
|
|
@@ -52,6 +55,9 @@ export class PlaygroundContext2d {
|
|
|
52
55
|
* 刷新 tree selection
|
|
53
56
|
*/
|
|
54
57
|
syncToSelectionTree = debounce((entities: SelectionEntityManager) => {
|
|
58
|
+
if (this.pathPointSelection.selectMode !== PathSelectMode.ADD_PATH) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
55
61
|
const selectedEntities: Editor2dEntity[] = entities.getSelectedEntities();
|
|
56
62
|
const selectedNodes = this.selection.selectedNodes;
|
|
57
63
|
// 清空数据
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { inject, injectable } from 'inversify';
|
|
2
2
|
import {
|
|
3
3
|
EditorStateConfigEntity,
|
|
4
|
+
PathPointSelectionService,
|
|
4
5
|
Playground,
|
|
5
6
|
PlaygroundConfig,
|
|
6
7
|
PlaygroundContribution,
|
|
@@ -17,7 +18,7 @@ import { HistoryService } from '@gedit/history';
|
|
|
17
18
|
import { Editor2dModelOptions, Editor2dNode } from '../model/editor2d';
|
|
18
19
|
import { ContextMenuRenderer } from '@gedit/layout';
|
|
19
20
|
import { CommandService } from '@gedit/command';
|
|
20
|
-
import { CommonCommands } from '@gedit/application-common/lib/browser';
|
|
21
|
+
import { CommonCommands, FrontendApplicationStateService } from '@gedit/application-common/lib/browser';
|
|
21
22
|
import { ExtendEditLayer, EXTEND_EDIT_STATE } from './extend-edit-layer';
|
|
22
23
|
import { Editor2dSelection } from '../model/editor2d-selection';
|
|
23
24
|
|
|
@@ -30,6 +31,8 @@ export class PlaygroundContribution2d implements PlaygroundContribution {
|
|
|
30
31
|
@inject(CommandService) readonly commandService: CommandService;
|
|
31
32
|
@inject(ContextMenuRenderer) readonly menuRender: ContextMenuRenderer;
|
|
32
33
|
@inject(Editor2dSelection) readonly editor2dSelection: Editor2dSelection;
|
|
34
|
+
@inject(PathPointSelectionService) readonly pathPointSelectionService: PathPointSelectionService;
|
|
35
|
+
@inject(FrontendApplicationStateService) readonly stateService: FrontendApplicationStateService;
|
|
33
36
|
registerPlayground(registry: PlaygroundRegistry): void {
|
|
34
37
|
registry.registerLayer(CanvasLayer);
|
|
35
38
|
registry.registerLayer(PathEditLayer);
|
|
@@ -96,27 +99,6 @@ export class PlaygroundContribution2d implements PlaygroundContribution {
|
|
|
96
99
|
});
|
|
97
100
|
}
|
|
98
101
|
});
|
|
99
|
-
/* stateEntity.registerState({
|
|
100
|
-
id: 'ADD_PATH',
|
|
101
|
-
icon: 'gedit-toolbar-pen',
|
|
102
|
-
title: '失量',
|
|
103
|
-
shortcut: 'P',
|
|
104
|
-
// cursor: 'url(https://gw.alipayobjects.com/zos/bmw-prod/8dc2fcc4-279b-408c-886c-60fdba4c1f1e.svg), copy',
|
|
105
|
-
// shortcutAutoEsc: true,
|
|
106
|
-
disableSelector: true,
|
|
107
|
-
priority: 0,
|
|
108
|
-
order: 1,
|
|
109
|
-
cancelMode: 'esc',
|
|
110
|
-
handle: (a, b) => {
|
|
111
|
-
const currentSelectedNodes = this.editor2dSelection.selectedNodes;
|
|
112
|
-
console.log(currentSelectedNodes);
|
|
113
|
-
if (currentSelectedNodes.length !== 1 || currentSelectedNodes[0].displayType !== 'path') {
|
|
114
|
-
// 路径选中时先取消所有 selection;
|
|
115
|
-
this.editor2dSelection.clearSelection();
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
}); */
|
|
120
102
|
}
|
|
121
103
|
// 模板编辑器模式
|
|
122
104
|
if (this.modelOpts.isTemplate) {
|
|
@@ -129,8 +111,19 @@ export class PlaygroundContribution2d implements PlaygroundContribution {
|
|
|
129
111
|
percentageInfoVisible: false,
|
|
130
112
|
});
|
|
131
113
|
}
|
|
132
|
-
playground.getConfigEntity<SnaplineConfigEntity>(SnaplineConfigEntity)
|
|
133
|
-
|
|
114
|
+
const snaplineEntity = playground.getConfigEntity<SnaplineConfigEntity>(SnaplineConfigEntity);
|
|
115
|
+
snaplineEntity.updateConfig({
|
|
116
|
+
lines: [],
|
|
117
|
+
originlineVisible: this.appConfig.configData?.engine === 'dom' ? false : isComponent, // 是否隐藏原点线条,如果是组件模式则显示
|
|
118
|
+
});
|
|
119
|
+
this.stateService.onStateChanged(state => {
|
|
120
|
+
if (state === 'initialized_layout') {
|
|
121
|
+
// 部局完成后再是否显示中心线,pixi 组件用
|
|
122
|
+
snaplineEntity.updateConfig({
|
|
123
|
+
lines: [],
|
|
124
|
+
originlineVisible: this.appConfig.configData?.engine === 'dom' ? false : isComponent,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
134
127
|
});
|
|
135
128
|
playground.toDispose.push(
|
|
136
129
|
// TODO 放在这里处理会增加复杂度
|
|
@@ -14,6 +14,7 @@ import type { PlaygroundContext2d } from './playground-context';
|
|
|
14
14
|
import { Rectangle } from '@gedit/math';
|
|
15
15
|
import { GameObject } from '@gedit/render-engine';
|
|
16
16
|
import { SelectorExtendRender } from './selector-extend-renderer';
|
|
17
|
+
import { followKeyType } from '@gedit/render-engine-pixi';
|
|
17
18
|
|
|
18
19
|
const numberToFixed4 = (data: {[key: string]: any}) => {
|
|
19
20
|
const d: any = {};
|
|
@@ -46,10 +47,6 @@ export class SelectionEntityManager {
|
|
|
46
47
|
const editorStateConfigEntity = entityManager.getEntity<EditorStateConfigEntity>(EditorStateConfigEntity);
|
|
47
48
|
const selectionConfigEntity = entityManager.getEntity<SelectorConfigEntity>(SelectorConfigEntity);
|
|
48
49
|
selectionConfigEntity?.customSelectorEntityRenderer(props => {
|
|
49
|
-
if (props.isMoving) {
|
|
50
|
-
// 如果是托拽状态,则清除跟随;
|
|
51
|
-
this.getDocument()?.clearSelectNodeFollow();
|
|
52
|
-
}
|
|
53
50
|
|
|
54
51
|
const showSceneRangeRuler = editorStateConfigEntity?.getCurrentState?.() === EditorState.SHOW_SCENE_RANGE_RULER;
|
|
55
52
|
const newProps: SelectorEntityRendererProps = {
|
|
@@ -62,7 +59,14 @@ export class SelectionEntityManager {
|
|
|
62
59
|
? this.context.renderEngine.getGameObjectIDERegister(entity.gameObject.scene.config.engine, entity.node.displayType)
|
|
63
60
|
: undefined;
|
|
64
61
|
const deco = register?.decoration;
|
|
65
|
-
newProps.extendRenderer = () =>
|
|
62
|
+
newProps.extendRenderer = () => (
|
|
63
|
+
<SelectorExtendRender
|
|
64
|
+
{...props}
|
|
65
|
+
customExtendSchema={selectionConfigEntity?.extendSchema}
|
|
66
|
+
register={register}
|
|
67
|
+
context={this.context}
|
|
68
|
+
/>
|
|
69
|
+
);
|
|
66
70
|
/* if (this.context.options.extendEntityRenderer) {
|
|
67
71
|
newProps.extendRenderer = () => this.context.options.extendEntityRenderer!({ ...props, context: this.context });
|
|
68
72
|
} */
|
|
@@ -116,6 +120,12 @@ export class SelectionEntityManager {
|
|
|
116
120
|
entity.nodeId = node.id;
|
|
117
121
|
entity.context = this.context;
|
|
118
122
|
entity.transform.sizeToScale = !!deco.sizeToScale;
|
|
123
|
+
if (deco.useComponentSceneSize) {
|
|
124
|
+
entity.transform.componentSceneSize = {
|
|
125
|
+
width: gameObject.data.scene?.width || 400,
|
|
126
|
+
height: gameObject.data.scene?.height || 400,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
119
129
|
|
|
120
130
|
this.setTransformMask(entity, nodePath, node);
|
|
121
131
|
// 切换选择框的类型,如圆形、矩形, 默认矩形
|
|
@@ -154,7 +164,31 @@ export class SelectionEntityManager {
|
|
|
154
164
|
return;
|
|
155
165
|
}
|
|
156
166
|
const newTransform = numberToFixed4(entity.transform.data);
|
|
157
|
-
document.
|
|
167
|
+
const node = document.getNodeById(entity.nodeId);
|
|
168
|
+
if (!node) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
// 跟随后不能动
|
|
172
|
+
if (node.follow) {
|
|
173
|
+
const { open, target, type } = node.follow;
|
|
174
|
+
if (open && target && node.position) {
|
|
175
|
+
const p = document.getFollowPosition(node);
|
|
176
|
+
p.forEach(c => {
|
|
177
|
+
newTransform.position[c.type] = c.value;
|
|
178
|
+
entity.transform.position[c.type] = c.value;
|
|
179
|
+
});
|
|
180
|
+
const selectionNodes = document.getSelectedNodes();
|
|
181
|
+
if (selectionNodes.some(c => c.id === node.id)) {
|
|
182
|
+
document.message.warn(
|
|
183
|
+
`元素开启了跟随,${type
|
|
184
|
+
?.map(c => followKeyType[c])
|
|
185
|
+
.join(',')} 被锁定`,
|
|
186
|
+
{timeout: 2000 }
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
document.updateNode(node, newTransform, true);
|
|
158
192
|
});
|
|
159
193
|
|
|
160
194
|
// ableManager是全局的,所以每个节点销毁后得注销时间
|
|
@@ -181,7 +215,7 @@ export class SelectionEntityManager {
|
|
|
181
215
|
entity.dispose();
|
|
182
216
|
}
|
|
183
217
|
}
|
|
184
|
-
updateEntity(nodePath: string, gameObject: GameObject): void {
|
|
218
|
+
updateEntity(nodePath: string, gameObject: GameObject, scale?: number): void {
|
|
185
219
|
const register = this.context.renderEngine.getGameObjectIDERegister(gameObject.scene.config.engine, gameObject.type);
|
|
186
220
|
const deco = register.decoration;
|
|
187
221
|
const entity = this.nodeEntitiesCache.get(nodePath);
|
|
@@ -197,7 +231,13 @@ export class SelectionEntityManager {
|
|
|
197
231
|
}
|
|
198
232
|
}
|
|
199
233
|
entity.transform.isContainer = !!deco.isContainer;
|
|
200
|
-
|
|
234
|
+
if (deco.useComponentSceneSize) {
|
|
235
|
+
entity.transform.componentSceneSize = {
|
|
236
|
+
width: gameObject.data.scene?.width || 400,
|
|
237
|
+
height: gameObject.data.scene?.height || 400,
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
entity.update(register.getSelectionData(gameObject, scale));
|
|
201
241
|
entity.ignoreTransformChanged = false;
|
|
202
242
|
const sizeVisible = !this.isHidden(entity.node); // && (entity.transform.size.width > 0 && entity.transform.size.height > 0 || !!deco.isContainer);
|
|
203
243
|
const opacityZero = this.isOpacityZero(node);
|
|
@@ -4,8 +4,11 @@ import clsx from 'clsx';
|
|
|
4
4
|
import { Popover, Tooltip } from '@gedit/ui';
|
|
5
5
|
|
|
6
6
|
import { selectIcon, SelectorExtendType } from './selector-extend-icons';
|
|
7
|
-
import {
|
|
8
|
-
|
|
7
|
+
import {
|
|
8
|
+
GameObjectIDERegister,
|
|
9
|
+
GameObjectSelectorExtend as SelectorExtend,
|
|
10
|
+
} from '@gedit/render-engine-ide';
|
|
11
|
+
import { SelectorEntityRendererProps } from '@gedit/playground';
|
|
9
12
|
import type { Editor2dEntity } from './entities/editor2d-entity';
|
|
10
13
|
import { Editor2dNode } from '../model';
|
|
11
14
|
import { PlaygroundContext2d } from './playground-context';
|
|
@@ -15,6 +18,7 @@ const getClassName = (str: string) => `gedit-selector-extend-${str}`;
|
|
|
15
18
|
export interface SelectorExtendProps extends SelectorEntityRendererProps {
|
|
16
19
|
register?: GameObjectIDERegister;
|
|
17
20
|
context: PlaygroundContext2d;
|
|
21
|
+
customExtendSchema?: SelectorExtend[];
|
|
18
22
|
}
|
|
19
23
|
|
|
20
24
|
const defaultExtends: SelectorExtend[] = [
|
|
@@ -23,7 +27,8 @@ const defaultExtends: SelectorExtend[] = [
|
|
|
23
27
|
title: '配置链接',
|
|
24
28
|
category: 1,
|
|
25
29
|
order: 0,
|
|
26
|
-
visible: (node: Editor2dNode, register: GameObjectIDERegister) =>
|
|
30
|
+
visible: (node: Editor2dNode, register: GameObjectIDERegister) =>
|
|
31
|
+
register?.getDisableKeys().indexOf('link') === -1,
|
|
27
32
|
event: {
|
|
28
33
|
title: '跳转配置',
|
|
29
34
|
type: 'selectorExtendAttr',
|
|
@@ -34,26 +39,27 @@ const defaultExtends: SelectorExtend[] = [
|
|
|
34
39
|
label: '类型',
|
|
35
40
|
renderProps: {
|
|
36
41
|
defaultValue: 'url',
|
|
37
|
-
items: [
|
|
38
|
-
|
|
42
|
+
items: [
|
|
43
|
+
{ value: 'url', label: 'URL' },
|
|
44
|
+
{ value: 'scene', label: '场景' },
|
|
45
|
+
],
|
|
46
|
+
},
|
|
39
47
|
},
|
|
40
48
|
{
|
|
41
49
|
type: 'text',
|
|
42
50
|
key: 'link',
|
|
43
|
-
visible: (v, key, node: Editor2dNode) =>
|
|
44
|
-
node && !node.linkType || node.linkType === 'url'
|
|
45
|
-
),
|
|
51
|
+
visible: (v, key, node: Editor2dNode) =>
|
|
52
|
+
(node && !node.linkType) || node.linkType === 'url',
|
|
46
53
|
label: '链接',
|
|
47
54
|
placeholder: '请输入 url 地址',
|
|
48
55
|
},
|
|
49
56
|
{
|
|
50
57
|
type: 'mindmapSelect',
|
|
51
58
|
key: 'link',
|
|
52
|
-
visible: (v, key, node: Editor2dNode) =>
|
|
53
|
-
node && node.linkType === 'scene'
|
|
54
|
-
),
|
|
59
|
+
visible: (v, key, node: Editor2dNode) =>
|
|
60
|
+
node && node.linkType === 'scene',
|
|
55
61
|
renderProps: {
|
|
56
|
-
filterTypes: ['scene']
|
|
62
|
+
filterTypes: ['scene'],
|
|
57
63
|
},
|
|
58
64
|
label: '场景',
|
|
59
65
|
placeholder: '请选择场景',
|
|
@@ -69,9 +75,9 @@ const defaultExtends: SelectorExtend[] = [
|
|
|
69
75
|
placeholder: 'c位',
|
|
70
76
|
renderProps: {
|
|
71
77
|
style: {
|
|
72
|
-
width: 80
|
|
73
|
-
}
|
|
74
|
-
}
|
|
78
|
+
width: 80,
|
|
79
|
+
},
|
|
80
|
+
},
|
|
75
81
|
},
|
|
76
82
|
{
|
|
77
83
|
type: 'text',
|
|
@@ -79,12 +85,12 @@ const defaultExtends: SelectorExtend[] = [
|
|
|
79
85
|
placeholder: 'd位',
|
|
80
86
|
renderProps: {
|
|
81
87
|
style: {
|
|
82
|
-
width: 80
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
]
|
|
87
|
-
}
|
|
88
|
+
width: 80,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
},
|
|
88
94
|
],
|
|
89
95
|
},
|
|
90
96
|
},
|
|
@@ -105,14 +111,16 @@ const defaultExtends: SelectorExtend[] = [
|
|
|
105
111
|
title: 'X 轴镜像',
|
|
106
112
|
category: 2,
|
|
107
113
|
order: 2,
|
|
108
|
-
visible: (node: Editor2dNode, register: GameObjectIDERegister) =>
|
|
114
|
+
visible: (node: Editor2dNode, register: GameObjectIDERegister) =>
|
|
115
|
+
register?.getDisableKeys().indexOf('flip.x') === -1,
|
|
109
116
|
},
|
|
110
117
|
{
|
|
111
118
|
type: SelectorExtendType.FLIP_Y,
|
|
112
119
|
title: 'Y 轴镜像',
|
|
113
120
|
category: 2,
|
|
114
121
|
order: 3,
|
|
115
|
-
visible: (node: Editor2dNode, register: GameObjectIDERegister) =>
|
|
122
|
+
visible: (node: Editor2dNode, register: GameObjectIDERegister) =>
|
|
123
|
+
register?.getDisableKeys().indexOf('flip.y') === -1,
|
|
116
124
|
},
|
|
117
125
|
{
|
|
118
126
|
type: SelectorExtendType.DELETE,
|
|
@@ -126,7 +134,7 @@ const defaultExtends: SelectorExtend[] = [
|
|
|
126
134
|
const sortData = (data: SelectorExtend[]) => {
|
|
127
135
|
const states: { [key: string | number]: SelectorExtend[] } = {};
|
|
128
136
|
data.forEach(c => {
|
|
129
|
-
const {category = 'empty'} = c;
|
|
137
|
+
const { category = 'empty' } = c;
|
|
130
138
|
states[category] = states[category] || [];
|
|
131
139
|
states[category].push(c);
|
|
132
140
|
states[category] = states[category].sort(
|
|
@@ -140,11 +148,17 @@ const sortData = (data: SelectorExtend[]) => {
|
|
|
140
148
|
|
|
141
149
|
const SelectorIcon = (props: {
|
|
142
150
|
item: SelectorExtend;
|
|
143
|
-
onChange: (type: SelectorExtendType |
|
|
144
|
-
context: PlaygroundContext2d
|
|
151
|
+
onChange: (type: SelectorExtendType | string, value?: any) => void;
|
|
152
|
+
context: PlaygroundContext2d;
|
|
145
153
|
node: any;
|
|
146
154
|
}) => {
|
|
147
|
-
const {item, onChange, node} = props;
|
|
155
|
+
const { item, onChange, context, node } = props;
|
|
156
|
+
const tooltipProps =
|
|
157
|
+
typeof item.tooltipProps === 'function'
|
|
158
|
+
? item.tooltipProps(node, context)
|
|
159
|
+
: item.tooltipProps || {};
|
|
160
|
+
const [open, setOpen] = React.useState(false);
|
|
161
|
+
item.changeCallback?.(setOpen);
|
|
148
162
|
const child = (
|
|
149
163
|
<div
|
|
150
164
|
className={clsx(getClassName('icon'), item.className)}
|
|
@@ -157,14 +171,15 @@ const SelectorIcon = (props: {
|
|
|
157
171
|
onChange?.(item.type);
|
|
158
172
|
}}
|
|
159
173
|
>
|
|
160
|
-
{selectIcon[item.type]}
|
|
174
|
+
{item.icon || selectIcon[item.type]}
|
|
161
175
|
</div>
|
|
162
176
|
);
|
|
163
177
|
if (item.event) {
|
|
164
|
-
|
|
178
|
+
const { hover, ...event } = item.event;
|
|
179
|
+
const pop = (
|
|
165
180
|
<Popover
|
|
166
181
|
content={props.context.formService.renderSchema({
|
|
167
|
-
...
|
|
182
|
+
...event,
|
|
168
183
|
context: {
|
|
169
184
|
node,
|
|
170
185
|
},
|
|
@@ -176,16 +191,33 @@ const SelectorIcon = (props: {
|
|
|
176
191
|
values: node,
|
|
177
192
|
size: 'middle',
|
|
178
193
|
})}
|
|
194
|
+
open={open}
|
|
179
195
|
title={item.event.title || item.title}
|
|
180
196
|
placement="right"
|
|
197
|
+
onOpenChange={() => {
|
|
198
|
+
setOpen(!open);
|
|
199
|
+
}}
|
|
200
|
+
{...tooltipProps}
|
|
181
201
|
>
|
|
182
202
|
{child}
|
|
183
203
|
</Popover>
|
|
184
204
|
);
|
|
205
|
+
if (hover) {
|
|
206
|
+
return <Tooltip {...hover}>{pop}</Tooltip>;
|
|
207
|
+
}
|
|
208
|
+
return pop;
|
|
185
209
|
}
|
|
186
210
|
if (item.title) {
|
|
187
211
|
return (
|
|
188
|
-
<Tooltip
|
|
212
|
+
<Tooltip
|
|
213
|
+
title={item.title}
|
|
214
|
+
open={open}
|
|
215
|
+
placement="right"
|
|
216
|
+
onOpenChange={() => {
|
|
217
|
+
setOpen(!open);
|
|
218
|
+
}}
|
|
219
|
+
{...tooltipProps}
|
|
220
|
+
>
|
|
189
221
|
{child}
|
|
190
222
|
</Tooltip>
|
|
191
223
|
);
|
|
@@ -194,15 +226,15 @@ const SelectorIcon = (props: {
|
|
|
194
226
|
};
|
|
195
227
|
|
|
196
228
|
export const SelectorExtendRender = (props: SelectorExtendProps) => {
|
|
197
|
-
const {entity, register, context} = props;
|
|
198
|
-
const {node} = entity as Editor2dEntity;
|
|
199
|
-
const {selectorExtends = []} = register?.decoration || {};
|
|
229
|
+
const { entity, register, context, customExtendSchema = [] } = props;
|
|
230
|
+
const { node } = entity as Editor2dEntity;
|
|
231
|
+
const { selectorExtends = [] } = register?.decoration || {};
|
|
200
232
|
const [t, update] = React.useState(0);
|
|
201
233
|
if (!node) return <></>;
|
|
202
234
|
|
|
203
235
|
const childData = sortData(
|
|
204
236
|
([] as SelectorExtend[])
|
|
205
|
-
.concat(defaultExtends, selectorExtends)
|
|
237
|
+
.concat(defaultExtends, selectorExtends, customExtendSchema)
|
|
206
238
|
.filter(c => (c.visible ? c.visible(node, register) : true))
|
|
207
239
|
);
|
|
208
240
|
const onChange = (type: SelectorExtendType | 'updateData', value?: any) => {
|
|
@@ -217,14 +249,14 @@ export const SelectorExtendRender = (props: SelectorExtendProps) => {
|
|
|
217
249
|
case SelectorExtendType.FLIP_X:
|
|
218
250
|
document.updateNode(
|
|
219
251
|
node,
|
|
220
|
-
{flip: {...node.flip!, x: !node?.flip?.x}},
|
|
252
|
+
{ flip: { ...node.flip!, x: !node?.flip?.x } },
|
|
221
253
|
true
|
|
222
254
|
);
|
|
223
255
|
break;
|
|
224
256
|
case SelectorExtendType.FLIP_Y:
|
|
225
257
|
document.updateNode(
|
|
226
258
|
node,
|
|
227
|
-
{flip: {...node.flip!, y: !node?.flip?.y}},
|
|
259
|
+
{ flip: { ...node.flip!, y: !node?.flip?.y } },
|
|
228
260
|
true
|
|
229
261
|
);
|
|
230
262
|
break;
|
|
@@ -5,51 +5,39 @@
|
|
|
5
5
|
overflow: visible;
|
|
6
6
|
z-index: 20;
|
|
7
7
|
&-point {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
height: 8px;
|
|
11
|
-
border-radius: 100%;
|
|
12
|
-
top: -4px;
|
|
13
|
-
left: -4px;
|
|
14
|
-
background-color: #fff; //var(--g-playground-select);
|
|
15
|
-
border: 1px solid #ccc;
|
|
8
|
+
stroke: #ccc;
|
|
9
|
+
fill: #fff;
|
|
16
10
|
cursor: pointer;
|
|
17
11
|
z-index: 50;
|
|
12
|
+
transition: stroke 0.2s ease-in-out, stroke-width 0.2s ease-in-out;
|
|
18
13
|
&-move {
|
|
19
14
|
z-index: 0;
|
|
20
15
|
}
|
|
16
|
+
&-closed {
|
|
17
|
+
cursor: url(../svg/pen_close.svg), copy;
|
|
18
|
+
}
|
|
21
19
|
}
|
|
22
20
|
&-point-bezier {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
height: 6px;
|
|
26
|
-
top: -3px;
|
|
27
|
-
left: -3px;
|
|
28
|
-
background-color: #fff;//var(--g-playground-select);
|
|
29
|
-
border: 1px solid #ccc;
|
|
30
|
-
border-radius: 100%;
|
|
21
|
+
stroke: #ccc;
|
|
22
|
+
fill: #fff;
|
|
31
23
|
cursor: pointer;
|
|
32
24
|
z-index: 50;
|
|
33
25
|
&-line {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
left: 0;
|
|
38
|
-
transform-origin: 0% 50%;
|
|
39
|
-
background-color: #bbb;
|
|
26
|
+
stroke: #bbb;
|
|
27
|
+
fill: none;
|
|
28
|
+
pointer-events: none;
|
|
40
29
|
}
|
|
41
30
|
}
|
|
31
|
+
&-point-active {
|
|
32
|
+
stroke: #aaa;
|
|
33
|
+
stroke-width: 2px;
|
|
34
|
+
}
|
|
42
35
|
&-pen {
|
|
43
|
-
// 移出画布
|
|
44
36
|
cursor: url(../svg/pen_add.svg), copy;
|
|
45
37
|
}
|
|
46
38
|
&-line {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
position: absolute;
|
|
50
|
-
top: 0;
|
|
51
|
-
left: 0;
|
|
52
|
-
transform-origin: 0% 50%;
|
|
39
|
+
stroke: #ccc;
|
|
40
|
+
fill: none;
|
|
53
41
|
z-index: 0;
|
|
54
42
|
}
|
|
55
43
|
&-svg {
|
|
@@ -57,7 +45,6 @@
|
|
|
57
45
|
overflow: visible;
|
|
58
46
|
left: 0;
|
|
59
47
|
top: 0;
|
|
60
|
-
cursor: url(../svg/pen_add.svg), copy;
|
|
61
48
|
z-index: 1;
|
|
62
49
|
}
|
|
63
50
|
&-path {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<svg width="20px" height="20px" viewBox="0 0 20 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
3
|
+
<title>pen_close</title>
|
|
4
|
+
<defs>
|
|
5
|
+
<rect id="path-1" x="0" y="0" width="20" height="20"></rect>
|
|
6
|
+
</defs>
|
|
7
|
+
<g id="页面-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
8
|
+
<g id="pen_close">
|
|
9
|
+
<mask id="mask-2" fill="white">
|
|
10
|
+
<use xlink:href="#path-1"></use>
|
|
11
|
+
</mask>
|
|
12
|
+
<g id="path-1"></g>
|
|
13
|
+
<g id="3-Pen" mask="url(#mask-2)">
|
|
14
|
+
<g transform="translate(-8.9503, -5.8277)" id="编组">
|
|
15
|
+
<g id="编组-3" transform="translate(15.9081, 15.9081) rotate(-33) translate(-15.9081, -15.9081)translate(4.4081, 4.4081)" fill-rule="nonzero">
|
|
16
|
+
<path d="M15.2636045,3.541283 C15.1463591,3.42389368 14.9824898,3.36270074 14.8080946,3.37118408 C14.6336994,3.37966741 14.4630852,3.45713107 14.3338359,3.58651098 L11.6470455,6.26392494 C11.5176657,6.39317433 11.440202,6.56378849 11.4317187,6.73818371 C11.4232353,6.91257892 11.4844283,7.07644823 11.6018176,7.19369369 L11.8768691,7.46874526 C10.5668432,8.45506004 9.02084742,9.03767616 7.45291352,9.13593475 C7.17991393,9.16129803 6.93457934,9.35190928 6.83636102,9.61496154 L3.41043657,18.7950899 C3.33416882,18.998745 3.35731687,19.2172739 3.47265178,19.3824321 C3.58798669,19.5475903 3.78145241,19.6392496 3.9926312,19.6287856 C4.06292863,19.6255581 4.13335027,19.6110664 4.20120966,19.5858632 L13.3818161,16.1500821 C13.6415844,16.0533232 13.8312241,15.8129004 13.8603634,15.5433857 C13.9604921,13.9787315 14.5428258,12.4364838 15.5270733,11.1292857 L15.8021248,11.4043373 C15.9193778,11.5205354 16.0825735,11.5809356 16.2560971,11.5723565 C16.4307018,11.5648704 16.6019069,11.488138 16.7318934,11.3591093 L19.4089874,8.67888941 C19.5435052,8.5487903 19.6244033,8.37447286 19.6330845,8.19600993 C19.6417657,8.01754701 19.5774832,7.85029179 19.4550144,7.73269362 L15.2636045,3.541283 Z" id="路径" stroke="#FFFFFF" fill="#000000" transform="translate(11.5, 11.5) rotate(135) translate(-11.5, -11.5)"></path>
|
|
17
|
+
<path d="M14.0272683,11.6425807 L7.59746278,14.0497581 L10.7844488,10.8596465 C11.2245543,10.9666112 11.7106563,10.753747 11.9661753,10.342168 C12.2216944,9.93058906 12.1818745,9.42460144 11.8693721,9.11209908 C11.5568698,8.79959672 11.0508821,8.75977682 10.6393032,9.01529586 C10.2277242,9.2708149 10.0148599,9.75691693 10.1218247,10.1970224 L6.93171313,13.3840084 L9.3388905,6.95420293 C11.0769107,6.75281134 12.7662556,6.04449086 14.1937469,4.91862435 L16.069098,6.79397547 C14.9422116,8.2189255 14.2317626,9.90598426 14.0272683,11.6425807 L14.0272683,11.6425807 Z" id="路径" fill="#FFFFFF" transform="translate(11.5004, 9.4842) rotate(135) translate(-11.5004, -9.4842)"></path>
|
|
18
|
+
</g>
|
|
19
|
+
<circle id="椭圆形" stroke="#000000" fill="#FFFFFF" cx="24.5" cy="10.5" r="3"></circle>
|
|
20
|
+
</g>
|
|
21
|
+
</g>
|
|
22
|
+
</g>
|
|
23
|
+
</g>
|
|
24
|
+
</svg>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CanvasDraw, CanvasDrawOpts } from '../playground/canvas-draw';
|
|
2
2
|
import {
|
|
3
3
|
debounce,
|
|
4
|
+
deepClone,
|
|
4
5
|
Disposable,
|
|
5
6
|
DisposableCollection,
|
|
6
7
|
DisposableImpl,
|
|
@@ -75,7 +76,7 @@ export class SnapshotCreator extends DisposableImpl {
|
|
|
75
76
|
if (!host) {
|
|
76
77
|
host = document.createElement('div');
|
|
77
78
|
host.className = 'gedit-editor-snapshots';
|
|
78
|
-
host.style.display = 'none';
|
|
79
|
+
// host.style.display = 'none';
|
|
79
80
|
document.body.appendChild(host);
|
|
80
81
|
}
|
|
81
82
|
this.drawer = new CanvasDraw({
|
|
@@ -160,6 +161,14 @@ export class SnapshotCreator extends DisposableImpl {
|
|
|
160
161
|
this.next(() => dispose.dispose());
|
|
161
162
|
return deferred.promise;
|
|
162
163
|
}
|
|
164
|
+
protected setParent(n: Editor2dNode): Editor2dNode {
|
|
165
|
+
if (!n.children) return n;
|
|
166
|
+
n.children.forEach((c: Editor2dNode) => {
|
|
167
|
+
c.parent = n as any;
|
|
168
|
+
this.setParent(c);
|
|
169
|
+
});
|
|
170
|
+
return n;
|
|
171
|
+
}
|
|
163
172
|
protected next(end: () => void): void {
|
|
164
173
|
const next = this.processingData.shift();
|
|
165
174
|
if (next) {
|
|
@@ -173,6 +182,8 @@ export class SnapshotCreator extends DisposableImpl {
|
|
|
173
182
|
const attrs = this.opts.renderEngine.getDisplayDefaultData(this.opts.engineName, content.displayType);
|
|
174
183
|
Object.assign(content, { ...attrs });
|
|
175
184
|
}
|
|
185
|
+
// 设置 parent, 保持 id 一致; mask 里用的是 path id;
|
|
186
|
+
content = this.setParent(deepClone(content));
|
|
176
187
|
this.drawer.update({
|
|
177
188
|
visible: true,
|
|
178
189
|
uri: next.uri,
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2020 GEdit
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { PathChild } from '@gedit/canvas-draw';
|
|
3
|
-
import { PositionSchema } from '@gedit/playground';
|
|
4
|
-
export interface PointSchema extends PositionSchema {
|
|
5
|
-
id?: string;
|
|
6
|
-
}
|
|
7
|
-
export declare const PointDefault: ({ getPosFromMouseEvent, paths, scale, }: {
|
|
8
|
-
getPosFromMouseEvent: (event: {
|
|
9
|
-
clientX: number;
|
|
10
|
-
clientY: number;
|
|
11
|
-
}, addScale?: boolean) => PointSchema;
|
|
12
|
-
paths: PathChild[];
|
|
13
|
-
scale: number;
|
|
14
|
-
}) => React.JSX.Element;
|
|
15
|
-
//# sourceMappingURL=path-edit-layer-move-point.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"path-edit-layer-move-point.d.ts","sourceRoot":"","sources":["../../../src/browser/playground/path-edit-layer-move-point.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAuB,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,MAAM,WAAW,WAAY,SAAQ,cAAc;IACjD,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AACD,eAAO,MAAM,YAAY;kCAMd;QACL,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;KACjB,aACU,OAAO,KACf,WAAW;WACT,SAAS,EAAE;WACX,MAAM;uBAkDd,CAAC"}
|