Skip to content

Commit 4087e3f

Browse files
committedFeb 27, 2024·
fix: add missing property onSelect to interface JSONEditorPropsOptional
1 parent 1380980 commit 4087e3f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed
 

‎src/lib/components/JSONEditor.svelte

+5-2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
import ModalRef from '../components/modals/ModalRef.svelte'
5959
import type { Open, Callbacks, Component } from 'svelte-simple-modal'
6060
import type { OnRenderContextMenu } from '$lib/types.js'
61+
import { cloneDeep } from 'lodash-es'
6162
6263
// TODO: document how to enable debugging in the readme: localStorage.debug="jsoneditor:*", then reload
6364
const debug = createDebug('jsoneditor:JSONEditor')
@@ -89,7 +90,7 @@
8990
9091
export let onChangeQueryLanguage: OnChangeQueryLanguage = noop
9192
export let onChange: OnChange = null
92-
export let onSelect: OnSelect = noop
93+
export let onSelect: OnSelect | null = null
9394
export let onRenderValue: OnRenderValue = renderValue
9495
export let onClassName: OnClassName = () => undefined
9596
export let onRenderMenu: OnRenderMenu = noop
@@ -288,7 +289,9 @@
288289
function handleSelect(updatedSelection: JSONEditorSelection | null) {
289290
selection = updatedSelection
290291
291-
onSelect(updatedSelection)
292+
if (onSelect) {
293+
onSelect(cloneDeep(updatedSelection))
294+
}
292295
}
293296
294297
function handleFocus() {

‎src/lib/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,7 @@ export interface JSONEditorPropsOptional {
452452
onRenderMenu?: OnRenderMenu
453453
onRenderContextMenu?: OnRenderContextMenu
454454
onChangeMode?: OnChangeMode
455+
onSelect?: OnSelect
455456
onError?: OnError
456457
onFocus?: OnFocus
457458
onBlur?: OnBlur

0 commit comments

Comments
 (0)
Please sign in to comment.