improve cursor position for figure
This commit is contained in:
@@ -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()
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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?
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user