diff --git a/assets/controllers/editor/layout_controller.js b/assets/controllers/editor/layout_controller.js index 7ea993a..b70db06 100644 --- a/assets/controllers/editor/layout_controller.js +++ b/assets/controllers/editor/layout_controller.js @@ -27,12 +27,13 @@ export default class extends Controller { }; this.hydrateState(); - // Check for and restore state after login - this.restoreStateAfterLogin(); - + // Update both editors with hydrated state this.updateMarkdownEditor(); this.updateQuillEditor(); + // Check for and restore state after login + this.restoreStateAfterLogin(); + // Live preview for summary and image fields const summaryInput = this.element.querySelector('textarea[name*="[summary]"], textarea[name="editor[summary]"]'); const imageInput = this.element.querySelector('input[name*="[image]"], input[name="editor[image]"]'); @@ -109,7 +110,8 @@ export default class extends Controller { } this.state.content_NMD = nmd; this.state.content_delta = this.nmdToDelta(nmd); - this.state.active_source = 'md'; + // Set active_source to 'quill' since we want rich text editor to be active first + this.state.active_source = 'quill'; } persistState() { @@ -450,9 +452,17 @@ export default class extends Controller { } updateQuillEditor() { // Set Quill editor value from state.content_delta - if (window.appQuill && this.state.content_delta) { - window.appQuill.setContents(this.state.content_delta); - } + const setQuillContent = () => { + if (window.appQuill && this.state.content_delta) { + console.log('[Editor] Updating Quill with delta:', this.state.content_delta); + window.appQuill.setContents(this.state.content_delta); + } else if (!window.appQuill) { + // Retry after a short delay if Quill isn't ready yet + console.log('[Editor] Quill not ready yet, retrying...'); + setTimeout(setQuillContent, 100); + } + }; + setQuillContent(); } // --- Conversion Stubs (implement via DNIR pipeline) --- diff --git a/assets/controllers/nostr/nostr_publish_controller.js b/assets/controllers/nostr/nostr_publish_controller.js index 9ef585a..1ff58b9 100644 --- a/assets/controllers/nostr/nostr_publish_controller.js +++ b/assets/controllers/nostr/nostr_publish_controller.js @@ -108,7 +108,7 @@ export default class extends Controller { this.textarea.style.display = 'none'; this.cmParent = document.createElement('div'); this.textarea.parentNode.insertBefore(this.cmParent, this.textarea); - console.log('[nostr-publish] Initializing CodeMirror for JSON textarea', this.textarea.value); + console.log('[nostr-publish] Initializing CodeMirror for JSON textarea'); this.cmView = new EditorView({ doc: this.textarea.value, extensions: [