Skip to content

Commit 3b0bdb7

Browse files
committedNov 29, 2023
fix: allow isEditing property to be true when in readOnly mode (see #342)
1 parent 6c19c89 commit 3b0bdb7

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed
 

‎src/lib/components/modes/treemode/JSONKey.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
}
6565
</script>
6666

67-
{#if isEditingKey}
67+
{#if !context.readOnly && isEditingKey}
6868
<EditableDiv
6969
value={context.normalization.escapeValue(key)}
7070
shortText

‎src/lib/components/modes/treemode/JSONValue.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
export let selection: JSONSelection | null
1313
export let searchResultItems: SearchResultItem[] | undefined
1414
15-
$: isEditing = !context.readOnly && isValueSelection(selection) && isEditingSelection(selection)
15+
$: isEditing = isValueSelection(selection) && isEditingSelection(selection)
1616
1717
$: renderers = context.onRenderValue({
1818
path,

‎src/lib/components/modes/treemode/TreeMode.svelte

+4-6
Original file line numberDiff line numberDiff line change
@@ -1702,7 +1702,7 @@
17021702
17031703
if (combo === 'Enter' && documentState.selection) {
17041704
// when the selection consists of a single Array item, change selection to editing its value
1705-
if (!readOnly && isMultiSelectionWithOneItem(documentState.selection)) {
1705+
if (isMultiSelectionWithOneItem(documentState.selection)) {
17061706
const path = documentState.selection.focusPath
17071707
const parent = getIn(json, initial(path))
17081708
if (Array.isArray(parent)) {
@@ -1711,7 +1711,7 @@
17111711
}
17121712
}
17131713
1714-
if (!readOnly && isKeySelection(documentState.selection)) {
1714+
if (isKeySelection(documentState.selection)) {
17151715
// go to key edit mode
17161716
event.preventDefault()
17171717
updateSelection({ ...documentState.selection, edit: true })
@@ -1725,10 +1725,8 @@
17251725
// expand object/array
17261726
handleExpand(documentState.selection.path, true)
17271727
} else {
1728-
if (!readOnly) {
1729-
// go to value edit mode
1730-
updateSelection({ ...documentState.selection, edit: true })
1731-
}
1728+
// go to value edit mode
1729+
updateSelection({ ...documentState.selection, edit: true })
17321730
}
17331731
}
17341732
}

0 commit comments

Comments
 (0)
Please sign in to comment.