fix: Resolve the issue of possible abnormal text generated during page creation.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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(() => {
|
||||
|
||||
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user