Move decodeHTMLEntities util into headless
This commit is contained in:
parent
8701708b53
commit
2f7dcb6bbc
@ -2,7 +2,7 @@ import dayjs from 'dayjs';
|
||||
import sizzle from 'sizzle';
|
||||
import { Strophe } from 'strophe.js/src/strophe';
|
||||
import { _converse, api } from '@converse/headless/core';
|
||||
import { decodeHTMLEntities } from 'shared/utils';
|
||||
import { decodeHTMLEntities } from '@converse/headless/shared/utils';
|
||||
import { rejectMessage } from '@converse/headless/shared/actions';
|
||||
|
||||
const { NS } = Strophe;
|
||||
|
@ -2,6 +2,7 @@ import Storage from '@converse/skeletor/src/storage.js';
|
||||
import log from '@converse/headless/log';
|
||||
import { _converse, api } from '@converse/headless/core';
|
||||
import { getOpenPromise } from '@converse/openpromise';
|
||||
import xss from 'xss/dist/xss';
|
||||
|
||||
export function getDefaultStore () {
|
||||
if (_converse.config.get('trusted')) {
|
||||
@ -45,3 +46,14 @@ export function replacePromise (name) {
|
||||
log.debug(`Not replacing promise "${name}"`);
|
||||
}
|
||||
}
|
||||
|
||||
const element = document.createElement('div');
|
||||
|
||||
export function decodeHTMLEntities (str) {
|
||||
if (str && typeof str === 'string') {
|
||||
element.innerHTML = xss.filterXSS(str);
|
||||
str = element.textContent;
|
||||
element.textContent = '';
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
@ -1,12 +0,0 @@
|
||||
import xss from 'xss/dist/xss';
|
||||
|
||||
const element = document.createElement('div');
|
||||
|
||||
export function decodeHTMLEntities (str) {
|
||||
if (str && typeof str === 'string') {
|
||||
element.innerHTML = xss.filterXSS(str);
|
||||
str = element.textContent;
|
||||
element.textContent = '';
|
||||
}
|
||||
return str;
|
||||
}
|
Loading…
Reference in New Issue
Block a user