1
0
Fork 0
mirror of https://github.com/anyproto/anytype-ts.git synced 2025-06-07 21:47:02 +09:00

fix latex

This commit is contained in:
Andrew Simachev 2025-06-06 12:14:24 +02:00
parent 95e06cd0c9
commit 26a6f95540
No known key found for this signature in database
GPG key ID: 1DFE44B21443F0EF
2 changed files with 11 additions and 6 deletions

View file

@ -98,7 +98,7 @@ const Editable = forwardRef<EditableRefProps, Props>(({
};
const setValue = (html: string) => {
$(editableRef.current).get(0).innerHTML = U.Common.sanitize(html);
$(editableRef.current).get(0).innerHTML = U.Common.sanitize(html, true);
};
const getTextValue = (): string => {

View file

@ -1324,7 +1324,7 @@ class UtilCommon {
* @param {string} s - The string to sanitize.
* @returns {string} The sanitized string.
*/
sanitize (s: string): string {
sanitize (s: string, withStyles?: boolean): string {
s = String(s || '');
if (!TEST_HTML.test(s)) {
@ -1332,13 +1332,18 @@ class UtilCommon {
};
const tags = [ 'b', 'br', 'a', 'ul', 'li', 'h1', 'span', 'p', 'name', 'smile', 'img' ].concat(Object.values(Mark.getTags()));
return DOMPurify.sanitize(s, {
const param: any = {
ADD_TAGS: tags,
ADD_ATTR: [ 'contenteditable' ],
ALLOWED_URI_REGEXP: /^(?:(?:[a-z]+):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,
FORBID_ATTR: [ 'style' ],
});
FORBID_ATTR: [],
};
if (!withStyles) {
param.FORBID_ATTR.push('style');
};
return DOMPurify.sanitize(s, param);
};
/**