@flowgram.ai/free-hover-plugin 0.1.0-alpha.7 → 0.1.0-alpha.8
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/esm/index.js +12 -10
- package/dist/esm/index.js.map +1 -1
- package/dist/index.js +11 -9
- package/dist/index.js.map +1 -1
- package/package.json +11 -11
package/dist/esm/index.js
CHANGED
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
WorkflowSelectService
|
|
26
26
|
} from "@flowgram.ai/free-layout-core";
|
|
27
27
|
import { WorkflowPortEntity } from "@flowgram.ai/free-layout-core";
|
|
28
|
-
import { FlowNodeTransformData as FlowNodeTransformData2 } from "@flowgram.ai/document";
|
|
28
|
+
import { FlowNodeBaseType, FlowNodeTransformData as FlowNodeTransformData2 } from "@flowgram.ai/document";
|
|
29
29
|
import {
|
|
30
30
|
EditorState,
|
|
31
31
|
EditorStateConfigEntity,
|
|
@@ -69,7 +69,7 @@ var HoverLayer = class extends Layer {
|
|
|
69
69
|
}
|
|
70
70
|
autorun() {
|
|
71
71
|
const { activatedNode } = this.selectionService;
|
|
72
|
-
this.nodeTransformsWithSort = this.nodeTransforms.filter((n) => n.entity.id !== "root").reverse().sort((n1) => n1.entity === activatedNode ? -1 : 0);
|
|
72
|
+
this.nodeTransformsWithSort = this.nodeTransforms.filter((n) => n.entity.id !== "root" && n.entity.flowNodeType !== FlowNodeBaseType.GROUP).reverse().sort((n1) => n1.entity === activatedNode ? -1 : 0);
|
|
73
73
|
}
|
|
74
74
|
/**
|
|
75
75
|
* 是否正在调整线条
|
|
@@ -94,11 +94,12 @@ var HoverLayer = class extends Layer {
|
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
96
|
const mousePos = this.config.getPosFromMouseEvent(e);
|
|
97
|
-
this.updateHoveredState(mousePos, e
|
|
97
|
+
this.updateHoveredState(mousePos, e == null ? void 0 : e.target);
|
|
98
98
|
}),
|
|
99
99
|
this.selectionService.onSelectionChanged(() => this.autorun()),
|
|
100
100
|
// 控制选中逻辑
|
|
101
101
|
this.listenPlaygroundEvent("mousedown", (e) => {
|
|
102
|
+
var _a;
|
|
102
103
|
if (!this.isEnabled() || this.isDrawing) {
|
|
103
104
|
return void 0;
|
|
104
105
|
}
|
|
@@ -120,7 +121,7 @@ var HoverLayer = class extends Layer {
|
|
|
120
121
|
true
|
|
121
122
|
);
|
|
122
123
|
if (selectionBounds.width > 0 && selectionBounds.contains(mousePos.x, mousePos.y)) {
|
|
123
|
-
this.dragService.startDragSelectedNodes(e)
|
|
124
|
+
(_a = this.dragService.startDragSelectedNodes(e)) == null ? void 0 : _a.then((dragSuccess) => {
|
|
124
125
|
if (!dragSuccess) {
|
|
125
126
|
if (hoveredNode && hoveredNode instanceof WorkflowNodeEntity2) {
|
|
126
127
|
if (e.shiftKey) {
|
|
@@ -148,6 +149,7 @@ var HoverLayer = class extends Layer {
|
|
|
148
149
|
* @param mousePos
|
|
149
150
|
*/
|
|
150
151
|
updateHoveredState(mousePos, target) {
|
|
152
|
+
var _a, _b, _c;
|
|
151
153
|
const { hoverService } = this;
|
|
152
154
|
const nodeTransforms = this.nodeTransformsWithSort;
|
|
153
155
|
const portHovered = this.linesManager.getPortFromMousePos(mousePos);
|
|
@@ -158,7 +160,7 @@ var HoverLayer = class extends Layer {
|
|
|
158
160
|
if (portHovered) {
|
|
159
161
|
if (portHovered.portType === "output") {
|
|
160
162
|
hoverService.updateHoveredKey(portHovered.id);
|
|
161
|
-
} else if (checkTargetFromLine || target
|
|
163
|
+
} else if (checkTargetFromLine || ((_b = (_a = target == null ? void 0 : target.className) == null ? void 0 : _a.includes) == null ? void 0 : _b.call(_a, PORT_BG_CLASS_NAME))) {
|
|
162
164
|
const lineHovered2 = this.linesManager.getCloseInLineFromMousePos(mousePos);
|
|
163
165
|
if (lineHovered2) {
|
|
164
166
|
this.updateHoveredKey(lineHovered2.id);
|
|
@@ -169,21 +171,21 @@ var HoverLayer = class extends Layer {
|
|
|
169
171
|
if (this.isDrawing) {
|
|
170
172
|
return;
|
|
171
173
|
}
|
|
172
|
-
const nodeHovered = nodeTransforms.find(
|
|
174
|
+
const nodeHovered = (_c = nodeTransforms.find(
|
|
173
175
|
(trans) => trans.bounds.contains(mousePos.x, mousePos.y)
|
|
174
|
-
)
|
|
176
|
+
)) == null ? void 0 : _c.entity;
|
|
175
177
|
const nodeDomNodes = this.playgroundNode.querySelectorAll(NODE_CLASS_NAME);
|
|
176
178
|
const checkTargetFromNode = [...nodeDomNodes].some(
|
|
177
179
|
(nodeDom) => nodeDom.contains(target)
|
|
178
180
|
);
|
|
179
181
|
if (nodeHovered || checkTargetFromNode) {
|
|
180
|
-
if (nodeHovered
|
|
182
|
+
if (nodeHovered == null ? void 0 : nodeHovered.id) {
|
|
181
183
|
this.updateHoveredKey(nodeHovered.id);
|
|
182
184
|
}
|
|
183
185
|
}
|
|
184
|
-
const nodeInContainer = !!(nodeHovered
|
|
186
|
+
const nodeInContainer = !!((nodeHovered == null ? void 0 : nodeHovered.parent) && nodeHovered.parent.flowNodeType !== "root");
|
|
185
187
|
const lineHovered = checkTargetFromLine ? this.linesManager.getCloseInLineFromMousePos(mousePos) : void 0;
|
|
186
|
-
const lineInContainer = !!lineHovered
|
|
188
|
+
const lineInContainer = !!(lineHovered == null ? void 0 : lineHovered.inContainer);
|
|
187
189
|
if (nodeHovered && nodeInContainer) {
|
|
188
190
|
this.updateHoveredKey(nodeHovered.id);
|
|
189
191
|
return;
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/create-free-hover-plugin.ts","../../src/hover-layer.tsx","../../src/selection-utils.ts"],"sourcesContent":["import { definePluginCreator } from '@flowgram.ai/core';\n\nimport { HoverLayer } from './hover-layer';\n\nexport const createFreeHoverPlugin = definePluginCreator({\n onInit(ctx): void {\n ctx.playground.registerLayer(HoverLayer);\n },\n});\n","/* eslint-disable complexity */\nimport { inject, injectable } from 'inversify';\nimport { type IPoint } from '@flowgram.ai/utils';\nimport { SelectorBoxConfigEntity } from '@flowgram.ai/renderer';\nimport {\n WorkflowDocument,\n WorkflowDragService,\n WorkflowHoverService,\n WorkflowLineEntity,\n WorkflowLinesManager,\n WorkflowNodeEntity,\n WorkflowSelectService,\n} from '@flowgram.ai/free-layout-core';\nimport { WorkflowPortEntity } from '@flowgram.ai/free-layout-core';\nimport { FlowNodeTransformData } from '@flowgram.ai/document';\nimport {\n EditorState,\n EditorStateConfigEntity,\n Layer,\n PlaygroundConfigEntity,\n observeEntities,\n observeEntity,\n observeEntityDatas,\n type LayerOptions,\n} from '@flowgram.ai/core';\n\nimport { getSelectionBounds } from './selection-utils';\nconst PORT_BG_CLASS_NAME = 'workflow-port-bg';\n\nexport interface HoverLayerOptions extends LayerOptions {\n canHovered?: (e: MouseEvent, service: WorkflowHoverService) => boolean;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace HoverLayerOptions {\n export const DEFAULT: HoverLayerOptions = {\n canHovered: () => true,\n };\n}\n\nconst LINE_CLASS_NAME = '.gedit-flow-activity-line';\nconst NODE_CLASS_NAME = '.gedit-flow-activity-node';\n\n@injectable()\nexport class HoverLayer extends Layer<HoverLayerOptions> {\n static type = 'HoverLayer';\n\n @inject(WorkflowDocument) document: WorkflowDocument;\n\n @inject(WorkflowSelectService) selectionService: WorkflowSelectService;\n\n @inject(WorkflowDragService) dragService: WorkflowDragService;\n\n @inject(WorkflowHoverService) hoverService: WorkflowHoverService;\n\n @inject(WorkflowLinesManager)\n linesManager: WorkflowLinesManager;\n\n @observeEntity(EditorStateConfigEntity)\n protected editorStateConfig: EditorStateConfigEntity;\n\n @observeEntity(SelectorBoxConfigEntity)\n protected selectorBoxConfigEntity: SelectorBoxConfigEntity;\n\n @inject(PlaygroundConfigEntity) configEntity: PlaygroundConfigEntity;\n\n /**\n * 监听节点 transform\n */\n @observeEntityDatas(WorkflowNodeEntity, FlowNodeTransformData)\n protected readonly nodeTransforms: FlowNodeTransformData[];\n\n /**\n * 按选中排序\n * @private\n */\n protected nodeTransformsWithSort: FlowNodeTransformData[] = [];\n\n autorun(): void {\n const { activatedNode } = this.selectionService;\n this.nodeTransformsWithSort = this.nodeTransforms\n .filter((n) => n.entity.id !== 'root')\n .reverse() // 后创建的排在前面\n .sort((n1) => (n1.entity === activatedNode ? -1 : 0));\n }\n\n /**\n * 监听线条\n */\n @observeEntities(WorkflowLineEntity)\n protected readonly lines: WorkflowLineEntity[];\n\n /**\n * 是否正在调整线条\n * @protected\n */\n get isDrawing(): boolean {\n return this.linesManager.isDrawing;\n }\n\n onReady(): void {\n this.options = {\n ...HoverLayerOptions.DEFAULT,\n ...this.options,\n };\n this.toDispose.pushAll([\n // 监听画布鼠标移动事件\n this.listenPlaygroundEvent('mousemove', (e: MouseEvent) => {\n this.hoverService.hoveredPos = this.config.getPosFromMouseEvent(e);\n if (!this.isEnabled()) {\n return;\n }\n if (!this.options.canHovered!(e, this.hoverService)) {\n return;\n }\n const mousePos = this.config.getPosFromMouseEvent(e);\n // 更新 hover 状态\n this.updateHoveredState(mousePos, e?.target as HTMLElement);\n }),\n this.selectionService.onSelectionChanged(() => this.autorun()),\n // 控制选中逻辑\n this.listenPlaygroundEvent('mousedown', (e: MouseEvent): boolean | undefined => {\n if (!this.isEnabled() || this.isDrawing) {\n return undefined;\n }\n const { hoveredNode } = this.hoverService;\n // 重置线条\n if (hoveredNode && hoveredNode instanceof WorkflowLineEntity) {\n this.dragService.resetLine(hoveredNode, e);\n return true;\n }\n if (\n hoveredNode &&\n hoveredNode instanceof WorkflowPortEntity &&\n hoveredNode.portType !== 'input' &&\n !hoveredNode.disabled &&\n e.button !== 1\n ) {\n e.stopPropagation();\n e.preventDefault();\n this.dragService.startDrawingLine(hoveredNode, e);\n return true;\n }\n const mousePos = this.config.getPosFromMouseEvent(e);\n const selectionBounds = getSelectionBounds(\n this.selectionService.selection,\n // 这里只考虑多选模式,单选模式已经下沉到 use-node-render 中\n true\n );\n if (selectionBounds.width > 0 && selectionBounds.contains(mousePos.x, mousePos.y)) {\n /**\n * 拖拽选择框\n */\n this.dragService.startDragSelectedNodes(e)?.then((dragSuccess) => {\n if (!dragSuccess) {\n // 拖拽没有成功触发了点击\n if (hoveredNode && hoveredNode instanceof WorkflowNodeEntity) {\n // 追加选择\n if (e.shiftKey) {\n this.selectionService.toggleSelect(hoveredNode);\n } else {\n this.selectionService.selectNode(hoveredNode);\n }\n } else {\n this.selectionService.clear();\n }\n }\n });\n // 这里会组织触发 selector box\n return true;\n } else {\n if (!hoveredNode) {\n this.selectionService.clear();\n }\n }\n return undefined;\n }),\n ]);\n }\n\n /**\n * 更新 hoverd\n * @param mousePos\n */\n updateHoveredState(mousePos: IPoint, target?: HTMLElement): void {\n const { hoverService } = this;\n const nodeTransforms = this.nodeTransformsWithSort;\n // // 判断连接点是否 hover\n const portHovered = this.linesManager.getPortFromMousePos(mousePos);\n\n const lineDomNodes = this.playgroundNode.querySelectorAll(LINE_CLASS_NAME);\n const checkTargetFromLine = [...lineDomNodes].some((lineDom) =>\n lineDom.contains(target as HTMLElement)\n );\n // 默认 只有 output 点位可以 hover\n if (portHovered) {\n // 输出点可以直接选中\n if (portHovered.portType === 'output') {\n hoverService.updateHoveredKey(portHovered.id);\n } else if (checkTargetFromLine || target?.className?.includes?.(PORT_BG_CLASS_NAME)) {\n // 输入点采用获取最接近的线条\n const lineHovered = this.linesManager.getCloseInLineFromMousePos(mousePos);\n if (lineHovered) {\n this.updateHoveredKey(lineHovered.id);\n }\n }\n return;\n }\n\n // Drawing 情况,不能选中节点和线条\n if (this.isDrawing) {\n return;\n }\n\n const nodeHovered = nodeTransforms.find((trans: FlowNodeTransformData) =>\n trans.bounds.contains(mousePos.x, mousePos.y)\n )?.entity as WorkflowNodeEntity;\n\n // 判断当前鼠标位置所在元素是否在节点内部\n const nodeDomNodes = this.playgroundNode.querySelectorAll(NODE_CLASS_NAME);\n const checkTargetFromNode = [...nodeDomNodes].some((nodeDom) =>\n nodeDom.contains(target as HTMLElement)\n );\n\n if (nodeHovered || checkTargetFromNode) {\n if (nodeHovered?.id) {\n this.updateHoveredKey(nodeHovered.id);\n }\n }\n\n const nodeInContainer = !!(nodeHovered?.parent && nodeHovered.parent.flowNodeType !== 'root');\n\n // 获取最接近的线条\n // 线条会相交需要获取最接近点位的线条,不能删除的线条不能被选中\n const lineHovered = checkTargetFromLine\n ? this.linesManager.getCloseInLineFromMousePos(mousePos)\n : undefined;\n const lineInContainer = !!lineHovered?.inContainer;\n\n // 判断容器内节点是否 hover\n if (nodeHovered && nodeInContainer) {\n this.updateHoveredKey(nodeHovered.id);\n return;\n }\n // 判断容器内线条是否 hover\n if (lineHovered && lineInContainer) {\n this.updateHoveredKey(lineHovered.id);\n return;\n }\n\n // 判断节点是否 hover\n if (nodeHovered) {\n this.updateHoveredKey(nodeHovered.id);\n return;\n }\n // 判断线条是否 hover\n if (lineHovered) {\n this.hoverService.updateHoveredKey(lineHovered.id);\n return;\n }\n\n // 上述逻辑都未命中 则清空 hoverd\n hoverService.clearHovered();\n\n const currentState = this.editorStateConfig.getCurrentState();\n const isMouseFriendly = currentState === EditorState.STATE_MOUSE_FRIENDLY_SELECT;\n\n // 鼠标优先,并且不是按住 shift 键,更新为小手\n if (isMouseFriendly && !this.editorStateConfig.isPressingShift) {\n this.configEntity.updateCursor('grab');\n }\n }\n\n updateHoveredKey(key: string): void {\n // 鼠标优先交互模式,如果是 hover,需要将鼠标的小手去掉,还原鼠标原有样式\n this.configEntity.updateCursor('default');\n this.hoverService.updateHoveredKey(key);\n }\n\n /**\n * 判断是否能够 hover\n * @returns 是否能 hover\n */\n isEnabled(): boolean {\n const currentState = this.editorStateConfig.getCurrentState();\n // 选择框情况禁止 hover\n return (\n // 鼠标友好模式下,也需要支持 hover 效果,不然线条选择不到\n // Coze 中没有使用该插件,需要在 workflow/render 包相应位置改动\n (currentState === EditorState.STATE_SELECT ||\n currentState === EditorState.STATE_MOUSE_FRIENDLY_SELECT) &&\n !this.selectorBoxConfigEntity.isStart &&\n !this.dragService.isDragging\n );\n }\n}\n","import { Rectangle } from '@flowgram.ai/utils';\nimport { WorkflowNodeEntity } from '@flowgram.ai/free-layout-core';\nimport { FlowNodeTransformData } from '@flowgram.ai/document';\nimport { type Entity } from '@flowgram.ai/core';\n\nconst BOUNDS_PADDING = 2;\n\nexport function getSelectionBounds(\n selection: Entity[],\n ignoreOneSelect: boolean = true // 忽略单选\n): Rectangle {\n const selectedNodes = selection.filter((node) => node instanceof WorkflowNodeEntity);\n\n // 选中单个的时候不显示\n return selectedNodes.length > (ignoreOneSelect ? 1 : 0)\n ? Rectangle.enlarge(selectedNodes.map((n) => n.getData(FlowNodeTransformData)!.bounds)).pad(\n BOUNDS_PADDING\n )\n : Rectangle.EMPTY;\n}\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,2BAA2B;;;ACCpC,SAAS,QAAQ,kBAAkB;AAEnC,SAAS,+BAA+B;AACxC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,sBAAAA;AAAA,EACA;AAAA,OACK;AACP,SAAS,0BAA0B;AACnC,SAAS,yBAAAC,8BAA6B;AACtC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;;;ACxBP,SAAS,iBAAiB;AAC1B,SAAS,0BAA0B;AACnC,SAAS,6BAA6B;AAGtC,IAAM,iBAAiB;AAEhB,SAAS,mBACd,WACA,kBAA2B,MAChB;AACX,QAAM,gBAAgB,UAAU,OAAO,CAAC,SAAS,gBAAgB,kBAAkB;AAGnF,SAAO,cAAc,UAAU,kBAAkB,IAAI,KACjD,UAAU,QAAQ,cAAc,IAAI,CAAC,MAAM,EAAE,QAAQ,qBAAqB,EAAG,MAAM,CAAC,EAAE;AAAA,IACpF;AAAA,EACF,IACA,UAAU;AAChB;;;ADQA,IAAM,qBAAqB;AAOpB,IAAU;AAAA,CAA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ayerOptions","WorkflowNodeEntity","lineHovered","FlowNodeTransformData"]}
|
|
1
|
+
{"version":3,"sources":["../../src/create-free-hover-plugin.ts","../../src/hover-layer.tsx","../../src/selection-utils.ts"],"sourcesContent":["import { definePluginCreator } from '@flowgram.ai/core';\n\nimport { HoverLayer } from './hover-layer';\n\nexport const createFreeHoverPlugin = definePluginCreator({\n onInit(ctx): void {\n ctx.playground.registerLayer(HoverLayer);\n },\n});\n","/* eslint-disable complexity */\nimport { inject, injectable } from 'inversify';\nimport { type IPoint } from '@flowgram.ai/utils';\nimport { SelectorBoxConfigEntity } from '@flowgram.ai/renderer';\nimport {\n WorkflowDocument,\n WorkflowDragService,\n WorkflowHoverService,\n WorkflowLineEntity,\n WorkflowLinesManager,\n WorkflowNodeEntity,\n WorkflowSelectService,\n} from '@flowgram.ai/free-layout-core';\nimport { WorkflowPortEntity } from '@flowgram.ai/free-layout-core';\nimport { FlowNodeBaseType, FlowNodeTransformData } from '@flowgram.ai/document';\nimport {\n EditorState,\n EditorStateConfigEntity,\n Layer,\n PlaygroundConfigEntity,\n observeEntities,\n observeEntity,\n observeEntityDatas,\n type LayerOptions,\n} from '@flowgram.ai/core';\n\nimport { getSelectionBounds } from './selection-utils';\nconst PORT_BG_CLASS_NAME = 'workflow-port-bg';\n\nexport interface HoverLayerOptions extends LayerOptions {\n canHovered?: (e: MouseEvent, service: WorkflowHoverService) => boolean;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace HoverLayerOptions {\n export const DEFAULT: HoverLayerOptions = {\n canHovered: () => true,\n };\n}\n\nconst LINE_CLASS_NAME = '.gedit-flow-activity-line';\nconst NODE_CLASS_NAME = '.gedit-flow-activity-node';\n\n@injectable()\nexport class HoverLayer extends Layer<HoverLayerOptions> {\n static type = 'HoverLayer';\n\n @inject(WorkflowDocument) document: WorkflowDocument;\n\n @inject(WorkflowSelectService) selectionService: WorkflowSelectService;\n\n @inject(WorkflowDragService) dragService: WorkflowDragService;\n\n @inject(WorkflowHoverService) hoverService: WorkflowHoverService;\n\n @inject(WorkflowLinesManager)\n linesManager: WorkflowLinesManager;\n\n @observeEntity(EditorStateConfigEntity)\n protected editorStateConfig: EditorStateConfigEntity;\n\n @observeEntity(SelectorBoxConfigEntity)\n protected selectorBoxConfigEntity: SelectorBoxConfigEntity;\n\n @inject(PlaygroundConfigEntity) configEntity: PlaygroundConfigEntity;\n\n /**\n * 监听节点 transform\n */\n @observeEntityDatas(WorkflowNodeEntity, FlowNodeTransformData)\n protected readonly nodeTransforms: FlowNodeTransformData[];\n\n /**\n * 按选中排序\n * @private\n */\n protected nodeTransformsWithSort: FlowNodeTransformData[] = [];\n\n autorun(): void {\n const { activatedNode } = this.selectionService;\n this.nodeTransformsWithSort = this.nodeTransforms\n .filter((n) => n.entity.id !== 'root' && n.entity.flowNodeType !== FlowNodeBaseType.GROUP)\n .reverse() // 后创建的排在前面\n .sort((n1) => (n1.entity === activatedNode ? -1 : 0));\n }\n\n /**\n * 监听线条\n */\n @observeEntities(WorkflowLineEntity)\n protected readonly lines: WorkflowLineEntity[];\n\n /**\n * 是否正在调整线条\n * @protected\n */\n get isDrawing(): boolean {\n return this.linesManager.isDrawing;\n }\n\n onReady(): void {\n this.options = {\n ...HoverLayerOptions.DEFAULT,\n ...this.options,\n };\n this.toDispose.pushAll([\n // 监听画布鼠标移动事件\n this.listenPlaygroundEvent('mousemove', (e: MouseEvent) => {\n this.hoverService.hoveredPos = this.config.getPosFromMouseEvent(e);\n if (!this.isEnabled()) {\n return;\n }\n if (!this.options.canHovered!(e, this.hoverService)) {\n return;\n }\n const mousePos = this.config.getPosFromMouseEvent(e);\n // 更新 hover 状态\n this.updateHoveredState(mousePos, e?.target as HTMLElement);\n }),\n this.selectionService.onSelectionChanged(() => this.autorun()),\n // 控制选中逻辑\n this.listenPlaygroundEvent('mousedown', (e: MouseEvent): boolean | undefined => {\n if (!this.isEnabled() || this.isDrawing) {\n return undefined;\n }\n const { hoveredNode } = this.hoverService;\n // 重置线条\n if (hoveredNode && hoveredNode instanceof WorkflowLineEntity) {\n this.dragService.resetLine(hoveredNode, e);\n return true;\n }\n if (\n hoveredNode &&\n hoveredNode instanceof WorkflowPortEntity &&\n hoveredNode.portType !== 'input' &&\n !hoveredNode.disabled &&\n e.button !== 1\n ) {\n e.stopPropagation();\n e.preventDefault();\n this.dragService.startDrawingLine(hoveredNode, e);\n return true;\n }\n const mousePos = this.config.getPosFromMouseEvent(e);\n const selectionBounds = getSelectionBounds(\n this.selectionService.selection,\n // 这里只考虑多选模式,单选模式已经下沉到 use-node-render 中\n true\n );\n if (selectionBounds.width > 0 && selectionBounds.contains(mousePos.x, mousePos.y)) {\n /**\n * 拖拽选择框\n */\n this.dragService.startDragSelectedNodes(e)?.then((dragSuccess) => {\n if (!dragSuccess) {\n // 拖拽没有成功触发了点击\n if (hoveredNode && hoveredNode instanceof WorkflowNodeEntity) {\n // 追加选择\n if (e.shiftKey) {\n this.selectionService.toggleSelect(hoveredNode);\n } else {\n this.selectionService.selectNode(hoveredNode);\n }\n } else {\n this.selectionService.clear();\n }\n }\n });\n // 这里会组织触发 selector box\n return true;\n } else {\n if (!hoveredNode) {\n this.selectionService.clear();\n }\n }\n return undefined;\n }),\n ]);\n }\n\n /**\n * 更新 hoverd\n * @param mousePos\n */\n updateHoveredState(mousePos: IPoint, target?: HTMLElement): void {\n const { hoverService } = this;\n const nodeTransforms = this.nodeTransformsWithSort;\n // // 判断连接点是否 hover\n const portHovered = this.linesManager.getPortFromMousePos(mousePos);\n\n const lineDomNodes = this.playgroundNode.querySelectorAll(LINE_CLASS_NAME);\n const checkTargetFromLine = [...lineDomNodes].some((lineDom) =>\n lineDom.contains(target as HTMLElement)\n );\n // 默认 只有 output 点位可以 hover\n if (portHovered) {\n // 输出点可以直接选中\n if (portHovered.portType === 'output') {\n hoverService.updateHoveredKey(portHovered.id);\n } else if (checkTargetFromLine || target?.className?.includes?.(PORT_BG_CLASS_NAME)) {\n // 输入点采用获取最接近的线条\n const lineHovered = this.linesManager.getCloseInLineFromMousePos(mousePos);\n if (lineHovered) {\n this.updateHoveredKey(lineHovered.id);\n }\n }\n return;\n }\n\n // Drawing 情况,不能选中节点和线条\n if (this.isDrawing) {\n return;\n }\n\n const nodeHovered = nodeTransforms.find((trans: FlowNodeTransformData) =>\n trans.bounds.contains(mousePos.x, mousePos.y)\n )?.entity as WorkflowNodeEntity;\n\n // 判断当前鼠标位置所在元素是否在节点内部\n const nodeDomNodes = this.playgroundNode.querySelectorAll(NODE_CLASS_NAME);\n const checkTargetFromNode = [...nodeDomNodes].some((nodeDom) =>\n nodeDom.contains(target as HTMLElement)\n );\n\n if (nodeHovered || checkTargetFromNode) {\n if (nodeHovered?.id) {\n this.updateHoveredKey(nodeHovered.id);\n }\n }\n\n const nodeInContainer = !!(nodeHovered?.parent && nodeHovered.parent.flowNodeType !== 'root');\n\n // 获取最接近的线条\n // 线条会相交需要获取最接近点位的线条,不能删除的线条不能被选中\n const lineHovered = checkTargetFromLine\n ? this.linesManager.getCloseInLineFromMousePos(mousePos)\n : undefined;\n const lineInContainer = !!lineHovered?.inContainer;\n\n // 判断容器内节点是否 hover\n if (nodeHovered && nodeInContainer) {\n this.updateHoveredKey(nodeHovered.id);\n return;\n }\n // 判断容器内线条是否 hover\n if (lineHovered && lineInContainer) {\n this.updateHoveredKey(lineHovered.id);\n return;\n }\n\n // 判断节点是否 hover\n if (nodeHovered) {\n this.updateHoveredKey(nodeHovered.id);\n return;\n }\n // 判断线条是否 hover\n if (lineHovered) {\n this.hoverService.updateHoveredKey(lineHovered.id);\n return;\n }\n\n // 上述逻辑都未命中 则清空 hoverd\n hoverService.clearHovered();\n\n const currentState = this.editorStateConfig.getCurrentState();\n const isMouseFriendly = currentState === EditorState.STATE_MOUSE_FRIENDLY_SELECT;\n\n // 鼠标优先,并且不是按住 shift 键,更新为小手\n if (isMouseFriendly && !this.editorStateConfig.isPressingShift) {\n this.configEntity.updateCursor('grab');\n }\n }\n\n updateHoveredKey(key: string): void {\n // 鼠标优先交互模式,如果是 hover,需要将鼠标的小手去掉,还原鼠标原有样式\n this.configEntity.updateCursor('default');\n this.hoverService.updateHoveredKey(key);\n }\n\n /**\n * 判断是否能够 hover\n * @returns 是否能 hover\n */\n isEnabled(): boolean {\n const currentState = this.editorStateConfig.getCurrentState();\n // 选择框情况禁止 hover\n return (\n // 鼠标友好模式下,也需要支持 hover 效果,不然线条选择不到\n // Coze 中没有使用该插件,需要在 workflow/render 包相应位置改动\n (currentState === EditorState.STATE_SELECT ||\n currentState === EditorState.STATE_MOUSE_FRIENDLY_SELECT) &&\n !this.selectorBoxConfigEntity.isStart &&\n !this.dragService.isDragging\n );\n }\n}\n","import { Rectangle } from '@flowgram.ai/utils';\nimport { WorkflowNodeEntity } from '@flowgram.ai/free-layout-core';\nimport { FlowNodeTransformData } from '@flowgram.ai/document';\nimport { type Entity } from '@flowgram.ai/core';\n\nconst BOUNDS_PADDING = 2;\n\nexport function getSelectionBounds(\n selection: Entity[],\n ignoreOneSelect: boolean = true // 忽略单选\n): Rectangle {\n const selectedNodes = selection.filter((node) => node instanceof WorkflowNodeEntity);\n\n // 选中单个的时候不显示\n return selectedNodes.length > (ignoreOneSelect ? 1 : 0)\n ? Rectangle.enlarge(selectedNodes.map((n) => n.getData(FlowNodeTransformData)!.bounds)).pad(\n BOUNDS_PADDING\n )\n : Rectangle.EMPTY;\n}\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,2BAA2B;;;ACCpC,SAAS,QAAQ,kBAAkB;AAEnC,SAAS,+BAA+B;AACxC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,sBAAAA;AAAA,EACA;AAAA,OACK;AACP,SAAS,0BAA0B;AACnC,SAAS,kBAAkB,yBAAAC,8BAA6B;AACxD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;;;ACxBP,SAAS,iBAAiB;AAC1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,cAAc,uBAAuB;AAAA,GAd3B,WAeD;AAGA;AAAA,EADT,cAAc,uBAAuB;AAAA,GAjB3B,WAkBD;AAEsB;AAAA,EAA/B,OAAO,sBAAsB;AAAA,GApBnB,WAoBqB;AAMb;AAAA,EADlB,mBAAmBD,qBAAoBE,sBAAqB;AAAA,GAzBlD,WA0BQ;AAoBA;AAAA,EADlB,gBAAgB,kBAAkB;AAAA,GA7CxB,WA8CQ;AA9CR,aAAN;AAAA,EADN,WAAW;AAAA,GACC;;;ADxCN,IAAM,wBAAwB,oBAAoB;AAAA,EACvD,OAAO,KAAW;AAChB,QAAI,WAAW,cAAc,UAAU;AAAA,EACzC;AACF,CAAC;","names":["WorkflowNodeEntity","FlowNodeTransformData","HoverLayerOptions","WorkflowNodeEntity","lineHovered","FlowNodeTransformData"]}
|
package/dist/index.js
CHANGED
|
@@ -76,7 +76,7 @@ var HoverLayer = class extends import_core.Layer {
|
|
|
76
76
|
}
|
|
77
77
|
autorun() {
|
|
78
78
|
const { activatedNode } = this.selectionService;
|
|
79
|
-
this.nodeTransformsWithSort = this.nodeTransforms.filter((n) => n.entity.id !== "root").reverse().sort((n1) => n1.entity === activatedNode ? -1 : 0);
|
|
79
|
+
this.nodeTransformsWithSort = this.nodeTransforms.filter((n) => n.entity.id !== "root" && n.entity.flowNodeType !== import_document2.FlowNodeBaseType.GROUP).reverse().sort((n1) => n1.entity === activatedNode ? -1 : 0);
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
82
|
* 是否正在调整线条
|
|
@@ -101,11 +101,12 @@ var HoverLayer = class extends import_core.Layer {
|
|
|
101
101
|
return;
|
|
102
102
|
}
|
|
103
103
|
const mousePos = this.config.getPosFromMouseEvent(e);
|
|
104
|
-
this.updateHoveredState(mousePos, e
|
|
104
|
+
this.updateHoveredState(mousePos, e == null ? void 0 : e.target);
|
|
105
105
|
}),
|
|
106
106
|
this.selectionService.onSelectionChanged(() => this.autorun()),
|
|
107
107
|
// 控制选中逻辑
|
|
108
108
|
this.listenPlaygroundEvent("mousedown", (e) => {
|
|
109
|
+
var _a;
|
|
109
110
|
if (!this.isEnabled() || this.isDrawing) {
|
|
110
111
|
return void 0;
|
|
111
112
|
}
|
|
@@ -127,7 +128,7 @@ var HoverLayer = class extends import_core.Layer {
|
|
|
127
128
|
true
|
|
128
129
|
);
|
|
129
130
|
if (selectionBounds.width > 0 && selectionBounds.contains(mousePos.x, mousePos.y)) {
|
|
130
|
-
this.dragService.startDragSelectedNodes(e)
|
|
131
|
+
(_a = this.dragService.startDragSelectedNodes(e)) == null ? void 0 : _a.then((dragSuccess) => {
|
|
131
132
|
if (!dragSuccess) {
|
|
132
133
|
if (hoveredNode && hoveredNode instanceof import_free_layout_core2.WorkflowNodeEntity) {
|
|
133
134
|
if (e.shiftKey) {
|
|
@@ -155,6 +156,7 @@ var HoverLayer = class extends import_core.Layer {
|
|
|
155
156
|
* @param mousePos
|
|
156
157
|
*/
|
|
157
158
|
updateHoveredState(mousePos, target) {
|
|
159
|
+
var _a, _b, _c;
|
|
158
160
|
const { hoverService } = this;
|
|
159
161
|
const nodeTransforms = this.nodeTransformsWithSort;
|
|
160
162
|
const portHovered = this.linesManager.getPortFromMousePos(mousePos);
|
|
@@ -165,7 +167,7 @@ var HoverLayer = class extends import_core.Layer {
|
|
|
165
167
|
if (portHovered) {
|
|
166
168
|
if (portHovered.portType === "output") {
|
|
167
169
|
hoverService.updateHoveredKey(portHovered.id);
|
|
168
|
-
} else if (checkTargetFromLine || target
|
|
170
|
+
} else if (checkTargetFromLine || ((_b = (_a = target == null ? void 0 : target.className) == null ? void 0 : _a.includes) == null ? void 0 : _b.call(_a, PORT_BG_CLASS_NAME))) {
|
|
169
171
|
const lineHovered2 = this.linesManager.getCloseInLineFromMousePos(mousePos);
|
|
170
172
|
if (lineHovered2) {
|
|
171
173
|
this.updateHoveredKey(lineHovered2.id);
|
|
@@ -176,21 +178,21 @@ var HoverLayer = class extends import_core.Layer {
|
|
|
176
178
|
if (this.isDrawing) {
|
|
177
179
|
return;
|
|
178
180
|
}
|
|
179
|
-
const nodeHovered = nodeTransforms.find(
|
|
181
|
+
const nodeHovered = (_c = nodeTransforms.find(
|
|
180
182
|
(trans) => trans.bounds.contains(mousePos.x, mousePos.y)
|
|
181
|
-
)
|
|
183
|
+
)) == null ? void 0 : _c.entity;
|
|
182
184
|
const nodeDomNodes = this.playgroundNode.querySelectorAll(NODE_CLASS_NAME);
|
|
183
185
|
const checkTargetFromNode = [...nodeDomNodes].some(
|
|
184
186
|
(nodeDom) => nodeDom.contains(target)
|
|
185
187
|
);
|
|
186
188
|
if (nodeHovered || checkTargetFromNode) {
|
|
187
|
-
if (nodeHovered
|
|
189
|
+
if (nodeHovered == null ? void 0 : nodeHovered.id) {
|
|
188
190
|
this.updateHoveredKey(nodeHovered.id);
|
|
189
191
|
}
|
|
190
192
|
}
|
|
191
|
-
const nodeInContainer = !!(nodeHovered
|
|
193
|
+
const nodeInContainer = !!((nodeHovered == null ? void 0 : nodeHovered.parent) && nodeHovered.parent.flowNodeType !== "root");
|
|
192
194
|
const lineHovered = checkTargetFromLine ? this.linesManager.getCloseInLineFromMousePos(mousePos) : void 0;
|
|
193
|
-
const lineInContainer = !!lineHovered
|
|
195
|
+
const lineInContainer = !!(lineHovered == null ? void 0 : lineHovered.inContainer);
|
|
194
196
|
if (nodeHovered && nodeInContainer) {
|
|
195
197
|
this.updateHoveredKey(nodeHovered.id);
|
|
196
198
|
return;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/create-free-hover-plugin.ts","../src/hover-layer.tsx","../src/selection-utils.ts"],"sourcesContent":["export * from './create-free-hover-plugin';\n","import { definePluginCreator } from '@flowgram.ai/core';\n\nimport { HoverLayer } from './hover-layer';\n\nexport const createFreeHoverPlugin = definePluginCreator({\n onInit(ctx): void {\n ctx.playground.registerLayer(HoverLayer);\n },\n});\n","/* eslint-disable complexity */\nimport { inject, injectable } from 'inversify';\nimport { type IPoint } from '@flowgram.ai/utils';\nimport { SelectorBoxConfigEntity } from '@flowgram.ai/renderer';\nimport {\n WorkflowDocument,\n WorkflowDragService,\n WorkflowHoverService,\n WorkflowLineEntity,\n WorkflowLinesManager,\n WorkflowNodeEntity,\n WorkflowSelectService,\n} from '@flowgram.ai/free-layout-core';\nimport { WorkflowPortEntity } from '@flowgram.ai/free-layout-core';\nimport { FlowNodeTransformData } from '@flowgram.ai/document';\nimport {\n EditorState,\n EditorStateConfigEntity,\n Layer,\n PlaygroundConfigEntity,\n observeEntities,\n observeEntity,\n observeEntityDatas,\n type LayerOptions,\n} from '@flowgram.ai/core';\n\nimport { getSelectionBounds } from './selection-utils';\nconst PORT_BG_CLASS_NAME = 'workflow-port-bg';\n\nexport interface HoverLayerOptions extends LayerOptions {\n canHovered?: (e: MouseEvent, service: WorkflowHoverService) => boolean;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace HoverLayerOptions {\n export const DEFAULT: HoverLayerOptions = {\n canHovered: () => true,\n };\n}\n\nconst LINE_CLASS_NAME = '.gedit-flow-activity-line';\nconst NODE_CLASS_NAME = '.gedit-flow-activity-node';\n\n@injectable()\nexport class HoverLayer extends Layer<HoverLayerOptions> {\n static type = 'HoverLayer';\n\n @inject(WorkflowDocument) document: WorkflowDocument;\n\n @inject(WorkflowSelectService) selectionService: WorkflowSelectService;\n\n @inject(WorkflowDragService) dragService: WorkflowDragService;\n\n @inject(WorkflowHoverService) hoverService: WorkflowHoverService;\n\n @inject(WorkflowLinesManager)\n linesManager: WorkflowLinesManager;\n\n @observeEntity(EditorStateConfigEntity)\n protected editorStateConfig: EditorStateConfigEntity;\n\n @observeEntity(SelectorBoxConfigEntity)\n protected selectorBoxConfigEntity: SelectorBoxConfigEntity;\n\n @inject(PlaygroundConfigEntity) configEntity: PlaygroundConfigEntity;\n\n /**\n * 监听节点 transform\n */\n @observeEntityDatas(WorkflowNodeEntity, FlowNodeTransformData)\n protected readonly nodeTransforms: FlowNodeTransformData[];\n\n /**\n * 按选中排序\n * @private\n */\n protected nodeTransformsWithSort: FlowNodeTransformData[] = [];\n\n autorun(): void {\n const { activatedNode } = this.selectionService;\n this.nodeTransformsWithSort = this.nodeTransforms\n .filter((n) => n.entity.id !== 'root')\n .reverse() // 后创建的排在前面\n .sort((n1) => (n1.entity === activatedNode ? -1 : 0));\n }\n\n /**\n * 监听线条\n */\n @observeEntities(WorkflowLineEntity)\n protected readonly lines: WorkflowLineEntity[];\n\n /**\n * 是否正在调整线条\n * @protected\n */\n get isDrawing(): boolean {\n return this.linesManager.isDrawing;\n }\n\n onReady(): void {\n this.options = {\n ...HoverLayerOptions.DEFAULT,\n ...this.options,\n };\n this.toDispose.pushAll([\n // 监听画布鼠标移动事件\n this.listenPlaygroundEvent('mousemove', (e: MouseEvent) => {\n this.hoverService.hoveredPos = this.config.getPosFromMouseEvent(e);\n if (!this.isEnabled()) {\n return;\n }\n if (!this.options.canHovered!(e, this.hoverService)) {\n return;\n }\n const mousePos = this.config.getPosFromMouseEvent(e);\n // 更新 hover 状态\n this.updateHoveredState(mousePos, e?.target as HTMLElement);\n }),\n this.selectionService.onSelectionChanged(() => this.autorun()),\n // 控制选中逻辑\n this.listenPlaygroundEvent('mousedown', (e: MouseEvent): boolean | undefined => {\n if (!this.isEnabled() || this.isDrawing) {\n return undefined;\n }\n const { hoveredNode } = this.hoverService;\n // 重置线条\n if (hoveredNode && hoveredNode instanceof WorkflowLineEntity) {\n this.dragService.resetLine(hoveredNode, e);\n return true;\n }\n if (\n hoveredNode &&\n hoveredNode instanceof WorkflowPortEntity &&\n hoveredNode.portType !== 'input' &&\n !hoveredNode.disabled &&\n e.button !== 1\n ) {\n e.stopPropagation();\n e.preventDefault();\n this.dragService.startDrawingLine(hoveredNode, e);\n return true;\n }\n const mousePos = this.config.getPosFromMouseEvent(e);\n const selectionBounds = getSelectionBounds(\n this.selectionService.selection,\n // 这里只考虑多选模式,单选模式已经下沉到 use-node-render 中\n true\n );\n if (selectionBounds.width > 0 && selectionBounds.contains(mousePos.x, mousePos.y)) {\n /**\n * 拖拽选择框\n */\n this.dragService.startDragSelectedNodes(e)?.then((dragSuccess) => {\n if (!dragSuccess) {\n // 拖拽没有成功触发了点击\n if (hoveredNode && hoveredNode instanceof WorkflowNodeEntity) {\n // 追加选择\n if (e.shiftKey) {\n this.selectionService.toggleSelect(hoveredNode);\n } else {\n this.selectionService.selectNode(hoveredNode);\n }\n } else {\n this.selectionService.clear();\n }\n }\n });\n // 这里会组织触发 selector box\n return true;\n } else {\n if (!hoveredNode) {\n this.selectionService.clear();\n }\n }\n return undefined;\n }),\n ]);\n }\n\n /**\n * 更新 hoverd\n * @param mousePos\n */\n updateHoveredState(mousePos: IPoint, target?: HTMLElement): void {\n const { hoverService } = this;\n const nodeTransforms = this.nodeTransformsWithSort;\n // // 判断连接点是否 hover\n const portHovered = this.linesManager.getPortFromMousePos(mousePos);\n\n const lineDomNodes = this.playgroundNode.querySelectorAll(LINE_CLASS_NAME);\n const checkTargetFromLine = [...lineDomNodes].some((lineDom) =>\n lineDom.contains(target as HTMLElement)\n );\n // 默认 只有 output 点位可以 hover\n if (portHovered) {\n // 输出点可以直接选中\n if (portHovered.portType === 'output') {\n hoverService.updateHoveredKey(portHovered.id);\n } else if (checkTargetFromLine || target?.className?.includes?.(PORT_BG_CLASS_NAME)) {\n // 输入点采用获取最接近的线条\n const lineHovered = this.linesManager.getCloseInLineFromMousePos(mousePos);\n if (lineHovered) {\n this.updateHoveredKey(lineHovered.id);\n }\n }\n return;\n }\n\n // Drawing 情况,不能选中节点和线条\n if (this.isDrawing) {\n return;\n }\n\n const nodeHovered = nodeTransforms.find((trans: FlowNodeTransformData) =>\n trans.bounds.contains(mousePos.x, mousePos.y)\n )?.entity as WorkflowNodeEntity;\n\n // 判断当前鼠标位置所在元素是否在节点内部\n const nodeDomNodes = this.playgroundNode.querySelectorAll(NODE_CLASS_NAME);\n const checkTargetFromNode = [...nodeDomNodes].some((nodeDom) =>\n nodeDom.contains(target as HTMLElement)\n );\n\n if (nodeHovered || checkTargetFromNode) {\n if (nodeHovered?.id) {\n this.updateHoveredKey(nodeHovered.id);\n }\n }\n\n const nodeInContainer = !!(nodeHovered?.parent && nodeHovered.parent.flowNodeType !== 'root');\n\n // 获取最接近的线条\n // 线条会相交需要获取最接近点位的线条,不能删除的线条不能被选中\n const lineHovered = checkTargetFromLine\n ? this.linesManager.getCloseInLineFromMousePos(mousePos)\n : undefined;\n const lineInContainer = !!lineHovered?.inContainer;\n\n // 判断容器内节点是否 hover\n if (nodeHovered && nodeInContainer) {\n this.updateHoveredKey(nodeHovered.id);\n return;\n }\n // 判断容器内线条是否 hover\n if (lineHovered && lineInContainer) {\n this.updateHoveredKey(lineHovered.id);\n return;\n }\n\n // 判断节点是否 hover\n if (nodeHovered) {\n this.updateHoveredKey(nodeHovered.id);\n return;\n }\n // 判断线条是否 hover\n if (lineHovered) {\n this.hoverService.updateHoveredKey(lineHovered.id);\n return;\n }\n\n // 上述逻辑都未命中 则清空 hoverd\n hoverService.clearHovered();\n\n const currentState = this.editorStateConfig.getCurrentState();\n const isMouseFriendly = currentState === EditorState.STATE_MOUSE_FRIENDLY_SELECT;\n\n // 鼠标优先,并且不是按住 shift 键,更新为小手\n if (isMouseFriendly && !this.editorStateConfig.isPressingShift) {\n this.configEntity.updateCursor('grab');\n }\n }\n\n updateHoveredKey(key: string): void {\n // 鼠标优先交互模式,如果是 hover,需要将鼠标的小手去掉,还原鼠标原有样式\n this.configEntity.updateCursor('default');\n this.hoverService.updateHoveredKey(key);\n }\n\n /**\n * 判断是否能够 hover\n * @returns 是否能 hover\n */\n isEnabled(): boolean {\n const currentState = this.editorStateConfig.getCurrentState();\n // 选择框情况禁止 hover\n return (\n // 鼠标友好模式下,也需要支持 hover 效果,不然线条选择不到\n // Coze 中没有使用该插件,需要在 workflow/render 包相应位置改动\n (currentState === EditorState.STATE_SELECT ||\n currentState === EditorState.STATE_MOUSE_FRIENDLY_SELECT) &&\n !this.selectorBoxConfigEntity.isStart &&\n !this.dragService.isDragging\n );\n }\n}\n","import { Rectangle } from '@flowgram.ai/utils';\nimport { WorkflowNodeEntity } from '@flowgram.ai/free-layout-core';\nimport { FlowNodeTransformData } from '@flowgram.ai/document';\nimport { type Entity } from '@flowgram.ai/core';\n\nconst BOUNDS_PADDING = 2;\n\nexport function getSelectionBounds(\n selection: Entity[],\n ignoreOneSelect: boolean = true // 忽略单选\n): Rectangle {\n const selectedNodes = selection.filter((node) => node instanceof WorkflowNodeEntity);\n\n // 选中单个的时候不显示\n return selectedNodes.length > (ignoreOneSelect ? 1 : 0)\n ? Rectangle.enlarge(selectedNodes.map((n) => n.getData(FlowNodeTransformData)!.bounds)).pad(\n BOUNDS_PADDING\n )\n : Rectangle.EMPTY;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,eAAoC;;;ACCpC,uBAAmC;AAEnC,sBAAwC;AACxC,IAAAC,2BAQO;AACP,IAAAA,2BAAmC;AACnC,IAAAC,mBAAsC;AACtC,kBASO;;;ACxBP,mBAA0B;AAC1B,8BAAmC;AACnC,sBAAsC;AAGtC,IAAM,iBAAiB;AAEhB,SAAS,mBACd,WACA,kBAA2B,MAChB;AACX,QAAM,gBAAgB,UAAU,OAAO,CAAC,SAAS,gBAAgB,0CAAkB;AAGnF,SAAO,cAAc,UAAU,kBAAkB,IAAI,KACjD,uBAAU,QAAQ,cAAc,IAAI,CAAC,MAAM,EAAE,QAAQ,qCAAqB,EAAG,MAAM,CAAC,EAAE;AAAA,IACpF;AAAA,EACF,IACA,uBAAU;AAChB;;;ADQA,IAAM,qBAAqB;AAOpB,IAAU;AAAA,CAAV,CAAUC,uBAAV;AACE,EAAMA,mBAAA,UAA6B;AAAA,IACxC,YAAY,MAAM;AAAA,EACpB;AAAA,GAHe;AAMjB,IAAM,kBAAkB;AACxB,IAAM,kBAAkB;AAGjB,IAAM,aA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AEA,iBAAiB,KAAmB;AAElC,SAAK,aAAa,aAAa,SAAS;AACxC,SAAK,aAAa,iBAAiB,GAAG;AAAA,EACxC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,YAAqB;AACnB,UAAM,eAAe,KAAK,kBAAkB,gBAAgB;AAE5D;AAAA;AAAA;AAAA,OAGG,iBAAiB,wBAAY,gBAC5B,iBAAiB,wBAAY,gCAC/B,CAAC,KAAK,wBAAwB,WAC9B,CAAC,KAAK,YAAY;AAAA;AAAA,EAEtB;AACF;AA3Pa,WACJ,OAAO;AAEY;AAAA,MAAzB,yBAAO,yCAAgB;AAAA,GAHb,WAGe;AAEK;AAAA,MAA9B,yBAAO,8CAAqB;AAAA,GALlB,WAKoB;AAEF;AAAA,MAA5B,yBAAO,4CAAmB;AAAA,GAPhB,WAOkB;AAEC;AAAA,MAA7B,yBAAO,6CAAoB;AAAA,GATjB,WASmB;AAG9B;AAAA,MADC,yBAAO,6CAAoB;AAAA,GAXjB,WAYX;AAGU;AAAA,MADT,2BAAc,mCAAuB;AAAA,GAd3B,WAeD;AAGA;AAAA,MADT,2BAAc,uCAAuB;AAAA,GAjB3B,WAkBD;AAEsB;AAAA,MAA/B,yBAAO,kCAAsB;AAAA,GApBnB,WAoBqB;AAMb;AAAA,MADlB,gCAAmB,6CAAoB,sCAAqB;AAAA,GAzBlD,WA0BQ;AAoBA;AAAA,MADlB,6BAAgB,2CAAkB;AAAA,GA7CxB,WA8CQ;AA9CR,aAAN;AAAA,MADN,6BAAW;AAAA,GACC;;;ADxCN,IAAM,4BAAwB,kCAAoB;AAAA,EACvD,OAAO,KAAW;AAChB,QAAI,WAAW,cAAc,UAAU;AAAA,EACzC;AACF,CAAC;","names":["import_core","import_free_layout_core","import_document","HoverLayerOptions","lineHovered"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/create-free-hover-plugin.ts","../src/hover-layer.tsx","../src/selection-utils.ts"],"sourcesContent":["export * from './create-free-hover-plugin';\n","import { definePluginCreator } from '@flowgram.ai/core';\n\nimport { HoverLayer } from './hover-layer';\n\nexport const createFreeHoverPlugin = definePluginCreator({\n onInit(ctx): void {\n ctx.playground.registerLayer(HoverLayer);\n },\n});\n","/* eslint-disable complexity */\nimport { inject, injectable } from 'inversify';\nimport { type IPoint } from '@flowgram.ai/utils';\nimport { SelectorBoxConfigEntity } from '@flowgram.ai/renderer';\nimport {\n WorkflowDocument,\n WorkflowDragService,\n WorkflowHoverService,\n WorkflowLineEntity,\n WorkflowLinesManager,\n WorkflowNodeEntity,\n WorkflowSelectService,\n} from '@flowgram.ai/free-layout-core';\nimport { WorkflowPortEntity } from '@flowgram.ai/free-layout-core';\nimport { FlowNodeBaseType, FlowNodeTransformData } from '@flowgram.ai/document';\nimport {\n EditorState,\n EditorStateConfigEntity,\n Layer,\n PlaygroundConfigEntity,\n observeEntities,\n observeEntity,\n observeEntityDatas,\n type LayerOptions,\n} from '@flowgram.ai/core';\n\nimport { getSelectionBounds } from './selection-utils';\nconst PORT_BG_CLASS_NAME = 'workflow-port-bg';\n\nexport interface HoverLayerOptions extends LayerOptions {\n canHovered?: (e: MouseEvent, service: WorkflowHoverService) => boolean;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace HoverLayerOptions {\n export const DEFAULT: HoverLayerOptions = {\n canHovered: () => true,\n };\n}\n\nconst LINE_CLASS_NAME = '.gedit-flow-activity-line';\nconst NODE_CLASS_NAME = '.gedit-flow-activity-node';\n\n@injectable()\nexport class HoverLayer extends Layer<HoverLayerOptions> {\n static type = 'HoverLayer';\n\n @inject(WorkflowDocument) document: WorkflowDocument;\n\n @inject(WorkflowSelectService) selectionService: WorkflowSelectService;\n\n @inject(WorkflowDragService) dragService: WorkflowDragService;\n\n @inject(WorkflowHoverService) hoverService: WorkflowHoverService;\n\n @inject(WorkflowLinesManager)\n linesManager: WorkflowLinesManager;\n\n @observeEntity(EditorStateConfigEntity)\n protected editorStateConfig: EditorStateConfigEntity;\n\n @observeEntity(SelectorBoxConfigEntity)\n protected selectorBoxConfigEntity: SelectorBoxConfigEntity;\n\n @inject(PlaygroundConfigEntity) configEntity: PlaygroundConfigEntity;\n\n /**\n * 监听节点 transform\n */\n @observeEntityDatas(WorkflowNodeEntity, FlowNodeTransformData)\n protected readonly nodeTransforms: FlowNodeTransformData[];\n\n /**\n * 按选中排序\n * @private\n */\n protected nodeTransformsWithSort: FlowNodeTransformData[] = [];\n\n autorun(): void {\n const { activatedNode } = this.selectionService;\n this.nodeTransformsWithSort = this.nodeTransforms\n .filter((n) => n.entity.id !== 'root' && n.entity.flowNodeType !== FlowNodeBaseType.GROUP)\n .reverse() // 后创建的排在前面\n .sort((n1) => (n1.entity === activatedNode ? -1 : 0));\n }\n\n /**\n * 监听线条\n */\n @observeEntities(WorkflowLineEntity)\n protected readonly lines: WorkflowLineEntity[];\n\n /**\n * 是否正在调整线条\n * @protected\n */\n get isDrawing(): boolean {\n return this.linesManager.isDrawing;\n }\n\n onReady(): void {\n this.options = {\n ...HoverLayerOptions.DEFAULT,\n ...this.options,\n };\n this.toDispose.pushAll([\n // 监听画布鼠标移动事件\n this.listenPlaygroundEvent('mousemove', (e: MouseEvent) => {\n this.hoverService.hoveredPos = this.config.getPosFromMouseEvent(e);\n if (!this.isEnabled()) {\n return;\n }\n if (!this.options.canHovered!(e, this.hoverService)) {\n return;\n }\n const mousePos = this.config.getPosFromMouseEvent(e);\n // 更新 hover 状态\n this.updateHoveredState(mousePos, e?.target as HTMLElement);\n }),\n this.selectionService.onSelectionChanged(() => this.autorun()),\n // 控制选中逻辑\n this.listenPlaygroundEvent('mousedown', (e: MouseEvent): boolean | undefined => {\n if (!this.isEnabled() || this.isDrawing) {\n return undefined;\n }\n const { hoveredNode } = this.hoverService;\n // 重置线条\n if (hoveredNode && hoveredNode instanceof WorkflowLineEntity) {\n this.dragService.resetLine(hoveredNode, e);\n return true;\n }\n if (\n hoveredNode &&\n hoveredNode instanceof WorkflowPortEntity &&\n hoveredNode.portType !== 'input' &&\n !hoveredNode.disabled &&\n e.button !== 1\n ) {\n e.stopPropagation();\n e.preventDefault();\n this.dragService.startDrawingLine(hoveredNode, e);\n return true;\n }\n const mousePos = this.config.getPosFromMouseEvent(e);\n const selectionBounds = getSelectionBounds(\n this.selectionService.selection,\n // 这里只考虑多选模式,单选模式已经下沉到 use-node-render 中\n true\n );\n if (selectionBounds.width > 0 && selectionBounds.contains(mousePos.x, mousePos.y)) {\n /**\n * 拖拽选择框\n */\n this.dragService.startDragSelectedNodes(e)?.then((dragSuccess) => {\n if (!dragSuccess) {\n // 拖拽没有成功触发了点击\n if (hoveredNode && hoveredNode instanceof WorkflowNodeEntity) {\n // 追加选择\n if (e.shiftKey) {\n this.selectionService.toggleSelect(hoveredNode);\n } else {\n this.selectionService.selectNode(hoveredNode);\n }\n } else {\n this.selectionService.clear();\n }\n }\n });\n // 这里会组织触发 selector box\n return true;\n } else {\n if (!hoveredNode) {\n this.selectionService.clear();\n }\n }\n return undefined;\n }),\n ]);\n }\n\n /**\n * 更新 hoverd\n * @param mousePos\n */\n updateHoveredState(mousePos: IPoint, target?: HTMLElement): void {\n const { hoverService } = this;\n const nodeTransforms = this.nodeTransformsWithSort;\n // // 判断连接点是否 hover\n const portHovered = this.linesManager.getPortFromMousePos(mousePos);\n\n const lineDomNodes = this.playgroundNode.querySelectorAll(LINE_CLASS_NAME);\n const checkTargetFromLine = [...lineDomNodes].some((lineDom) =>\n lineDom.contains(target as HTMLElement)\n );\n // 默认 只有 output 点位可以 hover\n if (portHovered) {\n // 输出点可以直接选中\n if (portHovered.portType === 'output') {\n hoverService.updateHoveredKey(portHovered.id);\n } else if (checkTargetFromLine || target?.className?.includes?.(PORT_BG_CLASS_NAME)) {\n // 输入点采用获取最接近的线条\n const lineHovered = this.linesManager.getCloseInLineFromMousePos(mousePos);\n if (lineHovered) {\n this.updateHoveredKey(lineHovered.id);\n }\n }\n return;\n }\n\n // Drawing 情况,不能选中节点和线条\n if (this.isDrawing) {\n return;\n }\n\n const nodeHovered = nodeTransforms.find((trans: FlowNodeTransformData) =>\n trans.bounds.contains(mousePos.x, mousePos.y)\n )?.entity as WorkflowNodeEntity;\n\n // 判断当前鼠标位置所在元素是否在节点内部\n const nodeDomNodes = this.playgroundNode.querySelectorAll(NODE_CLASS_NAME);\n const checkTargetFromNode = [...nodeDomNodes].some((nodeDom) =>\n nodeDom.contains(target as HTMLElement)\n );\n\n if (nodeHovered || checkTargetFromNode) {\n if (nodeHovered?.id) {\n this.updateHoveredKey(nodeHovered.id);\n }\n }\n\n const nodeInContainer = !!(nodeHovered?.parent && nodeHovered.parent.flowNodeType !== 'root');\n\n // 获取最接近的线条\n // 线条会相交需要获取最接近点位的线条,不能删除的线条不能被选中\n const lineHovered = checkTargetFromLine\n ? this.linesManager.getCloseInLineFromMousePos(mousePos)\n : undefined;\n const lineInContainer = !!lineHovered?.inContainer;\n\n // 判断容器内节点是否 hover\n if (nodeHovered && nodeInContainer) {\n this.updateHoveredKey(nodeHovered.id);\n return;\n }\n // 判断容器内线条是否 hover\n if (lineHovered && lineInContainer) {\n this.updateHoveredKey(lineHovered.id);\n return;\n }\n\n // 判断节点是否 hover\n if (nodeHovered) {\n this.updateHoveredKey(nodeHovered.id);\n return;\n }\n // 判断线条是否 hover\n if (lineHovered) {\n this.hoverService.updateHoveredKey(lineHovered.id);\n return;\n }\n\n // 上述逻辑都未命中 则清空 hoverd\n hoverService.clearHovered();\n\n const currentState = this.editorStateConfig.getCurrentState();\n const isMouseFriendly = currentState === EditorState.STATE_MOUSE_FRIENDLY_SELECT;\n\n // 鼠标优先,并且不是按住 shift 键,更新为小手\n if (isMouseFriendly && !this.editorStateConfig.isPressingShift) {\n this.configEntity.updateCursor('grab');\n }\n }\n\n updateHoveredKey(key: string): void {\n // 鼠标优先交互模式,如果是 hover,需要将鼠标的小手去掉,还原鼠标原有样式\n this.configEntity.updateCursor('default');\n this.hoverService.updateHoveredKey(key);\n }\n\n /**\n * 判断是否能够 hover\n * @returns 是否能 hover\n */\n isEnabled(): boolean {\n const currentState = this.editorStateConfig.getCurrentState();\n // 选择框情况禁止 hover\n return (\n // 鼠标友好模式下,也需要支持 hover 效果,不然线条选择不到\n // Coze 中没有使用该插件,需要在 workflow/render 包相应位置改动\n (currentState === EditorState.STATE_SELECT ||\n currentState === EditorState.STATE_MOUSE_FRIENDLY_SELECT) &&\n !this.selectorBoxConfigEntity.isStart &&\n !this.dragService.isDragging\n );\n }\n}\n","import { Rectangle } from '@flowgram.ai/utils';\nimport { WorkflowNodeEntity } from '@flowgram.ai/free-layout-core';\nimport { FlowNodeTransformData } from '@flowgram.ai/document';\nimport { type Entity } from '@flowgram.ai/core';\n\nconst BOUNDS_PADDING = 2;\n\nexport function getSelectionBounds(\n selection: Entity[],\n ignoreOneSelect: boolean = true // 忽略单选\n): Rectangle {\n const selectedNodes = selection.filter((node) => node instanceof WorkflowNodeEntity);\n\n // 选中单个的时候不显示\n return selectedNodes.length > (ignoreOneSelect ? 1 : 0)\n ? Rectangle.enlarge(selectedNodes.map((n) => n.getData(FlowNodeTransformData)!.bounds)).pad(\n BOUNDS_PADDING\n )\n : Rectangle.EMPTY;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,eAAoC;;;ACCpC,uBAAmC;AAEnC,sBAAwC;AACxC,IAAAC,2BAQO;AACP,IAAAA,2BAAmC;AACnC,IAAAC,mBAAwD;AACxD,kBASO;;;ACxBP,mBAA0B;AAC1B,8BAAmC;AACnC,sBAAsC;AAGtC,IAAM,iBAAiB;AAEhB,SAAS,mBACd,WACA,kBAA2B,MAChB;AACX,QAAM,gBAAgB,UAAU,OAAO,CAAC,SAAS,gBAAgB,0CAAkB;AAGnF,SAAO,cAAc,UAAU,kBAAkB,IAAI,KACjD,uBAAU,QAAQ,cAAc,IAAI,CAAC,MAAM,EAAE,QAAQ,qCAAqB,EAAG,MAAM,CAAC,EAAE;AAAA,IACpF;AAAA,E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N,6BAAW;AAAA,GACC;;;ADxCN,IAAM,4BAAwB,kCAAoB;AAAA,EACvD,OAAO,KAAW;AAChB,QAAI,WAAW,cAAc,UAAU;AAAA,EACzC;AACF,CAAC;","names":["import_core","import_free_layout_core","import_document","HoverLayerOptions","lineHovered"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowgram.ai/free-hover-plugin",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.8",
|
|
4
4
|
"homepage": "https://flowgram.ai/",
|
|
5
5
|
"repository": "https://github.com/bytedance/flowgram.ai",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"inversify": "^6.0.1",
|
|
20
20
|
"reflect-metadata": "~0.2.2",
|
|
21
|
-
"@flowgram.ai/core": "0.1.0-alpha.
|
|
22
|
-
"@flowgram.ai/document": "0.1.0-alpha.
|
|
23
|
-
"@flowgram.ai/free-layout-core": "0.1.0-alpha.
|
|
24
|
-
"@flowgram.ai/renderer": "0.1.0-alpha.
|
|
25
|
-
"@flowgram.ai/select-box-plugin": "0.1.0-alpha.
|
|
26
|
-
"@flowgram.ai/utils": "0.1.0-alpha.
|
|
21
|
+
"@flowgram.ai/core": "0.1.0-alpha.8",
|
|
22
|
+
"@flowgram.ai/document": "0.1.0-alpha.8",
|
|
23
|
+
"@flowgram.ai/free-layout-core": "0.1.0-alpha.8",
|
|
24
|
+
"@flowgram.ai/renderer": "0.1.0-alpha.8",
|
|
25
|
+
"@flowgram.ai/select-box-plugin": "0.1.0-alpha.8",
|
|
26
|
+
"@flowgram.ai/utils": "0.1.0-alpha.8"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/bezier-js": "4.1.3",
|
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
"tsup": "^8.0.1",
|
|
38
38
|
"typescript": "^5.0.4",
|
|
39
39
|
"vitest": "^0.34.6",
|
|
40
|
-
"@flowgram.ai/eslint-config": "0.1.0-alpha.
|
|
41
|
-
"@flowgram.ai/ts-config": "0.1.0-alpha.
|
|
40
|
+
"@flowgram.ai/eslint-config": "0.1.0-alpha.8",
|
|
41
|
+
"@flowgram.ai/ts-config": "0.1.0-alpha.8"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"react": ">=
|
|
45
|
-
"react-dom": ">=
|
|
44
|
+
"react": ">=16.8",
|
|
45
|
+
"react-dom": ">=16.8"
|
|
46
46
|
},
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public",
|