mirror of
https://gitee.com/tawords/tawords-docs
synced 2025-09-11 04:41:39 +08:00
CSS JS文件本地化提高加载速度
This commit is contained in:
51
docs/static/docsify/lib/plugins/docsify-drawio/drawio.js
vendored
Normal file
51
docs/static/docsify/lib/plugins/docsify-drawio/drawio.js
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
(function () {
|
||||
// 下面是解析的部分
|
||||
const chatMap = {
|
||||
"&": "&",
|
||||
"'": "'",
|
||||
"`": "`",
|
||||
'"': """,
|
||||
"<": "<",
|
||||
">": ">",
|
||||
};
|
||||
const escapeHTML = (string) => {
|
||||
if (typeof string !== "string") return string;
|
||||
return string.replace(/[&'`"<>]/g, function (match) {
|
||||
return chatMap[match];
|
||||
});
|
||||
};
|
||||
window.drawioConverter = function (xml, idx = new Date().getTime()) {
|
||||
let mxGraphData = {
|
||||
editable: false,
|
||||
highlight: "#0000ff",
|
||||
nav: false,
|
||||
toolbar: null,
|
||||
edit: null,
|
||||
resize: true,
|
||||
lightbox: "open",
|
||||
// "check-visible-state": false,
|
||||
// "auto-fit": false,
|
||||
// move: false,
|
||||
xml,
|
||||
};
|
||||
|
||||
const json = JSON.stringify(mxGraphData);
|
||||
|
||||
return `<div class="drawio-viewer-index-${idx}">
|
||||
<div class="mxgraph" style="max-width: 100%; border: 1px solid transparent" data-mxgraph="${escapeHTML(json)}"></div>
|
||||
</div>
|
||||
`;
|
||||
};
|
||||
|
||||
// 下面是插件加载部分
|
||||
|
||||
const install = function (hook) {
|
||||
hook.doneEach((hook) => {
|
||||
try {
|
||||
window.GraphViewer.processElements();
|
||||
} catch {}
|
||||
});
|
||||
};
|
||||
|
||||
window.$docsify.plugins = [].concat(install, $docsify.plugins);
|
||||
})();
|
3963
docs/static/docsify/lib/plugins/docsify-drawio/viewer.min.js
vendored
Normal file
3963
docs/static/docsify/lib/plugins/docsify-drawio/viewer.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user