diff --git a/src/JSONNode.svelte b/src/JSONNode.svelte index 1d6dab7..6834562 100644 --- a/src/JSONNode.svelte +++ b/src/JSONNode.svelte @@ -7,6 +7,7 @@ import { escapeHTML } from './utils/stringUtils.js' import { updateProps } from './utils/updateProps.js' import { unescapeHTML } from './utils/stringUtils' + import { getInnerText } from './utils/domUtils' export let key = undefined export let value @@ -41,6 +42,13 @@ $: escapedValue = escapeHTML(value, escapeUnicode) $: valueIsUrl = isUrl(value) + $: keyClass = classnames('key', { + empty: escapedKey.length === 0, + search: searchResult + ? !!searchResult[SEARCH_PROPERTY] + : false + }) + $: valueClass = classnames('value', type, { url: valueIsUrl, empty: escapedValue.length === 0, @@ -54,12 +62,12 @@ } function handleKeyInput (event) { - const newKey = unescapeHTML(event.target.innerText) + const newKey = unescapeHTML(getInnerText(event.target)) onChangeKey(newKey, key) } function handleValueInput (event) { - const valueText = unescapeHTML(event.target.innerText) + const valueText = unescapeHTML(getInnerText(event.target)) const newValue = stringConvert(valueText) // TODO: implement support for type "string" onChangeValue(newValue, key) } @@ -140,7 +148,7 @@ {#if typeof key === 'string'}
with hasChildNodes()==false is + // rendered with a new line. Note that a
with
+ // hasChildNodes()==true is rendered without a new line
+ // Other browsers always ensure there is a
inside the
, + // and if not, the
does not render a new line + return buffer.flush() + } + } + + // br or unknown + return '' + } + \ No newline at end of file