fix: Remove node AI Transform node (no-changelog) (#10400)

This commit is contained in:
Shireen Missi
2024-08-14 12:01:14 +01:00
committed by GitHub
parent c4fcbe40c5
commit bae0116d78
23 changed files with 38 additions and 831 deletions

View File

@@ -1,5 +1,5 @@
<template>
<div :class="$style.editor" :style="isReadOnly ? 'opacity: 0.7' : ''">
<div :class="$style.editor">
<div ref="jsEditorRef" class="ph-no-capture js-editor"></div>
<slot name="suffix" />
</div>
@@ -21,7 +21,7 @@ import {
keymap,
lineNumbers,
} from '@codemirror/view';
import { computed, onMounted, ref, watch } from 'vue';
import { computed, onMounted, ref } from 'vue';
import {
autocompleteKeyMap,
@@ -45,37 +45,11 @@ const emit = defineEmits<{
}>();
onMounted(() => {
createEditor();
});
watch(
() => props.modelValue,
(newValue: string) => {
const editorValue = editor.value?.state?.doc.toString();
// If model value changes from outside the component
if (
editorValue !== undefined &&
editorValue.length !== newValue.length &&
editorValue !== newValue
) {
destroyEditor();
createEditor();
}
},
);
function createEditor() {
const state = EditorState.create({ doc: props.modelValue, extensions: extensions.value });
const parent = jsEditorRef.value;
editor.value = new EditorView({ parent, state });
editorState.value = editor.value.state;
}
function destroyEditor() {
editor.value?.destroy();
}
});
const jsEditorRef = ref<HTMLDivElement>();
const editor = ref<EditorView | null>(null);