markmap-toolbar 0.15.4-alpha.1 → 0.15.5-alpha.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 +1 -1
- package/dist/index.mjs +144 -4
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! markmap-toolbar v0.15.
|
|
1
|
+
/*! markmap-toolbar v0.15.5-alpha.0+3c09f62 | MIT License */
|
|
2
2
|
(function (global, factory) {
|
|
3
3
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
4
4
|
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
/*! markmap-toolbar v0.15.
|
|
2
|
-
import { mountDom } from '@gera2ld/jsx-dom';
|
|
3
|
-
import { jsx, jsxs, Fragment } from '@gera2ld/jsx-dom/jsx-runtime';
|
|
4
|
-
|
|
1
|
+
/*! markmap-toolbar v0.15.5-alpha.0+3c09f62 | MIT License */
|
|
5
2
|
function _extends() {
|
|
6
3
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
7
4
|
for (var i = 1; i < arguments.length; i++) {
|
|
@@ -17,6 +14,149 @@ function _extends() {
|
|
|
17
14
|
return _extends.apply(this, arguments);
|
|
18
15
|
}
|
|
19
16
|
|
|
17
|
+
/*! @gera2ld/jsx-dom v2.2.2 | ISC License */
|
|
18
|
+
const VTYPE_ELEMENT = 1;
|
|
19
|
+
const VTYPE_FUNCTION = 2;
|
|
20
|
+
const SVG_NS = 'http://www.w3.org/2000/svg';
|
|
21
|
+
const XLINK_NS = 'http://www.w3.org/1999/xlink';
|
|
22
|
+
const NS_ATTRS = {
|
|
23
|
+
show: XLINK_NS,
|
|
24
|
+
actuate: XLINK_NS,
|
|
25
|
+
href: XLINK_NS
|
|
26
|
+
};
|
|
27
|
+
const isLeaf = c => typeof c === 'string' || typeof c === 'number';
|
|
28
|
+
const isElement = c => (c == null ? void 0 : c.vtype) === VTYPE_ELEMENT;
|
|
29
|
+
const isRenderFunction = c => (c == null ? void 0 : c.vtype) === VTYPE_FUNCTION;
|
|
30
|
+
function jsx(type, props) {
|
|
31
|
+
let vtype;
|
|
32
|
+
if (typeof type === 'string') vtype = VTYPE_ELEMENT;else if (typeof type === 'function') vtype = VTYPE_FUNCTION;else throw new Error('Invalid VNode type');
|
|
33
|
+
return {
|
|
34
|
+
vtype,
|
|
35
|
+
type,
|
|
36
|
+
props
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
const jsxs = jsx;
|
|
40
|
+
function Fragment(props) {
|
|
41
|
+
return props.children;
|
|
42
|
+
}
|
|
43
|
+
const DEFAULT_ENV = {
|
|
44
|
+
isSvg: false
|
|
45
|
+
};
|
|
46
|
+
function insertDom(parent, nodes) {
|
|
47
|
+
if (!Array.isArray(nodes)) nodes = [nodes];
|
|
48
|
+
nodes = nodes.filter(Boolean);
|
|
49
|
+
if (nodes.length) parent.append(...nodes);
|
|
50
|
+
}
|
|
51
|
+
function mountAttributes(domElement, props, env) {
|
|
52
|
+
for (const key in props) {
|
|
53
|
+
if (key === 'key' || key === 'children' || key === 'ref') continue;
|
|
54
|
+
if (key === 'dangerouslySetInnerHTML') {
|
|
55
|
+
domElement.innerHTML = props[key].__html;
|
|
56
|
+
} else if (key === 'innerHTML' || key === 'textContent' || key === 'innerText' || key === 'value' && ['textarea', 'select'].includes(domElement.tagName)) {
|
|
57
|
+
const value = props[key];
|
|
58
|
+
if (value != null) domElement[key] = value;
|
|
59
|
+
} else if (key.startsWith('on')) {
|
|
60
|
+
domElement[key.toLowerCase()] = props[key];
|
|
61
|
+
} else {
|
|
62
|
+
setDOMAttribute(domElement, key, props[key], env.isSvg);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const attrMap = {
|
|
67
|
+
className: 'class',
|
|
68
|
+
labelFor: 'for'
|
|
69
|
+
};
|
|
70
|
+
function setDOMAttribute(el, attr, value, isSVG) {
|
|
71
|
+
attr = attrMap[attr] || attr;
|
|
72
|
+
if (value === true) {
|
|
73
|
+
el.setAttribute(attr, '');
|
|
74
|
+
} else if (value === false) {
|
|
75
|
+
el.removeAttribute(attr);
|
|
76
|
+
} else {
|
|
77
|
+
const namespace = isSVG ? NS_ATTRS[attr] : undefined;
|
|
78
|
+
if (namespace !== undefined) {
|
|
79
|
+
el.setAttributeNS(namespace, attr, value);
|
|
80
|
+
} else {
|
|
81
|
+
el.setAttribute(attr, value);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function flatten(arr) {
|
|
86
|
+
return arr.reduce((prev, item) => prev.concat(item), []);
|
|
87
|
+
}
|
|
88
|
+
function mountChildren(children, env) {
|
|
89
|
+
return Array.isArray(children) ? flatten(children.map(child => mountChildren(child, env))) : mount(children, env);
|
|
90
|
+
}
|
|
91
|
+
function mount(vnode, env = DEFAULT_ENV) {
|
|
92
|
+
if (vnode == null || typeof vnode === 'boolean') {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
if (vnode instanceof Node) {
|
|
96
|
+
return vnode;
|
|
97
|
+
}
|
|
98
|
+
if (isRenderFunction(vnode)) {
|
|
99
|
+
const {
|
|
100
|
+
type,
|
|
101
|
+
props
|
|
102
|
+
} = vnode;
|
|
103
|
+
if (type === Fragment) {
|
|
104
|
+
const node = document.createDocumentFragment();
|
|
105
|
+
if (props.children) {
|
|
106
|
+
const children = mountChildren(props.children, env);
|
|
107
|
+
insertDom(node, children);
|
|
108
|
+
}
|
|
109
|
+
return node;
|
|
110
|
+
}
|
|
111
|
+
const childVNode = type(props);
|
|
112
|
+
return mount(childVNode, env);
|
|
113
|
+
}
|
|
114
|
+
if (isLeaf(vnode)) {
|
|
115
|
+
return document.createTextNode(`${vnode}`);
|
|
116
|
+
}
|
|
117
|
+
if (isElement(vnode)) {
|
|
118
|
+
let node;
|
|
119
|
+
const {
|
|
120
|
+
type,
|
|
121
|
+
props
|
|
122
|
+
} = vnode;
|
|
123
|
+
if (!env.isSvg && type === 'svg') {
|
|
124
|
+
env = Object.assign({}, env, {
|
|
125
|
+
isSvg: true
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
if (!env.isSvg) {
|
|
129
|
+
node = document.createElement(type);
|
|
130
|
+
} else {
|
|
131
|
+
node = document.createElementNS(SVG_NS, type);
|
|
132
|
+
}
|
|
133
|
+
mountAttributes(node, props, env);
|
|
134
|
+
if (props.children) {
|
|
135
|
+
let childEnv = env;
|
|
136
|
+
if (env.isSvg && type === 'foreignObject') {
|
|
137
|
+
childEnv = Object.assign({}, childEnv, {
|
|
138
|
+
isSvg: false
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
const children = mountChildren(props.children, childEnv);
|
|
142
|
+
if (children != null) insertDom(node, children);
|
|
143
|
+
}
|
|
144
|
+
const {
|
|
145
|
+
ref
|
|
146
|
+
} = props;
|
|
147
|
+
if (typeof ref === 'function') ref(node);
|
|
148
|
+
return node;
|
|
149
|
+
}
|
|
150
|
+
throw new Error('mount: Invalid Vnode!');
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Mount vdom as real DOM nodes.
|
|
155
|
+
*/
|
|
156
|
+
function mountDom(vnode) {
|
|
157
|
+
return mount(vnode);
|
|
158
|
+
}
|
|
159
|
+
|
|
20
160
|
const clsToolbarItem = 'mm-toolbar-item';
|
|
21
161
|
const clsActive = 'active';
|
|
22
162
|
function renderBrand() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markmap-toolbar",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.5-alpha.0+3c09f62",
|
|
4
4
|
"description": "Extensible toolbar for markmap",
|
|
5
5
|
"author": "Gerald <gera2ld@live.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"markmap-common": "0.15.3",
|
|
39
|
-
"markmap-view": "0.15.4
|
|
39
|
+
"markmap-view": "0.15.4"
|
|
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": "3c09f62f71732597eb5ea5f968d6ea932e7e15a7"
|
|
46
46
|
}
|