更新文档: 测试一个代码
@@ -1,20 +1,33 @@
|
|||||||
# 这是一段typescript代码333
|
# 这是一段typescript代码333
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import ForwardedIconComponent from "@/components/common/genericIconComponent";
|
import
|
||||||
import VditorEditor from "@/components/common/VditorEditor";
|
```
|
||||||
import { Button } from "@/components/ui/button";
|
|
||||||
import { Card } from "@/components/ui/card";
|
```ts
|
||||||
import { Input } from "@/components/ui/input";
|
|
||||||
import { Label } from "@/components/ui/label";
|
const handleKeyDown = (e: KeyboardEvent) => {
|
||||||
import {
|
// 在代码块内编辑时启用保护
|
||||||
useCreateWiki,
|
const selection = window.getSelection();
|
||||||
useGetWikiPage,
|
if (selection && selection.rangeCount > 0) {
|
||||||
usePatchUpdateWikiPage,
|
const range = selection.getRangeAt(0);
|
||||||
} from "@/controllers/API/queries/repository";
|
const preElement = range.commonAncestorContainer.closest('pre');
|
||||||
import useAlertStore from "@/stores/alertStore";
|
if (preElement) {
|
||||||
import { useRepositoryStore } from "@/stores/repositoryStore";
|
isInternalChangeRef.current = true;
|
||||||
import { Loader2 } from "lucide-react";
|
}
|
||||||
import { useEffect, useState } from "react";
|
}
|
||||||
import { useNavigate, useParams } from "react-router-dom";
|
};
|
||||||
|
|
||||||
|
const handleKeyUp = () => {
|
||||||
|
setTimeout(() => {
|
||||||
|
if (!vditorElement.matches(':focus')) {
|
||||||
|
isInternalChangeRef.current = false;
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
|
};
|
||||||
|
|
||||||
|
vditorElement.addEventListener('focusin', handleFocusIn);
|
||||||
|
vditorElement.addEventListener('focusout', handleFocusOut);
|
||||||
|
vditorElement.addEventListener('keydown', handleKeyDown);
|
||||||
|
vditorElement.addEventListener('keyup', handleKeyUp);
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user