@markmap/toolbar 1.0.0 → 1.1.0
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 +9 -1
- package/dist/toolbar.d.ts +2 -0
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -70,6 +70,7 @@ var CSS = `
|
|
|
70
70
|
.markmap-toolbar button:disabled, .markmap-toolbar select:disabled { opacity: 0.35; cursor: default; }
|
|
71
71
|
.markmap-toolbar :focus-visible { outline: 2px solid var(--mm-link, #0097e6); outline-offset: -2px; }
|
|
72
72
|
.markmap-toolbar option { background: Canvas; color: CanvasText; }
|
|
73
|
+
.markmap-toolbar img { display: block; margin: auto; width: 16px; height: 16px; }
|
|
73
74
|
.markmap-toolbar svg { display: block; margin: auto; width: 16px; height: 16px; }
|
|
74
75
|
.markmap-toolbar path { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
|
|
75
76
|
`;
|
|
@@ -84,6 +85,12 @@ function createIcon(doc, path) {
|
|
|
84
85
|
svg.append(shape);
|
|
85
86
|
return svg;
|
|
86
87
|
}
|
|
88
|
+
function createImage(doc, src) {
|
|
89
|
+
const img = doc.createElement("img");
|
|
90
|
+
img.src = src;
|
|
91
|
+
img.alt = "";
|
|
92
|
+
return img;
|
|
93
|
+
}
|
|
87
94
|
/** Depth of the deepest node with children: folding deeper than that does nothing. */
|
|
88
95
|
function deepestParent(node, depth = 0) {
|
|
89
96
|
if (!node?.children.length) return 0;
|
|
@@ -143,7 +150,8 @@ function createToolbar(mm, options = {}) {
|
|
|
143
150
|
el.type = "button";
|
|
144
151
|
el.title = item.label;
|
|
145
152
|
el.setAttribute("aria-label", item.label);
|
|
146
|
-
if (item.
|
|
153
|
+
if (item.image) el.append(createImage(doc, item.image));
|
|
154
|
+
else if (item.icon) el.append(createIcon(doc, item.icon));
|
|
147
155
|
else el.textContent = item.label;
|
|
148
156
|
el.addEventListener("click", () => {
|
|
149
157
|
item.onClick(mm);
|
package/dist/toolbar.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ export interface ToolbarButton {
|
|
|
5
5
|
label: string;
|
|
6
6
|
/** Path data of a line drawing in a 16 × 16 box. */
|
|
7
7
|
icon?: string;
|
|
8
|
+
/** URL of a full-color image, such as a logo, shown at icon size. Wins over `icon`. */
|
|
9
|
+
image?: string;
|
|
8
10
|
/** Checked whenever the map changes. */
|
|
9
11
|
disabled?: (mm: Markmap) => boolean;
|
|
10
12
|
onClick: (mm: Markmap) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markmap/toolbar",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Zoom and fold controls for a Markmap view",
|
|
5
5
|
"homepage": "https://github.com/markmap/markmap#readme",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,13 +24,13 @@
|
|
|
24
24
|
"access": "public"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@markmap/parse": "1.
|
|
28
|
-
"@markmap/render": "1.
|
|
29
|
-
"@markmap/view": "1.
|
|
27
|
+
"@markmap/parse": "1.1.0",
|
|
28
|
+
"@markmap/render": "1.1.0",
|
|
29
|
+
"@markmap/view": "1.1.0",
|
|
30
30
|
"happy-dom": "^21.0.4"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@markmap/view": "^1.
|
|
33
|
+
"@markmap/view": "^1.1.0"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"clean": "rm -rf dist tsconfig.tsbuildinfo",
|