From 5edb7c5f24df1809897525d2c8c0525147e0008a Mon Sep 17 00:00:00 2001 From: Jos de Jong Date: Thu, 1 Aug 2024 12:50:37 +0200 Subject: [PATCH] chore: remove passing `parser` to function `getEnforceString` --- src/lib/components/modes/tablemode/TableMode.svelte | 5 ++--- .../tablemode/contextmenu/createTableContextMenuItems.ts | 8 ++------ src/lib/components/modes/treemode/JSONNode.svelte | 2 +- src/lib/components/modes/treemode/TreeMode.svelte | 3 +-- .../treemode/contextmenu/createTreeContextMenuItems.ts | 6 +----- src/lib/logic/search.ts | 4 ++-- 6 files changed, 9 insertions(+), 19 deletions(-) diff --git a/src/lib/components/modes/tablemode/TableMode.svelte b/src/lib/components/modes/tablemode/TableMode.svelte index 064dcc15..d5fb0441 100644 --- a/src/lib/components/modes/tablemode/TableMode.svelte +++ b/src/lib/components/modes/tablemode/TableMode.svelte @@ -923,7 +923,6 @@ documentState, selection, readOnly, - parser, onEditValue: handleEditValue, onEditRow: handleEditRow, @@ -1066,7 +1065,7 @@ const path = selection.path const pointer = compileJSONPointer(path) const value = getIn(json, path) - const enforceString = !getEnforceString(json, documentState, path, parser) + const enforceString = !getEnforceString(json, documentState, path) const updatedValue = enforceString ? String(value) : stringConvert(String(value), parser) debug('handleToggleEnforceString', { enforceString, value, updatedValue }) @@ -1830,7 +1829,7 @@ void onEditRow: () => void onToggleEnforceString: () => void @@ -67,9 +65,7 @@ export default function ({ const canCut = !readOnly && hasSelectionContents const enforceString = - selection !== undefined - ? getEnforceString(json, documentState, getFocusPath(selection), parser) - : false + selection !== undefined ? getEnforceString(json, documentState, getFocusPath(selection)) : false return [ { type: 'separator' }, diff --git a/src/lib/components/modes/treemode/JSONNode.svelte b/src/lib/components/modes/treemode/JSONNode.svelte index 063a34aa..9b7205b0 100644 --- a/src/lib/components/modes/treemode/JSONNode.svelte +++ b/src/lib/components/modes/treemode/JSONNode.svelte @@ -103,7 +103,7 @@ $: expanded = isExpandableState(state) ? state.expanded : false let enforceString: boolean - $: enforceString = getEnforceString(value, state, [], context.parser) + $: enforceString = getEnforceString(value, state, []) let visibleSections: VisibleSection[] | undefined $: visibleSections = isArrayRecursiveState(state) ? state.visibleSections : undefined diff --git a/src/lib/components/modes/treemode/TreeMode.svelte b/src/lib/components/modes/treemode/TreeMode.svelte index ea52f4d1..8a6c2548 100644 --- a/src/lib/components/modes/treemode/TreeMode.svelte +++ b/src/lib/components/modes/treemode/TreeMode.svelte @@ -677,7 +677,7 @@ const path = getFocusPath(selection) const pointer = compileJSONPointer(path) const value = getIn(json, path) - const enforceString = !getEnforceString(json, documentState, path, parser) + const enforceString = !getEnforceString(json, documentState, path) const updatedValue = enforceString ? String(value) : stringConvert(String(value), parser) debug('handleToggleEnforceString', { enforceString, value, updatedValue }) @@ -1609,7 +1609,6 @@ documentState, selection, readOnly, - parser, onEditKey: handleEditKey, onEditValue: handleEditValue, diff --git a/src/lib/components/modes/treemode/contextmenu/createTreeContextMenuItems.ts b/src/lib/components/modes/treemode/contextmenu/createTreeContextMenuItems.ts index ab60da35..483ee5e2 100644 --- a/src/lib/components/modes/treemode/contextmenu/createTreeContextMenuItems.ts +++ b/src/lib/components/modes/treemode/contextmenu/createTreeContextMenuItems.ts @@ -43,7 +43,6 @@ export default function ({ documentState, selection, readOnly, - parser, onEditKey, onEditValue, onToggleEnforceString, @@ -64,7 +63,6 @@ export default function ({ documentState: DocumentState | undefined selection: JSONSelection | undefined readOnly: boolean - parser: JSONParser onEditKey: () => void onEditValue: () => void onToggleEnforceString: () => void @@ -131,9 +129,7 @@ export default function ({ !readOnly && (convertMode ? canConvert(selection) && isObjectOrArray(focusValue) : hasSelection) const enforceString = - selection !== undefined - ? getEnforceString(json, documentState, getFocusPath(selection), parser) - : false + selection !== undefined ? getEnforceString(json, documentState, getFocusPath(selection)) : false function handleInsertOrConvert(type: InsertType) { if (hasSelectionContents) { diff --git a/src/lib/logic/search.ts b/src/lib/logic/search.ts index f9015311..814f3582 100644 --- a/src/lib/logic/search.ts +++ b/src/lib/logic/search.ts @@ -303,7 +303,7 @@ export function createSearchAndReplaceOperations( } const currentValueText = typeof currentValue === 'string' ? currentValue : String(currentValue) - const enforceString = getEnforceString(json, documentState, path, parser) + const enforceString = getEnforceString(json, documentState, path) const value = replaceText(currentValueText, replacementText, start, end) const operations: JSONPatchOperation[] = [ @@ -402,7 +402,7 @@ export function createSearchAndReplaceAllOperations( } const currentValueText = typeof currentValue === 'string' ? currentValue : String(currentValue) - const enforceString = getEnforceString(json, documentState, path, parser) + const enforceString = getEnforceString(json, documentState, path) const value = replaceAllText(currentValueText, replacementText, items) const operations: JSONPatchOperation[] = [