markmap-lib 0.15.9-alpha.12 → 0.15.9-alpha.14
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.iife.js +13 -120
- package/dist/browser/index.mjs +14 -52
- package/dist/index.js +3 -44
- package/dist/index.mjs +4 -45
- package/dist/index.no-plugins.js +3 -44
- package/dist/index.no-plugins.mjs +4 -45
- package/dist/plugins.js +10 -7
- package/dist/plugins.mjs +10 -7
- package/dist/transform.d.ts +2 -7
- package/package.json +10 -6
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
(function(exports, require$$0) {
|
|
2
2
|
"use strict";
|
|
3
|
-
const template =
|
|
3
|
+
const template = process.env.TEMPLATE || "";
|
|
4
4
|
const baseJsPaths = [
|
|
5
5
|
`d3@${"7.8.5"}/dist/d3.min.js`,
|
|
6
|
-
`markmap-view@${"0.15.
|
|
6
|
+
`markmap-view@${"0.15.9-alpha.14"}/dist/browser/index.js`
|
|
7
7
|
];
|
|
8
8
|
const testPath = "npm2url/dist/index.cjs";
|
|
9
9
|
const defaultProviders = {
|
|
@@ -96,75 +96,6 @@
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
-
const escapeChars = {
|
|
100
|
-
"&": "&",
|
|
101
|
-
"<": "<",
|
|
102
|
-
'"': """
|
|
103
|
-
};
|
|
104
|
-
function escapeHtml$1(html2) {
|
|
105
|
-
return html2.replace(/[&<"]/g, (m) => escapeChars[m]);
|
|
106
|
-
}
|
|
107
|
-
function escapeScript(content) {
|
|
108
|
-
return content.replace(/<(\/script>)/g, "\\x3c$2");
|
|
109
|
-
}
|
|
110
|
-
function htmlOpen(tagName, attrs) {
|
|
111
|
-
const attrStr = attrs ? Object.entries(attrs).map(([key, value]) => {
|
|
112
|
-
if (value == null || value === false)
|
|
113
|
-
return;
|
|
114
|
-
key = ` ${escapeHtml$1(key)}`;
|
|
115
|
-
if (value === true)
|
|
116
|
-
return key;
|
|
117
|
-
return `${key}="${escapeHtml$1(value)}"`;
|
|
118
|
-
}).filter(Boolean).join("") : "";
|
|
119
|
-
return `<${tagName}${attrStr}>`;
|
|
120
|
-
}
|
|
121
|
-
function htmlClose(tagName) {
|
|
122
|
-
return `</${tagName}>`;
|
|
123
|
-
}
|
|
124
|
-
function wrapHtml(tagName, content, attrs) {
|
|
125
|
-
if (content == null)
|
|
126
|
-
return htmlOpen(tagName, attrs);
|
|
127
|
-
return htmlOpen(tagName, attrs) + (content || "") + htmlClose(tagName);
|
|
128
|
-
}
|
|
129
|
-
function buildCode(fn, args) {
|
|
130
|
-
const params = args.map((arg) => {
|
|
131
|
-
if (typeof arg === "function")
|
|
132
|
-
return arg.toString();
|
|
133
|
-
return JSON.stringify(arg ?? null);
|
|
134
|
-
}).join(",");
|
|
135
|
-
return `(${fn.toString()})(${params})`;
|
|
136
|
-
}
|
|
137
|
-
function persistJS(items, context) {
|
|
138
|
-
return items.map((item) => {
|
|
139
|
-
if (item.type === "script") {
|
|
140
|
-
const { textContent: textContent2, ...rest } = item.data;
|
|
141
|
-
return wrapHtml(
|
|
142
|
-
"script",
|
|
143
|
-
textContent2 || "",
|
|
144
|
-
rest
|
|
145
|
-
);
|
|
146
|
-
}
|
|
147
|
-
if (item.type === "iife") {
|
|
148
|
-
const { fn, getParams } = item.data;
|
|
149
|
-
return wrapHtml(
|
|
150
|
-
"script",
|
|
151
|
-
escapeScript(buildCode(fn, (getParams == null ? void 0 : getParams(context)) || []))
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
return "";
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
function persistCSS(items) {
|
|
158
|
-
return items.map((item) => {
|
|
159
|
-
if (item.type === "stylesheet") {
|
|
160
|
-
return wrapHtml("link", null, {
|
|
161
|
-
rel: "stylesheet",
|
|
162
|
-
...item.data
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
return wrapHtml("style", item.data);
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
99
|
Math.random().toString(36).slice(2, 8);
|
|
169
100
|
function noop() {
|
|
170
101
|
}
|
|
@@ -18045,9 +17976,13 @@
|
|
|
18045
17976
|
function definePlugin(plugin2) {
|
|
18046
17977
|
return plugin2;
|
|
18047
17978
|
}
|
|
18048
|
-
const
|
|
18049
|
-
const
|
|
17979
|
+
const svgMarked = '<svg width="16" height="16" viewBox="0 -3 24 24"><path d="M19 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2m-9 14-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8z"/></svg>\n';
|
|
17980
|
+
const svgUnmarked = '<svg width="16" height="16" viewBox="0 -3 24 24"><path fill-rule="evenodd" d="M6 5a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1zM3 6a3 3 0 0 1 3-3h12a3 3 0 0 1 3 3v12a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3v-5z" clip-rule="evenodd"/></svg>\n';
|
|
18050
17981
|
const name$5 = "checkbox";
|
|
17982
|
+
const images = {
|
|
17983
|
+
" ": svgUnmarked.trim(),
|
|
17984
|
+
x: svgMarked.trim()
|
|
17985
|
+
};
|
|
18051
17986
|
const plugin$3 = definePlugin({
|
|
18052
17987
|
name: name$5,
|
|
18053
17988
|
transform(transformHooks) {
|
|
@@ -18062,11 +17997,10 @@
|
|
|
18062
17997
|
const prevType = state.tokens[i2 - 1].type;
|
|
18063
17998
|
const prevPrevType = state.tokens[i2 - 2].type;
|
|
18064
17999
|
if (prevType === "heading_open" || prevType === "paragraph_open" && prevPrevType === "list_item_open") {
|
|
18065
|
-
|
|
18066
|
-
|
|
18067
|
-
|
|
18068
|
-
|
|
18069
|
-
}
|
|
18000
|
+
token.content = token.content.replace(
|
|
18001
|
+
/^\[(.)\] /,
|
|
18002
|
+
(m, g) => images[g] ? `${images[g]} ` : m
|
|
18003
|
+
);
|
|
18070
18004
|
}
|
|
18071
18005
|
}
|
|
18072
18006
|
}
|
|
@@ -21322,50 +21256,9 @@
|
|
|
21322
21256
|
const keys = this.plugins.map((plugin2) => plugin2.name).filter((name2) => features[name2]);
|
|
21323
21257
|
return this.getAssets(keys);
|
|
21324
21258
|
}
|
|
21325
|
-
fillTemplate(root2, assets, extra) {
|
|
21326
|
-
extra = {
|
|
21327
|
-
...extra
|
|
21328
|
-
};
|
|
21329
|
-
extra.baseJs ?? (extra.baseJs = baseJsPaths.map((path) => this.urlBuilder.getFullUrl(path)).map((path) => buildJSItem(path)));
|
|
21330
|
-
const { scripts, styles: styles2 } = assets;
|
|
21331
|
-
const cssList = [...styles2 ? persistCSS(styles2) : []];
|
|
21332
|
-
const context = {
|
|
21333
|
-
getMarkmap: () => window.markmap,
|
|
21334
|
-
getOptions: extra.getOptions,
|
|
21335
|
-
jsonOptions: extra.jsonOptions,
|
|
21336
|
-
root: root2
|
|
21337
|
-
};
|
|
21338
|
-
const jsList = [
|
|
21339
|
-
...persistJS(
|
|
21340
|
-
[
|
|
21341
|
-
...extra.baseJs,
|
|
21342
|
-
...scripts || [],
|
|
21343
|
-
{
|
|
21344
|
-
type: "iife",
|
|
21345
|
-
data: {
|
|
21346
|
-
fn: (getMarkmap, getOptions, root22, jsonOptions) => {
|
|
21347
|
-
const markmap = getMarkmap();
|
|
21348
|
-
window.mm = markmap.Markmap.create(
|
|
21349
|
-
"svg#mindmap",
|
|
21350
|
-
(getOptions || markmap.deriveOptions)(jsonOptions),
|
|
21351
|
-
root22
|
|
21352
|
-
);
|
|
21353
|
-
},
|
|
21354
|
-
getParams: ({ getMarkmap, getOptions, root: root22, jsonOptions }) => {
|
|
21355
|
-
return [getMarkmap, getOptions, root22, jsonOptions];
|
|
21356
|
-
}
|
|
21357
|
-
}
|
|
21358
|
-
}
|
|
21359
|
-
],
|
|
21360
|
-
context
|
|
21361
|
-
)
|
|
21362
|
-
];
|
|
21363
|
-
const html2 = template.replace("<!--CSS-->", () => cssList.join("")).replace("<!--JS-->", () => jsList.join(""));
|
|
21364
|
-
return html2;
|
|
21365
|
-
}
|
|
21366
21259
|
}
|
|
21367
21260
|
const transformerVersions = {
|
|
21368
|
-
"markmap-lib": "process.env.
|
|
21261
|
+
"markmap-lib": "process.env.LIB_VERSION",
|
|
21369
21262
|
d3: "7.8.5"
|
|
21370
21263
|
};
|
|
21371
21264
|
exports.Transformer = Transformer;
|
package/dist/browser/index.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Hook, buildJSItem, buildCSSItem, loadJS, noop, wrapFunction, UrlBuilder
|
|
1
|
+
import { Hook, buildJSItem, buildCSSItem, loadJS, noop, wrapFunction, UrlBuilder } from "markmap-common";
|
|
2
2
|
import { buildTree } from "markmap-html-parser";
|
|
3
3
|
import { Remarkable } from "remarkable";
|
|
4
4
|
import yaml from "js-yaml";
|
|
5
5
|
import remarkableKatex from "remarkable-katex";
|
|
6
|
-
const template =
|
|
6
|
+
const template = process.env.TEMPLATE || "";
|
|
7
7
|
const baseJsPaths = [
|
|
8
8
|
`d3@${"7.8.5"}/dist/d3.min.js`,
|
|
9
|
-
`markmap-view@${"0.15.
|
|
9
|
+
`markmap-view@${"0.15.9-alpha.14"}/dist/browser/index.js`
|
|
10
10
|
];
|
|
11
11
|
function createTransformHooks(transformer) {
|
|
12
12
|
return {
|
|
@@ -21,9 +21,13 @@ function createTransformHooks(transformer) {
|
|
|
21
21
|
function definePlugin(plugin2) {
|
|
22
22
|
return plugin2;
|
|
23
23
|
}
|
|
24
|
-
const
|
|
25
|
-
const
|
|
24
|
+
const svgMarked = '<svg width="16" height="16" viewBox="0 -3 24 24"><path d="M19 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2m-9 14-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8z"/></svg>\n';
|
|
25
|
+
const svgUnmarked = '<svg width="16" height="16" viewBox="0 -3 24 24"><path fill-rule="evenodd" d="M6 5a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1zM3 6a3 3 0 0 1 3-3h12a3 3 0 0 1 3 3v12a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3v-5z" clip-rule="evenodd"/></svg>\n';
|
|
26
26
|
const name$5 = "checkbox";
|
|
27
|
+
const images = {
|
|
28
|
+
" ": svgUnmarked.trim(),
|
|
29
|
+
x: svgMarked.trim()
|
|
30
|
+
};
|
|
27
31
|
const plugin$3 = definePlugin({
|
|
28
32
|
name: name$5,
|
|
29
33
|
transform(transformHooks) {
|
|
@@ -38,11 +42,10 @@ const plugin$3 = definePlugin({
|
|
|
38
42
|
const prevType = state.tokens[i - 1].type;
|
|
39
43
|
const prevPrevType = state.tokens[i - 2].type;
|
|
40
44
|
if (prevType === "heading_open" || prevType === "paragraph_open" && prevPrevType === "list_item_open") {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
45
|
+
token.content = token.content.replace(
|
|
46
|
+
/^\[(.)\] /,
|
|
47
|
+
(m, g) => images[g] ? `${images[g]} ` : m
|
|
48
|
+
);
|
|
46
49
|
}
|
|
47
50
|
}
|
|
48
51
|
}
|
|
@@ -479,50 +482,9 @@ class Transformer {
|
|
|
479
482
|
const keys = this.plugins.map((plugin2) => plugin2.name).filter((name2) => features[name2]);
|
|
480
483
|
return this.getAssets(keys);
|
|
481
484
|
}
|
|
482
|
-
fillTemplate(root, assets, extra) {
|
|
483
|
-
extra = {
|
|
484
|
-
...extra
|
|
485
|
-
};
|
|
486
|
-
extra.baseJs ?? (extra.baseJs = baseJsPaths.map((path) => this.urlBuilder.getFullUrl(path)).map((path) => buildJSItem(path)));
|
|
487
|
-
const { scripts, styles: styles2 } = assets;
|
|
488
|
-
const cssList = [...styles2 ? persistCSS(styles2) : []];
|
|
489
|
-
const context = {
|
|
490
|
-
getMarkmap: () => window.markmap,
|
|
491
|
-
getOptions: extra.getOptions,
|
|
492
|
-
jsonOptions: extra.jsonOptions,
|
|
493
|
-
root
|
|
494
|
-
};
|
|
495
|
-
const jsList = [
|
|
496
|
-
...persistJS(
|
|
497
|
-
[
|
|
498
|
-
...extra.baseJs,
|
|
499
|
-
...scripts || [],
|
|
500
|
-
{
|
|
501
|
-
type: "iife",
|
|
502
|
-
data: {
|
|
503
|
-
fn: (getMarkmap, getOptions, root2, jsonOptions) => {
|
|
504
|
-
const markmap = getMarkmap();
|
|
505
|
-
window.mm = markmap.Markmap.create(
|
|
506
|
-
"svg#mindmap",
|
|
507
|
-
(getOptions || markmap.deriveOptions)(jsonOptions),
|
|
508
|
-
root2
|
|
509
|
-
);
|
|
510
|
-
},
|
|
511
|
-
getParams: ({ getMarkmap, getOptions, root: root2, jsonOptions }) => {
|
|
512
|
-
return [getMarkmap, getOptions, root2, jsonOptions];
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
],
|
|
517
|
-
context
|
|
518
|
-
)
|
|
519
|
-
];
|
|
520
|
-
const html = template.replace("<!--CSS-->", () => cssList.join("")).replace("<!--JS-->", () => jsList.join(""));
|
|
521
|
-
return html;
|
|
522
|
-
}
|
|
523
485
|
}
|
|
524
486
|
const transformerVersions = {
|
|
525
|
-
"markmap-lib": "process.env.
|
|
487
|
+
"markmap-lib": "process.env.LIB_VERSION",
|
|
526
488
|
d3: "7.8.5"
|
|
527
489
|
};
|
|
528
490
|
export {
|
package/dist/index.js
CHANGED
|
@@ -7,10 +7,10 @@ const plugins = require("./plugins.js");
|
|
|
7
7
|
require("js-yaml");
|
|
8
8
|
require("highlight.js");
|
|
9
9
|
require("remarkable-katex");
|
|
10
|
-
const template =
|
|
10
|
+
const template = process.env.TEMPLATE || "";
|
|
11
11
|
const baseJsPaths = [
|
|
12
12
|
`d3@${"7.8.5"}/dist/d3.min.js`,
|
|
13
|
-
`markmap-view@${"0.15.
|
|
13
|
+
`markmap-view@${"0.15.9-alpha.14"}/dist/browser/index.js`
|
|
14
14
|
];
|
|
15
15
|
function patchJSItem(urlBuilder, item) {
|
|
16
16
|
if (item.type === "script" && item.data.src) {
|
|
@@ -126,50 +126,9 @@ class Transformer {
|
|
|
126
126
|
const keys = this.plugins.map((plugin) => plugin.name).filter((name) => features[name]);
|
|
127
127
|
return this.getAssets(keys);
|
|
128
128
|
}
|
|
129
|
-
fillTemplate(root, assets, extra) {
|
|
130
|
-
extra = {
|
|
131
|
-
...extra
|
|
132
|
-
};
|
|
133
|
-
extra.baseJs ?? (extra.baseJs = baseJsPaths.map((path) => this.urlBuilder.getFullUrl(path)).map((path) => markmapCommon.buildJSItem(path)));
|
|
134
|
-
const { scripts, styles } = assets;
|
|
135
|
-
const cssList = [...styles ? markmapCommon.persistCSS(styles) : []];
|
|
136
|
-
const context = {
|
|
137
|
-
getMarkmap: () => window.markmap,
|
|
138
|
-
getOptions: extra.getOptions,
|
|
139
|
-
jsonOptions: extra.jsonOptions,
|
|
140
|
-
root
|
|
141
|
-
};
|
|
142
|
-
const jsList = [
|
|
143
|
-
...markmapCommon.persistJS(
|
|
144
|
-
[
|
|
145
|
-
...extra.baseJs,
|
|
146
|
-
...scripts || [],
|
|
147
|
-
{
|
|
148
|
-
type: "iife",
|
|
149
|
-
data: {
|
|
150
|
-
fn: (getMarkmap, getOptions, root2, jsonOptions) => {
|
|
151
|
-
const markmap = getMarkmap();
|
|
152
|
-
window.mm = markmap.Markmap.create(
|
|
153
|
-
"svg#mindmap",
|
|
154
|
-
(getOptions || markmap.deriveOptions)(jsonOptions),
|
|
155
|
-
root2
|
|
156
|
-
);
|
|
157
|
-
},
|
|
158
|
-
getParams: ({ getMarkmap, getOptions, root: root2, jsonOptions }) => {
|
|
159
|
-
return [getMarkmap, getOptions, root2, jsonOptions];
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
],
|
|
164
|
-
context
|
|
165
|
-
)
|
|
166
|
-
];
|
|
167
|
-
const html = template.replace("<!--CSS-->", () => cssList.join("")).replace("<!--JS-->", () => jsList.join(""));
|
|
168
|
-
return html;
|
|
169
|
-
}
|
|
170
129
|
}
|
|
171
130
|
const transformerVersions = {
|
|
172
|
-
"markmap-lib": "process.env.
|
|
131
|
+
"markmap-lib": "process.env.LIB_VERSION",
|
|
173
132
|
d3: "7.8.5"
|
|
174
133
|
};
|
|
175
134
|
exports.Transformer = Transformer;
|
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { UrlBuilder, wrapFunction
|
|
1
|
+
import { UrlBuilder, wrapFunction } from "markmap-common";
|
|
2
2
|
import { buildTree } from "markmap-html-parser";
|
|
3
3
|
import { Remarkable } from "remarkable";
|
|
4
4
|
import { plugins, createTransformHooks } from "./plugins.mjs";
|
|
5
5
|
import "js-yaml";
|
|
6
6
|
import "highlight.js";
|
|
7
7
|
import "remarkable-katex";
|
|
8
|
-
const template =
|
|
8
|
+
const template = process.env.TEMPLATE || "";
|
|
9
9
|
const baseJsPaths = [
|
|
10
10
|
`d3@${"7.8.5"}/dist/d3.min.js`,
|
|
11
|
-
`markmap-view@${"0.15.
|
|
11
|
+
`markmap-view@${"0.15.9-alpha.14"}/dist/browser/index.js`
|
|
12
12
|
];
|
|
13
13
|
function patchJSItem(urlBuilder, item) {
|
|
14
14
|
if (item.type === "script" && item.data.src) {
|
|
@@ -124,50 +124,9 @@ class Transformer {
|
|
|
124
124
|
const keys = this.plugins.map((plugin) => plugin.name).filter((name) => features[name]);
|
|
125
125
|
return this.getAssets(keys);
|
|
126
126
|
}
|
|
127
|
-
fillTemplate(root, assets, extra) {
|
|
128
|
-
extra = {
|
|
129
|
-
...extra
|
|
130
|
-
};
|
|
131
|
-
extra.baseJs ?? (extra.baseJs = baseJsPaths.map((path) => this.urlBuilder.getFullUrl(path)).map((path) => buildJSItem(path)));
|
|
132
|
-
const { scripts, styles } = assets;
|
|
133
|
-
const cssList = [...styles ? persistCSS(styles) : []];
|
|
134
|
-
const context = {
|
|
135
|
-
getMarkmap: () => window.markmap,
|
|
136
|
-
getOptions: extra.getOptions,
|
|
137
|
-
jsonOptions: extra.jsonOptions,
|
|
138
|
-
root
|
|
139
|
-
};
|
|
140
|
-
const jsList = [
|
|
141
|
-
...persistJS(
|
|
142
|
-
[
|
|
143
|
-
...extra.baseJs,
|
|
144
|
-
...scripts || [],
|
|
145
|
-
{
|
|
146
|
-
type: "iife",
|
|
147
|
-
data: {
|
|
148
|
-
fn: (getMarkmap, getOptions, root2, jsonOptions) => {
|
|
149
|
-
const markmap = getMarkmap();
|
|
150
|
-
window.mm = markmap.Markmap.create(
|
|
151
|
-
"svg#mindmap",
|
|
152
|
-
(getOptions || markmap.deriveOptions)(jsonOptions),
|
|
153
|
-
root2
|
|
154
|
-
);
|
|
155
|
-
},
|
|
156
|
-
getParams: ({ getMarkmap, getOptions, root: root2, jsonOptions }) => {
|
|
157
|
-
return [getMarkmap, getOptions, root2, jsonOptions];
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
],
|
|
162
|
-
context
|
|
163
|
-
)
|
|
164
|
-
];
|
|
165
|
-
const html = template.replace("<!--CSS-->", () => cssList.join("")).replace("<!--JS-->", () => jsList.join(""));
|
|
166
|
-
return html;
|
|
167
|
-
}
|
|
168
127
|
}
|
|
169
128
|
const transformerVersions = {
|
|
170
|
-
"markmap-lib": "process.env.
|
|
129
|
+
"markmap-lib": "process.env.LIB_VERSION",
|
|
171
130
|
d3: "7.8.5"
|
|
172
131
|
};
|
|
173
132
|
export {
|
package/dist/index.no-plugins.js
CHANGED
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const markmapCommon = require("markmap-common");
|
|
4
4
|
const markmapHtmlParser = require("markmap-html-parser");
|
|
5
5
|
const remarkable = require("remarkable");
|
|
6
|
-
const template =
|
|
6
|
+
const template = process.env.TEMPLATE || "";
|
|
7
7
|
const baseJsPaths = [
|
|
8
8
|
`d3@${"7.8.5"}/dist/d3.min.js`,
|
|
9
|
-
`markmap-view@${"0.15.
|
|
9
|
+
`markmap-view@${"0.15.9-alpha.14"}/dist/browser/index.js`
|
|
10
10
|
];
|
|
11
11
|
function createTransformHooks(transformer) {
|
|
12
12
|
return {
|
|
@@ -132,50 +132,9 @@ class Transformer {
|
|
|
132
132
|
const keys = this.plugins.map((plugin) => plugin.name).filter((name) => features[name]);
|
|
133
133
|
return this.getAssets(keys);
|
|
134
134
|
}
|
|
135
|
-
fillTemplate(root, assets, extra) {
|
|
136
|
-
extra = {
|
|
137
|
-
...extra
|
|
138
|
-
};
|
|
139
|
-
extra.baseJs ?? (extra.baseJs = baseJsPaths.map((path) => this.urlBuilder.getFullUrl(path)).map((path) => markmapCommon.buildJSItem(path)));
|
|
140
|
-
const { scripts, styles } = assets;
|
|
141
|
-
const cssList = [...styles ? markmapCommon.persistCSS(styles) : []];
|
|
142
|
-
const context = {
|
|
143
|
-
getMarkmap: () => window.markmap,
|
|
144
|
-
getOptions: extra.getOptions,
|
|
145
|
-
jsonOptions: extra.jsonOptions,
|
|
146
|
-
root
|
|
147
|
-
};
|
|
148
|
-
const jsList = [
|
|
149
|
-
...markmapCommon.persistJS(
|
|
150
|
-
[
|
|
151
|
-
...extra.baseJs,
|
|
152
|
-
...scripts || [],
|
|
153
|
-
{
|
|
154
|
-
type: "iife",
|
|
155
|
-
data: {
|
|
156
|
-
fn: (getMarkmap, getOptions, root2, jsonOptions) => {
|
|
157
|
-
const markmap = getMarkmap();
|
|
158
|
-
window.mm = markmap.Markmap.create(
|
|
159
|
-
"svg#mindmap",
|
|
160
|
-
(getOptions || markmap.deriveOptions)(jsonOptions),
|
|
161
|
-
root2
|
|
162
|
-
);
|
|
163
|
-
},
|
|
164
|
-
getParams: ({ getMarkmap, getOptions, root: root2, jsonOptions }) => {
|
|
165
|
-
return [getMarkmap, getOptions, root2, jsonOptions];
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
],
|
|
170
|
-
context
|
|
171
|
-
)
|
|
172
|
-
];
|
|
173
|
-
const html = template.replace("<!--CSS-->", () => cssList.join("")).replace("<!--JS-->", () => jsList.join(""));
|
|
174
|
-
return html;
|
|
175
|
-
}
|
|
176
135
|
}
|
|
177
136
|
const transformerVersions = {
|
|
178
|
-
"markmap-lib": "process.env.
|
|
137
|
+
"markmap-lib": "process.env.LIB_VERSION",
|
|
179
138
|
d3: "7.8.5"
|
|
180
139
|
};
|
|
181
140
|
exports.Transformer = Transformer;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Hook, UrlBuilder, wrapFunction
|
|
1
|
+
import { Hook, UrlBuilder, wrapFunction } from "markmap-common";
|
|
2
2
|
import { buildTree } from "markmap-html-parser";
|
|
3
3
|
import { Remarkable } from "remarkable";
|
|
4
|
-
const template =
|
|
4
|
+
const template = process.env.TEMPLATE || "";
|
|
5
5
|
const baseJsPaths = [
|
|
6
6
|
`d3@${"7.8.5"}/dist/d3.min.js`,
|
|
7
|
-
`markmap-view@${"0.15.
|
|
7
|
+
`markmap-view@${"0.15.9-alpha.14"}/dist/browser/index.js`
|
|
8
8
|
];
|
|
9
9
|
function createTransformHooks(transformer) {
|
|
10
10
|
return {
|
|
@@ -130,50 +130,9 @@ class Transformer {
|
|
|
130
130
|
const keys = this.plugins.map((plugin) => plugin.name).filter((name) => features[name]);
|
|
131
131
|
return this.getAssets(keys);
|
|
132
132
|
}
|
|
133
|
-
fillTemplate(root, assets, extra) {
|
|
134
|
-
extra = {
|
|
135
|
-
...extra
|
|
136
|
-
};
|
|
137
|
-
extra.baseJs ?? (extra.baseJs = baseJsPaths.map((path) => this.urlBuilder.getFullUrl(path)).map((path) => buildJSItem(path)));
|
|
138
|
-
const { scripts, styles } = assets;
|
|
139
|
-
const cssList = [...styles ? persistCSS(styles) : []];
|
|
140
|
-
const context = {
|
|
141
|
-
getMarkmap: () => window.markmap,
|
|
142
|
-
getOptions: extra.getOptions,
|
|
143
|
-
jsonOptions: extra.jsonOptions,
|
|
144
|
-
root
|
|
145
|
-
};
|
|
146
|
-
const jsList = [
|
|
147
|
-
...persistJS(
|
|
148
|
-
[
|
|
149
|
-
...extra.baseJs,
|
|
150
|
-
...scripts || [],
|
|
151
|
-
{
|
|
152
|
-
type: "iife",
|
|
153
|
-
data: {
|
|
154
|
-
fn: (getMarkmap, getOptions, root2, jsonOptions) => {
|
|
155
|
-
const markmap = getMarkmap();
|
|
156
|
-
window.mm = markmap.Markmap.create(
|
|
157
|
-
"svg#mindmap",
|
|
158
|
-
(getOptions || markmap.deriveOptions)(jsonOptions),
|
|
159
|
-
root2
|
|
160
|
-
);
|
|
161
|
-
},
|
|
162
|
-
getParams: ({ getMarkmap, getOptions, root: root2, jsonOptions }) => {
|
|
163
|
-
return [getMarkmap, getOptions, root2, jsonOptions];
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
],
|
|
168
|
-
context
|
|
169
|
-
)
|
|
170
|
-
];
|
|
171
|
-
const html = template.replace("<!--CSS-->", () => cssList.join("")).replace("<!--JS-->", () => jsList.join(""));
|
|
172
|
-
return html;
|
|
173
|
-
}
|
|
174
133
|
}
|
|
175
134
|
const transformerVersions = {
|
|
176
|
-
"markmap-lib": "process.env.
|
|
135
|
+
"markmap-lib": "process.env.LIB_VERSION",
|
|
177
136
|
d3: "7.8.5"
|
|
178
137
|
};
|
|
179
138
|
export {
|
package/dist/plugins.js
CHANGED
|
@@ -17,9 +17,13 @@ function createTransformHooks(transformer) {
|
|
|
17
17
|
function definePlugin(plugin2) {
|
|
18
18
|
return plugin2;
|
|
19
19
|
}
|
|
20
|
-
const
|
|
21
|
-
const
|
|
20
|
+
const svgMarked = '<svg width="16" height="16" viewBox="0 -3 24 24"><path d="M19 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2m-9 14-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8z"/></svg>\n';
|
|
21
|
+
const svgUnmarked = '<svg width="16" height="16" viewBox="0 -3 24 24"><path fill-rule="evenodd" d="M6 5a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1zM3 6a3 3 0 0 1 3-3h12a3 3 0 0 1 3 3v12a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3v-5z" clip-rule="evenodd"/></svg>\n';
|
|
22
22
|
const name$5 = "checkbox";
|
|
23
|
+
const images = {
|
|
24
|
+
" ": svgUnmarked.trim(),
|
|
25
|
+
x: svgMarked.trim()
|
|
26
|
+
};
|
|
23
27
|
const plugin$3 = definePlugin({
|
|
24
28
|
name: name$5,
|
|
25
29
|
transform(transformHooks) {
|
|
@@ -34,11 +38,10 @@ const plugin$3 = definePlugin({
|
|
|
34
38
|
const prevType = state.tokens[i - 1].type;
|
|
35
39
|
const prevPrevType = state.tokens[i - 2].type;
|
|
36
40
|
if (prevType === "heading_open" || prevType === "paragraph_open" && prevPrevType === "list_item_open") {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
41
|
+
token.content = token.content.replace(
|
|
42
|
+
/^\[(.)\] /,
|
|
43
|
+
(m, g) => images[g] ? `${images[g]} ` : m
|
|
44
|
+
);
|
|
42
45
|
}
|
|
43
46
|
}
|
|
44
47
|
}
|
package/dist/plugins.mjs
CHANGED
|
@@ -15,9 +15,13 @@ function createTransformHooks(transformer) {
|
|
|
15
15
|
function definePlugin(plugin2) {
|
|
16
16
|
return plugin2;
|
|
17
17
|
}
|
|
18
|
-
const
|
|
19
|
-
const
|
|
18
|
+
const svgMarked = '<svg width="16" height="16" viewBox="0 -3 24 24"><path d="M19 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2m-9 14-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8z"/></svg>\n';
|
|
19
|
+
const svgUnmarked = '<svg width="16" height="16" viewBox="0 -3 24 24"><path fill-rule="evenodd" d="M6 5a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1zM3 6a3 3 0 0 1 3-3h12a3 3 0 0 1 3 3v12a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3v-5z" clip-rule="evenodd"/></svg>\n';
|
|
20
20
|
const name$5 = "checkbox";
|
|
21
|
+
const images = {
|
|
22
|
+
" ": svgUnmarked.trim(),
|
|
23
|
+
x: svgMarked.trim()
|
|
24
|
+
};
|
|
21
25
|
const plugin$3 = definePlugin({
|
|
22
26
|
name: name$5,
|
|
23
27
|
transform(transformHooks) {
|
|
@@ -32,11 +36,10 @@ const plugin$3 = definePlugin({
|
|
|
32
36
|
const prevType = state.tokens[i - 1].type;
|
|
33
37
|
const prevPrevType = state.tokens[i - 2].type;
|
|
34
38
|
if (prevType === "heading_open" || prevType === "paragraph_open" && prevPrevType === "list_item_open") {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
39
|
+
token.content = token.content.replace(
|
|
40
|
+
/^\[(.)\] /,
|
|
41
|
+
(m, g) => images[g] ? `${images[g]} ` : m
|
|
42
|
+
);
|
|
40
43
|
}
|
|
41
44
|
}
|
|
42
45
|
}
|
package/dist/transform.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UrlBuilder } from 'markmap-common';
|
|
2
2
|
import { IHtmlParserOptions } from 'markmap-html-parser';
|
|
3
3
|
import { Remarkable } from 'remarkable';
|
|
4
|
-
import { IAssets, IFeatures, ITransformHooks, ITransformPlugin, ITransformResult, ITransformer
|
|
4
|
+
import { IAssets, IFeatures, ITransformHooks, ITransformPlugin, ITransformResult, ITransformer } from './types';
|
|
5
5
|
export declare const builtInPlugins: ITransformPlugin[];
|
|
6
6
|
export declare class Transformer implements ITransformer {
|
|
7
7
|
hooks: ITransformHooks;
|
|
@@ -19,9 +19,4 @@ export declare class Transformer implements ITransformer {
|
|
|
19
19
|
* Get used assets by features object returned by `transform`.
|
|
20
20
|
*/
|
|
21
21
|
getUsedAssets(features: IFeatures): IAssets;
|
|
22
|
-
fillTemplate(root: IPureNode | null, assets: IAssets, extra?: {
|
|
23
|
-
baseJs?: JSItem[];
|
|
24
|
-
jsonOptions?: IMarkmapJSONOptions;
|
|
25
|
-
getOptions?: (jsonOptions: IMarkmapJSONOptions) => Partial<IMarkmapOptions>;
|
|
26
|
-
}): string;
|
|
27
22
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markmap-lib",
|
|
3
|
-
"version": "0.15.9-alpha.
|
|
3
|
+
"version": "0.15.9-alpha.14+fa8173f",
|
|
4
4
|
"description": "Visualize your Markdown as mindmaps with Markmap",
|
|
5
5
|
"author": "Gerald <gera2ld@live.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@highlightjs/cdn-assets": "^11.8.0",
|
|
61
61
|
"@types/remarkable": "^2.0.3",
|
|
62
|
-
"markmap-common": "0.15.9-alpha.
|
|
63
|
-
"markmap-view": "0.15.9-alpha.
|
|
62
|
+
"markmap-common": "0.15.9-alpha.14+fa8173f",
|
|
63
|
+
"markmap-view": "0.15.9-alpha.14+fa8173f",
|
|
64
64
|
"webfontloader": "^1.6.28"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"highlight.js": "^11.8.0",
|
|
69
69
|
"js-yaml": "^4.1.0",
|
|
70
70
|
"katex": "^0.16.8",
|
|
71
|
-
"markmap-html-parser": "0.15.9-alpha.
|
|
71
|
+
"markmap-html-parser": "0.15.9-alpha.14+fa8173f",
|
|
72
72
|
"prismjs": "^1.29.0",
|
|
73
73
|
"remarkable": "^2.0.1",
|
|
74
74
|
"remarkable-katex": "^1.2.1"
|
|
@@ -83,8 +83,12 @@
|
|
|
83
83
|
{
|
|
84
84
|
"rootMode": "upward"
|
|
85
85
|
}
|
|
86
|
-
]
|
|
86
|
+
],
|
|
87
|
+
"\\.svg$": "<rootDir>/scripts/file-transform.js"
|
|
88
|
+
},
|
|
89
|
+
"moduleNameMapper": {
|
|
90
|
+
"^(.*\\.svg)\\?raw$": "$1"
|
|
87
91
|
}
|
|
88
92
|
},
|
|
89
|
-
"gitHead": "
|
|
93
|
+
"gitHead": "fa8173fbb9d5b30e669da11497f24123e5ead511"
|
|
90
94
|
}
|