Merge remote-tracking branch 'origin/release/9.1.7' into sidv/mergeRelease

* origin/release/9.1.7:
  Release 9.1.7
  Fix for broken rendering test
  Fix for issue #3428, load the configured diagrams even when initialize has not been called.
This commit is contained in:
Sidharth Vinod
2022-09-14 11:11:12 +05:30
9 changed files with 103 additions and 13 deletions

View File

@@ -26,7 +26,7 @@ import flowDb from './diagrams/flowchart/flowDb';
import flowRenderer from './diagrams/flowchart/flowRenderer';
import ganttDb from './diagrams/gantt/ganttDb';
import Diagram from './Diagram';
import errorRenderer from './errorRenderer';
import errorRenderer from './diagrams/error/errorRenderer';
import { attachFunctions } from './interactionDb';
import { log, setLogLevel } from './logger';
import getStyles from './styles';
@@ -124,6 +124,10 @@ const render = function (
cb: (svgCode: string, bindFunctions?: (element: Element) => void) => void,
container?: Element
): void {
if (!hasLoadedDiagrams) {
addDiagrams();
hasLoadedDiagrams = true;
}
configApi.reset();
text = text.replace(/\r\n?/g, '\n'); // parser problems on CRLF ignore all CR and leave LF;;
const graphInit = utils.detectInit(text);
@@ -228,7 +232,14 @@ const render = function (
text = encodeEntities(text);
// Important that we do not create the diagram until after the directives have been included
const diag = new Diagram(text);
let diag;
let parseEncounteredException;
try {
diag = new Diagram(text);
} catch (error) {
diag = new Diagram('error');
parseEncounteredException = error;
}
// Get the tmp element containing the the svg
const element = root.select('#d' + id).node();
const graphType = diag.type;
@@ -371,6 +382,10 @@ const render = function (
node.remove();
}
if (parseEncounteredException) {
throw parseEncounteredException;
}
return svgCode;
};