diff --git a/cSpell.json b/cSpell.json index ec2daed59..340954ba0 100644 --- a/cSpell.json +++ b/cSpell.json @@ -19,7 +19,7 @@ "brkt", "brolin", "brotli", - "Città", + "città", "classdef", "codedoc", "colour", @@ -110,11 +110,7 @@ "yash" ], "patterns": [ - { - "name": "Markdown links", - "pattern": "\\((.*)\\)", - "description": "" - }, + { "name": "Markdown links", "pattern": "\\((.*)\\)", "description": "" }, { "name": "Markdown code blocks", "pattern": "/^(\\s*`{3,}).*[\\s\\S]*?^\\1/gmx", @@ -125,25 +121,14 @@ "pattern": "\\`([^\\`\\r\\n]+?)\\`", "description": "https://stackoverflow.com/questions/41274241/how-to-capture-inline-markdown-code-but-not-a-markdown-code-fence-with-regex" }, - { - "name": "Link contents", - "pattern": "\\", - "description": "" - }, - { - "name": "Snippet references", - "pattern": "-- snippet:(.*)", - "description": "" - }, + { "name": "Link contents", "pattern": "\\", "description": "" }, + { "name": "Snippet references", "pattern": "-- snippet:(.*)", "description": "" }, { "name": "Snippet references 2", "pattern": "\\<\\[sample:(.*)", "description": "another kind of snippet reference" }, - { - "name": "Multi-line code blocks", - "pattern": "/^\\s*```[\\s\\S]*?^\\s*```/gm" - }, + { "name": "Multi-line code blocks", "pattern": "/^\\s*```[\\s\\S]*?^\\s*```/gm" }, { "name": "HTML Tags", "pattern": "<[^>]*>", diff --git a/packages/mermaid/src/config.type.ts b/packages/mermaid/src/config.type.ts index 22781411e..75d1138aa 100644 --- a/packages/mermaid/src/config.type.ts +++ b/packages/mermaid/src/config.type.ts @@ -395,4 +395,4 @@ export interface FontConfig { export type FontCalculator = () => Partial; -export { }; +export {}; diff --git a/packages/mermaid/src/diagrams/class/classDb.ts b/packages/mermaid/src/diagrams/class/classDb.ts index 451e66f0a..be5fc5ebf 100644 --- a/packages/mermaid/src/diagrams/class/classDb.ts +++ b/packages/mermaid/src/diagrams/class/classDb.ts @@ -342,7 +342,8 @@ export const relationType = { }; const setupToolTips = function (element: Element) { - let tooltipElem: Selection = select('.mermaidTooltip'); + let tooltipElem: Selection = + select('.mermaidTooltip'); // @ts-ignore - _groups is a dynamic property if ((tooltipElem._groups || tooltipElem)[0][0] === null) { tooltipElem = select('body').append('div').attr('class', 'mermaidTooltip').style('opacity', 0); diff --git a/packages/mermaid/src/diagrams/class/classDiagram.spec.ts b/packages/mermaid/src/diagrams/class/classDiagram.spec.ts index 6e170c7cb..5ff193186 100644 --- a/packages/mermaid/src/diagrams/class/classDiagram.spec.ts +++ b/packages/mermaid/src/diagrams/class/classDiagram.spec.ts @@ -1024,7 +1024,6 @@ C1 --> C2 expect(c1.label).toBe('Class 1 with text label'); expect(c1.cssClasses.length).toBe(1); expect(c1.cssClasses[0]).toBe('styleClass'); - }); it('should parse a class with text label and css class', () => { @@ -1040,7 +1039,6 @@ cssClass "C1" styleClass expect(c1.label).toBe('Class 1 with text label'); expect(c1.cssClasses.length).toBe(1); expect(c1.cssClasses[0]).toBe('styleClass'); - }); it('should parse two classes with text labels and css classes', () => { @@ -1130,7 +1128,7 @@ class C13["With Città foreign language"] expect(classDb.getClass('C9').label).toBe('With - dash'); expect(classDb.getClass('C10').label).toBe('With _ underscore'); expect(classDb.getClass('C11').label).toBe("With ' single quote"); - expect(classDb.getClass('C12').label).toBe("With ~!@#$%^&*()_+=-/?"); + expect(classDb.getClass('C12').label).toBe('With ~!@#$%^&*()_+=-/?'); expect(classDb.getClass('C13').label).toBe('With Città foreign language'); }); }); diff --git a/packages/mermaid/src/diagrams/class/classRenderer-v2.ts b/packages/mermaid/src/diagrams/class/classRenderer-v2.ts index 14af5308a..637ff9392 100644 --- a/packages/mermaid/src/diagrams/class/classRenderer-v2.ts +++ b/packages/mermaid/src/diagrams/class/classRenderer-v2.ts @@ -16,7 +16,7 @@ let conf = { dividerMargin: 10, padding: 5, textHeight: 10, - curve: undefined + curve: undefined, }; /** @@ -27,7 +27,12 @@ let conf = { * @param _id - id of the graph * @param diagObj - The diagram object */ -export const addClasses = function (classes: ClassMap, g: graphlib.Graph, _id: string, diagObj: any) { +export const addClasses = function ( + classes: ClassMap, + g: graphlib.Graph, + _id: string, + diagObj: any +) { const keys = Object.keys(classes); log.info('keys:', keys); log.info(classes); @@ -83,7 +88,12 @@ export const addClasses = function (classes: ClassMap, g: graphlib.Graph, _id: s * @param startEdgeId - starting index for note edge * @param classes - Classes */ -export const addNotes = function (notes: ClassNote[], g: graphlib.Graph, startEdgeId: number, classes: ClassMap) { +export const addNotes = function ( + notes: ClassNote[], + g: graphlib.Graph, + startEdgeId: number, + classes: ClassMap +) { log.info(notes); // Iterate through each item in the vertex object (containing all the vertices found) in the graph definition @@ -154,7 +164,7 @@ export const addNotes = function (notes: ClassNote[], g: graphlib.Graph, startEd /** * Add edges to graph based on parsed graph definition * - * @param relations - + * @param relations - * @param g - The graph object */ export const addRelations = function (relations: ClassRelation[], g: graphlib.Graph) { @@ -178,19 +188,17 @@ export const addRelations = function (relations: ClassRelation[], g: graphlib.Gr arrowTypeEnd: getArrowMarker(edge.relation.type2), style: 'fill:none', labelStyle: '', - curve: interpolateToCurve(conf?.curve, curveLinear) - } + curve: interpolateToCurve(conf?.curve, curveLinear), + }; log.info(edgeData, edge); - if (edge.style !== undefined) { const styles = getStylesFromArray(edge.style); edgeData.style = styles.style; edgeData.labelStyle = styles.labelStyle; } - edge.text = edge.title; if (edge.text === undefined) { if (edge.style !== undefined) { @@ -227,14 +235,15 @@ export const addRelations = function (relations: ClassRelation[], g: graphlib.Gr */ export const setConf = function (cnf: any) { conf = { - ...conf, ...cnf - } + ...conf, + ...cnf, + }; }; /** * Draws a flowchart in the tag with id: id based on the graph definition in text. * - * @param text - + * @param text - * @param id - * @param _version - * @param diagObj - @@ -281,9 +290,9 @@ export const draw = function (text: string, id: string, _version: string, diagOb } const root = securityLevel === 'sandbox' - // @ts-ignore Ignore type error for now + ? // @ts-ignore Ignore type error for now - ? select(sandboxElement.nodes()[0].contentDocument.body) + select(sandboxElement.nodes()[0].contentDocument.body) : select('body'); // @ts-ignore Ignore type error for now const svg = root.select(`[id="${id}"]`); diff --git a/packages/mermaid/src/diagrams/class/classTypes.ts b/packages/mermaid/src/diagrams/class/classTypes.ts index 3d7ed1488..4cacad3db 100644 --- a/packages/mermaid/src/diagrams/class/classTypes.ts +++ b/packages/mermaid/src/diagrams/class/classTypes.ts @@ -1,55 +1,55 @@ export interface ClassNode { - id: string; - type: string; - label: string; - cssClasses: string[]; - methods: string[]; - members: string[]; - annotations: string[]; - domId: string; - link?: string; - linkTarget?: string; - haveCallback?: boolean; - tooltip?: string; + id: string; + type: string; + label: string; + cssClasses: string[]; + methods: string[]; + members: string[]; + annotations: string[]; + domId: string; + link?: string; + linkTarget?: string; + haveCallback?: boolean; + tooltip?: string; } export interface ClassNote { - id: string; - class: string; - text: string; + id: string; + class: string; + text: string; } export interface EdgeData { - arrowheadStyle?: string; - labelpos?: string; - labelType?: string; - label?: string; - classes: string; - pattern: string; - id: string; - arrowhead: string; - startLabelRight: string; - endLabelLeft: string; - arrowTypeStart: string; - arrowTypeEnd: string; - style: string; - labelStyle: string; - curve: any; + arrowheadStyle?: string; + labelpos?: string; + labelType?: string; + label?: string; + classes: string; + pattern: string; + id: string; + arrowhead: string; + startLabelRight: string; + endLabelLeft: string; + arrowTypeStart: string; + arrowTypeEnd: string; + style: string; + labelStyle: string; + curve: any; } export type ClassRelation = { - id1: string, - id2: string, - relationTitle1: string, - relationTitle2: string, - type: string, - title: string, - text: string, - style: string[], - relation: { - type1: number, - type2: number, - lineType: number - } + id1: string; + id2: string; + relationTitle1: string; + relationTitle2: string; + type: string; + title: string; + text: string; + style: string[]; + relation: { + type1: number; + type2: number; + lineType: number; + }; }; -export type ClassMap = Record \ No newline at end of file +export type ClassMap = Record;