Skip to content

Commit

Permalink
refactor: file embed plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
amanharwara committed Jan 3, 2024
1 parent 423c62b commit 83cefb3
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,21 @@ export default function FilePlugin({ currentNote }: { currentNote: SNNote }): JS
},
COMMAND_PRIORITY_NORMAL,
),
editor.registerNodeTransform(FileNode, (node) => {
/**
* Before this was added, we used to wrap the file node in a paragraph node,
* which caused issues with selection. We no longer do that, but for existing
* notes that have this, we use this transform to remove the wrapper node.
*/
const parent = node.getParent()
if (!parent) {
return
}
if (parent.getChildrenSize() === 1) {
parent.insertBefore(node)
parent.remove()
}
}),
)
}, [application, currentNote.protected, editor, filesController, linkingController])

Expand Down

0 comments on commit 83cefb3

Please sign in to comment.