Skip to content

Commit

Permalink
docs: add directives to basic-syntax.mdx
Browse files Browse the repository at this point in the history
  • Loading branch information
hikerpig committed Feb 6, 2022
1 parent 3cabdaf commit 3016714
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 4 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
packages/pintora-diagrams/src/*/parser/*.[jt]s
2 changes: 1 addition & 1 deletion packages/pintora-renderer/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { IRenderer } from './type'
import { makeRenderer, RendererType, BaseRenderer, rendererRegistry } from './renderers'

export type RenderOptions = {
container: any
container: HTMLElement
renderer?: RendererType
onRender?(renderer: IRenderer): void
}
Expand Down
9 changes: 6 additions & 3 deletions packages/pintora-standalone/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ const pintoraStandalone = {
...pintora,
renderTo(code: string, options: RenderToOptions) {
const { container, config } = options
let ctn: HTMLDivElement
let ctn: HTMLElement
if (typeof container === 'string') {
ctn = document.querySelector(container) as any
ctn = document.querySelector(container)
} else {
ctn = container
}
Expand Down Expand Up @@ -79,7 +79,10 @@ const pintoraStandalone = {
if (canvasBackground) graphicIR.bgColor = canvasBackground
}

render(graphicIR, options)
render(graphicIR, {
...options,
container: ctn,
})
}
} finally {
if (config && backupConfig) configApi.replaceConfig(backupConfig)
Expand Down
28 changes: 28 additions & 0 deletions website/docs/getting-started/basic-syntax.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,31 @@ sequenceDiagram
%% another line comment
A-->B: Hi there!
```

## Directives

### @param and @config

You can override current diagram config with these directives.

See [Config](/configuration/config.md) for more details.

```pintora play
erDiagram
@param fontSize 18
@config({
"themeConfig": {
"theme": "larkLight"
},
"er": {
"curvedEdge": false
}
})
CUSTOMER {
int id PK
int address FK
}
CUSTOMER ||--o{ ORDER : places
ORDER ||--|{ LINE-ITEM : contains
CUSTOMER }|..|{ DELIVERY-ADDRESS : uses
```
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,31 @@ sequenceDiagram
%% another line comment
A-->B: Hi there!
```

## Directives 指令

### @param@config

可以使用这两个指令来覆盖当前图表配置。

更多细节请查看 [Config](/configuration/config.md)

```pintora play
erDiagram
@param fontSize 18
@config({
"themeConfig": {
"theme": "larkLight"
},
"er": {
"curvedEdge": false
}
})
CUSTOMER {
int id PK
int address FK
}
CUSTOMER ||--o{ ORDER : places
ORDER ||--|{ LINE-ITEM : contains
CUSTOMER }|..|{ DELIVERY-ADDRESS : uses
```

0 comments on commit 3016714

Please sign in to comment.