markmap-view 0.18.4-alpha.4 → 0.18.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.
@@ -1,5 +1,342 @@
1
1
  (function(exports, d32) {
2
2
  "use strict";
3
+ class Hook {
4
+ constructor() {
5
+ this.listeners = [];
6
+ }
7
+ tap(fn) {
8
+ this.listeners.push(fn);
9
+ return () => this.revoke(fn);
10
+ }
11
+ revoke(fn) {
12
+ const i = this.listeners.indexOf(fn);
13
+ if (i >= 0) this.listeners.splice(i, 1);
14
+ }
15
+ revokeAll() {
16
+ this.listeners.splice(0);
17
+ }
18
+ call(...args) {
19
+ for (const fn of this.listeners) {
20
+ fn(...args);
21
+ }
22
+ }
23
+ }
24
+ const uniqId = Math.random().toString(36).slice(2, 8);
25
+ let globalIndex = 0;
26
+ function getId() {
27
+ globalIndex += 1;
28
+ return `mm-${uniqId}-${globalIndex}`;
29
+ }
30
+ function noop() {
31
+ }
32
+ function walkTree(tree, callback) {
33
+ const walk = (item, parent) => callback(
34
+ item,
35
+ () => {
36
+ var _a;
37
+ return (_a = item.children) == null ? void 0 : _a.map((child) => walk(child, item));
38
+ },
39
+ parent
40
+ );
41
+ return walk(tree);
42
+ }
43
+ function addClass(className, ...rest) {
44
+ const classList = (className || "").split(" ").filter(Boolean);
45
+ rest.forEach((item) => {
46
+ if (item && classList.indexOf(item) < 0) classList.push(item);
47
+ });
48
+ return classList.join(" ");
49
+ }
50
+ function childSelector(filter) {
51
+ if (typeof filter === "string") {
52
+ const tagName = filter;
53
+ filter = (el) => el.tagName === tagName;
54
+ }
55
+ const filterFn = filter;
56
+ return function selector() {
57
+ let nodes = Array.from(this.childNodes);
58
+ if (filterFn) nodes = nodes.filter((node) => filterFn(node));
59
+ return nodes;
60
+ };
61
+ }
62
+ function defer() {
63
+ const obj = {};
64
+ obj.promise = new Promise((resolve, reject) => {
65
+ obj.resolve = resolve;
66
+ obj.reject = reject;
67
+ });
68
+ return obj;
69
+ }
70
+ function memoize(fn) {
71
+ const cache = {};
72
+ return function memoized(...args) {
73
+ const key = `${args[0]}`;
74
+ let data = cache[key];
75
+ if (!data) {
76
+ data = {
77
+ value: fn(...args)
78
+ };
79
+ cache[key] = data;
80
+ }
81
+ return data.value;
82
+ };
83
+ }
84
+ function debounce(fn, time) {
85
+ const state = {
86
+ timer: 0
87
+ };
88
+ function reset() {
89
+ if (state.timer) {
90
+ window.clearTimeout(state.timer);
91
+ state.timer = 0;
92
+ }
93
+ }
94
+ function run() {
95
+ reset();
96
+ if (state.args) state.result = fn(...state.args);
97
+ }
98
+ return function debounced(...args) {
99
+ reset();
100
+ state.args = args;
101
+ state.timer = window.setTimeout(run, time);
102
+ return state.result;
103
+ };
104
+ }
105
+ /*! @gera2ld/jsx-dom v2.2.2 | ISC License */
106
+ const VTYPE_ELEMENT = 1;
107
+ const VTYPE_FUNCTION = 2;
108
+ const SVG_NS = "http://www.w3.org/2000/svg";
109
+ const XLINK_NS = "http://www.w3.org/1999/xlink";
110
+ const NS_ATTRS = {
111
+ show: XLINK_NS,
112
+ actuate: XLINK_NS,
113
+ href: XLINK_NS
114
+ };
115
+ const isLeaf = (c) => typeof c === "string" || typeof c === "number";
116
+ const isElement = (c) => (c == null ? void 0 : c.vtype) === VTYPE_ELEMENT;
117
+ const isRenderFunction = (c) => (c == null ? void 0 : c.vtype) === VTYPE_FUNCTION;
118
+ function h(type, props, ...children) {
119
+ props = Object.assign({}, props, {
120
+ children: children.length === 1 ? children[0] : children
121
+ });
122
+ return jsx(type, props);
123
+ }
124
+ function jsx(type, props) {
125
+ let vtype;
126
+ if (typeof type === "string") vtype = VTYPE_ELEMENT;
127
+ else if (typeof type === "function") vtype = VTYPE_FUNCTION;
128
+ else throw new Error("Invalid VNode type");
129
+ return {
130
+ vtype,
131
+ type,
132
+ props
133
+ };
134
+ }
135
+ function Fragment(props) {
136
+ return props.children;
137
+ }
138
+ const DEFAULT_ENV = {
139
+ isSvg: false
140
+ };
141
+ function insertDom(parent, nodes) {
142
+ if (!Array.isArray(nodes)) nodes = [nodes];
143
+ nodes = nodes.filter(Boolean);
144
+ if (nodes.length) parent.append(...nodes);
145
+ }
146
+ function mountAttributes(domElement, props, env) {
147
+ for (const key in props) {
148
+ if (key === "key" || key === "children" || key === "ref") continue;
149
+ if (key === "dangerouslySetInnerHTML") {
150
+ domElement.innerHTML = props[key].__html;
151
+ } else if (key === "innerHTML" || key === "textContent" || key === "innerText" || key === "value" && ["textarea", "select"].includes(domElement.tagName)) {
152
+ const value = props[key];
153
+ if (value != null) domElement[key] = value;
154
+ } else if (key.startsWith("on")) {
155
+ domElement[key.toLowerCase()] = props[key];
156
+ } else {
157
+ setDOMAttribute(domElement, key, props[key], env.isSvg);
158
+ }
159
+ }
160
+ }
161
+ const attrMap = {
162
+ className: "class",
163
+ labelFor: "for"
164
+ };
165
+ function setDOMAttribute(el, attr, value, isSVG) {
166
+ attr = attrMap[attr] || attr;
167
+ if (value === true) {
168
+ el.setAttribute(attr, "");
169
+ } else if (value === false) {
170
+ el.removeAttribute(attr);
171
+ } else {
172
+ const namespace = isSVG ? NS_ATTRS[attr] : void 0;
173
+ if (namespace !== void 0) {
174
+ el.setAttributeNS(namespace, attr, value);
175
+ } else {
176
+ el.setAttribute(attr, value);
177
+ }
178
+ }
179
+ }
180
+ function flatten(arr) {
181
+ return arr.reduce((prev, item) => prev.concat(item), []);
182
+ }
183
+ function mountChildren(children, env) {
184
+ return Array.isArray(children) ? flatten(children.map((child) => mountChildren(child, env))) : mount(children, env);
185
+ }
186
+ function mount(vnode, env = DEFAULT_ENV) {
187
+ if (vnode == null || typeof vnode === "boolean") {
188
+ return null;
189
+ }
190
+ if (vnode instanceof Node) {
191
+ return vnode;
192
+ }
193
+ if (isRenderFunction(vnode)) {
194
+ const {
195
+ type,
196
+ props
197
+ } = vnode;
198
+ if (type === Fragment) {
199
+ const node = document.createDocumentFragment();
200
+ if (props.children) {
201
+ const children = mountChildren(props.children, env);
202
+ insertDom(node, children);
203
+ }
204
+ return node;
205
+ }
206
+ const childVNode = type(props);
207
+ return mount(childVNode, env);
208
+ }
209
+ if (isLeaf(vnode)) {
210
+ return document.createTextNode(`${vnode}`);
211
+ }
212
+ if (isElement(vnode)) {
213
+ let node;
214
+ const {
215
+ type,
216
+ props
217
+ } = vnode;
218
+ if (!env.isSvg && type === "svg") {
219
+ env = Object.assign({}, env, {
220
+ isSvg: true
221
+ });
222
+ }
223
+ if (!env.isSvg) {
224
+ node = document.createElement(type);
225
+ } else {
226
+ node = document.createElementNS(SVG_NS, type);
227
+ }
228
+ mountAttributes(node, props, env);
229
+ if (props.children) {
230
+ let childEnv = env;
231
+ if (env.isSvg && type === "foreignObject") {
232
+ childEnv = Object.assign({}, childEnv, {
233
+ isSvg: false
234
+ });
235
+ }
236
+ const children = mountChildren(props.children, childEnv);
237
+ if (children != null) insertDom(node, children);
238
+ }
239
+ const {
240
+ ref
241
+ } = props;
242
+ if (typeof ref === "function") ref(node);
243
+ return node;
244
+ }
245
+ throw new Error("mount: Invalid Vnode!");
246
+ }
247
+ function mountDom(vnode) {
248
+ return mount(vnode);
249
+ }
250
+ function hm(...args) {
251
+ return mountDom(h(...args));
252
+ }
253
+ const memoizedPreloadJS = memoize((url) => {
254
+ document.head.append(
255
+ hm("link", {
256
+ rel: "preload",
257
+ as: "script",
258
+ href: url
259
+ })
260
+ );
261
+ });
262
+ const jsCache = {};
263
+ const cssCache = {};
264
+ async function loadJSItem(item, context) {
265
+ var _a;
266
+ const src = item.type === "script" && ((_a = item.data) == null ? void 0 : _a.src) || "";
267
+ item.loaded || (item.loaded = jsCache[src]);
268
+ if (!item.loaded) {
269
+ const deferred = defer();
270
+ item.loaded = deferred.promise;
271
+ if (item.type === "script") {
272
+ document.head.append(
273
+ hm("script", {
274
+ ...item.data,
275
+ onLoad: () => deferred.resolve(),
276
+ onError: deferred.reject
277
+ })
278
+ );
279
+ if (!src) {
280
+ deferred.resolve();
281
+ } else {
282
+ jsCache[src] = item.loaded;
283
+ }
284
+ }
285
+ if (item.type === "iife") {
286
+ const { fn, getParams } = item.data;
287
+ fn(...(getParams == null ? void 0 : getParams(context)) || []);
288
+ deferred.resolve();
289
+ }
290
+ }
291
+ await item.loaded;
292
+ }
293
+ async function loadCSSItem(item) {
294
+ const url = item.type === "stylesheet" && item.data.href || "";
295
+ item.loaded || (item.loaded = cssCache[url]);
296
+ if (!item.loaded) {
297
+ const deferred = defer();
298
+ item.loaded = deferred.promise;
299
+ if (url) cssCache[url] = item.loaded;
300
+ if (item.type === "style") {
301
+ document.head.append(
302
+ hm("style", {
303
+ textContent: item.data
304
+ })
305
+ );
306
+ deferred.resolve();
307
+ } else if (url) {
308
+ document.head.append(
309
+ hm("link", {
310
+ rel: "stylesheet",
311
+ ...item.data
312
+ })
313
+ );
314
+ fetch(url).then((res) => {
315
+ if (res.ok) return res.text();
316
+ throw res;
317
+ }).then(() => deferred.resolve(), deferred.reject);
318
+ }
319
+ }
320
+ await item.loaded;
321
+ }
322
+ async function loadJS(items, context) {
323
+ items.forEach((item) => {
324
+ var _a;
325
+ if (item.type === "script" && ((_a = item.data) == null ? void 0 : _a.src)) {
326
+ memoizedPreloadJS(item.data.src);
327
+ }
328
+ });
329
+ context = {
330
+ getMarkmap: () => window.markmap,
331
+ ...context
332
+ };
333
+ for (const item of items) {
334
+ await loadJSItem(item, context);
335
+ }
336
+ }
337
+ async function loadCSS(items) {
338
+ await Promise.all(items.map((item) => loadCSSItem(item)));
339
+ }
3
340
  const isMacintosh = typeof navigator !== "undefined" && navigator.userAgent.includes("Macintosh");
4
341
  const defaultColorFn = d32.scaleOrdinal(d32.schemeCategory10);
5
342
  const defaultOptions = {
@@ -193,14 +530,14 @@
193
530
  return links;
194
531
  }
195
532
  function hierarchy(data, children) {
196
- var root = new Node(data), valued = +data.value && (root.value = data.value), node, nodes = [root], child, childs, i, n;
533
+ var root = new Node$1(data), valued = +data.value && (root.value = data.value), node, nodes = [root], child, childs, i, n;
197
534
  if (children == null) children = defaultChildren;
198
535
  while (node = nodes.pop()) {
199
536
  if (valued) node.value = +node.data.value;
200
537
  if ((childs = children(node.data)) && (n = childs.length)) {
201
538
  node.children = new Array(n);
202
539
  for (i = n - 1; i >= 0; --i) {
203
- nodes.push(child = node.children[i] = new Node(childs[i]));
540
+ nodes.push(child = node.children[i] = new Node$1(childs[i]));
204
541
  child.parent = node;
205
542
  child.depth = node.depth + 1;
206
543
  }
@@ -223,13 +560,13 @@
223
560
  node.height = height;
224
561
  while ((node = node.parent) && node.height < ++height);
225
562
  }
226
- function Node(data) {
563
+ function Node$1(data) {
227
564
  this.data = data;
228
565
  this.depth = this.height = 0;
229
566
  this.parent = null;
230
567
  }
231
- Node.prototype = hierarchy.prototype = {
232
- constructor: Node,
568
+ Node$1.prototype = hierarchy.prototype = {
569
+ constructor: Node$1,
233
570
  count: node_count,
234
571
  each: node_each,
235
572
  eachAfter: node_eachAfter,
@@ -605,86 +942,6 @@
605
942
  next: lastLows
606
943
  };
607
944
  };
608
- class Hook {
609
- constructor() {
610
- this.listeners = [];
611
- }
612
- tap(fn) {
613
- this.listeners.push(fn);
614
- return () => this.revoke(fn);
615
- }
616
- revoke(fn) {
617
- const i = this.listeners.indexOf(fn);
618
- if (i >= 0) this.listeners.splice(i, 1);
619
- }
620
- revokeAll() {
621
- this.listeners.splice(0);
622
- }
623
- call(...args) {
624
- for (const fn of this.listeners) {
625
- fn(...args);
626
- }
627
- }
628
- }
629
- const uniqId = Math.random().toString(36).slice(2, 8);
630
- let globalIndex = 0;
631
- function getId() {
632
- globalIndex += 1;
633
- return `mm-${uniqId}-${globalIndex}`;
634
- }
635
- function noop() {
636
- }
637
- function walkTree(tree, callback) {
638
- const walk = (item, parent) => callback(
639
- item,
640
- () => {
641
- var _a;
642
- return (_a = item.children) == null ? void 0 : _a.map((child) => walk(child, item));
643
- },
644
- parent
645
- );
646
- return walk(tree);
647
- }
648
- function addClass(className, ...rest) {
649
- const classList = (className || "").split(" ").filter(Boolean);
650
- rest.forEach((item) => {
651
- if (item && classList.indexOf(item) < 0) classList.push(item);
652
- });
653
- return classList.join(" ");
654
- }
655
- function childSelector(filter) {
656
- if (typeof filter === "string") {
657
- const tagName = filter;
658
- filter = (el) => el.tagName === tagName;
659
- }
660
- const filterFn = filter;
661
- return function selector() {
662
- let nodes = Array.from(this.childNodes);
663
- if (filterFn) nodes = nodes.filter((node) => filterFn(node));
664
- return nodes;
665
- };
666
- }
667
- function debounce(fn, time) {
668
- const state = {
669
- timer: 0
670
- };
671
- function reset() {
672
- if (state.timer) {
673
- window.clearTimeout(state.timer);
674
- state.timer = 0;
675
- }
676
- }
677
- function run() {
678
- reset();
679
- if (state.args) state.result = fn(...state.args);
680
- }
681
- return function debounced(...args) {
682
- reset();
683
- state.args = args;
684
- state.timer = window.setTimeout(run, time);
685
- return state.result;
686
- };
687
- }
688
945
  const css = ".markmap {\n --markmap-max-width: 9999px;\n --markmap-a-color: #0097e6;\n --markmap-a-hover-color: #00a8ff;\n --markmap-code-bg: #f0f0f0;\n --markmap-code-color: #555;\n --markmap-highlight-bg: #ffeaa7;\n --markmap-table-border: 1px solid currentColor;\n --markmap-font: 300 16px/20px sans-serif;\n --markmap-circle-open-bg: #fff;\n --markmap-text-color: #333;\n\n font: var(--markmap-font);\n color: var(--markmap-text-color);\n}\n\n .markmap-link {\n fill: none;\n }\n\n .markmap-node > circle {\n cursor: pointer;\n }\n\n .markmap-foreign {\n display: inline-block;\n }\n\n .markmap-foreign p {\n margin: 0;\n }\n\n .markmap-foreign a {\n color: var(--markmap-a-color);\n }\n\n .markmap-foreign a:hover {\n color: var(--markmap-a-hover-color);\n }\n\n .markmap-foreign code {\n padding: 0.25em;\n font-size: calc(1em - 2px);\n color: var(--markmap-code-color);\n background-color: var(--markmap-code-bg);\n border-radius: 2px;\n }\n\n .markmap-foreign pre {\n margin: 0;\n }\n\n .markmap-foreign pre > code {\n display: block;\n }\n\n .markmap-foreign del {\n text-decoration: line-through;\n }\n\n .markmap-foreign em {\n font-style: italic;\n }\n\n .markmap-foreign strong {\n font-weight: bold;\n }\n\n .markmap-foreign mark {\n background: var(--markmap-highlight-bg);\n }\n\n .markmap-foreign table,\n .markmap-foreign th,\n .markmap-foreign td {\n border-collapse: collapse;\n border: var(--markmap-table-border);\n }\n\n .markmap-foreign img {\n display: inline-block;\n }\n\n .markmap-foreign svg {\n fill: currentColor;\n }\n\n .markmap-foreign > div {\n width: var(--markmap-max-width);\n text-align: left;\n }\n\n .markmap-foreign > div > div {\n display: inline-block;\n }\n\n.markmap-dark .markmap {\n --markmap-code-bg: #1a1b26;\n --markmap-code-color: #ddd;\n --markmap-circle-open-bg: #444;\n --markmap-text-color: #eee;\n}\n";
689
946
  const globalCSS = css;
690
947
  const linkShape = d32.linkHorizontal();
@@ -1184,6 +1441,8 @@
1184
1441
  exports.deriveOptions = deriveOptions;
1185
1442
  exports.globalCSS = globalCSS;
1186
1443
  exports.isMacintosh = isMacintosh;
1444
+ exports.loadCSS = loadCSS;
1445
+ exports.loadJS = loadJS;
1187
1446
  exports.refreshHook = refreshHook;
1188
1447
  exports.simpleHash = simpleHash;
1189
1448
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export { loadJS, loadCSS } from 'markmap-common';
1
2
  export * from './types';
2
3
  export * from './constants';
3
4
  export * from './util';
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
- import { scaleOrdinal as G, schemeCategory10 as at, linkHorizontal as lt, zoomTransform as w, select as ct, zoom as ht, min as P, max as W, zoomIdentity as dt, minIndex as pt } from "d3";
2
- import { Hook as ut, getId as mt, debounce as gt, addClass as ft, walkTree as C, childSelector as v, noop as S } from "markmap-common";
3
- const V = typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), xt = G(at), U = {
1
+ import { Hook as at, getId as lt, debounce as ct, addClass as ht, walkTree as C, childSelector as v, noop as w } from "markmap-common";
2
+ import { loadCSS as xe, loadJS as ye } from "markmap-common";
3
+ import { scaleOrdinal as G, schemeCategory10 as dt, linkHorizontal as pt, zoomTransform as S, select as ut, zoom as mt, min as P, max as W, zoomIdentity as gt, minIndex as ft } from "d3";
4
+ const V = typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), xt = G(dt), U = {
4
5
  autoFit: !1,
5
6
  color: (e) => {
6
7
  var t;
@@ -96,13 +97,13 @@ function Et(e) {
96
97
  e(t);
97
98
  return this;
98
99
  }
99
- function wt(e) {
100
+ function Ct(e) {
100
101
  return this.eachAfter(function(t) {
101
102
  for (var s = +e(t.data) || 0, n = t.children, o = n && n.length; --o >= 0; ) s += n[o].value;
102
103
  t.value = s;
103
104
  });
104
105
  }
105
- function Ct(e) {
106
+ function wt(e) {
106
107
  return this.eachBefore(function(t) {
107
108
  t.children && t.children.sort(e);
108
109
  });
@@ -176,8 +177,8 @@ R.prototype = B.prototype = {
176
177
  each: bt,
177
178
  eachAfter: Et,
178
179
  eachBefore: zt,
179
- sum: wt,
180
- sort: Ct,
180
+ sum: Ct,
181
+ sort: wt,
181
182
  path: St,
182
183
  ancestors: Xt,
183
184
  descendants: Mt,
@@ -446,18 +447,18 @@ const q = (e, t = 0) => (e.y = t, (e.children || []).reduce((s, n) => {
446
447
  index: t,
447
448
  next: s
448
449
  };
449
- }, Q = ".markmap{--markmap-max-width: 9999px;--markmap-a-color: #0097e6;--markmap-a-hover-color: #00a8ff;--markmap-code-bg: #f0f0f0;--markmap-code-color: #555;--markmap-highlight-bg: #ffeaa7;--markmap-table-border: 1px solid currentColor;--markmap-font: 300 16px/20px sans-serif;--markmap-circle-open-bg: #fff;--markmap-text-color: #333;font:var(--markmap-font);color:var(--markmap-text-color)}.markmap-link{fill:none}.markmap-node>circle{cursor:pointer}.markmap-foreign{display:inline-block}.markmap-foreign p{margin:0}.markmap-foreign a{color:var(--markmap-a-color)}.markmap-foreign a:hover{color:var(--markmap-a-hover-color)}.markmap-foreign code{padding:.25em;font-size:calc(1em - 2px);color:var(--markmap-code-color);background-color:var(--markmap-code-bg);border-radius:2px}.markmap-foreign pre{margin:0}.markmap-foreign pre>code{display:block}.markmap-foreign del{text-decoration:line-through}.markmap-foreign em{font-style:italic}.markmap-foreign strong{font-weight:700}.markmap-foreign mark{background:var(--markmap-highlight-bg)}.markmap-foreign table,.markmap-foreign th,.markmap-foreign td{border-collapse:collapse;border:var(--markmap-table-border)}.markmap-foreign img{display:inline-block}.markmap-foreign svg{fill:currentColor}.markmap-foreign>div{width:var(--markmap-max-width);text-align:left}.markmap-foreign>div>div{display:inline-block}.markmap-dark .markmap{--markmap-code-bg: #1a1b26;--markmap-code-color: #ddd;--markmap-circle-open-bg: #444;--markmap-text-color: #eee}", me = Q, j = lt();
450
+ }, Q = ".markmap{--markmap-max-width: 9999px;--markmap-a-color: #0097e6;--markmap-a-hover-color: #00a8ff;--markmap-code-bg: #f0f0f0;--markmap-code-color: #555;--markmap-highlight-bg: #ffeaa7;--markmap-table-border: 1px solid currentColor;--markmap-font: 300 16px/20px sans-serif;--markmap-circle-open-bg: #fff;--markmap-text-color: #333;font:var(--markmap-font);color:var(--markmap-text-color)}.markmap-link{fill:none}.markmap-node>circle{cursor:pointer}.markmap-foreign{display:inline-block}.markmap-foreign p{margin:0}.markmap-foreign a{color:var(--markmap-a-color)}.markmap-foreign a:hover{color:var(--markmap-a-hover-color)}.markmap-foreign code{padding:.25em;font-size:calc(1em - 2px);color:var(--markmap-code-color);background-color:var(--markmap-code-bg);border-radius:2px}.markmap-foreign pre{margin:0}.markmap-foreign pre>code{display:block}.markmap-foreign del{text-decoration:line-through}.markmap-foreign em{font-style:italic}.markmap-foreign strong{font-weight:700}.markmap-foreign mark{background:var(--markmap-highlight-bg)}.markmap-foreign table,.markmap-foreign th,.markmap-foreign td{border-collapse:collapse;border:var(--markmap-table-border)}.markmap-foreign img{display:inline-block}.markmap-foreign svg{fill:currentColor}.markmap-foreign>div{width:var(--markmap-max-width);text-align:left}.markmap-foreign>div>div{display:inline-block}.markmap-dark .markmap{--markmap-code-bg: #1a1b26;--markmap-code-color: #ddd;--markmap-circle-open-bg: #444;--markmap-text-color: #eee}", me = Q, j = pt();
450
451
  function I(e) {
451
452
  return Math.max(4 - 2 * e.state.depth, 1.5);
452
453
  }
453
454
  function K(e, t) {
454
- const s = pt(e, t);
455
+ const s = ft(e, t);
455
456
  return e[s];
456
457
  }
457
458
  function O(e) {
458
459
  e.stopPropagation();
459
460
  }
460
- const le = new ut();
461
+ const le = new at();
461
462
  class tt {
462
463
  constructor(t, s) {
463
464
  this.options = U, this.revokers = [], this.handleZoom = (n) => {
@@ -465,7 +466,7 @@ class tt {
465
466
  this.g.attr("transform", o);
466
467
  }, this.handlePan = (n) => {
467
468
  n.preventDefault();
468
- const o = w(this.svg.node()), a = o.translate(
469
+ const o = S(this.svg.node()), a = o.translate(
469
470
  -n.deltaX / o.k,
470
471
  -n.deltaY / o.k
471
472
  );
@@ -473,11 +474,11 @@ class tt {
473
474
  }, this.handleClick = (n, o) => {
474
475
  let a = this.options.toggleRecursively;
475
476
  (V ? n.metaKey : n.ctrlKey) && (a = !a), this.toggleNode(o, a);
476
- }, this.ensureView = this.ensureVisible, this.svg = t.datum ? t : ct(t), this.styleNode = this.svg.append("style"), this.zoom = ht().filter((n) => this.options.scrollForPan && n.type === "wheel" ? n.ctrlKey && !n.button : (!n.ctrlKey || n.type === "wheel") && !n.button).on("zoom", this.handleZoom), this.setOptions(s), this.state = {
477
- id: this.options.id || this.svg.attr("id") || mt(),
477
+ }, this.ensureView = this.ensureVisible, this.svg = t.datum ? t : ut(t), this.styleNode = this.svg.append("style"), this.zoom = mt().filter((n) => this.options.scrollForPan && n.type === "wheel" ? n.ctrlKey && !n.button : (!n.ctrlKey || n.type === "wheel") && !n.button).on("zoom", this.handleZoom), this.setOptions(s), this.state = {
478
+ id: this.options.id || this.svg.attr("id") || lt(),
478
479
  rect: { x1: 0, y1: 0, x2: 0, y2: 0 }
479
480
  }, this.g = this.svg.append("g"), this.observer = new ResizeObserver(
480
- gt(() => {
481
+ ct(() => {
481
482
  this.renderData();
482
483
  }, 100)
483
484
  ), this.revokers.push(
@@ -495,7 +496,7 @@ class tt {
495
496
  updateStyle() {
496
497
  this.svg.attr(
497
498
  "class",
498
- ft(this.svg.attr("class"), "markmap", this.state.id)
499
+ ht(this.svg.attr("class"), "markmap", this.state.id)
499
500
  );
500
501
  const t = this.getStyleContent();
501
502
  this.styleNode.text(t);
@@ -702,11 +703,11 @@ class tt {
702
703
  n / h * a,
703
704
  o / u * a,
704
705
  t
705
- ), g = dt.translate(
706
+ ), g = gt.translate(
706
707
  (n - h * m) / 2 - l * m,
707
708
  (o - u * m) / 2 - r * m
708
709
  ).scale(m);
709
- return this.transition(this.svg).call(this.zoom.transform, g).end().catch(S);
710
+ return this.transition(this.svg).call(this.zoom.transform, g).end().catch(w);
710
711
  }
711
712
  findElement(t) {
712
713
  let s;
@@ -724,7 +725,7 @@ class tt {
724
725
  var b;
725
726
  const n = (b = this.findElement(t)) == null ? void 0 : b.data;
726
727
  if (!n) return;
727
- const o = this.svg.node(), a = o.getBoundingClientRect(), l = w(o), [r, c] = [
728
+ const o = this.svg.node(), a = o.getBoundingClientRect(), l = S(o), [r, c] = [
728
729
  n.state.rect.x,
729
730
  n.state.rect.x + n.state.rect.width + 2
730
731
  ].map((k) => k * l.k + l.x), [p, h] = [
@@ -739,14 +740,14 @@ class tt {
739
740
  }, m = [u.left - r, a.width - u.right - c], g = [u.top - p, a.height - u.bottom - h], y = m[0] * m[1] > 0 ? K(m, Math.abs) / l.k : 0, x = g[0] * g[1] > 0 ? K(g, Math.abs) / l.k : 0;
740
741
  if (y || x) {
741
742
  const k = l.translate(y, x);
742
- return this.transition(this.svg).call(this.zoom.transform, k).end().catch(S);
743
+ return this.transition(this.svg).call(this.zoom.transform, k).end().catch(w);
743
744
  }
744
745
  }
745
746
  async centerNode(t, s) {
746
747
  var y;
747
748
  const n = (y = this.findElement(t)) == null ? void 0 : y.data;
748
749
  if (!n) return;
749
- const o = this.svg.node(), a = o.getBoundingClientRect(), l = w(o), r = (n.state.rect.x + n.state.rect.width / 2) * l.k + l.x, c = (n.state.rect.y + n.state.rect.height / 2) * l.k + l.y, p = {
750
+ const o = this.svg.node(), a = o.getBoundingClientRect(), l = S(o), r = (n.state.rect.x + n.state.rect.width / 2) * l.k + l.x, c = (n.state.rect.y + n.state.rect.height / 2) * l.k + l.y, p = {
750
751
  left: 0,
751
752
  right: 0,
752
753
  top: 0,
@@ -755,18 +756,18 @@ class tt {
755
756
  }, h = (p.left + a.width - p.right) / 2, u = (p.top + a.height - p.bottom) / 2, m = (h - r) / l.k, g = (u - c) / l.k;
756
757
  if (m || g) {
757
758
  const x = l.translate(m, g);
758
- return this.transition(this.svg).call(this.zoom.transform, x).end().catch(S);
759
+ return this.transition(this.svg).call(this.zoom.transform, x).end().catch(w);
759
760
  }
760
761
  }
761
762
  /**
762
763
  * Scale content with it pinned at the center of the viewport.
763
764
  */
764
765
  async rescale(t) {
765
- const s = this.svg.node(), { width: n, height: o } = s.getBoundingClientRect(), a = n / 2, l = o / 2, r = w(s), c = r.translate(
766
+ const s = this.svg.node(), { width: n, height: o } = s.getBoundingClientRect(), a = n / 2, l = o / 2, r = S(s), c = r.translate(
766
767
  (a - r.x) * (1 - t) / r.k,
767
768
  (l - r.y) * (1 - t) / r.k
768
769
  ).scale(t);
769
- return this.transition(this.svg).call(this.zoom.transform, c).end().catch(S);
770
+ return this.transition(this.svg).call(this.zoom.transform, c).end().catch(w);
770
771
  }
771
772
  destroy() {
772
773
  this.svg.on(".zoom", null), this.svg.html(null), this.revokers.forEach((t) => {
@@ -787,6 +788,8 @@ export {
787
788
  ue as deriveOptions,
788
789
  me as globalCSS,
789
790
  V as isMacintosh,
791
+ xe as loadCSS,
792
+ ye as loadJS,
790
793
  le as refreshHook,
791
794
  yt as simpleHash
792
795
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markmap-view",
3
- "version": "0.18.4-alpha.4+8f90d3c",
3
+ "version": "0.18.4",
4
4
  "description": "View markmaps in browser",
5
5
  "author": "Gerald <gera2ld@live.com>",
6
6
  "license": "MIT",
@@ -46,10 +46,10 @@
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/d3-flextree": "^2.1.1",
49
- "markmap-common": "0.18.0"
49
+ "markmap-common": "0.18.4"
50
50
  },
51
51
  "peerDependencies": {
52
52
  "markmap-common": "*"
53
53
  },
54
- "gitHead": "8f90d3cef5816b56ad80fc1db35caea8df330789"
54
+ "gitHead": "eb77f9eb79a44d60237f9a9cdadf0a7ca7fa9e29"
55
55
  }