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:
parent
95e06cd0c9
commit
26a6f95540
2 changed files with 11 additions and 6 deletions
|
@ -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 => {
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue