fix: 修复工作流节点交互与旧浏览器兼容
- 修复 Tinyflow Vue wrapper 可选 boolean 默认关闭节点拖拽和连线的问题 - 为 Tinyflow 增加 structuredClone 兼容与 Chrome 90 构建目标 - 增加节点交互归一化与 Tab 空值防御
This commit is contained in:
@@ -2,6 +2,10 @@ import type {useSvelteFlow} from '@xyflow/svelte';
|
||||
import {componentName} from './consts';
|
||||
import {store} from './store/stores.svelte';
|
||||
import type {TinyflowData, TinyflowOptions, TinyflowTheme} from './types';
|
||||
import {installTinyflowBrowserCompat} from './utils/compat';
|
||||
import {createTinyflowNodeNormalizer} from './utils/nodeInteraction';
|
||||
|
||||
installTinyflowBrowserCompat();
|
||||
|
||||
type FlowInstance = ReturnType<typeof useSvelteFlow>;
|
||||
|
||||
@@ -102,6 +106,7 @@ export class Tinyflow {
|
||||
|
||||
const currentViewport = flow.getViewport();
|
||||
const currentNodes = flow.getNodes();
|
||||
const normalizeNode = createTinyflowNodeNormalizer(this.options);
|
||||
const currentNodePositions = new Map(
|
||||
currentNodes.map((node) => [node.id, node.position]),
|
||||
);
|
||||
@@ -109,11 +114,12 @@ export class Tinyflow {
|
||||
options?.preserveViewport === true
|
||||
? (data.nodes || currentNodes).map((node) => {
|
||||
const currentPosition = currentNodePositions.get(node.id);
|
||||
return currentPosition
|
||||
const nextNode = currentPosition
|
||||
? { ...node, position: { ...currentPosition } }
|
||||
: node;
|
||||
return normalizeNode(nextNode);
|
||||
})
|
||||
: data.nodes || currentNodes;
|
||||
: (data.nodes || currentNodes).map((node) => normalizeNode(node));
|
||||
store.setNodes(nextNodes);
|
||||
store.setEdges(data.edges || flow.getEdges());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user