Hildebrandt Tobias
02/05/2025, 1:50 PMonUpdate
callback here properly:
<EditorProvider
extensions={extensions}
content={content}
slotAfter={<EditorToolbar />}
editorProps={editorProps}
onUpdate={({ editor }) => {
setValue(editor.getJSON())
}}
>
I it tried with
external interface Editor {
val options: EditorOptions
fun setOptions(options: EditorOptions)
fun getJSON(): dynamic
}
external interface EditorOptions {
[...]
var onUpdate: (editor: Editor) -> Unit
}
// Inside my component then:
EditorProvider {
extensions = props.extensions
content = props.content
onUpdate = { editor ->
println(editor.getJSON())
}
}
But I only get getJSON() is not a function
.
When I do useCurrentEditor().getJSON()
from a child it works.
For reference: https://github.com/ueberdosis/tiptap/discussions/4636
Edit: Thank you for rubber ducking after looking deeper into the source:
this.emit('update', {
editor: this,
transaction,
})
I got it:
external interface EditorOptions {
[...]
var onUpdate: (updaate: EditorUpdate ) -> Unit
}
external interface EditorUpdate {
var editor: dynamic
var transaction: dynamic
}
EditorProvider {
extensions = props.extensions
content = props.content
onUpdate = { update ->
println(JSON.stringify(update.editor.getJSON()))
}
}
Artem Kobzar
02/05/2025, 2:11 PMturansky
02/05/2025, 2:13 PMexternal interface EditorOptions {
[...]
var onUpdate: (options: UpdateOptions) -> Unit
interface UpdateOptions {
val editor: Editor
}
}
Hildebrandt Tobias
02/05/2025, 2:16 PM{({({({({({({
stuff is why I have trouble parsing JS 😞turansky
02/05/2025, 2:17 PM({ editor })
- editor
field from first parameter of functionturansky
02/05/2025, 4:39 PMdebugger
constant to stop execution in lambda and check parameters if signature isn't transparent