2026-04-12 11:45:59 +02:00
|
|
|
import type { useCreateBlockNote } from '@blocknote/react'
|
|
|
|
|
|
|
|
|
|
export function clearTableResizeState(editor: ReturnType<typeof useCreateBlockNote>) {
|
|
|
|
|
const view = editor._tiptapEditor?.view
|
|
|
|
|
if (!view || view.isDestroyed) return
|
|
|
|
|
|
2026-04-12 12:29:13 +02:00
|
|
|
const resizePluginKey = view.state.plugins.find((plugin: { key?: unknown }) => (
|
2026-04-12 11:45:59 +02:00
|
|
|
typeof plugin.key === 'string' && plugin.key.startsWith('tableColumnResizing')
|
|
|
|
|
))?.key
|
|
|
|
|
if (!resizePluginKey) return
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
view.dispatch(
|
|
|
|
|
view.state.tr.setMeta(resizePluginKey, {
|
|
|
|
|
setHandle: -1,
|
|
|
|
|
setDragging: null,
|
|
|
|
|
}),
|
|
|
|
|
)
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.warn('Failed to clear table resize state before raw mode toggle:', error)
|
|
|
|
|
}
|
|
|
|
|
}
|