Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(badges/content): add support for web view
Elian Doran5a2b04adba37
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 2f78d6a341..ea5fda411a 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -2296,6 +2296,7 @@"type_widget": "Widget","type_app_css": "Custom CSS","type_render_note": "Render note",+ "type_web_view": "Web view","toggle_tooltip_enable_tooltip": "Click to enable this {{type}}.","toggle_tooltip_disable_tooltip": "Click to disable this {{type}}.","menu_docs": "Open documentation",diff --git a/apps/client/src/widgets/layout/ActiveContentBadges.tsx b/apps/client/src/widgets/layout/ActiveContentBadges.tsxindex d39ab75f36..644ad7c49e 100644--- a/apps/client/src/widgets/layout/ActiveContentBadges.tsx+++ b/apps/client/src/widgets/layout/ActiveContentBadges.tsx@@ -14,7 +14,7 @@ const DANGEROUS_ATTRIBUTES = BUILTIN_ATTRIBUTES.filter(a => a.isDangerous || a.nconst activeContentLabels = [ "iconPack", "widget", "appCss" ] as const;interface ActiveContentInfo {- type: "iconPack" | "backendScript" | "frontendScript" | "widget" | "appCss" | "renderNote";+ type: "iconPack" | "backendScript" | "frontendScript" | "widget" | "appCss" | "renderNote" | "webView";isEnabled: boolean;canToggleEnabled: boolean;}@@ -52,6 +52,10 @@ const typeMappings: Record<ActiveContentInfo["type"], {renderNote: {icon: "bx bx-extension",helpPage: "HcABDtFCkbFN"+ },+ webView: {+ icon: "bx bx-globe",+ helpPage: "1vHRoWCEjj0L"}};@@ -194,6 +198,8 @@ function getTranslationForType(type: ActiveContentInfo["type"]) {return t("active_content_badges.type_app_css");case "renderNote":return t("active_content_badges.type_render_note");+ case "webView":+ return t("note_types.web-view");}}@@ -251,6 +257,10 @@ function useActiveContentInfo(note: FNote | null | undefined) {type = "renderNote";isEnabled = note.hasRelation("renderNote");canToggleEnabled = note.hasRelation("renderNote") || note.hasRelation("disabled:renderNote");+ } else if (note.type === "webView") {+ type = "webView";+ isEnabled = note.hasLabel("webViewSrc");+ canToggleEnabled = note.hasLabelOrDisabled("webViewSrc");} else if (note.type === "code" && note.mime === "application/javascript;env=backend") {type = "backendScript";for (const backendLabel of [ "run", "customRequestHandler", "customResourceProvider" ]) {