markmap-lib 0.11.6 → 0.13.0
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/browser/index.js +4730 -838
- package/dist/browser/index.min.js +4 -3
- package/dist/index.esm.js +151 -110
- package/dist/index.js +153 -111
- package/package.json +12 -11
- package/types/index.d.ts +3 -3
- package/types/plugins/base.d.ts +2 -10
- package/types/plugins/frontmatter.d.ts +3 -0
- package/types/plugins/index.d.ts +5 -4
- package/types/plugins/katex.browser.d.ts +3 -3
- package/types/plugins/katex.d.ts +3 -3
- package/types/plugins/prism.browser.d.ts +3 -3
- package/types/plugins/prism.d.ts +3 -3
- package/types/template.d.ts +8 -6
- package/types/transform.d.ts +22 -22
- package/types/types.d.ts +55 -32
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! markmap-lib v0.
|
|
1
|
+
/*! markmap-lib v0.13.0 | MIT License */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
@@ -7,28 +7,27 @@ var remarkable = require('remarkable');
|
|
|
7
7
|
var remarkableKatex = require('remarkable-katex');
|
|
8
8
|
var Prism = require('prismjs');
|
|
9
9
|
var loadLanguages = require('prismjs/components/');
|
|
10
|
+
var yaml = require('js-yaml');
|
|
10
11
|
|
|
11
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e[
|
|
12
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
|
|
12
13
|
|
|
13
14
|
var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
|
|
14
15
|
var remarkableKatex__default = /*#__PURE__*/_interopDefaultLegacy(remarkableKatex);
|
|
15
16
|
var Prism__default = /*#__PURE__*/_interopDefaultLegacy(Prism);
|
|
16
17
|
var loadLanguages__default = /*#__PURE__*/_interopDefaultLegacy(loadLanguages);
|
|
18
|
+
var yaml__default = /*#__PURE__*/_interopDefaultLegacy(yaml);
|
|
17
19
|
|
|
18
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";
|
|
19
|
-
const BASE_JS = [`https://cdn.jsdelivr.net/npm/d3@${"6.
|
|
21
|
+
const BASE_JS = [`https://cdn.jsdelivr.net/npm/d3@${"6.7.0"}`, `https://cdn.jsdelivr.net/npm/markmap-view@${"0.13.0"}`].map(src => ({
|
|
20
22
|
type: 'script',
|
|
21
23
|
data: {
|
|
22
24
|
src
|
|
23
25
|
}
|
|
24
26
|
}));
|
|
25
|
-
function fillTemplate(data, assets, extra) {
|
|
26
|
-
if (typeof extra === 'function') {
|
|
27
|
-
extra = {
|
|
28
|
-
getOptions: extra
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
27
|
|
|
28
|
+
const defaultGetOptions = (markmap, jsonOptions) => markmap.deriveOptions(jsonOptions);
|
|
29
|
+
|
|
30
|
+
function fillTemplate(root, assets, extra) {
|
|
32
31
|
extra = _extends__default({
|
|
33
32
|
baseJs: BASE_JS
|
|
34
33
|
}, extra);
|
|
@@ -39,24 +38,24 @@ function fillTemplate(data, assets, extra) {
|
|
|
39
38
|
const cssList = [...(styles ? markmapCommon.persistCSS(styles) : [])];
|
|
40
39
|
const context = {
|
|
41
40
|
getMarkmap: () => window.markmap,
|
|
42
|
-
getOptions: extra.getOptions,
|
|
43
|
-
|
|
41
|
+
getOptions: extra.getOptions || defaultGetOptions,
|
|
42
|
+
jsonOptions: extra.jsonOptions,
|
|
43
|
+
root
|
|
44
44
|
};
|
|
45
|
-
const jsList = [...markmapCommon.persistJS(extra.baseJs
|
|
45
|
+
const jsList = [...markmapCommon.persistJS([...extra.baseJs, ...(scripts || []), {
|
|
46
46
|
type: 'iife',
|
|
47
47
|
data: {
|
|
48
|
-
fn: (getMarkmap, getOptions,
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
} = getMarkmap();
|
|
52
|
-
window.mm = Markmap.create('svg#mindmap', getOptions == null ? void 0 : getOptions(), data);
|
|
48
|
+
fn: (getMarkmap, getOptions, root, jsonOptions) => {
|
|
49
|
+
const markmap = getMarkmap();
|
|
50
|
+
window.mm = markmap.Markmap.create('svg#mindmap', getOptions == null ? void 0 : getOptions(markmap, jsonOptions), root);
|
|
53
51
|
},
|
|
54
52
|
getParams: ({
|
|
55
53
|
getMarkmap,
|
|
56
54
|
getOptions,
|
|
57
|
-
|
|
55
|
+
root,
|
|
56
|
+
jsonOptions
|
|
58
57
|
}) => {
|
|
59
|
-
return [getMarkmap, getOptions,
|
|
58
|
+
return [getMarkmap, getOptions, root, jsonOptions];
|
|
60
59
|
}
|
|
61
60
|
}
|
|
62
61
|
}], context)];
|
|
@@ -64,16 +63,23 @@ function fillTemplate(data, assets, extra) {
|
|
|
64
63
|
return html;
|
|
65
64
|
}
|
|
66
65
|
|
|
67
|
-
const name$
|
|
68
|
-
function transform$
|
|
69
|
-
|
|
66
|
+
const name$2 = 'katex';
|
|
67
|
+
function transform$2(transformHooks) {
|
|
68
|
+
let enableFeature = () => {};
|
|
69
|
+
|
|
70
|
+
transformHooks.parser.tap(md => {
|
|
70
71
|
md.use(remarkableKatex__default);
|
|
71
72
|
md.renderer.rules.katex = markmapCommon.wrapFunction(md.renderer.rules.katex, {
|
|
72
73
|
after: () => {
|
|
73
|
-
|
|
74
|
+
enableFeature();
|
|
74
75
|
}
|
|
75
76
|
});
|
|
76
77
|
});
|
|
78
|
+
transformHooks.transform.tap((_, context) => {
|
|
79
|
+
enableFeature = () => {
|
|
80
|
+
context.features[name$2] = true;
|
|
81
|
+
};
|
|
82
|
+
});
|
|
77
83
|
return {
|
|
78
84
|
styles: [{
|
|
79
85
|
type: 'stylesheet',
|
|
@@ -114,19 +120,21 @@ function transform$1(transformHooks) {
|
|
|
114
120
|
|
|
115
121
|
var katex = /*#__PURE__*/Object.freeze({
|
|
116
122
|
__proto__: null,
|
|
117
|
-
name: name$
|
|
118
|
-
transform: transform$
|
|
123
|
+
name: name$2,
|
|
124
|
+
transform: transform$2
|
|
119
125
|
});
|
|
120
126
|
|
|
121
|
-
const name = 'prism';
|
|
122
|
-
function transform(transformHooks) {
|
|
123
|
-
|
|
127
|
+
const name$1 = 'prism';
|
|
128
|
+
function transform$1(transformHooks) {
|
|
129
|
+
let enableFeature = () => {};
|
|
130
|
+
|
|
131
|
+
transformHooks.parser.tap(md => {
|
|
124
132
|
md.set({
|
|
125
133
|
highlight: (str, lang) => {
|
|
126
|
-
|
|
134
|
+
enableFeature();
|
|
127
135
|
let grammar = Prism__default.languages[lang];
|
|
128
136
|
|
|
129
|
-
if (!grammar) {
|
|
137
|
+
if (!grammar && lang) {
|
|
130
138
|
loadLanguages__default([lang]);
|
|
131
139
|
grammar = Prism__default.languages[lang];
|
|
132
140
|
}
|
|
@@ -139,11 +147,16 @@ function transform(transformHooks) {
|
|
|
139
147
|
}
|
|
140
148
|
});
|
|
141
149
|
});
|
|
150
|
+
transformHooks.transform.tap((_, context) => {
|
|
151
|
+
enableFeature = () => {
|
|
152
|
+
context.features[name$1] = true;
|
|
153
|
+
};
|
|
154
|
+
});
|
|
142
155
|
return {
|
|
143
156
|
styles: [{
|
|
144
157
|
type: 'stylesheet',
|
|
145
158
|
data: {
|
|
146
|
-
href: `https://cdn.jsdelivr.net/npm/prismjs@${"1.
|
|
159
|
+
href: `https://cdn.jsdelivr.net/npm/prismjs@${"1.28.0"}/themes/prism.css`
|
|
147
160
|
}
|
|
148
161
|
}]
|
|
149
162
|
};
|
|
@@ -151,6 +164,43 @@ function transform(transformHooks) {
|
|
|
151
164
|
|
|
152
165
|
var prism = /*#__PURE__*/Object.freeze({
|
|
153
166
|
__proto__: null,
|
|
167
|
+
name: name$1,
|
|
168
|
+
transform: transform$1
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
const name = 'frontmatter';
|
|
172
|
+
function transform(transformHooks) {
|
|
173
|
+
transformHooks.transform.tap((md, context) => {
|
|
174
|
+
const origParse = md.parse;
|
|
175
|
+
md.parse = markmapCommon.wrapFunction(origParse, {
|
|
176
|
+
before(ctx) {
|
|
177
|
+
const [content] = ctx.args;
|
|
178
|
+
if (!content.startsWith('---\n')) return;
|
|
179
|
+
const endOffset = content.indexOf('\n---\n');
|
|
180
|
+
if (endOffset < 0) return;
|
|
181
|
+
const raw = content.slice(4, endOffset);
|
|
182
|
+
|
|
183
|
+
try {
|
|
184
|
+
context.frontmatter = yaml__default.load(raw);
|
|
185
|
+
} catch (_unused) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const offset = endOffset + 5;
|
|
190
|
+
ctx.args[0] = content.slice(offset);
|
|
191
|
+
},
|
|
192
|
+
|
|
193
|
+
after() {
|
|
194
|
+
md.parse = origParse;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
return {};
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
var frontmatter = /*#__PURE__*/Object.freeze({
|
|
203
|
+
__proto__: null,
|
|
154
204
|
name: name,
|
|
155
205
|
transform: transform
|
|
156
206
|
});
|
|
@@ -158,31 +208,27 @@ transform: transform
|
|
|
158
208
|
function createTransformHooks() {
|
|
159
209
|
return {
|
|
160
210
|
parser: new markmapCommon.Hook(),
|
|
211
|
+
transform: new markmapCommon.Hook(),
|
|
161
212
|
htmltag: new markmapCommon.Hook(),
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* Indicate that the last transformation is not complete for reasons like
|
|
165
|
-
* lack of resources and is called when it is ready for a new transformation.
|
|
166
|
-
*/
|
|
167
213
|
retransform: new markmapCommon.Hook()
|
|
168
214
|
};
|
|
169
215
|
}
|
|
170
216
|
|
|
171
|
-
const plugins = [katex, prism];
|
|
217
|
+
const plugins = [katex, prism, frontmatter];
|
|
172
218
|
|
|
173
219
|
function cleanNode(node, depth = 0) {
|
|
174
|
-
if (node.
|
|
220
|
+
if (node.type === 'heading') {
|
|
175
221
|
// drop all paragraphs
|
|
176
|
-
node.
|
|
177
|
-
} else if (node.
|
|
178
|
-
var _node$
|
|
222
|
+
node.children = node.children.filter(item => item.type !== 'paragraph');
|
|
223
|
+
} else if (node.type === 'list_item') {
|
|
224
|
+
var _node$payload;
|
|
179
225
|
|
|
180
226
|
// keep first paragraph as content of list_item, drop others
|
|
181
|
-
node.
|
|
182
|
-
if (['paragraph', 'fence'].includes(item.
|
|
183
|
-
if (!node.
|
|
184
|
-
node.
|
|
185
|
-
node.
|
|
227
|
+
node.children = node.children.filter(item => {
|
|
228
|
+
if (['paragraph', 'fence'].includes(item.type)) {
|
|
229
|
+
if (!node.content) {
|
|
230
|
+
node.content = item.content;
|
|
231
|
+
node.payload = _extends__default({}, node.payload, item.payload);
|
|
186
232
|
}
|
|
187
233
|
|
|
188
234
|
return false;
|
|
@@ -191,16 +237,16 @@ function cleanNode(node, depth = 0) {
|
|
|
191
237
|
return true;
|
|
192
238
|
});
|
|
193
239
|
|
|
194
|
-
if (((_node$
|
|
195
|
-
node.
|
|
240
|
+
if (((_node$payload = node.payload) == null ? void 0 : _node$payload.index) != null) {
|
|
241
|
+
node.content = `${node.payload.index}. ${node.content}`;
|
|
196
242
|
}
|
|
197
|
-
} else if (node.
|
|
198
|
-
var _node$
|
|
243
|
+
} else if (node.type === 'ordered_list') {
|
|
244
|
+
var _node$payload$startIn, _node$payload2;
|
|
199
245
|
|
|
200
|
-
let index = (_node$
|
|
201
|
-
node.
|
|
202
|
-
if (item.
|
|
203
|
-
item.
|
|
246
|
+
let index = (_node$payload$startIn = (_node$payload2 = node.payload) == null ? void 0 : _node$payload2.startIndex) != null ? _node$payload$startIn : 1;
|
|
247
|
+
node.children.forEach(item => {
|
|
248
|
+
if (item.type === 'list_item') {
|
|
249
|
+
item.payload = _extends__default({}, item.payload, {
|
|
204
250
|
index
|
|
205
251
|
});
|
|
206
252
|
index += 1;
|
|
@@ -208,39 +254,23 @@ function cleanNode(node, depth = 0) {
|
|
|
208
254
|
});
|
|
209
255
|
}
|
|
210
256
|
|
|
211
|
-
if (node.
|
|
212
|
-
delete node.
|
|
257
|
+
if (node.children.length === 0) {
|
|
258
|
+
delete node.children;
|
|
213
259
|
} else {
|
|
214
|
-
node.
|
|
260
|
+
node.children.forEach(child => cleanNode(child, depth + 1));
|
|
215
261
|
|
|
216
|
-
if (node.
|
|
217
|
-
node.
|
|
262
|
+
if (node.children.length === 1 && !node.children[0].content) {
|
|
263
|
+
node.children = node.children[0].children;
|
|
218
264
|
}
|
|
219
265
|
}
|
|
220
266
|
|
|
221
|
-
node.
|
|
267
|
+
node.depth = depth;
|
|
222
268
|
}
|
|
223
269
|
|
|
224
270
|
class Transformer {
|
|
225
271
|
constructor(plugins$1 = plugins) {
|
|
226
|
-
this.plugins = void 0;
|
|
227
|
-
this.hooks = void 0;
|
|
228
|
-
this.md = void 0;
|
|
229
|
-
this.assetsMap = void 0;
|
|
230
272
|
this.plugins = plugins$1;
|
|
231
273
|
this.hooks = createTransformHooks();
|
|
232
|
-
const md = new remarkable.Remarkable({
|
|
233
|
-
html: true,
|
|
234
|
-
breaks: true,
|
|
235
|
-
maxNesting: Infinity
|
|
236
|
-
});
|
|
237
|
-
md.block.ruler.enable(['deflist']);
|
|
238
|
-
md.renderer.rules.htmltag = markmapCommon.wrapFunction(md.renderer.rules.htmltag, {
|
|
239
|
-
after: ctx => {
|
|
240
|
-
this.hooks.htmltag.call(ctx);
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
this.md = md;
|
|
244
274
|
const assetsMap = {};
|
|
245
275
|
|
|
246
276
|
for (const {
|
|
@@ -251,19 +281,30 @@ class Transformer {
|
|
|
251
281
|
}
|
|
252
282
|
|
|
253
283
|
this.assetsMap = assetsMap;
|
|
284
|
+
const md = new remarkable.Remarkable('full', {
|
|
285
|
+
html: true,
|
|
286
|
+
breaks: true,
|
|
287
|
+
maxNesting: Infinity
|
|
288
|
+
});
|
|
289
|
+
md.renderer.rules.htmltag = markmapCommon.wrapFunction(md.renderer.rules.htmltag, {
|
|
290
|
+
after: ctx => {
|
|
291
|
+
this.hooks.htmltag.call(ctx);
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
this.md = md;
|
|
295
|
+
this.hooks.parser.call(md);
|
|
254
296
|
}
|
|
255
297
|
|
|
256
298
|
buildTree(tokens) {
|
|
257
299
|
const {
|
|
258
300
|
md
|
|
259
|
-
} = this;
|
|
260
|
-
|
|
301
|
+
} = this;
|
|
261
302
|
const root = {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
303
|
+
type: 'root',
|
|
304
|
+
depth: 0,
|
|
305
|
+
content: '',
|
|
306
|
+
children: [],
|
|
307
|
+
payload: {}
|
|
267
308
|
};
|
|
268
309
|
const stack = [root];
|
|
269
310
|
let depth = 0;
|
|
@@ -282,7 +323,7 @@ class Transformer {
|
|
|
282
323
|
if (type === 'heading') {
|
|
283
324
|
depth = token.hLevel;
|
|
284
325
|
|
|
285
|
-
while (((_current = current) == null ? void 0 : _current.
|
|
326
|
+
while (((_current = current) == null ? void 0 : _current.depth) >= depth) {
|
|
286
327
|
var _current;
|
|
287
328
|
|
|
288
329
|
stack.pop();
|
|
@@ -291,27 +332,27 @@ class Transformer {
|
|
|
291
332
|
} else {
|
|
292
333
|
var _current2;
|
|
293
334
|
|
|
294
|
-
depth = Math.max(depth, ((_current2 = current) == null ? void 0 : _current2.
|
|
335
|
+
depth = Math.max(depth, ((_current2 = current) == null ? void 0 : _current2.depth) || 0) + 1;
|
|
295
336
|
|
|
296
337
|
if (type === 'ordered_list') {
|
|
297
|
-
payload.
|
|
338
|
+
payload.startIndex = token.order;
|
|
298
339
|
}
|
|
299
340
|
}
|
|
300
341
|
|
|
301
342
|
const item = {
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
343
|
+
type,
|
|
344
|
+
depth,
|
|
345
|
+
payload,
|
|
346
|
+
content: '',
|
|
347
|
+
children: []
|
|
307
348
|
};
|
|
308
|
-
current.
|
|
349
|
+
current.children.push(item);
|
|
309
350
|
stack.push(item);
|
|
310
351
|
} else if (!current) {
|
|
311
352
|
continue;
|
|
312
|
-
} else if (token.type === `${current.
|
|
313
|
-
if (current.
|
|
314
|
-
depth = current.
|
|
353
|
+
} else if (token.type === `${current.type}_close`) {
|
|
354
|
+
if (current.type === 'heading') {
|
|
355
|
+
depth = current.depth;
|
|
315
356
|
} else {
|
|
316
357
|
stack.pop();
|
|
317
358
|
depth = 0;
|
|
@@ -322,23 +363,23 @@ class Transformer {
|
|
|
322
363
|
const data = comment == null ? void 0 : comment[1].trim();
|
|
323
364
|
|
|
324
365
|
if (data === 'fold') {
|
|
325
|
-
current.
|
|
366
|
+
current.payload.fold = true;
|
|
326
367
|
ctx.result = '';
|
|
327
368
|
}
|
|
328
369
|
});
|
|
329
370
|
const text = md.renderer.render([token], md.options, {});
|
|
330
371
|
revoke();
|
|
331
|
-
current.
|
|
372
|
+
current.content = `${current.content || ''}${text}`;
|
|
332
373
|
} else if (token.type === 'fence') {
|
|
333
374
|
let result = md.renderer.render([token], md.options, {}); // Remarkable only adds className to `<code>` but not `<pre>`, copy it to make PrismJS style work.
|
|
334
375
|
|
|
335
376
|
const matches = result.match(/<code( class="[^"]*")>/);
|
|
336
377
|
if (matches) result = result.replace('<pre>', `<pre${matches[1]}>`);
|
|
337
|
-
current.
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
378
|
+
current.children.push({
|
|
379
|
+
type: token.type,
|
|
380
|
+
depth: depth + 1,
|
|
381
|
+
content: result,
|
|
382
|
+
children: []
|
|
342
383
|
});
|
|
343
384
|
} else ;
|
|
344
385
|
}
|
|
@@ -347,18 +388,19 @@ class Transformer {
|
|
|
347
388
|
}
|
|
348
389
|
|
|
349
390
|
transform(content) {
|
|
350
|
-
var _root$
|
|
391
|
+
var _root$children;
|
|
351
392
|
|
|
352
|
-
const
|
|
353
|
-
|
|
354
|
-
|
|
393
|
+
const context = {
|
|
394
|
+
features: {}
|
|
395
|
+
};
|
|
396
|
+
this.hooks.transform.call(this.md, context);
|
|
397
|
+
const tokens = this.md.parse(content, {});
|
|
355
398
|
let root = this.buildTree(tokens);
|
|
356
399
|
cleanNode(root);
|
|
357
|
-
if (((_root$
|
|
358
|
-
return {
|
|
359
|
-
root
|
|
360
|
-
|
|
361
|
-
};
|
|
400
|
+
if (((_root$children = root.children) == null ? void 0 : _root$children.length) === 1) root = root.children[0];
|
|
401
|
+
return _extends__default({}, context, {
|
|
402
|
+
root
|
|
403
|
+
});
|
|
362
404
|
}
|
|
363
405
|
/**
|
|
364
406
|
* Get all assets from enabled plugins or filter them by plugin names as keys.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markmap-lib",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Visualize your Markdown as mindmaps with Markmap",
|
|
5
5
|
"author": "Gerald <gera2ld@live.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -11,8 +11,7 @@
|
|
|
11
11
|
"dev": "rollup -wc rollup.conf.js",
|
|
12
12
|
"clean": "del-cli dist types",
|
|
13
13
|
"build:types": "tsc",
|
|
14
|
-
"build:js": "rollup -c rollup.conf.js"
|
|
15
|
-
"lint": "eslint --ext .ts ."
|
|
14
|
+
"build:js": "rollup -c rollup.conf.js"
|
|
16
15
|
},
|
|
17
16
|
"publishConfig": {
|
|
18
17
|
"access": "public",
|
|
@@ -35,15 +34,17 @@
|
|
|
35
34
|
],
|
|
36
35
|
"repository": "git@github.com:gera2ld/markmap.git",
|
|
37
36
|
"devDependencies": {
|
|
38
|
-
"
|
|
37
|
+
"@types/remarkable": "^2.0.3",
|
|
38
|
+
"markmap-view": "^0.13.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@babel/runtime": "^7.
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"remarkable
|
|
41
|
+
"@babel/runtime": "^7.16.3",
|
|
42
|
+
"js-yaml": "^4.1.0",
|
|
43
|
+
"katex": "^0.15.1",
|
|
44
|
+
"markmap-common": "^0.13.0",
|
|
45
|
+
"prismjs": "^1.25.0",
|
|
46
|
+
"remarkable": "^2.0.1",
|
|
47
|
+
"remarkable-katex": "^1.1.8"
|
|
47
48
|
},
|
|
48
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "4f5096be2e5ee0d666c0868dbb0d163b19b00ffe"
|
|
49
50
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './types';
|
|
2
|
-
export * from './template';
|
|
3
|
-
export * from './transform';
|
|
1
|
+
export * from './types';
|
|
2
|
+
export * from './template';
|
|
3
|
+
export * from './transform';
|
package/types/plugins/base.d.ts
CHANGED
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function createTransformHooks():
|
|
3
|
-
parser: Hook<(md: any, features: any) => void>;
|
|
4
|
-
htmltag: Hook<(ctx: IWrapContext<any>) => void>;
|
|
5
|
-
/**
|
|
6
|
-
* Indicate that the last transformation is not complete for reasons like
|
|
7
|
-
* lack of resources and is called when it is ready for a new transformation.
|
|
8
|
-
*/
|
|
9
|
-
retransform: Hook<() => void>;
|
|
10
|
-
};
|
|
1
|
+
import { ITransformHooks } from '../types';
|
|
2
|
+
export declare function createTransformHooks(): ITransformHooks;
|
package/types/plugins/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import * as katex from './katex';
|
|
2
|
-
import * as prism from './prism';
|
|
3
|
-
|
|
4
|
-
export
|
|
1
|
+
import * as katex from './katex';
|
|
2
|
+
import * as prism from './prism';
|
|
3
|
+
import * as frontmatter from './frontmatter';
|
|
4
|
+
export * from './base';
|
|
5
|
+
export declare const plugins: (typeof katex | typeof prism | typeof frontmatter)[];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { IAssets, ITransformHooks } from '../types';
|
|
2
|
-
export declare const name = "katex";
|
|
3
|
-
export declare function transform(transformHooks: ITransformHooks): IAssets;
|
|
1
|
+
import { IAssets, ITransformHooks } from '../types';
|
|
2
|
+
export declare const name = "katex";
|
|
3
|
+
export declare function transform(transformHooks: ITransformHooks): IAssets;
|
package/types/plugins/katex.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { IAssets, ITransformHooks } from '../types';
|
|
2
|
-
export declare const name = "katex";
|
|
3
|
-
export declare function transform(transformHooks: ITransformHooks): IAssets;
|
|
1
|
+
import { IAssets, ITransformHooks } from '../types';
|
|
2
|
+
export declare const name = "katex";
|
|
3
|
+
export declare function transform(transformHooks: ITransformHooks): IAssets;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { IAssets, ITransformHooks } from '../types';
|
|
2
|
-
export declare const name = "prism";
|
|
3
|
-
export declare function transform(transformHooks: ITransformHooks): IAssets;
|
|
1
|
+
import { IAssets, ITransformHooks } from '../types';
|
|
2
|
+
export declare const name = "prism";
|
|
3
|
+
export declare function transform(transformHooks: ITransformHooks): IAssets;
|
package/types/plugins/prism.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { IAssets, ITransformHooks } from '../types';
|
|
2
|
-
export declare const name = "prism";
|
|
3
|
-
export declare function transform(transformHooks: ITransformHooks): IAssets;
|
|
1
|
+
import { IAssets, ITransformHooks } from '../types';
|
|
2
|
+
export declare const name = "prism";
|
|
3
|
+
export declare function transform(transformHooks: ITransformHooks): IAssets;
|
package/types/template.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { JSItem, INode } from 'markmap-common';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { JSItem, INode } from 'markmap-common';
|
|
2
|
+
import type { IMarkmapOptions, IMarkmapJSONOptions } from 'markmap-view';
|
|
3
|
+
import { IAssets } from './types';
|
|
4
|
+
export declare function fillTemplate(root: INode | undefined, assets: IAssets, extra?: {
|
|
5
|
+
baseJs?: JSItem[];
|
|
6
|
+
jsonOptions?: IMarkmapJSONOptions;
|
|
7
|
+
getOptions?: (markmap: typeof window.markmap, jsonOptions: IMarkmapJSONOptions) => Partial<IMarkmapOptions>;
|
|
8
|
+
}): string;
|
package/types/transform.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { Remarkable } from 'remarkable';
|
|
2
|
-
import { INode } from 'markmap-common';
|
|
3
|
-
import { ITransformResult, ITransformPlugin, IAssets, IAssetsMap, ITransformHooks, IFeatures } from './types';
|
|
4
|
-
import { plugins as builtInPlugins } from './plugins';
|
|
5
|
-
export { builtInPlugins };
|
|
6
|
-
export declare class Transformer {
|
|
7
|
-
plugins: ITransformPlugin[];
|
|
8
|
-
hooks: ITransformHooks;
|
|
9
|
-
md: Remarkable;
|
|
10
|
-
assetsMap: IAssetsMap;
|
|
11
|
-
constructor(plugins?: ITransformPlugin[]);
|
|
12
|
-
buildTree(tokens:
|
|
13
|
-
transform(content: string): ITransformResult;
|
|
14
|
-
/**
|
|
15
|
-
* Get all assets from enabled plugins or filter them by plugin names as keys.
|
|
16
|
-
*/
|
|
17
|
-
getAssets(keys?: string[]): IAssets;
|
|
18
|
-
/**
|
|
19
|
-
* Get used assets by features object returned by `transform`.
|
|
20
|
-
*/
|
|
21
|
-
getUsedAssets(features: IFeatures): IAssets;
|
|
22
|
-
}
|
|
1
|
+
import { Remarkable } from 'remarkable';
|
|
2
|
+
import { INode } from 'markmap-common';
|
|
3
|
+
import { ITransformResult, ITransformPlugin, IAssets, IAssetsMap, ITransformHooks, IFeatures } from './types';
|
|
4
|
+
import { plugins as builtInPlugins } from './plugins';
|
|
5
|
+
export { builtInPlugins };
|
|
6
|
+
export declare class Transformer {
|
|
7
|
+
plugins: ITransformPlugin[];
|
|
8
|
+
hooks: ITransformHooks;
|
|
9
|
+
md: Remarkable;
|
|
10
|
+
assetsMap: IAssetsMap;
|
|
11
|
+
constructor(plugins?: ITransformPlugin[]);
|
|
12
|
+
buildTree(tokens: Remarkable.Token[]): INode;
|
|
13
|
+
transform(content: string): ITransformResult;
|
|
14
|
+
/**
|
|
15
|
+
* Get all assets from enabled plugins or filter them by plugin names as keys.
|
|
16
|
+
*/
|
|
17
|
+
getAssets(keys?: string[]): IAssets;
|
|
18
|
+
/**
|
|
19
|
+
* Get used assets by features object returned by `transform`.
|
|
20
|
+
*/
|
|
21
|
+
getUsedAssets(features: IFeatures): IAssets;
|
|
22
|
+
}
|