@flowgram-vue/editor 0.2.0

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/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
4
+ Copyright (c) 2026 Crayon
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/dist/index.cjs ADDED
Binary file
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/preset/editor-props.ts","../src/clients/node-client/highlight/highlight-style.ts","../src/clients/node-client/highlight/constants.ts","../src/clients/node-client/highlight/highlight-form-item.ts","../src/clients/node-client/highlight/use-highlight.ts","../src/clients/node-client/node-focus-service.ts","../src/clients/node-client/node-client.ts","../src/clients/node-client/highlight/create-node-highlight-plugin.ts","../src/clients/node-client/create-node-client-plugins.ts","../src/clients/flow-editor-client.ts","../src/clients/flow-editor-client-plugins.ts","../src/preset/editor-default-preset.ts","../src/components/editor-provider.vue","../src/components/editor.vue","../src/hooks/use-flow-editor.ts"],"names":["EditorProps","FlowNodeRenderData","ref","NodeFocusService","inject","Playground","injectable","NodeClient","definePluginCreator","FlowEditorClient","createI18nPlugin","createReduxDevToolPlugin","FlowDocumentContainerModule","FlowRendererContainerModule","createMaterialsPlugin","createNodeCorePlugin","createNodeVariablePlugin","createHistoryNodePlugin","createPlaygroundPlugin","ctx","node","getNodeForm","getNodeScope","getNodePrivateScope","FlowRendererRegistry","createPluginContextDefault","FlowDocument","SelectionService","_createBlock","_renderSlot","_mergeProps","_withCtx","_createVNode","useService"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6IiBA;AAAA,CAAV,CAAUA,YAAAA,KAAV;AAIE,EAAMA,aAAA,OAAA,GAAuB;AAAA,IAClC,YAAY;AAAC,GACf;AAAA,CAAA,EANeA,mBAAA,KAAAA,mBAAA,GAAA,EAAA,CAAA,CAAA;;;ACxIV,IAAM,mBAAA,GAAsB,mBAAA;AAEnC,IAAM,SAAA,GAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA,EAiBf,mBAAmB,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AAOtB,IAAI,QAAA;AAEG,SAAS,oBAAA,GAA6B;AAC3C,EAAA,IAAI,QAAA,EAAU;AACd,EAAA,QAAA,GAAW,QAAA,CAAS,cAAc,OAAO,CAAA;AACzC,EAAA,QAAA,CAAS,SAAA,GAAY,SAAA;AACrB,EAAA,QAAA,CAAS,IAAA,CAAK,YAAY,QAAQ,CAAA;AACpC;AAEO,SAAS,oBAAA,GAA6B;AAC3C,EAAA,QAAA,EAAU,MAAA,EAAO;AACjB,EAAA,QAAA,GAAW,MAAA;AACb;;;ACrCO,IAAM,yBAAA,GAA4B,CAAA;;;ACUlC,SAAS,iBA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,MAAM,WAAA,GAAc3B,QAAgC,IAAI,CAAA;AAExD,IAAA,QAAA,CAAa;AACX,MAAA,IAAI,UAAA,GAAa;AACf,QAAA,OAAO,YAAY,KAAA,EAAO,UAAA;AAC5B,MAAA,CAAA;AACA,MAAA,IAAI,SAAA,GAAY;AACd,QAAA,OAAO,YAAY,KAAA,EAAO,SAAA;AAC5B,MAAA,CAAA;AACA,MAAA,IAAI,QAAA,GAAW;AACb,QAAA,OAAO,YAAY,KAAA,EAAO,QAAA;AAC5B,MAAA,CAAA;AACA,MAAA,IAAI,SAAA,GAAY;AACd,QAAA,OAAO,YAAY,KAAA,EAAO,SAAA;AAC5B,MAAA,CAAA;AACA,MAAA,GAAA,GAAM,CAAC,UAAA,KAAe,WAAA,CAAY,KAAA,EAAO,IAAI,UAAU,CAAA,CAAA;AACvD,MAAA,MAAA,GAAS,CAAC,UAAA,KACR,WAAA,CAAY,OAAO,MAAA,CAAO,UAAU,KAAK,EAAC;KAC7C,CAAA;;;;;;;;;AAIC0B,EAAAA,OAAAA,aAAAA,EAAAA,EAAAA,eAAAA;AAIiB,IAAA,MAAA,CAAA,gBAAA,CAAA;AAJjB,IAAAE,cAAA,CAIiB,EAJD,GAAA,EAAI,aAAA,EAAa,EAAS,OAAA,KAAK,CAAA;AAAA,IAAA;AAAA,MAAA,OAAA,EAAAC,YAC7C,MAEiB;QAFjBC,eAAA,CAEiB,MAAA,CAAA,gBAAA,CAAA,EAAA,IAAA,EAAA;AAAA,UAAA,OAAA,EAAAD,YADf,MAAQ;YAARF,cAAAA,CAAQ,IAAA,CAAA,QAAA,SAAA;WAAA,CAAA;;;;;;;;;;;;;AC7BP,SAAS,aAAA,GAAkC;AAChD,EAAA,OAAOI,gBAAWxB,wBAAgB,CAAA;AACpC","file":"index.cjs","sourcesContent":["/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { FlowNodeScope, VariablePluginOptions } from '@flowgram-vue/variable-plugin';\nimport { ReduxDevToolPluginOptions } from '@flowgram-vue/redux-devtool-plugin';\nimport { type PlaygroundVueProps } from '@flowgram-vue/playground-vue';\nimport { NodeCorePluginOptions } from '@flowgram-vue/node-core-plugin';\nimport { type NodeFormProps } from '@flowgram-vue/node';\nimport { MaterialsPluginOptions } from '@flowgram-vue/materials-plugin';\nimport { I18nPluginOptions } from '@flowgram-vue/i18n-plugin';\nimport { HistoryPluginOptions } from '@flowgram-vue/history';\nimport { FormMetaOrFormMetaGenerator } from '@flowgram-vue/form-core';\nimport {\n FlowDocument,\n FlowDocumentJSON,\n FlowNodeEntity,\n type FlowNodeJSON,\n FlowNodeRegistry,\n FlowNodeType,\n} from '@flowgram-vue/document';\nimport { PluginContext, SelectionService } from '@flowgram-vue/core';\n\ndeclare module '@flowgram-vue/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 PlaygroundVueProps<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 Vue components\n * 画布物料, 用于自定义 Vue 组件\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\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 { FormItem } from '@flowgram-vue/form-core';\nimport { FlowNodeRenderData } from '@flowgram-vue/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\nimport { ref, type Ref } from 'vue';\nimport { FormModel, type FormItemDomRef } from '@flowgram-vue/form-core';\n\ninterface HighlightProps {\n form: FormModel;\n path: string;\n}\n\nexport function useHighlight(props: HighlightProps): Ref<HTMLElement | null> | null {\n const elRef = ref<HTMLElement | null>(null);\n const { form, path } = props;\n const formItem = form.getFormItemByPath(path);\n if (!formItem) {\n return null;\n }\n const domRef: FormItemDomRef = {\n get current() {\n return elRef.value;\n },\n set current(value) {\n elRef.value = value;\n },\n };\n formItem.domRef = domRef;\n return elRef;\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-vue/form-core';\nimport { Playground, PlaygroundConfigRevealOpts } from '@flowgram-vue/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 { 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-vue/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 { definePluginCreator } from '@flowgram-vue/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-vue/form-core';\nimport { FlowNodeEntity } from '@flowgram-vue/document';\nimport { Playground, PlaygroundConfigRevealOpts } from '@flowgram-vue/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 { definePluginCreator } from '@flowgram-vue/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 { interfaces } from 'inversify';\nimport { FlowNodeScope, getNodePrivateScope, getNodeScope } from '@flowgram-vue/variable-plugin';\nimport { FlowRendererContainerModule, FlowRendererRegistry } from '@flowgram-vue/renderer';\nimport { createReduxDevToolPlugin } from '@flowgram-vue/redux-devtool-plugin';\nimport { createNodeVariablePlugin } from '@flowgram-vue/node-variable-plugin';\nimport { createNodeCorePlugin } from '@flowgram-vue/node-core-plugin';\nimport { getNodeForm, NodeFormProps } from '@flowgram-vue/node';\nimport { createMaterialsPlugin } from '@flowgram-vue/materials-plugin';\nimport { createI18nPlugin } from '@flowgram-vue/i18n-plugin';\nimport { createHistoryNodePlugin } from '@flowgram-vue/history-node-plugin';\nimport { FlowDocumentContainerModule } from '@flowgram-vue/document';\nimport { createPlaygroundPlugin, Plugin, PluginsProvider } from '@flowgram-vue/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 && opts.history?.enableChangeNode !== false) {\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 ctx.document.options.preNodeCreate = (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 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","<script setup lang=\"ts\">\n/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\nimport { FlowDocument } from '@flowgram-vue/document';\nimport {\n PlaygroundVueProvider,\n createPluginContextDefault,\n SelectionService,\n} from '@flowgram-vue/core';\nimport type { interfaces } from 'inversify';\nimport { ref } from 'vue';\n\nimport { type EditorPluginContext, type EditorProps, createDefaultPreset } from '../preset';\n\ndefineOptions({ name: 'EditorProvider' });\n\nconst props = defineProps<EditorProps>();\nconst providerRef = ref<EditorPluginContext | null>(null);\n\nconst preset = createDefaultPreset(props);\n\nconst customPluginContext = (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\ndefineExpose({\n get playground() {\n return providerRef.value?.playground as EditorPluginContext['playground'];\n },\n get container() {\n return providerRef.value?.container as EditorPluginContext['container'];\n },\n get document() {\n return providerRef.value?.document as EditorPluginContext['document'];\n },\n get selection() {\n return providerRef.value?.selection as EditorPluginContext['selection'];\n },\n get: ((identifier) => providerRef.value?.get(identifier)) as EditorPluginContext['get'],\n getAll: ((identifier) =>\n providerRef.value?.getAll(identifier) ?? []) as EditorPluginContext['getAll'],\n});\n</script>\n\n<template>\n <PlaygroundVueProvider\n ref=\"providerRef\"\n :plugins=\"preset\"\n :custom-plugin-context=\"customPluginContext\"\n :parent-container=\"props.parentContainer\"\n >\n <slot />\n </PlaygroundVueProvider>\n</template>\n","<script setup lang=\"ts\">\n/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\nimport { ref } from 'vue';\n\nimport { type EditorPluginContext, type EditorProps } from '../preset';\nimport { EditorRenderer } from './editor-renderer';\nimport EditorProvider from './editor-provider.vue';\n\ndefineOptions({ name: 'Editor' });\n\nconst props = defineProps<EditorProps>();\nconst providerRef = ref<EditorPluginContext | null>(null);\n\ndefineExpose({\n get playground() {\n return providerRef.value?.playground as EditorPluginContext['playground'];\n },\n get container() {\n return providerRef.value?.container as EditorPluginContext['container'];\n },\n get document() {\n return providerRef.value?.document as EditorPluginContext['document'];\n },\n get selection() {\n return providerRef.value?.selection as EditorPluginContext['selection'];\n },\n get: ((identifier) => providerRef.value?.get(identifier)) as EditorPluginContext['get'],\n getAll: ((identifier) =>\n providerRef.value?.getAll(identifier) ?? []) as EditorPluginContext['getAll'],\n});\n</script>\n\n<template>\n <EditorProvider ref=\"providerRef\" v-bind=\"props\">\n <EditorRenderer>\n <slot />\n </EditorRenderer>\n </EditorProvider>\n</template>\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { useService } from '@flowgram-vue/core';\n\nimport { FlowEditorClient } from '../clients';\n\nexport function useFlowEditor(): FlowEditorClient {\n return useService(FlowEditorClient);\n}\n"]}
@@ -0,0 +1 @@
1
+ export * from '../src/index';
package/dist/index.js ADDED
Binary file
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/preset/editor-props.ts","../src/clients/node-client/highlight/highlight-style.ts","../src/clients/node-client/highlight/constants.ts","../src/clients/node-client/highlight/highlight-form-item.ts","../src/clients/node-client/highlight/use-highlight.ts","../src/clients/node-client/node-focus-service.ts","../src/clients/node-client/node-client.ts","../src/clients/node-client/highlight/create-node-highlight-plugin.ts","../src/clients/node-client/create-node-client-plugins.ts","../src/clients/flow-editor-client.ts","../src/clients/flow-editor-client-plugins.ts","../src/preset/editor-default-preset.ts","../src/components/editor-provider.vue","../src/components/editor.vue","../src/hooks/use-flow-editor.ts"],"names":["EditorProps","inject","injectable","definePluginCreator","Playground","ctx","ref","_createBlock","_renderSlot","_mergeProps","_withCtx","_createVNode"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6IO,IAAU;AAAA,CAAV,CAAUA,YAAAA,KAAV;AAIE,EAAMA,aAAA,OAAA,GAAuB;AAAA,IAClC,YAAY;AAAC,GACf;AAAA,CAAA,EANe,WAAA,KAAA,WAAA,GAAA,EAAA,CAAA,CAAA;;;ACxIV,IAAM,mBAAA,GAAsB,mBAAA;AAEnC,IAAM,SAAA,GAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA,EAiBf,mBAAmB,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AAO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AAAD,QADf,MAAQ;YAARF,UAAAA,CAAQ,IAAA,CAAA,QAAA,SAAA;WAAA,CAAA;;;;;;;;;;;;;AC7BP,SAAS,aAAA,GAAkC;AAChD,EAAA,OAAO,WAAW,gBAAgB,CAAA;AACpC","file":"index.js","sourcesContent":["/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { FlowNodeScope, VariablePluginOptions } from '@flowgram-vue/variable-plugin';\nimport { ReduxDevToolPluginOptions } from '@flowgram-vue/redux-devtool-plugin';\nimport { type PlaygroundVueProps } from '@flowgram-vue/playground-vue';\nimport { NodeCorePluginOptions } from '@flowgram-vue/node-core-plugin';\nimport { type NodeFormProps } from '@flowgram-vue/node';\nimport { MaterialsPluginOptions } from '@flowgram-vue/materials-plugin';\nimport { I18nPluginOptions } from '@flowgram-vue/i18n-plugin';\nimport { HistoryPluginOptions } from '@flowgram-vue/history';\nimport { FormMetaOrFormMetaGenerator } from '@flowgram-vue/form-core';\nimport {\n FlowDocument,\n FlowDocumentJSON,\n FlowNodeEntity,\n type FlowNodeJSON,\n FlowNodeRegistry,\n FlowNodeType,\n} from '@flowgram-vue/document';\nimport { PluginContext, SelectionService } from '@flowgram-vue/core';\n\ndeclare module '@flowgram-vue/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 PlaygroundVueProps<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 Vue components\n * 画布物料, 用于自定义 Vue 组件\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\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 { FormItem } from '@flowgram-vue/form-core';\nimport { FlowNodeRenderData } from '@flowgram-vue/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\nimport { ref, type Ref } from 'vue';\nimport { FormModel, type FormItemDomRef } from '@flowgram-vue/form-core';\n\ninterface HighlightProps {\n form: FormModel;\n path: string;\n}\n\nexport function useHighlight(props: HighlightProps): Ref<HTMLElement | null> | null {\n const elRef = ref<HTMLElement | null>(null);\n const { form, path } = props;\n const formItem = form.getFormItemByPath(path);\n if (!formItem) {\n return null;\n }\n const domRef: FormItemDomRef = {\n get current() {\n return elRef.value;\n },\n set current(value) {\n elRef.value = value;\n },\n };\n formItem.domRef = domRef;\n return elRef;\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-vue/form-core';\nimport { Playground, PlaygroundConfigRevealOpts } from '@flowgram-vue/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 { 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-vue/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 { definePluginCreator } from '@flowgram-vue/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-vue/form-core';\nimport { FlowNodeEntity } from '@flowgram-vue/document';\nimport { Playground, PlaygroundConfigRevealOpts } from '@flowgram-vue/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 { definePluginCreator } from '@flowgram-vue/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 { interfaces } from 'inversify';\nimport { FlowNodeScope, getNodePrivateScope, getNodeScope } from '@flowgram-vue/variable-plugin';\nimport { FlowRendererContainerModule, FlowRendererRegistry } from '@flowgram-vue/renderer';\nimport { createReduxDevToolPlugin } from '@flowgram-vue/redux-devtool-plugin';\nimport { createNodeVariablePlugin } from '@flowgram-vue/node-variable-plugin';\nimport { createNodeCorePlugin } from '@flowgram-vue/node-core-plugin';\nimport { getNodeForm, NodeFormProps } from '@flowgram-vue/node';\nimport { createMaterialsPlugin } from '@flowgram-vue/materials-plugin';\nimport { createI18nPlugin } from '@flowgram-vue/i18n-plugin';\nimport { createHistoryNodePlugin } from '@flowgram-vue/history-node-plugin';\nimport { FlowDocumentContainerModule } from '@flowgram-vue/document';\nimport { createPlaygroundPlugin, Plugin, PluginsProvider } from '@flowgram-vue/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 && opts.history?.enableChangeNode !== false) {\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 ctx.document.options.preNodeCreate = (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 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","<script setup lang=\"ts\">\n/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\nimport { FlowDocument } from '@flowgram-vue/document';\nimport {\n PlaygroundVueProvider,\n createPluginContextDefault,\n SelectionService,\n} from '@flowgram-vue/core';\nimport type { interfaces } from 'inversify';\nimport { ref } from 'vue';\n\nimport { type EditorPluginContext, type EditorProps, createDefaultPreset } from '../preset';\n\ndefineOptions({ name: 'EditorProvider' });\n\nconst props = defineProps<EditorProps>();\nconst providerRef = ref<EditorPluginContext | null>(null);\n\nconst preset = createDefaultPreset(props);\n\nconst customPluginContext = (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\ndefineExpose({\n get playground() {\n return providerRef.value?.playground as EditorPluginContext['playground'];\n },\n get container() {\n return providerRef.value?.container as EditorPluginContext['container'];\n },\n get document() {\n return providerRef.value?.document as EditorPluginContext['document'];\n },\n get selection() {\n return providerRef.value?.selection as EditorPluginContext['selection'];\n },\n get: ((identifier) => providerRef.value?.get(identifier)) as EditorPluginContext['get'],\n getAll: ((identifier) =>\n providerRef.value?.getAll(identifier) ?? []) as EditorPluginContext['getAll'],\n});\n</script>\n\n<template>\n <PlaygroundVueProvider\n ref=\"providerRef\"\n :plugins=\"preset\"\n :custom-plugin-context=\"customPluginContext\"\n :parent-container=\"props.parentContainer\"\n >\n <slot />\n </PlaygroundVueProvider>\n</template>\n","<script setup lang=\"ts\">\n/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\nimport { ref } from 'vue';\n\nimport { type EditorPluginContext, type EditorProps } from '../preset';\nimport { EditorRenderer } from './editor-renderer';\nimport EditorProvider from './editor-provider.vue';\n\ndefineOptions({ name: 'Editor' });\n\nconst props = defineProps<EditorProps>();\nconst providerRef = ref<EditorPluginContext | null>(null);\n\ndefineExpose({\n get playground() {\n return providerRef.value?.playground as EditorPluginContext['playground'];\n },\n get container() {\n return providerRef.value?.container as EditorPluginContext['container'];\n },\n get document() {\n return providerRef.value?.document as EditorPluginContext['document'];\n },\n get selection() {\n return providerRef.value?.selection as EditorPluginContext['selection'];\n },\n get: ((identifier) => providerRef.value?.get(identifier)) as EditorPluginContext['get'],\n getAll: ((identifier) =>\n providerRef.value?.getAll(identifier) ?? []) as EditorPluginContext['getAll'],\n});\n</script>\n\n<template>\n <EditorProvider ref=\"providerRef\" v-bind=\"props\">\n <EditorRenderer>\n <slot />\n </EditorRenderer>\n </EditorProvider>\n</template>\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { useService } from '@flowgram-vue/core';\n\nimport { FlowEditorClient } from '../clients';\n\nexport function useFlowEditor(): FlowEditorClient {\n return useService(FlowEditorClient);\n}\n"]}
package/package.json ADDED
@@ -0,0 +1,76 @@
1
+ {
2
+ "name": "@flowgram-vue/editor",
3
+ "version": "0.2.0",
4
+ "type": "module",
5
+ "license": "MIT",
6
+ "homepage": "https://flowgram.ai/",
7
+ "repository": "https://github.com/Crayon-hua/flowgram-vue",
8
+ "description": "Vue editor preset and components for FlowGram.",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "require": "./dist/index.cjs"
14
+ }
15
+ },
16
+ "main": "./dist/index.cjs",
17
+ "module": "./dist/index.js",
18
+ "types": "./dist/index.d.ts",
19
+ "files": [
20
+ "src",
21
+ "dist"
22
+ ],
23
+ "dependencies": {
24
+ "inversify": "^6.0.1",
25
+ "reflect-metadata": "~0.2.2",
26
+ "@flowgram-vue/form": "0.2.0",
27
+ "@flowgram-vue/core": "0.2.0",
28
+ "@flowgram-vue/background-plugin": "0.2.0",
29
+ "@flowgram-vue/history": "0.2.0",
30
+ "@flowgram-vue/history-node-plugin": "0.2.0",
31
+ "@flowgram-vue/materials-plugin": "0.2.0",
32
+ "@flowgram-vue/document": "0.2.0",
33
+ "@flowgram-vue/node": "0.2.0",
34
+ "@flowgram-vue/node-variable-plugin": "0.2.0",
35
+ "@flowgram-vue/form-core": "0.2.0",
36
+ "@flowgram-vue/node-core-plugin": "0.2.0",
37
+ "@flowgram-vue/playground-vue": "0.2.0",
38
+ "@flowgram-vue/i18n-plugin": "0.2.0",
39
+ "@flowgram-vue/redux-devtool-plugin": "0.2.0",
40
+ "@flowgram-vue/shortcuts-plugin": "0.2.0",
41
+ "@flowgram-vue/utils": "0.2.0",
42
+ "@flowgram-vue/renderer": "0.2.0",
43
+ "@flowgram-vue/reactive": "0.2.0",
44
+ "@flowgram-vue/variable-plugin": "0.2.0"
45
+ },
46
+ "peerDependencies": {
47
+ "vue": "^3.3.0"
48
+ },
49
+ "devDependencies": {
50
+ "@types/node": "^20",
51
+ "@vitejs/plugin-vue": "^6.0.1",
52
+ "@vitest/coverage-v8": "^3.2.4",
53
+ "@vue/test-utils": "^2.4.6",
54
+ "eslint": "^9.0.0",
55
+ "jsdom": "^26.1.0",
56
+ "typescript": "^5.8.3",
57
+ "vitest": "^3.2.4",
58
+ "vue": "^3.5.18",
59
+ "@flowgram-vue/build-config": "0.2.0",
60
+ "@flowgram-vue/ts-config": "0.2.0",
61
+ "@flowgram-vue/eslint-config": "0.2.0"
62
+ },
63
+ "publishConfig": {
64
+ "access": "public",
65
+ "registry": "https://registry.npmjs.org/"
66
+ },
67
+ "scripts": {
68
+ "build": "flowgram-build",
69
+ "test": "vitest run",
70
+ "lint": "eslint .",
71
+ "ts-check": "tsc --noEmit",
72
+ "type-check": "tsc --noEmit",
73
+ "build:fast": "flowgram-build --fast",
74
+ "build:watch": "flowgram-build --watch"
75
+ }
76
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { definePluginCreator } from '@flowgram-vue/core';
7
+
8
+ import { createNodeClientPlugins } from './node-client/create-node-client-plugins';
9
+ import { FlowEditorClient } from './flow-editor-client';
10
+
11
+ export const createFlowEditorClientPlugin = definePluginCreator<{}>({
12
+ onBind({ bind }) {
13
+ bind(FlowEditorClient).toSelf().inSingletonScope();
14
+ },
15
+ });
16
+
17
+ export const createFlowEditorClientPlugins = () => [
18
+ ...createNodeClientPlugins(),
19
+ createFlowEditorClientPlugin({}),
20
+ ];
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { injectable, inject } from 'inversify';
7
+ import { type FormItem } from '@flowgram-vue/form-core';
8
+ import { FlowNodeEntity } from '@flowgram-vue/document';
9
+ import { Playground, PlaygroundConfigRevealOpts } from '@flowgram-vue/core';
10
+
11
+ import { FocusNodeFormItemOptions, NodeClient } from './node-client';
12
+
13
+ interface FocusNodeOptions {
14
+ zoom?: PlaygroundConfigRevealOpts['zoom'];
15
+ easing?: PlaygroundConfigRevealOpts['easing']; // 是否开启缓动,默认开启
16
+ easingDuration?: PlaygroundConfigRevealOpts['easingDuration']; // 默认 500 ms
17
+ scrollToCenter?: PlaygroundConfigRevealOpts['scrollToCenter']; // 是否滚动到中心
18
+ }
19
+
20
+ @injectable()
21
+ export class FlowEditorClient {
22
+ @inject(NodeClient) readonly nodeClient: NodeClient;
23
+
24
+ @inject(Playground) readonly playground: Playground;
25
+
26
+ focusNodeFormItem(formItem: FormItem, options?: FocusNodeFormItemOptions) {
27
+ this.nodeClient.nodeFocusService.focusNodeFormItem(formItem, options);
28
+ }
29
+
30
+ focusNode(node: FlowNodeEntity, options?: FocusNodeOptions) {
31
+ this.playground.scrollToView({ entities: [node], ...options });
32
+ }
33
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ export * from './node-client';
7
+ export * from './flow-editor-client';
8
+ export * from './flow-editor-client-plugins';
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { definePluginCreator } from '@flowgram-vue/core';
7
+
8
+ import { NodeFocusService } from './node-focus-service';
9
+ import { NodeClient } from './node-client';
10
+ import { createNodeHighlightPlugin } from './highlight/create-node-highlight-plugin';
11
+
12
+ export const createNodeClientPlugin = definePluginCreator<{}>({
13
+ onBind({ bind }) {
14
+ bind(NodeFocusService).toSelf().inSingletonScope();
15
+ bind(NodeClient).toSelf().inSingletonScope();
16
+ },
17
+ });
18
+
19
+ export const createNodeClientPlugins = () => [
20
+ createNodeHighlightPlugin({}),
21
+ createNodeClientPlugin({}),
22
+ ];
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ export const DEFAULT_HIGHLIGHT_COLOR = 'rgba(238, 245, 40, 0.5)';
7
+ export const DEFAULT_HIGHLIGHT_PADDING = 0;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { definePluginCreator } from '@flowgram-vue/core';
7
+
8
+ import { createHighlightStyle, removeHighlightStyle } from './highlight-style';
9
+
10
+ export const createNodeHighlightPlugin = definePluginCreator<{}>({
11
+ onInit() {
12
+ createHighlightStyle();
13
+ },
14
+ onDispose() {
15
+ removeHighlightStyle();
16
+ },
17
+ });
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { FormItem } from '@flowgram-vue/form-core';
7
+ import { FlowNodeRenderData } from '@flowgram-vue/document';
8
+
9
+ import { HIGHLIGHT_CLASSNAME } from './highlight-style';
10
+ import { DEFAULT_HIGHLIGHT_PADDING } from './constants';
11
+
12
+ export interface HighLightOptions {
13
+ padding?: number;
14
+ overlayClassName?: string;
15
+ }
16
+
17
+ export function highlightFormItem(
18
+ formItem: FormItem,
19
+ options?: HighLightOptions,
20
+ ): HTMLDivElement | undefined {
21
+ const parent =
22
+ formItem.formModel.flowNodeEntity.getData<FlowNodeRenderData>(FlowNodeRenderData).node;
23
+ const target = formItem.domRef.current;
24
+
25
+ if (!target) {
26
+ return undefined;
27
+ }
28
+
29
+ const overlay = document.createElement('div');
30
+
31
+ const { padding = DEFAULT_HIGHLIGHT_PADDING, overlayClassName } = options || {};
32
+
33
+ overlay.style.position = 'absolute';
34
+ overlay.style.top = '0';
35
+ overlay.style.left = '0';
36
+ overlay.style.width = '100%';
37
+ overlay.style.height = '100%';
38
+ overlay.style.zIndex = '9999';
39
+
40
+ parent.appendChild(overlay);
41
+
42
+ const parentRect = parent.getBoundingClientRect();
43
+ const targetRect = target.getBoundingClientRect();
44
+
45
+ overlay.style.top = targetRect.top - parentRect.top - padding + 'px';
46
+ overlay.style.left = targetRect.left - parentRect.left - padding + 'px';
47
+ overlay.style.width = targetRect.width + padding * 2 + 'px';
48
+ overlay.style.height = targetRect.height + padding * 2 + 'px';
49
+
50
+ overlay.className = overlayClassName || HIGHLIGHT_CLASSNAME;
51
+ setTimeout(() => {
52
+ overlay.remove();
53
+ }, 2000);
54
+ return overlay;
55
+ }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ export const HIGHLIGHT_CLASSNAME = 'flowide-highlight';
7
+
8
+ const styleText = `
9
+ @keyframes flowide-fade {
10
+ from {
11
+ opacity: 1.0;
12
+ }
13
+ to {
14
+ opacity: 0;
15
+ }
16
+ }
17
+ @-webkit-keyframes flowide-fade {
18
+ from {
19
+ opacity: 1.0;
20
+ }
21
+ to {
22
+ opacity: 0;
23
+ }
24
+ }
25
+ .${HIGHLIGHT_CLASSNAME} {
26
+ background-color: rgba(238, 245, 40, 0.5);
27
+ animation: flowide-fade 2s 1 forwards;
28
+ -webkit-animation: flowide-fade 2s 1 forwards;
29
+ }
30
+ `;
31
+
32
+ let styleDom: HTMLStyleElement | undefined;
33
+
34
+ export function createHighlightStyle(): void {
35
+ if (styleDom) return;
36
+ styleDom = document.createElement('style');
37
+ styleDom.innerHTML = styleText;
38
+ document.head.appendChild(styleDom);
39
+ }
40
+
41
+ export function removeHighlightStyle(): void {
42
+ styleDom?.remove();
43
+ styleDom = undefined;
44
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ export { highlightFormItem } from './highlight-form-item';
7
+ export type { HighLightOptions } from './highlight-form-item';
8
+ export { useHighlight } from './use-highlight';
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { ref, type Ref } from 'vue';
7
+ import { FormModel, type FormItemDomRef } from '@flowgram-vue/form-core';
8
+
9
+ interface HighlightProps {
10
+ form: FormModel;
11
+ path: string;
12
+ }
13
+
14
+ export function useHighlight(props: HighlightProps): Ref<HTMLElement | null> | null {
15
+ const elRef = ref<HTMLElement | null>(null);
16
+ const { form, path } = props;
17
+ const formItem = form.getFormItemByPath(path);
18
+ if (!formItem) {
19
+ return null;
20
+ }
21
+ const domRef: FormItemDomRef = {
22
+ get current() {
23
+ return elRef.value;
24
+ },
25
+ set current(value) {
26
+ elRef.value = value;
27
+ },
28
+ };
29
+ formItem.domRef = domRef;
30
+ return elRef;
31
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ export * from './highlight';
7
+ export * from './node-client';
8
+ export * from './node-focus-service';
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { injectable, inject } from 'inversify';
7
+
8
+ import { NodeFocusService } from './node-focus-service';
9
+
10
+ @injectable()
11
+ export class NodeClient {
12
+ @inject(NodeFocusService) nodeFocusService: NodeFocusService;
13
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { injectable, inject } from 'inversify';
7
+ import { type FormItem } from '@flowgram-vue/form-core';
8
+ import { Playground, PlaygroundConfigRevealOpts } from '@flowgram-vue/core';
9
+
10
+ import { highlightFormItem, HighLightOptions } from './highlight';
11
+
12
+ export type FocusNodeCanvasOptions = PlaygroundConfigRevealOpts;
13
+
14
+ export interface FocusNodeFormItemOptions {
15
+ canvas?: FocusNodeCanvasOptions;
16
+ highlight?: boolean | HighLightOptions;
17
+ }
18
+
19
+ @injectable()
20
+ export class NodeFocusService {
21
+ @inject(Playground) readonly playground: Playground;
22
+
23
+ protected previousOverlay: HTMLDivElement | undefined;
24
+
25
+ protected currentPromise: Promise<void> | undefined;
26
+
27
+ highlightNodeFormItem(formItem: FormItem, options?: HighLightOptions) {
28
+ this.previousOverlay = highlightFormItem(formItem, options);
29
+ }
30
+
31
+ focusNodeFormItem(formItem: FormItem, options?: FocusNodeFormItemOptions): Promise<void> {
32
+ const node = formItem.formModel.flowNodeEntity;
33
+ const { canvas = {}, highlight } = options || {};
34
+ if (this.previousOverlay) {
35
+ this.previousOverlay.remove();
36
+ this.previousOverlay = undefined;
37
+ }
38
+ const currentPromise = this.playground
39
+ .scrollToView({ entities: [node], scrollToCenter: true, ...canvas })
40
+ .then(() => {
41
+ if (!formItem || !highlight || this.currentPromise !== currentPromise) {
42
+ return;
43
+ }
44
+ this.highlightNodeFormItem(formItem, typeof highlight === 'boolean' ? {} : highlight);
45
+ });
46
+ this.currentPromise = currentPromise;
47
+ return this.currentPromise;
48
+ }
49
+ }
@@ -0,0 +1,63 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+ import { FlowDocument } from '@flowgram-vue/document';
7
+ import {
8
+ PlaygroundVueProvider,
9
+ createPluginContextDefault,
10
+ SelectionService,
11
+ } from '@flowgram-vue/core';
12
+ import type { interfaces } from 'inversify';
13
+ import { ref } from 'vue';
14
+
15
+ import { type EditorPluginContext, type EditorProps, createDefaultPreset } from '../preset';
16
+
17
+ defineOptions({ name: 'EditorProvider' });
18
+
19
+ const props = defineProps<EditorProps>();
20
+ const providerRef = ref<EditorPluginContext | null>(null);
21
+
22
+ const preset = createDefaultPreset(props);
23
+
24
+ const customPluginContext = (container: interfaces.Container) =>
25
+ ({
26
+ ...createPluginContextDefault(container),
27
+ get document(): FlowDocument {
28
+ return container.get<FlowDocument>(FlowDocument);
29
+ },
30
+ get selection(): SelectionService {
31
+ return container.get<SelectionService>(SelectionService);
32
+ },
33
+ }) as EditorPluginContext;
34
+
35
+ defineExpose({
36
+ get playground() {
37
+ return providerRef.value?.playground as EditorPluginContext['playground'];
38
+ },
39
+ get container() {
40
+ return providerRef.value?.container as EditorPluginContext['container'];
41
+ },
42
+ get document() {
43
+ return providerRef.value?.document as EditorPluginContext['document'];
44
+ },
45
+ get selection() {
46
+ return providerRef.value?.selection as EditorPluginContext['selection'];
47
+ },
48
+ get: ((identifier) => providerRef.value?.get(identifier)) as EditorPluginContext['get'],
49
+ getAll: ((identifier) =>
50
+ providerRef.value?.getAll(identifier) ?? []) as EditorPluginContext['getAll'],
51
+ });
52
+ </script>
53
+
54
+ <template>
55
+ <PlaygroundVueProvider
56
+ ref="providerRef"
57
+ :plugins="preset"
58
+ :custom-plugin-context="customPluginContext"
59
+ :parent-container="props.parentContainer"
60
+ >
61
+ <slot />
62
+ </PlaygroundVueProvider>
63
+ </template>
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ export { PlaygroundVueRenderer as EditorRenderer } from '@flowgram-vue/core';
@@ -0,0 +1,42 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+ import { ref } from 'vue';
7
+
8
+ import { type EditorPluginContext, type EditorProps } from '../preset';
9
+ import { EditorRenderer } from './editor-renderer';
10
+ import EditorProvider from './editor-provider.vue';
11
+
12
+ defineOptions({ name: 'Editor' });
13
+
14
+ const props = defineProps<EditorProps>();
15
+ const providerRef = ref<EditorPluginContext | null>(null);
16
+
17
+ defineExpose({
18
+ get playground() {
19
+ return providerRef.value?.playground as EditorPluginContext['playground'];
20
+ },
21
+ get container() {
22
+ return providerRef.value?.container as EditorPluginContext['container'];
23
+ },
24
+ get document() {
25
+ return providerRef.value?.document as EditorPluginContext['document'];
26
+ },
27
+ get selection() {
28
+ return providerRef.value?.selection as EditorPluginContext['selection'];
29
+ },
30
+ get: ((identifier) => providerRef.value?.get(identifier)) as EditorPluginContext['get'],
31
+ getAll: ((identifier) =>
32
+ providerRef.value?.getAll(identifier) ?? []) as EditorPluginContext['getAll'],
33
+ });
34
+ </script>
35
+
36
+ <template>
37
+ <EditorProvider ref="providerRef" v-bind="props">
38
+ <EditorRenderer>
39
+ <slot />
40
+ </EditorRenderer>
41
+ </EditorProvider>
42
+ </template>
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ export { default as EditorProvider } from './editor-provider.vue';
7
+ export { EditorRenderer } from './editor-renderer';
8
+ export { default as Editor } from './editor.vue';
package/src/env.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ declare module '*.vue' {
7
+ import type { DefineComponent } from 'vue';
8
+ const component: DefineComponent<object, object, unknown>;
9
+ export default component;
10
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ export * from './use-flow-editor';
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { useService } from '@flowgram-vue/core';
7
+
8
+ import { FlowEditorClient } from '../clients';
9
+
10
+ export function useFlowEditor(): FlowEditorClient {
11
+ return useService(FlowEditorClient);
12
+ }
package/src/index.ts ADDED
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import 'reflect-metadata';
7
+ import { FormModelV2 } from '@flowgram-vue/node';
8
+
9
+ /* 核心 模块导出 */
10
+ export * from '@flowgram-vue/utils';
11
+ export * from '@flowgram-vue/core';
12
+ export * from '@flowgram-vue/document';
13
+ export * from '@flowgram-vue/renderer';
14
+ export * from '@flowgram-vue/variable-plugin';
15
+ export * from '@flowgram-vue/shortcuts-plugin';
16
+ export * from '@flowgram-vue/background-plugin';
17
+ export * from '@flowgram-vue/node-core-plugin';
18
+ export * from '@flowgram-vue/i18n-plugin';
19
+ export {
20
+ ReactiveState,
21
+ ReactiveBaseState,
22
+ Tracker,
23
+ useReactiveState,
24
+ useReadonlyReactiveState,
25
+ useObserve,
26
+ observe,
27
+ } from '@flowgram-vue/reactive';
28
+ export {
29
+ type interfaces,
30
+ injectable,
31
+ postConstruct,
32
+ named,
33
+ Container,
34
+ ContainerModule,
35
+ AsyncContainerModule,
36
+ inject,
37
+ multiInject,
38
+ } from 'inversify';
39
+
40
+ export { FlowNodeFormData, NodeRender, type NodeRenderProps } from '@flowgram-vue/form-core';
41
+
42
+ export type {
43
+ FormState,
44
+ FieldState,
45
+ FieldArrayRenderProps,
46
+ FieldRenderProps,
47
+ FormRenderProps,
48
+ Validate,
49
+ FormControl,
50
+ FieldName,
51
+ FieldError,
52
+ FieldWarning,
53
+ IField,
54
+ IFieldArray,
55
+ IForm,
56
+ Errors,
57
+ Warnings,
58
+ } from '@flowgram-vue/form';
59
+
60
+ export {
61
+ Form,
62
+ Field,
63
+ FieldArray,
64
+ useForm,
65
+ useField,
66
+ useCurrentField,
67
+ useCurrentFieldState,
68
+ useFieldValidate,
69
+ useWatch,
70
+ ValidateTrigger,
71
+ FeedbackLevel,
72
+ } from '@flowgram-vue/form';
73
+ export * from '@flowgram-vue/node';
74
+ export { FormModelV2 as FormModel };
75
+
76
+ /**
77
+ * 固定布局模块导出
78
+ */
79
+ export * from './preset';
80
+ export * from './components';
81
+ export * from './hooks';
82
+ export * from './clients';
83
+
84
+ /**
85
+ * Plugin 导出
86
+ */
87
+
88
+ export * from '@flowgram-vue/node-variable-plugin';
89
+
90
+ export {
91
+ createPlaygroundVuePreset,
92
+ PlaygroundVue,
93
+ PlaygroundVueContent,
94
+ type PlaygroundVueProps,
95
+ type PlaygroundRef,
96
+ } from '@flowgram-vue/playground-vue';
@@ -0,0 +1,148 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { interfaces } from 'inversify';
7
+ import { FlowNodeScope, getNodePrivateScope, getNodeScope } from '@flowgram-vue/variable-plugin';
8
+ import { FlowRendererContainerModule, FlowRendererRegistry } from '@flowgram-vue/renderer';
9
+ import { createReduxDevToolPlugin } from '@flowgram-vue/redux-devtool-plugin';
10
+ import { createNodeVariablePlugin } from '@flowgram-vue/node-variable-plugin';
11
+ import { createNodeCorePlugin } from '@flowgram-vue/node-core-plugin';
12
+ import { getNodeForm, NodeFormProps } from '@flowgram-vue/node';
13
+ import { createMaterialsPlugin } from '@flowgram-vue/materials-plugin';
14
+ import { createI18nPlugin } from '@flowgram-vue/i18n-plugin';
15
+ import { createHistoryNodePlugin } from '@flowgram-vue/history-node-plugin';
16
+ import { FlowDocumentContainerModule } from '@flowgram-vue/document';
17
+ import { createPlaygroundPlugin, Plugin, PluginsProvider } from '@flowgram-vue/core';
18
+
19
+ import { createFlowEditorClientPlugins } from '../clients/flow-editor-client-plugins';
20
+ import { EditorPluginContext, EditorProps } from './editor-props';
21
+
22
+ export function createDefaultPreset<CTX extends EditorPluginContext = EditorPluginContext>(
23
+ opts: EditorProps<CTX>,
24
+ plugins: Plugin[] = []
25
+ ): PluginsProvider<CTX> {
26
+ return (ctx: CTX) => {
27
+ opts = { ...EditorProps.DEFAULT, ...opts };
28
+ /**
29
+ * i18n support
30
+ */
31
+ if (opts.i18n) {
32
+ plugins.push(createI18nPlugin(opts.i18n));
33
+ }
34
+ /**
35
+ * 默认注册顶层 flow editor client plugin
36
+ */
37
+ plugins.push(...createFlowEditorClientPlugins());
38
+
39
+ /**
40
+ * 注册 Redux 开发者工具
41
+ */
42
+ if (opts.reduxDevTool?.enable) {
43
+ plugins.push(createReduxDevToolPlugin(opts.reduxDevTool));
44
+ }
45
+
46
+ /**
47
+ * 注册画布模块
48
+ */
49
+ const defaultContainerModules: interfaces.ContainerModule[] = [
50
+ FlowDocumentContainerModule, // 默认文档
51
+ FlowRendererContainerModule, // 默认渲染
52
+ ];
53
+ /**
54
+ * 注册物料
55
+ */
56
+ plugins.push(createMaterialsPlugin(opts.materials || {}));
57
+
58
+ /**
59
+ * 注册节点引擎
60
+ */
61
+ if (opts.nodeEngine && opts.nodeEngine.enable !== false) {
62
+ plugins.push(createNodeCorePlugin({ materials: opts.nodeEngine.materials }));
63
+
64
+ if (opts.variableEngine?.enable) {
65
+ plugins.push(createNodeVariablePlugin({}));
66
+ }
67
+
68
+ if (opts.history?.enable && opts.history?.enableChangeNode !== false) {
69
+ plugins.push(createHistoryNodePlugin({}));
70
+ }
71
+ }
72
+ /**
73
+ * 画布生命周期注册
74
+ */
75
+ plugins.push(
76
+ createPlaygroundPlugin<CTX>({
77
+ onInit: (ctx) => {
78
+ if (opts.nodeRegistries) {
79
+ ctx.document.registerFlowNodes(...opts.nodeRegistries);
80
+ }
81
+ // 自定义画布内部常量
82
+ if (opts.constants) {
83
+ ctx.document.options.constants = opts.constants;
84
+ }
85
+ if (opts.getNodeDefaultRegistry) {
86
+ ctx.document.options.getNodeDefaultRegistry = opts.getNodeDefaultRegistry;
87
+ }
88
+ ctx.document.options.preNodeCreate = (node) => {
89
+ /**
90
+ * Define node.form
91
+ */
92
+ if (opts.nodeEngine && opts.nodeEngine.enable !== false) {
93
+ let cache: NodeFormProps<any> | undefined;
94
+ Object.defineProperty(node, 'form', {
95
+ get: () => {
96
+ if (cache) return cache;
97
+ cache = getNodeForm(node);
98
+ return cache;
99
+ },
100
+ });
101
+ }
102
+
103
+ /**
104
+ * Define node.scope & node.privateScope
105
+ */
106
+ if (opts.variableEngine && opts.variableEngine.enable !== false) {
107
+ let cache: FlowNodeScope | undefined;
108
+ let privateCache: FlowNodeScope | undefined;
109
+
110
+ Object.defineProperty(node, 'scope', {
111
+ get: () => {
112
+ if (cache) return cache;
113
+ cache = getNodeScope(node);
114
+ return cache;
115
+ },
116
+ });
117
+ Object.defineProperty(node, 'privateScope', {
118
+ get: () => {
119
+ if (privateCache) return privateCache;
120
+ privateCache = getNodePrivateScope(node);
121
+ return privateCache;
122
+ },
123
+ });
124
+ }
125
+ };
126
+ ctx.get<FlowRendererRegistry>(FlowRendererRegistry).init();
127
+ },
128
+ onReady(ctx) {
129
+ if (opts.initialData) {
130
+ ctx.document.fromJSON(opts.initialData);
131
+ }
132
+ if (opts.readonly) {
133
+ ctx.playground.config.readonly = opts.readonly;
134
+ }
135
+ ctx.document.load().then(() => {
136
+ if (opts.onLoad) opts.onLoad(ctx);
137
+ });
138
+ },
139
+ onDispose(ctx) {
140
+ ctx.document.dispose();
141
+ },
142
+ containerModules: defaultContainerModules,
143
+ })
144
+ );
145
+
146
+ return plugins;
147
+ };
148
+ }
@@ -0,0 +1,149 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { FlowNodeScope, VariablePluginOptions } from '@flowgram-vue/variable-plugin';
7
+ import { ReduxDevToolPluginOptions } from '@flowgram-vue/redux-devtool-plugin';
8
+ import { type PlaygroundVueProps } from '@flowgram-vue/playground-vue';
9
+ import { NodeCorePluginOptions } from '@flowgram-vue/node-core-plugin';
10
+ import { type NodeFormProps } from '@flowgram-vue/node';
11
+ import { MaterialsPluginOptions } from '@flowgram-vue/materials-plugin';
12
+ import { I18nPluginOptions } from '@flowgram-vue/i18n-plugin';
13
+ import { HistoryPluginOptions } from '@flowgram-vue/history';
14
+ import { FormMetaOrFormMetaGenerator } from '@flowgram-vue/form-core';
15
+ import {
16
+ FlowDocument,
17
+ FlowDocumentJSON,
18
+ FlowNodeEntity,
19
+ type FlowNodeJSON,
20
+ FlowNodeRegistry,
21
+ FlowNodeType,
22
+ } from '@flowgram-vue/document';
23
+ import { PluginContext, SelectionService } from '@flowgram-vue/core';
24
+
25
+ declare module '@flowgram-vue/document' {
26
+ interface FlowNodeEntity {
27
+ form: NodeFormProps<any> | undefined;
28
+ scope: FlowNodeScope | undefined;
29
+ privateScope: FlowNodeScope | undefined;
30
+ }
31
+ }
32
+
33
+ export interface EditorPluginContext extends PluginContext {
34
+ document: FlowDocument;
35
+ selection: SelectionService;
36
+ }
37
+
38
+ export interface EditorProps<
39
+ CTX extends EditorPluginContext = EditorPluginContext,
40
+ JSON = FlowDocumentJSON
41
+ > extends PlaygroundVueProps<CTX> {
42
+ /**
43
+ * Initialize data
44
+ * 初始化数据
45
+ */
46
+ initialData?: JSON;
47
+ /**
48
+ * whether it is readonly
49
+ * 是否为 readonly
50
+ */
51
+ readonly?: boolean;
52
+ /**
53
+ * node registries
54
+ * 节点定义
55
+ */
56
+ nodeRegistries?: FlowNodeRegistry[];
57
+ /**
58
+ * Get the default node registry, which will be merged with the 'nodeRegistries'
59
+ * 提供默认的节点注册,这个会和 nodeRegistries 做合并
60
+ */
61
+ getNodeDefaultRegistry?: (type: FlowNodeType) => FlowNodeRegistry;
62
+ /**
63
+ * Node engine configuration
64
+ */
65
+ nodeEngine?: NodeCorePluginOptions & {
66
+ /**
67
+ * Default formMeta
68
+ */
69
+ createDefaultFormMeta?: (node: FlowNodeEntity) => FormMetaOrFormMetaGenerator;
70
+ /**
71
+ * Enable node engine
72
+ */
73
+ enable?: boolean;
74
+ };
75
+ /**
76
+ * By default, all nodes are expanded
77
+ * 默认是否展开所有节点
78
+ */
79
+ allNodesDefaultExpanded?: boolean;
80
+ /**
81
+ * Canvas material, Used to customize Vue components
82
+ * 画布物料, 用于自定义 Vue 组件
83
+ */
84
+ materials?: MaterialsPluginOptions;
85
+ /**
86
+ * 画布数据加载完成, 请使用 onAllLayersRendered 替代
87
+ * @deprecated
88
+ * */
89
+ onLoad?: (ctx: CTX) => void;
90
+ /**
91
+ * 是否开启变量引擎
92
+ * Variable engine enable
93
+ */
94
+ variableEngine?: VariablePluginOptions;
95
+ /**
96
+ * Redo/Undo enable
97
+ */
98
+ history?: HistoryPluginOptions<CTX> & { disableShortcuts?: boolean };
99
+
100
+ /**
101
+ * redux devtool configuration
102
+ */
103
+ reduxDevTool?: ReduxDevToolPluginOptions;
104
+
105
+ /**
106
+ * Scroll configuration
107
+ * 滚动配置
108
+ */
109
+ scroll?: {
110
+ enableScrollLimit?: boolean; // 开启滚动限制
111
+ disableScrollBar?: boolean; // 关闭滚动条
112
+ disableScroll?: boolean; // 禁止滚动
113
+ };
114
+
115
+ /**
116
+ * Node data transformation, called by ctx.document.fromJSON
117
+ * 节点数据转换, 由 ctx.document.fromJSON 调用
118
+ * @param node - current node
119
+ * @param json - Current node json data
120
+ */
121
+ toNodeJSON?(node: FlowNodeEntity, json: FlowNodeJSON): FlowNodeJSON;
122
+ /**
123
+ * Node data transformation, called by ctx.document.toJSON
124
+ * 节点数据转换, 由 ctx.document.toJSON 调用
125
+ * @param node - current node
126
+ * @param json - Current node json data
127
+ * @param isFirstCreate - Whether it is created for the first time, If document.fromJSON is recalled, but the node already exists, isFirstCreate is false
128
+ */
129
+ fromNodeJSON?(node: FlowNodeEntity, json: FlowNodeJSON, isFirstCreate: boolean): FlowNodeJSON;
130
+ /**
131
+ * Canvas internal constant customization
132
+ * 画布内部常量自定义
133
+ */
134
+ constants?: Record<string, any>;
135
+ /**
136
+ * i18n
137
+ * 国际化
138
+ */
139
+ i18n?: I18nPluginOptions;
140
+ }
141
+
142
+ export namespace EditorProps {
143
+ /**
144
+ * 默认配置
145
+ */
146
+ export const DEFAULT: EditorProps = {
147
+ background: {},
148
+ };
149
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ export * from './editor-props';
7
+ export * from './editor-default-preset';