mirror of
https://github.com/laurent22/joplin.git
synced 2025-01-02 12:47:41 +02:00
All: Include injected Mermaid JS only when necessary
This commit is contained in:
parent
833d473268
commit
945d83608a
@ -1,5 +1,4 @@
|
||||
const { shim } = require('lib/shim');
|
||||
const injectedJs = require('lib/rnInjectedJs/mermaid');
|
||||
|
||||
class MdToHtml_Mermaid {
|
||||
|
||||
@ -20,7 +19,8 @@ class MdToHtml_Mermaid {
|
||||
}
|
||||
|
||||
injectedJavaScript() {
|
||||
return injectedJs + '\n' + 'mermaid.init();';
|
||||
const js = shim.injectedJs('mermaid');
|
||||
return js ? js + '\n' + 'mermaid.init();' : '';
|
||||
}
|
||||
|
||||
async loadAssets() {}
|
||||
|
@ -12,6 +12,10 @@ const { basename, fileExtension } = require('lib/path-utils.js');
|
||||
const { uuid } = require('lib/uuid.js');
|
||||
const Resource = require('lib/models/Resource');
|
||||
|
||||
const injectedJs = {
|
||||
mermaid: require('lib/rnInjectedJs/mermaid'),
|
||||
};
|
||||
|
||||
function shimInit() {
|
||||
shim.Geolocation = GeolocationReact;
|
||||
shim.setInterval = PoorManIntervals.setInterval;
|
||||
@ -164,6 +168,11 @@ function shimInit() {
|
||||
return resource;
|
||||
}
|
||||
|
||||
shim.injectedJs = function(name) {
|
||||
if (name in injectedJs) return injectedJs[name];
|
||||
return '';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = { shimInit };
|
@ -149,5 +149,6 @@ shim.imageFromDataUrl = async function(imageDataUrl, filePath, options = null) {
|
||||
shim.Buffer = null;
|
||||
shim.openUrl = () => { throw new Error('Not implemented'); }
|
||||
shim.waitForFrame = () => { throw new Error('Not implemented'); }
|
||||
shim.injectedJs = name => '';
|
||||
|
||||
module.exports = { shim };
|
||||
|
Loading…
Reference in New Issue
Block a user