mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-28 23:59:25 +08:00
improve cursor position for figure
This commit is contained in:
parent
f038b94fba
commit
53d7172ff1
@ -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()
|
||||
},
|
||||
}
|
||||
|
@ -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?
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user