markmap-lib 0.13.2 → 0.13.3-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! markmap-lib v0.13.2 | MIT License */
1
+ /*! markmap-lib v0.13.3-alpha.2+a5a159b | MIT License */
2
2
  import _extends from '@babel/runtime/helpers/esm/extends';
3
3
  import { persistCSS, persistJS, wrapFunction, Hook } from 'markmap-common';
4
4
  import { Remarkable } from 'remarkable';
@@ -8,15 +8,12 @@ import loadLanguages from 'prismjs/components/';
8
8
  import yaml from 'js-yaml';
9
9
 
10
10
  const template = "<!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n<meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\">\n<title>Markmap</title>\n<style>\n* {\n margin: 0;\n padding: 0;\n}\n#mindmap {\n display: block;\n width: 100vw;\n height: 100vh;\n}\n</style>\n<!--CSS-->\n</head>\n<body>\n<svg id=\"mindmap\"></svg>\n<!--JS-->\n</body>\n</html>\n";
11
- const BASE_JS = [`https://cdn.jsdelivr.net/npm/d3@${"6.7.0"}`, `https://cdn.jsdelivr.net/npm/markmap-view@${"0.13.2"}`].map(src => ({
11
+ const BASE_JS = [`https://cdn.jsdelivr.net/npm/d3@${"6.7.0"}`, `https://cdn.jsdelivr.net/npm/markmap-view@${"0.13.3-alpha.2+a5a159b"}`].map(src => ({
12
12
  type: 'script',
13
13
  data: {
14
14
  src
15
15
  }
16
16
  }));
17
-
18
- const defaultGetOptions = (markmap, jsonOptions) => markmap.deriveOptions(jsonOptions);
19
-
20
17
  function fillTemplate(root, assets, extra) {
21
18
  extra = _extends({
22
19
  baseJs: BASE_JS
@@ -28,7 +25,7 @@ function fillTemplate(root, assets, extra) {
28
25
  const cssList = [...(styles ? persistCSS(styles) : [])];
29
26
  const context = {
30
27
  getMarkmap: () => window.markmap,
31
- getOptions: extra.getOptions || defaultGetOptions,
28
+ getOptions: extra.getOptions,
32
29
  jsonOptions: extra.jsonOptions,
33
30
  root
34
31
  };
@@ -37,7 +34,7 @@ function fillTemplate(root, assets, extra) {
37
34
  data: {
38
35
  fn: (getMarkmap, getOptions, root, jsonOptions) => {
39
36
  const markmap = getMarkmap();
40
- window.mm = markmap.Markmap.create('svg#mindmap', getOptions == null ? void 0 : getOptions(markmap, jsonOptions), root);
37
+ window.mm = markmap.Markmap.create('svg#mindmap', (getOptions || markmap.deriveOptions)(jsonOptions), root);
41
38
  },
42
39
  getParams: ({
43
40
  getMarkmap,
@@ -53,6 +50,49 @@ function fillTemplate(root, assets, extra) {
53
50
  return html;
54
51
  }
55
52
 
53
+ var options$1 = {
54
+ preloadScripts: [{
55
+ type: 'script',
56
+ data: {
57
+ src: `https://cdn.jsdelivr.net/npm/katex@${"0.15.3"}/dist/katex.min.js`
58
+ }
59
+ }],
60
+ scripts: [{
61
+ type: 'iife',
62
+ data: {
63
+ fn: getMarkmap => {
64
+ window.WebFontConfig = {
65
+ custom: {
66
+ families: ['KaTeX_AMS', 'KaTeX_Caligraphic:n4,n7', 'KaTeX_Fraktur:n4,n7', 'KaTeX_Main:n4,n7,i4,i7', 'KaTeX_Math:i4,i7', 'KaTeX_Script', 'KaTeX_SansSerif:n4,n7,i4', 'KaTeX_Size1', 'KaTeX_Size2', 'KaTeX_Size3', 'KaTeX_Size4', 'KaTeX_Typewriter']
67
+ },
68
+ active: () => {
69
+ getMarkmap().refreshHook.call();
70
+ }
71
+ };
72
+ },
73
+
74
+ getParams({
75
+ getMarkmap
76
+ }) {
77
+ return [getMarkmap];
78
+ }
79
+
80
+ }
81
+ }, {
82
+ type: 'script',
83
+ data: {
84
+ src: `https://cdn.jsdelivr.net/npm/webfontloader@${"1.6.28"}/webfontloader.js`,
85
+ defer: true
86
+ }
87
+ }],
88
+ styles: [{
89
+ type: 'stylesheet',
90
+ data: {
91
+ href: `https://cdn.jsdelivr.net/npm/katex@${"0.15.3"}/dist/katex.min.css`
92
+ }
93
+ }]
94
+ };
95
+
56
96
  const name$2 = 'katex';
57
97
  function transform$2(transformHooks) {
58
98
  let enableFeature = () => {};
@@ -71,40 +111,8 @@ function transform$2(transformHooks) {
71
111
  };
72
112
  });
73
113
  return {
74
- styles: [{
75
- type: 'stylesheet',
76
- data: {
77
- href: 'https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.css'
78
- }
79
- }],
80
- scripts: [{
81
- type: 'iife',
82
- data: {
83
- fn: getMarkmap => {
84
- window.WebFontConfig = {
85
- custom: {
86
- families: ['KaTeX_AMS', 'KaTeX_Caligraphic:n4,n7', 'KaTeX_Fraktur:n4,n7', 'KaTeX_Main:n4,n7,i4,i7', 'KaTeX_Math:i4,i7', 'KaTeX_Script', 'KaTeX_SansSerif:n4,n7,i4', 'KaTeX_Size1', 'KaTeX_Size2', 'KaTeX_Size3', 'KaTeX_Size4', 'KaTeX_Typewriter']
87
- },
88
- active: () => {
89
- getMarkmap().refreshHook.call();
90
- }
91
- };
92
- },
93
-
94
- getParams({
95
- getMarkmap
96
- }) {
97
- return [getMarkmap];
98
- }
99
-
100
- }
101
- }, {
102
- type: 'script',
103
- data: {
104
- src: 'https://cdn.jsdelivr.net/npm/webfontloader@1.6.28/webfontloader.js',
105
- defer: true
106
- }
107
- }]
114
+ styles: options$1.styles,
115
+ scripts: options$1.scripts
108
116
  };
109
117
  }
110
118
 
@@ -114,6 +122,26 @@ name: name$2,
114
122
  transform: transform$2
115
123
  });
116
124
 
125
+ var options = {
126
+ preloadScripts: [{
127
+ type: 'script',
128
+ data: {
129
+ src: `https://cdn.jsdelivr.net/npm/prismjs@${"1.28.0"}/components/prism-core.min.js`
130
+ }
131
+ }, {
132
+ type: 'script',
133
+ data: {
134
+ src: `https://cdn.jsdelivr.net/npm/prismjs@${"1.28.0"}/plugins/autoloader/prism-autoloader.min.js`
135
+ }
136
+ }],
137
+ styles: [{
138
+ type: 'stylesheet',
139
+ data: {
140
+ href: `https://cdn.jsdelivr.net/npm/prismjs@${"1.28.0"}/themes/prism.css`
141
+ }
142
+ }]
143
+ };
144
+
117
145
  const name$1 = 'prism';
118
146
  function transform$1(transformHooks) {
119
147
  let enableFeature = () => {};
@@ -143,12 +171,7 @@ function transform$1(transformHooks) {
143
171
  };
144
172
  });
145
173
  return {
146
- styles: [{
147
- type: 'stylesheet',
148
- data: {
149
- href: `https://cdn.jsdelivr.net/npm/prismjs@${"1.25.0"}/themes/prism.css`
150
- }
151
- }]
174
+ styles: options.styles
152
175
  };
153
176
  }
154
177
 
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! markmap-lib v0.13.2 | MIT License */
1
+ /*! markmap-lib v0.13.3-alpha.2+a5a159b | MIT License */
2
2
  'use strict';
3
3
 
4
4
  var _extends = require('@babel/runtime/helpers/extends');
@@ -18,15 +18,12 @@ var loadLanguages__default = /*#__PURE__*/_interopDefaultLegacy(loadLanguages);
18
18
  var yaml__default = /*#__PURE__*/_interopDefaultLegacy(yaml);
19
19
 
20
20
  const template = "<!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n<meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\">\n<title>Markmap</title>\n<style>\n* {\n margin: 0;\n padding: 0;\n}\n#mindmap {\n display: block;\n width: 100vw;\n height: 100vh;\n}\n</style>\n<!--CSS-->\n</head>\n<body>\n<svg id=\"mindmap\"></svg>\n<!--JS-->\n</body>\n</html>\n";
21
- const BASE_JS = [`https://cdn.jsdelivr.net/npm/d3@${"6.7.0"}`, `https://cdn.jsdelivr.net/npm/markmap-view@${"0.13.2"}`].map(src => ({
21
+ const BASE_JS = [`https://cdn.jsdelivr.net/npm/d3@${"6.7.0"}`, `https://cdn.jsdelivr.net/npm/markmap-view@${"0.13.3-alpha.2+a5a159b"}`].map(src => ({
22
22
  type: 'script',
23
23
  data: {
24
24
  src
25
25
  }
26
26
  }));
27
-
28
- const defaultGetOptions = (markmap, jsonOptions) => markmap.deriveOptions(jsonOptions);
29
-
30
27
  function fillTemplate(root, assets, extra) {
31
28
  extra = _extends__default({
32
29
  baseJs: BASE_JS
@@ -38,7 +35,7 @@ function fillTemplate(root, assets, extra) {
38
35
  const cssList = [...(styles ? markmapCommon.persistCSS(styles) : [])];
39
36
  const context = {
40
37
  getMarkmap: () => window.markmap,
41
- getOptions: extra.getOptions || defaultGetOptions,
38
+ getOptions: extra.getOptions,
42
39
  jsonOptions: extra.jsonOptions,
43
40
  root
44
41
  };
@@ -47,7 +44,7 @@ function fillTemplate(root, assets, extra) {
47
44
  data: {
48
45
  fn: (getMarkmap, getOptions, root, jsonOptions) => {
49
46
  const markmap = getMarkmap();
50
- window.mm = markmap.Markmap.create('svg#mindmap', getOptions == null ? void 0 : getOptions(markmap, jsonOptions), root);
47
+ window.mm = markmap.Markmap.create('svg#mindmap', (getOptions || markmap.deriveOptions)(jsonOptions), root);
51
48
  },
52
49
  getParams: ({
53
50
  getMarkmap,
@@ -63,6 +60,49 @@ function fillTemplate(root, assets, extra) {
63
60
  return html;
64
61
  }
65
62
 
63
+ var options$1 = {
64
+ preloadScripts: [{
65
+ type: 'script',
66
+ data: {
67
+ src: `https://cdn.jsdelivr.net/npm/katex@${"0.15.3"}/dist/katex.min.js`
68
+ }
69
+ }],
70
+ scripts: [{
71
+ type: 'iife',
72
+ data: {
73
+ fn: getMarkmap => {
74
+ window.WebFontConfig = {
75
+ custom: {
76
+ families: ['KaTeX_AMS', 'KaTeX_Caligraphic:n4,n7', 'KaTeX_Fraktur:n4,n7', 'KaTeX_Main:n4,n7,i4,i7', 'KaTeX_Math:i4,i7', 'KaTeX_Script', 'KaTeX_SansSerif:n4,n7,i4', 'KaTeX_Size1', 'KaTeX_Size2', 'KaTeX_Size3', 'KaTeX_Size4', 'KaTeX_Typewriter']
77
+ },
78
+ active: () => {
79
+ getMarkmap().refreshHook.call();
80
+ }
81
+ };
82
+ },
83
+
84
+ getParams({
85
+ getMarkmap
86
+ }) {
87
+ return [getMarkmap];
88
+ }
89
+
90
+ }
91
+ }, {
92
+ type: 'script',
93
+ data: {
94
+ src: `https://cdn.jsdelivr.net/npm/webfontloader@${"1.6.28"}/webfontloader.js`,
95
+ defer: true
96
+ }
97
+ }],
98
+ styles: [{
99
+ type: 'stylesheet',
100
+ data: {
101
+ href: `https://cdn.jsdelivr.net/npm/katex@${"0.15.3"}/dist/katex.min.css`
102
+ }
103
+ }]
104
+ };
105
+
66
106
  const name$2 = 'katex';
67
107
  function transform$2(transformHooks) {
68
108
  let enableFeature = () => {};
@@ -81,40 +121,8 @@ function transform$2(transformHooks) {
81
121
  };
82
122
  });
83
123
  return {
84
- styles: [{
85
- type: 'stylesheet',
86
- data: {
87
- href: 'https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.css'
88
- }
89
- }],
90
- scripts: [{
91
- type: 'iife',
92
- data: {
93
- fn: getMarkmap => {
94
- window.WebFontConfig = {
95
- custom: {
96
- families: ['KaTeX_AMS', 'KaTeX_Caligraphic:n4,n7', 'KaTeX_Fraktur:n4,n7', 'KaTeX_Main:n4,n7,i4,i7', 'KaTeX_Math:i4,i7', 'KaTeX_Script', 'KaTeX_SansSerif:n4,n7,i4', 'KaTeX_Size1', 'KaTeX_Size2', 'KaTeX_Size3', 'KaTeX_Size4', 'KaTeX_Typewriter']
97
- },
98
- active: () => {
99
- getMarkmap().refreshHook.call();
100
- }
101
- };
102
- },
103
-
104
- getParams({
105
- getMarkmap
106
- }) {
107
- return [getMarkmap];
108
- }
109
-
110
- }
111
- }, {
112
- type: 'script',
113
- data: {
114
- src: 'https://cdn.jsdelivr.net/npm/webfontloader@1.6.28/webfontloader.js',
115
- defer: true
116
- }
117
- }]
124
+ styles: options$1.styles,
125
+ scripts: options$1.scripts
118
126
  };
119
127
  }
120
128
 
@@ -124,6 +132,26 @@ name: name$2,
124
132
  transform: transform$2
125
133
  });
126
134
 
135
+ var options = {
136
+ preloadScripts: [{
137
+ type: 'script',
138
+ data: {
139
+ src: `https://cdn.jsdelivr.net/npm/prismjs@${"1.28.0"}/components/prism-core.min.js`
140
+ }
141
+ }, {
142
+ type: 'script',
143
+ data: {
144
+ src: `https://cdn.jsdelivr.net/npm/prismjs@${"1.28.0"}/plugins/autoloader/prism-autoloader.min.js`
145
+ }
146
+ }],
147
+ styles: [{
148
+ type: 'stylesheet',
149
+ data: {
150
+ href: `https://cdn.jsdelivr.net/npm/prismjs@${"1.28.0"}/themes/prism.css`
151
+ }
152
+ }]
153
+ };
154
+
127
155
  const name$1 = 'prism';
128
156
  function transform$1(transformHooks) {
129
157
  let enableFeature = () => {};
@@ -153,12 +181,7 @@ function transform$1(transformHooks) {
153
181
  };
154
182
  });
155
183
  return {
156
- styles: [{
157
- type: 'stylesheet',
158
- data: {
159
- href: `https://cdn.jsdelivr.net/npm/prismjs@${"1.25.0"}/themes/prism.css`
160
- }
161
- }]
184
+ styles: options.styles
162
185
  };
163
186
  }
164
187
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markmap-lib",
3
- "version": "0.13.2",
3
+ "version": "0.13.3-alpha.2+a5a159b",
4
4
  "description": "Visualize your Markdown as mindmaps with Markmap",
5
5
  "author": "Gerald <gera2ld@live.com>",
6
6
  "license": "MIT",
@@ -35,16 +35,17 @@
35
35
  "repository": "git@github.com:gera2ld/markmap.git",
36
36
  "devDependencies": {
37
37
  "@types/remarkable": "^2.0.3",
38
- "markmap-view": "^0.13.2"
38
+ "markmap-view": "^0.13.3-alpha.2+a5a159b",
39
+ "webfontloader": "^1.6.28"
39
40
  },
40
41
  "dependencies": {
41
42
  "@babel/runtime": "^7.16.3",
42
43
  "js-yaml": "^4.1.0",
43
44
  "katex": "^0.15.1",
44
- "markmap-common": "^0.13.0",
45
+ "markmap-common": "^0.13.3-alpha.2+a5a159b",
45
46
  "prismjs": "^1.25.0",
46
47
  "remarkable": "^2.0.1",
47
48
  "remarkable-katex": "^1.1.8"
48
49
  },
49
- "gitHead": "963b0f47f78be88a06ff50bed97a7ce0597cf392"
50
+ "gitHead": "a5a159bee156ba7c77cf952f6f0f3e450f8c12fa"
50
51
  }
@@ -1,3 +1,5 @@
1
1
  import { IAssets, ITransformHooks } from '../types';
2
+ import options from './katex.options';
3
+ export { options };
2
4
  export declare const name = "katex";
3
5
  export declare function transform(transformHooks: ITransformHooks): IAssets;
@@ -0,0 +1,7 @@
1
+ import { CSSItem, JSItem } from 'markmap-common';
2
+ declare const _default: {
3
+ preloadScripts: JSItem[];
4
+ scripts: JSItem[];
5
+ styles: CSSItem[];
6
+ };
7
+ export default _default;
@@ -1,3 +1,5 @@
1
1
  import { IAssets, ITransformHooks } from '../types';
2
+ import options from './prism.options';
3
+ export { options };
2
4
  export declare const name = "prism";
3
5
  export declare function transform(transformHooks: ITransformHooks): IAssets;
@@ -0,0 +1,6 @@
1
+ import { CSSItem, JSItem } from 'markmap-common';
2
+ declare const _default: {
3
+ preloadScripts: JSItem[];
4
+ styles: CSSItem[];
5
+ };
6
+ export default _default;
@@ -1,8 +1,7 @@
1
- import { JSItem, INode } from 'markmap-common';
2
- import type { IMarkmapOptions, IMarkmapJSONOptions } from 'markmap-view';
1
+ import { JSItem, INode, IMarkmapOptions, IMarkmapJSONOptions } from 'markmap-common';
3
2
  import { IAssets } from './types';
4
3
  export declare function fillTemplate(root: INode | undefined, assets: IAssets, extra?: {
5
4
  baseJs?: JSItem[];
6
5
  jsonOptions?: IMarkmapJSONOptions;
7
- getOptions?: (markmap: typeof window.markmap, jsonOptions: IMarkmapJSONOptions) => Partial<IMarkmapOptions>;
6
+ getOptions?: (jsonOptions: IMarkmapJSONOptions) => Partial<IMarkmapOptions>;
8
7
  }): string;