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