@flowgram.ai/editor 0.4.16 → 0.4.17
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 +32 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +34 -2
- package/dist/index.js.map +1 -1
- package/package.json +23 -23
package/dist/esm/index.js
CHANGED
|
@@ -64,10 +64,12 @@ var EditorProps;
|
|
|
64
64
|
})(EditorProps || (EditorProps = {}));
|
|
65
65
|
|
|
66
66
|
// src/preset/editor-default-preset.ts
|
|
67
|
+
import { getNodePrivateScope, getNodeScope } from "@flowgram.ai/variable-plugin";
|
|
67
68
|
import { FlowRendererContainerModule, FlowRendererRegistry } from "@flowgram.ai/renderer";
|
|
68
69
|
import { createReduxDevToolPlugin } from "@flowgram.ai/redux-devtool-plugin";
|
|
69
70
|
import { createNodeVariablePlugin } from "@flowgram.ai/node-variable-plugin";
|
|
70
71
|
import { createNodeCorePlugin } from "@flowgram.ai/node-core-plugin";
|
|
72
|
+
import { getNodeForm } from "@flowgram.ai/node";
|
|
71
73
|
import { createMaterialsPlugin } from "@flowgram.ai/materials-plugin";
|
|
72
74
|
import { createI18nPlugin } from "@flowgram.ai/i18n-plugin";
|
|
73
75
|
import { createHistoryNodePlugin } from "@flowgram.ai/history-node-plugin";
|
|
@@ -304,6 +306,36 @@ function createDefaultPreset(opts, plugins = []) {
|
|
|
304
306
|
ctx2.document.options.getNodeDefaultRegistry = opts.getNodeDefaultRegistry;
|
|
305
307
|
}
|
|
306
308
|
ctx2.get(FlowRendererRegistry).init();
|
|
309
|
+
ctx2.document.onNodeCreate(({ node }) => {
|
|
310
|
+
if (opts.nodeEngine && opts.nodeEngine.enable !== false) {
|
|
311
|
+
let cache;
|
|
312
|
+
Object.defineProperty(node, "form", {
|
|
313
|
+
get: () => {
|
|
314
|
+
if (cache) return cache;
|
|
315
|
+
cache = getNodeForm(node);
|
|
316
|
+
return cache;
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
if (opts.variableEngine && opts.variableEngine.enable !== false) {
|
|
321
|
+
let cache;
|
|
322
|
+
let privateCache;
|
|
323
|
+
Object.defineProperty(node, "scope", {
|
|
324
|
+
get: () => {
|
|
325
|
+
if (cache) return cache;
|
|
326
|
+
cache = getNodeScope(node);
|
|
327
|
+
return cache;
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
Object.defineProperty(node, "privateScope", {
|
|
331
|
+
get: () => {
|
|
332
|
+
if (privateCache) return privateCache;
|
|
333
|
+
privateCache = getNodePrivateScope(node);
|
|
334
|
+
return privateCache;
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
});
|
|
307
339
|
},
|
|
308
340
|
onReady(ctx2) {
|
|
309
341
|
if (opts.initialData) {
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/preset/editor-props.ts","../../src/preset/editor-default-preset.ts","../../src/clients/flow-editor-client-plugins.ts","../../src/clients/node-client/create-node-client-plugins.ts","../../src/clients/node-client/node-focus-service.ts","../../src/clients/node-client/highlight/highlight-form-item.ts","../../src/clients/node-client/highlight/highlight-style.ts","../../src/clients/node-client/highlight/constants.ts","../../src/clients/node-client/highlight/use-highlight.ts","../../src/clients/node-client/node-client.ts","../../src/clients/node-client/highlight/create-node-highlight-plugin.ts","../../src/clients/flow-editor-client.ts","../../src/components/editor-provider.tsx","../../src/components/editor-renderer.tsx","../../src/components/editor.tsx","../../src/hooks/use-flow-editor.ts"],"sourcesContent":["/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport 'reflect-metadata';\nimport { FormModelV2 } from '@flowgram.ai/node';\n\n/* 核心 模块导出 */\nexport * from '@flowgram.ai/utils';\nexport * from '@flowgram.ai/core';\nexport * from '@flowgram.ai/document';\nexport * from '@flowgram.ai/renderer';\nexport * from '@flowgram.ai/variable-plugin';\nexport * from '@flowgram.ai/shortcuts-plugin';\nexport * from '@flowgram.ai/node-core-plugin';\nexport * from '@flowgram.ai/i18n-plugin';\nexport {\n ReactiveState,\n ReactiveBaseState,\n Tracker,\n useReactiveState,\n useReadonlyReactiveState,\n useObserve,\n observe,\n} from '@flowgram.ai/reactive';\nexport {\n type interfaces,\n injectable,\n postConstruct,\n named,\n Container,\n ContainerModule,\n AsyncContainerModule,\n inject,\n multiInject,\n} from 'inversify';\n\nexport { FlowNodeFormData, NodeRender, type NodeRenderProps } from '@flowgram.ai/form-core';\n\nexport type {\n FormState,\n FieldState,\n FieldArrayRenderProps,\n FieldRenderProps,\n FormRenderProps,\n Validate,\n FormControl,\n FieldName,\n FieldError,\n FieldWarning,\n IField,\n IFieldArray,\n IForm,\n Errors,\n Warnings,\n} from '@flowgram.ai/form';\n\nexport {\n Form,\n Field,\n FieldArray,\n useForm,\n useField,\n useCurrentField,\n useCurrentFieldState,\n useFieldValidate,\n useWatch,\n ValidateTrigger,\n FeedbackLevel,\n} from '@flowgram.ai/form';\nexport * from '@flowgram.ai/node';\nexport { FormModelV2 as FormModel };\n\n/**\n * 固定布局模块导出\n */\nexport * from './preset';\nexport * from './components';\nexport * from './hooks';\nexport * from './clients';\n\n/**\n * Plugin 导出\n */\n\nexport * from '@flowgram.ai/node-variable-plugin';\n\nexport { createPlaygroundReactPreset } from '@flowgram.ai/playground-react';\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { VariablePluginOptions } from '@flowgram.ai/variable-plugin';\nimport { ReduxDevToolPluginOptions } from '@flowgram.ai/redux-devtool-plugin';\nimport { PlaygroundReactProps, SelectionService } from '@flowgram.ai/playground-react';\nimport { NodeCorePluginOptions } from '@flowgram.ai/node-core-plugin';\nimport { MaterialsPluginOptions } from '@flowgram.ai/materials-plugin';\nimport { I18nPluginOptions } from '@flowgram.ai/i18n-plugin';\nimport { HistoryPluginOptions } from '@flowgram.ai/history';\nimport { FormMetaOrFormMetaGenerator } from '@flowgram.ai/form-core';\nimport {\n FlowDocument,\n FlowDocumentJSON,\n FlowNodeEntity,\n type FlowNodeJSON,\n FlowNodeRegistry,\n FlowNodeType,\n} from '@flowgram.ai/document';\nimport { PluginContext } from '@flowgram.ai/core';\n\nexport interface EditorPluginContext extends PluginContext {\n document: FlowDocument;\n selection: SelectionService;\n}\n\nexport interface EditorProps<\n CTX extends EditorPluginContext = EditorPluginContext,\n JSON = FlowDocumentJSON\n> extends PlaygroundReactProps<CTX> {\n /**\n * Initialize data\n * 初始化数据\n */\n initialData?: JSON;\n /**\n * whether it is readonly\n * 是否为 readonly\n */\n readonly?: boolean;\n /**\n * node registries\n * 节点定义\n */\n nodeRegistries?: FlowNodeRegistry[];\n /**\n * Get the default node registry, which will be merged with the 'nodeRegistries'\n * 提供默认的节点注册,这个会和 nodeRegistries 做合并\n */\n getNodeDefaultRegistry?: (type: FlowNodeType) => FlowNodeRegistry;\n /**\n * Node engine configuration\n */\n nodeEngine?: NodeCorePluginOptions & {\n /**\n * Default formMeta\n */\n createDefaultFormMeta?: (node: FlowNodeEntity) => FormMetaOrFormMetaGenerator;\n /**\n * Enable node engine\n */\n enable?: boolean;\n };\n /**\n * By default, all nodes are expanded\n * 默认是否展开所有节点\n */\n allNodesDefaultExpanded?: boolean;\n /**\n * Canvas material, Used to customize react components\n * 画布物料, 用于自定义 react 组件\n */\n materials?: MaterialsPluginOptions;\n /**\n * 画布数据加载完成, 请使用 onAllLayersRendered 替代\n * @deprecated\n * */\n onLoad?: (ctx: CTX) => void;\n /**\n * 是否开启变量引擎\n * Variable engine enable\n */\n variableEngine?: VariablePluginOptions;\n /**\n * Redo/Undo enable\n */\n history?: HistoryPluginOptions<CTX> & { disableShortcuts?: boolean };\n\n /**\n * redux devtool configuration\n */\n reduxDevTool?: ReduxDevToolPluginOptions;\n\n /**\n * Scroll configuration\n * 滚动配置\n */\n scroll?: {\n enableScrollLimit?: boolean; // 开启滚动限制\n disableScrollBar?: boolean; // 关闭滚动条\n disableScroll?: boolean; // 禁止滚动\n };\n\n /**\n * Node data transformation, called by ctx.document.fromJSON\n * 节点数据转换, 由 ctx.document.fromJSON 调用\n * @param node - current node\n * @param json - Current node json data\n */\n toNodeJSON?(node: FlowNodeEntity, json: FlowNodeJSON): FlowNodeJSON;\n /**\n * Node data transformation, called by ctx.document.toJSON\n * 节点数据转换, 由 ctx.document.toJSON 调用\n * @param node - current node\n * @param json - Current node json data\n * @param isFirstCreate - Whether it is created for the first time, If document.fromJSON is recalled, but the node already exists, isFirstCreate is false\n */\n fromNodeJSON?(node: FlowNodeEntity, json: FlowNodeJSON, isFirstCreate: boolean): FlowNodeJSON;\n /**\n * Canvas internal constant customization\n * 画布内部常量自定义\n */\n constants?: Record<string, any>;\n /**\n * i18n\n * 国际化\n */\n i18n?: I18nPluginOptions;\n}\n\nexport namespace EditorProps {\n /**\n * 默认配置\n */\n export const DEFAULT: EditorProps = {\n background: {},\n };\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { interfaces } from 'inversify';\nimport { FlowRendererContainerModule, FlowRendererRegistry } from '@flowgram.ai/renderer';\nimport { createReduxDevToolPlugin } from '@flowgram.ai/redux-devtool-plugin';\nimport { createNodeVariablePlugin } from '@flowgram.ai/node-variable-plugin';\nimport { createNodeCorePlugin } from '@flowgram.ai/node-core-plugin';\nimport { createMaterialsPlugin } from '@flowgram.ai/materials-plugin';\nimport { createI18nPlugin } from '@flowgram.ai/i18n-plugin';\nimport { createHistoryNodePlugin } from '@flowgram.ai/history-node-plugin';\nimport { FlowDocumentContainerModule } from '@flowgram.ai/document';\nimport { createPlaygroundPlugin, Plugin, PluginsProvider } from '@flowgram.ai/core';\n\nimport { createFlowEditorClientPlugins } from '../clients/flow-editor-client-plugins';\nimport { EditorPluginContext, EditorProps } from './editor-props';\n\nexport function createDefaultPreset<CTX extends EditorPluginContext = EditorPluginContext>(\n opts: EditorProps<CTX>,\n plugins: Plugin[] = []\n): PluginsProvider<CTX> {\n return (ctx: CTX) => {\n opts = { ...EditorProps.DEFAULT, ...opts };\n /**\n * i18n support\n */\n if (opts.i18n) {\n plugins.push(createI18nPlugin(opts.i18n));\n }\n /**\n * 默认注册顶层 flow editor client plugin\n */\n plugins.push(...createFlowEditorClientPlugins());\n\n /**\n * 注册 Redux 开发者工具\n */\n if (opts.reduxDevTool?.enable) {\n plugins.push(createReduxDevToolPlugin(opts.reduxDevTool));\n }\n\n /**\n * 注册画布模块\n */\n const defaultContainerModules: interfaces.ContainerModule[] = [\n FlowDocumentContainerModule, // 默认文档\n FlowRendererContainerModule, // 默认渲染\n ];\n /**\n * 注册物料\n */\n plugins.push(createMaterialsPlugin(opts.materials || {}));\n\n /**\n * 注册节点引擎\n */\n if (opts.nodeEngine && opts.nodeEngine.enable !== false) {\n plugins.push(createNodeCorePlugin({ materials: opts.nodeEngine.materials }));\n\n if (opts.variableEngine?.enable) {\n plugins.push(createNodeVariablePlugin({}));\n }\n\n if (opts.history?.enable) {\n plugins.push(createHistoryNodePlugin({}));\n }\n }\n /**\n * 画布生命周期注册\n */\n plugins.push(\n createPlaygroundPlugin<CTX>({\n onInit: (ctx) => {\n if (opts.nodeRegistries) {\n ctx.document.registerFlowNodes(...opts.nodeRegistries);\n }\n // 自定义画布内部常量\n if (opts.constants) {\n ctx.document.options.constants = opts.constants;\n }\n if (opts.getNodeDefaultRegistry) {\n ctx.document.options.getNodeDefaultRegistry = opts.getNodeDefaultRegistry;\n }\n // TODO\n // if (opts.onContentChange) {\n // ctx.document.onContentChange(event => opts.onContentChange!(ctx, event));\n // }\n // TODO 这个会触发组件注册,后续要废弃这个,通过 materials 插件来做\n ctx.get<FlowRendererRegistry>(FlowRendererRegistry).init();\n },\n onReady(ctx) {\n if (opts.initialData) {\n ctx.document.fromJSON(opts.initialData);\n }\n if (opts.readonly) {\n ctx.playground.config.readonly = opts.readonly;\n }\n ctx.document.load().then(() => {\n if (opts.onLoad) opts.onLoad(ctx);\n });\n },\n onDispose(ctx) {\n ctx.document.dispose();\n },\n containerModules: defaultContainerModules,\n })\n );\n\n return plugins;\n };\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { definePluginCreator } from '@flowgram.ai/core';\n\nimport { createNodeClientPlugins } from './node-client/create-node-client-plugins';\nimport { FlowEditorClient } from './flow-editor-client';\n\nexport const createFlowEditorClientPlugin = definePluginCreator<{}>({\n onBind({ bind }) {\n bind(FlowEditorClient).toSelf().inSingletonScope();\n },\n});\n\nexport const createFlowEditorClientPlugins = () => [\n ...createNodeClientPlugins(),\n createFlowEditorClientPlugin({}),\n];\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { definePluginCreator } from '@flowgram.ai/core';\n\nimport { NodeFocusService } from './node-focus-service';\nimport { NodeClient } from './node-client';\nimport { createNodeHighlightPlugin } from './highlight/create-node-highlight-plugin';\n\nexport const createNodeClientPlugin = definePluginCreator<{}>({\n onBind({ bind }) {\n bind(NodeFocusService).toSelf().inSingletonScope();\n bind(NodeClient).toSelf().inSingletonScope();\n },\n});\n\nexport const createNodeClientPlugins = () => [\n createNodeHighlightPlugin({}),\n createNodeClientPlugin({}),\n];\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { injectable, inject } from 'inversify';\nimport { type FormItem } from '@flowgram.ai/form-core';\nimport { Playground, PlaygroundConfigRevealOpts } from '@flowgram.ai/core';\n\nimport { highlightFormItem, HighLightOptions } from './highlight';\n\nexport type FocusNodeCanvasOptions = PlaygroundConfigRevealOpts;\n\nexport interface FocusNodeFormItemOptions {\n canvas?: FocusNodeCanvasOptions;\n highlight?: boolean | HighLightOptions;\n}\n\n@injectable()\nexport class NodeFocusService {\n @inject(Playground) readonly playground: Playground;\n\n protected previousOverlay: HTMLDivElement | undefined;\n\n protected currentPromise: Promise<void> | undefined;\n\n highlightNodeFormItem(formItem: FormItem, options?: HighLightOptions) {\n this.previousOverlay = highlightFormItem(formItem, options);\n }\n\n focusNodeFormItem(formItem: FormItem, options?: FocusNodeFormItemOptions): Promise<void> {\n const node = formItem.formModel.flowNodeEntity;\n const { canvas = {}, highlight } = options || {};\n if (this.previousOverlay) {\n this.previousOverlay.remove();\n this.previousOverlay = undefined;\n }\n const currentPromise = this.playground\n .scrollToView({ entities: [node], scrollToCenter: true, ...canvas })\n .then(() => {\n if (!formItem || !highlight || this.currentPromise !== currentPromise) {\n return;\n }\n this.highlightNodeFormItem(formItem, typeof highlight === 'boolean' ? {} : highlight);\n });\n this.currentPromise = currentPromise;\n return this.currentPromise;\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { FormItem } from '@flowgram.ai/form-core';\nimport { FlowNodeRenderData } from '@flowgram.ai/document';\n\nimport { HIGHLIGHT_CLASSNAME } from './highlight-style';\nimport { DEFAULT_HIGHLIGHT_PADDING } from './constants';\n\nexport interface HighLightOptions {\n padding?: number;\n overlayClassName?: string;\n}\n\nexport function highlightFormItem(\n formItem: FormItem,\n options?: HighLightOptions,\n): HTMLDivElement | undefined {\n const parent =\n formItem.formModel.flowNodeEntity.getData<FlowNodeRenderData>(FlowNodeRenderData).node;\n const target = formItem.domRef.current;\n\n if (!target) {\n return undefined;\n }\n\n const overlay = document.createElement('div');\n\n const { padding = DEFAULT_HIGHLIGHT_PADDING, overlayClassName } = options || {};\n\n overlay.style.position = 'absolute';\n overlay.style.top = '0';\n overlay.style.left = '0';\n overlay.style.width = '100%';\n overlay.style.height = '100%';\n overlay.style.zIndex = '9999';\n\n parent.appendChild(overlay);\n\n const parentRect = parent.getBoundingClientRect();\n const targetRect = target.getBoundingClientRect();\n\n overlay.style.top = targetRect.top - parentRect.top - padding + 'px';\n overlay.style.left = targetRect.left - parentRect.left - padding + 'px';\n overlay.style.width = targetRect.width + padding * 2 + 'px';\n overlay.style.height = targetRect.height + padding * 2 + 'px';\n\n overlay.className = overlayClassName || HIGHLIGHT_CLASSNAME;\n setTimeout(() => {\n overlay.remove();\n }, 2000);\n return overlay;\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nexport const HIGHLIGHT_CLASSNAME = 'flowide-highlight';\n\nconst styleText = `\n@keyframes flowide-fade {\n from {\n opacity: 1.0;\n }\n to {\n opacity: 0;\n }\n}\n@-webkit-keyframes flowide-fade {\n from {\n opacity: 1.0;\n }\n to {\n opacity: 0;\n }\n}\n.${HIGHLIGHT_CLASSNAME} {\n background-color: rgba(238, 245, 40, 0.5);\n animation: flowide-fade 2s 1 forwards;\n -webkit-animation: flowide-fade 2s 1 forwards;\n}\n`;\n\nlet styleDom: HTMLStyleElement | undefined;\n\nexport function createHighlightStyle(): void {\n if (styleDom) return;\n styleDom = document.createElement('style');\n styleDom.innerHTML = styleText;\n document.head.appendChild(styleDom);\n}\n\nexport function removeHighlightStyle(): void {\n styleDom?.remove();\n styleDom = undefined;\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nexport const DEFAULT_HIGHLIGHT_COLOR = 'rgba(238, 245, 40, 0.5)';\nexport const DEFAULT_HIGHLIGHT_PADDING = 0;\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { useRef } from 'react';\n\nimport { FormModel } from '@flowgram.ai/form-core';\n\ninterface HighlightProps {\n form: FormModel;\n path: string;\n}\n\nexport function useHighlight(props: HighlightProps) {\n const ref = useRef<any>(null);\n const { form, path } = props;\n const formItem = form.getFormItemByPath(path);\n if (!formItem) {\n return null;\n }\n formItem.domRef = ref;\n return ref;\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { injectable, inject } from 'inversify';\n\nimport { NodeFocusService } from './node-focus-service';\n\n@injectable()\nexport class NodeClient {\n @inject(NodeFocusService) nodeFocusService: NodeFocusService;\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { definePluginCreator } from '@flowgram.ai/core';\n\nimport { createHighlightStyle, removeHighlightStyle } from './highlight-style';\n\nexport const createNodeHighlightPlugin = definePluginCreator<{}>({\n onInit() {\n createHighlightStyle();\n },\n onDispose() {\n removeHighlightStyle();\n },\n});\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { injectable, inject } from 'inversify';\nimport { type FormItem } from '@flowgram.ai/form-core';\nimport { FlowNodeEntity } from '@flowgram.ai/document';\nimport { Playground, PlaygroundConfigRevealOpts } from '@flowgram.ai/core';\n\nimport { FocusNodeFormItemOptions, NodeClient } from './node-client';\n\ninterface FocusNodeOptions {\n zoom?: PlaygroundConfigRevealOpts['zoom'];\n easing?: PlaygroundConfigRevealOpts['easing']; // 是否开启缓动,默认开启\n easingDuration?: PlaygroundConfigRevealOpts['easingDuration']; // 默认 500 ms\n scrollToCenter?: PlaygroundConfigRevealOpts['scrollToCenter']; // 是否滚动到中心\n}\n\n@injectable()\nexport class FlowEditorClient {\n @inject(NodeClient) readonly nodeClient: NodeClient;\n\n @inject(Playground) readonly playground: Playground;\n\n focusNodeFormItem(formItem: FormItem, options?: FocusNodeFormItemOptions) {\n this.nodeClient.nodeFocusService.focusNodeFormItem(formItem, options);\n }\n\n focusNode(node: FlowNodeEntity, options?: FocusNodeOptions) {\n this.playground.scrollToView({ entities: [node], ...options });\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport React, { useMemo, useCallback } from 'react';\n\nimport { interfaces } from 'inversify';\nimport { FlowDocument } from '@flowgram.ai/document';\nimport {\n PlaygroundReactProvider,\n createPluginContextDefault,\n SelectionService,\n} from '@flowgram.ai/core';\n\nimport { EditorPluginContext, EditorProps, createDefaultPreset } from '../preset';\n\nexport const EditorProvider: React.FC<EditorProps> = (props: EditorProps) => {\n const { children, ...others } = props;\n const preset = useMemo(() => createDefaultPreset(others), []);\n const customPluginContext = useCallback(\n (container: interfaces.Container) =>\n ({\n ...createPluginContextDefault(container),\n get document(): FlowDocument {\n return container.get<FlowDocument>(FlowDocument);\n },\n get selection(): SelectionService {\n return container.get<SelectionService>(SelectionService);\n },\n } as EditorPluginContext),\n []\n );\n return (\n <PlaygroundReactProvider plugins={preset} customPluginContext={customPluginContext}>\n {children}\n </PlaygroundReactProvider>\n );\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nexport { PlaygroundReactRenderer as EditorRenderer } from '@flowgram.ai/core';\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport React from 'react';\n\nimport { EditorProps } from '../preset';\nimport { EditorRenderer } from './editor-renderer';\nimport { EditorProvider } from './editor-provider';\n\n/**\n * 画布编辑器\n * @param props\n * @constructor\n */\nexport const Editor: React.FC<EditorProps> = (props: EditorProps) => {\n const { children, ...otherProps } = props;\n return (\n <EditorProvider {...otherProps}>\n <EditorRenderer>{children}</EditorRenderer>\n </EditorProvider>\n );\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { useService } from '@flowgram.ai/core';\n\nimport { FlowEditorClient } from '../clients';\n\nexport function useFlowEditor(): FlowEditorClient {\n return useService(FlowEditorClient);\n}\n"],"mappings":";;;;;;;;;;;;AAKA,OAAO;AACP,SAAS,mBAAmB;AAG5B,cAAc;AACd,cAAc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AuB;AAC3E,QAAM,EAAE,UAAU,GAAG,OAAO,IAAI;AAChC,QAAM,SAAS,QAAQ,MAAM,oBAAoB,MAAM,GAAG,CAAC,CAAC;AAC5D,QAAM,sBAAsB;AAAA,IAC1B,CAAC,eACE;AAAA,MACC,GAAG,2BAA2B,SAAS;AAAA,MACvC,IAAI,WAAyB;AAC3B,eAAO,UAAU,IAAkB,YAAY;AAAA,MACjD;AAAA,MACA,IAAI,YAA8B;AAChC,eAAO,UAAU,IAAsB,gBAAgB;AAAA,MACzD;AAAA,IACF;AAAA,IACF,CAAC;AAAA,EACH;AACA,SACE,oCAAC,2BAAwB,SAAS,QAAQ,uBACvC,QACH;AAEJ;;;ACjCA,SAAoC,+BAAsB;;;ACA1D,OAAOC,YAAW;AAWX,IAAM,SAAgC,CAAC,UAAuB;AACnE,QAAM,EAAE,UAAU,GAAG,WAAW,IAAI;AACpC,SACE,gBAAAC,OAAA,cAAC,kBAAgB,GAAG,cAClB,gBAAAA,OAAA,cAAC,+BAAgB,QAAS,CAC5B;AAEJ;;;AClBA,SAAS,kBAAkB;AAIpB,SAAS,gBAAkC;AAChD,SAAO,WAAW,gBAAgB;AACpC;;;AhB2EA,cAAc;AAEd,SAAS,mCAAmC;","names":["injectable","inject","EditorProps","definePluginCreator","definePluginCreator","injectable","inject","inject","injectable","definePluginCreator","injectable","inject","Playground","inject","Playground","injectable","definePluginCreator","ctx","React","React"]}
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/preset/editor-props.ts","../../src/preset/editor-default-preset.ts","../../src/clients/flow-editor-client-plugins.ts","../../src/clients/node-client/create-node-client-plugins.ts","../../src/clients/node-client/node-focus-service.ts","../../src/clients/node-client/highlight/highlight-form-item.ts","../../src/clients/node-client/highlight/highlight-style.ts","../../src/clients/node-client/highlight/constants.ts","../../src/clients/node-client/highlight/use-highlight.ts","../../src/clients/node-client/node-client.ts","../../src/clients/node-client/highlight/create-node-highlight-plugin.ts","../../src/clients/flow-editor-client.ts","../../src/components/editor-provider.tsx","../../src/components/editor-renderer.tsx","../../src/components/editor.tsx","../../src/hooks/use-flow-editor.ts"],"sourcesContent":["/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport 'reflect-metadata';\nimport { FormModelV2 } from '@flowgram.ai/node';\n\n/* 核心 模块导出 */\nexport * from '@flowgram.ai/utils';\nexport * from '@flowgram.ai/core';\nexport * from '@flowgram.ai/document';\nexport * from '@flowgram.ai/renderer';\nexport * from '@flowgram.ai/variable-plugin';\nexport * from '@flowgram.ai/shortcuts-plugin';\nexport * from '@flowgram.ai/node-core-plugin';\nexport * from '@flowgram.ai/i18n-plugin';\nexport {\n ReactiveState,\n ReactiveBaseState,\n Tracker,\n useReactiveState,\n useReadonlyReactiveState,\n useObserve,\n observe,\n} from '@flowgram.ai/reactive';\nexport {\n type interfaces,\n injectable,\n postConstruct,\n named,\n Container,\n ContainerModule,\n AsyncContainerModule,\n inject,\n multiInject,\n} from 'inversify';\n\nexport { FlowNodeFormData, NodeRender, type NodeRenderProps } from '@flowgram.ai/form-core';\n\nexport type {\n FormState,\n FieldState,\n FieldArrayRenderProps,\n FieldRenderProps,\n FormRenderProps,\n Validate,\n FormControl,\n FieldName,\n FieldError,\n FieldWarning,\n IField,\n IFieldArray,\n IForm,\n Errors,\n Warnings,\n} from '@flowgram.ai/form';\n\nexport {\n Form,\n Field,\n FieldArray,\n useForm,\n useField,\n useCurrentField,\n useCurrentFieldState,\n useFieldValidate,\n useWatch,\n ValidateTrigger,\n FeedbackLevel,\n} from '@flowgram.ai/form';\nexport * from '@flowgram.ai/node';\nexport { FormModelV2 as FormModel };\n\n/**\n * 固定布局模块导出\n */\nexport * from './preset';\nexport * from './components';\nexport * from './hooks';\nexport * from './clients';\n\n/**\n * Plugin 导出\n */\n\nexport * from '@flowgram.ai/node-variable-plugin';\n\nexport { createPlaygroundReactPreset } from '@flowgram.ai/playground-react';\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { FlowNodeScope, VariablePluginOptions } from '@flowgram.ai/variable-plugin';\nimport { ReduxDevToolPluginOptions } from '@flowgram.ai/redux-devtool-plugin';\nimport { PlaygroundReactProps, SelectionService } from '@flowgram.ai/playground-react';\nimport { NodeCorePluginOptions } from '@flowgram.ai/node-core-plugin';\nimport { type NodeFormProps } from '@flowgram.ai/node';\nimport { MaterialsPluginOptions } from '@flowgram.ai/materials-plugin';\nimport { I18nPluginOptions } from '@flowgram.ai/i18n-plugin';\nimport { HistoryPluginOptions } from '@flowgram.ai/history';\nimport { FormMetaOrFormMetaGenerator } from '@flowgram.ai/form-core';\nimport {\n FlowDocument,\n FlowDocumentJSON,\n FlowNodeEntity,\n type FlowNodeJSON,\n FlowNodeRegistry,\n FlowNodeType,\n} from '@flowgram.ai/document';\nimport { PluginContext } from '@flowgram.ai/core';\n\ndeclare module '@flowgram.ai/document' {\n interface FlowNodeEntity {\n form: NodeFormProps<any> | undefined;\n scope: FlowNodeScope | undefined;\n privateScope: FlowNodeScope | undefined;\n }\n}\n\nexport interface EditorPluginContext extends PluginContext {\n document: FlowDocument;\n selection: SelectionService;\n}\n\nexport interface EditorProps<\n CTX extends EditorPluginContext = EditorPluginContext,\n JSON = FlowDocumentJSON\n> extends PlaygroundReactProps<CTX> {\n /**\n * Initialize data\n * 初始化数据\n */\n initialData?: JSON;\n /**\n * whether it is readonly\n * 是否为 readonly\n */\n readonly?: boolean;\n /**\n * node registries\n * 节点定义\n */\n nodeRegistries?: FlowNodeRegistry[];\n /**\n * Get the default node registry, which will be merged with the 'nodeRegistries'\n * 提供默认的节点注册,这个会和 nodeRegistries 做合并\n */\n getNodeDefaultRegistry?: (type: FlowNodeType) => FlowNodeRegistry;\n /**\n * Node engine configuration\n */\n nodeEngine?: NodeCorePluginOptions & {\n /**\n * Default formMeta\n */\n createDefaultFormMeta?: (node: FlowNodeEntity) => FormMetaOrFormMetaGenerator;\n /**\n * Enable node engine\n */\n enable?: boolean;\n };\n /**\n * By default, all nodes are expanded\n * 默认是否展开所有节点\n */\n allNodesDefaultExpanded?: boolean;\n /**\n * Canvas material, Used to customize react components\n * 画布物料, 用于自定义 react 组件\n */\n materials?: MaterialsPluginOptions;\n /**\n * 画布数据加载完成, 请使用 onAllLayersRendered 替代\n * @deprecated\n * */\n onLoad?: (ctx: CTX) => void;\n /**\n * 是否开启变量引擎\n * Variable engine enable\n */\n variableEngine?: VariablePluginOptions;\n /**\n * Redo/Undo enable\n */\n history?: HistoryPluginOptions<CTX> & { disableShortcuts?: boolean };\n\n /**\n * redux devtool configuration\n */\n reduxDevTool?: ReduxDevToolPluginOptions;\n\n /**\n * Scroll configuration\n * 滚动配置\n */\n scroll?: {\n enableScrollLimit?: boolean; // 开启滚动限制\n disableScrollBar?: boolean; // 关闭滚动条\n disableScroll?: boolean; // 禁止滚动\n };\n\n /**\n * Node data transformation, called by ctx.document.fromJSON\n * 节点数据转换, 由 ctx.document.fromJSON 调用\n * @param node - current node\n * @param json - Current node json data\n */\n toNodeJSON?(node: FlowNodeEntity, json: FlowNodeJSON): FlowNodeJSON;\n /**\n * Node data transformation, called by ctx.document.toJSON\n * 节点数据转换, 由 ctx.document.toJSON 调用\n * @param node - current node\n * @param json - Current node json data\n * @param isFirstCreate - Whether it is created for the first time, If document.fromJSON is recalled, but the node already exists, isFirstCreate is false\n */\n fromNodeJSON?(node: FlowNodeEntity, json: FlowNodeJSON, isFirstCreate: boolean): FlowNodeJSON;\n /**\n * Canvas internal constant customization\n * 画布内部常量自定义\n */\n constants?: Record<string, any>;\n /**\n * i18n\n * 国际化\n */\n i18n?: I18nPluginOptions;\n}\n\nexport namespace EditorProps {\n /**\n * 默认配置\n */\n export const DEFAULT: EditorProps = {\n background: {},\n };\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { interfaces } from 'inversify';\nimport { FlowNodeScope, getNodePrivateScope, getNodeScope } from '@flowgram.ai/variable-plugin';\nimport { FlowRendererContainerModule, FlowRendererRegistry } from '@flowgram.ai/renderer';\nimport { createReduxDevToolPlugin } from '@flowgram.ai/redux-devtool-plugin';\nimport { createNodeVariablePlugin } from '@flowgram.ai/node-variable-plugin';\nimport { createNodeCorePlugin } from '@flowgram.ai/node-core-plugin';\nimport { getNodeForm, NodeFormProps } from '@flowgram.ai/node';\nimport { createMaterialsPlugin } from '@flowgram.ai/materials-plugin';\nimport { createI18nPlugin } from '@flowgram.ai/i18n-plugin';\nimport { createHistoryNodePlugin } from '@flowgram.ai/history-node-plugin';\nimport { FlowDocumentContainerModule } from '@flowgram.ai/document';\nimport { createPlaygroundPlugin, Plugin, PluginsProvider } from '@flowgram.ai/core';\n\nimport { createFlowEditorClientPlugins } from '../clients/flow-editor-client-plugins';\nimport { EditorPluginContext, EditorProps } from './editor-props';\n\nexport function createDefaultPreset<CTX extends EditorPluginContext = EditorPluginContext>(\n opts: EditorProps<CTX>,\n plugins: Plugin[] = []\n): PluginsProvider<CTX> {\n return (ctx: CTX) => {\n opts = { ...EditorProps.DEFAULT, ...opts };\n /**\n * i18n support\n */\n if (opts.i18n) {\n plugins.push(createI18nPlugin(opts.i18n));\n }\n /**\n * 默认注册顶层 flow editor client plugin\n */\n plugins.push(...createFlowEditorClientPlugins());\n\n /**\n * 注册 Redux 开发者工具\n */\n if (opts.reduxDevTool?.enable) {\n plugins.push(createReduxDevToolPlugin(opts.reduxDevTool));\n }\n\n /**\n * 注册画布模块\n */\n const defaultContainerModules: interfaces.ContainerModule[] = [\n FlowDocumentContainerModule, // 默认文档\n FlowRendererContainerModule, // 默认渲染\n ];\n /**\n * 注册物料\n */\n plugins.push(createMaterialsPlugin(opts.materials || {}));\n\n /**\n * 注册节点引擎\n */\n if (opts.nodeEngine && opts.nodeEngine.enable !== false) {\n plugins.push(createNodeCorePlugin({ materials: opts.nodeEngine.materials }));\n\n if (opts.variableEngine?.enable) {\n plugins.push(createNodeVariablePlugin({}));\n }\n\n if (opts.history?.enable) {\n plugins.push(createHistoryNodePlugin({}));\n }\n }\n /**\n * 画布生命周期注册\n */\n plugins.push(\n createPlaygroundPlugin<CTX>({\n onInit: (ctx) => {\n if (opts.nodeRegistries) {\n ctx.document.registerFlowNodes(...opts.nodeRegistries);\n }\n // 自定义画布内部常量\n if (opts.constants) {\n ctx.document.options.constants = opts.constants;\n }\n if (opts.getNodeDefaultRegistry) {\n ctx.document.options.getNodeDefaultRegistry = opts.getNodeDefaultRegistry;\n }\n // TODO\n // if (opts.onContentChange) {\n // ctx.document.onContentChange(event => opts.onContentChange!(ctx, event));\n // }\n // TODO 这个会触发组件注册,后续要废弃这个,通过 materials 插件来做\n ctx.get<FlowRendererRegistry>(FlowRendererRegistry).init();\n\n ctx.document.onNodeCreate(({ node }) => {\n /**\n * Define node.form\n */\n if (opts.nodeEngine && opts.nodeEngine.enable !== false) {\n let cache: NodeFormProps<any> | undefined;\n Object.defineProperty(node, 'form', {\n get: () => {\n if (cache) return cache;\n cache = getNodeForm(node);\n return cache;\n },\n });\n }\n\n /**\n * Define node.scope & node.privateScope\n */\n if (opts.variableEngine && opts.variableEngine.enable !== false) {\n let cache: FlowNodeScope | undefined;\n let privateCache: FlowNodeScope | undefined;\n\n Object.defineProperty(node, 'scope', {\n get: () => {\n if (cache) return cache;\n cache = getNodeScope(node);\n return cache;\n },\n });\n Object.defineProperty(node, 'privateScope', {\n get: () => {\n if (privateCache) return privateCache;\n privateCache = getNodePrivateScope(node);\n return privateCache;\n },\n });\n }\n });\n },\n onReady(ctx) {\n if (opts.initialData) {\n ctx.document.fromJSON(opts.initialData);\n }\n if (opts.readonly) {\n ctx.playground.config.readonly = opts.readonly;\n }\n ctx.document.load().then(() => {\n if (opts.onLoad) opts.onLoad(ctx);\n });\n },\n onDispose(ctx) {\n ctx.document.dispose();\n },\n containerModules: defaultContainerModules,\n })\n );\n\n return plugins;\n };\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { definePluginCreator } from '@flowgram.ai/core';\n\nimport { createNodeClientPlugins } from './node-client/create-node-client-plugins';\nimport { FlowEditorClient } from './flow-editor-client';\n\nexport const createFlowEditorClientPlugin = definePluginCreator<{}>({\n onBind({ bind }) {\n bind(FlowEditorClient).toSelf().inSingletonScope();\n },\n});\n\nexport const createFlowEditorClientPlugins = () => [\n ...createNodeClientPlugins(),\n createFlowEditorClientPlugin({}),\n];\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { definePluginCreator } from '@flowgram.ai/core';\n\nimport { NodeFocusService } from './node-focus-service';\nimport { NodeClient } from './node-client';\nimport { createNodeHighlightPlugin } from './highlight/create-node-highlight-plugin';\n\nexport const createNodeClientPlugin = definePluginCreator<{}>({\n onBind({ bind }) {\n bind(NodeFocusService).toSelf().inSingletonScope();\n bind(NodeClient).toSelf().inSingletonScope();\n },\n});\n\nexport const createNodeClientPlugins = () => [\n createNodeHighlightPlugin({}),\n createNodeClientPlugin({}),\n];\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { injectable, inject } from 'inversify';\nimport { type FormItem } from '@flowgram.ai/form-core';\nimport { Playground, PlaygroundConfigRevealOpts } from '@flowgram.ai/core';\n\nimport { highlightFormItem, HighLightOptions } from './highlight';\n\nexport type FocusNodeCanvasOptions = PlaygroundConfigRevealOpts;\n\nexport interface FocusNodeFormItemOptions {\n canvas?: FocusNodeCanvasOptions;\n highlight?: boolean | HighLightOptions;\n}\n\n@injectable()\nexport class NodeFocusService {\n @inject(Playground) readonly playground: Playground;\n\n protected previousOverlay: HTMLDivElement | undefined;\n\n protected currentPromise: Promise<void> | undefined;\n\n highlightNodeFormItem(formItem: FormItem, options?: HighLightOptions) {\n this.previousOverlay = highlightFormItem(formItem, options);\n }\n\n focusNodeFormItem(formItem: FormItem, options?: FocusNodeFormItemOptions): Promise<void> {\n const node = formItem.formModel.flowNodeEntity;\n const { canvas = {}, highlight } = options || {};\n if (this.previousOverlay) {\n this.previousOverlay.remove();\n this.previousOverlay = undefined;\n }\n const currentPromise = this.playground\n .scrollToView({ entities: [node], scrollToCenter: true, ...canvas })\n .then(() => {\n if (!formItem || !highlight || this.currentPromise !== currentPromise) {\n return;\n }\n this.highlightNodeFormItem(formItem, typeof highlight === 'boolean' ? {} : highlight);\n });\n this.currentPromise = currentPromise;\n return this.currentPromise;\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { FormItem } from '@flowgram.ai/form-core';\nimport { FlowNodeRenderData } from '@flowgram.ai/document';\n\nimport { HIGHLIGHT_CLASSNAME } from './highlight-style';\nimport { DEFAULT_HIGHLIGHT_PADDING } from './constants';\n\nexport interface HighLightOptions {\n padding?: number;\n overlayClassName?: string;\n}\n\nexport function highlightFormItem(\n formItem: FormItem,\n options?: HighLightOptions,\n): HTMLDivElement | undefined {\n const parent =\n formItem.formModel.flowNodeEntity.getData<FlowNodeRenderData>(FlowNodeRenderData).node;\n const target = formItem.domRef.current;\n\n if (!target) {\n return undefined;\n }\n\n const overlay = document.createElement('div');\n\n const { padding = DEFAULT_HIGHLIGHT_PADDING, overlayClassName } = options || {};\n\n overlay.style.position = 'absolute';\n overlay.style.top = '0';\n overlay.style.left = '0';\n overlay.style.width = '100%';\n overlay.style.height = '100%';\n overlay.style.zIndex = '9999';\n\n parent.appendChild(overlay);\n\n const parentRect = parent.getBoundingClientRect();\n const targetRect = target.getBoundingClientRect();\n\n overlay.style.top = targetRect.top - parentRect.top - padding + 'px';\n overlay.style.left = targetRect.left - parentRect.left - padding + 'px';\n overlay.style.width = targetRect.width + padding * 2 + 'px';\n overlay.style.height = targetRect.height + padding * 2 + 'px';\n\n overlay.className = overlayClassName || HIGHLIGHT_CLASSNAME;\n setTimeout(() => {\n overlay.remove();\n }, 2000);\n return overlay;\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nexport const HIGHLIGHT_CLASSNAME = 'flowide-highlight';\n\nconst styleText = `\n@keyframes flowide-fade {\n from {\n opacity: 1.0;\n }\n to {\n opacity: 0;\n }\n}\n@-webkit-keyframes flowide-fade {\n from {\n opacity: 1.0;\n }\n to {\n opacity: 0;\n }\n}\n.${HIGHLIGHT_CLASSNAME} {\n background-color: rgba(238, 245, 40, 0.5);\n animation: flowide-fade 2s 1 forwards;\n -webkit-animation: flowide-fade 2s 1 forwards;\n}\n`;\n\nlet styleDom: HTMLStyleElement | undefined;\n\nexport function createHighlightStyle(): void {\n if (styleDom) return;\n styleDom = document.createElement('style');\n styleDom.innerHTML = styleText;\n document.head.appendChild(styleDom);\n}\n\nexport function removeHighlightStyle(): void {\n styleDom?.remove();\n styleDom = undefined;\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nexport const DEFAULT_HIGHLIGHT_COLOR = 'rgba(238, 245, 40, 0.5)';\nexport const DEFAULT_HIGHLIGHT_PADDING = 0;\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { useRef } from 'react';\n\nimport { FormModel } from '@flowgram.ai/form-core';\n\ninterface HighlightProps {\n form: FormModel;\n path: string;\n}\n\nexport function useHighlight(props: HighlightProps) {\n const ref = useRef<any>(null);\n const { form, path } = props;\n const formItem = form.getFormItemByPath(path);\n if (!formItem) {\n return null;\n }\n formItem.domRef = ref;\n return ref;\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { injectable, inject } from 'inversify';\n\nimport { NodeFocusService } from './node-focus-service';\n\n@injectable()\nexport class NodeClient {\n @inject(NodeFocusService) nodeFocusService: NodeFocusService;\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { definePluginCreator } from '@flowgram.ai/core';\n\nimport { createHighlightStyle, removeHighlightStyle } from './highlight-style';\n\nexport const createNodeHighlightPlugin = definePluginCreator<{}>({\n onInit() {\n createHighlightStyle();\n },\n onDispose() {\n removeHighlightStyle();\n },\n});\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { injectable, inject } from 'inversify';\nimport { type FormItem } from '@flowgram.ai/form-core';\nimport { FlowNodeEntity } from '@flowgram.ai/document';\nimport { Playground, PlaygroundConfigRevealOpts } from '@flowgram.ai/core';\n\nimport { FocusNodeFormItemOptions, NodeClient } from './node-client';\n\ninterface FocusNodeOptions {\n zoom?: PlaygroundConfigRevealOpts['zoom'];\n easing?: PlaygroundConfigRevealOpts['easing']; // 是否开启缓动,默认开启\n easingDuration?: PlaygroundConfigRevealOpts['easingDuration']; // 默认 500 ms\n scrollToCenter?: PlaygroundConfigRevealOpts['scrollToCenter']; // 是否滚动到中心\n}\n\n@injectable()\nexport class FlowEditorClient {\n @inject(NodeClient) readonly nodeClient: NodeClient;\n\n @inject(Playground) readonly playground: Playground;\n\n focusNodeFormItem(formItem: FormItem, options?: FocusNodeFormItemOptions) {\n this.nodeClient.nodeFocusService.focusNodeFormItem(formItem, options);\n }\n\n focusNode(node: FlowNodeEntity, options?: FocusNodeOptions) {\n this.playground.scrollToView({ entities: [node], ...options });\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport React, { useMemo, useCallback } from 'react';\n\nimport { interfaces } from 'inversify';\nimport { FlowDocument } from '@flowgram.ai/document';\nimport {\n PlaygroundReactProvider,\n createPluginContextDefault,\n SelectionService,\n} from '@flowgram.ai/core';\n\nimport { EditorPluginContext, EditorProps, createDefaultPreset } from '../preset';\n\nexport const EditorProvider: React.FC<EditorProps> = (props: EditorProps) => {\n const { children, ...others } = props;\n const preset = useMemo(() => createDefaultPreset(others), []);\n const customPluginContext = useCallback(\n (container: interfaces.Container) =>\n ({\n ...createPluginContextDefault(container),\n get document(): FlowDocument {\n return container.get<FlowDocument>(FlowDocument);\n },\n get selection(): SelectionService {\n return container.get<SelectionService>(SelectionService);\n },\n } as EditorPluginContext),\n []\n );\n return (\n <PlaygroundReactProvider plugins={preset} customPluginContext={customPluginContext}>\n {children}\n </PlaygroundReactProvider>\n );\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nexport { PlaygroundReactRenderer as EditorRenderer } from '@flowgram.ai/core';\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport React from 'react';\n\nimport { EditorProps } from '../preset';\nimport { EditorRenderer } from './editor-renderer';\nimport { EditorProvider } from './editor-provider';\n\n/**\n * 画布编辑器\n * @param props\n * @constructor\n */\nexport const Editor: React.FC<EditorProps> = (props: EditorProps) => {\n const { children, ...otherProps } = props;\n return (\n <EditorProvider {...otherProps}>\n <EditorRenderer>{children}</EditorRenderer>\n </EditorProvider>\n );\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { useService } from '@flowgram.ai/core';\n\nimport { FlowEditorClient } from '../clients';\n\nexport function useFlowEditor(): FlowEditorClient {\n return useService(FlowEditorClient);\n}\n"],"mappings":";;;;;;;;;;;;AAKA,OAAO;AACP,SAAS,mBAAmB;AAG5B,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EAEE,cAAAA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,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gBAAgB;AACpC;;;AhB2EA,cAAc;AAEd,SAAS,mCAAmC;","names":["injectable","inject","EditorProps","definePluginCreator","definePluginCreator","injectable","inject","inject","injectable","definePluginCreator","injectable","inject","Playground","inject","Playground","injectable","definePluginCreator","ctx","React","React"]}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NodeFormProps } from '@flowgram.ai/node';
|
|
1
2
|
export * from '@flowgram.ai/node';
|
|
2
3
|
export { FormModelV2 as FormModel } from '@flowgram.ai/node';
|
|
3
4
|
export * from '@flowgram.ai/utils';
|
|
@@ -8,7 +9,7 @@ export { PlaygroundReactRenderer as EditorRenderer } from '@flowgram.ai/core';
|
|
|
8
9
|
import { FlowDocument, FlowDocumentJSON, FlowNodeRegistry, FlowNodeType, FlowNodeEntity, FlowNodeJSON } from '@flowgram.ai/document';
|
|
9
10
|
export * from '@flowgram.ai/document';
|
|
10
11
|
export * from '@flowgram.ai/renderer';
|
|
11
|
-
import { VariablePluginOptions } from '@flowgram.ai/variable-plugin';
|
|
12
|
+
import { FlowNodeScope, VariablePluginOptions } from '@flowgram.ai/variable-plugin';
|
|
12
13
|
export * from '@flowgram.ai/variable-plugin';
|
|
13
14
|
export * from '@flowgram.ai/shortcuts-plugin';
|
|
14
15
|
import { NodeCorePluginOptions } from '@flowgram.ai/node-core-plugin';
|
|
@@ -34,6 +35,13 @@ export * from '@flowgram.ai/node-variable-plugin';
|
|
|
34
35
|
* SPDX-License-Identifier: MIT
|
|
35
36
|
*/
|
|
36
37
|
|
|
38
|
+
declare module '@flowgram.ai/document' {
|
|
39
|
+
interface FlowNodeEntity {
|
|
40
|
+
form: NodeFormProps<any> | undefined;
|
|
41
|
+
scope: FlowNodeScope | undefined;
|
|
42
|
+
privateScope: FlowNodeScope | undefined;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
37
45
|
interface EditorPluginContext extends PluginContext {
|
|
38
46
|
document: FlowDocument;
|
|
39
47
|
selection: SelectionService;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NodeFormProps } from '@flowgram.ai/node';
|
|
1
2
|
export * from '@flowgram.ai/node';
|
|
2
3
|
export { FormModelV2 as FormModel } from '@flowgram.ai/node';
|
|
3
4
|
export * from '@flowgram.ai/utils';
|
|
@@ -8,7 +9,7 @@ export { PlaygroundReactRenderer as EditorRenderer } from '@flowgram.ai/core';
|
|
|
8
9
|
import { FlowDocument, FlowDocumentJSON, FlowNodeRegistry, FlowNodeType, FlowNodeEntity, FlowNodeJSON } from '@flowgram.ai/document';
|
|
9
10
|
export * from '@flowgram.ai/document';
|
|
10
11
|
export * from '@flowgram.ai/renderer';
|
|
11
|
-
import { VariablePluginOptions } from '@flowgram.ai/variable-plugin';
|
|
12
|
+
import { FlowNodeScope, VariablePluginOptions } from '@flowgram.ai/variable-plugin';
|
|
12
13
|
export * from '@flowgram.ai/variable-plugin';
|
|
13
14
|
export * from '@flowgram.ai/shortcuts-plugin';
|
|
14
15
|
import { NodeCorePluginOptions } from '@flowgram.ai/node-core-plugin';
|
|
@@ -34,6 +35,13 @@ export * from '@flowgram.ai/node-variable-plugin';
|
|
|
34
35
|
* SPDX-License-Identifier: MIT
|
|
35
36
|
*/
|
|
36
37
|
|
|
38
|
+
declare module '@flowgram.ai/document' {
|
|
39
|
+
interface FlowNodeEntity {
|
|
40
|
+
form: NodeFormProps<any> | undefined;
|
|
41
|
+
scope: FlowNodeScope | undefined;
|
|
42
|
+
privateScope: FlowNodeScope | undefined;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
37
45
|
interface EditorPluginContext extends PluginContext {
|
|
38
46
|
document: FlowDocument;
|
|
39
47
|
selection: SelectionService;
|
package/dist/index.js
CHANGED
|
@@ -52,7 +52,7 @@ __export(index_exports, {
|
|
|
52
52
|
FlowEditorClient: () => FlowEditorClient,
|
|
53
53
|
FlowNodeFormData: () => import_form_core.FlowNodeFormData,
|
|
54
54
|
Form: () => import_form.Form,
|
|
55
|
-
FormModel: () =>
|
|
55
|
+
FormModel: () => import_node2.FormModelV2,
|
|
56
56
|
NodeClient: () => NodeClient,
|
|
57
57
|
NodeFocusService: () => NodeFocusService,
|
|
58
58
|
NodeRender: () => import_form_core.NodeRender,
|
|
@@ -85,7 +85,7 @@ __export(index_exports, {
|
|
|
85
85
|
});
|
|
86
86
|
module.exports = __toCommonJS(index_exports);
|
|
87
87
|
var import_reflect_metadata = require("reflect-metadata");
|
|
88
|
-
var
|
|
88
|
+
var import_node2 = require("@flowgram.ai/node");
|
|
89
89
|
__reExport(index_exports, require("@flowgram.ai/utils"), module.exports);
|
|
90
90
|
__reExport(index_exports, require("@flowgram.ai/core"), module.exports);
|
|
91
91
|
__reExport(index_exports, require("@flowgram.ai/document"), module.exports);
|
|
@@ -109,10 +109,12 @@ var EditorProps;
|
|
|
109
109
|
})(EditorProps || (EditorProps = {}));
|
|
110
110
|
|
|
111
111
|
// src/preset/editor-default-preset.ts
|
|
112
|
+
var import_variable_plugin = require("@flowgram.ai/variable-plugin");
|
|
112
113
|
var import_renderer = require("@flowgram.ai/renderer");
|
|
113
114
|
var import_redux_devtool_plugin = require("@flowgram.ai/redux-devtool-plugin");
|
|
114
115
|
var import_node_variable_plugin = require("@flowgram.ai/node-variable-plugin");
|
|
115
116
|
var import_node_core_plugin = require("@flowgram.ai/node-core-plugin");
|
|
117
|
+
var import_node = require("@flowgram.ai/node");
|
|
116
118
|
var import_materials_plugin = require("@flowgram.ai/materials-plugin");
|
|
117
119
|
var import_i18n_plugin = require("@flowgram.ai/i18n-plugin");
|
|
118
120
|
var import_history_node_plugin = require("@flowgram.ai/history-node-plugin");
|
|
@@ -349,6 +351,36 @@ function createDefaultPreset(opts, plugins = []) {
|
|
|
349
351
|
ctx2.document.options.getNodeDefaultRegistry = opts.getNodeDefaultRegistry;
|
|
350
352
|
}
|
|
351
353
|
ctx2.get(import_renderer.FlowRendererRegistry).init();
|
|
354
|
+
ctx2.document.onNodeCreate(({ node }) => {
|
|
355
|
+
if (opts.nodeEngine && opts.nodeEngine.enable !== false) {
|
|
356
|
+
let cache;
|
|
357
|
+
Object.defineProperty(node, "form", {
|
|
358
|
+
get: () => {
|
|
359
|
+
if (cache) return cache;
|
|
360
|
+
cache = (0, import_node.getNodeForm)(node);
|
|
361
|
+
return cache;
|
|
362
|
+
}
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
if (opts.variableEngine && opts.variableEngine.enable !== false) {
|
|
366
|
+
let cache;
|
|
367
|
+
let privateCache;
|
|
368
|
+
Object.defineProperty(node, "scope", {
|
|
369
|
+
get: () => {
|
|
370
|
+
if (cache) return cache;
|
|
371
|
+
cache = (0, import_variable_plugin.getNodeScope)(node);
|
|
372
|
+
return cache;
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
Object.defineProperty(node, "privateScope", {
|
|
376
|
+
get: () => {
|
|
377
|
+
if (privateCache) return privateCache;
|
|
378
|
+
privateCache = (0, import_variable_plugin.getNodePrivateScope)(node);
|
|
379
|
+
return privateCache;
|
|
380
|
+
}
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
});
|
|
352
384
|
},
|
|
353
385
|
onReady(ctx2) {
|
|
354
386
|
if (opts.initialData) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/preset/editor-props.ts","../src/preset/editor-default-preset.ts","../src/clients/flow-editor-client-plugins.ts","../src/clients/node-client/create-node-client-plugins.ts","../src/clients/node-client/node-focus-service.ts","../src/clients/node-client/highlight/highlight-form-item.ts","../src/clients/node-client/highlight/highlight-style.ts","../src/clients/node-client/highlight/constants.ts","../src/clients/node-client/highlight/use-highlight.ts","../src/clients/node-client/node-client.ts","../src/clients/node-client/highlight/create-node-highlight-plugin.ts","../src/clients/flow-editor-client.ts","../src/components/editor-provider.tsx","../src/components/editor-renderer.tsx","../src/components/editor.tsx","../src/hooks/use-flow-editor.ts"],"sourcesContent":["/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport 'reflect-metadata';\nimport { FormModelV2 } from '@flowgram.ai/node';\n\n/* 核心 模块导出 */\nexport * from '@flowgram.ai/utils';\nexport * from '@flowgram.ai/core';\nexport * from '@flowgram.ai/document';\nexport * from '@flowgram.ai/renderer';\nexport * from '@flowgram.ai/variable-plugin';\nexport * from '@flowgram.ai/shortcuts-plugin';\nexport * from '@flowgram.ai/node-core-plugin';\nexport * from '@flowgram.ai/i18n-plugin';\nexport {\n ReactiveState,\n ReactiveBaseState,\n Tracker,\n useReactiveState,\n useReadonlyReactiveState,\n useObserve,\n observe,\n} from '@flowgram.ai/reactive';\nexport {\n type interfaces,\n injectable,\n postConstruct,\n named,\n Container,\n ContainerModule,\n AsyncContainerModule,\n inject,\n multiInject,\n} from 'inversify';\n\nexport { FlowNodeFormData, NodeRender, type NodeRenderProps } from '@flowgram.ai/form-core';\n\nexport type {\n FormState,\n FieldState,\n FieldArrayRenderProps,\n FieldRenderProps,\n FormRenderProps,\n Validate,\n FormControl,\n FieldName,\n FieldError,\n FieldWarning,\n IField,\n IFieldArray,\n IForm,\n Errors,\n Warnings,\n} from '@flowgram.ai/form';\n\nexport {\n Form,\n Field,\n FieldArray,\n useForm,\n useField,\n useCurrentField,\n useCurrentFieldState,\n useFieldValidate,\n useWatch,\n ValidateTrigger,\n FeedbackLevel,\n} from '@flowgram.ai/form';\nexport * from '@flowgram.ai/node';\nexport { FormModelV2 as FormModel };\n\n/**\n * 固定布局模块导出\n */\nexport * from './preset';\nexport * from './components';\nexport * from './hooks';\nexport * from './clients';\n\n/**\n * Plugin 导出\n */\n\nexport * from '@flowgram.ai/node-variable-plugin';\n\nexport { createPlaygroundReactPreset } from '@flowgram.ai/playground-react';\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { VariablePluginOptions } from '@flowgram.ai/variable-plugin';\nimport { ReduxDevToolPluginOptions } from '@flowgram.ai/redux-devtool-plugin';\nimport { PlaygroundReactProps, SelectionService } from '@flowgram.ai/playground-react';\nimport { NodeCorePluginOptions } from '@flowgram.ai/node-core-plugin';\nimport { MaterialsPluginOptions } from '@flowgram.ai/materials-plugin';\nimport { I18nPluginOptions } from '@flowgram.ai/i18n-plugin';\nimport { HistoryPluginOptions } from '@flowgram.ai/history';\nimport { FormMetaOrFormMetaGenerator } from '@flowgram.ai/form-core';\nimport {\n FlowDocument,\n FlowDocumentJSON,\n FlowNodeEntity,\n type FlowNodeJSON,\n FlowNodeRegistry,\n FlowNodeType,\n} from '@flowgram.ai/document';\nimport { PluginContext } from '@flowgram.ai/core';\n\nexport interface EditorPluginContext extends PluginContext {\n document: FlowDocument;\n selection: SelectionService;\n}\n\nexport interface EditorProps<\n CTX extends EditorPluginContext = EditorPluginContext,\n JSON = FlowDocumentJSON\n> extends PlaygroundReactProps<CTX> {\n /**\n * Initialize data\n * 初始化数据\n */\n initialData?: JSON;\n /**\n * whether it is readonly\n * 是否为 readonly\n */\n readonly?: boolean;\n /**\n * node registries\n * 节点定义\n */\n nodeRegistries?: FlowNodeRegistry[];\n /**\n * Get the default node registry, which will be merged with the 'nodeRegistries'\n * 提供默认的节点注册,这个会和 nodeRegistries 做合并\n */\n getNodeDefaultRegistry?: (type: FlowNodeType) => FlowNodeRegistry;\n /**\n * Node engine configuration\n */\n nodeEngine?: NodeCorePluginOptions & {\n /**\n * Default formMeta\n */\n createDefaultFormMeta?: (node: FlowNodeEntity) => FormMetaOrFormMetaGenerator;\n /**\n * Enable node engine\n */\n enable?: boolean;\n };\n /**\n * By default, all nodes are expanded\n * 默认是否展开所有节点\n */\n allNodesDefaultExpanded?: boolean;\n /**\n * Canvas material, Used to customize react components\n * 画布物料, 用于自定义 react 组件\n */\n materials?: MaterialsPluginOptions;\n /**\n * 画布数据加载完成, 请使用 onAllLayersRendered 替代\n * @deprecated\n * */\n onLoad?: (ctx: CTX) => void;\n /**\n * 是否开启变量引擎\n * Variable engine enable\n */\n variableEngine?: VariablePluginOptions;\n /**\n * Redo/Undo enable\n */\n history?: HistoryPluginOptions<CTX> & { disableShortcuts?: boolean };\n\n /**\n * redux devtool configuration\n */\n reduxDevTool?: ReduxDevToolPluginOptions;\n\n /**\n * Scroll configuration\n * 滚动配置\n */\n scroll?: {\n enableScrollLimit?: boolean; // 开启滚动限制\n disableScrollBar?: boolean; // 关闭滚动条\n disableScroll?: boolean; // 禁止滚动\n };\n\n /**\n * Node data transformation, called by ctx.document.fromJSON\n * 节点数据转换, 由 ctx.document.fromJSON 调用\n * @param node - current node\n * @param json - Current node json data\n */\n toNodeJSON?(node: FlowNodeEntity, json: FlowNodeJSON): FlowNodeJSON;\n /**\n * Node data transformation, called by ctx.document.toJSON\n * 节点数据转换, 由 ctx.document.toJSON 调用\n * @param node - current node\n * @param json - Current node json data\n * @param isFirstCreate - Whether it is created for the first time, If document.fromJSON is recalled, but the node already exists, isFirstCreate is false\n */\n fromNodeJSON?(node: FlowNodeEntity, json: FlowNodeJSON, isFirstCreate: boolean): FlowNodeJSON;\n /**\n * Canvas internal constant customization\n * 画布内部常量自定义\n */\n constants?: Record<string, any>;\n /**\n * i18n\n * 国际化\n */\n i18n?: I18nPluginOptions;\n}\n\nexport namespace EditorProps {\n /**\n * 默认配置\n */\n export const DEFAULT: EditorProps = {\n background: {},\n };\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { interfaces } from 'inversify';\nimport { FlowRendererContainerModule, FlowRendererRegistry } from '@flowgram.ai/renderer';\nimport { createReduxDevToolPlugin } from '@flowgram.ai/redux-devtool-plugin';\nimport { createNodeVariablePlugin } from '@flowgram.ai/node-variable-plugin';\nimport { createNodeCorePlugin } from '@flowgram.ai/node-core-plugin';\nimport { createMaterialsPlugin } from '@flowgram.ai/materials-plugin';\nimport { createI18nPlugin } from '@flowgram.ai/i18n-plugin';\nimport { createHistoryNodePlugin } from '@flowgram.ai/history-node-plugin';\nimport { FlowDocumentContainerModule } from '@flowgram.ai/document';\nimport { createPlaygroundPlugin, Plugin, PluginsProvider } from '@flowgram.ai/core';\n\nimport { createFlowEditorClientPlugins } from '../clients/flow-editor-client-plugins';\nimport { EditorPluginContext, EditorProps } from './editor-props';\n\nexport function createDefaultPreset<CTX extends EditorPluginContext = EditorPluginContext>(\n opts: EditorProps<CTX>,\n plugins: Plugin[] = []\n): PluginsProvider<CTX> {\n return (ctx: CTX) => {\n opts = { ...EditorProps.DEFAULT, ...opts };\n /**\n * i18n support\n */\n if (opts.i18n) {\n plugins.push(createI18nPlugin(opts.i18n));\n }\n /**\n * 默认注册顶层 flow editor client plugin\n */\n plugins.push(...createFlowEditorClientPlugins());\n\n /**\n * 注册 Redux 开发者工具\n */\n if (opts.reduxDevTool?.enable) {\n plugins.push(createReduxDevToolPlugin(opts.reduxDevTool));\n }\n\n /**\n * 注册画布模块\n */\n const defaultContainerModules: interfaces.ContainerModule[] = [\n FlowDocumentContainerModule, // 默认文档\n FlowRendererContainerModule, // 默认渲染\n ];\n /**\n * 注册物料\n */\n plugins.push(createMaterialsPlugin(opts.materials || {}));\n\n /**\n * 注册节点引擎\n */\n if (opts.nodeEngine && opts.nodeEngine.enable !== false) {\n plugins.push(createNodeCorePlugin({ materials: opts.nodeEngine.materials }));\n\n if (opts.variableEngine?.enable) {\n plugins.push(createNodeVariablePlugin({}));\n }\n\n if (opts.history?.enable) {\n plugins.push(createHistoryNodePlugin({}));\n }\n }\n /**\n * 画布生命周期注册\n */\n plugins.push(\n createPlaygroundPlugin<CTX>({\n onInit: (ctx) => {\n if (opts.nodeRegistries) {\n ctx.document.registerFlowNodes(...opts.nodeRegistries);\n }\n // 自定义画布内部常量\n if (opts.constants) {\n ctx.document.options.constants = opts.constants;\n }\n if (opts.getNodeDefaultRegistry) {\n ctx.document.options.getNodeDefaultRegistry = opts.getNodeDefaultRegistry;\n }\n // TODO\n // if (opts.onContentChange) {\n // ctx.document.onContentChange(event => opts.onContentChange!(ctx, event));\n // }\n // TODO 这个会触发组件注册,后续要废弃这个,通过 materials 插件来做\n ctx.get<FlowRendererRegistry>(FlowRendererRegistry).init();\n },\n onReady(ctx) {\n if (opts.initialData) {\n ctx.document.fromJSON(opts.initialData);\n }\n if (opts.readonly) {\n ctx.playground.config.readonly = opts.readonly;\n }\n ctx.document.load().then(() => {\n if (opts.onLoad) opts.onLoad(ctx);\n });\n },\n onDispose(ctx) {\n ctx.document.dispose();\n },\n containerModules: defaultContainerModules,\n })\n );\n\n return plugins;\n };\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { definePluginCreator } from '@flowgram.ai/core';\n\nimport { createNodeClientPlugins } from './node-client/create-node-client-plugins';\nimport { FlowEditorClient } from './flow-editor-client';\n\nexport const createFlowEditorClientPlugin = definePluginCreator<{}>({\n onBind({ bind }) {\n bind(FlowEditorClient).toSelf().inSingletonScope();\n },\n});\n\nexport const createFlowEditorClientPlugins = () => [\n ...createNodeClientPlugins(),\n createFlowEditorClientPlugin({}),\n];\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { definePluginCreator } from '@flowgram.ai/core';\n\nimport { NodeFocusService } from './node-focus-service';\nimport { NodeClient } from './node-client';\nimport { createNodeHighlightPlugin } from './highlight/create-node-highlight-plugin';\n\nexport const createNodeClientPlugin = definePluginCreator<{}>({\n onBind({ bind }) {\n bind(NodeFocusService).toSelf().inSingletonScope();\n bind(NodeClient).toSelf().inSingletonScope();\n },\n});\n\nexport const createNodeClientPlugins = () => [\n createNodeHighlightPlugin({}),\n createNodeClientPlugin({}),\n];\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { injectable, inject } from 'inversify';\nimport { type FormItem } from '@flowgram.ai/form-core';\nimport { Playground, PlaygroundConfigRevealOpts } from '@flowgram.ai/core';\n\nimport { highlightFormItem, HighLightOptions } from './highlight';\n\nexport type FocusNodeCanvasOptions = PlaygroundConfigRevealOpts;\n\nexport interface FocusNodeFormItemOptions {\n canvas?: FocusNodeCanvasOptions;\n highlight?: boolean | HighLightOptions;\n}\n\n@injectable()\nexport class NodeFocusService {\n @inject(Playground) readonly playground: Playground;\n\n protected previousOverlay: HTMLDivElement | undefined;\n\n protected currentPromise: Promise<void> | undefined;\n\n highlightNodeFormItem(formItem: FormItem, options?: HighLightOptions) {\n this.previousOverlay = highlightFormItem(formItem, options);\n }\n\n focusNodeFormItem(formItem: FormItem, options?: FocusNodeFormItemOptions): Promise<void> {\n const node = formItem.formModel.flowNodeEntity;\n const { canvas = {}, highlight } = options || {};\n if (this.previousOverlay) {\n this.previousOverlay.remove();\n this.previousOverlay = undefined;\n }\n const currentPromise = this.playground\n .scrollToView({ entities: [node], scrollToCenter: true, ...canvas })\n .then(() => {\n if (!formItem || !highlight || this.currentPromise !== currentPromise) {\n return;\n }\n this.highlightNodeFormItem(formItem, typeof highlight === 'boolean' ? {} : highlight);\n });\n this.currentPromise = currentPromise;\n return this.currentPromise;\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { FormItem } from '@flowgram.ai/form-core';\nimport { FlowNodeRenderData } from '@flowgram.ai/document';\n\nimport { HIGHLIGHT_CLASSNAME } from './highlight-style';\nimport { DEFAULT_HIGHLIGHT_PADDING } from './constants';\n\nexport interface HighLightOptions {\n padding?: number;\n overlayClassName?: string;\n}\n\nexport function highlightFormItem(\n formItem: FormItem,\n options?: HighLightOptions,\n): HTMLDivElement | undefined {\n const parent =\n formItem.formModel.flowNodeEntity.getData<FlowNodeRenderData>(FlowNodeRenderData).node;\n const target = formItem.domRef.current;\n\n if (!target) {\n return undefined;\n }\n\n const overlay = document.createElement('div');\n\n const { padding = DEFAULT_HIGHLIGHT_PADDING, overlayClassName } = options || {};\n\n overlay.style.position = 'absolute';\n overlay.style.top = '0';\n overlay.style.left = '0';\n overlay.style.width = '100%';\n overlay.style.height = '100%';\n overlay.style.zIndex = '9999';\n\n parent.appendChild(overlay);\n\n const parentRect = parent.getBoundingClientRect();\n const targetRect = target.getBoundingClientRect();\n\n overlay.style.top = targetRect.top - parentRect.top - padding + 'px';\n overlay.style.left = targetRect.left - parentRect.left - padding + 'px';\n overlay.style.width = targetRect.width + padding * 2 + 'px';\n overlay.style.height = targetRect.height + padding * 2 + 'px';\n\n overlay.className = overlayClassName || HIGHLIGHT_CLASSNAME;\n setTimeout(() => {\n overlay.remove();\n }, 2000);\n return overlay;\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nexport const HIGHLIGHT_CLASSNAME = 'flowide-highlight';\n\nconst styleText = `\n@keyframes flowide-fade {\n from {\n opacity: 1.0;\n }\n to {\n opacity: 0;\n }\n}\n@-webkit-keyframes flowide-fade {\n from {\n opacity: 1.0;\n }\n to {\n opacity: 0;\n }\n}\n.${HIGHLIGHT_CLASSNAME} {\n background-color: rgba(238, 245, 40, 0.5);\n animation: flowide-fade 2s 1 forwards;\n -webkit-animation: flowide-fade 2s 1 forwards;\n}\n`;\n\nlet styleDom: HTMLStyleElement | undefined;\n\nexport function createHighlightStyle(): void {\n if (styleDom) return;\n styleDom = document.createElement('style');\n styleDom.innerHTML = styleText;\n document.head.appendChild(styleDom);\n}\n\nexport function removeHighlightStyle(): void {\n styleDom?.remove();\n styleDom = undefined;\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nexport const DEFAULT_HIGHLIGHT_COLOR = 'rgba(238, 245, 40, 0.5)';\nexport const DEFAULT_HIGHLIGHT_PADDING = 0;\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { useRef } from 'react';\n\nimport { FormModel } from '@flowgram.ai/form-core';\n\ninterface HighlightProps {\n form: FormModel;\n path: string;\n}\n\nexport function useHighlight(props: HighlightProps) {\n const ref = useRef<any>(null);\n const { form, path } = props;\n const formItem = form.getFormItemByPath(path);\n if (!formItem) {\n return null;\n }\n formItem.domRef = ref;\n return ref;\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { injectable, inject } from 'inversify';\n\nimport { NodeFocusService } from './node-focus-service';\n\n@injectable()\nexport class NodeClient {\n @inject(NodeFocusService) nodeFocusService: NodeFocusService;\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { definePluginCreator } from '@flowgram.ai/core';\n\nimport { createHighlightStyle, removeHighlightStyle } from './highlight-style';\n\nexport const createNodeHighlightPlugin = definePluginCreator<{}>({\n onInit() {\n createHighlightStyle();\n },\n onDispose() {\n removeHighlightStyle();\n },\n});\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { injectable, inject } from 'inversify';\nimport { type FormItem } from '@flowgram.ai/form-core';\nimport { FlowNodeEntity } from '@flowgram.ai/document';\nimport { Playground, PlaygroundConfigRevealOpts } from '@flowgram.ai/core';\n\nimport { FocusNodeFormItemOptions, NodeClient } from './node-client';\n\ninterface FocusNodeOptions {\n zoom?: PlaygroundConfigRevealOpts['zoom'];\n easing?: PlaygroundConfigRevealOpts['easing']; // 是否开启缓动,默认开启\n easingDuration?: PlaygroundConfigRevealOpts['easingDuration']; // 默认 500 ms\n scrollToCenter?: PlaygroundConfigRevealOpts['scrollToCenter']; // 是否滚动到中心\n}\n\n@injectable()\nexport class FlowEditorClient {\n @inject(NodeClient) readonly nodeClient: NodeClient;\n\n @inject(Playground) readonly playground: Playground;\n\n focusNodeFormItem(formItem: FormItem, options?: FocusNodeFormItemOptions) {\n this.nodeClient.nodeFocusService.focusNodeFormItem(formItem, options);\n }\n\n focusNode(node: FlowNodeEntity, options?: FocusNodeOptions) {\n this.playground.scrollToView({ entities: [node], ...options });\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport React, { useMemo, useCallback } from 'react';\n\nimport { interfaces } from 'inversify';\nimport { FlowDocument } from '@flowgram.ai/document';\nimport {\n PlaygroundReactProvider,\n createPluginContextDefault,\n SelectionService,\n} from '@flowgram.ai/core';\n\nimport { EditorPluginContext, EditorProps, createDefaultPreset } from '../preset';\n\nexport const EditorProvider: React.FC<EditorProps> = (props: EditorProps) => {\n const { children, ...others } = props;\n const preset = useMemo(() => createDefaultPreset(others), []);\n const customPluginContext = useCallback(\n (container: interfaces.Container) =>\n ({\n ...createPluginContextDefault(container),\n get document(): FlowDocument {\n return container.get<FlowDocument>(FlowDocument);\n },\n get selection(): SelectionService {\n return container.get<SelectionService>(SelectionService);\n },\n } as EditorPluginContext),\n []\n );\n return (\n <PlaygroundReactProvider plugins={preset} customPluginContext={customPluginContext}>\n {children}\n </PlaygroundReactProvider>\n );\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nexport { PlaygroundReactRenderer as EditorRenderer } from '@flowgram.ai/core';\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport React from 'react';\n\nimport { EditorProps } from '../preset';\nimport { EditorRenderer } from './editor-renderer';\nimport { EditorProvider } from './editor-provider';\n\n/**\n * 画布编辑器\n * @param props\n * @constructor\n */\nexport const Editor: React.FC<EditorProps> = (props: EditorProps) => {\n const { children, ...otherProps } = props;\n return (\n <EditorProvider {...otherProps}>\n <EditorRenderer>{children}</EditorRenderer>\n </EditorProvider>\n );\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { useService } from '@flowgram.ai/core';\n\nimport { FlowEditorClient } from '../clients';\n\nexport function useFlowEditor(): FlowEditorClient {\n return useService(FlowEditorClient);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,8BAAO;AACP,kBAA4B;AAG5B,0BAAc,+BATd;AAUA,0BAAc,8BAVd;AAWA,0BAAc,kCAXd;AAYA,0BAAc,kCAZd;AAaA,0BAAc,yCAbd;AAcA,0BAAc,0CAdd;AAeA,0BAAc,0CAfd;AAgBA,0BAAc,qCAhBd;AAiBA,sBAQO;AACP,IAAAA,oBAUO;AAEP,uBAAmE;AAoBnE,kBAYO;AACP,0BAAc,8BAvEd;;;ACoIO,IAAU;AAAA,CAAV,CAAUC,iBAAV;AAIE,EAAMA,aAAA,UAAuB;AAAA,IAClC,YAAY,CAAC;AAAA,EACf;AAAA,GANe;;;AC9HjB,sBAAkE;AAClE,kCAAyC;AACzC,kCAAyC;AACzC,8BAAqC;AACrC,8BAAsC;AACtC,yBAAiC;AACjC,iCAAwC;AACxC,IAAAC,mBAA4C;AAC5C,IAAAC,eAAgE;;;ACThE,IAAAC,eAAoC;;;ACApC,IAAAC,eAAoC;;;ACApC,uBAAmC;AAEnC,kBAAuD;;;ACDvD,sBAAmC;;;ACD5B,IAAM,sBAAsB;AAEnC,IAAM,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAiBf,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;AW3GA,IAAAC,gBAA4C;AAG5C,IAAAC,mBAA6B;AAC7B,IAAAC,eAIO;AAIA,IAAM,iBAAwC,CAAC,UAAuB;AAC3E,QAAM,EAAE,UAAU,GAAG,OAAO,IAAI;AAChC,QAAM,aAAS,uBAAQ,MAAM,oBAAoB,MAAM,GAAG,CAAC,CAAC;AAC5D,QAAM,0BAAsB;AAAA,IAC1B,CAAC,eACE;AAAA,MACC,OAAG,yCAA2B,SAAS;AAAA,MACvC,IAAI,WAAyB;AAC3B,eAAO,UAAU,IAAkB,6BAAY;AAAA,MACjD;AAAA,MACA,IAAI,YAA8B;AAChC,eAAO,UAAU,IAAsB,6BAAgB;AAAA,MACzD;AAAA,IACF;AAAA,IACF,CAAC;AAAA,EACH;AACA,SACE,8BAAAC,QAAA,cAAC,wCAAwB,SAAS,QAAQ,uBACvC,QACH;AAEJ;;;ACjCA,IAAAC,eAA0D;;;ACA1D,IAAAC,gBAAkB;AAWX,IAAM,SAAgC,CAAC,UAAuB;AACnE,QAAM,EAAE,UAAU,GAAG,WAAW,IAAI;AACpC,SACE,8BAAAC,QAAA,cAAC,kBAAgB,GAAG,cAClB,8BAAAA,QAAA,cAAC,4CAAgB,QAAS,CAC5B;AAEJ;;;AClBA,IAAAC,eAA2B;AAIpB,SAAS,gBAAkC;AAChD,aAAO,yBAAW,gBAAgB;AACpC;;;AhB2EA,0BAAc,8CAtFd;AAwFA,8BAA4C;","names":["import_inversify","EditorProps","import_document","import_core","import_core","import_core","import_inversify","import_core","import_inversify","import_core","ctx","import_react","import_document","import_core","React","import_core","import_react","React","import_core"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/preset/editor-props.ts","../src/preset/editor-default-preset.ts","../src/clients/flow-editor-client-plugins.ts","../src/clients/node-client/create-node-client-plugins.ts","../src/clients/node-client/node-focus-service.ts","../src/clients/node-client/highlight/highlight-form-item.ts","../src/clients/node-client/highlight/highlight-style.ts","../src/clients/node-client/highlight/constants.ts","../src/clients/node-client/highlight/use-highlight.ts","../src/clients/node-client/node-client.ts","../src/clients/node-client/highlight/create-node-highlight-plugin.ts","../src/clients/flow-editor-client.ts","../src/components/editor-provider.tsx","../src/components/editor-renderer.tsx","../src/components/editor.tsx","../src/hooks/use-flow-editor.ts"],"sourcesContent":["/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport 'reflect-metadata';\nimport { FormModelV2 } from '@flowgram.ai/node';\n\n/* 核心 模块导出 */\nexport * from '@flowgram.ai/utils';\nexport * from '@flowgram.ai/core';\nexport * from '@flowgram.ai/document';\nexport * from '@flowgram.ai/renderer';\nexport * from '@flowgram.ai/variable-plugin';\nexport * from '@flowgram.ai/shortcuts-plugin';\nexport * from '@flowgram.ai/node-core-plugin';\nexport * from '@flowgram.ai/i18n-plugin';\nexport {\n ReactiveState,\n ReactiveBaseState,\n Tracker,\n useReactiveState,\n useReadonlyReactiveState,\n useObserve,\n observe,\n} from '@flowgram.ai/reactive';\nexport {\n type interfaces,\n injectable,\n postConstruct,\n named,\n Container,\n ContainerModule,\n AsyncContainerModule,\n inject,\n multiInject,\n} from 'inversify';\n\nexport { FlowNodeFormData, NodeRender, type NodeRenderProps } from '@flowgram.ai/form-core';\n\nexport type {\n FormState,\n FieldState,\n FieldArrayRenderProps,\n FieldRenderProps,\n FormRenderProps,\n Validate,\n FormControl,\n FieldName,\n FieldError,\n FieldWarning,\n IField,\n IFieldArray,\n IForm,\n Errors,\n Warnings,\n} from '@flowgram.ai/form';\n\nexport {\n Form,\n Field,\n FieldArray,\n useForm,\n useField,\n useCurrentField,\n useCurrentFieldState,\n useFieldValidate,\n useWatch,\n ValidateTrigger,\n FeedbackLevel,\n} from '@flowgram.ai/form';\nexport * from '@flowgram.ai/node';\nexport { FormModelV2 as FormModel };\n\n/**\n * 固定布局模块导出\n */\nexport * from './preset';\nexport * from './components';\nexport * from './hooks';\nexport * from './clients';\n\n/**\n * Plugin 导出\n */\n\nexport * from '@flowgram.ai/node-variable-plugin';\n\nexport { createPlaygroundReactPreset } from '@flowgram.ai/playground-react';\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { FlowNodeScope, VariablePluginOptions } from '@flowgram.ai/variable-plugin';\nimport { ReduxDevToolPluginOptions } from '@flowgram.ai/redux-devtool-plugin';\nimport { PlaygroundReactProps, SelectionService } from '@flowgram.ai/playground-react';\nimport { NodeCorePluginOptions } from '@flowgram.ai/node-core-plugin';\nimport { type NodeFormProps } from '@flowgram.ai/node';\nimport { MaterialsPluginOptions } from '@flowgram.ai/materials-plugin';\nimport { I18nPluginOptions } from '@flowgram.ai/i18n-plugin';\nimport { HistoryPluginOptions } from '@flowgram.ai/history';\nimport { FormMetaOrFormMetaGenerator } from '@flowgram.ai/form-core';\nimport {\n FlowDocument,\n FlowDocumentJSON,\n FlowNodeEntity,\n type FlowNodeJSON,\n FlowNodeRegistry,\n FlowNodeType,\n} from '@flowgram.ai/document';\nimport { PluginContext } from '@flowgram.ai/core';\n\ndeclare module '@flowgram.ai/document' {\n interface FlowNodeEntity {\n form: NodeFormProps<any> | undefined;\n scope: FlowNodeScope | undefined;\n privateScope: FlowNodeScope | undefined;\n }\n}\n\nexport interface EditorPluginContext extends PluginContext {\n document: FlowDocument;\n selection: SelectionService;\n}\n\nexport interface EditorProps<\n CTX extends EditorPluginContext = EditorPluginContext,\n JSON = FlowDocumentJSON\n> extends PlaygroundReactProps<CTX> {\n /**\n * Initialize data\n * 初始化数据\n */\n initialData?: JSON;\n /**\n * whether it is readonly\n * 是否为 readonly\n */\n readonly?: boolean;\n /**\n * node registries\n * 节点定义\n */\n nodeRegistries?: FlowNodeRegistry[];\n /**\n * Get the default node registry, which will be merged with the 'nodeRegistries'\n * 提供默认的节点注册,这个会和 nodeRegistries 做合并\n */\n getNodeDefaultRegistry?: (type: FlowNodeType) => FlowNodeRegistry;\n /**\n * Node engine configuration\n */\n nodeEngine?: NodeCorePluginOptions & {\n /**\n * Default formMeta\n */\n createDefaultFormMeta?: (node: FlowNodeEntity) => FormMetaOrFormMetaGenerator;\n /**\n * Enable node engine\n */\n enable?: boolean;\n };\n /**\n * By default, all nodes are expanded\n * 默认是否展开所有节点\n */\n allNodesDefaultExpanded?: boolean;\n /**\n * Canvas material, Used to customize react components\n * 画布物料, 用于自定义 react 组件\n */\n materials?: MaterialsPluginOptions;\n /**\n * 画布数据加载完成, 请使用 onAllLayersRendered 替代\n * @deprecated\n * */\n onLoad?: (ctx: CTX) => void;\n /**\n * 是否开启变量引擎\n * Variable engine enable\n */\n variableEngine?: VariablePluginOptions;\n /**\n * Redo/Undo enable\n */\n history?: HistoryPluginOptions<CTX> & { disableShortcuts?: boolean };\n\n /**\n * redux devtool configuration\n */\n reduxDevTool?: ReduxDevToolPluginOptions;\n\n /**\n * Scroll configuration\n * 滚动配置\n */\n scroll?: {\n enableScrollLimit?: boolean; // 开启滚动限制\n disableScrollBar?: boolean; // 关闭滚动条\n disableScroll?: boolean; // 禁止滚动\n };\n\n /**\n * Node data transformation, called by ctx.document.fromJSON\n * 节点数据转换, 由 ctx.document.fromJSON 调用\n * @param node - current node\n * @param json - Current node json data\n */\n toNodeJSON?(node: FlowNodeEntity, json: FlowNodeJSON): FlowNodeJSON;\n /**\n * Node data transformation, called by ctx.document.toJSON\n * 节点数据转换, 由 ctx.document.toJSON 调用\n * @param node - current node\n * @param json - Current node json data\n * @param isFirstCreate - Whether it is created for the first time, If document.fromJSON is recalled, but the node already exists, isFirstCreate is false\n */\n fromNodeJSON?(node: FlowNodeEntity, json: FlowNodeJSON, isFirstCreate: boolean): FlowNodeJSON;\n /**\n * Canvas internal constant customization\n * 画布内部常量自定义\n */\n constants?: Record<string, any>;\n /**\n * i18n\n * 国际化\n */\n i18n?: I18nPluginOptions;\n}\n\nexport namespace EditorProps {\n /**\n * 默认配置\n */\n export const DEFAULT: EditorProps = {\n background: {},\n };\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { interfaces } from 'inversify';\nimport { FlowNodeScope, getNodePrivateScope, getNodeScope } from '@flowgram.ai/variable-plugin';\nimport { FlowRendererContainerModule, FlowRendererRegistry } from '@flowgram.ai/renderer';\nimport { createReduxDevToolPlugin } from '@flowgram.ai/redux-devtool-plugin';\nimport { createNodeVariablePlugin } from '@flowgram.ai/node-variable-plugin';\nimport { createNodeCorePlugin } from '@flowgram.ai/node-core-plugin';\nimport { getNodeForm, NodeFormProps } from '@flowgram.ai/node';\nimport { createMaterialsPlugin } from '@flowgram.ai/materials-plugin';\nimport { createI18nPlugin } from '@flowgram.ai/i18n-plugin';\nimport { createHistoryNodePlugin } from '@flowgram.ai/history-node-plugin';\nimport { FlowDocumentContainerModule } from '@flowgram.ai/document';\nimport { createPlaygroundPlugin, Plugin, PluginsProvider } from '@flowgram.ai/core';\n\nimport { createFlowEditorClientPlugins } from '../clients/flow-editor-client-plugins';\nimport { EditorPluginContext, EditorProps } from './editor-props';\n\nexport function createDefaultPreset<CTX extends EditorPluginContext = EditorPluginContext>(\n opts: EditorProps<CTX>,\n plugins: Plugin[] = []\n): PluginsProvider<CTX> {\n return (ctx: CTX) => {\n opts = { ...EditorProps.DEFAULT, ...opts };\n /**\n * i18n support\n */\n if (opts.i18n) {\n plugins.push(createI18nPlugin(opts.i18n));\n }\n /**\n * 默认注册顶层 flow editor client plugin\n */\n plugins.push(...createFlowEditorClientPlugins());\n\n /**\n * 注册 Redux 开发者工具\n */\n if (opts.reduxDevTool?.enable) {\n plugins.push(createReduxDevToolPlugin(opts.reduxDevTool));\n }\n\n /**\n * 注册画布模块\n */\n const defaultContainerModules: interfaces.ContainerModule[] = [\n FlowDocumentContainerModule, // 默认文档\n FlowRendererContainerModule, // 默认渲染\n ];\n /**\n * 注册物料\n */\n plugins.push(createMaterialsPlugin(opts.materials || {}));\n\n /**\n * 注册节点引擎\n */\n if (opts.nodeEngine && opts.nodeEngine.enable !== false) {\n plugins.push(createNodeCorePlugin({ materials: opts.nodeEngine.materials }));\n\n if (opts.variableEngine?.enable) {\n plugins.push(createNodeVariablePlugin({}));\n }\n\n if (opts.history?.enable) {\n plugins.push(createHistoryNodePlugin({}));\n }\n }\n /**\n * 画布生命周期注册\n */\n plugins.push(\n createPlaygroundPlugin<CTX>({\n onInit: (ctx) => {\n if (opts.nodeRegistries) {\n ctx.document.registerFlowNodes(...opts.nodeRegistries);\n }\n // 自定义画布内部常量\n if (opts.constants) {\n ctx.document.options.constants = opts.constants;\n }\n if (opts.getNodeDefaultRegistry) {\n ctx.document.options.getNodeDefaultRegistry = opts.getNodeDefaultRegistry;\n }\n // TODO\n // if (opts.onContentChange) {\n // ctx.document.onContentChange(event => opts.onContentChange!(ctx, event));\n // }\n // TODO 这个会触发组件注册,后续要废弃这个,通过 materials 插件来做\n ctx.get<FlowRendererRegistry>(FlowRendererRegistry).init();\n\n ctx.document.onNodeCreate(({ node }) => {\n /**\n * Define node.form\n */\n if (opts.nodeEngine && opts.nodeEngine.enable !== false) {\n let cache: NodeFormProps<any> | undefined;\n Object.defineProperty(node, 'form', {\n get: () => {\n if (cache) return cache;\n cache = getNodeForm(node);\n return cache;\n },\n });\n }\n\n /**\n * Define node.scope & node.privateScope\n */\n if (opts.variableEngine && opts.variableEngine.enable !== false) {\n let cache: FlowNodeScope | undefined;\n let privateCache: FlowNodeScope | undefined;\n\n Object.defineProperty(node, 'scope', {\n get: () => {\n if (cache) return cache;\n cache = getNodeScope(node);\n return cache;\n },\n });\n Object.defineProperty(node, 'privateScope', {\n get: () => {\n if (privateCache) return privateCache;\n privateCache = getNodePrivateScope(node);\n return privateCache;\n },\n });\n }\n });\n },\n onReady(ctx) {\n if (opts.initialData) {\n ctx.document.fromJSON(opts.initialData);\n }\n if (opts.readonly) {\n ctx.playground.config.readonly = opts.readonly;\n }\n ctx.document.load().then(() => {\n if (opts.onLoad) opts.onLoad(ctx);\n });\n },\n onDispose(ctx) {\n ctx.document.dispose();\n },\n containerModules: defaultContainerModules,\n })\n );\n\n return plugins;\n };\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { definePluginCreator } from '@flowgram.ai/core';\n\nimport { createNodeClientPlugins } from './node-client/create-node-client-plugins';\nimport { FlowEditorClient } from './flow-editor-client';\n\nexport const createFlowEditorClientPlugin = definePluginCreator<{}>({\n onBind({ bind }) {\n bind(FlowEditorClient).toSelf().inSingletonScope();\n },\n});\n\nexport const createFlowEditorClientPlugins = () => [\n ...createNodeClientPlugins(),\n createFlowEditorClientPlugin({}),\n];\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { definePluginCreator } from '@flowgram.ai/core';\n\nimport { NodeFocusService } from './node-focus-service';\nimport { NodeClient } from './node-client';\nimport { createNodeHighlightPlugin } from './highlight/create-node-highlight-plugin';\n\nexport const createNodeClientPlugin = definePluginCreator<{}>({\n onBind({ bind }) {\n bind(NodeFocusService).toSelf().inSingletonScope();\n bind(NodeClient).toSelf().inSingletonScope();\n },\n});\n\nexport const createNodeClientPlugins = () => [\n createNodeHighlightPlugin({}),\n createNodeClientPlugin({}),\n];\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { injectable, inject } from 'inversify';\nimport { type FormItem } from '@flowgram.ai/form-core';\nimport { Playground, PlaygroundConfigRevealOpts } from '@flowgram.ai/core';\n\nimport { highlightFormItem, HighLightOptions } from './highlight';\n\nexport type FocusNodeCanvasOptions = PlaygroundConfigRevealOpts;\n\nexport interface FocusNodeFormItemOptions {\n canvas?: FocusNodeCanvasOptions;\n highlight?: boolean | HighLightOptions;\n}\n\n@injectable()\nexport class NodeFocusService {\n @inject(Playground) readonly playground: Playground;\n\n protected previousOverlay: HTMLDivElement | undefined;\n\n protected currentPromise: Promise<void> | undefined;\n\n highlightNodeFormItem(formItem: FormItem, options?: HighLightOptions) {\n this.previousOverlay = highlightFormItem(formItem, options);\n }\n\n focusNodeFormItem(formItem: FormItem, options?: FocusNodeFormItemOptions): Promise<void> {\n const node = formItem.formModel.flowNodeEntity;\n const { canvas = {}, highlight } = options || {};\n if (this.previousOverlay) {\n this.previousOverlay.remove();\n this.previousOverlay = undefined;\n }\n const currentPromise = this.playground\n .scrollToView({ entities: [node], scrollToCenter: true, ...canvas })\n .then(() => {\n if (!formItem || !highlight || this.currentPromise !== currentPromise) {\n return;\n }\n this.highlightNodeFormItem(formItem, typeof highlight === 'boolean' ? {} : highlight);\n });\n this.currentPromise = currentPromise;\n return this.currentPromise;\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { FormItem } from '@flowgram.ai/form-core';\nimport { FlowNodeRenderData } from '@flowgram.ai/document';\n\nimport { HIGHLIGHT_CLASSNAME } from './highlight-style';\nimport { DEFAULT_HIGHLIGHT_PADDING } from './constants';\n\nexport interface HighLightOptions {\n padding?: number;\n overlayClassName?: string;\n}\n\nexport function highlightFormItem(\n formItem: FormItem,\n options?: HighLightOptions,\n): HTMLDivElement | undefined {\n const parent =\n formItem.formModel.flowNodeEntity.getData<FlowNodeRenderData>(FlowNodeRenderData).node;\n const target = formItem.domRef.current;\n\n if (!target) {\n return undefined;\n }\n\n const overlay = document.createElement('div');\n\n const { padding = DEFAULT_HIGHLIGHT_PADDING, overlayClassName } = options || {};\n\n overlay.style.position = 'absolute';\n overlay.style.top = '0';\n overlay.style.left = '0';\n overlay.style.width = '100%';\n overlay.style.height = '100%';\n overlay.style.zIndex = '9999';\n\n parent.appendChild(overlay);\n\n const parentRect = parent.getBoundingClientRect();\n const targetRect = target.getBoundingClientRect();\n\n overlay.style.top = targetRect.top - parentRect.top - padding + 'px';\n overlay.style.left = targetRect.left - parentRect.left - padding + 'px';\n overlay.style.width = targetRect.width + padding * 2 + 'px';\n overlay.style.height = targetRect.height + padding * 2 + 'px';\n\n overlay.className = overlayClassName || HIGHLIGHT_CLASSNAME;\n setTimeout(() => {\n overlay.remove();\n }, 2000);\n return overlay;\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nexport const HIGHLIGHT_CLASSNAME = 'flowide-highlight';\n\nconst styleText = `\n@keyframes flowide-fade {\n from {\n opacity: 1.0;\n }\n to {\n opacity: 0;\n }\n}\n@-webkit-keyframes flowide-fade {\n from {\n opacity: 1.0;\n }\n to {\n opacity: 0;\n }\n}\n.${HIGHLIGHT_CLASSNAME} {\n background-color: rgba(238, 245, 40, 0.5);\n animation: flowide-fade 2s 1 forwards;\n -webkit-animation: flowide-fade 2s 1 forwards;\n}\n`;\n\nlet styleDom: HTMLStyleElement | undefined;\n\nexport function createHighlightStyle(): void {\n if (styleDom) return;\n styleDom = document.createElement('style');\n styleDom.innerHTML = styleText;\n document.head.appendChild(styleDom);\n}\n\nexport function removeHighlightStyle(): void {\n styleDom?.remove();\n styleDom = undefined;\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nexport const DEFAULT_HIGHLIGHT_COLOR = 'rgba(238, 245, 40, 0.5)';\nexport const DEFAULT_HIGHLIGHT_PADDING = 0;\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { useRef } from 'react';\n\nimport { FormModel } from '@flowgram.ai/form-core';\n\ninterface HighlightProps {\n form: FormModel;\n path: string;\n}\n\nexport function useHighlight(props: HighlightProps) {\n const ref = useRef<any>(null);\n const { form, path } = props;\n const formItem = form.getFormItemByPath(path);\n if (!formItem) {\n return null;\n }\n formItem.domRef = ref;\n return ref;\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { injectable, inject } from 'inversify';\n\nimport { NodeFocusService } from './node-focus-service';\n\n@injectable()\nexport class NodeClient {\n @inject(NodeFocusService) nodeFocusService: NodeFocusService;\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { definePluginCreator } from '@flowgram.ai/core';\n\nimport { createHighlightStyle, removeHighlightStyle } from './highlight-style';\n\nexport const createNodeHighlightPlugin = definePluginCreator<{}>({\n onInit() {\n createHighlightStyle();\n },\n onDispose() {\n removeHighlightStyle();\n },\n});\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { injectable, inject } from 'inversify';\nimport { type FormItem } from '@flowgram.ai/form-core';\nimport { FlowNodeEntity } from '@flowgram.ai/document';\nimport { Playground, PlaygroundConfigRevealOpts } from '@flowgram.ai/core';\n\nimport { FocusNodeFormItemOptions, NodeClient } from './node-client';\n\ninterface FocusNodeOptions {\n zoom?: PlaygroundConfigRevealOpts['zoom'];\n easing?: PlaygroundConfigRevealOpts['easing']; // 是否开启缓动,默认开启\n easingDuration?: PlaygroundConfigRevealOpts['easingDuration']; // 默认 500 ms\n scrollToCenter?: PlaygroundConfigRevealOpts['scrollToCenter']; // 是否滚动到中心\n}\n\n@injectable()\nexport class FlowEditorClient {\n @inject(NodeClient) readonly nodeClient: NodeClient;\n\n @inject(Playground) readonly playground: Playground;\n\n focusNodeFormItem(formItem: FormItem, options?: FocusNodeFormItemOptions) {\n this.nodeClient.nodeFocusService.focusNodeFormItem(formItem, options);\n }\n\n focusNode(node: FlowNodeEntity, options?: FocusNodeOptions) {\n this.playground.scrollToView({ entities: [node], ...options });\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport React, { useMemo, useCallback } from 'react';\n\nimport { interfaces } from 'inversify';\nimport { FlowDocument } from '@flowgram.ai/document';\nimport {\n PlaygroundReactProvider,\n createPluginContextDefault,\n SelectionService,\n} from '@flowgram.ai/core';\n\nimport { EditorPluginContext, EditorProps, createDefaultPreset } from '../preset';\n\nexport const EditorProvider: React.FC<EditorProps> = (props: EditorProps) => {\n const { children, ...others } = props;\n const preset = useMemo(() => createDefaultPreset(others), []);\n const customPluginContext = useCallback(\n (container: interfaces.Container) =>\n ({\n ...createPluginContextDefault(container),\n get document(): FlowDocument {\n return container.get<FlowDocument>(FlowDocument);\n },\n get selection(): SelectionService {\n return container.get<SelectionService>(SelectionService);\n },\n } as EditorPluginContext),\n []\n );\n return (\n <PlaygroundReactProvider plugins={preset} customPluginContext={customPluginContext}>\n {children}\n </PlaygroundReactProvider>\n );\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nexport { PlaygroundReactRenderer as EditorRenderer } from '@flowgram.ai/core';\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport React from 'react';\n\nimport { EditorProps } from '../preset';\nimport { EditorRenderer } from './editor-renderer';\nimport { EditorProvider } from './editor-provider';\n\n/**\n * 画布编辑器\n * @param props\n * @constructor\n */\nexport const Editor: React.FC<EditorProps> = (props: EditorProps) => {\n const { children, ...otherProps } = props;\n return (\n <EditorProvider {...otherProps}>\n <EditorRenderer>{children}</EditorRenderer>\n </EditorProvider>\n );\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { useService } from '@flowgram.ai/core';\n\nimport { FlowEditorClient } from '../clients';\n\nexport function useFlowEditor(): FlowEditorClient {\n return useService(FlowEditorClient);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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yBAAW,gBAAgB;AACpC;;;AhB2EA,0BAAc,8CAtFd;AAwFA,8BAA4C;","names":["import_node","import_inversify","EditorProps","import_document","import_core","import_core","import_core","import_inversify","import_core","import_inversify","import_core","ctx","import_react","import_document","import_core","React","import_core","import_react","React","import_core"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowgram.ai/editor",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.17",
|
|
4
4
|
"homepage": "https://flowgram.ai/",
|
|
5
5
|
"repository": "https://github.com/bytedance/flowgram.ai",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,26 +18,26 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"inversify": "^6.0.1",
|
|
20
20
|
"reflect-metadata": "~0.2.2",
|
|
21
|
-
"@flowgram.ai/background-plugin": "0.4.
|
|
22
|
-
"@flowgram.ai/core": "0.4.
|
|
23
|
-
"@flowgram.ai/document": "0.4.
|
|
24
|
-
"@flowgram.ai/form
|
|
25
|
-
"@flowgram.ai/form": "0.4.
|
|
26
|
-
"@flowgram.ai/group-plugin": "0.4.
|
|
27
|
-
"@flowgram.ai/history": "0.4.
|
|
28
|
-
"@flowgram.ai/history-node-plugin": "0.4.
|
|
29
|
-
"@flowgram.ai/i18n-plugin": "0.4.
|
|
30
|
-
"@flowgram.ai/
|
|
31
|
-
"@flowgram.ai/node": "0.4.
|
|
32
|
-
"@flowgram.ai/
|
|
33
|
-
"@flowgram.ai/node-variable-plugin": "0.4.
|
|
34
|
-
"@flowgram.ai/
|
|
35
|
-
"@flowgram.ai/
|
|
36
|
-
"@flowgram.ai/
|
|
37
|
-
"@flowgram.ai/
|
|
38
|
-
"@flowgram.ai/
|
|
39
|
-
"@flowgram.ai/
|
|
40
|
-
"@flowgram.ai/
|
|
21
|
+
"@flowgram.ai/background-plugin": "0.4.17",
|
|
22
|
+
"@flowgram.ai/core": "0.4.17",
|
|
23
|
+
"@flowgram.ai/document": "0.4.17",
|
|
24
|
+
"@flowgram.ai/form": "0.4.17",
|
|
25
|
+
"@flowgram.ai/form-core": "0.4.17",
|
|
26
|
+
"@flowgram.ai/group-plugin": "0.4.17",
|
|
27
|
+
"@flowgram.ai/history": "0.4.17",
|
|
28
|
+
"@flowgram.ai/history-node-plugin": "0.4.17",
|
|
29
|
+
"@flowgram.ai/i18n-plugin": "0.4.17",
|
|
30
|
+
"@flowgram.ai/node-core-plugin": "0.4.17",
|
|
31
|
+
"@flowgram.ai/node": "0.4.17",
|
|
32
|
+
"@flowgram.ai/materials-plugin": "0.4.17",
|
|
33
|
+
"@flowgram.ai/node-variable-plugin": "0.4.17",
|
|
34
|
+
"@flowgram.ai/playground-react": "0.4.17",
|
|
35
|
+
"@flowgram.ai/redux-devtool-plugin": "0.4.17",
|
|
36
|
+
"@flowgram.ai/shortcuts-plugin": "0.4.17",
|
|
37
|
+
"@flowgram.ai/renderer": "0.4.17",
|
|
38
|
+
"@flowgram.ai/variable-plugin": "0.4.17",
|
|
39
|
+
"@flowgram.ai/utils": "0.4.17",
|
|
40
|
+
"@flowgram.ai/reactive": "0.4.17"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/bezier-js": "4.1.3",
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"tsup": "^8.0.1",
|
|
52
52
|
"typescript": "^5.8.3",
|
|
53
53
|
"vitest": "^3.2.4",
|
|
54
|
-
"@flowgram.ai/eslint-config": "0.4.
|
|
55
|
-
"@flowgram.ai/ts-config": "0.4.
|
|
54
|
+
"@flowgram.ai/eslint-config": "0.4.17",
|
|
55
|
+
"@flowgram.ai/ts-config": "0.4.17"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"react": ">=16.8",
|