Skip to content

Commit

Permalink
#3336 Merged typescript changes
Browse files Browse the repository at this point in the history
  • Loading branch information
knsv committed Sep 5, 2022
1 parent 01106ca commit 8b4a08e
Show file tree
Hide file tree
Showing 12 changed files with 96 additions and 57 deletions.
Binary file added cypress/downloads/downloads.html
Binary file not shown.
30 changes: 8 additions & 22 deletions cypress/platform/knsv.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,10 @@
</style>
</head>
<body>
<pre class="mermaid2" style="width: 50%">
flowchart LR
classDef aPID stroke:#4e4403,fill:#fdde29,color:#4e4403,rx:5px,ry:5px;
classDef crm stroke:#333333,fill:#DCDCDC,color:#333333,rx:5px,ry:5px;
classDef type stroke:#502604,fill:#FAB565,color:#502604,rx:20px,ry:20px;;

O0("Joe")
class O0 aPID;

O1("Person")
class O1 crm;
O0 -- has type -->O1["Person"]

O2("aat:300411314")
class O2 type;
click O2 function "Sorry the newline html tags are not being processed correctly<br/> So all of this appears on the <br/> same line."
O0 -- has type -->O2["Bug"]
click O0 function "Lots of great info about Joe<br>Lots of great info about Joe<br>burt<br>fred";
<pre class="mermaid" style="width: 50%">
mindmap
apa
bapa
</pre>
<pre class="mermaid2" style="width: 50%">
flowchart TD
Expand All @@ -77,14 +63,14 @@
end

</div>
<div class="mermaid" style="width: 50%;">
<div class="mermaid2" style="width: 50%;">
flowchart TD
id
</div>
<div class="mermaid2" style="width: 50%;">
<pre class="mermaid2" style="width: 50%;">
flowchart LR
a["<strong>Haiya</strong>"]===>b
</div>
</pre>
<div class="mermaid2" style="width: 50%;">
flowchart TD
A --> B
Expand Down Expand Up @@ -122,7 +108,7 @@

linkStyle 1 stroke:#ff3,stroke-width:4px,color:red;
</pre>
<pre class="mermaid2" style="width: 100%">
<pre class="mermaid" style="width: 100%">
journey
accTitle: My User Journey Diagram
accDescr: My User Journey Diagram Description
Expand Down
62 changes: 34 additions & 28 deletions docs/Setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ Theme , the CSS style sheet

**Notes:**

- Trace: 0
- Debug: 1
- Info: 2
- Warn: 3
- Error: 4
- Fatal: 5 (default)
- Trace: 0
- Debug: 1
- Info: 2
- Warn: 3
- Error: 4
- Fatal: 5 (default)

## securityLevel

Expand All @@ -79,13 +79,13 @@ Theme , the CSS style sheet

**Notes**:

- **strict**: (**default**) tags in text are encoded, click functionality is disabled
- **loose**: tags in text are allowed, click functionality is enabled
- **antiscript**: html tags in text are allowed, (only script element is removed), click
functionality is enabled
- **sandbox**: With this security level all rendering takes place in a sandboxed iframe. This
prevent any JavaScript from running in the context. This may hinder interactive functionality
of the diagram like scripts, popups in sequence diagram or links to other tabs/targets etc.
- **strict**: (**default**) tags in text are encoded, click functionality is disabled
- **loose**: tags in text are allowed, click functionality is enabled
- **antiscript**: html tags in text are allowed, (only script element is removed), click
functionality is enabled
- **sandbox**: With this security level all rendering takes place in a sandboxed iframe. This
prevent any JavaScript from running in the context. This may hinder interactive functionality
of the diagram like scripts, popups in sequence diagram or links to other tabs/targets etc.

## startOnLoad

Expand Down Expand Up @@ -1420,7 +1420,7 @@ function _Default value: At default, will mirror Global Config_

### Parameters

- `conf` **MermaidConfig** The base currentConfig to use as siteConfig
- `conf` **MermaidConfig** The base currentConfig to use as siteConfig

Returns **[object][5]** The siteConfig

Expand Down Expand Up @@ -1450,7 +1450,7 @@ corresponding siteConfig value.

### Parameters

- `conf` **any** The potential currentConfig
- `conf` **any** The potential currentConfig

Returns **any** The currentConfig merged with the sanitized conf

Expand All @@ -1473,14 +1473,14 @@ $(function () {

### Parameters

- `id` **[string][6]** The id of the element to be rendered
- `text` **[string][6]** The graph definition
- `cb` **function (svgCode: [string][6], bindFunctions: function (element: [Element][7]): void): void**
- `container` **[Element][7]** Selector to element in which a div with the graph temporarily will be
inserted. If one is provided a hidden div will be inserted in the body of the page instead. The
element will be removed when rendering is completed.
- `id` **[string][6]** The id of the element to be rendered
- `text` **[string][6]** The graph definition
- `cb` **function (svgCode: [string][6], bindFunctions: function (element: [Element][7]): void): void**
- `container` **[Element][7]** Selector to element in which a div with the graph temporarily will be
inserted. If one is provided a hidden div will be inserted in the body of the page instead. The
element will be removed when rendering is completed.

Returns **void**
Returns **void**

## getConfig

Expand All @@ -1507,15 +1507,15 @@ options in-place

### Parameters

- `options` **any** The potential setConfig parameter
- `options` **any** The potential setConfig parameter

## addDirective

Pushes in a directive to the configuration

### Parameters

- `directive` **[object][5]** The directive to push in
- `directive` **[object][5]** The directive to push in

## reset

Expand All @@ -1535,17 +1535,17 @@ Pushes in a directive to the configuration

### Parameters

- `config` (optional, default `siteConfig`)
- `config` (optional, default `siteConfig`)

Returns **void**
Returns **void**

## initialize

### Parameters

- `options` **MermaidConfig**
- `options` **MermaidConfig**

##
##

## mermaidAPI configuration defaults

Expand Down Expand Up @@ -1610,9 +1610,15 @@ Returns **void**
```

[1]: https://github.com/mermaid-js/mermaid/blob/develop/src/mermaidAPI.js

[2]: Setup.md?id=render

[3]: 8.6.0_docs.md

[4]: #mermaidapi-configuration-defaults

[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object

[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String

[7]: https://developer.mozilla.org/docs/Web/API/Element
8 changes: 7 additions & 1 deletion src/config.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ export interface MermaidConfig {
er?: ErDiagramConfig;
pie?: PieDiagramConfig;
requirement?: RequirementDiagramConfig;
mindmap?: MindmapDiagramConfig;
gitGraph?: GitGraphDiagramConfig;
c4?: C4DiagramConfig;
dompurifyConfig?: DOMPurify.Config;
wrap?: boolean;
fontSize?: number;
}

// TODO: More configs needs to be moved in here
Expand Down Expand Up @@ -211,7 +213,11 @@ export interface RequirementDiagramConfig extends BaseDiagramConfig {
rect_padding?: number;
line_height?: number;
}

export interface MindmapDiagramConfig extends BaseDiagramConfig {
useMaxWidth: boolean;
padding: number;
maxNodeWidth: number;
}
export interface PieDiagramConfig extends BaseDiagramConfig {}

export interface ErDiagramConfig extends BaseDiagramConfig {
Expand Down
4 changes: 2 additions & 2 deletions src/diagram-api/diagram-orchestration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import mindmapDb from '../diagrams/mindmap/mindmapDb';
import mindmapRenderer from '../diagrams/mindmap/mindmapRenderer';
// @ts-ignore
import mindmapParser from '../diagrams/mindmap/parser/mindmap';
import mindmapDetector from '../diagrams/mindmap/mindmapDetector';
import { mindmapDetector } from '../diagrams/mindmap/mindmapDetector';
import mindmapStyles from '../diagrams/mindmap/styles';

import gitGraphDb from '../diagrams/git/gitGraphAst';
Expand All @@ -23,6 +23,6 @@ export const addDiagrams = () => {
registerDiagram(
'mindmap',
{ parser: mindmapParser, db: mindmapDb, renderer: mindmapRenderer, styles: mindmapStyles },
gitGraphDetector
mindmapDetector
);
};
1 change: 1 addition & 0 deletions src/diagram-api/diagramAPI.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe('DiagramAPI', () => {
db: {},
parser: {},
renderer: {},
styles: {},
},
(text: string) => text.includes('loki')
);
Expand Down
Loading

0 comments on commit 8b4a08e

Please sign in to comment.