This commit is contained in:
Sidharth Vinod
2023-02-14 10:56:16 +05:30
parent e1710fddd9
commit 10e6c92766
6 changed files with 75 additions and 82 deletions

View File

@@ -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": "\\<a(.*)\\>",
"description": ""
},
{
"name": "Snippet references",
"pattern": "-- snippet:(.*)",
"description": ""
},
{ "name": "Link contents", "pattern": "\\<a(.*)\\>", "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": "<[^>]*>",

View File

@@ -342,7 +342,8 @@ export const relationType = {
};
const setupToolTips = function (element: Element) {
let tooltipElem: Selection<HTMLDivElement, unknown, HTMLElement, unknown> = select('.mermaidTooltip');
let tooltipElem: Selection<HTMLDivElement, unknown, HTMLElement, unknown> =
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);

View File

@@ -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');
});
});

View File

@@ -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
@@ -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,8 +235,9 @@ export const addRelations = function (relations: ClassRelation[], g: graphlib.Gr
*/
export const setConf = function (cnf: any) {
conf = {
...conf, ...cnf
}
...conf,
...cnf,
};
};
/**
@@ -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}"]`);

View File

@@ -38,18 +38,18 @@ export interface EdgeData {
}
export type ClassRelation = {
id1: string,
id2: string,
relationTitle1: string,
relationTitle2: string,
type: string,
title: string,
text: string,
style: string[],
id1: string;
id2: string;
relationTitle1: string;
relationTitle2: string;
type: string;
title: string;
text: string;
style: string[];
relation: {
type1: number,
type2: number,
lineType: number
}
type1: number;
type2: number;
lineType: number;
};
export type ClassMap = Record<string, ClassNode>
};
export type ClassMap = Record<string, ClassNode>;