Fix #1603 Remove entity-decode Dependency.
This commit is contained in:
parent
5070d992dd
commit
862330a576
|
@ -52,9 +52,7 @@
|
|||
"d3": "^5.7.0",
|
||||
"dagre": "^0.8.4",
|
||||
"dagre-d3": "^0.6.4",
|
||||
"entity-decode": "^2.0.2",
|
||||
"graphlib": "^2.1.7",
|
||||
"he": "^1.2.0",
|
||||
"khroma": "^1.1.0",
|
||||
"minify": "^4.1.1",
|
||||
"moment-mini": "^2.22.1",
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
* Web page integration module for the mermaid framework. It uses the mermaidAPI for mermaid functionality and to render
|
||||
* the diagrams to svg code.
|
||||
*/
|
||||
// import { decode } from 'he';
|
||||
import decode from 'entity-decode/browser';
|
||||
import { log } from './logger';
|
||||
import mermaidAPI from './mermaidAPI';
|
||||
import utils from './utils';
|
||||
|
@ -98,7 +96,8 @@ const init = function() {
|
|||
txt = element.innerHTML;
|
||||
|
||||
// transforms the html to pure text
|
||||
txt = decode(txt)
|
||||
txt = utils
|
||||
.entityDecode(txt)
|
||||
.trim()
|
||||
.replace(/<br\s*\/?>/gi, '<br/>');
|
||||
|
||||
|
|
15
src/utils.js
15
src/utils.js
|
@ -812,6 +812,20 @@ export const initIdGeneratior = class iterator {
|
|||
}
|
||||
};
|
||||
|
||||
// Source https://github.com/shrpne/entity-decode/blob/master/browser.js
|
||||
let decoder;
|
||||
export const entityDecode = function(html) {
|
||||
decoder = decoder || document.createElement('div');
|
||||
// Escape HTML before decoding for HTML Entities
|
||||
html = escape(html)
|
||||
.replace(/%26/g, '&')
|
||||
.replace(/%23/g, '#')
|
||||
.replace(/%3B/g, ';');
|
||||
// decoding
|
||||
decoder.innerHTML = html;
|
||||
return unescape(decoder.textContent);
|
||||
};
|
||||
|
||||
export default {
|
||||
assignWithDepth,
|
||||
wrapLabel,
|
||||
|
@ -834,5 +848,6 @@ export default {
|
|||
random,
|
||||
memoize,
|
||||
runFunc,
|
||||
entityDecode,
|
||||
initIdGeneratior
|
||||
};
|
||||
|
|
|
@ -4120,13 +4120,6 @@ enhanced-resolve@^4.1.0:
|
|||
memory-fs "^0.5.0"
|
||||
tapable "^1.0.0"
|
||||
|
||||
entity-decode@^2.0.2:
|
||||
version "2.0.2"
|
||||
resolved "https://registry.yarnpkg.com/entity-decode/-/entity-decode-2.0.2.tgz#e4f807e52c3294246e9347d1f2b02b07fd5f92e7"
|
||||
integrity sha512-5CCY/3ci4MC1m2jlumNjWd7VBFt4VfFnmSqSNmVcXq4gxM3Vmarxtt+SvmBnzwLS669MWdVuXboNVj1qN2esVg==
|
||||
dependencies:
|
||||
he "^1.1.1"
|
||||
|
||||
env-paths@^2.2.0:
|
||||
version "2.2.0"
|
||||
resolved "https://registry.yarnpkg.com/env-paths/-/env-paths-2.2.0.tgz#cdca557dc009152917d6166e2febe1f039685e43"
|
||||
|
@ -5428,7 +5421,7 @@ hast-util-whitespace@^1.0.0:
|
|||
resolved "https://registry.yarnpkg.com/hast-util-whitespace/-/hast-util-whitespace-1.0.3.tgz#6d161b307bd0693b5ec000c7c7e8b5445109ee34"
|
||||
integrity sha512-AlkYiLTTwPOyxZ8axq2/bCwRUPjIPBfrHkXuCR92B38b3lSdU22R5F/Z4DL6a2kxWpekWq1w6Nj48tWat6GeRA==
|
||||
|
||||
he@^1.1.0, he@^1.1.1, he@^1.2.0:
|
||||
he@^1.1.0, he@^1.2.0:
|
||||
version "1.2.0"
|
||||
resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f"
|
||||
integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==
|
||||
|
|
Loading…
Reference in New Issue