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({ .insertContent({
type: this.name, type: this.name,
attrs, attrs,
content: [ content: caption
{ ? [{
type: 'text', type: 'text',
text: caption, 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() .run()
}, },
} }

View File

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