chore: bump oxlint & enable more supported rules (#14769)
This commit is contained in:
@@ -20,6 +20,7 @@ export * from './popper-position';
|
||||
export * from './print-to-pdf';
|
||||
export * from './reference';
|
||||
export * from './reordering';
|
||||
export * from './safe-html';
|
||||
export * from './signal';
|
||||
export * from './string';
|
||||
export * from './title';
|
||||
|
||||
22
blocksuite/affine/shared/src/utils/safe-html.ts
Normal file
22
blocksuite/affine/shared/src/utils/safe-html.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import DOMPurify from 'dompurify';
|
||||
import { unsafeHTML as unsafeLitHtml } from 'lit/directives/unsafe-html.js';
|
||||
|
||||
type DOMPurifyOptions = NonNullable<Parameters<typeof DOMPurify.sanitize>[1]>;
|
||||
|
||||
type SanitizeOptions = Omit<
|
||||
DOMPurifyOptions,
|
||||
'IN_PLACE' | 'RETURN_DOM' | 'RETURN_DOM_FRAGMENT' | 'RETURN_TRUSTED_TYPE'
|
||||
> & {
|
||||
IN_PLACE?: false | undefined;
|
||||
RETURN_DOM?: false | undefined;
|
||||
RETURN_DOM_FRAGMENT?: false | undefined;
|
||||
RETURN_TRUSTED_TYPE?: false | undefined;
|
||||
};
|
||||
|
||||
export function sanitizeHTML(html: string, options?: SanitizeOptions): string {
|
||||
return DOMPurify.sanitize(html, options);
|
||||
}
|
||||
|
||||
export function unsafeHTML(html: string, options?: SanitizeOptions) {
|
||||
return unsafeLitHtml(sanitizeHTML(html, options));
|
||||
}
|
||||
Reference in New Issue
Block a user