mirror of
https://gitee.com/ByteDance/flowgram.ai.git
synced 2025-07-07 17:43:29 +08:00
feat(demo-fixed-layout): update initialData (#341)
* feat(demo-fixed-layout): update initialData * fix(fixed-layout-demo): clipboard plugin
This commit is contained in:
parent
fbfe45c993
commit
c320ab61e9
@ -88,113 +88,112 @@ export const initialData: FlowDocumentJSON = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'if_0',
|
id: 'switch_0',
|
||||||
type: 'if',
|
type: 'switch',
|
||||||
data: {
|
data: {
|
||||||
title: 'If',
|
title: 'Switch',
|
||||||
inputsValues: {
|
|
||||||
condition: { type: 'constant', content: true },
|
|
||||||
},
|
|
||||||
inputs: {
|
|
||||||
type: 'object',
|
|
||||||
required: ['condition'],
|
|
||||||
properties: {
|
|
||||||
condition: {
|
|
||||||
type: 'boolean',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
blocks: [
|
blocks: [
|
||||||
{
|
{
|
||||||
id: 'if_true',
|
id: 'case_0',
|
||||||
type: 'ifBlock',
|
type: 'case',
|
||||||
data: {
|
data: {
|
||||||
title: 'true',
|
title: 'Case_0',
|
||||||
|
inputsValues: {
|
||||||
|
condition: { type: 'constant', content: true },
|
||||||
|
},
|
||||||
|
inputs: {
|
||||||
|
type: 'object',
|
||||||
|
required: ['condition'],
|
||||||
|
properties: {
|
||||||
|
condition: {
|
||||||
|
type: 'boolean',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
blocks: [],
|
blocks: [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'if_false',
|
id: 'case_1',
|
||||||
type: 'ifBlock',
|
type: 'case',
|
||||||
data: {
|
data: {
|
||||||
title: 'false',
|
title: 'Case_1',
|
||||||
|
inputsValues: {
|
||||||
|
condition: { type: 'constant', content: true },
|
||||||
|
},
|
||||||
|
inputs: {
|
||||||
|
type: 'object',
|
||||||
|
required: ['condition'],
|
||||||
|
properties: {
|
||||||
|
condition: {
|
||||||
|
type: 'boolean',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'case_default_1',
|
||||||
|
type: 'caseDefault',
|
||||||
|
data: {
|
||||||
|
title: 'Default',
|
||||||
|
},
|
||||||
|
blocks: [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'loop_0',
|
||||||
|
type: 'loop',
|
||||||
|
data: {
|
||||||
|
title: 'Loop',
|
||||||
|
batchFor: {
|
||||||
|
type: 'ref',
|
||||||
|
content: ['start_0', 'array_obj'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
blocks: [
|
||||||
|
{
|
||||||
|
id: 'if_0',
|
||||||
|
type: 'if',
|
||||||
|
data: {
|
||||||
|
title: 'If',
|
||||||
|
inputsValues: {
|
||||||
|
condition: { type: 'constant', content: true },
|
||||||
|
},
|
||||||
|
inputs: {
|
||||||
|
type: 'object',
|
||||||
|
required: ['condition'],
|
||||||
|
properties: {
|
||||||
|
condition: {
|
||||||
|
type: 'boolean',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
blocks: [
|
blocks: [
|
||||||
{
|
{
|
||||||
id: 'loop_0',
|
id: 'if_true',
|
||||||
type: 'loop',
|
type: 'ifBlock',
|
||||||
data: {
|
data: {
|
||||||
title: 'Loop',
|
title: 'true',
|
||||||
batchFor: {
|
},
|
||||||
type: 'ref',
|
blocks: [],
|
||||||
content: ['start_0', 'array_obj'],
|
},
|
||||||
},
|
{
|
||||||
|
id: 'if_false',
|
||||||
|
type: 'ifBlock',
|
||||||
|
data: {
|
||||||
|
title: 'false',
|
||||||
},
|
},
|
||||||
blocks: [
|
blocks: [
|
||||||
{
|
{
|
||||||
id: 'switch_0',
|
id: 'break_0',
|
||||||
type: 'switch',
|
type: 'breakLoop',
|
||||||
data: {
|
data: {
|
||||||
title: 'Switch',
|
title: 'BreakLoop',
|
||||||
},
|
},
|
||||||
blocks: [
|
|
||||||
{
|
|
||||||
id: 'case_0',
|
|
||||||
type: 'case',
|
|
||||||
data: {
|
|
||||||
title: 'Case_0',
|
|
||||||
inputsValues: {
|
|
||||||
condition: { type: 'constant', content: true },
|
|
||||||
},
|
|
||||||
inputs: {
|
|
||||||
type: 'object',
|
|
||||||
required: ['condition'],
|
|
||||||
properties: {
|
|
||||||
condition: {
|
|
||||||
type: 'boolean',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
blocks: [],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'case_1',
|
|
||||||
type: 'case',
|
|
||||||
data: {
|
|
||||||
title: 'Case_1',
|
|
||||||
inputsValues: {
|
|
||||||
condition: { type: 'constant', content: true },
|
|
||||||
},
|
|
||||||
inputs: {
|
|
||||||
type: 'object',
|
|
||||||
required: ['condition'],
|
|
||||||
properties: {
|
|
||||||
condition: {
|
|
||||||
type: 'boolean',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'case_default_1',
|
|
||||||
type: 'caseDefault',
|
|
||||||
data: {
|
|
||||||
title: 'Default',
|
|
||||||
},
|
|
||||||
blocks: [
|
|
||||||
{
|
|
||||||
id: 'break_0',
|
|
||||||
type: 'breakLoop',
|
|
||||||
data: {
|
|
||||||
title: 'BreakLoop',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,14 +1,11 @@
|
|||||||
import {
|
import {
|
||||||
definePluginCreator,
|
definePluginCreator,
|
||||||
Disposable,
|
|
||||||
FixedLayoutPluginContext,
|
FixedLayoutPluginContext,
|
||||||
PluginCreator,
|
PluginCreator,
|
||||||
} from '@flowgram.ai/fixed-layout-editor';
|
} from '@flowgram.ai/fixed-layout-editor';
|
||||||
|
|
||||||
import { readData } from '../../shortcuts/utils';
|
import { readData } from '../../shortcuts/utils';
|
||||||
|
|
||||||
let disposable: any;
|
|
||||||
|
|
||||||
export const createClipboardPlugin: PluginCreator<void> = definePluginCreator<
|
export const createClipboardPlugin: PluginCreator<void> = definePluginCreator<
|
||||||
void,
|
void,
|
||||||
FixedLayoutPluginContext
|
FixedLayoutPluginContext
|
||||||
@ -20,13 +17,8 @@ export const createClipboardPlugin: PluginCreator<void> = definePluginCreator<
|
|||||||
clipboard.writeText(e.value);
|
clipboard.writeText(e.value);
|
||||||
};
|
};
|
||||||
navigator.clipboard.addEventListener('onchange', clipboardListener);
|
navigator.clipboard.addEventListener('onchange', clipboardListener);
|
||||||
|
ctx.playground.toDispose.onDispose(() => {
|
||||||
disposable = Disposable.create(() => {
|
|
||||||
navigator.clipboard.removeEventListener('onchange', clipboardListener);
|
navigator.clipboard.removeEventListener('onchange', clipboardListener);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onDispose() {
|
|
||||||
disposable?.dispose?.();
|
|
||||||
disposable = undefined;
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|||||||
@ -23,7 +23,7 @@ test.describe('node operations', () => {
|
|||||||
const prevCount = await editorPage.getNodeCount();
|
const prevCount = await editorPage.getNodeCount();
|
||||||
await editorPage.insert('switch', {
|
await editorPage.insert('switch', {
|
||||||
from: 'llm_0',
|
from: 'llm_0',
|
||||||
to: 'if_0',
|
to: 'switch_0',
|
||||||
});
|
});
|
||||||
const defaultNodeCount = await editorPage.getNodeCount();
|
const defaultNodeCount = await editorPage.getNodeCount();
|
||||||
expect(defaultNodeCount).toEqual(prevCount + 4);
|
expect(defaultNodeCount).toEqual(prevCount + 4);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user