Skip to content

Commit

Permalink
feat: insert new paragraph after figures
Browse files Browse the repository at this point in the history
  • Loading branch information
robertu7 committed May 2, 2023
1 parent 3337b6f commit 60922e4
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 39 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@matters/matters-editor",
"version": "0.2.0-alpha.32",
"version": "0.2.0-alpha.33",
"description": "Editor for matters.news",
"author": "https://github.com/thematters",
"homepage": "https://github.com/thematters/matters-editor",
Expand Down
22 changes: 10 additions & 12 deletions src/editors/extensions/figureAudio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,22 +119,20 @@ export const FigureAudio = Node.create({
setFigureAudio:
({ caption, ...attrs }) =>
({ chain }) => {
return (
chain()
.insertContent({
return chain()
.insertContent([
{
type: this.name,
attrs,
content: caption ? [{ type: 'text', text: caption }] : [],
})
// set cursor at end of caption field
// .command(({ tr, commands }) => {
// const { doc, selection } = tr
// const position = doc.resolve(selection.to - 2).end()
},
{
type: 'paragraph',
content: [],
},
])

// return commands.setTextSelection(position)
// })
.run()
)
.run()
},
}
},
Expand Down
23 changes: 10 additions & 13 deletions src/editors/extensions/figureEmbed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,22 +303,19 @@ export const FigureEmbed = Node.create({
setFigureEmbed:
({ caption, ...attrs }) =>
({ chain }) => {
return (
chain()
.insertContent({
return chain()
.insertContent([
{
type: this.name,
attrs,
content: caption ? [{ type: 'text', text: caption }] : [],
})
// set cursor at end of caption field
// .command(({ tr, commands }) => {
// const { doc, selection } = tr
// const position = doc.resolve(selection.to - 2).end()

// return commands.setTextSelection(position)
// })
.run()
)
},
{
type: 'paragraph',
content: [],
},
])
.run()
},
}
},
Expand Down
23 changes: 10 additions & 13 deletions src/editors/extensions/figureImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,19 @@ export const FigureImage = Node.create({
setFigureImage:
({ caption, ...attrs }) =>
({ chain }) => {
return (
chain()
.insertContent({
return chain()
.insertContent([
{
type: this.name,
attrs,
content: caption ? [{ type: 'text', text: caption }] : [],
})
// set cursor at end of caption field
// .command(({ tr, commands }) => {
// const { doc, selection } = tr
// const position = doc.resolve(selection.to - 2).end()

// return commands.setTextSelection(position)
// })
.run()
)
},
{
type: 'paragraph',
content: [],
},
])
.run()
},
}
},
Expand Down

0 comments on commit 60922e4

Please sign in to comment.