action
type OnActionResult {
// source of action, configuration of related button
item: {
id: string;
}
// array of keys of fields that were changed
changes: string[]
// map of field keys to actual values
values: Record<string, any>
}
onaction(ev: OnActionResult): void
event is triggered when a button in the editor is clicked. It can be used to handle changes made in the editor and respond to user interactions.
Usage
Detecting button clicks in the editor
<script>
import { Editor } from "wx-svelte-editor";
const items = [
{ comp: "text", key: "name", label: "Name",
validation: v => (v && v.length > 5) },
{
comp: "textarea",
key: "descr",
label: "Description"
},
{ comp: "checkbox", key: "admin", label: "Is Admin" }
];
function onaction(ev){
console.log(`button ${ev.item.id} was clicked`);
}
</script>
<Editor {items} {onaction} />