markmap-toolbar 0.17.2 → 0.17.3-alpha.3
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/index.js +12 -24
- package/dist/index.mjs +12 -24
- package/dist/style.css +11 -10
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -15,12 +15,9 @@
|
|
|
15
15
|
const isRenderFunction = (c) => (c == null ? void 0 : c.vtype) === VTYPE_FUNCTION;
|
|
16
16
|
function jsx(type, props) {
|
|
17
17
|
let vtype;
|
|
18
|
-
if (typeof type === "string")
|
|
19
|
-
|
|
20
|
-
else
|
|
21
|
-
vtype = VTYPE_FUNCTION;
|
|
22
|
-
else
|
|
23
|
-
throw new Error("Invalid VNode type");
|
|
18
|
+
if (typeof type === "string") vtype = VTYPE_ELEMENT;
|
|
19
|
+
else if (typeof type === "function") vtype = VTYPE_FUNCTION;
|
|
20
|
+
else throw new Error("Invalid VNode type");
|
|
24
21
|
return {
|
|
25
22
|
vtype,
|
|
26
23
|
type,
|
|
@@ -35,22 +32,18 @@
|
|
|
35
32
|
isSvg: false
|
|
36
33
|
};
|
|
37
34
|
function insertDom(parent, nodes) {
|
|
38
|
-
if (!Array.isArray(nodes))
|
|
39
|
-
nodes = [nodes];
|
|
35
|
+
if (!Array.isArray(nodes)) nodes = [nodes];
|
|
40
36
|
nodes = nodes.filter(Boolean);
|
|
41
|
-
if (nodes.length)
|
|
42
|
-
parent.append(...nodes);
|
|
37
|
+
if (nodes.length) parent.append(...nodes);
|
|
43
38
|
}
|
|
44
39
|
function mountAttributes(domElement, props, env) {
|
|
45
40
|
for (const key in props) {
|
|
46
|
-
if (key === "key" || key === "children" || key === "ref")
|
|
47
|
-
continue;
|
|
41
|
+
if (key === "key" || key === "children" || key === "ref") continue;
|
|
48
42
|
if (key === "dangerouslySetInnerHTML") {
|
|
49
43
|
domElement.innerHTML = props[key].__html;
|
|
50
44
|
} else if (key === "innerHTML" || key === "textContent" || key === "innerText" || key === "value" && ["textarea", "select"].includes(domElement.tagName)) {
|
|
51
45
|
const value = props[key];
|
|
52
|
-
if (value != null)
|
|
53
|
-
domElement[key] = value;
|
|
46
|
+
if (value != null) domElement[key] = value;
|
|
54
47
|
} else if (key.startsWith("on")) {
|
|
55
48
|
domElement[key.toLowerCase()] = props[key];
|
|
56
49
|
} else {
|
|
@@ -134,14 +127,12 @@
|
|
|
134
127
|
});
|
|
135
128
|
}
|
|
136
129
|
const children = mountChildren(props.children, childEnv);
|
|
137
|
-
if (children != null)
|
|
138
|
-
insertDom(node, children);
|
|
130
|
+
if (children != null) insertDom(node, children);
|
|
139
131
|
}
|
|
140
132
|
const {
|
|
141
133
|
ref
|
|
142
134
|
} = props;
|
|
143
|
-
if (typeof ref === "function")
|
|
144
|
-
ref(node);
|
|
135
|
+
if (typeof ref === "function") ref(node);
|
|
145
136
|
return node;
|
|
146
137
|
}
|
|
147
138
|
throw new Error("mount: Invalid Vnode!");
|
|
@@ -169,8 +160,7 @@
|
|
|
169
160
|
let promise;
|
|
170
161
|
function safeCaller(fn) {
|
|
171
162
|
return async (...args) => {
|
|
172
|
-
if (promise)
|
|
173
|
-
return;
|
|
163
|
+
if (promise) return;
|
|
174
164
|
promise = fn(...args);
|
|
175
165
|
try {
|
|
176
166
|
await promise;
|
|
@@ -246,8 +236,7 @@
|
|
|
246
236
|
getHandler(handle) {
|
|
247
237
|
handle = safeCaller(handle);
|
|
248
238
|
return () => {
|
|
249
|
-
if (this.markmap)
|
|
250
|
-
handle(this.markmap);
|
|
239
|
+
if (this.markmap) handle(this.markmap);
|
|
251
240
|
};
|
|
252
241
|
}
|
|
253
242
|
setItems(items) {
|
|
@@ -261,8 +250,7 @@
|
|
|
261
250
|
const items = this.items.map((item) => {
|
|
262
251
|
if (typeof item === "string") {
|
|
263
252
|
const data = this.registry[item];
|
|
264
|
-
if (!data)
|
|
265
|
-
console.warn(`[markmap-toolbar] ${item} not found`);
|
|
253
|
+
if (!data) console.warn(`[markmap-toolbar] ${item} not found`);
|
|
266
254
|
return data;
|
|
267
255
|
}
|
|
268
256
|
return item;
|
package/dist/index.mjs
CHANGED
|
@@ -13,12 +13,9 @@ const isElement = (c) => (c == null ? void 0 : c.vtype) === VTYPE_ELEMENT;
|
|
|
13
13
|
const isRenderFunction = (c) => (c == null ? void 0 : c.vtype) === VTYPE_FUNCTION;
|
|
14
14
|
function jsx(type, props) {
|
|
15
15
|
let vtype;
|
|
16
|
-
if (typeof type === "string")
|
|
17
|
-
|
|
18
|
-
else
|
|
19
|
-
vtype = VTYPE_FUNCTION;
|
|
20
|
-
else
|
|
21
|
-
throw new Error("Invalid VNode type");
|
|
16
|
+
if (typeof type === "string") vtype = VTYPE_ELEMENT;
|
|
17
|
+
else if (typeof type === "function") vtype = VTYPE_FUNCTION;
|
|
18
|
+
else throw new Error("Invalid VNode type");
|
|
22
19
|
return {
|
|
23
20
|
vtype,
|
|
24
21
|
type,
|
|
@@ -33,22 +30,18 @@ const DEFAULT_ENV = {
|
|
|
33
30
|
isSvg: false
|
|
34
31
|
};
|
|
35
32
|
function insertDom(parent, nodes) {
|
|
36
|
-
if (!Array.isArray(nodes))
|
|
37
|
-
nodes = [nodes];
|
|
33
|
+
if (!Array.isArray(nodes)) nodes = [nodes];
|
|
38
34
|
nodes = nodes.filter(Boolean);
|
|
39
|
-
if (nodes.length)
|
|
40
|
-
parent.append(...nodes);
|
|
35
|
+
if (nodes.length) parent.append(...nodes);
|
|
41
36
|
}
|
|
42
37
|
function mountAttributes(domElement, props, env) {
|
|
43
38
|
for (const key in props) {
|
|
44
|
-
if (key === "key" || key === "children" || key === "ref")
|
|
45
|
-
continue;
|
|
39
|
+
if (key === "key" || key === "children" || key === "ref") continue;
|
|
46
40
|
if (key === "dangerouslySetInnerHTML") {
|
|
47
41
|
domElement.innerHTML = props[key].__html;
|
|
48
42
|
} else if (key === "innerHTML" || key === "textContent" || key === "innerText" || key === "value" && ["textarea", "select"].includes(domElement.tagName)) {
|
|
49
43
|
const value = props[key];
|
|
50
|
-
if (value != null)
|
|
51
|
-
domElement[key] = value;
|
|
44
|
+
if (value != null) domElement[key] = value;
|
|
52
45
|
} else if (key.startsWith("on")) {
|
|
53
46
|
domElement[key.toLowerCase()] = props[key];
|
|
54
47
|
} else {
|
|
@@ -132,14 +125,12 @@ function mount(vnode, env = DEFAULT_ENV) {
|
|
|
132
125
|
});
|
|
133
126
|
}
|
|
134
127
|
const children = mountChildren(props.children, childEnv);
|
|
135
|
-
if (children != null)
|
|
136
|
-
insertDom(node, children);
|
|
128
|
+
if (children != null) insertDom(node, children);
|
|
137
129
|
}
|
|
138
130
|
const {
|
|
139
131
|
ref
|
|
140
132
|
} = props;
|
|
141
|
-
if (typeof ref === "function")
|
|
142
|
-
ref(node);
|
|
133
|
+
if (typeof ref === "function") ref(node);
|
|
143
134
|
return node;
|
|
144
135
|
}
|
|
145
136
|
throw new Error("mount: Invalid Vnode!");
|
|
@@ -167,8 +158,7 @@ function renderItem({ title, content, onClick }) {
|
|
|
167
158
|
let promise;
|
|
168
159
|
function safeCaller(fn) {
|
|
169
160
|
return async (...args) => {
|
|
170
|
-
if (promise)
|
|
171
|
-
return;
|
|
161
|
+
if (promise) return;
|
|
172
162
|
promise = fn(...args);
|
|
173
163
|
try {
|
|
174
164
|
await promise;
|
|
@@ -244,8 +234,7 @@ const _Toolbar = class _Toolbar {
|
|
|
244
234
|
getHandler(handle) {
|
|
245
235
|
handle = safeCaller(handle);
|
|
246
236
|
return () => {
|
|
247
|
-
if (this.markmap)
|
|
248
|
-
handle(this.markmap);
|
|
237
|
+
if (this.markmap) handle(this.markmap);
|
|
249
238
|
};
|
|
250
239
|
}
|
|
251
240
|
setItems(items) {
|
|
@@ -259,8 +248,7 @@ const _Toolbar = class _Toolbar {
|
|
|
259
248
|
const items = this.items.map((item) => {
|
|
260
249
|
if (typeof item === "string") {
|
|
261
250
|
const data = this.registry[item];
|
|
262
|
-
if (!data)
|
|
263
|
-
console.warn(`[markmap-toolbar] ${item} not found`);
|
|
251
|
+
if (!data) console.warn(`[markmap-toolbar] ${item} not found`);
|
|
264
252
|
return data;
|
|
265
253
|
}
|
|
266
254
|
return item;
|
package/dist/style.css
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
.mm-toolbar
|
|
1
|
+
.mm-toolbar {display:flex;-webkit-user-select:none;-moz-user-select:none;user-select:none;align-items:center;border-width:1px;--un-border-opacity:1;border-color:rgb(212 212 216 / var(--un-border-opacity));border-radius:0.25rem;border-style:solid;--un-bg-opacity:1;background-color:rgb(255 255 255 / var(--un-bg-opacity));padding:0.25rem;line-height:1;
|
|
2
|
+
}
|
|
3
|
+
.mm-toolbar:hover {--un-border-opacity:1;border-color:rgb(161 161 170 / var(--un-border-opacity));
|
|
2
4
|
}
|
|
3
5
|
.mm-toolbar svg {display:block;
|
|
4
6
|
}
|
|
@@ -21,17 +23,16 @@
|
|
|
21
23
|
}
|
|
22
24
|
.mm-toolbar-brand.active, .mm-toolbar-item.active {--un-bg-opacity:1;background-color:rgb(212 212 216 / var(--un-bg-opacity));
|
|
23
25
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
.markmap-dark .mm-toolbar:hover {--un-border-opacity:1;border-color:rgb(113 113 122 / var(--un-border-opacity));
|
|
28
|
-
}
|
|
26
|
+
@media (prefers-color-scheme: dark) {
|
|
27
|
+
.mm-toolbar {--un-border-opacity:1;border-color:rgb(82 82 91 / var(--un-border-opacity));--un-bg-opacity:1;background-color:rgb(39 39 42 / var(--un-bg-opacity));--un-text-opacity:1;color:rgb(161 161 170 / var(--un-text-opacity));
|
|
28
|
+
}
|
|
29
29
|
|
|
30
|
-
.
|
|
30
|
+
.mm-toolbar:hover {--un-border-opacity:1;border-color:rgb(113 113 122 / var(--un-border-opacity));
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
.
|
|
34
|
-
}
|
|
33
|
+
.mm-toolbar > *:hover > * {--un-text-opacity:1;color:rgb(228 228 231 / var(--un-text-opacity));
|
|
34
|
+
}
|
|
35
35
|
|
|
36
|
-
.
|
|
36
|
+
.mm-toolbar > *:hover {--un-bg-opacity:1;background-color:rgb(82 82 91 / var(--un-bg-opacity));
|
|
37
37
|
}
|
|
38
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markmap-toolbar",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.3-alpha.3+89ad076",
|
|
4
4
|
"description": "Extensible toolbar for markmap",
|
|
5
5
|
"author": "Gerald <gera2ld@live.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
"markmap-common": "*"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"markmap-common": "0.17.
|
|
39
|
-
"markmap-view": "0.17.
|
|
38
|
+
"markmap-common": "0.17.3-alpha.3+89ad076",
|
|
39
|
+
"markmap-view": "0.17.3-alpha.3+89ad076"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@babel/runtime": "^7.22.6",
|
|
43
43
|
"@gera2ld/jsx-dom": "^2.2.2"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "89ad076e313dd4c126aeafc49f052315755e8c0d"
|
|
46
46
|
}
|