Skip to content

Commit

Permalink
Merge pull request #100 from easyops-cn/steve/fix-source-editor-with-…
Browse files Browse the repository at this point in the history
…chinese

Fix that a line with Chinese chars can't be selected when expand the source editor
  • Loading branch information
weareoutman authored Sep 5, 2024
2 parents 1b51041 + 0867827 commit e3b6f91
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/components/MonacoEditor/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useLayoutEffect, useRef } from "react";
import React, { useEffect, useRef } from "react";
import { useColorMode } from "@docusaurus/theme-common";
import * as monaco from "monaco-editor/esm/vs/editor/editor.api";
import {
Expand Down Expand Up @@ -68,7 +68,7 @@ export default function MonacoEditor({
}
}, [code, type]);

useLayoutEffect(() => {
useEffect(() => {
if (automaticLayoutRef.current) {
return;
}
Expand Down
10 changes: 9 additions & 1 deletion src/components/NextExample/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,13 @@ export default function NextExample({
setSourceShown((prev) => !prev);
}, []);

const sourceShownOnceRef = useRef(false);
useEffect(() => {
if (!sourceShownOnceRef.current && sourceShown) {
sourceShownOnceRef.current = true;
}
}, [sourceShown]);

const [playgroundUrl, setPlaygroundUrl] = useState("/playground");

useEffect(() => {
Expand Down Expand Up @@ -260,7 +267,8 @@ export default function NextExample({
[styles.sourceShown]: sourceShown,
})}
>
{wait || !ready ? (
{!(sourceShown || sourceShownOnceRef.current) ? null : wait ||
!ready ? (
<LoadingRingBox height={editorInitialHeight} />
) : (
<BrowserOnly
Expand Down

0 comments on commit e3b6f91

Please sign in to comment.