markmap-lib 0.13.3-alpha.1 → 0.13.4-alpha.1
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 +109 -65
- package/dist/browser/index.min.js +3 -3
- package/dist/index.esm.js +83 -47
- package/dist/index.js +83 -47
- package/package.json +5 -4
- package/types/plugins/katex.browser.d.ts +2 -0
- package/types/plugins/katex.config.d.ts +7 -0
- package/types/plugins/katex.d.ts +2 -0
- package/types/plugins/prism.browser.d.ts +2 -0
- package/types/plugins/prism.config.d.ts +6 -0
- package/types/plugins/prism.d.ts +2 -0
package/dist/browser/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! markmap-lib v0.13.
|
|
1
|
+
/*! markmap-lib v0.13.4-alpha.1+51f8ed9 | MIT License */
|
|
2
2
|
(function (global, factory) {
|
|
3
3
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('katex')) :
|
|
4
4
|
typeof define === 'function' && define.amd ? define(['exports', 'katex'], factory) :
|
|
@@ -27,7 +27,7 @@ function _extends$1() {
|
|
|
27
27
|
return _extends$1.apply(this, arguments);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
/*! markmap-common v0.13.
|
|
30
|
+
/*! markmap-common v0.13.4-alpha.1+51f8ed9 | MIT License */
|
|
31
31
|
class Hook {
|
|
32
32
|
constructor() {
|
|
33
33
|
this.listeners = [];
|
|
@@ -73,6 +73,23 @@ function _extends() {
|
|
|
73
73
|
return _extends.apply(this, arguments);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
77
|
+
if (source == null) return {};
|
|
78
|
+
var target = {};
|
|
79
|
+
var sourceKeys = Object.keys(source);
|
|
80
|
+
var key, i;
|
|
81
|
+
|
|
82
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
83
|
+
key = sourceKeys[i];
|
|
84
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
85
|
+
target[key] = source[key];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return target;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const _excluded = ["textContent"];
|
|
92
|
+
|
|
76
93
|
function escapeHtml$1(html) {
|
|
77
94
|
return html.replace(/[&<"]/g, m => ({
|
|
78
95
|
'&': '&',
|
|
@@ -114,7 +131,15 @@ function buildCode(fn, args) {
|
|
|
114
131
|
|
|
115
132
|
function persistJS(items, context) {
|
|
116
133
|
return items.map(item => {
|
|
117
|
-
if (item.type === 'script')
|
|
134
|
+
if (item.type === 'script') {
|
|
135
|
+
const _item$data = item.data,
|
|
136
|
+
{
|
|
137
|
+
textContent
|
|
138
|
+
} = _item$data,
|
|
139
|
+
rest = _objectWithoutPropertiesLoose(_item$data, _excluded);
|
|
140
|
+
|
|
141
|
+
return wrapHtml('script', textContent || '', rest);
|
|
142
|
+
}
|
|
118
143
|
|
|
119
144
|
if (item.type === 'iife') {
|
|
120
145
|
const {
|
|
@@ -253,7 +278,7 @@ async function loadJS(items, context) {
|
|
|
253
278
|
}
|
|
254
279
|
|
|
255
280
|
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";
|
|
256
|
-
const BASE_JS = [`https://cdn.jsdelivr.net/npm/d3@${"6.7.0"}`, `https://cdn.jsdelivr.net/npm/markmap-view@${"0.13.
|
|
281
|
+
const BASE_JS = [`https://cdn.jsdelivr.net/npm/d3@${"6.7.0"}`, `https://cdn.jsdelivr.net/npm/markmap-view@${"0.13.4-alpha.1+51f8ed9"}`].map(src => ({
|
|
257
282
|
type: 'script',
|
|
258
283
|
data: {
|
|
259
284
|
src
|
|
@@ -8218,7 +8243,7 @@ var commonmarkConfig = {
|
|
|
8218
8243
|
* Preset configs
|
|
8219
8244
|
*/
|
|
8220
8245
|
|
|
8221
|
-
var config = {
|
|
8246
|
+
var config$2 = {
|
|
8222
8247
|
'default': defaultConfig,
|
|
8223
8248
|
'full': fullConfig,
|
|
8224
8249
|
'commonmark': commonmarkConfig
|
|
@@ -8267,7 +8292,7 @@ function Remarkable(preset, options) {
|
|
|
8267
8292
|
this.renderer = new Renderer();
|
|
8268
8293
|
this.ruler = new Ruler();
|
|
8269
8294
|
this.options = {};
|
|
8270
|
-
this.configure(config[preset]);
|
|
8295
|
+
this.configure(config$2[preset]);
|
|
8271
8296
|
this.set(options || {});
|
|
8272
8297
|
}
|
|
8273
8298
|
/**
|
|
@@ -8585,18 +8610,55 @@ const rkatex = (md, options) => {
|
|
|
8585
8610
|
|
|
8586
8611
|
var remarkableKatex = rkatex;
|
|
8587
8612
|
|
|
8588
|
-
|
|
8613
|
+
var config$1 = {
|
|
8614
|
+
preloadScripts: [{
|
|
8615
|
+
type: 'script',
|
|
8616
|
+
data: {
|
|
8617
|
+
src: `https://cdn.jsdelivr.net/npm/katex@${"0.15.3"}/dist/katex.min.js`
|
|
8618
|
+
}
|
|
8619
|
+
}],
|
|
8620
|
+
scripts: [{
|
|
8621
|
+
type: 'iife',
|
|
8622
|
+
data: {
|
|
8623
|
+
fn: getMarkmap => {
|
|
8624
|
+
window.WebFontConfig = {
|
|
8625
|
+
custom: {
|
|
8626
|
+
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']
|
|
8627
|
+
},
|
|
8628
|
+
active: () => {
|
|
8629
|
+
getMarkmap().refreshHook.call();
|
|
8630
|
+
}
|
|
8631
|
+
};
|
|
8632
|
+
},
|
|
8589
8633
|
|
|
8590
|
-
|
|
8591
|
-
|
|
8634
|
+
getParams({
|
|
8635
|
+
getMarkmap
|
|
8636
|
+
}) {
|
|
8637
|
+
return [getMarkmap];
|
|
8638
|
+
}
|
|
8639
|
+
|
|
8640
|
+
}
|
|
8641
|
+
}, {
|
|
8592
8642
|
type: 'script',
|
|
8593
8643
|
data: {
|
|
8594
|
-
src:
|
|
8644
|
+
src: `https://cdn.jsdelivr.net/npm/webfontloader@${"1.6.28"}/webfontloader.js`,
|
|
8645
|
+
defer: true
|
|
8595
8646
|
}
|
|
8596
|
-
}]
|
|
8597
|
-
|
|
8647
|
+
}],
|
|
8648
|
+
styles: [{
|
|
8649
|
+
type: 'stylesheet',
|
|
8650
|
+
data: {
|
|
8651
|
+
href: `https://cdn.jsdelivr.net/npm/katex@${"0.15.3"}/dist/katex.min.css`
|
|
8652
|
+
}
|
|
8653
|
+
}]
|
|
8598
8654
|
};
|
|
8599
8655
|
|
|
8656
|
+
let loading$1;
|
|
8657
|
+
|
|
8658
|
+
const autoload$1 = () => {
|
|
8659
|
+
loading$1 || (loading$1 = loadJS(config$1.preloadScripts));
|
|
8660
|
+
return loading$1;
|
|
8661
|
+
};
|
|
8600
8662
|
const name$2 = 'katex';
|
|
8601
8663
|
function transform$2(transformHooks) {
|
|
8602
8664
|
const renderKatex = (source, displayMode) => {
|
|
@@ -8634,63 +8696,42 @@ function transform$2(transformHooks) {
|
|
|
8634
8696
|
};
|
|
8635
8697
|
});
|
|
8636
8698
|
return {
|
|
8637
|
-
styles:
|
|
8638
|
-
|
|
8639
|
-
data: {
|
|
8640
|
-
href: 'https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.css'
|
|
8641
|
-
}
|
|
8642
|
-
}],
|
|
8643
|
-
scripts: [{
|
|
8644
|
-
type: 'iife',
|
|
8645
|
-
data: {
|
|
8646
|
-
fn: getMarkmap => {
|
|
8647
|
-
window.WebFontConfig = {
|
|
8648
|
-
custom: {
|
|
8649
|
-
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']
|
|
8650
|
-
},
|
|
8651
|
-
active: () => {
|
|
8652
|
-
getMarkmap().refreshHook.call();
|
|
8653
|
-
}
|
|
8654
|
-
};
|
|
8655
|
-
},
|
|
8656
|
-
|
|
8657
|
-
getParams({
|
|
8658
|
-
getMarkmap
|
|
8659
|
-
}) {
|
|
8660
|
-
return [getMarkmap];
|
|
8661
|
-
}
|
|
8662
|
-
|
|
8663
|
-
}
|
|
8664
|
-
}, {
|
|
8665
|
-
type: 'script',
|
|
8666
|
-
data: {
|
|
8667
|
-
src: 'https://cdn.jsdelivr.net/npm/webfontloader@1.6.28/webfontloader.js',
|
|
8668
|
-
defer: true
|
|
8669
|
-
}
|
|
8670
|
-
}]
|
|
8699
|
+
styles: config$1.styles,
|
|
8700
|
+
scripts: config$1.scripts
|
|
8671
8701
|
};
|
|
8672
8702
|
}
|
|
8673
8703
|
|
|
8674
8704
|
var katex = /*#__PURE__*/Object.freeze({
|
|
8675
8705
|
__proto__: null,
|
|
8706
|
+
config: config$1,
|
|
8676
8707
|
name: name$2,
|
|
8677
8708
|
transform: transform$2
|
|
8678
8709
|
});
|
|
8679
8710
|
|
|
8680
|
-
|
|
8681
|
-
|
|
8682
|
-
const autoload = () => {
|
|
8683
|
-
loading || (loading = loadJS([{
|
|
8711
|
+
var config = {
|
|
8712
|
+
preloadScripts: [{
|
|
8684
8713
|
type: 'script',
|
|
8685
8714
|
data: {
|
|
8686
|
-
src: `https://cdn.jsdelivr.net/npm/prismjs@${"1.
|
|
8715
|
+
src: `https://cdn.jsdelivr.net/npm/prismjs@${"1.28.0"}/components/prism-core.min.js`
|
|
8687
8716
|
}
|
|
8688
8717
|
}, {
|
|
8689
8718
|
type: 'script',
|
|
8690
8719
|
data: {
|
|
8691
|
-
src: `https://cdn.jsdelivr.net/npm/prismjs@${"1.
|
|
8720
|
+
src: `https://cdn.jsdelivr.net/npm/prismjs@${"1.28.0"}/plugins/autoloader/prism-autoloader.min.js`
|
|
8721
|
+
}
|
|
8722
|
+
}],
|
|
8723
|
+
styles: [{
|
|
8724
|
+
type: 'stylesheet',
|
|
8725
|
+
data: {
|
|
8726
|
+
href: `https://cdn.jsdelivr.net/npm/prismjs@${"1.28.0"}/themes/prism.css`
|
|
8692
8727
|
}
|
|
8693
|
-
}]
|
|
8728
|
+
}]
|
|
8729
|
+
};
|
|
8730
|
+
|
|
8731
|
+
let loading;
|
|
8732
|
+
|
|
8733
|
+
const autoload = () => {
|
|
8734
|
+
loading || (loading = loadJS(config.preloadScripts));
|
|
8694
8735
|
return loading;
|
|
8695
8736
|
};
|
|
8696
8737
|
|
|
@@ -8701,7 +8742,6 @@ function loadLanguageAndRefresh(lang, transformHooks) {
|
|
|
8701
8742
|
});
|
|
8702
8743
|
});
|
|
8703
8744
|
}
|
|
8704
|
-
|
|
8705
8745
|
const name$1 = 'prism';
|
|
8706
8746
|
function transform$1(transformHooks) {
|
|
8707
8747
|
let enableFeature = () => {};
|
|
@@ -8732,17 +8772,13 @@ function transform$1(transformHooks) {
|
|
|
8732
8772
|
};
|
|
8733
8773
|
});
|
|
8734
8774
|
return {
|
|
8735
|
-
styles:
|
|
8736
|
-
type: 'stylesheet',
|
|
8737
|
-
data: {
|
|
8738
|
-
href: `https://cdn.jsdelivr.net/npm/prismjs@${"1.25.0"}/themes/prism.css`
|
|
8739
|
-
}
|
|
8740
|
-
}]
|
|
8775
|
+
styles: config.styles
|
|
8741
8776
|
};
|
|
8742
8777
|
}
|
|
8743
8778
|
|
|
8744
8779
|
var prism = /*#__PURE__*/Object.freeze({
|
|
8745
8780
|
__proto__: null,
|
|
8781
|
+
config: config,
|
|
8746
8782
|
name: name$1,
|
|
8747
8783
|
transform: transform$1
|
|
8748
8784
|
});
|
|
@@ -12645,7 +12681,7 @@ function createTransformHooks() {
|
|
|
12645
12681
|
|
|
12646
12682
|
const plugins = [katex, prism, frontmatter];
|
|
12647
12683
|
|
|
12648
|
-
function cleanNode(node
|
|
12684
|
+
function cleanNode(node) {
|
|
12649
12685
|
if (node.type === 'heading') {
|
|
12650
12686
|
// drop all paragraphs
|
|
12651
12687
|
node.children = node.children.filter(item => item.type !== 'paragraph');
|
|
@@ -12686,14 +12722,21 @@ function cleanNode(node, depth = 0) {
|
|
|
12686
12722
|
if (node.children.length === 0) {
|
|
12687
12723
|
delete node.children;
|
|
12688
12724
|
} else {
|
|
12689
|
-
node.children.forEach(child => cleanNode(child
|
|
12725
|
+
node.children.forEach(child => cleanNode(child));
|
|
12690
12726
|
|
|
12691
12727
|
if (node.children.length === 1 && !node.children[0].content) {
|
|
12692
12728
|
node.children = node.children[0].children;
|
|
12693
12729
|
}
|
|
12694
12730
|
}
|
|
12731
|
+
}
|
|
12732
|
+
|
|
12733
|
+
function resetDepth(node, depth = 0) {
|
|
12734
|
+
var _node$children;
|
|
12695
12735
|
|
|
12696
12736
|
node.depth = depth;
|
|
12737
|
+
(_node$children = node.children) == null ? void 0 : _node$children.forEach(child => {
|
|
12738
|
+
resetDepth(child, depth + 1);
|
|
12739
|
+
});
|
|
12697
12740
|
}
|
|
12698
12741
|
|
|
12699
12742
|
class Transformer {
|
|
@@ -12789,10 +12832,10 @@ class Transformer {
|
|
|
12789
12832
|
} else if (token.type === 'inline') {
|
|
12790
12833
|
const revoke = this.hooks.htmltag.tap(ctx => {
|
|
12791
12834
|
const comment = ctx.result.match(/^<!--([\s\S]*?)-->$/);
|
|
12792
|
-
const data = comment == null ? void 0 : comment[1].trim();
|
|
12835
|
+
const data = comment == null ? void 0 : comment[1].trim().split(' ');
|
|
12793
12836
|
|
|
12794
|
-
if (data === 'fold') {
|
|
12795
|
-
current.payload.fold =
|
|
12837
|
+
if (data[0] === 'fold') {
|
|
12838
|
+
current.payload.fold = ['all', 'recursively'].includes(data[1]) ? 2 : 1;
|
|
12796
12839
|
ctx.result = '';
|
|
12797
12840
|
}
|
|
12798
12841
|
});
|
|
@@ -12827,6 +12870,7 @@ class Transformer {
|
|
|
12827
12870
|
let root = this.buildTree(tokens);
|
|
12828
12871
|
cleanNode(root);
|
|
12829
12872
|
if (((_root$children = root.children) == null ? void 0 : _root$children.length) === 1) root = root.children[0];
|
|
12873
|
+
resetDepth(root);
|
|
12830
12874
|
return _extends$1({}, context, {
|
|
12831
12875
|
root
|
|
12832
12876
|
});
|