From dd96f4ef8edce236332048f5934ff31418a6a25d Mon Sep 17 00:00:00 2001 From: Michael Drury Date: Thu, 16 Jan 2025 11:45:45 +0000 Subject: [PATCH] PR comments. --- .../common/CodeEditor/CodeEditor.svelte | 16 ++++++++-------- .../frontend-core/src/utils/jsonFormatter.ts | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/builder/src/components/common/CodeEditor/CodeEditor.svelte b/packages/builder/src/components/common/CodeEditor/CodeEditor.svelte index 1fa2eb3fae..bc88f0f981 100644 --- a/packages/builder/src/components/common/CodeEditor/CodeEditor.svelte +++ b/packages/builder/src/components/common/CodeEditor/CodeEditor.svelte @@ -60,8 +60,8 @@ const dispatch = createEventDispatcher() - let textarea: HTMLDivElement | undefined - let editor: EditorView | undefined + let textarea: HTMLDivElement + let editor: EditorView let mounted = false let isEditorInitialised = false let queuedRefresh = false @@ -73,7 +73,7 @@ $: { if (autofocus && isEditorInitialised) { - editor?.focus() + editor.focus() } } @@ -90,7 +90,7 @@ isDark = !currentTheme.includes("light") // Issue theme compartment update - editor?.dispatch({ + editor.dispatch({ effects: themeConfig.reconfigure([...(isDark ? [oneDark] : [])]), }) } @@ -119,7 +119,7 @@ (editor.state.doc.toString() !== value || queuedRefresh) ) { editor.dispatch({ - changes: { from: 0, to: editor.state.doc.length, insert: value! }, + changes: { from: 0, to: editor.state.doc.length, insert: value }, }) queuedRefresh = false } @@ -127,7 +127,7 @@ // Export a function to expose caret position export const getCaretPosition = () => { - const selection_range = editor?.state.selection.ranges[0] + const selection_range = editor.state.selection.ranges[0] return { start: selection_range?.from, end: selection_range?.to, @@ -142,7 +142,7 @@ }) => { // Updating the value inside. // Retain focus - editor?.dispatch({ + editor.dispatch({ changes: { from: opts.start || editor.state.doc.length, to: opts.end || editor.state.doc.length, @@ -323,7 +323,7 @@ keymap.of(buildKeymap()), EditorView.domEventHandlers({ blur: () => { - dispatch("blur", editor?.state.doc.toString()) + dispatch("blur", editor.state.doc.toString()) }, }), EditorView.updateListener.of(v => { diff --git a/packages/frontend-core/src/utils/jsonFormatter.ts b/packages/frontend-core/src/utils/jsonFormatter.ts index ba9f8fc748..de17426109 100644 --- a/packages/frontend-core/src/utils/jsonFormatter.ts +++ b/packages/frontend-core/src/utils/jsonFormatter.ts @@ -18,7 +18,7 @@ const defaultColors: ColorsOptions = { nullColor: "cornflowerblue", } -const entityMap: Record = { +const entityMap = { "&": "&", "<": "<", ">": ">",