mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-12-09 05:54:07 +01:00
The `node16` module resolution requires imports to use the `.js` file extension in type definitions. `@rollup/plugin-typescript` is needed to make this work with the Vite setup used by Mermaid. The module option for Mermaid internally is set to `nodenext`. This is needed to support `.json` imports. Note that setting `module` to `node16` or `nodenext` implies a matching `moduleResolution` value.
70 lines
1.4 KiB
JavaScript
70 lines
1.4 KiB
JavaScript
import { log } from '../../logger.js';
|
|
import mermaidAPI from '../../mermaidAPI.js';
|
|
import * as configApi from '../../config.js';
|
|
import common from '../common/common.js';
|
|
import {
|
|
setAccTitle,
|
|
getAccTitle,
|
|
setDiagramTitle,
|
|
getDiagramTitle,
|
|
getAccDescription,
|
|
setAccDescription,
|
|
clear as commonClear,
|
|
} from '../../commonDb.js';
|
|
|
|
let sections = {};
|
|
let showData = false;
|
|
|
|
export const parseDirective = function (statement, context, type) {
|
|
mermaidAPI.parseDirective(this, statement, context, type);
|
|
};
|
|
|
|
const addSection = function (id, value) {
|
|
id = common.sanitizeText(id, configApi.getConfig());
|
|
if (sections[id] === undefined) {
|
|
sections[id] = value;
|
|
log.debug('Added new section :', id);
|
|
}
|
|
};
|
|
const getSections = () => sections;
|
|
|
|
const setShowData = function (toggle) {
|
|
showData = toggle;
|
|
};
|
|
|
|
const getShowData = function () {
|
|
return showData;
|
|
};
|
|
|
|
const cleanupValue = function (value) {
|
|
if (value.substring(0, 1) === ':') {
|
|
value = value.substring(1).trim();
|
|
return Number(value.trim());
|
|
} else {
|
|
return Number(value.trim());
|
|
}
|
|
};
|
|
|
|
const clear = function () {
|
|
sections = {};
|
|
showData = false;
|
|
commonClear();
|
|
};
|
|
|
|
export default {
|
|
parseDirective,
|
|
getConfig: () => configApi.getConfig().pie,
|
|
addSection,
|
|
getSections,
|
|
cleanupValue,
|
|
clear,
|
|
setAccTitle,
|
|
getAccTitle,
|
|
setDiagramTitle,
|
|
getDiagramTitle,
|
|
setShowData,
|
|
getShowData,
|
|
getAccDescription,
|
|
setAccDescription,
|
|
};
|