From a8d69608b361d28f1e57ab017dcd806a3bef79a9 Mon Sep 17 00:00:00 2001 From: Petyo Ivanov Date: Mon, 11 Nov 2024 08:50:09 +0200 Subject: [PATCH] fix: avoid duplicating frontmatter edge case --- src/plugins/frontmatter/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/plugins/frontmatter/index.ts b/src/plugins/frontmatter/index.ts index 27942ef..1ad2319 100644 --- a/src/plugins/frontmatter/index.ts +++ b/src/plugins/frontmatter/index.ts @@ -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 } )