Skip to content

Build your personal knowledge base with Trilium Notes

chore(client): get rid of data-in-app-help-page

Elian Doranf8ad52bcfa11
diff --git a/apps/client/src/services/glob.ts b/apps/client/src/services/glob.ts
index 44ce643094..84b644f4ff 100644
--- a/apps/client/src/services/glob.ts
+++ b/apps/client/src/services/glob.ts
@@ -75,8 +75,6 @@ function setupGlobs() {
requireCss(`api/notes/download/${appCssNoteId}`, false);
}
- utils.initHelpButtons($(window));
-
$("body").on("click", "a.external", function () {
window.open($(this).attr("href"), "_blank");
diff --git a/apps/client/src/services/utils.ts b/apps/client/src/services/utils.ts
index 410db6c2d0..4123258269 100644
--- a/apps/client/src/services/utils.ts
+++ b/apps/client/src/services/utils.ts
@@ -404,20 +404,6 @@ function initHelpDropdown($el: JQuery<HTMLElement>) {
// stop inside clicks from closing the menu
const $dropdownMenu = $el.find(".help-dropdown .dropdown-menu");
$dropdownMenu.on("click", (e) => e.stopPropagation());
-
- // previous propagation stop will also block help buttons from being opened, so we need to re-init for this element
- initHelpButtons($dropdownMenu);
-}
-
-async function openInAppHelp($button: JQuery<HTMLElement>) {
- if ($button.length === 0) {
- return;
- }
-
- const inAppHelpPage = $button.attr("data-in-app-help");
- if (inAppHelpPage) {
- openInAppHelpFromUrl(inAppHelpPage);
- }
}
/**
@@ -462,14 +448,6 @@ export async function openInReusableSplit(targetNoteId: string, targetViewMode:
}
}
-function initHelpButtons($el: JQuery<HTMLElement> | JQuery<Window>) {
- // for some reason, the .on(event, listener, handler) does not work here (e.g. Options -> Sync -> Help button)
- // so we do it manually
- $el.on("click", (e) => {
- openInAppHelp($(e.target).closest("[data-in-app-help]"));
- });
-}
-
function filterAttributeName(name: string) {
return name.replace(/[^\p{L}\p{N}_:]/gu, "");
}
@@ -929,7 +907,6 @@ export default {
dynamicRequire,
timeLimit,
initHelpDropdown,
- initHelpButtons,
filterAttributeName,
isValidAttributeName,
sleep,
diff --git a/apps/client/src/widgets/react/Modal.tsx b/apps/client/src/widgets/react/Modal.tsx
index f84bac3222..e642c4de5b 100644
--- a/apps/client/src/widgets/react/Modal.tsx
+++ b/apps/client/src/widgets/react/Modal.tsx
@@ -5,6 +5,7 @@ import { useEffect, useMemo, useRef } from "preact/hooks";
import { openDialog } from "../../services/dialog";
import { t } from "../../services/i18n";
+import { openInAppHelpFromUrl } from "../../services/utils";
import { useSyncedRef } from "./hooks";
interface CustomTitleBarButton {
@@ -170,7 +171,7 @@ export default function Modal({ children, className, size, title, customTitleBar
)}
{header}
{helpPageId && (
- <button className="help-button" type="button" data-in-app-help={helpPageId} title={t("modal.help_title")}>?</button>
+ <button className="help-button" type="button" onClick={() => openInAppHelpFromUrl(helpPageId)} title={t("modal.help_title")}>?</button>
)}
{titleBarButtons?.filter((b) => b !== null).map((titleBarButton) => (