-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.ts
65 lines (59 loc) · 1.74 KB
/
options.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/**
* Options for the jsoncanvas
*/
export interface Options {
/**
* Open links in a new tab
*
* Defaults to true
*/
openEmbededInNewTab?: boolean
/**
* This is a dumb hack for accomodating SSr. Basically, the mrakdown embed path requires the SSR relative path, and image svg is from the client side, so doesn't see the `public`directory. Otherwise will use assetPath
*
* Defaults to 'public'
*/
ssrPath?: string
/**
* Define an asset path where the .canvas files exists. This will add the asset path before the filename. Otherwise uses cwd.process() path + filename
*
* Defaults to null
*/
assetPath?: string | null
/**
* Define an markdown path where the .md files will be searched for WHEN EMBEDDING ONLY. This will add the md path before the filename. Otherwise uses assetPath defaults
*
* Defaults to null
*/
mdPath?: string | null
/**
* Canvas node stroke width
*
* Defaults to 3
*/
nodeStrokeWidth?: number
/**
* Canvas line stroke width
*
* Defaults to 5
*/
lineStrokeWidth?: number
}
/**
* Applies default values for any unspecified options
*/
export function applyDefaults(config: Partial<Options> = {}): Options {
return {
openEmbededInNewTab:
config.openEmbededInNewTab === undefined
? true
: config.openEmbededInNewTab,
assetPath: config.assetPath === undefined ? null : config.assetPath,
ssrPath: config.ssrPath === undefined ? "public" : config.ssrPath,
mdPath: config.mdPath === undefined ? config.assetPath : config.mdPath,
nodeStrokeWidth:
config.nodeStrokeWidth === undefined ? 3 : config.nodeStrokeWidth,
lineStrokeWidth:
config.lineStrokeWidth === undefined ? 5 : config.lineStrokeWidth,
}
}