@flowgram.ai/editor 0.1.0-alpha.3 → 0.1.0-alpha.30

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 CHANGED
@@ -20,7 +20,26 @@ export * from "@flowgram.ai/variable-plugin";
20
20
  export * from "@flowgram.ai/shortcuts-plugin";
21
21
  export * from "@flowgram.ai/node-core-plugin";
22
22
  export * from "@flowgram.ai/i18n-plugin";
23
- import { FlowNodeFormData as FlowNodeFormData2, NodeRender } from "@flowgram.ai/form-core";
23
+ import {
24
+ ReactiveState,
25
+ ReactiveBaseState,
26
+ Tracker,
27
+ useReactiveState,
28
+ useReadonlyReactiveState,
29
+ useObserve,
30
+ observe
31
+ } from "@flowgram.ai/reactive";
32
+ import {
33
+ injectable as injectable4,
34
+ postConstruct,
35
+ named,
36
+ Container,
37
+ ContainerModule,
38
+ AsyncContainerModule,
39
+ inject as inject4,
40
+ multiInject
41
+ } from "inversify";
42
+ import { FlowNodeFormData, NodeRender } from "@flowgram.ai/form-core";
24
43
  import {
25
44
  Form,
26
45
  Field,
@@ -31,86 +50,32 @@ import {
31
50
  useCurrentFieldState,
32
51
  useFieldValidate,
33
52
  useWatch,
34
- ValidateTrigger
53
+ ValidateTrigger,
54
+ FeedbackLevel
35
55
  } from "@flowgram.ai/form";
36
56
  export * from "@flowgram.ai/node";
37
57
 
38
- // src/preset/editor-props.ts
39
- import { FlowNodeFormData } from "@flowgram.ai/form-core";
40
-
41
- // src/constants.ts
42
- var EditorOptions = Symbol("EditorOptions");
43
-
44
58
  // src/preset/editor-props.ts
45
59
  var EditorProps;
46
60
  ((EditorProps3) => {
47
61
  EditorProps3.DEFAULT = {
48
- background: {},
49
- fromNodeJSON(node, json) {
50
- const formData = node.getData(FlowNodeFormData);
51
- if (!formData) {
52
- if (json.data) {
53
- node.updateExtInfo(json.data);
54
- }
55
- } else {
56
- const defaultFormMeta = node.getService(EditorOptions).nodeEngine?.createDefaultFormMeta?.(node);
57
- const formMeta = node.getNodeRegistry()?.formMeta || defaultFormMeta;
58
- if (formMeta) {
59
- formData.createForm(formMeta, json.data);
60
- }
61
- }
62
- },
63
- toNodeJSON(node) {
64
- const nodesMap = {};
65
- let startNodeJSON;
66
- node.document.traverse((node2) => {
67
- const isSystemNode = node2.id.startsWith("$");
68
- if (isSystemNode) return;
69
- const formData = node2.getData(FlowNodeFormData);
70
- let formJSON = formData && formData.formModel && formData.formModel.initialized ? formData.toJSON() : void 0;
71
- const nodeJSON = {
72
- id: node2.id,
73
- type: node2.flowNodeType,
74
- data: formData ? formJSON : node2.getExtInfo(),
75
- blocks: []
76
- };
77
- if (!startNodeJSON) startNodeJSON = nodeJSON;
78
- let { parent } = node2;
79
- if (parent && parent.id.startsWith("$")) {
80
- parent = parent.originParent;
81
- }
82
- const parentJSON = parent ? nodesMap[parent.id] : void 0;
83
- if (parentJSON) {
84
- parentJSON.blocks?.push(nodeJSON);
85
- }
86
- nodesMap[node2.id] = nodeJSON;
87
- }, node);
88
- return startNodeJSON;
89
- }
62
+ background: {}
90
63
  };
91
64
  })(EditorProps || (EditorProps = {}));
92
65
 
93
66
  // src/preset/editor-default-preset.ts
67
+ import { getNodePrivateScope, getNodeScope } from "@flowgram.ai/variable-plugin";
94
68
  import { FlowRendererContainerModule, FlowRendererRegistry } from "@flowgram.ai/renderer";
95
69
  import { createReduxDevToolPlugin } from "@flowgram.ai/redux-devtool-plugin";
96
- import { createPlaygroundReactPreset } from "@flowgram.ai/playground-react";
97
70
  import { createNodeVariablePlugin } from "@flowgram.ai/node-variable-plugin";
98
71
  import { createNodeCorePlugin } from "@flowgram.ai/node-core-plugin";
72
+ import { getNodeForm } from "@flowgram.ai/node";
99
73
  import { createMaterialsPlugin } from "@flowgram.ai/materials-plugin";
100
74
  import { createI18nPlugin } from "@flowgram.ai/i18n-plugin";
101
75
  import { createHistoryNodePlugin } from "@flowgram.ai/history-node-plugin";
102
76
  import { FlowDocumentContainerModule } from "@flowgram.ai/document";
103
77
  import { createPlaygroundPlugin } from "@flowgram.ai/core";
104
78
 
105
- // src/utils/compose.ts
106
- var compose = (fnList) => (node, data) => {
107
- const list = fnList.filter(Boolean);
108
- if (!list.length) {
109
- return data;
110
- }
111
- return list.reduce((acc, fn) => fn(node, acc), data);
112
- };
113
-
114
79
  // src/clients/flow-editor-client-plugins.ts
115
80
  import { definePluginCreator as definePluginCreator3 } from "@flowgram.ai/core";
116
81
 
@@ -305,7 +270,6 @@ var createFlowEditorClientPlugins = () => [
305
270
  function createDefaultPreset(opts, plugins = []) {
306
271
  return (ctx) => {
307
272
  opts = { ...EditorProps.DEFAULT, ...opts };
308
- ctx.container.bind(EditorOptions).toConstantValue(opts);
309
273
  if (opts.i18n) {
310
274
  plugins.push(createI18nPlugin(opts.i18n));
311
275
  }
@@ -325,7 +289,7 @@ function createDefaultPreset(opts, plugins = []) {
325
289
  if (opts.variableEngine?.enable) {
326
290
  plugins.push(createNodeVariablePlugin({}));
327
291
  }
328
- if (opts.history?.enable) {
292
+ if (opts.history?.enable && opts.history?.enableChangeNode !== false) {
329
293
  plugins.push(createHistoryNodePlugin({}));
330
294
  }
331
295
  }
@@ -338,21 +302,39 @@ function createDefaultPreset(opts, plugins = []) {
338
302
  if (opts.constants) {
339
303
  ctx2.document.options.constants = opts.constants;
340
304
  }
341
- if (opts.formatNodeLines) {
342
- ctx2.document.options.formatNodeLines = compose([
343
- ctx2.document.options.formatNodeLines,
344
- opts.formatNodeLines
345
- ]);
346
- }
347
- if (opts.formatNodeLabels) {
348
- ctx2.document.options.formatNodeLabels = compose([
349
- ctx2.document.options.formatNodeLabels,
350
- opts.formatNodeLabels
351
- ]);
352
- }
353
305
  if (opts.getNodeDefaultRegistry) {
354
306
  ctx2.document.options.getNodeDefaultRegistry = opts.getNodeDefaultRegistry;
355
307
  }
308
+ ctx2.document.options.preNodeCreate = (node) => {
309
+ if (opts.nodeEngine && opts.nodeEngine.enable !== false) {
310
+ let cache;
311
+ Object.defineProperty(node, "form", {
312
+ get: () => {
313
+ if (cache) return cache;
314
+ cache = getNodeForm(node);
315
+ return cache;
316
+ }
317
+ });
318
+ }
319
+ if (opts.variableEngine && opts.variableEngine.enable !== false) {
320
+ let cache;
321
+ let privateCache;
322
+ Object.defineProperty(node, "scope", {
323
+ get: () => {
324
+ if (cache) return cache;
325
+ cache = getNodeScope(node);
326
+ return cache;
327
+ }
328
+ });
329
+ Object.defineProperty(node, "privateScope", {
330
+ get: () => {
331
+ if (privateCache) return privateCache;
332
+ privateCache = getNodePrivateScope(node);
333
+ return privateCache;
334
+ }
335
+ });
336
+ }
337
+ };
356
338
  ctx2.get(FlowRendererRegistry).init();
357
339
  },
358
340
  onReady(ctx2) {
@@ -372,7 +354,7 @@ function createDefaultPreset(opts, plugins = []) {
372
354
  containerModules: defaultContainerModules
373
355
  })
374
356
  );
375
- return createPlaygroundReactPreset(opts, plugins)(ctx);
357
+ return plugins;
376
358
  };
377
359
  }
378
360
 
@@ -420,25 +402,40 @@ function useFlowEditor() {
420
402
 
421
403
  // src/index.ts
422
404
  export * from "@flowgram.ai/node-variable-plugin";
405
+ import { createPlaygroundReactPreset } from "@flowgram.ai/playground-react";
423
406
  export {
407
+ AsyncContainerModule,
408
+ Container,
409
+ ContainerModule,
424
410
  Editor,
425
411
  EditorProps,
426
412
  EditorProvider,
427
413
  PlaygroundReactRenderer as EditorRenderer,
414
+ FeedbackLevel,
428
415
  Field,
429
416
  FieldArray,
430
417
  FlowEditorClient,
431
- FlowNodeFormData2 as FlowNodeFormData,
418
+ FlowNodeFormData,
432
419
  Form,
433
420
  FormModelV2 as FormModel,
434
421
  NodeClient,
435
422
  NodeFocusService,
436
423
  NodeRender,
424
+ ReactiveBaseState,
425
+ ReactiveState,
426
+ Tracker,
437
427
  ValidateTrigger,
438
428
  createDefaultPreset,
439
429
  createFlowEditorClientPlugin,
440
430
  createFlowEditorClientPlugins,
431
+ createPlaygroundReactPreset,
441
432
  highlightFormItem,
433
+ inject4 as inject,
434
+ injectable4 as injectable,
435
+ multiInject,
436
+ named,
437
+ observe,
438
+ postConstruct,
442
439
  useCurrentField,
443
440
  useCurrentFieldState,
444
441
  useField,
@@ -446,6 +443,9 @@ export {
446
443
  useFlowEditor,
447
444
  useForm,
448
445
  useHighlight,
446
+ useObserve,
447
+ useReactiveState,
448
+ useReadonlyReactiveState,
449
449
  useWatch
450
450
  };
451
451
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts","../../src/preset/editor-props.ts","../../src/constants.ts","../../src/preset/editor-default-preset.ts","../../src/utils/compose.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":["import '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';\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} 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","import { 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 { FlowNodeFormData, FormMetaOrFormMetaGenerator } from '@flowgram.ai/form-core';\nimport {\n FlowDocument,\n FlowDocumentJSON,\n FlowNodeEntity,\n type FlowNodeJSON,\n FlowNodeRegistry,\n FlowNodeType,\n FlowTransitionLabel,\n FlowTransitionLine,\n} from '@flowgram.ai/document';\nimport { PluginContext } from '@flowgram.ai/core';\n\nimport { EditorOptions } from '../constants';\n\nexport interface EditorPluginContext extends PluginContext {\n document: FlowDocument;\n selection: SelectionService;\n}\n\n/**\n * 固定布局配置\n */\nexport interface EditorProps<\n CTX extends EditorPluginContext = EditorPluginContext,\n JSON = FlowDocumentJSON\n> extends PlaygroundReactProps<CTX> {\n /**\n * 初始化数据\n */\n initialData?: JSON;\n /**\n * 是否为 readonly\n */\n readonly?: boolean;\n /**\n * 节点定义\n */\n nodeRegistries?: FlowNodeRegistry[];\n /**\n * 获取默认的节点配置\n */\n getNodeDefaultRegistry?: (type: FlowNodeType) => FlowNodeRegistry;\n /**\n * 节点引擎配置\n */\n nodeEngine?: NodeCorePluginOptions & {\n /**\n * 默认FormMeta\n */\n createDefaultFormMeta?: (node: FlowNodeEntity) => FormMetaOrFormMetaGenerator;\n /**\n * 开启\n */\n enable?: boolean;\n };\n /**\n * 默认是否展开所有节点\n */\n allNodesDefaultExpanded?: boolean;\n /**\n * 画布物料\n */\n materials?: MaterialsPluginOptions;\n /**\n * 画布数据加载完成, 请使用 onAllLayersRendered 替代\n * @deprecated\n * */\n onLoad?: (ctx: CTX) => void;\n /**\n * 是否开启变量引擎\n */\n variableEngine?: VariablePluginOptions;\n /**\n * 是否开启历史\n */\n history?: HistoryPluginOptions<CTX> & { disableShortcuts?: boolean };\n\n /**\n * redux 开发者工具配置\n */\n reduxDevTool?: ReduxDevToolPluginOptions;\n\n scroll?: {\n disableScrollLimit?: boolean; // 关闭滚动限制\n disableScrollBar?: boolean; // 关闭滚动条\n };\n\n /**\n * 节点转\n * @param node\n */\n toNodeJSON?(node: FlowNodeEntity): FlowNodeJSON;\n fromNodeJSON?(node: FlowNodeEntity, json: FlowNodeJSON): void;\n\n /**\n * 画布内部常量自定义\n */\n constants?: Record<string, any>;\n /**\n * 自定义节点线条\n */\n formatNodeLines?: (node: FlowNodeEntity, lines: FlowTransitionLine[]) => FlowTransitionLine[];\n /**\n * 自定义节点 label\n */\n formatNodeLabels?: (node: FlowNodeEntity, lines: FlowTransitionLabel[]) => FlowTransitionLabel[];\n /**\n * 国际化\n */\n i18n?: I18nPluginOptions;\n}\n\nexport namespace EditorProps {\n /**\n * 默认配置\n */\n export const DEFAULT: EditorProps = {\n background: {},\n fromNodeJSON(node: FlowNodeEntity, json: FlowNodeJSON) {\n const formData = node.getData(FlowNodeFormData)!;\n // 如果没有使用表单引擎,将 data 数据填入 extInfo\n if (!formData) {\n if (json.data) {\n node.updateExtInfo(json.data);\n }\n } else {\n const defaultFormMeta = node\n .getService<EditorProps>(EditorOptions)\n .nodeEngine?.createDefaultFormMeta?.(node);\n\n const formMeta = node.getNodeRegistry()?.formMeta || defaultFormMeta;\n\n if (formMeta) {\n formData.createForm(formMeta, json.data);\n }\n }\n },\n toNodeJSON(node: FlowNodeEntity): FlowNodeJSON {\n const nodesMap: Record<string, FlowNodeJSON> = {};\n let startNodeJSON: FlowNodeJSON;\n node.document.traverse((node) => {\n const isSystemNode = node.id.startsWith('$');\n if (isSystemNode) return;\n const formData = node.getData(FlowNodeFormData);\n let formJSON =\n formData && formData.formModel && formData.formModel.initialized\n ? formData.toJSON()\n : undefined;\n const nodeJSON = {\n id: node.id,\n type: node.flowNodeType,\n data: formData ? formJSON : node.getExtInfo(),\n blocks: [],\n };\n if (!startNodeJSON) startNodeJSON = nodeJSON;\n let { parent } = node;\n if (parent && parent.id.startsWith('$')) {\n parent = parent.originParent;\n }\n const parentJSON = parent ? nodesMap[parent.id] : undefined;\n if (parentJSON) {\n parentJSON.blocks?.push(nodeJSON);\n }\n nodesMap[node.id] = nodeJSON;\n }, node);\n return startNodeJSON!;\n },\n };\n}\n","export const EditorOptions = Symbol('EditorOptions');\n","import { interfaces } from 'inversify';\nimport { FlowRendererContainerModule, FlowRendererRegistry } from '@flowgram.ai/renderer';\nimport { createReduxDevToolPlugin } from '@flowgram.ai/redux-devtool-plugin';\nimport { createPlaygroundReactPreset } from '@flowgram.ai/playground-react';\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 { compose } from '../utils/compose';\nimport { EditorOptions } from '../constants';\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 ctx.container.bind(EditorOptions).toConstantValue(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 // 劫持节点线条\n if (opts.formatNodeLines) {\n ctx.document.options.formatNodeLines = compose([\n ctx.document.options.formatNodeLines,\n opts.formatNodeLines,\n ]);\n }\n // 劫持节点 label\n if (opts.formatNodeLabels) {\n ctx.document.options.formatNodeLabels = compose([\n ctx.document.options.formatNodeLabels,\n opts.formatNodeLabels,\n ]);\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 createPlaygroundReactPreset<CTX>(opts, plugins)(ctx);\n };\n}\n","import { FlowNodeEntity } from '@flowgram.ai/document';\n\nexport type ComposeListItem<T> = (node: FlowNodeEntity, data: T[]) => T[];\n\nexport const compose =\n <T>(fnList: (ComposeListItem<T> | undefined)[]) =>\n (node: FlowNodeEntity, data: T[]): T[] => {\n const list = fnList.filter(Boolean) as ComposeListItem<T>[];\n if (!list.length) {\n return data;\n }\n return list.reduce((acc: T[], fn) => fn(node, acc), data);\n };\n","import { 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","import { 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","import { 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","import { 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","export 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","export const DEFAULT_HIGHLIGHT_COLOR = 'rgba(238, 245, 40, 0.5)';\nexport const DEFAULT_HIGHLIGHT_PADDING = 0;\n","import { 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","import { injectable, inject } from 'inversify';\n\nimport { NodeFocusService } from './node-focus-service';\n\n@injectable()\nexport class NodeClient {\n @inject(NodeFocusService) nodeFocusService: NodeFocusService;\n}\n","import { 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","import { 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","import 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","export { PlaygroundReactRenderer as EditorRenderer } from '@flowgram.ai/core';\n","import 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","import { useService } from '@flowgram.ai/core';\n\nimport { FlowEditorClient } from '../clients';\n\nexport function useFlowEditor(): FlowEditorClient {\n return useService(FlowEditorClient);\n}\n"],"mappings":";;;;;;;;;;;;AAAA,OAAO;AACP,SAAS,mBAAmB;AAG5B,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,SAAS,oBAAAA,mBAAkB,kBAAwC;AAoBnE;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,cAAc;;;ACtCd,SAAS,wBAAqD;;;ACPvD,IAAM,gBAAgB,OAAO,eAAe;;;ADwH5C,IAAU;AAAA,CAAV,CAAUC,iBAAV;AAIE,EAAMA,aAAA,UAAuB;AAAA,IAClC,YAAY,CAAC;AAAA,IACb,aAAa,MAAsB,MAAoB;AACrD,YAAM,WAAW,KAAK,QAAQ,gBAAgB;AAE9C,UAAI,CAAC,UAAU;AACb,YAAI,KAAK,MAAM;AACb,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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;;;AlBsDA,cAAc;","names":["FlowNodeFormData","EditorProps","node","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 && 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","/**\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,EACA;AAAA,EACA;AAAA,EACA,UAAAC;AAAA,EACA;AAAA,OACK;AAEP,SAAS,kBAAkB,kBAAwC;AAoBnE;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,cAAc;;;ACsEP,IAAU;AAAA,C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;AAAA,QACA,UAAUA,MAAK;AACb,UAAAA,KAAI,SAAS,QAAQ;AAAA,QACvB;AAAA,QACA,kBAAkB;AAAA,MACpB,CAAC;AAAA,IACH;AAEA,WAAO;AAAA,EACT;AACF;;;AW9IA,OAAO,SAAS,SAAS,mBAAmB;AAG5C,SAAS,oBAAoB;AAC7B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAIA,IAAM,iBAAwC,CAAC,UAAuB;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"]}
package/dist/index.d.mts CHANGED
@@ -1,74 +1,93 @@
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';
4
5
  import * as _flowgram_ai_core from '@flowgram.ai/core';
5
- import { PluginContext, Plugin, PluginsProvider, PlaygroundConfigRevealOpts, Playground } from '@flowgram.ai/core';
6
+ import { PluginContext, Plugin, PluginsProvider, Playground, PlaygroundConfigRevealOpts } from '@flowgram.ai/core';
6
7
  export * from '@flowgram.ai/core';
7
8
  export { PlaygroundReactRenderer as EditorRenderer } from '@flowgram.ai/core';
8
- import { FlowDocument, FlowDocumentJSON, FlowNodeRegistry, FlowNodeType, FlowNodeEntity, FlowNodeJSON, FlowTransitionLine, FlowTransitionLabel } from '@flowgram.ai/document';
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';
15
16
  export * from '@flowgram.ai/node-core-plugin';
16
17
  import { I18nPluginOptions } from '@flowgram.ai/i18n-plugin';
17
18
  export * from '@flowgram.ai/i18n-plugin';
19
+ export { ReactiveBaseState, ReactiveState, Tracker, observe, useObserve, useReactiveState, useReadonlyReactiveState } from '@flowgram.ai/reactive';
20
+ export { AsyncContainerModule, Container, ContainerModule, inject, injectable, interfaces, multiInject, named, postConstruct } from 'inversify';
18
21
  import { FormMetaOrFormMetaGenerator, FormItem, FormModel } from '@flowgram.ai/form-core';
19
22
  export { FlowNodeFormData, NodeRender, NodeRenderProps } from '@flowgram.ai/form-core';
20
- export { Errors, Field, FieldArray, FieldArrayRenderProps, FieldError, FieldName, FieldRenderProps, FieldState, FieldWarning, Form, FormControl, FormRenderProps, FormState, IField, IFieldArray, IForm, Validate, ValidateTrigger, Warnings, useCurrentField, useCurrentFieldState, useField, useFieldValidate, useForm, useWatch } from '@flowgram.ai/form';
23
+ export { Errors, FeedbackLevel, Field, FieldArray, FieldArrayRenderProps, FieldError, FieldName, FieldRenderProps, FieldState, FieldWarning, Form, FormControl, FormRenderProps, FormState, IField, IFieldArray, IForm, Validate, ValidateTrigger, Warnings, useCurrentField, useCurrentFieldState, useField, useFieldValidate, useForm, useWatch } from '@flowgram.ai/form';
21
24
  import { ReduxDevToolPluginOptions } from '@flowgram.ai/redux-devtool-plugin';
22
25
  import { SelectionService, PlaygroundReactProps } from '@flowgram.ai/playground-react';
26
+ export { createPlaygroundReactPreset } from '@flowgram.ai/playground-react';
23
27
  import { MaterialsPluginOptions } from '@flowgram.ai/materials-plugin';
24
28
  import { HistoryPluginOptions } from '@flowgram.ai/history';
25
29
  import * as React from 'react';
26
30
  import React__default from 'react';
27
31
  export * from '@flowgram.ai/node-variable-plugin';
28
32
 
33
+ /**
34
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
35
+ * SPDX-License-Identifier: MIT
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
+ }
29
45
  interface EditorPluginContext extends PluginContext {
30
46
  document: FlowDocument;
31
47
  selection: SelectionService;
32
48
  }
33
- /**
34
- * 固定布局配置
35
- */
36
49
  interface EditorProps<CTX extends EditorPluginContext = EditorPluginContext, JSON = FlowDocumentJSON> extends PlaygroundReactProps<CTX> {
37
50
  /**
51
+ * Initialize data
38
52
  * 初始化数据
39
53
  */
40
54
  initialData?: JSON;
41
55
  /**
56
+ * whether it is readonly
42
57
  * 是否为 readonly
43
58
  */
44
59
  readonly?: boolean;
45
60
  /**
61
+ * node registries
46
62
  * 节点定义
47
63
  */
48
64
  nodeRegistries?: FlowNodeRegistry[];
49
65
  /**
50
- * 获取默认的节点配置
66
+ * Get the default node registry, which will be merged with the 'nodeRegistries'
67
+ * 提供默认的节点注册,这个会和 nodeRegistries 做合并
51
68
  */
52
69
  getNodeDefaultRegistry?: (type: FlowNodeType) => FlowNodeRegistry;
53
70
  /**
54
- * 节点引擎配置
71
+ * Node engine configuration
55
72
  */
56
73
  nodeEngine?: NodeCorePluginOptions & {
57
74
  /**
58
- * 默认FormMeta
75
+ * Default formMeta
59
76
  */
60
77
  createDefaultFormMeta?: (node: FlowNodeEntity) => FormMetaOrFormMetaGenerator;
61
78
  /**
62
- * 开启
79
+ * Enable node engine
63
80
  */
64
81
  enable?: boolean;
65
82
  };
66
83
  /**
84
+ * By default, all nodes are expanded
67
85
  * 默认是否展开所有节点
68
86
  */
69
87
  allNodesDefaultExpanded?: boolean;
70
88
  /**
71
- * 画布物料
89
+ * Canvas material, Used to customize react components
90
+ * 画布物料, 用于自定义 react 组件
72
91
  */
73
92
  materials?: MaterialsPluginOptions;
74
93
  /**
@@ -78,41 +97,50 @@ interface EditorProps<CTX extends EditorPluginContext = EditorPluginContext, JSO
78
97
  onLoad?: (ctx: CTX) => void;
79
98
  /**
80
99
  * 是否开启变量引擎
100
+ * Variable engine enable
81
101
  */
82
102
  variableEngine?: VariablePluginOptions;
83
103
  /**
84
- * 是否开启历史
104
+ * Redo/Undo enable
85
105
  */
86
106
  history?: HistoryPluginOptions<CTX> & {
87
107
  disableShortcuts?: boolean;
88
108
  };
89
109
  /**
90
- * redux 开发者工具配置
110
+ * redux devtool configuration
91
111
  */
92
112
  reduxDevTool?: ReduxDevToolPluginOptions;
113
+ /**
114
+ * Scroll configuration
115
+ * 滚动配置
116
+ */
93
117
  scroll?: {
94
- disableScrollLimit?: boolean;
118
+ enableScrollLimit?: boolean;
95
119
  disableScrollBar?: boolean;
120
+ disableScroll?: boolean;
96
121
  };
97
122
  /**
98
- * 节点转
99
- * @param node
100
- */
101
- toNodeJSON?(node: FlowNodeEntity): FlowNodeJSON;
102
- fromNodeJSON?(node: FlowNodeEntity, json: FlowNodeJSON): void;
103
- /**
104
- * 画布内部常量自定义
123
+ * Node data transformation, called by ctx.document.fromJSON
124
+ * 节点数据转换, 由 ctx.document.fromJSON 调用
125
+ * @param node - current node
126
+ * @param json - Current node json data
105
127
  */
106
- constants?: Record<string, any>;
128
+ toNodeJSON?(node: FlowNodeEntity, json: FlowNodeJSON): FlowNodeJSON;
107
129
  /**
108
- * 自定义节点线条
130
+ * Node data transformation, called by ctx.document.toJSON
131
+ * 节点数据转换, 由 ctx.document.toJSON 调用
132
+ * @param node - current node
133
+ * @param json - Current node json data
134
+ * @param isFirstCreate - Whether it is created for the first time, If document.fromJSON is recalled, but the node already exists, isFirstCreate is false
109
135
  */
110
- formatNodeLines?: (node: FlowNodeEntity, lines: FlowTransitionLine[]) => FlowTransitionLine[];
136
+ fromNodeJSON?(node: FlowNodeEntity, json: FlowNodeJSON, isFirstCreate: boolean): FlowNodeJSON;
111
137
  /**
112
- * 自定义节点 label
138
+ * Canvas internal constant customization
139
+ * 画布内部常量自定义
113
140
  */
114
- formatNodeLabels?: (node: FlowNodeEntity, lines: FlowTransitionLabel[]) => FlowTransitionLabel[];
141
+ constants?: Record<string, any>;
115
142
  /**
143
+ * i18n
116
144
  * 国际化
117
145
  */
118
146
  i18n?: I18nPluginOptions;
@@ -124,10 +152,25 @@ declare namespace EditorProps {
124
152
  const DEFAULT: EditorProps;
125
153
  }
126
154
 
155
+ /**
156
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
157
+ * SPDX-License-Identifier: MIT
158
+ */
159
+
127
160
  declare function createDefaultPreset<CTX extends EditorPluginContext = EditorPluginContext>(opts: EditorProps<CTX>, plugins?: Plugin[]): PluginsProvider<CTX>;
128
161
 
162
+ /**
163
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
164
+ * SPDX-License-Identifier: MIT
165
+ */
166
+
129
167
  declare const EditorProvider: React__default.FC<EditorProps>;
130
168
 
169
+ /**
170
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
171
+ * SPDX-License-Identifier: MIT
172
+ */
173
+
131
174
  /**
132
175
  * 画布编辑器
133
176
  * @param props
@@ -135,6 +178,11 @@ declare const EditorProvider: React__default.FC<EditorProps>;
135
178
  */
136
179
  declare const Editor: React__default.FC<EditorProps>;
137
180
 
181
+ /**
182
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
183
+ * SPDX-License-Identifier: MIT
184
+ */
185
+
138
186
  interface HighLightOptions {
139
187
  padding?: number;
140
188
  overlayClassName?: string;
@@ -147,6 +195,11 @@ interface HighlightProps {
147
195
  }
148
196
  declare function useHighlight(props: HighlightProps): React.MutableRefObject<any> | null;
149
197
 
198
+ /**
199
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
200
+ * SPDX-License-Identifier: MIT
201
+ */
202
+
150
203
  type FocusNodeCanvasOptions = PlaygroundConfigRevealOpts;
151
204
  interface FocusNodeFormItemOptions {
152
205
  canvas?: FocusNodeCanvasOptions;
@@ -160,10 +213,20 @@ declare class NodeFocusService {
160
213
  focusNodeFormItem(formItem: FormItem, options?: FocusNodeFormItemOptions): Promise<void>;
161
214
  }
162
215
 
216
+ /**
217
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
218
+ * SPDX-License-Identifier: MIT
219
+ */
220
+
163
221
  declare class NodeClient {
164
222
  nodeFocusService: NodeFocusService;
165
223
  }
166
224
 
225
+ /**
226
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
227
+ * SPDX-License-Identifier: MIT
228
+ */
229
+
167
230
  interface FocusNodeOptions {
168
231
  zoom?: PlaygroundConfigRevealOpts['zoom'];
169
232
  easing?: PlaygroundConfigRevealOpts['easing'];
@@ -177,9 +240,18 @@ declare class FlowEditorClient {
177
240
  focusNode(node: FlowNodeEntity, options?: FocusNodeOptions): void;
178
241
  }
179
242
 
243
+ /**
244
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
245
+ * SPDX-License-Identifier: MIT
246
+ */
180
247
  declare const createFlowEditorClientPlugin: _flowgram_ai_core.PluginCreator<{}>;
181
248
  declare const createFlowEditorClientPlugins: () => _flowgram_ai_core.Plugin<{}>[];
182
249
 
250
+ /**
251
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
252
+ * SPDX-License-Identifier: MIT
253
+ */
254
+
183
255
  declare function useFlowEditor(): FlowEditorClient;
184
256
 
185
257
  export { Editor, type EditorPluginContext, EditorProps, EditorProvider, FlowEditorClient, type FocusNodeCanvasOptions, type FocusNodeFormItemOptions, type HighLightOptions, NodeClient, NodeFocusService, createDefaultPreset, createFlowEditorClientPlugin, createFlowEditorClientPlugins, highlightFormItem, useFlowEditor, useHighlight };