fix: Resolve the issue of possible abnormal text generated during page creation.

This commit is contained in:
LIlGG
2025-10-09 17:48:18 +08:00
parent a93a679c71
commit c5d47c680c
11 changed files with 404 additions and 54 deletions

View File

@@ -14,9 +14,9 @@ const highlighterOptions = {
};
const shellHighlighter: HighlighterGeneric<BundledLanguage, BundledTheme> =
import.meta.hot?.data.shellHighlighter ?? (await createHighlighter(highlighterOptions));
import.meta.hot?.data?.shellHighlighter ?? (await createHighlighter(highlighterOptions));
if (import.meta.hot) {
if (import.meta.hot && import.meta.hot.data) {
import.meta.hot.data.shellHighlighter = shellHighlighter;
}

View File

@@ -28,7 +28,6 @@ interface Props {
editable?: boolean;
debounceChange?: number;
debounceScroll?: number;
autoFocusOnDocumentChange?: boolean;
onChange?: OnChangeCallback;
onReset?: () => void;
onSave?: OnSaveCallback;
@@ -39,7 +38,7 @@ interface Props {
}
export const EditorStudio = memo(
({ documents, currentPage, currentSection, autoFocusOnDocumentChange, onChange, onSave, onLoad, onReady }: Props) => {
({ documents, currentPage, currentSection, onChange, onSave, onLoad, onReady }: Props) => {
const editorRef = useRef<Editor | null>(null);
const pendingSectionRef = useRef<Section | null>(null);
@@ -134,7 +133,7 @@ export const EditorStudio = memo(
// 保存最新的页面属性,确保在节流期间如果有新的更新进来,会使用最新的数据
pendingSectionRef.current = currentSection;
setEditorDocument(editor, currentSection);
}, [currentSection, autoFocusOnDocumentChange]);
}, [currentSection]);
// 确保在组件卸载前应用最后一次更新
useEffect(() => {

View File

@@ -6,7 +6,6 @@ import type { PageMap } from '~/lib/stores/pages';
import type { PageHistory, Section } from '~/types/actions';
import type { DocumentProperties } from '~/types/editor';
import { logger, renderLogger } from '~/utils/logger';
import { isMobile } from '~/utils/mobile';
import {
EditorStudio,
type OnChangeCallback,
@@ -84,7 +83,6 @@ export const EditorPanel = memo(
settings={editorSettings}
currentPage={currentPage}
currentSection={currentSection}
autoFocusOnDocumentChange={!isMobile()}
onChange={onEditorChange}
onSave={onPageSave}
onReset={onPageReset}