markmap-toolbar 0.17.2 → 0.17.3-alpha.1

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 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
- vtype = VTYPE_ELEMENT;
20
- else if (typeof type === "function")
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
- vtype = VTYPE_ELEMENT;
18
- else if (typeof type === "function")
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markmap-toolbar",
3
- "version": "0.17.2",
3
+ "version": "0.17.3-alpha.1+4942a37",
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.17.1",
39
- "markmap-view": "0.17.2"
39
+ "markmap-view": "0.17.3-alpha.1+4942a37"
40
40
  },
41
41
  "dependencies": {
42
42
  "@babel/runtime": "^7.22.6",
43
43
  "@gera2ld/jsx-dom": "^2.2.2"
44
44
  },
45
- "gitHead": "bbeec32d0efeea4e36755b1909a5993187264487"
45
+ "gitHead": "4942a3759db08bbbc179034c0b08c5c2112566dc"
46
46
  }