markmap-autoloader 0.14.4-alpha.0 → 0.14.4
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/README.md +12 -4
- package/dist/index.js +6 -28
- package/dist/index.min.js +2 -2
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -18,18 +18,26 @@ HTML:
|
|
|
18
18
|
}
|
|
19
19
|
</style>
|
|
20
20
|
|
|
21
|
-
<div class="markmap">
|
|
21
|
+
<div class="markmap"><script type="text/template">
|
|
22
22
|
- markmap
|
|
23
23
|
- autoloader
|
|
24
24
|
- transformer
|
|
25
25
|
- view
|
|
26
|
-
</div>
|
|
26
|
+
</script></div>
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
Note that `<script type="text/template">` is optional, for the content inside to be invisible before the markmap is rendered.
|
|
30
|
+
|
|
31
|
+
Autoload all elements matching `.markmap`, using latest autoloader version:
|
|
30
32
|
|
|
31
33
|
```html
|
|
32
|
-
<script src="https://cdn.jsdelivr.net/npm/markmap-autoloader"></script>
|
|
34
|
+
<script src="https://cdn.jsdelivr.net/npm/markmap-autoloader@latest"></script>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
To use specific version (here: `0.14.3`) of `mark-autoloader`:
|
|
38
|
+
|
|
39
|
+
```html
|
|
40
|
+
<script src="https://cdn.jsdelivr.net/npm/markmap-autoloader@0.14.3"></script>
|
|
33
41
|
```
|
|
34
42
|
|
|
35
43
|
Load manually:
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! markmap-autoloader v0.14.4
|
|
1
|
+
/*! markmap-autoloader v0.14.4 | MIT License */
|
|
2
2
|
this.markmap = this.markmap || {};
|
|
3
3
|
(function (exports) {
|
|
4
4
|
'use strict';
|
|
@@ -24,7 +24,6 @@ function _extends() {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
Math.random().toString(36).slice(2, 8);
|
|
27
|
-
|
|
28
27
|
function memoize(fn) {
|
|
29
28
|
const cache = {};
|
|
30
29
|
return function memoized(...args) {
|
|
@@ -98,21 +97,6 @@ async function loadJSItem(item, context) {
|
|
|
98
97
|
await item.loaded;
|
|
99
98
|
}
|
|
100
99
|
|
|
101
|
-
function loadCSSItem(item) {
|
|
102
|
-
if (item.loaded) return;
|
|
103
|
-
item.loaded = true;
|
|
104
|
-
|
|
105
|
-
if (item.type === 'style') {
|
|
106
|
-
document.head.append(createElement('style', {
|
|
107
|
-
textContent: item.data
|
|
108
|
-
}));
|
|
109
|
-
} else if (item.type === 'stylesheet') {
|
|
110
|
-
document.head.append(createElement('link', _extends({
|
|
111
|
-
rel: 'stylesheet'
|
|
112
|
-
}, item.data)));
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
100
|
async function loadJS(items, context) {
|
|
117
101
|
const needPreload = items.filter(item => {
|
|
118
102
|
var _item$data2;
|
|
@@ -129,12 +113,6 @@ async function loadJS(items, context) {
|
|
|
129
113
|
}
|
|
130
114
|
}
|
|
131
115
|
|
|
132
|
-
function loadCSS(items) {
|
|
133
|
-
for (const item of items) {
|
|
134
|
-
loadCSSItem(item);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
116
|
var _window$markmap, _window$markmap$autoL, _window$markmap2, _window$markmap2$auto;
|
|
139
117
|
const enabled = {};
|
|
140
118
|
const ready = loadJS(((_window$markmap = window.markmap) == null ? void 0 : (_window$markmap$autoL = _window$markmap.autoLoader) == null ? void 0 : _window$markmap$autoL.baseJs) || [{
|
|
@@ -145,7 +123,7 @@ const ready = loadJS(((_window$markmap = window.markmap) == null ? void 0 : (_wi
|
|
|
145
123
|
}, {
|
|
146
124
|
type: 'script',
|
|
147
125
|
data: {
|
|
148
|
-
src: `https://cdn.jsdelivr.net/combine/npm/markmap-lib@${"0.14.
|
|
126
|
+
src: `https://cdn.jsdelivr.net/combine/npm/markmap-lib@${"0.14.4"},npm/markmap-view@${"0.14.4"}`
|
|
149
127
|
}
|
|
150
128
|
}]).then(() => {
|
|
151
129
|
var _markmap$autoLoader;
|
|
@@ -153,10 +131,10 @@ const ready = loadJS(((_window$markmap = window.markmap) == null ? void 0 : (_wi
|
|
|
153
131
|
const {
|
|
154
132
|
markmap
|
|
155
133
|
} = window;
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
134
|
+
const style = document.createElement('style');
|
|
135
|
+
style.textContent = markmap.globalCSS; // Insert global CSS to body so it has higher priority than prism.css, etc.
|
|
136
|
+
|
|
137
|
+
document.body.prepend(style);
|
|
160
138
|
(_markmap$autoLoader = markmap.autoLoader) == null ? void 0 : _markmap$autoLoader.onReady == null ? void 0 : _markmap$autoLoader.onReady();
|
|
161
139
|
});
|
|
162
140
|
|
package/dist/index.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! markmap-autoloader v0.14.4
|
|
1
|
+
/*! markmap-autoloader v0.14.4 | MIT License */
|
|
2
2
|
this.markmap=this.markmap||{},function(t){"use strict";
|
|
3
|
-
/*! markmap-common v0.14.2 | MIT License */function
|
|
3
|
+
/*! markmap-common v0.14.2 | MIT License */function n(){return n=Object.assign||function(t){for(var n=1;n<arguments.length;n++){var e=arguments[n];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a])}return t},n.apply(this,arguments)}function e(t,n,e){const a=document.createElement(t);return n&&Object.entries(n).forEach((([t,n])=>{a[t]=n})),e&&Object.entries(e).forEach((([t,n])=>{a.setAttribute(t,n)})),a}Math.random().toString(36).slice(2,8);const a=function(t){const n={};return function(...e){const a=`${e[0]}`;let r=n[a];return r||(r={value:t(...e)},n[a]=r),r.value}}((t=>{document.head.append(e("link",{rel:"preload",as:"script",href:t}))}));async function r(t,a){if(!t.loaded&&("script"===t.type&&(t.loaded=new Promise(((a,r)=>{var o;document.head.append(e("script",n({},t.data,{onload:a,onerror:r}))),null!=(o=t.data)&&o.src||a(void 0)})).then((()=>{t.loaded=!0}))),"iife"===t.type)){const{fn:n,getParams:e}=t.data;n(...(null==e?void 0:e(a))||[]),t.loaded=!0}await t.loaded}var o,s,d,c;const i={},l=async function(t,e){const o=t.filter((t=>{var n;return"script"===t.type&&(null==(n=t.data)?void 0:n.src)}));o.length>1&&o.forEach((t=>a(t.data.src))),e=n({getMarkmap:()=>window.markmap},e);for(const n of t)await r(n,e)}((null==(o=window.markmap)||null==(s=o.autoLoader)?void 0:s.baseJs)||[{type:"script",data:{src:"https://cdn.jsdelivr.net/npm/d3@6.7.0"}},{type:"script",data:{src:"https://cdn.jsdelivr.net/combine/npm/markmap-lib@0.14.4,npm/markmap-view@0.14.4"}}]).then((()=>{var t;const{markmap:n}=window,e=document.createElement("style");e.textContent=n.globalCSS,document.body.prepend(e),null==(t=n.autoLoader)||null==t.onReady||t.onReady()}));function m(t){const{Transformer:n,Markmap:e,autoLoader:a,deriveOptions:r}=window.markmap,o=t.textContent.split("\n");let s=1/0;o.forEach((t=>{const n=t.match(/^\s*/)[0].length;n<t.length&&(s=Math.min(s,n))}));const d=o.map((t=>t.slice(s))).join("\n").trim(),c=new n(null==a?void 0:a.transformPlugins);t.innerHTML="<svg></svg>";const l=t.firstChild,m=e.create(l,{embedGlobalCSS:!1}),u=()=>{const{root:t,frontmatter:n}=function(t,n){const e=t.transform(n),a=Object.keys(e.features).filter((t=>!i[t]));a.forEach((t=>{i[t]=!0}));const{styles:r,scripts:o}=t.getAssets(a),{markmap:s}=window;return r&&s.loadCSS(r),o&&s.loadJS(o),e}(c,d),e=null==n?void 0:n.markmap,a=r(e);m.setData(t,a),m.fit()};c.hooks.retransform.tap(u),u()}async function u(t){await l,t.querySelectorAll(".markmap").forEach(m)}function p(){return u(document)}null!=(d=window.markmap)&&null!=(c=d.autoLoader)&&c.manual||("loading"===document.readyState?document.addEventListener("DOMContentLoaded",(()=>{p()})):p()),t.ready=l,t.render=m,t.renderAll=p,t.renderAllUnder=u}(this.markmap.autoLoader=this.markmap.autoLoader||{});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markmap-autoloader",
|
|
3
|
-
"version": "0.14.4
|
|
3
|
+
"version": "0.14.4",
|
|
4
4
|
"description": "Load markmaps automatically in HTML",
|
|
5
5
|
"author": "Gerald <gera2ld@live.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"markmap-common": "^0.14.2",
|
|
45
|
-
"markmap-lib": "^0.14.
|
|
46
|
-
"markmap-view": "^0.14.
|
|
45
|
+
"markmap-lib": "^0.14.4",
|
|
46
|
+
"markmap-view": "^0.14.4"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "8eb2fa223ab85d1a7699d2c9660fdb5fac24acd1"
|
|
49
49
|
}
|