diff --git a/src/public/app/services/link.ts b/src/public/app/services/link.ts index 17879ff22..e1a220b34 100644 --- a/src/public/app/services/link.ts +++ b/src/public/app/services/link.ts @@ -234,7 +234,7 @@ function goToLink(evt: MouseEvent | JQuery.ClickEvent) { return goToLinkExt(evt, hrefLink, $link); } -function goToLinkExt(evt: MouseEvent | JQuery.ClickEvent, hrefLink: string | undefined, $link: JQuery) { +function goToLinkExt(evt: MouseEvent | JQuery.ClickEvent, hrefLink: string | undefined, $link: JQuery | null) { if (hrefLink?.startsWith("data:")) { return true; } @@ -242,7 +242,7 @@ function goToLinkExt(evt: MouseEvent | JQuery.ClickEvent, hrefLink: string | und evt.preventDefault(); evt.stopPropagation(); - if (hrefLink?.startsWith("#fn")) { + if (hrefLink?.startsWith("#fn") && $link) { return handleFootnote(hrefLink, $link); } diff --git a/src/public/app/types.d.ts b/src/public/app/types.d.ts index 4c53d181f..878391322 100644 --- a/src/public/app/types.d.ts +++ b/src/public/app/types.d.ts @@ -54,6 +54,72 @@ declare global { process?: ElectronProcess; glob?: CustomGlobals; + React: { + createElement(any, any?, any?); + Fragment: any; + useState({ + width: undefined, + height: undefined + }); + useRef(ref: null); + useEffect(cb: () => void, args: unknown[]); + useCallback(cb: (el, ev) => void, args: unknown[]); + }; + ReactDOM: { + unmountComponentAtNode(el: HTMLElement); + createRoot(el: HTMLElement); + } + ExcalidrawLib: { + getSceneVersion(el: unknown[]): number; + exportToSvg(opts: { + elements: ExcalidrawElement[], + appState: ExcalidrawAppState, + exportPadding: number, + metadata: string, + files: ExcalidrawElement[] + }): Promise; + updateScene, + Excalidraw: unknown + } + EXCALIDRAW_ASSET_PATH: string; + } + + interface ExcalidrawApi { + getSceneElements(): ExcalidrawElement[]; + getAppState(): ExcalidrawAppState; + getFiles(): ExcalidrawElement[]; + updateScene(scene: ExcalidrawScene); + updateLibrary(opts: { libraryItems?: ExcalidrawLibrary[], merge: boolean }): Promise; + addFiles(files: ExcalidrawElement[]); + history: { + clear(); + } + } + + interface ExcalidrawElement { + fileId: number; + } + + interface ExcalidrawLibrary { + id: string; + name: string; + } + + interface ExcalidrawScene { + elements: unknown[]; + appState: ExcalidrawAppState; + collaborators: unknown[]; + } + + interface ExcalidrawAppState { + scrollX?: number; + scrollY?: number; + zoom?: number; + theme?: string; + width?: number; + height?: number; + offsetLeft?: number; + offsetTop?: number; } interface AutoCompleteConfig { diff --git a/src/public/app/widgets/type_widgets/canvas.js b/src/public/app/widgets/type_widgets/canvas.ts similarity index 93% rename from src/public/app/widgets/type_widgets/canvas.js rename to src/public/app/widgets/type_widgets/canvas.ts index 42ee54720..bdee2783e 100644 --- a/src/public/app/widgets/type_widgets/canvas.js +++ b/src/public/app/widgets/type_widgets/canvas.ts @@ -3,6 +3,7 @@ import TypeWidget from "./type_widget.js"; import utils from "../../services/utils.js"; import linkService from "../../services/link.js"; import server from "../../services/server.js"; +import type FNote from "../../entities/fnote.js"; const TPL = `