all repos — snow-editor @ main

small and cozy markdown, and orgmode editor

src/lib/org/sanitize.js (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
import DOMPurify from 'dompurify';
import { ORG_SANITIZE_OPTIONS } from './constants.js';

export function sanitizeOrgHtml(html) {
  if (!html) return '';
  if (typeof window === 'undefined' || !window.document) {
    return html;
  }
  return DOMPurify.sanitize(html, ORG_SANITIZE_OPTIONS);
}