mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-01-22 09:25:53 +08:00
fix: make useEditorState run before layout
This commit is contained in:
parent
05e1755d10
commit
e6ce7b621d
@ -2,9 +2,7 @@ context('/src/Extensions/History/React/', () => {
|
||||
beforeEach(() => {
|
||||
cy.visit('/src/Extensions/History/React/')
|
||||
cy.get('.tiptap').then(([{ editor }]) => {
|
||||
setTimeout(() => {
|
||||
editor.commands.setContent('<p>Mistake</p>')
|
||||
}, 0)
|
||||
editor.commands.setContent('<p>Mistake</p>')
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
import type { Editor } from '@tiptap/core'
|
||||
import deepEqual from 'fast-deep-equal/es6/react'
|
||||
import { useDebugValue, useEffect, useState } from 'react'
|
||||
import {
|
||||
useDebugValue, useLayoutEffect, useState,
|
||||
} from 'react'
|
||||
import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector'
|
||||
|
||||
export type EditorStateSnapshot<TEditor extends Editor | null = Editor | null> = {
|
||||
@ -164,7 +166,7 @@ export function useEditorState<TSelectorResult>(
|
||||
options.equalityFn ?? deepEqual,
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
useLayoutEffect(() => {
|
||||
return editorStateManager.watch(options.editor)
|
||||
}, [options.editor, editorStateManager])
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user