Skip to content

Commit fe31246

Browse files
authored
feat: add select parent node of selected node (#158)
* feat: add select parent node of selected node * feat: move select parent node to SelectSource * fix: change icon & order --------- Co-authored-by: ccloli <[email protected]>
1 parent 9daf387 commit fe31246

File tree

9 files changed

+49
-5
lines changed

9 files changed

+49
-5
lines changed

apps/playground/src/pages/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ const sandboxQuery = new DndQuery({
8989

9090
// 4. 图标库初始化(物料面板和组件树使用了 iconfont 里的图标)
9191
createFromIconfontCN({
92-
scriptUrl: '//at.alicdn.com/t/c/font_2891794_cxbtmzehxyi.js',
92+
scriptUrl: '//at.alicdn.com/t/c/font_2891794_151xsllxqd7.js',
9393
});
9494

9595
/**

apps/playground/src/pages/mail.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const sandboxQuery = new DndQuery({
4545

4646
// 4. 图标库初始化(物料面板和组件树使用了 iconfont 里的图标)
4747
createFromIconfontCN({
48-
scriptUrl: '//at.alicdn.com/t/c/font_2891794_cxbtmzehxyi.js',
48+
scriptUrl: '//at.alicdn.com/t/c/font_2891794_151xsllxqd7.js',
4949
});
5050

5151
/**

apps/storybook/src/setting-form.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const BLACK_LIST = ['codeSetter', 'eventSetter', 'modelSetter', 'routerSetter'];
1414
BUILT_IN_SETTERS.filter((setter) => !BLACK_LIST.includes(setter.name)).forEach(register);
1515

1616
createFromIconfontCN({
17-
scriptUrl: '//at.alicdn.com/t/c/font_2891794_cxbtmzehxyi.js',
17+
scriptUrl: '//at.alicdn.com/t/c/font_2891794_151xsllxqd7.js',
1818
});
1919

2020
export default {

packages/core/src/models/select-source.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,20 @@ export class SelectSource {
109109
this._start = null;
110110
}
111111

112+
/**
113+
* 选中当前选中节点的父节点
114+
*/
115+
selectParent() {
116+
const parents = this.first?.parents || [];
117+
if (parents.length) {
118+
const [parent, ...rest] = parents;
119+
this.select({
120+
...parent,
121+
parents: rest,
122+
});
123+
}
124+
}
125+
112126
setStart(data: StartDataType) {
113127
this._start = data;
114128
}

packages/designer/src/dnd/use-dnd.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ export function useDnd({
5858
'command+v,ctrl+v': () => {
5959
workspace.pasteSelectedNode();
6060
},
61+
'command+arrowup,ctrl+arrowup': () => {
62+
workspace.selectSource.selectParent();
63+
},
6164
'command+z,ctrl+z': () => {
6265
workspace.history.back();
6366
},
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export * from './copy-node';
22
export * from './delete-node';
3+
export * from './select-parent-node';
34
export * from './view-source';
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React from 'react';
2+
import { useWorkspace, observer } from '@music163/tango-context';
3+
import { IconFont, SelectAction } from '@music163/tango-ui';
4+
5+
export const SelectParentNodeAction = observer(() => {
6+
const workspace = useWorkspace();
7+
8+
return (
9+
<SelectAction
10+
tooltip="选中父节点"
11+
onClick={() => {
12+
workspace.selectSource.selectParent();
13+
}}
14+
>
15+
<IconFont type="icon-huiche1" rotate={90} />
16+
</SelectAction>
17+
);
18+
});

packages/designer/src/simulator/selection.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ export interface SelectionToolsProps {
2424
}
2525

2626
export const SelectionTools = observer(
27-
({ actions: actionsProp = ['viewSource', 'copyNode', 'deleteNode'] }: SelectionToolsProps) => {
27+
({
28+
actions: actionsProp = ['selectParentNode', 'viewSource', 'copyNode', 'deleteNode'],
29+
}: SelectionToolsProps) => {
2830
const workspace = useWorkspace();
2931
const selectSource = workspace.selectSource;
3032
const actions = actionsProp.map((item) => {

packages/designer/src/widgets.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ import {
1313
OutlinePanel,
1414
VariablePanel,
1515
} from './sidebar';
16-
import { CopyNodeAction, DeleteNodeAction, ViewSourceAction } from './selection-menu';
16+
import {
17+
CopyNodeAction,
18+
DeleteNodeAction,
19+
ViewSourceAction,
20+
SelectParentNodeAction,
21+
} from './selection-menu';
1722

1823
const widgets = {};
1924

@@ -48,4 +53,5 @@ registerWidget('sidebar.dataSource', DataSourcePanel);
4853

4954
registerWidget('selectionMenu.copyNode', CopyNodeAction);
5055
registerWidget('selectionMenu.deleteNode', DeleteNodeAction);
56+
registerWidget('selectionMenu.selectParentNode', SelectParentNodeAction);
5157
registerWidget('selectionMenu.viewSource', ViewSourceAction);

0 commit comments

Comments
 (0)