Closed 1pone closed 4 months ago
Or can I submit a PR to add ReadonlyPassword
export?
I haven't tried out if/how you can use onRenderValue
from an other framework like React, we have to do some experimentation there.
I like the idea of exporting ReadonlyPassword
: it can be the first a collection of extra value render components. I think though that we should either rename it to something like HiddenValue
, or improve on it: it was just a minimal example, and when you double click it to edit, you see all of the password in plain sight, that should remain hidden whilst typing.
I think you can do it like this (after https://github.com/josdejong/svelte-jsoneditor/issues/373). Other frameworks will be able to create everything they need, and reactivity both inside and outside the component will be provided by runes.
Do you mean defining an API like a Svelte action?
Yes
I think that makes sense indeed.
I tried out using Svelte actions, it works like a charm, see #398
I've finished and merged #398 (not yet published)
v0.21.5
Can you give me a specific example of how to customize a component
可以这样写自己的样式
onRenderValue={(props: any) => {
const myRendererAction = {
action: (node: any) => {
const content = document.createElement('div')
content.innerHTML = props.value
node.classList.add('highlight')
node.appendChild(content)
return {
update: (node: any) => {
// update the DOM
},
destroy: () => {
// cleanup the DOM
},
}
},
props,
}
return [myRendererAction]
}
}
Can you please use English?
I'm using vanilla-jsoneditor in React, and i need use custom RenderValueComponent for
onRenderValue.component
to render value as password, like the ReadonlyPassword example shown in the project. But how can i define the RenderValueComponent without svelte?