diff --git a/packages/editor-ui/src/components/CodeNodeEditor/theme.ts b/packages/editor-ui/src/components/CodeNodeEditor/theme.ts index bb88695526..0b6d923a97 100644 --- a/packages/editor-ui/src/components/CodeNodeEditor/theme.ts +++ b/packages/editor-ui/src/components/CodeNodeEditor/theme.ts @@ -53,7 +53,7 @@ export const codeNodeEditorTheme = ({ }, '.cm-content': { fontFamily: BASE_STYLING.fontFamily, - caretColor: 'var(--color-code-caret)', + caretColor: isReadOnly ? 'transparent' : 'var(--color-code-caret)', }, '.cm-cursor, .cm-dropCursor': { borderLeftColor: 'var(--color-code-caret)', diff --git a/packages/editor-ui/src/components/InlineExpressionEditor/ExpressionOutput.vue b/packages/editor-ui/src/components/InlineExpressionEditor/ExpressionOutput.vue index c037129a46..1424b7d2e3 100644 --- a/packages/editor-ui/src/components/InlineExpressionEditor/ExpressionOutput.vue +++ b/packages/editor-ui/src/components/InlineExpressionEditor/ExpressionOutput.vue @@ -97,7 +97,6 @@ onMounted(() => { extensions: [ EditorState.readOnly.of(true), EditorView.lineWrapping, - EditorView.editable.of(false), EditorView.domEventHandlers({ scroll: forceParse }), ...props.extensions, ], diff --git a/packages/editor-ui/src/components/InlineExpressionEditor/InlineExpressionEditorInput.vue b/packages/editor-ui/src/components/InlineExpressionEditor/InlineExpressionEditorInput.vue index 6b33cce6f3..37c13e110c 100644 --- a/packages/editor-ui/src/components/InlineExpressionEditor/InlineExpressionEditorInput.vue +++ b/packages/editor-ui/src/components/InlineExpressionEditor/InlineExpressionEditorInput.vue @@ -53,7 +53,7 @@ const extensions = computed(() => [ ), n8nLang(), n8nAutocompletion(), - inputTheme({ rows: props.rows }), + inputTheme({ isReadOnly: props.isReadOnly, rows: props.rows }), history(), expressionInputHandler(), EditorView.lineWrapping, diff --git a/packages/editor-ui/src/components/InlineExpressionEditor/theme.ts b/packages/editor-ui/src/components/InlineExpressionEditor/theme.ts index 4c1225063b..384cf4a01f 100644 --- a/packages/editor-ui/src/components/InlineExpressionEditor/theme.ts +++ b/packages/editor-ui/src/components/InlineExpressionEditor/theme.ts @@ -1,24 +1,24 @@ import { EditorView } from '@codemirror/view'; import { highlighter } from '@/plugins/codemirror/resolvableHighlighter'; -const commonThemeProps = { +const commonThemeProps = (isReadOnly = false) => ({ '&.cm-focused': { outline: '0 !important', }, '.cm-content': { fontFamily: 'var(--font-family-monospace)', color: 'var(--input-font-color, var(--color-text-dark))', - caretColor: 'var(--color-code-caret)', + caretColor: isReadOnly ? 'transparent' : 'var(--color-code-caret)', }, '.cm-line': { padding: '0', }, -}; +}); -export const inputTheme = ({ rows } = { rows: 5 }) => { +export const inputTheme = ({ rows, isReadOnly } = { rows: 5, isReadOnly: false }) => { const maxHeight = Math.max(rows * 22 + 8); const theme = EditorView.theme({ - ...commonThemeProps, + ...commonThemeProps(isReadOnly), '&': { maxHeight: `${maxHeight}px`, minHeight: '30px', @@ -54,7 +54,7 @@ export const inputTheme = ({ rows } = { rows: 5 }) => { export const outputTheme = () => { const theme = EditorView.theme({ - ...commonThemeProps, + ...commonThemeProps(true), '&': { maxHeight: '95px', width: '100%', diff --git a/packages/editor-ui/src/components/JsEditor/JsEditor.vue b/packages/editor-ui/src/components/JsEditor/JsEditor.vue index 3b356d7a2d..2f8b3e4549 100644 --- a/packages/editor-ui/src/components/JsEditor/JsEditor.vue +++ b/packages/editor-ui/src/components/JsEditor/JsEditor.vue @@ -61,7 +61,6 @@ const extensions = computed(() => { lineNumbers(), EditorView.lineWrapping, EditorState.readOnly.of(props.isReadOnly), - EditorView.editable.of(!props.isReadOnly), codeNodeEditorTheme({ isReadOnly: props.isReadOnly, maxHeight: props.fillParent ? '100%' : '40vh', diff --git a/packages/editor-ui/src/components/JsonEditor/JsonEditor.vue b/packages/editor-ui/src/components/JsonEditor/JsonEditor.vue index 3f5068a931..68e35a2c62 100644 --- a/packages/editor-ui/src/components/JsonEditor/JsonEditor.vue +++ b/packages/editor-ui/src/components/JsonEditor/JsonEditor.vue @@ -54,7 +54,6 @@ const extensions = computed(() => { lineNumbers(), EditorView.lineWrapping, EditorState.readOnly.of(props.isReadOnly), - EditorView.editable.of(!props.isReadOnly), codeNodeEditorTheme({ isReadOnly: props.isReadOnly, maxHeight: props.fillParent ? '100%' : '40vh', diff --git a/packages/editor-ui/src/components/__tests__/ExpressionParameterInput.test.ts b/packages/editor-ui/src/components/__tests__/ExpressionParameterInput.test.ts index 8943b1bc2b..0b7ef9c6e9 100644 --- a/packages/editor-ui/src/components/__tests__/ExpressionParameterInput.test.ts +++ b/packages/editor-ui/src/components/__tests__/ExpressionParameterInput.test.ts @@ -61,7 +61,6 @@ describe('ExpressionParameterInput', () => { await waitFor(() => { const editor = container.querySelector('.cm-content') as HTMLDivElement; expect(editor).toBeInTheDocument(); - expect(editor.getAttribute('contenteditable')).toEqual('false'); expect(editor.getAttribute('aria-readonly')).toEqual('true'); }); }); diff --git a/packages/editor-ui/src/composables/useExpressionEditor.ts b/packages/editor-ui/src/composables/useExpressionEditor.ts index 781578b52a..c596fd12dc 100644 --- a/packages/editor-ui/src/composables/useExpressionEditor.ts +++ b/packages/editor-ui/src/composables/useExpressionEditor.ts @@ -185,10 +185,7 @@ export const useExpressionEditor = ({ doc: toValue(editorValue), extensions: [ customExtensions.value.of(toValue(extensions)), - readOnlyExtensions.value.of([ - EditorState.readOnly.of(toValue(isReadOnly)), - EditorView.editable.of(!toValue(isReadOnly)), - ]), + readOnlyExtensions.value.of([EditorState.readOnly.of(toValue(isReadOnly))]), telemetryExtensions.value.of([]), EditorView.updateListener.of(onEditorUpdate), EditorView.focusChangeEffect.of((_, newHasFocus) => { @@ -229,7 +226,6 @@ export const useExpressionEditor = ({ editor.value.dispatch({ effects: readOnlyExtensions.value.reconfigure([ EditorState.readOnly.of(toValue(isReadOnly)), - EditorView.editable.of(!toValue(isReadOnly)), ]), }); }