prosemirror-menu 1.2.3 → 1.2.4
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/CHANGELOG.md +6 -0
- package/dist/index.cjs +15 -29
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/src/icons.ts +2 -2
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -18,12 +18,6 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
18
18
|
|
|
19
19
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
20
20
|
|
|
21
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
22
|
-
|
|
23
|
-
Object.defineProperty(exports, '__esModule', {
|
|
24
|
-
value: true
|
|
25
|
-
});
|
|
26
|
-
|
|
27
21
|
var crel = require('crelt');
|
|
28
22
|
|
|
29
23
|
var prosemirrorCommands = require('prosemirror-commands');
|
|
@@ -32,14 +26,6 @@ var prosemirrorHistory = require('prosemirror-history');
|
|
|
32
26
|
|
|
33
27
|
var prosemirrorState = require('prosemirror-state');
|
|
34
28
|
|
|
35
|
-
function _interopDefaultLegacy(e) {
|
|
36
|
-
return e && _typeof(e) === 'object' && 'default' in e ? e : {
|
|
37
|
-
'default': e
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
var crel__default = _interopDefaultLegacy(crel);
|
|
42
|
-
|
|
43
29
|
var SVG = "http://www.w3.org/2000/svg";
|
|
44
30
|
var XLINK = "http://www.w3.org/1999/xlink";
|
|
45
31
|
var prefix$2 = "ProseMirror-icon";
|
|
@@ -55,7 +41,7 @@ function hashPath(path) {
|
|
|
55
41
|
}
|
|
56
42
|
|
|
57
43
|
function getIcon(root, icon) {
|
|
58
|
-
var doc = root.ownerDocument;
|
|
44
|
+
var doc = (root.nodeType == 9 ? root : root.ownerDocument) || document;
|
|
59
45
|
var node = doc.createElement("div");
|
|
60
46
|
node.className = prefix$2;
|
|
61
47
|
|
|
@@ -82,7 +68,7 @@ function getIcon(root, icon) {
|
|
|
82
68
|
}
|
|
83
69
|
|
|
84
70
|
function buildSVG(root, name, data) {
|
|
85
|
-
var _ref = root.nodeType == 9 ? [root, root.body] : [root.ownerDocument, root],
|
|
71
|
+
var _ref = root.nodeType == 9 ? [root, root.body] : [root.ownerDocument || document, root],
|
|
86
72
|
_ref2 = _slicedToArray(_ref, 2),
|
|
87
73
|
doc = _ref2[0],
|
|
88
74
|
top = _ref2[1];
|
|
@@ -117,7 +103,7 @@ var MenuItem = function () {
|
|
|
117
103
|
key: "render",
|
|
118
104
|
value: function render(view) {
|
|
119
105
|
var spec = this.spec;
|
|
120
|
-
var dom = spec.render ? spec.render(view) : spec.icon ? getIcon(view.root, spec.icon) : spec.label ?
|
|
106
|
+
var dom = spec.render ? spec.render(view) : spec.icon ? getIcon(view.root, spec.icon) : spec.label ? crel("div", null, translate(view, spec.label)) : null;
|
|
121
107
|
if (!dom) throw new RangeError("MenuItem without icon or label property");
|
|
122
108
|
|
|
123
109
|
if (spec.title) {
|
|
@@ -200,12 +186,12 @@ var Dropdown = function () {
|
|
|
200
186
|
|
|
201
187
|
var content = renderDropdownItems(this.content, view);
|
|
202
188
|
var win = view.dom.ownerDocument.defaultView || window;
|
|
203
|
-
var label =
|
|
189
|
+
var label = crel("div", {
|
|
204
190
|
"class": prefix$1 + "-dropdown " + (this.options["class"] || ""),
|
|
205
191
|
style: this.options.css
|
|
206
192
|
}, translate(view, this.options.label || ""));
|
|
207
193
|
if (this.options.title) label.setAttribute("title", translate(view, this.options.title));
|
|
208
|
-
var wrap =
|
|
194
|
+
var wrap = crel("div", {
|
|
209
195
|
"class": prefix$1 + "-dropdown-wrap"
|
|
210
196
|
}, label);
|
|
211
197
|
var open = null;
|
|
@@ -246,7 +232,7 @@ var Dropdown = function () {
|
|
|
246
232
|
}, {
|
|
247
233
|
key: "expand",
|
|
248
234
|
value: function expand(dom, items) {
|
|
249
|
-
var menuDOM =
|
|
235
|
+
var menuDOM = crel("div", {
|
|
250
236
|
"class": prefix$1 + "-dropdown-menu " + (this.options["class"] || "")
|
|
251
237
|
}, items);
|
|
252
238
|
var done = false;
|
|
@@ -278,7 +264,7 @@ function renderDropdownItems(items, view) {
|
|
|
278
264
|
dom = _items$i$render.dom,
|
|
279
265
|
update = _items$i$render.update;
|
|
280
266
|
|
|
281
|
-
rendered.push(
|
|
267
|
+
rendered.push(crel("div", {
|
|
282
268
|
"class": prefix$1 + "-dropdown-item"
|
|
283
269
|
}, dom));
|
|
284
270
|
updates.push(update);
|
|
@@ -319,12 +305,12 @@ var DropdownSubmenu = function () {
|
|
|
319
305
|
value: function render(view) {
|
|
320
306
|
var items = renderDropdownItems(this.content, view);
|
|
321
307
|
var win = view.dom.ownerDocument.defaultView || window;
|
|
322
|
-
var label =
|
|
308
|
+
var label = crel("div", {
|
|
323
309
|
"class": prefix$1 + "-submenu-label"
|
|
324
310
|
}, translate(view, this.options.label || ""));
|
|
325
|
-
var wrap =
|
|
311
|
+
var wrap = crel("div", {
|
|
326
312
|
"class": prefix$1 + "-submenu-wrap"
|
|
327
|
-
}, label,
|
|
313
|
+
}, label, crel("div", {
|
|
328
314
|
"class": prefix$1 + "-submenu"
|
|
329
315
|
}, items.dom));
|
|
330
316
|
var _listeningOnClose = null;
|
|
@@ -372,7 +358,7 @@ function renderGrouped(view, content) {
|
|
|
372
358
|
dom = _items$j$render.dom,
|
|
373
359
|
_update = _items$j$render.update;
|
|
374
360
|
|
|
375
|
-
var span =
|
|
361
|
+
var span = crel("span", {
|
|
376
362
|
"class": prefix$1 + "item"
|
|
377
363
|
}, dom);
|
|
378
364
|
result.appendChild(span);
|
|
@@ -408,7 +394,7 @@ function renderGrouped(view, content) {
|
|
|
408
394
|
}
|
|
409
395
|
|
|
410
396
|
function separator() {
|
|
411
|
-
return
|
|
397
|
+
return crel("span", {
|
|
412
398
|
"class": prefix$1 + "separator"
|
|
413
399
|
});
|
|
414
400
|
}
|
|
@@ -589,10 +575,10 @@ var MenuBarView = function () {
|
|
|
589
575
|
this.widthForMaxHeight = 0;
|
|
590
576
|
this.floating = false;
|
|
591
577
|
this.scrollHandler = null;
|
|
592
|
-
this.wrapper =
|
|
578
|
+
this.wrapper = crel("div", {
|
|
593
579
|
"class": prefix + "-wrapper"
|
|
594
580
|
});
|
|
595
|
-
this.menu = this.wrapper.appendChild(
|
|
581
|
+
this.menu = this.wrapper.appendChild(crel("div", {
|
|
596
582
|
"class": prefix
|
|
597
583
|
}));
|
|
598
584
|
this.menu.className = prefix;
|
|
@@ -686,7 +672,7 @@ var MenuBarView = function () {
|
|
|
686
672
|
this.menu.style.width = menuRect.width + "px";
|
|
687
673
|
if (scrollAncestor) this.menu.style.top = top + "px";
|
|
688
674
|
this.menu.style.position = "fixed";
|
|
689
|
-
this.spacer =
|
|
675
|
+
this.spacer = crel("div", {
|
|
690
676
|
"class": prefix + "-spacer",
|
|
691
677
|
style: "height: ".concat(menuRect.height, "px")
|
|
692
678
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -55,7 +55,7 @@ specifying a string of text that makes up the icon, with an
|
|
|
55
55
|
optional `css` property giving additional CSS styling for the
|
|
56
56
|
text. _Or_ it may contain `dom` property containing a DOM node.
|
|
57
57
|
*/
|
|
58
|
-
|
|
58
|
+
type IconSpec = {
|
|
59
59
|
path: string;
|
|
60
60
|
width: number;
|
|
61
61
|
height: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -55,7 +55,7 @@ specifying a string of text that makes up the icon, with an
|
|
|
55
55
|
optional `css` property giving additional CSS styling for the
|
|
56
56
|
text. _Or_ it may contain `dom` property containing a DOM node.
|
|
57
57
|
*/
|
|
58
|
-
|
|
58
|
+
type IconSpec = {
|
|
59
59
|
path: string;
|
|
60
60
|
width: number;
|
|
61
61
|
height: number;
|
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ function hashPath(path) {
|
|
|
13
13
|
return hash;
|
|
14
14
|
}
|
|
15
15
|
function getIcon(root, icon) {
|
|
16
|
-
let doc = root.ownerDocument;
|
|
16
|
+
let doc = (root.nodeType == 9 ? root : root.ownerDocument) || document;
|
|
17
17
|
let node = doc.createElement("div");
|
|
18
18
|
node.className = prefix$2;
|
|
19
19
|
if (icon.path) {
|
|
@@ -38,7 +38,7 @@ function getIcon(root, icon) {
|
|
|
38
38
|
return node;
|
|
39
39
|
}
|
|
40
40
|
function buildSVG(root, name, data) {
|
|
41
|
-
let [doc, top] = root.nodeType == 9 ? [root, root.body] : [root.ownerDocument, root];
|
|
41
|
+
let [doc, top] = root.nodeType == 9 ? [root, root.body] : [root.ownerDocument || document, root];
|
|
42
42
|
let collection = doc.getElementById(prefix$2 + "-collection");
|
|
43
43
|
if (!collection) {
|
|
44
44
|
collection = doc.createElementNS(SVG, "svg");
|
package/package.json
CHANGED
package/src/icons.ts
CHANGED
|
@@ -14,7 +14,7 @@ export function getIcon(
|
|
|
14
14
|
root: Document | ShadowRoot,
|
|
15
15
|
icon: {path: string, width: number, height: number} | {text: string, css?: string} | {dom: Node}
|
|
16
16
|
): HTMLElement {
|
|
17
|
-
let doc = root.ownerDocument
|
|
17
|
+
let doc = (root.nodeType == 9 ? root as Document : root.ownerDocument) || document
|
|
18
18
|
let node = doc.createElement("div")
|
|
19
19
|
node.className = prefix
|
|
20
20
|
if ((icon as any).path) {
|
|
@@ -36,7 +36,7 @@ export function getIcon(
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
function buildSVG(root: Document | ShadowRoot, name: string, data: {width: number, height: number, path: string}) {
|
|
39
|
-
let [doc, top] = root.nodeType == 9 ? [root as Document, (root as Document).body] : [root.ownerDocument
|
|
39
|
+
let [doc, top] = root.nodeType == 9 ? [root as Document, (root as Document).body] : [root.ownerDocument || document, root]
|
|
40
40
|
let collection = doc.getElementById(prefix + "-collection") as Element
|
|
41
41
|
if (!collection) {
|
|
42
42
|
collection = doc.createElementNS(SVG, "svg")
|