2026-04-15 23:33:30 +02:00
|
|
|
import { useRef, useLayoutEffect, useCallback, useState } from 'react'
|
|
|
|
|
import type { useCreateBlockNote } from '@blocknote/react'
|
|
|
|
|
import { useRawMode } from '../hooks/useRawMode'
|
|
|
|
|
import { clearTableResizeState } from './tableResizeState'
|
|
|
|
|
import {
|
|
|
|
|
buildCodeMirrorRestoreState,
|
|
|
|
|
captureRawCodeMirrorRestoreState,
|
|
|
|
|
captureRawEditorPositionSnapshot,
|
|
|
|
|
captureRichEditorPositionSnapshot,
|
|
|
|
|
type CodeMirrorRestoreState,
|
|
|
|
|
} from './editorModePosition'
|
|
|
|
|
import {
|
|
|
|
|
type PendingRawExitContent,
|
|
|
|
|
buildPendingRawExitContent,
|
2026-05-13 02:18:19 +02:00
|
|
|
createRawModeContentTransition,
|
2026-04-15 23:33:30 +02:00
|
|
|
rememberPendingRawExitContent,
|
|
|
|
|
syncActiveTabIntoRawBuffer,
|
2026-05-13 02:18:19 +02:00
|
|
|
withPendingRawExitContent,
|
|
|
|
|
withRawModeContentOverride,
|
2026-04-15 23:33:30 +02:00
|
|
|
} from './editorRawModeSync'
|
2026-05-13 02:18:19 +02:00
|
|
|
import {
|
|
|
|
|
createEditorModeRestoreTransition,
|
|
|
|
|
type EditorModeRestoreTransition,
|
|
|
|
|
useEditorModePositionSync,
|
|
|
|
|
} from './useEditorModePositionSync'
|
2026-04-15 23:33:30 +02:00
|
|
|
|
|
|
|
|
interface PendingRoundTripRawRestore {
|
|
|
|
|
path: string
|
|
|
|
|
state: CodeMirrorRestoreState
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getRoundTripRawRestore({
|
|
|
|
|
activeTabPath,
|
2026-05-13 02:18:19 +02:00
|
|
|
restoreTransition,
|
2026-04-15 23:33:30 +02:00
|
|
|
}: {
|
|
|
|
|
activeTabPath: string | null
|
2026-05-13 02:18:19 +02:00
|
|
|
restoreTransition: EditorModeRestoreTransition
|
2026-04-15 23:33:30 +02:00
|
|
|
}) {
|
|
|
|
|
if (!activeTabPath) return null
|
2026-05-13 02:18:19 +02:00
|
|
|
return restoreTransition.roundTripRawRestore?.path === activeTabPath
|
|
|
|
|
? restoreTransition.roundTripRawRestore.state
|
2026-04-15 23:33:30 +02:00
|
|
|
: null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function buildPendingRawRestore({
|
|
|
|
|
activeTabContent,
|
|
|
|
|
activeTabPath,
|
|
|
|
|
editor,
|
2026-05-13 02:18:19 +02:00
|
|
|
restoreTransition,
|
2026-04-15 23:33:30 +02:00
|
|
|
syncedContent,
|
|
|
|
|
}: {
|
|
|
|
|
activeTabContent: string | null
|
|
|
|
|
activeTabPath: string | null
|
|
|
|
|
editor: ReturnType<typeof useCreateBlockNote>
|
2026-05-13 02:18:19 +02:00
|
|
|
restoreTransition: EditorModeRestoreTransition
|
2026-04-15 23:33:30 +02:00
|
|
|
syncedContent: string | null
|
|
|
|
|
}) {
|
|
|
|
|
const roundTripRestore = getRoundTripRawRestore({
|
|
|
|
|
activeTabPath,
|
2026-05-13 02:18:19 +02:00
|
|
|
restoreTransition,
|
2026-04-15 23:33:30 +02:00
|
|
|
})
|
|
|
|
|
if (roundTripRestore) return roundTripRestore
|
|
|
|
|
|
|
|
|
|
const nextContent = syncedContent ?? activeTabContent
|
|
|
|
|
if (!nextContent) return null
|
|
|
|
|
|
|
|
|
|
const richSnapshot = captureRichEditorPositionSnapshot(editor, document)
|
|
|
|
|
return richSnapshot
|
|
|
|
|
? buildCodeMirrorRestoreState(editor, nextContent, richSnapshot)
|
|
|
|
|
: null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function capturePendingRoundTripRawRestore(activeTabPath: string | null): PendingRoundTripRawRestore | null {
|
|
|
|
|
if (!activeTabPath) return null
|
|
|
|
|
|
|
|
|
|
const rawRestoreState = captureRawCodeMirrorRestoreState(document)
|
|
|
|
|
return rawRestoreState
|
|
|
|
|
? { path: activeTabPath, state: rawRestoreState }
|
|
|
|
|
: null
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-12 08:06:10 +02:00
|
|
|
function resolveActiveTabContent({
|
|
|
|
|
activeTabContent,
|
|
|
|
|
activeTabPath,
|
|
|
|
|
pendingRawExitContent,
|
|
|
|
|
}: {
|
|
|
|
|
activeTabContent: string | null
|
|
|
|
|
activeTabPath: string | null
|
|
|
|
|
pendingRawExitContent: PendingRawExitContent | null
|
|
|
|
|
}) {
|
|
|
|
|
if (activeTabPath && pendingRawExitContent?.path === activeTabPath) {
|
|
|
|
|
return pendingRawExitContent.content
|
|
|
|
|
}
|
|
|
|
|
return activeTabContent
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-15 23:33:30 +02:00
|
|
|
function useTrackRawBuffer({
|
|
|
|
|
activeTabContent,
|
|
|
|
|
activeTabPath,
|
2026-04-17 17:12:25 +02:00
|
|
|
rawInitialContentRef,
|
2026-04-15 23:33:30 +02:00
|
|
|
rawBufferPathRef,
|
|
|
|
|
rawLatestContentRef,
|
2026-04-21 18:50:50 +02:00
|
|
|
rawSourceContentRef,
|
2026-04-15 23:33:30 +02:00
|
|
|
}: {
|
|
|
|
|
activeTabContent: string | null
|
|
|
|
|
activeTabPath: string | null
|
2026-04-17 17:12:25 +02:00
|
|
|
rawInitialContentRef: React.MutableRefObject<string | null>
|
2026-04-15 23:33:30 +02:00
|
|
|
rawBufferPathRef: React.MutableRefObject<string | null>
|
|
|
|
|
rawLatestContentRef: React.MutableRefObject<string | null>
|
2026-04-21 18:50:50 +02:00
|
|
|
rawSourceContentRef: React.MutableRefObject<string | null>
|
2026-04-15 23:33:30 +02:00
|
|
|
}) {
|
|
|
|
|
useLayoutEffect(() => {
|
|
|
|
|
if (!activeTabPath) {
|
|
|
|
|
rawLatestContentRef.current = null
|
2026-04-17 17:12:25 +02:00
|
|
|
rawInitialContentRef.current = null
|
2026-04-15 23:33:30 +02:00
|
|
|
rawBufferPathRef.current = null
|
2026-04-21 18:50:50 +02:00
|
|
|
rawSourceContentRef.current = null
|
2026-04-15 23:33:30 +02:00
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (rawBufferPathRef.current === activeTabPath) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rawLatestContentRef.current = activeTabContent
|
2026-04-17 17:12:25 +02:00
|
|
|
rawInitialContentRef.current = activeTabContent
|
2026-04-15 23:33:30 +02:00
|
|
|
rawBufferPathRef.current = activeTabContent === null ? null : activeTabPath
|
2026-04-21 18:50:50 +02:00
|
|
|
rawSourceContentRef.current = activeTabContent
|
|
|
|
|
}, [activeTabContent, activeTabPath, rawBufferPathRef, rawInitialContentRef, rawLatestContentRef, rawSourceContentRef])
|
2026-04-15 23:33:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function resetRawBufferState({
|
2026-04-17 17:12:25 +02:00
|
|
|
rawInitialContentRef,
|
2026-04-15 23:33:30 +02:00
|
|
|
rawBufferPathRef,
|
|
|
|
|
rawLatestContentRef,
|
2026-04-21 18:50:50 +02:00
|
|
|
rawSourceContentRef,
|
2026-04-15 23:33:30 +02:00
|
|
|
}: {
|
2026-04-17 17:12:25 +02:00
|
|
|
rawInitialContentRef: React.MutableRefObject<string | null>
|
2026-04-15 23:33:30 +02:00
|
|
|
rawBufferPathRef: React.MutableRefObject<string | null>
|
|
|
|
|
rawLatestContentRef: React.MutableRefObject<string | null>
|
2026-04-21 18:50:50 +02:00
|
|
|
rawSourceContentRef: React.MutableRefObject<string | null>
|
2026-04-15 23:33:30 +02:00
|
|
|
}) {
|
2026-04-17 17:12:25 +02:00
|
|
|
rawInitialContentRef.current = null
|
2026-04-15 23:33:30 +02:00
|
|
|
rawBufferPathRef.current = null
|
|
|
|
|
rawLatestContentRef.current = null
|
2026-04-21 18:50:50 +02:00
|
|
|
rawSourceContentRef.current = null
|
2026-04-15 23:33:30 +02:00
|
|
|
}
|
|
|
|
|
|
2026-04-17 17:12:25 +02:00
|
|
|
function useHandleFlushPending({
|
|
|
|
|
editor,
|
|
|
|
|
activeTabPath,
|
|
|
|
|
activeTabContent,
|
|
|
|
|
rawInitialContentRef,
|
|
|
|
|
rawLatestContentRef,
|
2026-04-21 18:50:50 +02:00
|
|
|
rawSourceContentRef,
|
2026-05-02 00:41:42 +02:00
|
|
|
flushPendingEditorChangeRef,
|
2026-05-13 02:18:19 +02:00
|
|
|
restoreTransitionRef,
|
2026-04-17 17:12:25 +02:00
|
|
|
setRawModeContentOverride,
|
2026-04-23 16:31:36 +02:00
|
|
|
vaultPath,
|
2026-04-17 17:12:25 +02:00
|
|
|
}: {
|
|
|
|
|
editor: ReturnType<typeof useCreateBlockNote>
|
|
|
|
|
activeTabPath: string | null
|
|
|
|
|
activeTabContent: string | null
|
|
|
|
|
rawInitialContentRef: React.MutableRefObject<string | null>
|
|
|
|
|
rawLatestContentRef: React.MutableRefObject<string | null>
|
2026-04-21 18:50:50 +02:00
|
|
|
rawSourceContentRef: React.MutableRefObject<string | null>
|
2026-05-02 00:41:42 +02:00
|
|
|
flushPendingEditorChangeRef?: React.MutableRefObject<(() => boolean) | null>
|
2026-05-13 02:18:19 +02:00
|
|
|
restoreTransitionRef: React.MutableRefObject<EditorModeRestoreTransition>
|
2026-04-17 17:12:25 +02:00
|
|
|
setRawModeContentOverride: React.Dispatch<React.SetStateAction<PendingRawExitContent | null>>
|
2026-04-23 16:31:36 +02:00
|
|
|
vaultPath?: string
|
2026-04-17 17:12:25 +02:00
|
|
|
}) {
|
|
|
|
|
return useCallback(async () => {
|
2026-04-21 18:50:50 +02:00
|
|
|
rawSourceContentRef.current = activeTabContent
|
2026-05-02 00:41:42 +02:00
|
|
|
const serializeRichEditorContent = flushPendingEditorChangeRef?.current?.() ?? true
|
2026-04-15 23:33:30 +02:00
|
|
|
const syncedContent = syncActiveTabIntoRawBuffer({
|
|
|
|
|
editor,
|
|
|
|
|
activeTabPath,
|
|
|
|
|
activeTabContent,
|
|
|
|
|
rawLatestContentRef,
|
2026-05-02 00:41:42 +02:00
|
|
|
serializeRichEditorContent,
|
2026-04-23 16:31:36 +02:00
|
|
|
vaultPath,
|
2026-04-15 23:33:30 +02:00
|
|
|
})
|
2026-04-17 17:12:25 +02:00
|
|
|
rawInitialContentRef.current = syncedContent ?? activeTabContent
|
2026-05-13 02:18:19 +02:00
|
|
|
const restoreTransition = restoreTransitionRef.current
|
|
|
|
|
restoreTransition.rawRestore = buildPendingRawRestore({
|
2026-04-15 23:33:30 +02:00
|
|
|
activeTabContent,
|
|
|
|
|
activeTabPath,
|
|
|
|
|
editor,
|
2026-05-13 02:18:19 +02:00
|
|
|
restoreTransition,
|
2026-04-15 23:33:30 +02:00
|
|
|
syncedContent,
|
|
|
|
|
})
|
2026-05-13 02:18:19 +02:00
|
|
|
restoreTransition.roundTripRawRestore = null
|
2026-04-15 23:33:30 +02:00
|
|
|
setRawModeContentOverride(buildPendingRawExitContent(activeTabPath, syncedContent))
|
|
|
|
|
clearTableResizeState(editor)
|
|
|
|
|
return true
|
2026-04-17 17:12:25 +02:00
|
|
|
}, [
|
|
|
|
|
activeTabContent,
|
|
|
|
|
activeTabPath,
|
|
|
|
|
editor,
|
2026-05-02 00:41:42 +02:00
|
|
|
flushPendingEditorChangeRef,
|
2026-05-13 02:18:19 +02:00
|
|
|
restoreTransitionRef,
|
2026-04-17 17:12:25 +02:00
|
|
|
rawInitialContentRef,
|
|
|
|
|
rawLatestContentRef,
|
2026-04-21 18:50:50 +02:00
|
|
|
rawSourceContentRef,
|
2026-04-17 17:12:25 +02:00
|
|
|
setRawModeContentOverride,
|
2026-04-23 16:31:36 +02:00
|
|
|
vaultPath,
|
2026-04-17 17:12:25 +02:00
|
|
|
])
|
|
|
|
|
}
|
2026-04-15 23:33:30 +02:00
|
|
|
|
2026-04-17 17:12:25 +02:00
|
|
|
function useHandleBeforeRawEnd({
|
|
|
|
|
activeTabPath,
|
|
|
|
|
activeTabContent,
|
|
|
|
|
onContentChange,
|
|
|
|
|
rawInitialContentRef,
|
|
|
|
|
rawBufferPathRef,
|
|
|
|
|
rawLatestContentRef,
|
2026-04-21 18:50:50 +02:00
|
|
|
rawSourceContentRef,
|
2026-05-13 02:18:19 +02:00
|
|
|
restoreTransitionRef,
|
2026-04-17 17:12:25 +02:00
|
|
|
setPendingRawExitContent,
|
|
|
|
|
setRawModeContentOverride,
|
|
|
|
|
}: {
|
|
|
|
|
activeTabPath: string | null
|
|
|
|
|
activeTabContent: string | null
|
|
|
|
|
onContentChange?: (path: string, content: string) => void
|
|
|
|
|
rawInitialContentRef: React.MutableRefObject<string | null>
|
|
|
|
|
rawBufferPathRef: React.MutableRefObject<string | null>
|
|
|
|
|
rawLatestContentRef: React.MutableRefObject<string | null>
|
2026-04-21 18:50:50 +02:00
|
|
|
rawSourceContentRef: React.MutableRefObject<string | null>
|
2026-05-13 02:18:19 +02:00
|
|
|
restoreTransitionRef: React.MutableRefObject<EditorModeRestoreTransition>
|
2026-04-17 17:12:25 +02:00
|
|
|
setPendingRawExitContent: React.Dispatch<React.SetStateAction<PendingRawExitContent | null>>
|
|
|
|
|
setRawModeContentOverride: React.Dispatch<React.SetStateAction<PendingRawExitContent | null>>
|
|
|
|
|
}) {
|
|
|
|
|
return useCallback(() => {
|
2026-05-13 02:18:19 +02:00
|
|
|
const restoreTransition = restoreTransitionRef.current
|
|
|
|
|
restoreTransition.roundTripRawRestore = capturePendingRoundTripRawRestore(activeTabPath)
|
|
|
|
|
restoreTransition.richRestore = captureRawEditorPositionSnapshot(document)
|
|
|
|
|
restoreTransition.rawRestore = null
|
2026-04-15 23:33:30 +02:00
|
|
|
setPendingRawExitContent(rememberPendingRawExitContent({
|
|
|
|
|
activeTabPath,
|
2026-04-17 17:12:25 +02:00
|
|
|
activeTabContent,
|
|
|
|
|
rawInitialContent: rawInitialContentRef.current,
|
2026-04-15 23:33:30 +02:00
|
|
|
rawLatestContentRef,
|
|
|
|
|
onContentChange,
|
|
|
|
|
}))
|
|
|
|
|
setRawModeContentOverride(null)
|
2026-04-21 18:50:50 +02:00
|
|
|
resetRawBufferState({ rawInitialContentRef, rawBufferPathRef, rawLatestContentRef, rawSourceContentRef })
|
2026-04-17 17:12:25 +02:00
|
|
|
}, [
|
|
|
|
|
activeTabContent,
|
|
|
|
|
activeTabPath,
|
|
|
|
|
onContentChange,
|
2026-05-13 02:18:19 +02:00
|
|
|
restoreTransitionRef,
|
2026-04-17 17:12:25 +02:00
|
|
|
rawInitialContentRef,
|
|
|
|
|
rawBufferPathRef,
|
|
|
|
|
rawLatestContentRef,
|
2026-04-21 18:50:50 +02:00
|
|
|
rawSourceContentRef,
|
2026-04-17 17:12:25 +02:00
|
|
|
setPendingRawExitContent,
|
|
|
|
|
setRawModeContentOverride,
|
|
|
|
|
])
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-21 18:50:50 +02:00
|
|
|
function useSyncRawModeContentOverride({
|
|
|
|
|
activeTabContent,
|
|
|
|
|
activeTabPath,
|
|
|
|
|
rawSourceContentRef,
|
|
|
|
|
setRawModeContentOverride,
|
|
|
|
|
}: {
|
|
|
|
|
activeTabContent: string | null
|
|
|
|
|
activeTabPath: string | null
|
|
|
|
|
rawSourceContentRef: React.MutableRefObject<string | null>
|
|
|
|
|
setRawModeContentOverride: React.Dispatch<React.SetStateAction<PendingRawExitContent | null>>
|
|
|
|
|
}) {
|
|
|
|
|
useLayoutEffect(() => {
|
|
|
|
|
if (!activeTabPath || activeTabContent === null) return
|
|
|
|
|
if (rawSourceContentRef.current === null || activeTabContent === rawSourceContentRef.current) return
|
2026-04-21 18:54:02 +02:00
|
|
|
const nextContent = activeTabContent
|
2026-04-21 18:50:50 +02:00
|
|
|
|
2026-04-23 16:31:36 +02:00
|
|
|
setRawModeContentOverride((current) => {
|
|
|
|
|
if (!current) return current
|
|
|
|
|
if (current.path !== activeTabPath || current.content === nextContent) return current
|
|
|
|
|
return { path: activeTabPath, content: nextContent }
|
|
|
|
|
})
|
2026-04-21 18:50:50 +02:00
|
|
|
}, [activeTabContent, activeTabPath, rawSourceContentRef, setRawModeContentOverride])
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-17 17:12:25 +02:00
|
|
|
export function useRawModeWithFlush(
|
|
|
|
|
editor: ReturnType<typeof useCreateBlockNote>,
|
|
|
|
|
activeTabPath: string | null,
|
|
|
|
|
activeTabContent: string | null,
|
|
|
|
|
onContentChange?: (path: string, content: string) => void,
|
2026-04-23 16:31:36 +02:00
|
|
|
vaultPath?: string,
|
2026-05-02 00:41:42 +02:00
|
|
|
flushPendingEditorChangeRef?: React.MutableRefObject<(() => boolean) | null>,
|
2026-04-17 17:12:25 +02:00
|
|
|
) {
|
|
|
|
|
const rawLatestContentRef = useRef<string | null>(null)
|
|
|
|
|
const rawInitialContentRef = useRef<string | null>(null)
|
|
|
|
|
const rawBufferPathRef = useRef<string | null>(null)
|
2026-04-21 18:50:50 +02:00
|
|
|
const rawSourceContentRef = useRef<string | null>(null)
|
2026-05-13 02:18:19 +02:00
|
|
|
const restoreTransitionRef = useRef(createEditorModeRestoreTransition())
|
|
|
|
|
const [contentTransition, setContentTransition] = useState(createRawModeContentTransition)
|
|
|
|
|
const setPendingRawExitContent = useCallback<React.Dispatch<React.SetStateAction<PendingRawExitContent | null>>>((action) => {
|
|
|
|
|
setContentTransition(transition => withPendingRawExitContent(transition, action))
|
|
|
|
|
}, [])
|
|
|
|
|
const setRawModeContentOverride = useCallback<React.Dispatch<React.SetStateAction<PendingRawExitContent | null>>>((action) => {
|
|
|
|
|
setContentTransition(transition => withRawModeContentOverride(transition, action))
|
|
|
|
|
}, [])
|
2026-05-12 08:06:10 +02:00
|
|
|
const effectiveActiveTabContent = resolveActiveTabContent({
|
2026-04-17 17:12:25 +02:00
|
|
|
activeTabContent,
|
|
|
|
|
activeTabPath,
|
2026-05-13 02:18:19 +02:00
|
|
|
pendingRawExitContent: contentTransition.pendingExitContent,
|
2026-05-12 08:06:10 +02:00
|
|
|
})
|
|
|
|
|
useTrackRawBuffer({
|
|
|
|
|
activeTabContent: effectiveActiveTabContent,
|
|
|
|
|
activeTabPath,
|
2026-04-17 17:12:25 +02:00
|
|
|
rawInitialContentRef,
|
|
|
|
|
rawBufferPathRef,
|
|
|
|
|
rawLatestContentRef,
|
2026-04-21 18:50:50 +02:00
|
|
|
rawSourceContentRef,
|
|
|
|
|
})
|
|
|
|
|
useSyncRawModeContentOverride({
|
2026-05-12 08:06:10 +02:00
|
|
|
activeTabContent: effectiveActiveTabContent,
|
2026-04-21 18:50:50 +02:00
|
|
|
activeTabPath,
|
|
|
|
|
rawSourceContentRef,
|
|
|
|
|
setRawModeContentOverride,
|
2026-04-17 17:12:25 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const handleFlushPending = useHandleFlushPending({
|
|
|
|
|
editor,
|
|
|
|
|
activeTabPath,
|
2026-05-12 08:06:10 +02:00
|
|
|
activeTabContent: effectiveActiveTabContent,
|
2026-04-17 17:12:25 +02:00
|
|
|
rawInitialContentRef,
|
|
|
|
|
rawLatestContentRef,
|
2026-04-21 18:50:50 +02:00
|
|
|
rawSourceContentRef,
|
2026-05-02 00:41:42 +02:00
|
|
|
flushPendingEditorChangeRef,
|
2026-05-13 02:18:19 +02:00
|
|
|
restoreTransitionRef,
|
2026-04-17 17:12:25 +02:00
|
|
|
setRawModeContentOverride,
|
2026-04-23 16:31:36 +02:00
|
|
|
vaultPath,
|
2026-04-17 17:12:25 +02:00
|
|
|
})
|
|
|
|
|
const handleBeforeRawEnd = useHandleBeforeRawEnd({
|
|
|
|
|
activeTabPath,
|
2026-05-12 08:06:10 +02:00
|
|
|
activeTabContent: effectiveActiveTabContent,
|
2026-04-17 17:12:25 +02:00
|
|
|
onContentChange,
|
|
|
|
|
rawInitialContentRef,
|
|
|
|
|
rawBufferPathRef,
|
|
|
|
|
rawLatestContentRef,
|
2026-04-21 18:50:50 +02:00
|
|
|
rawSourceContentRef,
|
2026-05-13 02:18:19 +02:00
|
|
|
restoreTransitionRef,
|
2026-04-17 17:12:25 +02:00
|
|
|
setPendingRawExitContent,
|
|
|
|
|
setRawModeContentOverride,
|
|
|
|
|
})
|
2026-04-15 23:33:30 +02:00
|
|
|
|
|
|
|
|
const { rawMode, handleToggleRaw } = useRawMode({
|
|
|
|
|
activeTabPath,
|
|
|
|
|
onFlushPending: handleFlushPending,
|
|
|
|
|
onBeforeRawEnd: handleBeforeRawEnd,
|
|
|
|
|
})
|
|
|
|
|
useEditorModePositionSync({
|
|
|
|
|
activeTabPath,
|
|
|
|
|
editor,
|
2026-05-13 02:18:19 +02:00
|
|
|
restoreTransitionRef,
|
2026-04-15 23:33:30 +02:00
|
|
|
rawMode,
|
|
|
|
|
})
|
|
|
|
|
|
2026-05-13 02:18:19 +02:00
|
|
|
return {
|
|
|
|
|
rawMode,
|
|
|
|
|
handleToggleRaw,
|
|
|
|
|
rawLatestContentRef,
|
|
|
|
|
pendingRawExitContent: contentTransition.pendingExitContent,
|
|
|
|
|
setPendingRawExitContent,
|
|
|
|
|
rawModeContentOverride: contentTransition.rawModeContentOverride,
|
|
|
|
|
}
|
2026-04-15 23:33:30 +02:00
|
|
|
}
|