Lazy loading fix for example-diagram and mindmaps

This commit is contained in:
Knut Sveidqvist
2022-10-03 07:01:56 +02:00
parent 02a0f87562
commit 56add0756f
12 changed files with 334 additions and 26 deletions

View File

@@ -1,3 +1,10 @@
/**
* Detector function that will be called by mermaid to determine if the diagram is this type of digram.
*
* @param txt The diagram text will be passed to the detector
* @returns True if the diagram text matches a diagram of this type
*/
export const detector = (txt: string) => {
return txt.match(/^\s*example-diagram/) !== null;
};

View File

@@ -13,21 +13,29 @@ export const getMessage = () => {
return message;
};
/**
* Sets the info flag
*
* @param {boolean} inf
*/
export const setInfo = (inf) => {
info = inf;
};
/** @returns Returns the info flag */
export const getInfo = () => {
return info;
};
export const clear = () => {
message = '';
info = false;
};
export default {
setMessage,
getMessage,
setInfo,
getInfo,
clear: () => {
message = '';
info = false;
},
clear,
};

View File

@@ -8,7 +8,7 @@
%%
"info" return 'info' ;
"example-diagram" return 'example-diagram' ;
[\s\n\r]+ return 'NL' ;
[\s]+ return 'space';
"showInfo" return 'showInfo';
@@ -22,8 +22,8 @@
%% /* language grammar */
start
// %{ : info document 'EOF' { return yy; } }
: info document 'EOF' { return yy; }
// %{ : example-diagram document 'EOF' { return yy; } }
: example-diagram document 'EOF' { return yy; }
;
document