markmap-lib 0.15.0 → 0.15.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 +453 -50
- package/dist/browser/index.mjs +2 -2
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/package.json +2 -2
package/dist/browser/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
/*! markmap-lib v0.15.
|
|
1
|
+
/*! markmap-lib v0.15.1 | MIT License */
|
|
2
2
|
(function (global, factory) {
|
|
3
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('
|
|
4
|
-
typeof define === 'function' && define.amd ? define(['exports', '
|
|
5
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.markmap = global.markmap || {}, global.
|
|
6
|
-
})(this, (function (exports,
|
|
3
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('katex'), require('highlight.js')) :
|
|
4
|
+
typeof define === 'function' && define.amd ? define(['exports', 'katex', 'highlight.js'], factory) :
|
|
5
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.markmap = global.markmap || {}, global.window.katex, global.window.hljs));
|
|
6
|
+
})(this, (function (exports, require$$0, hljs) { 'use strict';
|
|
7
7
|
|
|
8
8
|
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" ;
|
|
9
9
|
const baseJsPaths = [`d3@${"7.8.5"}/dist/d3.min.js`, `markmap-view@${"0.15.0"}/dist/browser/index.js`];
|
|
10
10
|
|
|
11
|
-
function _extends() {
|
|
12
|
-
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
11
|
+
function _extends$1() {
|
|
12
|
+
_extends$1 = Object.assign ? Object.assign.bind() : function (target) {
|
|
13
13
|
for (var i = 1; i < arguments.length; i++) {
|
|
14
14
|
var source = arguments[i];
|
|
15
15
|
for (var key in source) {
|
|
@@ -20,7 +20,7 @@ function _extends() {
|
|
|
20
20
|
}
|
|
21
21
|
return target;
|
|
22
22
|
};
|
|
23
|
-
return _extends.apply(this, arguments);
|
|
23
|
+
return _extends$1.apply(this, arguments);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
// List of valid entities
|
|
@@ -2279,7 +2279,7 @@ var HTML_REPLACEMENTS = {
|
|
|
2279
2279
|
function replaceUnsafeChar(ch) {
|
|
2280
2280
|
return HTML_REPLACEMENTS[ch];
|
|
2281
2281
|
}
|
|
2282
|
-
function escapeHtml(str) {
|
|
2282
|
+
function escapeHtml$1(str) {
|
|
2283
2283
|
if (HTML_ESCAPE_TEST_RE.test(str)) {
|
|
2284
2284
|
return str.replace(HTML_ESCAPE_REPLACE_RE, replaceUnsafeChar);
|
|
2285
2285
|
}
|
|
@@ -2310,9 +2310,9 @@ rules.blockquote_close = function (tokens, idx /*, options, env */) {
|
|
|
2310
2310
|
|
|
2311
2311
|
rules.code = function (tokens, idx /*, options, env */) {
|
|
2312
2312
|
if (tokens[idx].block) {
|
|
2313
|
-
return '<pre><code>' + escapeHtml(tokens[idx].content) + '</code></pre>' + getBreak(tokens, idx);
|
|
2313
|
+
return '<pre><code>' + escapeHtml$1(tokens[idx].content) + '</code></pre>' + getBreak(tokens, idx);
|
|
2314
2314
|
}
|
|
2315
|
-
return '<code>' + escapeHtml(tokens[idx].content) + '</code>';
|
|
2315
|
+
return '<code>' + escapeHtml$1(tokens[idx].content) + '</code>';
|
|
2316
2316
|
};
|
|
2317
2317
|
|
|
2318
2318
|
/**
|
|
@@ -2340,13 +2340,13 @@ rules.fence = function (tokens, idx, options, env, instance) {
|
|
|
2340
2340
|
if (has$1(instance.rules.fence_custom, fences[0])) {
|
|
2341
2341
|
return instance.rules.fence_custom[fences[0]](tokens, idx, options, env, instance);
|
|
2342
2342
|
}
|
|
2343
|
-
langName = escapeHtml(replaceEntities(unescapeMd(fenceName)));
|
|
2343
|
+
langName = escapeHtml$1(replaceEntities(unescapeMd(fenceName)));
|
|
2344
2344
|
langClass = ' class="' + langPrefix + langName + '"';
|
|
2345
2345
|
}
|
|
2346
2346
|
if (options.highlight) {
|
|
2347
|
-
highlighted = options.highlight.apply(options.highlight, [token.content].concat(fences)) || escapeHtml(token.content);
|
|
2347
|
+
highlighted = options.highlight.apply(options.highlight, [token.content].concat(fences)) || escapeHtml$1(token.content);
|
|
2348
2348
|
} else {
|
|
2349
|
-
highlighted = escapeHtml(token.content);
|
|
2349
|
+
highlighted = escapeHtml$1(token.content);
|
|
2350
2350
|
}
|
|
2351
2351
|
return '<pre><code' + langClass + '>' + highlighted + '</code></pre>' + getBreak(tokens, idx);
|
|
2352
2352
|
};
|
|
@@ -2426,9 +2426,9 @@ rules.paragraph_close = function (tokens, idx /*, options, env */) {
|
|
|
2426
2426
|
*/
|
|
2427
2427
|
|
|
2428
2428
|
rules.link_open = function (tokens, idx, options /* env */) {
|
|
2429
|
-
var title = tokens[idx].title ? ' title="' + escapeHtml(replaceEntities(tokens[idx].title)) + '"' : '';
|
|
2429
|
+
var title = tokens[idx].title ? ' title="' + escapeHtml$1(replaceEntities(tokens[idx].title)) + '"' : '';
|
|
2430
2430
|
var target = options.linkTarget ? ' target="' + options.linkTarget + '"' : '';
|
|
2431
|
-
return '<a href="' + escapeHtml(tokens[idx].href) + '"' + title + target + '>';
|
|
2431
|
+
return '<a href="' + escapeHtml$1(tokens[idx].href) + '"' + title + target + '>';
|
|
2432
2432
|
};
|
|
2433
2433
|
rules.link_close = function /* tokens, idx, options, env */
|
|
2434
2434
|
() {
|
|
@@ -2440,9 +2440,9 @@ rules.link_close = function /* tokens, idx, options, env */
|
|
|
2440
2440
|
*/
|
|
2441
2441
|
|
|
2442
2442
|
rules.image = function (tokens, idx, options /*, env */) {
|
|
2443
|
-
var src = ' src="' + escapeHtml(tokens[idx].src) + '"';
|
|
2444
|
-
var title = tokens[idx].title ? ' title="' + escapeHtml(replaceEntities(tokens[idx].title)) + '"' : '';
|
|
2445
|
-
var alt = ' alt="' + (tokens[idx].alt ? escapeHtml(replaceEntities(unescapeMd(tokens[idx].alt))) : '') + '"';
|
|
2443
|
+
var src = ' src="' + escapeHtml$1(tokens[idx].src) + '"';
|
|
2444
|
+
var title = tokens[idx].title ? ' title="' + escapeHtml$1(replaceEntities(tokens[idx].title)) + '"' : '';
|
|
2445
|
+
var alt = ' alt="' + (tokens[idx].alt ? escapeHtml$1(replaceEntities(unescapeMd(tokens[idx].alt))) : '') + '"';
|
|
2446
2446
|
var suffix = options.xhtmlOut ? ' /' : '';
|
|
2447
2447
|
return '<img' + src + alt + title + suffix + '>';
|
|
2448
2448
|
};
|
|
@@ -2570,10 +2570,10 @@ rules.mark_close = function /* tokens, idx, options, env */
|
|
|
2570
2570
|
*/
|
|
2571
2571
|
|
|
2572
2572
|
rules.sub = function (tokens, idx /*, options, env */) {
|
|
2573
|
-
return '<sub>' + escapeHtml(tokens[idx].content) + '</sub>';
|
|
2573
|
+
return '<sub>' + escapeHtml$1(tokens[idx].content) + '</sub>';
|
|
2574
2574
|
};
|
|
2575
2575
|
rules.sup = function (tokens, idx /*, options, env */) {
|
|
2576
|
-
return '<sup>' + escapeHtml(tokens[idx].content) + '</sup>';
|
|
2576
|
+
return '<sup>' + escapeHtml$1(tokens[idx].content) + '</sup>';
|
|
2577
2577
|
};
|
|
2578
2578
|
|
|
2579
2579
|
/**
|
|
@@ -2592,7 +2592,7 @@ rules.softbreak = function (tokens, idx, options /*, env */) {
|
|
|
2592
2592
|
*/
|
|
2593
2593
|
|
|
2594
2594
|
rules.text = function (tokens, idx /*, options, env */) {
|
|
2595
|
-
return escapeHtml(tokens[idx].content);
|
|
2595
|
+
return escapeHtml$1(tokens[idx].content);
|
|
2596
2596
|
};
|
|
2597
2597
|
|
|
2598
2598
|
/**
|
|
@@ -2611,7 +2611,7 @@ rules.htmltag = function (tokens, idx /*, options, env */) {
|
|
|
2611
2611
|
*/
|
|
2612
2612
|
|
|
2613
2613
|
rules.abbr_open = function (tokens, idx /*, options, env */) {
|
|
2614
|
-
return '<abbr title="' + escapeHtml(replaceEntities(tokens[idx].title)) + '">';
|
|
2614
|
+
return '<abbr title="' + escapeHtml$1(replaceEntities(tokens[idx].title)) + '">';
|
|
2615
2615
|
};
|
|
2616
2616
|
rules.abbr_close = function /* tokens, idx, options, env */
|
|
2617
2617
|
() {
|
|
@@ -7119,6 +7119,409 @@ Remarkable.prototype.renderInline = function (str, env) {
|
|
|
7119
7119
|
return this.renderer.render(this.parseInline(str, env), this.options, env);
|
|
7120
7120
|
};
|
|
7121
7121
|
|
|
7122
|
+
/*! markmap-common v0.15.0 | MIT License */
|
|
7123
|
+
function _extends() {
|
|
7124
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
7125
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
7126
|
+
var source = arguments[i];
|
|
7127
|
+
for (var key in source) {
|
|
7128
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
7129
|
+
target[key] = source[key];
|
|
7130
|
+
}
|
|
7131
|
+
}
|
|
7132
|
+
}
|
|
7133
|
+
return target;
|
|
7134
|
+
};
|
|
7135
|
+
return _extends.apply(this, arguments);
|
|
7136
|
+
}
|
|
7137
|
+
const testPath = "npm2url/dist/index.cjs";
|
|
7138
|
+
const defaultProviders = {
|
|
7139
|
+
jsdelivr: path => `https://cdn.jsdelivr.net/npm/${path}`,
|
|
7140
|
+
unpkg: path => `https://unpkg.com/${path}`
|
|
7141
|
+
};
|
|
7142
|
+
class UrlBuilder {
|
|
7143
|
+
constructor() {
|
|
7144
|
+
this.providers = _extends({}, defaultProviders);
|
|
7145
|
+
this.provider = "jsdelivr";
|
|
7146
|
+
}
|
|
7147
|
+
getFastestProvider(path = testPath) {
|
|
7148
|
+
return Promise.any(Object.entries(this.providers).map(async ([name, factory]) => {
|
|
7149
|
+
const res = await fetch(factory(path));
|
|
7150
|
+
if (!res.ok) {
|
|
7151
|
+
throw res;
|
|
7152
|
+
}
|
|
7153
|
+
await res.text();
|
|
7154
|
+
return name;
|
|
7155
|
+
}));
|
|
7156
|
+
}
|
|
7157
|
+
async findFastestProvider() {
|
|
7158
|
+
this.provider = await this.getFastestProvider();
|
|
7159
|
+
return this.provider;
|
|
7160
|
+
}
|
|
7161
|
+
setProvider(name, factory) {
|
|
7162
|
+
if (factory) {
|
|
7163
|
+
this.providers[name] = factory;
|
|
7164
|
+
} else {
|
|
7165
|
+
delete this.providers[name];
|
|
7166
|
+
}
|
|
7167
|
+
}
|
|
7168
|
+
getFullUrl(path, provider = this.provider) {
|
|
7169
|
+
if (path.includes("://")) {
|
|
7170
|
+
return path;
|
|
7171
|
+
}
|
|
7172
|
+
const factory = this.providers[provider];
|
|
7173
|
+
if (!factory) {
|
|
7174
|
+
throw new Error(`Provider ${provider} not found`);
|
|
7175
|
+
}
|
|
7176
|
+
return factory(path);
|
|
7177
|
+
}
|
|
7178
|
+
}
|
|
7179
|
+
new UrlBuilder();
|
|
7180
|
+
class Hook {
|
|
7181
|
+
constructor() {
|
|
7182
|
+
this.listeners = [];
|
|
7183
|
+
}
|
|
7184
|
+
tap(fn) {
|
|
7185
|
+
this.listeners.push(fn);
|
|
7186
|
+
return () => this.revoke(fn);
|
|
7187
|
+
}
|
|
7188
|
+
revoke(fn) {
|
|
7189
|
+
const i = this.listeners.indexOf(fn);
|
|
7190
|
+
if (i >= 0) this.listeners.splice(i, 1);
|
|
7191
|
+
}
|
|
7192
|
+
revokeAll() {
|
|
7193
|
+
this.listeners.splice(0);
|
|
7194
|
+
}
|
|
7195
|
+
call(...args) {
|
|
7196
|
+
for (const fn of this.listeners) {
|
|
7197
|
+
fn(...args);
|
|
7198
|
+
}
|
|
7199
|
+
}
|
|
7200
|
+
}
|
|
7201
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
7202
|
+
if (source == null) return {};
|
|
7203
|
+
var target = {};
|
|
7204
|
+
var sourceKeys = Object.keys(source);
|
|
7205
|
+
var key, i;
|
|
7206
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
7207
|
+
key = sourceKeys[i];
|
|
7208
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
7209
|
+
target[key] = source[key];
|
|
7210
|
+
}
|
|
7211
|
+
return target;
|
|
7212
|
+
}
|
|
7213
|
+
const _excluded = ["textContent"];
|
|
7214
|
+
const escapeChars = {
|
|
7215
|
+
'&': '&',
|
|
7216
|
+
'<': '<',
|
|
7217
|
+
'"': '"'
|
|
7218
|
+
};
|
|
7219
|
+
function escapeHtml(html) {
|
|
7220
|
+
return html.replace(/[&<"]/g, m => escapeChars[m]);
|
|
7221
|
+
}
|
|
7222
|
+
function escapeScript(content) {
|
|
7223
|
+
return content.replace(/<(\/script>)/g, '\\x3c$2');
|
|
7224
|
+
}
|
|
7225
|
+
function htmlOpen(tagName, attrs) {
|
|
7226
|
+
const attrStr = attrs ? Object.entries(attrs).map(([key, value]) => {
|
|
7227
|
+
if (value == null || value === false) return;
|
|
7228
|
+
key = ` ${escapeHtml(key)}`;
|
|
7229
|
+
if (value === true) return key;
|
|
7230
|
+
return `${key}="${escapeHtml(value)}"`;
|
|
7231
|
+
}).filter(Boolean).join('') : '';
|
|
7232
|
+
return `<${tagName}${attrStr}>`;
|
|
7233
|
+
}
|
|
7234
|
+
function htmlClose(tagName) {
|
|
7235
|
+
return `</${tagName}>`;
|
|
7236
|
+
}
|
|
7237
|
+
function wrapHtml(tagName, content, attrs) {
|
|
7238
|
+
if (content == null) return htmlOpen(tagName, attrs);
|
|
7239
|
+
return htmlOpen(tagName, attrs) + (content || '') + htmlClose(tagName);
|
|
7240
|
+
}
|
|
7241
|
+
function buildCode(fn, args) {
|
|
7242
|
+
const params = args.map(arg => {
|
|
7243
|
+
if (typeof arg === 'function') return arg.toString();
|
|
7244
|
+
return JSON.stringify(arg != null ? arg : null);
|
|
7245
|
+
}).join(',');
|
|
7246
|
+
return `(${fn.toString()})(${params})`;
|
|
7247
|
+
}
|
|
7248
|
+
function persistJS(items, context) {
|
|
7249
|
+
return items.map(item => {
|
|
7250
|
+
if (item.type === 'script') {
|
|
7251
|
+
const _item$data = item.data,
|
|
7252
|
+
{
|
|
7253
|
+
textContent
|
|
7254
|
+
} = _item$data,
|
|
7255
|
+
rest = _objectWithoutPropertiesLoose(_item$data, _excluded);
|
|
7256
|
+
return wrapHtml('script', textContent || '', rest);
|
|
7257
|
+
}
|
|
7258
|
+
if (item.type === 'iife') {
|
|
7259
|
+
const {
|
|
7260
|
+
fn,
|
|
7261
|
+
getParams
|
|
7262
|
+
} = item.data;
|
|
7263
|
+
return wrapHtml('script', escapeScript(buildCode(fn, (getParams == null ? void 0 : getParams(context)) || [])));
|
|
7264
|
+
}
|
|
7265
|
+
return '';
|
|
7266
|
+
});
|
|
7267
|
+
}
|
|
7268
|
+
function persistCSS(items) {
|
|
7269
|
+
return items.map(item => {
|
|
7270
|
+
if (item.type === 'stylesheet') {
|
|
7271
|
+
return wrapHtml('link', null, _extends({
|
|
7272
|
+
rel: 'stylesheet'
|
|
7273
|
+
}, item.data));
|
|
7274
|
+
}
|
|
7275
|
+
/* else if (item.type === 'style') */
|
|
7276
|
+
return wrapHtml('style', item.data);
|
|
7277
|
+
});
|
|
7278
|
+
}
|
|
7279
|
+
Math.random().toString(36).slice(2, 8);
|
|
7280
|
+
function noop() {
|
|
7281
|
+
// noop
|
|
7282
|
+
}
|
|
7283
|
+
function wrapFunction(fn, wrapper) {
|
|
7284
|
+
return (...args) => wrapper(fn, ...args);
|
|
7285
|
+
}
|
|
7286
|
+
function memoize(fn) {
|
|
7287
|
+
const cache = {};
|
|
7288
|
+
return function memoized(...args) {
|
|
7289
|
+
const key = `${args[0]}`;
|
|
7290
|
+
let data = cache[key];
|
|
7291
|
+
if (!data) {
|
|
7292
|
+
data = {
|
|
7293
|
+
value: fn(...args)
|
|
7294
|
+
};
|
|
7295
|
+
cache[key] = data;
|
|
7296
|
+
}
|
|
7297
|
+
return data.value;
|
|
7298
|
+
};
|
|
7299
|
+
}
|
|
7300
|
+
|
|
7301
|
+
/*! @gera2ld/jsx-dom v2.2.2 | ISC License */
|
|
7302
|
+
const VTYPE_ELEMENT = 1;
|
|
7303
|
+
const VTYPE_FUNCTION = 2;
|
|
7304
|
+
const SVG_NS = 'http://www.w3.org/2000/svg';
|
|
7305
|
+
const XLINK_NS = 'http://www.w3.org/1999/xlink';
|
|
7306
|
+
const NS_ATTRS = {
|
|
7307
|
+
show: XLINK_NS,
|
|
7308
|
+
actuate: XLINK_NS,
|
|
7309
|
+
href: XLINK_NS
|
|
7310
|
+
};
|
|
7311
|
+
const isLeaf = c => typeof c === 'string' || typeof c === 'number';
|
|
7312
|
+
const isElement = c => (c == null ? void 0 : c.vtype) === VTYPE_ELEMENT;
|
|
7313
|
+
const isRenderFunction = c => (c == null ? void 0 : c.vtype) === VTYPE_FUNCTION;
|
|
7314
|
+
function h(type, props, ...children) {
|
|
7315
|
+
props = Object.assign({}, props, {
|
|
7316
|
+
children: children.length === 1 ? children[0] : children
|
|
7317
|
+
});
|
|
7318
|
+
return jsx(type, props);
|
|
7319
|
+
}
|
|
7320
|
+
function jsx(type, props) {
|
|
7321
|
+
let vtype;
|
|
7322
|
+
if (typeof type === 'string') vtype = VTYPE_ELEMENT;else if (typeof type === 'function') vtype = VTYPE_FUNCTION;else throw new Error('Invalid VNode type');
|
|
7323
|
+
return {
|
|
7324
|
+
vtype,
|
|
7325
|
+
type,
|
|
7326
|
+
props
|
|
7327
|
+
};
|
|
7328
|
+
}
|
|
7329
|
+
function Fragment(props) {
|
|
7330
|
+
return props.children;
|
|
7331
|
+
}
|
|
7332
|
+
const DEFAULT_ENV = {
|
|
7333
|
+
isSvg: false
|
|
7334
|
+
};
|
|
7335
|
+
function insertDom(parent, nodes) {
|
|
7336
|
+
if (!Array.isArray(nodes)) nodes = [nodes];
|
|
7337
|
+
nodes = nodes.filter(Boolean);
|
|
7338
|
+
if (nodes.length) parent.append(...nodes);
|
|
7339
|
+
}
|
|
7340
|
+
function mountAttributes(domElement, props, env) {
|
|
7341
|
+
for (const key in props) {
|
|
7342
|
+
if (key === 'key' || key === 'children' || key === 'ref') continue;
|
|
7343
|
+
if (key === 'dangerouslySetInnerHTML') {
|
|
7344
|
+
domElement.innerHTML = props[key].__html;
|
|
7345
|
+
} else if (key === 'innerHTML' || key === 'textContent' || key === 'innerText' || key === 'value' && ['textarea', 'select'].includes(domElement.tagName)) {
|
|
7346
|
+
const value = props[key];
|
|
7347
|
+
if (value != null) domElement[key] = value;
|
|
7348
|
+
} else if (key.startsWith('on')) {
|
|
7349
|
+
domElement[key.toLowerCase()] = props[key];
|
|
7350
|
+
} else {
|
|
7351
|
+
setDOMAttribute(domElement, key, props[key], env.isSvg);
|
|
7352
|
+
}
|
|
7353
|
+
}
|
|
7354
|
+
}
|
|
7355
|
+
const attrMap = {
|
|
7356
|
+
className: 'class',
|
|
7357
|
+
labelFor: 'for'
|
|
7358
|
+
};
|
|
7359
|
+
function setDOMAttribute(el, attr, value, isSVG) {
|
|
7360
|
+
attr = attrMap[attr] || attr;
|
|
7361
|
+
if (value === true) {
|
|
7362
|
+
el.setAttribute(attr, '');
|
|
7363
|
+
} else if (value === false) {
|
|
7364
|
+
el.removeAttribute(attr);
|
|
7365
|
+
} else {
|
|
7366
|
+
const namespace = isSVG ? NS_ATTRS[attr] : undefined;
|
|
7367
|
+
if (namespace !== undefined) {
|
|
7368
|
+
el.setAttributeNS(namespace, attr, value);
|
|
7369
|
+
} else {
|
|
7370
|
+
el.setAttribute(attr, value);
|
|
7371
|
+
}
|
|
7372
|
+
}
|
|
7373
|
+
}
|
|
7374
|
+
function flatten(arr) {
|
|
7375
|
+
return arr.reduce((prev, item) => prev.concat(item), []);
|
|
7376
|
+
}
|
|
7377
|
+
function mountChildren(children, env) {
|
|
7378
|
+
return Array.isArray(children) ? flatten(children.map(child => mountChildren(child, env))) : mount(children, env);
|
|
7379
|
+
}
|
|
7380
|
+
function mount(vnode, env = DEFAULT_ENV) {
|
|
7381
|
+
if (vnode == null || typeof vnode === 'boolean') {
|
|
7382
|
+
return null;
|
|
7383
|
+
}
|
|
7384
|
+
if (vnode instanceof Node) {
|
|
7385
|
+
return vnode;
|
|
7386
|
+
}
|
|
7387
|
+
if (isRenderFunction(vnode)) {
|
|
7388
|
+
const {
|
|
7389
|
+
type,
|
|
7390
|
+
props
|
|
7391
|
+
} = vnode;
|
|
7392
|
+
if (type === Fragment) {
|
|
7393
|
+
const node = document.createDocumentFragment();
|
|
7394
|
+
if (props.children) {
|
|
7395
|
+
const children = mountChildren(props.children, env);
|
|
7396
|
+
insertDom(node, children);
|
|
7397
|
+
}
|
|
7398
|
+
return node;
|
|
7399
|
+
}
|
|
7400
|
+
const childVNode = type(props);
|
|
7401
|
+
return mount(childVNode, env);
|
|
7402
|
+
}
|
|
7403
|
+
if (isLeaf(vnode)) {
|
|
7404
|
+
return document.createTextNode(`${vnode}`);
|
|
7405
|
+
}
|
|
7406
|
+
if (isElement(vnode)) {
|
|
7407
|
+
let node;
|
|
7408
|
+
const {
|
|
7409
|
+
type,
|
|
7410
|
+
props
|
|
7411
|
+
} = vnode;
|
|
7412
|
+
if (!env.isSvg && type === 'svg') {
|
|
7413
|
+
env = Object.assign({}, env, {
|
|
7414
|
+
isSvg: true
|
|
7415
|
+
});
|
|
7416
|
+
}
|
|
7417
|
+
if (!env.isSvg) {
|
|
7418
|
+
node = document.createElement(type);
|
|
7419
|
+
} else {
|
|
7420
|
+
node = document.createElementNS(SVG_NS, type);
|
|
7421
|
+
}
|
|
7422
|
+
mountAttributes(node, props, env);
|
|
7423
|
+
if (props.children) {
|
|
7424
|
+
let childEnv = env;
|
|
7425
|
+
if (env.isSvg && type === 'foreignObject') {
|
|
7426
|
+
childEnv = Object.assign({}, childEnv, {
|
|
7427
|
+
isSvg: false
|
|
7428
|
+
});
|
|
7429
|
+
}
|
|
7430
|
+
const children = mountChildren(props.children, childEnv);
|
|
7431
|
+
if (children != null) insertDom(node, children);
|
|
7432
|
+
}
|
|
7433
|
+
const {
|
|
7434
|
+
ref
|
|
7435
|
+
} = props;
|
|
7436
|
+
if (typeof ref === 'function') ref(node);
|
|
7437
|
+
return node;
|
|
7438
|
+
}
|
|
7439
|
+
throw new Error('mount: Invalid Vnode!');
|
|
7440
|
+
}
|
|
7441
|
+
|
|
7442
|
+
/**
|
|
7443
|
+
* Mount vdom as real DOM nodes.
|
|
7444
|
+
*/
|
|
7445
|
+
function mountDom(vnode) {
|
|
7446
|
+
return mount(vnode);
|
|
7447
|
+
}
|
|
7448
|
+
|
|
7449
|
+
/**
|
|
7450
|
+
* Render and mount without returning VirtualDOM, useful when you don't need SVG support.
|
|
7451
|
+
*/
|
|
7452
|
+
function hm(...args) {
|
|
7453
|
+
return mountDom(h(...args));
|
|
7454
|
+
}
|
|
7455
|
+
const memoizedPreloadJS = memoize(url => {
|
|
7456
|
+
document.head.append(hm('link', {
|
|
7457
|
+
rel: 'preload',
|
|
7458
|
+
as: 'script',
|
|
7459
|
+
href: url
|
|
7460
|
+
}));
|
|
7461
|
+
});
|
|
7462
|
+
const jsCache = {};
|
|
7463
|
+
async function loadJSItem(item, context) {
|
|
7464
|
+
var _item$data;
|
|
7465
|
+
const src = item.type === 'script' && ((_item$data = item.data) == null ? void 0 : _item$data.src) || '';
|
|
7466
|
+
item.loaded || (item.loaded = jsCache[src]);
|
|
7467
|
+
if (!item.loaded) {
|
|
7468
|
+
if (item.type === 'script') {
|
|
7469
|
+
item.loaded = new Promise((resolve, reject) => {
|
|
7470
|
+
document.head.append(hm('script', _extends({}, item.data, {
|
|
7471
|
+
onLoad: resolve,
|
|
7472
|
+
onError: reject
|
|
7473
|
+
})));
|
|
7474
|
+
if (!src) {
|
|
7475
|
+
// Run inline script synchronously
|
|
7476
|
+
resolve(undefined);
|
|
7477
|
+
}
|
|
7478
|
+
}).then(() => {
|
|
7479
|
+
item.loaded = true;
|
|
7480
|
+
});
|
|
7481
|
+
if (src) jsCache[src] = item.loaded;
|
|
7482
|
+
}
|
|
7483
|
+
if (item.type === 'iife') {
|
|
7484
|
+
const {
|
|
7485
|
+
fn,
|
|
7486
|
+
getParams
|
|
7487
|
+
} = item.data;
|
|
7488
|
+
fn(...((getParams == null ? void 0 : getParams(context)) || []));
|
|
7489
|
+
item.loaded = true;
|
|
7490
|
+
}
|
|
7491
|
+
}
|
|
7492
|
+
await item.loaded;
|
|
7493
|
+
}
|
|
7494
|
+
async function loadJS(items, context) {
|
|
7495
|
+
items.forEach(item => {
|
|
7496
|
+
var _item$data2;
|
|
7497
|
+
if (item.type === 'script' && (_item$data2 = item.data) != null && _item$data2.src) {
|
|
7498
|
+
memoizedPreloadJS(item.data.src);
|
|
7499
|
+
}
|
|
7500
|
+
});
|
|
7501
|
+
context = _extends({
|
|
7502
|
+
getMarkmap: () => window.markmap
|
|
7503
|
+
}, context);
|
|
7504
|
+
for (const item of items) {
|
|
7505
|
+
await loadJSItem(item, context);
|
|
7506
|
+
}
|
|
7507
|
+
}
|
|
7508
|
+
function buildJSItem(path) {
|
|
7509
|
+
return {
|
|
7510
|
+
type: 'script',
|
|
7511
|
+
data: {
|
|
7512
|
+
src: path
|
|
7513
|
+
}
|
|
7514
|
+
};
|
|
7515
|
+
}
|
|
7516
|
+
function buildCSSItem(path) {
|
|
7517
|
+
return {
|
|
7518
|
+
type: 'stylesheet',
|
|
7519
|
+
data: {
|
|
7520
|
+
href: path
|
|
7521
|
+
}
|
|
7522
|
+
};
|
|
7523
|
+
}
|
|
7524
|
+
|
|
7122
7525
|
function getDefaultExportFromCjs (x) {
|
|
7123
7526
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
7124
7527
|
}
|
|
@@ -7284,10 +7687,10 @@ var remarkableKatex = rkatex;
|
|
|
7284
7687
|
var remarkableKatex$1 = /*@__PURE__*/getDefaultExportFromCjs(remarkableKatex);
|
|
7285
7688
|
|
|
7286
7689
|
const name$3 = 'katex';
|
|
7287
|
-
const preloadScripts = [`katex@${"0.16.8"}/dist/katex.min.js`].map(path =>
|
|
7288
|
-
const webfontloader =
|
|
7690
|
+
const preloadScripts = [`katex@${"0.16.8"}/dist/katex.min.js`].map(path => buildJSItem(path));
|
|
7691
|
+
const webfontloader = buildJSItem(`webfontloader@${"1.6.28"}/webfontloader.js`);
|
|
7289
7692
|
webfontloader.data.defer = true;
|
|
7290
|
-
const styles$1 = [`katex@${"0.16.8"}/dist/katex.min.css`].map(path =>
|
|
7693
|
+
const styles$1 = [`katex@${"0.16.8"}/dist/katex.min.css`].map(path => buildCSSItem(path));
|
|
7291
7694
|
const config$1 = {
|
|
7292
7695
|
versions: {
|
|
7293
7696
|
katex: "0.16.8" ,
|
|
@@ -7336,8 +7739,8 @@ function addDefaultVersions(paths, name, version) {
|
|
|
7336
7739
|
}
|
|
7337
7740
|
function patchJSItem(transformer, item) {
|
|
7338
7741
|
if (item.type === 'script' && item.data.src) {
|
|
7339
|
-
return _extends({}, item, {
|
|
7340
|
-
data: _extends({}, item.data, {
|
|
7742
|
+
return _extends$1({}, item, {
|
|
7743
|
+
data: _extends$1({}, item.data, {
|
|
7341
7744
|
src: transformer.urlBuilder.getFullUrl(item.data.src)
|
|
7342
7745
|
})
|
|
7343
7746
|
});
|
|
@@ -7346,8 +7749,8 @@ function patchJSItem(transformer, item) {
|
|
|
7346
7749
|
}
|
|
7347
7750
|
function patchCSSItem(transformer, item) {
|
|
7348
7751
|
if (item.type === 'stylesheet' && item.data.href) {
|
|
7349
|
-
return _extends({}, item, {
|
|
7350
|
-
data: _extends({}, item.data, {
|
|
7752
|
+
return _extends$1({}, item, {
|
|
7753
|
+
data: _extends$1({}, item.data, {
|
|
7351
7754
|
href: transformer.urlBuilder.getFullUrl(item.data.href)
|
|
7352
7755
|
})
|
|
7353
7756
|
});
|
|
@@ -7358,11 +7761,11 @@ function patchCSSItem(transformer, item) {
|
|
|
7358
7761
|
function createTransformHooks(transformer) {
|
|
7359
7762
|
return {
|
|
7360
7763
|
transformer,
|
|
7361
|
-
parser: new
|
|
7362
|
-
beforeParse: new
|
|
7363
|
-
afterParse: new
|
|
7364
|
-
htmltag: new
|
|
7365
|
-
retransform: new
|
|
7764
|
+
parser: new Hook(),
|
|
7765
|
+
beforeParse: new Hook(),
|
|
7766
|
+
afterParse: new Hook(),
|
|
7767
|
+
htmltag: new Hook(),
|
|
7768
|
+
retransform: new Hook()
|
|
7366
7769
|
};
|
|
7367
7770
|
}
|
|
7368
7771
|
|
|
@@ -7381,7 +7784,7 @@ const plugin$1 = definePlugin({
|
|
|
7381
7784
|
let loading;
|
|
7382
7785
|
const preloadScripts = ((_plugin$config = plugin$1.config) == null || (_plugin$config = _plugin$config.preloadScripts) == null ? void 0 : _plugin$config.map(item => patchJSItem(transformHooks.transformer, item))) || [];
|
|
7383
7786
|
const autoload = () => {
|
|
7384
|
-
loading || (loading =
|
|
7787
|
+
loading || (loading = loadJS(preloadScripts));
|
|
7385
7788
|
return loading;
|
|
7386
7789
|
};
|
|
7387
7790
|
const renderKatex = (source, displayMode) => {
|
|
@@ -7399,7 +7802,7 @@ const plugin$1 = definePlugin({
|
|
|
7399
7802
|
});
|
|
7400
7803
|
return source;
|
|
7401
7804
|
};
|
|
7402
|
-
let enableFeature =
|
|
7805
|
+
let enableFeature = noop;
|
|
7403
7806
|
transformHooks.parser.tap(md => {
|
|
7404
7807
|
md.use(remarkableKatex$1);
|
|
7405
7808
|
md.renderer.rules.katex = (tokens, idx) => {
|
|
@@ -10622,7 +11025,7 @@ var npmUrl = definePlugin({
|
|
|
10622
11025
|
});
|
|
10623
11026
|
|
|
10624
11027
|
const name = 'hljs';
|
|
10625
|
-
const styles = [`highlight.js@${"11.8.0"}/styles/default.css`].map(path =>
|
|
11028
|
+
const styles = [`highlight.js@${"11.8.0"}/styles/default.css`].map(path => buildCSSItem(path));
|
|
10626
11029
|
const config = {
|
|
10627
11030
|
versions: {
|
|
10628
11031
|
hljs: "11.8.0"
|
|
@@ -10634,7 +11037,7 @@ const plugin = definePlugin({
|
|
|
10634
11037
|
config,
|
|
10635
11038
|
transform(transformHooks) {
|
|
10636
11039
|
var _plugin$config;
|
|
10637
|
-
let enableFeature =
|
|
11040
|
+
let enableFeature = noop;
|
|
10638
11041
|
transformHooks.parser.tap(md => {
|
|
10639
11042
|
md.set({
|
|
10640
11043
|
highlight: (str, language) => {
|
|
@@ -10667,7 +11070,7 @@ function cleanNode(node) {
|
|
|
10667
11070
|
if (['paragraph', 'fence'].includes(item.type)) {
|
|
10668
11071
|
if (!node.content) {
|
|
10669
11072
|
node.content = item.content;
|
|
10670
|
-
node.payload = _extends({}, node.payload, item.payload);
|
|
11073
|
+
node.payload = _extends$1({}, node.payload, item.payload);
|
|
10671
11074
|
}
|
|
10672
11075
|
return false;
|
|
10673
11076
|
}
|
|
@@ -10681,7 +11084,7 @@ function cleanNode(node) {
|
|
|
10681
11084
|
let index = (_node$payload$startIn = (_node$payload2 = node.payload) == null ? void 0 : _node$payload2.startIndex) != null ? _node$payload$startIn : 1;
|
|
10682
11085
|
node.children.forEach(item => {
|
|
10683
11086
|
if (item.type === 'list_item') {
|
|
10684
|
-
item.payload = _extends({}, item.payload, {
|
|
11087
|
+
item.payload = _extends$1({}, item.payload, {
|
|
10685
11088
|
index
|
|
10686
11089
|
});
|
|
10687
11090
|
index += 1;
|
|
@@ -10704,7 +11107,7 @@ function resetDepth(node, depth = 0) {
|
|
|
10704
11107
|
class Transformer {
|
|
10705
11108
|
constructor(plugins$1 = plugins) {
|
|
10706
11109
|
this.assetsMap = {};
|
|
10707
|
-
this.urlBuilder = new
|
|
11110
|
+
this.urlBuilder = new UrlBuilder();
|
|
10708
11111
|
this.hooks = createTransformHooks(this);
|
|
10709
11112
|
this.plugins = plugins$1.map(plugin => typeof plugin === 'function' ? plugin() : plugin);
|
|
10710
11113
|
const assetsMap = {};
|
|
@@ -10720,7 +11123,7 @@ class Transformer {
|
|
|
10720
11123
|
breaks: true,
|
|
10721
11124
|
maxNesting: Infinity
|
|
10722
11125
|
});
|
|
10723
|
-
md.renderer.rules.htmltag =
|
|
11126
|
+
md.renderer.rules.htmltag = wrapFunction(md.renderer.rules.htmltag, (render, ...args) => {
|
|
10724
11127
|
const result = render(...args);
|
|
10725
11128
|
this.hooks.htmltag.call({
|
|
10726
11129
|
args,
|
|
@@ -10790,7 +11193,7 @@ class Transformer {
|
|
|
10790
11193
|
const comment = (_ctx$result = ctx.result) == null ? void 0 : _ctx$result.match(/^<!--([\s\S]*?)-->$/);
|
|
10791
11194
|
const data = comment == null ? void 0 : comment[1].trim().split(' ');
|
|
10792
11195
|
if ((data == null ? void 0 : data[0]) === 'fold') {
|
|
10793
|
-
current.payload = _extends({}, current.payload, {
|
|
11196
|
+
current.payload = _extends$1({}, current.payload, {
|
|
10794
11197
|
fold: ['all', 'recursively'].includes(data[1]) ? 2 : 1
|
|
10795
11198
|
});
|
|
10796
11199
|
ctx.result = '';
|
|
@@ -10826,7 +11229,7 @@ class Transformer {
|
|
|
10826
11229
|
cleanNode(root);
|
|
10827
11230
|
if (((_root$children = root.children) == null ? void 0 : _root$children.length) === 1) root = root.children[0];
|
|
10828
11231
|
resetDepth(root);
|
|
10829
|
-
return _extends({}, context, {
|
|
11232
|
+
return _extends$1({}, context, {
|
|
10830
11233
|
root
|
|
10831
11234
|
});
|
|
10832
11235
|
}
|
|
@@ -10860,20 +11263,20 @@ class Transformer {
|
|
|
10860
11263
|
}
|
|
10861
11264
|
fillTemplate(root, assets, extra) {
|
|
10862
11265
|
var _extra, _extra$baseJs;
|
|
10863
|
-
extra = _extends({}, extra);
|
|
10864
|
-
(_extra$baseJs = (_extra = extra).baseJs) != null ? _extra$baseJs : _extra.baseJs = baseJsPaths.map(path => this.urlBuilder.getFullUrl(path)).map(path =>
|
|
11266
|
+
extra = _extends$1({}, extra);
|
|
11267
|
+
(_extra$baseJs = (_extra = extra).baseJs) != null ? _extra$baseJs : _extra.baseJs = baseJsPaths.map(path => this.urlBuilder.getFullUrl(path)).map(path => buildJSItem(path));
|
|
10865
11268
|
const {
|
|
10866
11269
|
scripts,
|
|
10867
11270
|
styles
|
|
10868
11271
|
} = assets;
|
|
10869
|
-
const cssList = [...(styles ?
|
|
11272
|
+
const cssList = [...(styles ? persistCSS(styles) : [])];
|
|
10870
11273
|
const context = {
|
|
10871
11274
|
getMarkmap: () => window.markmap,
|
|
10872
11275
|
getOptions: extra.getOptions,
|
|
10873
11276
|
jsonOptions: extra.jsonOptions,
|
|
10874
11277
|
root
|
|
10875
11278
|
};
|
|
10876
|
-
const jsList = [...
|
|
11279
|
+
const jsList = [...persistJS([...extra.baseJs, ...(scripts || []), {
|
|
10877
11280
|
type: 'iife',
|
|
10878
11281
|
data: {
|
|
10879
11282
|
fn: (getMarkmap, getOptions, root, jsonOptions) => {
|
|
@@ -10896,7 +11299,7 @@ class Transformer {
|
|
|
10896
11299
|
}
|
|
10897
11300
|
|
|
10898
11301
|
const transformerVersions = {
|
|
10899
|
-
'markmap-lib': '0.15.
|
|
11302
|
+
'markmap-lib': '0.15.1',
|
|
10900
11303
|
d3: "7.8.5"
|
|
10901
11304
|
};
|
|
10902
11305
|
|
package/dist/browser/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! markmap-lib v0.15.
|
|
1
|
+
/*! markmap-lib v0.15.1 | MIT License */
|
|
2
2
|
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
3
3
|
import { Remarkable } from 'remarkable';
|
|
4
4
|
import { buildJSItem, buildCSSItem, Hook, noop, loadJS, UrlBuilder, wrapFunction, persistCSS, persistJS } from 'markmap-common';
|
|
@@ -511,7 +511,7 @@ class Transformer {
|
|
|
511
511
|
}
|
|
512
512
|
|
|
513
513
|
const transformerVersions = {
|
|
514
|
-
'markmap-lib': '0.15.
|
|
514
|
+
'markmap-lib': '0.15.1',
|
|
515
515
|
d3: "7.8.5"
|
|
516
516
|
};
|
|
517
517
|
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! markmap-lib v0.15.
|
|
1
|
+
/*! markmap-lib v0.15.1 | MIT License */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
@@ -461,7 +461,7 @@ class Transformer {
|
|
|
461
461
|
}
|
|
462
462
|
|
|
463
463
|
const transformerVersions = {
|
|
464
|
-
'markmap-lib': '0.15.
|
|
464
|
+
'markmap-lib': '0.15.1',
|
|
465
465
|
d3: "7.8.5"
|
|
466
466
|
};
|
|
467
467
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! markmap-lib v0.15.
|
|
1
|
+
/*! markmap-lib v0.15.1 | MIT License */
|
|
2
2
|
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
3
3
|
import { Remarkable } from 'remarkable';
|
|
4
4
|
import { buildJSItem, buildCSSItem, Hook, wrapFunction, noop, UrlBuilder, persistCSS, persistJS } from 'markmap-common';
|
|
@@ -459,7 +459,7 @@ class Transformer {
|
|
|
459
459
|
}
|
|
460
460
|
|
|
461
461
|
const transformerVersions = {
|
|
462
|
-
'markmap-lib': '0.15.
|
|
462
|
+
'markmap-lib': '0.15.1',
|
|
463
463
|
d3: "7.8.5"
|
|
464
464
|
};
|
|
465
465
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markmap-lib",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.1",
|
|
4
4
|
"description": "Visualize your Markdown as mindmaps with Markmap",
|
|
5
5
|
"author": "Gerald <gera2ld@live.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -74,5 +74,5 @@
|
|
|
74
74
|
]
|
|
75
75
|
}
|
|
76
76
|
},
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "66edd3e66f16930d15d763ec0ea7239372f3b9c8"
|
|
78
78
|
}
|