mirror of
https://gitee.com/ByteDance/flowgram.ai.git
synced 2025-07-07 17:43:29 +08:00
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
import { WorkflowLinesManager } from '@flowgram.ai/free-layout-core';
|
|
import { definePluginCreator, PluginContext } from '@flowgram.ai/core';
|
|
|
|
import { FreeLinesPluginOptions } from './type';
|
|
import { WorkflowLinesLayer } from './layer';
|
|
import { WorkflowBezierLineContribution, WorkflowFoldLineContribution } from './contributions';
|
|
|
|
export const createFreeLinesPlugin = definePluginCreator({
|
|
singleton: true,
|
|
onInit: (ctx: PluginContext, opts: FreeLinesPluginOptions) => {
|
|
ctx.playground.registerLayer(WorkflowLinesLayer, {
|
|
...opts,
|
|
});
|
|
},
|
|
onReady: (ctx: PluginContext, opts: FreeLinesPluginOptions) => {
|
|
const linesManager = ctx.container.get(WorkflowLinesManager);
|
|
linesManager
|
|
.registerContribution(WorkflowBezierLineContribution)
|
|
.registerContribution(WorkflowFoldLineContribution);
|
|
|
|
if (opts.contributions) {
|
|
opts.contributions.forEach((contribution) => {
|
|
linesManager.registerContribution(contribution);
|
|
});
|
|
}
|
|
|
|
if (opts.defaultLineType) {
|
|
linesManager.switchLineType(opts.defaultLineType);
|
|
}
|
|
},
|
|
});
|