Skip to content

Commit

Permalink
fix: allow isEditing property to be true when in readOnly mode (see
Browse files Browse the repository at this point in the history
  • Loading branch information
josdejong committed Nov 29, 2023
1 parent 6c19c89 commit 3b0bdb7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/lib/components/modes/treemode/JSONKey.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
}
</script>

{#if isEditingKey}
{#if !context.readOnly && isEditingKey}
<EditableDiv
value={context.normalization.escapeValue(key)}
shortText
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/modes/treemode/JSONValue.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
export let selection: JSONSelection | null
export let searchResultItems: SearchResultItem[] | undefined
$: isEditing = !context.readOnly && isValueSelection(selection) && isEditingSelection(selection)
$: isEditing = isValueSelection(selection) && isEditingSelection(selection)
$: renderers = context.onRenderValue({
path,
Expand Down
10 changes: 4 additions & 6 deletions src/lib/components/modes/treemode/TreeMode.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -1702,7 +1702,7 @@
if (combo === 'Enter' && documentState.selection) {
// when the selection consists of a single Array item, change selection to editing its value
if (!readOnly && isMultiSelectionWithOneItem(documentState.selection)) {
if (isMultiSelectionWithOneItem(documentState.selection)) {
const path = documentState.selection.focusPath
const parent = getIn(json, initial(path))
if (Array.isArray(parent)) {
Expand All @@ -1711,7 +1711,7 @@
}
}
if (!readOnly && isKeySelection(documentState.selection)) {
if (isKeySelection(documentState.selection)) {
// go to key edit mode
event.preventDefault()
updateSelection({ ...documentState.selection, edit: true })
Expand All @@ -1725,10 +1725,8 @@
// expand object/array
handleExpand(documentState.selection.path, true)
} else {
if (!readOnly) {
// go to value edit mode
updateSelection({ ...documentState.selection, edit: true })
}
// go to value edit mode
updateSelection({ ...documentState.selection, edit: true })
}
}
}
Expand Down

0 comments on commit 3b0bdb7

Please sign in to comment.