diff --git a/apps/demo-fixed-layout/src/initial-data.ts b/apps/demo-fixed-layout/src/initial-data.ts index 9b98928a..6046ebfc 100644 --- a/apps/demo-fixed-layout/src/initial-data.ts +++ b/apps/demo-fixed-layout/src/initial-data.ts @@ -88,113 +88,112 @@ export const initialData: FlowDocumentJSON = { }, }, { - id: 'if_0', - type: 'if', + id: 'switch_0', + type: 'switch', data: { - title: 'If', - inputsValues: { - condition: { type: 'constant', content: true }, - }, - inputs: { - type: 'object', - required: ['condition'], - properties: { - condition: { - type: 'boolean', - }, - }, - }, + title: 'Switch', }, blocks: [ { - id: 'if_true', - type: 'ifBlock', + id: 'case_0', + type: 'case', data: { - title: 'true', + title: 'Case_0', + inputsValues: { + condition: { type: 'constant', content: true }, + }, + inputs: { + type: 'object', + required: ['condition'], + properties: { + condition: { + type: 'boolean', + }, + }, + }, }, blocks: [], }, { - id: 'if_false', - type: 'ifBlock', + id: 'case_1', + type: 'case', 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: [ { - id: 'loop_0', - type: 'loop', + id: 'if_true', + type: 'ifBlock', data: { - title: 'Loop', - batchFor: { - type: 'ref', - content: ['start_0', 'array_obj'], - }, + title: 'true', + }, + blocks: [], + }, + { + id: 'if_false', + type: 'ifBlock', + data: { + title: 'false', }, blocks: [ { - id: 'switch_0', - type: 'switch', + id: 'break_0', + type: 'breakLoop', 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', - }, - }, - ], - }, - ], }, ], }, diff --git a/apps/demo-fixed-layout/src/plugins/clipboard-plugin/create-clipboard-plugin.ts b/apps/demo-fixed-layout/src/plugins/clipboard-plugin/create-clipboard-plugin.ts index f1e25aa8..f6bdcc56 100644 --- a/apps/demo-fixed-layout/src/plugins/clipboard-plugin/create-clipboard-plugin.ts +++ b/apps/demo-fixed-layout/src/plugins/clipboard-plugin/create-clipboard-plugin.ts @@ -1,14 +1,11 @@ import { definePluginCreator, - Disposable, FixedLayoutPluginContext, PluginCreator, } from '@flowgram.ai/fixed-layout-editor'; import { readData } from '../../shortcuts/utils'; -let disposable: any; - export const createClipboardPlugin: PluginCreator = definePluginCreator< void, FixedLayoutPluginContext @@ -20,13 +17,8 @@ export const createClipboardPlugin: PluginCreator = definePluginCreator< clipboard.writeText(e.value); }; navigator.clipboard.addEventListener('onchange', clipboardListener); - - disposable = Disposable.create(() => { + ctx.playground.toDispose.onDispose(() => { navigator.clipboard.removeEventListener('onchange', clipboardListener); }); }, - onDispose() { - disposable?.dispose?.(); - disposable = undefined; - }, }); diff --git a/e2e/fixed-layout/tests/node.spec.ts b/e2e/fixed-layout/tests/node.spec.ts index a869e39c..9a8f8e6c 100644 --- a/e2e/fixed-layout/tests/node.spec.ts +++ b/e2e/fixed-layout/tests/node.spec.ts @@ -23,7 +23,7 @@ test.describe('node operations', () => { const prevCount = await editorPage.getNodeCount(); await editorPage.insert('switch', { from: 'llm_0', - to: 'if_0', + to: 'switch_0', }); const defaultNodeCount = await editorPage.getNodeCount(); expect(defaultNodeCount).toEqual(prevCount + 4);