markmap-autoloader 0.14.4-alpha.0 → 0.14.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/README.md +4 -2
- package/dist/index.js +6 -27
- package/dist/index.min.js +2 -2
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -18,14 +18,16 @@ 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
|
+
Note that `<script type="text/template">` is optional, for the content inside to be invisible before the markmap is rendered.
|
|
30
|
+
|
|
29
31
|
Autoload all elements matching `.markmap`:
|
|
30
32
|
|
|
31
33
|
```html
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! markmap-autoloader v0.14.4-alpha.
|
|
1
|
+
/*! markmap-autoloader v0.14.4-alpha.1+8a57fea | MIT License */
|
|
2
2
|
this.markmap = this.markmap || {};
|
|
3
3
|
(function (exports) {
|
|
4
4
|
'use strict';
|
|
@@ -98,21 +98,6 @@ async function loadJSItem(item, context) {
|
|
|
98
98
|
await item.loaded;
|
|
99
99
|
}
|
|
100
100
|
|
|
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
101
|
async function loadJS(items, context) {
|
|
117
102
|
const needPreload = items.filter(item => {
|
|
118
103
|
var _item$data2;
|
|
@@ -129,12 +114,6 @@ async function loadJS(items, context) {
|
|
|
129
114
|
}
|
|
130
115
|
}
|
|
131
116
|
|
|
132
|
-
function loadCSS(items) {
|
|
133
|
-
for (const item of items) {
|
|
134
|
-
loadCSSItem(item);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
117
|
var _window$markmap, _window$markmap$autoL, _window$markmap2, _window$markmap2$auto;
|
|
139
118
|
const enabled = {};
|
|
140
119
|
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 +124,7 @@ const ready = loadJS(((_window$markmap = window.markmap) == null ? void 0 : (_wi
|
|
|
145
124
|
}, {
|
|
146
125
|
type: 'script',
|
|
147
126
|
data: {
|
|
148
|
-
src: `https://cdn.jsdelivr.net/combine/npm/markmap-lib@${"0.14.
|
|
127
|
+
src: `https://cdn.jsdelivr.net/combine/npm/markmap-lib@${"0.14.4-alpha.1+8a57fea"},npm/markmap-view@${"0.14.4-alpha.1+8a57fea"}`
|
|
149
128
|
}
|
|
150
129
|
}]).then(() => {
|
|
151
130
|
var _markmap$autoLoader;
|
|
@@ -153,10 +132,10 @@ const ready = loadJS(((_window$markmap = window.markmap) == null ? void 0 : (_wi
|
|
|
153
132
|
const {
|
|
154
133
|
markmap
|
|
155
134
|
} = window;
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
135
|
+
const style = document.createElement('style');
|
|
136
|
+
style.textContent = markmap.globalCSS; // Insert global CSS to body so it has higher priority than prism.css, etc.
|
|
137
|
+
|
|
138
|
+
document.body.prepend(style);
|
|
160
139
|
(_markmap$autoLoader = markmap.autoLoader) == null ? void 0 : _markmap$autoLoader.onReady == null ? void 0 : _markmap$autoLoader.onReady();
|
|
161
140
|
});
|
|
162
141
|
|
package/dist/index.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! markmap-autoloader v0.14.4-alpha.
|
|
1
|
+
/*! markmap-autoloader v0.14.4-alpha.1+8a57fea | 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 a(){return a=Object.assign||function(t){for(var a=1;a<arguments.length;a++){var n=arguments[a];for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])}return t},a.apply(this,arguments)}function n(t,a,n){const e=document.createElement(t);return a&&Object.entries(a).forEach((([t,a])=>{e[t]=a})),n&&Object.entries(n).forEach((([t,a])=>{e.setAttribute(t,a)})),e}Math.random().toString(36).slice(2,8);const e=function(t){const a={};return function(...n){const e=`${n[0]}`;let r=a[e];return r||(r={value:t(...n)},a[e]=r),r.value}}((t=>{document.head.append(n("link",{rel:"preload",as:"script",href:t}))}));async function r(t,e){if(!t.loaded&&("script"===t.type&&(t.loaded=new Promise(((e,r)=>{var o;document.head.append(n("script",a({},t.data,{onload:e,onerror:r}))),null!=(o=t.data)&&o.src||e(void 0)})).then((()=>{t.loaded=!0}))),"iife"===t.type)){const{fn:a,getParams:n}=t.data;a(...(null==n?void 0:n(e))||[]),t.loaded=!0}await t.loaded}var o,s,d,c;const i={},l=async function(t,n){const o=t.filter((t=>{var a;return"script"===t.type&&(null==(a=t.data)?void 0:a.src)}));o.length>1&&o.forEach((t=>e(t.data.src))),n=a({getMarkmap:()=>window.markmap},n);for(const a of t)await r(a,n)}((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-alpha.1+8a57fea,npm/markmap-view@0.14.4-alpha.1+8a57fea"}}]).then((()=>{var t;const{markmap:a}=window,n=document.createElement("style");n.textContent=a.globalCSS,document.body.prepend(n),null==(t=a.autoLoader)||null==t.onReady||t.onReady()}));function m(t){const{Transformer:a,Markmap:n,autoLoader:e,deriveOptions:r}=window.markmap,o=t.textContent.split("\n");let s=1/0;o.forEach((t=>{const a=t.match(/^\s*/)[0].length;a<t.length&&(s=Math.min(s,a))}));const d=o.map((t=>t.slice(s))).join("\n").trim(),c=new a(null==e?void 0:e.transformPlugins);t.innerHTML="<svg></svg>";const l=t.firstChild,m=n.create(l,{embedGlobalCSS:!1}),u=()=>{const{root:t,frontmatter:a}=function(t,a){const n=t.transform(a),e=Object.keys(n.features).filter((t=>!i[t]));e.forEach((t=>{i[t]=!0}));const{styles:r,scripts:o}=t.getAssets(e),{markmap:s}=window;return r&&s.loadCSS(r),o&&s.loadJS(o),n}(c,d),n=null==a?void 0:a.markmap,e=r(n);m.setData(t,e),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-alpha.
|
|
3
|
+
"version": "0.14.4-alpha.1+8a57fea",
|
|
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-alpha.1+8a57fea",
|
|
46
|
+
"markmap-view": "^0.14.4-alpha.1+8a57fea"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "8a57fea7292bee5c50dc0594553d5da62e46d9f8"
|
|
49
49
|
}
|