Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat: open links in help in new tabs (#2174)

ZhengXecc1f5845cb2
diff --git a/frontend/src/App.vue b/frontend/src/App.vue
index 902ada8aa2..273cb483a8 100644
--- a/frontend/src/App.vue
+++ b/frontend/src/App.vue
@@ -31,7 +31,7 @@ import { isDev } from "./utils";
import { BBNotificationItem } from "./bbkit/types";
import KBarWrapper from "./components/KBar/KBarWrapper.vue";
import BBModalStack from "./bbkit/BBModalStack.vue";
-import HelpDrawer from "@/components/HelpDrawer.vue";
+import HelpDrawer from "@/components/HelpDrawer";
import { NConfigProvider, NDialogProvider } from "naive-ui";
import { themeOverrides, dateLang, generalLang } from "../naive-ui.config";
diff --git a/frontend/src/components/HelpDrawer.vue b/frontend/src/components/HelpDrawer/HelpDrawer.vue
similarity index 92%
rename from frontend/src/components/HelpDrawer.vue
rename to frontend/src/components/HelpDrawer/HelpDrawer.vue
index 208da78c65..6cf6d32bc9 100644
--- a/frontend/src/components/HelpDrawer.vue
+++ b/frontend/src/components/HelpDrawer/HelpDrawer.vue
@@ -21,6 +21,7 @@ import { storeToRefs } from "pinia";
import { useLanguage } from "@/composables/useLanguage";
import { useUIStateStore, useHelpStore } from "@/store";
import Drawer from "@/components/Drawer.vue";
+import { markdocConfig, DOMPurifyConfig } from "./config";
interface State {
frontmatter: Record<string, string>;
@@ -50,14 +51,15 @@ export default defineComponent({
);
const markdown = await res.text();
const ast: Node = Markdoc.parse(markdown);
- const content = Markdoc.transform(ast) as Tag;
+ const content = Markdoc.transform(ast, markdocConfig) as Tag;
+
content.attributes.class = "markdown-body"; // style help content
const html: string = Markdoc.renderers.html(content);
state.frontmatter = ast.attributes.frontmatter
? (yaml.load(ast.attributes.frontmatter) as Record<string, string>)
: {};
- state.html = DOMPurify.sanitize(html);
+ state.html = DOMPurify.sanitize(html, DOMPurifyConfig);
activate();
} else {
state.frontmatter = {};
diff --git a/frontend/src/components/HelpDrawer/config.ts b/frontend/src/components/HelpDrawer/config.ts
new file mode 100644
index 0000000000..72ed206af3
--- /dev/null
+++ b/frontend/src/components/HelpDrawer/config.ts
@@ -0,0 +1,23 @@
+import { Tag } from "@markdoc/markdoc";
+
+export const markdocConfig = {
+ nodes: {
+ link: {
+ render: "a",
+ attributes: {
+ href: { type: String, required: true },
+ target: { type: String, default: "_blank" },
+ },
+ transform(node: any, config: any) {
+ const attributes = node.transformAttributes(config);
+ const children = node.transformChildren(config);
+ Object.assign(attributes, { target: "_blank" });
+ return new Tag("a", attributes, children);
+ },
+ },
+ },
+};
+
+export const DOMPurifyConfig = {
+ ADD_ATTR: ["target"],
+};
diff --git a/frontend/src/components/HelpDrawer/index.ts b/frontend/src/components/HelpDrawer/index.ts
new file mode 100644
index 0000000000..e750fa3d9b
--- /dev/null
+++ b/frontend/src/components/HelpDrawer/index.ts
@@ -0,0 +1,3 @@
+import HelpDrawer from "./HelpDrawer.vue";
+
+export default HelpDrawer;