Skip to content

Commit

Permalink
fix: avoid duplicating frontmatter edge case
Browse files Browse the repository at this point in the history
  • Loading branch information
petyosi committed Nov 11, 2024
1 parent 0910c73 commit a8d6960
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/plugins/frontmatter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ export const frontmatterPlugin = realmPlugin({
setTimeout(() => {
editor.update(
() => {
$getRoot().splice(0, 0, [$createFrontmatterNode(yaml)])
const firstItem = $getRoot().getFirstChild()
if (!$isFrontmatterNode(firstItem)) {
$getRoot().splice(0, 0, [$createFrontmatterNode(yaml)])
}
},
{ discrete: true }
)
Expand Down

0 comments on commit a8d6960

Please sign in to comment.