1 line
18 KiB
Plaintext
1 line
18 KiB
Plaintext
|
{"version":3,"file":"classDiagram-v2-6bb7b84a.js","sources":["../src/diagrams/class/classRenderer-v2.ts","../src/diagrams/class/classDiagram-v2.ts"],"sourcesContent":["// @ts-ignore d3 types are not available\nimport { select, curveLinear } from 'd3';\nimport * as graphlib from 'dagre-d3-es/src/graphlib/index.js';\nimport { log } from '../../logger';\nimport { getConfig } from '../../config';\nimport { render } from '../../dagre-wrapper/index.js';\nimport utils from '../../utils';\nimport { interpolateToCurve, getStylesFromArray } from '../../utils';\nimport { setupGraphViewbox } from '../../setupGraphViewbox';\nimport common from '../common/common';\nimport { ClassRelation, ClassNote, ClassMap, EdgeData } from './classTypes';\n\nconst sanitizeText = (txt: string) => common.sanitizeText(txt, getConfig());\n\nlet conf = {\n dividerMargin: 10,\n padding: 5,\n textHeight: 10,\n curve: undefined,\n};\n\n/**\n * Function that adds the vertices found during parsing to the graph to be rendered.\n *\n * @param classes - Object containing the vertices.\n * @param g - The graph that is to be drawn.\n * @param _id - id of the graph\n * @param diagObj - The diagram object\n */\nexport const addClasses = function (\n classes: ClassMap,\n g: graphlib.Graph,\n _id: string,\n diagObj: any\n) {\n const keys = Object.keys(classes);\n log.info('keys:', keys);\n log.info(classes);\n\n // Iterate through each item in the vertex object (containing all the vertices found) in the graph definition\n keys.forEach(function (id) {\n const vertex = classes[id];\n\n /**\n * Variable for storing the classes for the vertex\n */\n let cssClassStr = '';\n if (vertex.cssClasses.length > 0) {\n cssClassStr = cssClassStr + ' ' + vertex.cssClasses.join(' ');\n }\n\n const styles = { labelStyle: '', style: '' }; //getStylesFromArray(vertex.styles);\n\n // Use vertex id as text in the box if no text is provided by the graph definition\n const vertexText = vertex.label ?? vertex.id;\n const radius = 0;\n const shape = 'class_box';\n // Add the node\n const node = {\n labelStyle: styles.labelStyle,\n shape: shape,\n labelText: sanitizeText(vertexText),\n classData: vertex,\n rx: radius,\n ry: radius,\n class: cssClassStr,\n style: styles.style,\n id: vertex.id,\n domId: vertex.domId,\n tooltip: diagObj.db.getTooltip(vertex.id) || '',\n haveCallback: vertex.haveCallback,\n link: vertex.link,\n width: vertex.type === 'group' ? 500 : undefined,\n type: vertex.type,\n // TODO V10: Flowchart ? Keeping flowchart for backwards compatibility. Remove in next major release\n padding: getConfig().flowchart?.padding ?? getConfig().class?.padding,\n };\n g.setNode(vertex.id, node);\n log.info('setNode', node);\n });\n};\n\n/**\n * Function that adds the additional vertices (notes) found during parsing to the graph to be rendered.\n *\n * @param notes - Object containing the additional vertices (notes).\n * @param g - The graph that is to be drawn.\n * @param startEdgeId - starting index for note edge\n * @param classes - Classes\n */\nexport const addNotes = function (\n notes: ClassNote[],\n g: graphlib.Graph,\n startEdgeId: number,\n classes: ClassMap\n) {\n log.info(notes);\n\n // Iterate through each item in the vertex object (containing all the vertices found) in the graph definition\n notes.forEach(function (note, i) {\n const vertex = note;\n\n /**\n * Variable for storing the classes for the vertex\n *\n */\n const cssNoteStr = '';\n\n const styles = { labelStyle: '', style: '' };\n\n // Use vertex id as text in the box if no text is provided by the graph definition\n const vertexText = vertex.text;\n\n const radius = 0;\n const shape = 'note';\n // Add the node\n const node = {\n labelStyle: styles.labelStyle,\n shape: shape,\n labelText: sanitizeText(vertexText),\n noteData: vertex,\n rx: radius,\n ry: radius,\n class: cssNoteS
|