|
1 | 1 | import { useEffect, useState } from "react"; |
2 | 2 | import Button from "../components/Button"; |
3 | | -import { Vector } from "../core/dataStruct/Vector"; |
4 | | -import { Renderer } from "../core/render/canvas2d/renderer"; |
5 | | -import { InputElement } from "../core/render/domElement/inputElement"; |
6 | | -import { StageStyleManager } from "../core/service/feedbackService/stageStyle/StageStyleManager"; |
7 | | -import { Camera } from "../core/stage/Camera"; |
8 | 3 | import { Settings } from "../core/service/Settings"; |
9 | 4 | import tipsJson from "../assets/projectGraphTips.json"; |
| 5 | +// import DetailsEditSidePanel from "./_details_edit_side_panel"; |
| 6 | +// import MarkdownEditor from "./_vditor_panel"; |
| 7 | +// import Vditor from "vditor"; |
| 8 | +import "vditor/dist/index.css"; |
| 9 | +import MarkdownEditor from "./_vditor_panel"; |
10 | 10 |
|
11 | 11 | export default function TestPage() { |
12 | 12 | useEffect(() => { |
13 | 13 | // InputElement.textarea(new Vector(300, 300), "hello world"); |
14 | 14 | }); |
15 | 15 |
|
16 | | - function testInput() { |
17 | | - InputElement.input(new Vector(300, 300), "hello world", () => {}, { |
18 | | - fontSize: Renderer.FONT_SIZE * Camera.currentScale + "px", |
19 | | - backgroundColor: "transparent", |
20 | | - color: StageStyleManager.currentStyle.StageObjectBorderColor.toString(), |
21 | | - outline: "solid 1px white", |
22 | | - marginTop: -8 * Camera.currentScale + "px", |
23 | | - width: "100vw", |
24 | | - }); |
25 | | - } |
26 | | - |
27 | | - function testTextarea() { |
28 | | - InputElement.textarea(new Vector(300, 300), "hello world", () => {}, { |
29 | | - fontSize: Renderer.FONT_SIZE * Camera.currentScale + "px", |
30 | | - backgroundColor: "transparent", |
31 | | - color: StageStyleManager.currentStyle.StageObjectBorderColor.toString(), |
32 | | - outline: "solid 1px white", |
33 | | - marginTop: -8 * Camera.currentScale + "px", |
34 | | - }); |
35 | | - } |
36 | | - |
37 | 16 | const [theme, setTheme] = useState("light"); |
| 17 | + // const [vd, setVd] = useState<Vditor>(); |
38 | 18 | useEffect(() => { |
39 | 19 | Settings.watch("uiTheme", (value) => { |
40 | 20 | setTheme(value); |
41 | 21 | document.documentElement.setAttribute("data-theme", value); |
42 | 22 | }); |
| 23 | + return () => { |
| 24 | + // vd?.destroy(); |
| 25 | + // setVd(undefined); |
| 26 | + }; |
43 | 27 | }, []); |
44 | 28 |
|
| 29 | + const [inputCurrentDetails, setInputCurrentDetails] = useState(""); |
| 30 | + const setInputCurrentDetailsHandler = (value?: string | undefined) => { |
| 31 | + if (value !== undefined) { |
| 32 | + setInputCurrentDetails(value); |
| 33 | + } |
| 34 | + }; |
45 | 35 | return ( |
46 | 36 | <> |
47 | 37 | <div className="p-4"> |
48 | 38 | <h1> Test Page </h1> |
49 | | - <Button onClick={testInput}>TestInput</Button> |
50 | | - <Button onClick={testTextarea}>TestTextarea</Button> |
51 | 39 | <Button onClick={() => console.log(tipsJson)}>test json</Button> |
52 | 40 | <div className="h-16 bg-gray-800" /> |
53 | 41 | <p>当前主题: {theme}</p> |
54 | 42 | <div className="bg-test-bg h-64 w-64 outline-2"></div> |
55 | 43 | <div className="bg-test-bg h-64 w-64 outline-2 hover:cursor-pointer"></div> |
| 44 | + <MarkdownEditor |
| 45 | + id="details-editor" |
| 46 | + className="fixed bottom-4 right-4 top-20 z-50 overflow-hidden rounded-xl" |
| 47 | + onChange={setInputCurrentDetailsHandler} |
| 48 | + defaultValue={inputCurrentDetails} |
| 49 | + options={{ |
| 50 | + width: "50%", |
| 51 | + toolbar: [ |
| 52 | + // { |
| 53 | + // name: "confirm", |
| 54 | + // tip: "确认", |
| 55 | + // tipPosition: "n", |
| 56 | + // icon: '<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 1024 1024"><path fill="currentColor" d="M912 190h-69.9c-9.8 0-19.1 4.5-25.1 12.2L404.7 724.5L207 474a32 32 0 0 0-25.1-12.2H112c-6.7 0-10.4 7.7-6.3 12.9l273.9 347c12.8 16.2 37.4 16.2 50.3 0l488.4-618.9c4.1-5.1.4-12.8-6.3-12.8"/></svg>', |
| 57 | + // click: handleConfirmDetailsEdit, |
| 58 | + // }, |
| 59 | + "fullscreen", |
| 60 | + "|", |
| 61 | + "headings", |
| 62 | + "bold", |
| 63 | + "italic", |
| 64 | + "strike", |
| 65 | + "link", |
| 66 | + "|", |
| 67 | + "list", |
| 68 | + "ordered-list", |
| 69 | + "check", |
| 70 | + "outdent", |
| 71 | + "indent", |
| 72 | + "|", |
| 73 | + "quote", |
| 74 | + "line", |
| 75 | + "code", |
| 76 | + "inline-code", |
| 77 | + "table", |
| 78 | + "|", |
| 79 | + "undo", |
| 80 | + "redo", |
| 81 | + ], |
| 82 | + }} |
| 83 | + /> |
56 | 84 | </div> |
57 | 85 | </> |
58 | 86 | ); |
|
0 commit comments