From 2bfe803f5320480eb0c00cc4c9eaf814247f4aca Mon Sep 17 00:00:00 2001 From: am009 Date: Thu, 18 Jul 2024 13:31:00 +0000 Subject: [PATCH] Add side buttons. --- frontend/app/monaco.tsx | 4 ++-- frontend/app/page.tsx | 29 +++++++++++++++++++---------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/frontend/app/monaco.tsx b/frontend/app/monaco.tsx index 31cd691..50f4f50 100644 --- a/frontend/app/monaco.tsx +++ b/frontend/app/monaco.tsx @@ -1,6 +1,6 @@ import * as monaco from "monaco-editor/esm/vs/editor/editor.api"; -import { useEffect, useMemo, useRef } from "react"; +import { useEffect, useRef } from "react"; export type ChangeHandler = ( value: string, @@ -77,7 +77,7 @@ export default function MonacoDiffEditor( } if (onNewChange !== undefined) { const models = editor.current.getModel() - _oldSubscription.current = models?.modified.onDidChangeContent((event) => { + _newSubscription.current = models?.modified.onDidChangeContent((event) => { onNewChange(models?.modified.getValue(), event) }); } diff --git a/frontend/app/page.tsx b/frontend/app/page.tsx index 48964c2..43ddfed 100644 --- a/frontend/app/page.tsx +++ b/frontend/app/page.tsx @@ -17,7 +17,7 @@ import Space from 'antd/es/space'; import Flex from 'antd/es/flex'; import Giscus from './giscus'; -import { useState, useEffect } from 'react'; +import { useState, useEffect, useRef } from 'react'; import { Divider, Form } from 'antd'; import { Color } from 'antd/es/color-picker'; import { ColorFactory } from 'antd/es/color-picker/color'; @@ -26,6 +26,7 @@ import DiffEditor from './editor'; const { Option } = Select; export default function Home() { + const submitButton = useRef(null); const [dockerCmd, setDockerCmd] = useState("docker run --rm -v :/work am009/latexdiff-web-worker"); const [configJson, setConfigJson] = useState(""); const [pdfURL, setPdfURL] = useState(""); @@ -224,7 +225,7 @@ export default function Home() { Custom Style Options - + @@ -403,13 +404,21 @@ export default function Home() { ); + + const doSubmit = () => { + if (submitButton.current) { + submitButton.current.click(); + } + } + let submit2 = () + let next = (); let title = ( - - <a href="https://github.com/am009/git-latexdiff-web">git-latexdiff web</a> - ); + + <a href="https://github.com/am009/git-latexdiff-web">git-latexdiff web</a> + ); let editor = (
) - let next = currentTab === 'editor' ? () : null + let right = currentTab === 'editor' ? next : submit2 return (
setCurrentTab(key)} - tabBarExtraContent={{ left: title, right: next }} + tabBarExtraContent={{ left: title, right: right }} items={[ { label: "Editor", key: "editor", children: editor, forceRender: false }, { label: "Settings", key: "settings", children: form },