diff --git a/src/JSONEditor.svelte b/src/JSONEditor.svelte
index 989deb4..749b53b 100644
--- a/src/JSONEditor.svelte
+++ b/src/JSONEditor.svelte
@@ -75,10 +75,6 @@
}
}
- function getPath() {
- return []
- }
-
function doSearch(json, searchText) {
return search(null, json, searchText)
}
@@ -297,12 +293,12 @@
diff --git a/src/JSONNode.svelte b/src/JSONNode.svelte
index c55a023..df72d23 100644
--- a/src/JSONNode.svelte
+++ b/src/JSONNode.svelte
@@ -16,22 +16,15 @@
export let key = undefined // only applicable for object properties
export let value
+ export let path
export let state
export let searchResult
export let onPatch
export let onChangeKey
export let onExpand
- export let getParentPath
-
$: expanded = state && state[EXPANDED_PROPERTY]
- function getPath () {
- return key !== undefined
- ? getParentPath().concat(key)
- : []
- }
-
const DEBOUNCE_DELAY = 300 // milliseconds TODO: make the debounce delay configurable?
const DEFAULT_LIMIT = 100
const escapeUnicode = false // TODO: pass via options
@@ -100,7 +93,7 @@
}
function toggle () {
- onExpand(getPath(), !expanded)
+ onExpand(path, !expanded)
}
function updateKey () {
@@ -140,7 +133,7 @@
onPatch([{
op: 'replace',
- path: compileJSONPointer(getPath()),
+ path: compileJSONPointer(path),
value: newValue
}])
}
@@ -205,7 +198,6 @@
})
}
- const path = getPath()
onPatch([{
op: 'move',
from: compileJSONPointer(path.concat(oldChildKey)),
@@ -233,7 +225,7 @@
{#if typeof key === 'string'}
[
{:else}
[
-
+
]
{/if}
@@ -256,12 +248,12 @@
{/each}
{#if limited}
@@ -286,7 +278,7 @@
{#if typeof key === 'string'}
{
{:else}
{
-
+
}
{/if}
@@ -309,12 +301,12 @@
{/each}
@@ -327,7 +319,7 @@
{#if typeof key === 'string'}