Fix indentation

This commit is contained in:
josdejong 2020-05-08 21:10:59 +02:00
parent 324e5053d9
commit bcd4553adb
1 changed files with 45 additions and 45 deletions

View File

@ -1,62 +1,62 @@
<script> <script>
import Icon from 'svelte-awesome' import Icon from 'svelte-awesome'
import { faSearch } from '@fortawesome/free-solid-svg-icons' import { faSearch } from '@fortawesome/free-solid-svg-icons'
import Node from './JSONNode.svelte' import Node from './JSONNode.svelte'
import { search } from './search' import { search } from './search'
import { immutableJSONPatch } from './utils/immutableJSONPatch' import { immutableJSONPatch } from './utils/immutableJSONPatch'
export let json = {} export let json = {}
export let onChangeJson = () => {} export let onChangeJson = () => {}
export let searchText = '' export let searchText = ''
export function get() { export function get() {
return json return json
} }
export function set(newJson) { export function set(newJson) {
json = newJson json = newJson
} }
function getPath () { function getPath () {
return [] return []
} }
function doSearch (json, searchText) { function doSearch (json, searchText) {
console.time('search') console.time('search')
const result = search(null, json, searchText) const result = search(null, json, searchText)
console.timeEnd('search') console.timeEnd('search')
return result return result
} }
$: searchResult = searchText ? doSearch(json, searchText) : undefined $: searchResult = searchText ? doSearch(json, searchText) : undefined
$: onChangeJson(json) $: onChangeJson(json)
function handleChangeKey (key, oldKey) { function handleChangeKey (key, oldKey) {
// console.log('handleChangeKey', { key, oldKey }) // console.log('handleChangeKey', { key, oldKey })
// TODO: this should not happen? // TODO: this should not happen?
} }
function handleChangeValue (value, key) { function handleChangeValue (value, key) {
// console.log('handleChangeValue', value, key) // console.log('handleChangeValue', value, key)
// json = value // json = value
} }
/** /**
* @param {JSONPatchDocument} operations * @param {JSONPatchDocument} operations
*/ */
function handleChange (operations) { function handleChange (operations) {
// console.log('handleChange', operations) // console.log('handleChange', operations)
// TODO: store changes in history // TODO: store changes in history
json = immutableJSONPatch(json, operations).json json = immutableJSONPatch(json, operations).json
} }
</script> </script>
<div class="jsoneditor"> <div class="jsoneditor">
<div class="menu"> <div class="menu">
<Icon data={faSearch} /> Search: <input class="search-input" bind:value={searchText} /> <Icon data={faSearch} /> Search: <input class="search-input" bind:value={searchText} />
</div> </div>
<div class="contents"> <div class="contents">
<Node <Node
value={json} value={json}
@ -64,7 +64,7 @@
expanded={true} expanded={true}
onChangeKey={handleChangeKey} onChangeKey={handleChangeKey}
onChange={handleChange} onChange={handleChange}
getParentPath={getPath} getParentPath={getPath}
/> />
</div> </div>
</div> </div>