mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-10-08 16:49:38 +02:00
Merge pull request #2175 from sidharthv96/fix/entity-decode
Remove entity-decode dependency
This commit is contained in:
@@ -52,7 +52,6 @@
|
|||||||
"d3": "^5.7.0",
|
"d3": "^5.7.0",
|
||||||
"dagre": "^0.8.4",
|
"dagre": "^0.8.4",
|
||||||
"dagre-d3": "^0.6.4",
|
"dagre-d3": "^0.6.4",
|
||||||
"entity-decode": "^2.0.2",
|
|
||||||
"graphlib": "^2.1.7",
|
"graphlib": "^2.1.7",
|
||||||
"khroma": "^1.1.0",
|
"khroma": "^1.1.0",
|
||||||
"moment-mini": "^2.22.1",
|
"moment-mini": "^2.22.1",
|
||||||
|
@@ -2,7 +2,6 @@
|
|||||||
* Web page integration module for the mermaid framework. It uses the mermaidAPI for mermaid functionality and to render
|
* Web page integration module for the mermaid framework. It uses the mermaidAPI for mermaid functionality and to render
|
||||||
* the diagrams to svg code.
|
* the diagrams to svg code.
|
||||||
*/
|
*/
|
||||||
import decode from 'entity-decode/browser';
|
|
||||||
import { log } from './logger';
|
import { log } from './logger';
|
||||||
import mermaidAPI from './mermaidAPI';
|
import mermaidAPI from './mermaidAPI';
|
||||||
import utils from './utils';
|
import utils from './utils';
|
||||||
@@ -97,7 +96,8 @@ const init = function() {
|
|||||||
txt = element.innerHTML;
|
txt = element.innerHTML;
|
||||||
|
|
||||||
// transforms the html to pure text
|
// transforms the html to pure text
|
||||||
txt = decode(txt)
|
txt = utils
|
||||||
|
.entityDecode(txt)
|
||||||
.trim()
|
.trim()
|
||||||
.replace(/<br\s*\/?>/gi, '<br/>');
|
.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 {
|
export default {
|
||||||
assignWithDepth,
|
assignWithDepth,
|
||||||
wrapLabel,
|
wrapLabel,
|
||||||
@@ -834,5 +848,6 @@ export default {
|
|||||||
random,
|
random,
|
||||||
memoize,
|
memoize,
|
||||||
runFunc,
|
runFunc,
|
||||||
|
entityDecode,
|
||||||
initIdGeneratior
|
initIdGeneratior
|
||||||
};
|
};
|
||||||
|
17
yarn.lock
17
yarn.lock
@@ -4181,12 +4181,15 @@ enhanced-resolve@^4.1.1, enhanced-resolve@^4.5.0:
|
|||||||
memory-fs "^0.5.0"
|
memory-fs "^0.5.0"
|
||||||
tapable "^1.0.0"
|
tapable "^1.0.0"
|
||||||
|
|
||||||
entity-decode@^2.0.2:
|
env-paths@^2.2.0:
|
||||||
version "2.0.2"
|
version "2.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/entity-decode/-/entity-decode-2.0.2.tgz#e4f807e52c3294246e9347d1f2b02b07fd5f92e7"
|
resolved "https://registry.yarnpkg.com/env-paths/-/env-paths-2.2.0.tgz#cdca557dc009152917d6166e2febe1f039685e43"
|
||||||
integrity sha512-5CCY/3ci4MC1m2jlumNjWd7VBFt4VfFnmSqSNmVcXq4gxM3Vmarxtt+SvmBnzwLS669MWdVuXboNVj1qN2esVg==
|
integrity sha512-6u0VYSCo/OW6IoD5WCLLy9JUGARbamfSavcNXry/eu8aHVFei6CD3Sw+VGX5alea1i9pgPHW0mbu6Xj0uBh7gA==
|
||||||
dependencies:
|
|
||||||
he "^1.1.1"
|
env-variable@0.0.x:
|
||||||
|
version "0.0.6"
|
||||||
|
resolved "https://registry.yarnpkg.com/env-variable/-/env-variable-0.0.6.tgz#74ab20b3786c545b62b4a4813ab8cf22726c9808"
|
||||||
|
integrity sha512-bHz59NlBbtS0NhftmR8+ExBEekE7br0e01jw+kk0NDro7TtZzBYZ5ScGPs3OmwnpyfHTHOtr1Y6uedCdrIldtg==
|
||||||
|
|
||||||
errno@^0.1.3, errno@~0.1.7:
|
errno@^0.1.3, errno@~0.1.7:
|
||||||
version "0.1.8"
|
version "0.1.8"
|
||||||
@@ -5524,7 +5527,7 @@ hast-util-whitespace@^1.0.0:
|
|||||||
resolved "https://registry.yarnpkg.com/hast-util-whitespace/-/hast-util-whitespace-1.0.4.tgz#e4fe77c4a9ae1cb2e6c25e02df0043d0164f6e41"
|
resolved "https://registry.yarnpkg.com/hast-util-whitespace/-/hast-util-whitespace-1.0.4.tgz#e4fe77c4a9ae1cb2e6c25e02df0043d0164f6e41"
|
||||||
integrity sha512-I5GTdSfhYfAPNztx2xJRQpG8cuDSNt599/7YUn7Gx/WxNMsG+a835k97TDkFgk123cwjfwINaZknkKkphx/f2A==
|
integrity sha512-I5GTdSfhYfAPNztx2xJRQpG8cuDSNt599/7YUn7Gx/WxNMsG+a835k97TDkFgk123cwjfwINaZknkKkphx/f2A==
|
||||||
|
|
||||||
he@^1.1.0, he@^1.1.1, he@^1.2.0:
|
he@^1.1.0, he@^1.2.0:
|
||||||
version "1.2.0"
|
version "1.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f"
|
resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f"
|
||||||
integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==
|
integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==
|
||||||
|
Reference in New Issue
Block a user