improve cursor position for figure

This commit is contained in:
Philipp Kühn 2021-06-04 00:01:14 +02:00
parent f038b94fba
commit 53d7172ff1
2 changed files with 8 additions and 10 deletions

View File

@ -96,18 +96,17 @@ export const Figure = Node.create<FigureOptions>({
.insertContent({
type: this.name,
attrs,
content: [
{
content: caption
? [{
type: 'text',
text: caption,
},
],
}]
: [],
})
// set cursor at end of caption field
.command(({ tr, commands }) => {
return commands.setTextSelection(tr.doc.resolve(tr.selection.to - 2).end())
})
// try to set cursor within caption field
// but this fails when inserting at an empty document
// .command(({ tr, commands }) => {
// return commands.setTextSelection(tr.selection.$from.before() - 1)
// })
.run()
},
}

View File

@ -3,7 +3,6 @@
⚠️ Experiment
## Tasks
* Add the caption as an optional parameter to the command
* Build commands to wrap an image into a figure + figcaption?
* Build commands to unrwap figure + figcaption to an image?