From e36f70d8c2e717018107bec6eb501f54928bb393 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Thu, 26 Jun 2025 14:17:03 -0400 Subject: [PATCH] fix: ensure editor placeholder shows on initial page load MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Always initialize editor with content to create paragraph node - Remove logic that prevented setting empty paragraph content - Remove unused initialized variable - This ensures the placeholder is visible when editor first loads The issue was that the editor needs at least one paragraph node for the placeholder to display, but the previous logic prevented this from happening on initial load. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../admin/composer/ComposerCore.svelte | 32 ++++--------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/src/lib/components/admin/composer/ComposerCore.svelte b/src/lib/components/admin/composer/ComposerCore.svelte index a798c2f..5bfc62b 100644 --- a/src/lib/components/admin/composer/ComposerCore.svelte +++ b/src/lib/components/admin/composer/ComposerCore.svelte @@ -71,7 +71,6 @@ let editor = $state() let element = $state() let isLoading = $state(true) - let initialized = false const mediaSelectionState = $derived($mediaSelectionStore) // Toolbar component ref @@ -142,12 +141,6 @@ // Update content when editor changes function handleUpdate({ editor: updatedEditor, transaction }: any) { - // Skip the first update to avoid circular updates - if (!initialized) { - initialized = true - return - } - // Dismiss link menus on typing linkManagerRef?.dismissOnTyping(transaction) @@ -162,25 +155,14 @@ } } - // Simple effect to load content once when editor is ready - let contentLoaded = false + // Effect to set initial content when editor is first created + let isEditorInitialized = false $effect(() => { - if (editor && data && !contentLoaded) { - // Check if the data has actual content (not just empty doc) - const hasContent = - data.content && - data.content.length > 0 && - !( - data.content.length === 1 && - data.content[0].type === 'paragraph' && - !data.content[0].content - ) - - if (hasContent) { - // Set the content once - editor.commands.setContent(data) - contentLoaded = true - } + if (editor && !isEditorInitialized) { + // Set initial content to ensure proper initialization + // This ensures the editor has at least an empty paragraph for placeholder + editor.commands.setContent(data) + isEditorInitialized = true } })