Skip to content

Build your personal knowledge base with Trilium Notes

chore(core): reuse the escapeHtml from commons

Elian Doran0a4e74444d07
diff --git a/packages/trilium-core/src/services/utils/index.ts b/packages/trilium-core/src/services/utils/index.ts
index ac7a786368..f0979fea8e 100644
--- a/packages/trilium-core/src/services/utils/index.ts
+++ b/packages/trilium-core/src/services/utils/index.ts
@@ -9,6 +9,8 @@ import { extensions as mimeToExt, types as extToMime } from "mime-types";
import { basename, extname } from "./path";
import { NoteMeta } from "../../meta";
+export { escapeHtml } from "@triliumnext/commons/src/lib/utils.js";
+
export function isDev() { return getPlatform().getEnv("TRILIUM_ENV") === "dev"; }
export function isElectron() { return getPlatform().isElectron; }
export function isStandalone() { return getPlatform().isStandalone; }
@@ -284,15 +286,6 @@ export function toMap<T extends Record<string, any>>(list: T[], key: keyof T) {
return map;
}
-const HTML_ESCAPES: Record<string, string> = {
- "&": "&amp;", "<": "&lt;", ">": "&gt;", "\"": "&quot;", "'": "&#39;"
-};
-
-/** Escapes `&`, `<`, `>`, `"` and `'`, so the result is safe in element content and quoted attributes. */
-export function escapeHtml(str: string): string {
- return str.replace(/[&<>"']/g, (char) => HTML_ESCAPES[char]);
-}
-
/**
* Escapes `value` for use inside a double-quoted CSS string, one hex escape per character.
* Covers the markup characters alongside the quote and the backslash, because the HTML