Fix problematic onTransaction call
This commit is contained in:
parent
3ba7f6b762
commit
0f8b8c9f2a
2 changed files with 17 additions and 8 deletions
|
|
@ -90,6 +90,9 @@
|
|||
showLinkBubbleMenu={!simpleMode}
|
||||
showTableBubbleMenu={false}
|
||||
class="editor-content"
|
||||
onEditorReady={(e) => {
|
||||
editor = e
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -58,8 +58,9 @@
|
|||
showTableBubbleMenu = true,
|
||||
onUpdate,
|
||||
showToolbar = true,
|
||||
placeholder = 'Type "/" for commands...'
|
||||
}: EdraProps & { showToolbar?: boolean; placeholder?: string } = $props()
|
||||
placeholder = 'Type "/" for commands...',
|
||||
onEditorReady
|
||||
}: EdraProps & { showToolbar?: boolean; placeholder?: string; onEditorReady?: (editor: Editor) => void } = $props()
|
||||
|
||||
let element = $state<HTMLElement>()
|
||||
let isLoading = $state(true)
|
||||
|
|
@ -148,6 +149,9 @@
|
|||
return 'Paragraph'
|
||||
}
|
||||
|
||||
// Derived state for current text style to avoid reactive mutations
|
||||
let currentTextStyle = $derived(editor ? getCurrentTextStyle(editor) : 'Paragraph')
|
||||
|
||||
// Calculate dropdown position
|
||||
const updateDropdownPosition = () => {
|
||||
if (dropdownTriggerRef) {
|
||||
|
|
@ -314,7 +318,7 @@
|
|||
}
|
||||
|
||||
onMount(() => {
|
||||
editor = initiateEditor(
|
||||
const newEditor = initiateEditor(
|
||||
element,
|
||||
content,
|
||||
limit,
|
||||
|
|
@ -341,10 +345,6 @@
|
|||
{
|
||||
editable,
|
||||
onUpdate,
|
||||
onTransaction: (props) => {
|
||||
editor = undefined
|
||||
editor = props.editor
|
||||
},
|
||||
editorProps: {
|
||||
attributes: {
|
||||
class: 'prose prose-sm max-w-none focus:outline-none'
|
||||
|
|
@ -354,6 +354,12 @@
|
|||
},
|
||||
placeholder
|
||||
)
|
||||
editor = newEditor
|
||||
|
||||
// Notify parent component that editor is ready
|
||||
if (onEditorReady) {
|
||||
onEditorReady(newEditor)
|
||||
}
|
||||
|
||||
// Add placeholder
|
||||
if (placeholder && editor) {
|
||||
|
|
@ -377,7 +383,7 @@
|
|||
<!-- Text Style Dropdown -->
|
||||
<div class="text-style-dropdown">
|
||||
<button bind:this={dropdownTriggerRef} class="dropdown-trigger" onclick={toggleDropdown}>
|
||||
<span>{getCurrentTextStyle(editor)}</span>
|
||||
<span>{currentTextStyle}</span>
|
||||
<svg
|
||||
width="12"
|
||||
height="12"
|
||||
|
|
|
|||
Loading…
Reference in a new issue