fix(editor): Fix switching between connected SQL/HTML editors (#15297)

This commit is contained in:
Elias Meire
2025-05-13 19:21:46 +02:00
committed by GitHub
parent 102c67628c
commit bb2cfc209c
6 changed files with 109 additions and 63 deletions

View File

@@ -10,18 +10,18 @@ import {
keymap,
lineNumbers,
} from '@codemirror/view';
import { computed, onMounted, ref, toRaw, watch } from 'vue';
import { computed, ref, toRaw } from 'vue';
import { useExpressionEditor } from '@/composables/useExpressionEditor';
import { n8nCompletionSources } from '@/plugins/codemirror/completions/addCompletions';
import { editorKeymap } from '@/plugins/codemirror/keymap';
import { n8nAutocompletion } from '@/plugins/codemirror/n8nLang';
import { codeEditorTheme } from '../CodeNodeEditor/theme';
import { dropInExpressionEditor, mappingDropCursor } from '@/plugins/codemirror/dragAndDrop';
import {
expressionCloseBrackets,
expressionCloseBracketsConfig,
} from '@/plugins/codemirror/expressionCloseBrackets';
import { editorKeymap } from '@/plugins/codemirror/keymap';
import { n8nAutocompletion } from '@/plugins/codemirror/n8nLang';
import { codeEditorTheme } from '../CodeNodeEditor/theme';
type Props = {
modelValue: string;
@@ -69,23 +69,13 @@ const extensions = computed(() => [
mappingDropCursor(),
]);
const {
editor: editorRef,
segments,
readEditorValue,
isDirty,
} = useExpressionEditor({
const { editor: editorRef, readEditorValue } = useExpressionEditor({
editorRef: cssEditor,
editorValue,
extensions,
});
watch(segments.display, () => {
emit('update:model-value', readEditorValue());
});
onMounted(() => {
if (isDirty.value) emit('update:model-value', readEditorValue());
onChange: () => {
emit('update:model-value', readEditorValue());
},
});
async function onDrop(value: string, event: MouseEvent) {