mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-20 11:22:15 +00:00
fix(editor): Force parse on long expressions (#5009)
⚡ Force parse on long expressions
This commit is contained in:
@@ -16,6 +16,7 @@ import { highlighter } from '@/plugins/codemirror/resolvableHighlighter';
|
|||||||
import { inputTheme } from './theme';
|
import { inputTheme } from './theme';
|
||||||
|
|
||||||
import type { IVariableItemSelected } from '@/Interface';
|
import type { IVariableItemSelected } from '@/Interface';
|
||||||
|
import { forceParse } from '@/utils/forceParse';
|
||||||
|
|
||||||
export default mixins(expressionManager, workflowHelpers).extend({
|
export default mixins(expressionManager, workflowHelpers).extend({
|
||||||
name: 'ExpressionEditorModalInput',
|
name: 'ExpressionEditorModalInput',
|
||||||
@@ -40,6 +41,7 @@ export default mixins(expressionManager, workflowHelpers).extend({
|
|||||||
doubleBraceHandler(),
|
doubleBraceHandler(),
|
||||||
EditorView.lineWrapping,
|
EditorView.lineWrapping,
|
||||||
EditorState.readOnly.of(this.isReadOnly),
|
EditorState.readOnly.of(this.isReadOnly),
|
||||||
|
EditorView.domEventHandlers({ scroll: forceParse }),
|
||||||
EditorView.updateListener.of((viewUpdate) => {
|
EditorView.updateListener.of((viewUpdate) => {
|
||||||
if (!this.editor || !viewUpdate.docChanged) return;
|
if (!this.editor || !viewUpdate.docChanged) return;
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { highlighter } from '@/plugins/codemirror/resolvableHighlighter';
|
|||||||
import { outputTheme } from './theme';
|
import { outputTheme } from './theme';
|
||||||
|
|
||||||
import type { Plaintext, Resolved, Segment } from '@/types/expressions';
|
import type { Plaintext, Resolved, Segment } from '@/types/expressions';
|
||||||
|
import { forceParse } from '@/utils/forceParse';
|
||||||
|
|
||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
name: 'ExpressionEditorModalOutput',
|
name: 'ExpressionEditorModalOutput',
|
||||||
@@ -37,7 +38,12 @@ export default Vue.extend({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
const extensions = [outputTheme(), EditorState.readOnly.of(true), EditorView.lineWrapping];
|
const extensions = [
|
||||||
|
outputTheme(),
|
||||||
|
EditorState.readOnly.of(true),
|
||||||
|
EditorView.lineWrapping,
|
||||||
|
EditorView.domEventHandlers({ scroll: forceParse }),
|
||||||
|
];
|
||||||
|
|
||||||
this.editor = new EditorView({
|
this.editor = new EditorView({
|
||||||
parent: this.$refs.root as HTMLDivElement,
|
parent: this.$refs.root as HTMLDivElement,
|
||||||
|
|||||||
14
packages/editor-ui/src/utils/forceParse.ts
Normal file
14
packages/editor-ui/src/utils/forceParse.ts
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import { EditorView } from '@codemirror/view';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simulate user action to force parser to catch up during scroll.
|
||||||
|
*/
|
||||||
|
export function forceParse(_: Event, view: EditorView) {
|
||||||
|
view.dispatch({
|
||||||
|
changes: { from: view.viewport.to, insert: '_' },
|
||||||
|
});
|
||||||
|
|
||||||
|
view.dispatch({
|
||||||
|
changes: { from: view.viewport.to - 1, to: view.viewport.to, insert: '' },
|
||||||
|
});
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user