@dooherceg/tiptap-controlled-editor-with-table 0.0.6 → 0.0.8
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/_virtual/_commonjsHelpers.js +8 -0
- package/dist/_virtual/index.js +7 -0
- package/dist/assets/components/tiptap-node/blockquote-node/blockquote-node.css +1 -0
- package/dist/assets/components/tiptap-node/code-block-node/code-block-node.css +1 -0
- package/dist/assets/components/tiptap-node/heading-node/heading-node.css +1 -0
- package/dist/assets/components/tiptap-node/horizontal-rule-node/horizontal-rule-node.css +1 -0
- package/dist/assets/components/tiptap-node/image-node/image-node.css +1 -0
- package/dist/assets/components/tiptap-node/list-node/list-node.css +1 -0
- package/dist/assets/components/tiptap-node/paragraph-node/paragraph-node.css +1 -0
- package/dist/assets/components/tiptap-templates/simple/simple-editor.css +1 -0
- package/dist/assets/{badge.css → components/tiptap-ui-primitive/badge/badge-colors.css} +1 -1
- package/dist/assets/components/tiptap-ui-primitive/badge/badge-group.css +1 -0
- package/dist/assets/components/tiptap-ui-primitive/badge/badge.css +1 -0
- package/dist/assets/{button.css → components/tiptap-ui-primitive/button/button-colors.css} +1 -1
- package/dist/assets/components/tiptap-ui-primitive/button/button-group.css +1 -0
- package/dist/assets/components/tiptap-ui-primitive/button/button.css +1 -0
- package/dist/assets/styles/_keyframe-animations.css +1 -0
- package/dist/assets/styles/_variables.css +1 -0
- package/dist/components/tiptap-node/horizontal-rule-node/horizontal-rule-node-extension.js +6 -58
- package/dist/components/tiptap-node/image-upload-node/image-upload-node.js +4 -3
- package/dist/components/tiptap-templates/simple/simple-editor.js +160 -1899
- package/dist/components/tiptap-ui/color-highlight-button/color-highlight-button.js +6 -5
- package/dist/components/tiptap-ui/color-highlight-button/use-color-highlight.js +1 -1
- package/dist/components/tiptap-ui/image-upload-button/use-image-upload.js +16 -16
- package/dist/components/tiptap-ui-primitive/badge/badge.js +19 -16
- package/dist/components/tiptap-ui-primitive/button/button.js +18 -15
- package/dist/components/tiptap-ui-primitive/card/card.js +13 -12
- package/dist/components/tiptap-ui-primitive/dropdown-menu/dropdown-menu.js +39 -1012
- package/dist/components/tiptap-ui-primitive/input/input.js +7 -6
- package/dist/components/tiptap-ui-primitive/popover/popover.js +24 -233
- package/dist/components/tiptap-ui-primitive/separator/separator.js +9 -8
- package/dist/components/tiptap-ui-primitive/toolbar/toolbar.js +2 -1
- package/dist/components/tiptap-ui-primitive/tooltip/tooltip.js +84 -1330
- package/dist/hooks/use-throttled-callback.js +13 -108
- package/dist/node_modules/@floating-ui/core/dist/floating-ui.core.js +527 -0
- package/dist/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +402 -0
- package/dist/node_modules/@floating-ui/react/dist/floating-ui.react.js +932 -0
- package/dist/node_modules/@floating-ui/react/dist/floating-ui.react.utils.js +185 -0
- package/dist/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.js +208 -0
- package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +136 -0
- package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +130 -0
- package/dist/node_modules/@radix-ui/primitive/dist/index.js +9 -0
- package/dist/node_modules/@radix-ui/react-arrow/dist/index.js +24 -0
- package/dist/node_modules/@radix-ui/react-collection/dist/index.js +48 -0
- package/dist/node_modules/@radix-ui/react-compose-refs/dist/index.js +29 -0
- package/dist/node_modules/@radix-ui/react-context/dist/index.js +53 -0
- package/dist/node_modules/@radix-ui/react-direction/dist/index.js +10 -0
- package/dist/node_modules/@radix-ui/react-dismissable-layer/dist/index.js +127 -0
- package/dist/node_modules/@radix-ui/react-dropdown-menu/dist/index.js +221 -0
- package/dist/node_modules/@radix-ui/react-focus-guards/dist/index.js +17 -0
- package/dist/node_modules/@radix-ui/react-focus-scope/dist/index.js +136 -0
- package/dist/node_modules/@radix-ui/react-id/dist/index.js +13 -0
- package/dist/node_modules/@radix-ui/react-menu/dist/index.js +636 -0
- package/dist/node_modules/@radix-ui/react-popover/dist/index.js +239 -0
- package/dist/node_modules/@radix-ui/react-popper/dist/index.js +219 -0
- package/dist/node_modules/@radix-ui/react-portal/dist/index.js +15 -0
- package/dist/node_modules/@radix-ui/react-presence/dist/index.js +70 -0
- package/dist/node_modules/@radix-ui/react-primitive/dist/index.js +36 -0
- package/dist/node_modules/@radix-ui/react-roving-focus/dist/index.js +183 -0
- package/dist/node_modules/@radix-ui/react-slot/dist/index.js +49 -0
- package/dist/node_modules/@radix-ui/react-use-callback-ref/dist/index.js +10 -0
- package/dist/node_modules/@radix-ui/react-use-controllable-state/dist/index.js +52 -0
- package/dist/node_modules/@radix-ui/react-use-escape-keydown/dist/index.js +14 -0
- package/dist/node_modules/@radix-ui/react-use-layout-effect/dist/index.js +6 -0
- package/dist/node_modules/@radix-ui/react-use-size/dist/index.js +27 -0
- package/dist/node_modules/@tiptap/extension-highlight/dist/index.js +84 -0
- package/dist/node_modules/@tiptap/extension-horizontal-rule/dist/index.js +57 -0
- package/dist/node_modules/@tiptap/extension-image/dist/index.js +128 -0
- package/dist/node_modules/@tiptap/extension-list/dist/index.js +713 -0
- package/dist/node_modules/@tiptap/extension-subscript/dist/index.js +40 -0
- package/dist/node_modules/@tiptap/extension-superscript/dist/index.js +40 -0
- package/dist/node_modules/@tiptap/extension-table/dist/index.js +380 -0
- package/dist/node_modules/@tiptap/extension-text-align/dist/index.js +46 -0
- package/dist/node_modules/@tiptap/extension-typography/dist/index.js +125 -0
- package/dist/node_modules/@tiptap/extensions/dist/index.js +288 -0
- package/dist/node_modules/aria-hidden/dist/es2015/index.js +52 -0
- package/dist/node_modules/get-nonce/dist/es2015/index.js +7 -0
- package/dist/node_modules/lodash.throttle/index.js +95 -0
- package/dist/{index-Bqw9S4qP.js → node_modules/react-hotkeys-hook/packages/react-hotkeys-hook/dist/index.js} +57 -55
- package/dist/node_modules/react-remove-scroll/dist/es2015/Combination.js +11 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/SideEffect.js +112 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/UI.js +31 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.js +16 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/handleScroll.js +68 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/medium.js +5 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/sidecar.js +7 -0
- package/dist/node_modules/react-remove-scroll-bar/dist/es2015/component.js +71 -0
- package/dist/node_modules/react-remove-scroll-bar/dist/es2015/constants.js +7 -0
- package/dist/node_modules/react-remove-scroll-bar/dist/es2015/utils.js +25 -0
- package/dist/node_modules/react-style-singleton/dist/es2015/component.js +11 -0
- package/dist/node_modules/react-style-singleton/dist/es2015/hook.js +15 -0
- package/dist/node_modules/react-style-singleton/dist/es2015/singleton.js +30 -0
- package/dist/node_modules/tabbable/dist/index.esm.js +197 -0
- package/dist/node_modules/tslib/tslib.es6.js +27 -0
- package/dist/node_modules/use-callback-ref/dist/es2015/assignRef.js +6 -0
- package/dist/node_modules/use-callback-ref/dist/es2015/useMergeRef.js +26 -0
- package/dist/node_modules/use-callback-ref/dist/es2015/useRef.js +25 -0
- package/dist/node_modules/use-sidecar/dist/es2015/exports.js +18 -0
- package/dist/node_modules/use-sidecar/dist/es2015/medium.js +67 -0
- package/package.json +1 -1
- package/dist/Combination-CO0ZtURs.js +0 -1333
- package/dist/assets/simple-editor.css +0 -1
- package/dist/floating-ui.react-dom-DgOuULHo.js +0 -1334
- /package/dist/assets/{image-upload-node.css → components/tiptap-node/image-upload-node/image-upload-node.css} +0 -0
- /package/dist/assets/{color-highlight-button.css → components/tiptap-ui/color-highlight-button/color-highlight-button.css} +0 -0
- /package/dist/assets/{card.css → components/tiptap-ui-primitive/card/card.css} +0 -0
- /package/dist/assets/{dropdown-menu.css → components/tiptap-ui-primitive/dropdown-menu/dropdown-menu.css} +0 -0
- /package/dist/assets/{input.css → components/tiptap-ui-primitive/input/input.css} +0 -0
- /package/dist/assets/{popover.css → components/tiptap-ui-primitive/popover/popover.css} +0 -0
- /package/dist/assets/{separator.css → components/tiptap-ui-primitive/separator/separator.css} +0 -0
- /package/dist/assets/{toolbar.css → components/tiptap-ui-primitive/toolbar/toolbar.css} +0 -0
- /package/dist/assets/{tooltip.css → components/tiptap-ui-primitive/tooltip/tooltip.css} +0 -0
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import { Extension as u, callOrReturn as w, getExtensionField as S, isNodeEmpty as P, isNodeSelection as v } from "@tiptap/core";
|
|
2
|
+
import { Plugin as p, PluginKey as m } from "prosemirror-state";
|
|
3
|
+
import { dropCursor as z } from "prosemirror-dropcursor";
|
|
4
|
+
import { DecorationSet as f, Decoration as g } from "prosemirror-view";
|
|
5
|
+
import { gapCursor as E } from "prosemirror-gapcursor";
|
|
6
|
+
import { history as M, redo as N, undo as O } from "prosemirror-history";
|
|
7
|
+
u.create({
|
|
8
|
+
name: "characterCount",
|
|
9
|
+
addOptions() {
|
|
10
|
+
return {
|
|
11
|
+
limit: null,
|
|
12
|
+
mode: "textSize",
|
|
13
|
+
textCounter: (e) => e.length,
|
|
14
|
+
wordCounter: (e) => e.split(" ").filter((t) => t !== "").length
|
|
15
|
+
};
|
|
16
|
+
},
|
|
17
|
+
addStorage() {
|
|
18
|
+
return {
|
|
19
|
+
characters: () => 0,
|
|
20
|
+
words: () => 0
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
onBeforeCreate() {
|
|
24
|
+
this.storage.characters = (e) => {
|
|
25
|
+
const t = e?.node || this.editor.state.doc;
|
|
26
|
+
if ((e?.mode || this.options.mode) === "textSize") {
|
|
27
|
+
const r = t.textBetween(0, t.content.size, void 0, " ");
|
|
28
|
+
return this.options.textCounter(r);
|
|
29
|
+
}
|
|
30
|
+
return t.nodeSize;
|
|
31
|
+
}, this.storage.words = (e) => {
|
|
32
|
+
const t = e?.node || this.editor.state.doc, n = t.textBetween(0, t.content.size, " ", " ");
|
|
33
|
+
return this.options.wordCounter(n);
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
addProseMirrorPlugins() {
|
|
37
|
+
let e = !1;
|
|
38
|
+
return [
|
|
39
|
+
new p({
|
|
40
|
+
key: new m("characterCount"),
|
|
41
|
+
appendTransaction: (t, n, r) => {
|
|
42
|
+
if (e)
|
|
43
|
+
return;
|
|
44
|
+
const o = this.options.limit;
|
|
45
|
+
if (o == null || o === 0) {
|
|
46
|
+
e = !0;
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const s = this.storage.characters({ node: r.doc });
|
|
50
|
+
if (s > o) {
|
|
51
|
+
const i = s - o, d = 0, a = i;
|
|
52
|
+
console.warn(
|
|
53
|
+
`[CharacterCount] Initial content exceeded limit of ${o} characters. Content was automatically trimmed.`
|
|
54
|
+
);
|
|
55
|
+
const c = r.tr.deleteRange(d, a);
|
|
56
|
+
return e = !0, c;
|
|
57
|
+
}
|
|
58
|
+
e = !0;
|
|
59
|
+
},
|
|
60
|
+
filterTransaction: (t, n) => {
|
|
61
|
+
const r = this.options.limit;
|
|
62
|
+
if (!t.docChanged || r === 0 || r === null || r === void 0)
|
|
63
|
+
return !0;
|
|
64
|
+
const o = this.storage.characters({ node: n.doc }), s = this.storage.characters({ node: t.doc });
|
|
65
|
+
if (s <= r || o > r && s > r && s <= o)
|
|
66
|
+
return !0;
|
|
67
|
+
if (o > r && s > r && s > o || !t.getMeta("paste"))
|
|
68
|
+
return !1;
|
|
69
|
+
const d = t.selection.$head.pos, a = s - r, c = d - a, l = d;
|
|
70
|
+
return t.deleteRange(c, l), !(this.storage.characters({ node: t.doc }) > r);
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
u.create({
|
|
77
|
+
name: "dropCursor",
|
|
78
|
+
addOptions() {
|
|
79
|
+
return {
|
|
80
|
+
color: "currentColor",
|
|
81
|
+
width: 1,
|
|
82
|
+
class: void 0
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
addProseMirrorPlugins() {
|
|
86
|
+
return [z(this.options)];
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
u.create({
|
|
90
|
+
name: "focus",
|
|
91
|
+
addOptions() {
|
|
92
|
+
return {
|
|
93
|
+
className: "has-focus",
|
|
94
|
+
mode: "all"
|
|
95
|
+
};
|
|
96
|
+
},
|
|
97
|
+
addProseMirrorPlugins() {
|
|
98
|
+
return [
|
|
99
|
+
new p({
|
|
100
|
+
key: new m("focus"),
|
|
101
|
+
props: {
|
|
102
|
+
decorations: ({ doc: e, selection: t }) => {
|
|
103
|
+
const { isEditable: n, isFocused: r } = this.editor, { anchor: o } = t, s = [];
|
|
104
|
+
if (!n || !r)
|
|
105
|
+
return f.create(e, []);
|
|
106
|
+
let i = 0;
|
|
107
|
+
this.options.mode === "deepest" && e.descendants((a, c) => {
|
|
108
|
+
if (a.isText)
|
|
109
|
+
return;
|
|
110
|
+
if (!(o >= c && o <= c + a.nodeSize - 1))
|
|
111
|
+
return !1;
|
|
112
|
+
i += 1;
|
|
113
|
+
});
|
|
114
|
+
let d = 0;
|
|
115
|
+
return e.descendants((a, c) => {
|
|
116
|
+
if (a.isText || !(o >= c && o <= c + a.nodeSize - 1))
|
|
117
|
+
return !1;
|
|
118
|
+
if (d += 1, this.options.mode === "deepest" && i - d > 0 || this.options.mode === "shallowest" && d > 1)
|
|
119
|
+
return this.options.mode === "deepest";
|
|
120
|
+
s.push(
|
|
121
|
+
g.node(c, c + a.nodeSize, {
|
|
122
|
+
class: this.options.className
|
|
123
|
+
})
|
|
124
|
+
);
|
|
125
|
+
}), f.create(e, s);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
})
|
|
129
|
+
];
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
u.create({
|
|
133
|
+
name: "gapCursor",
|
|
134
|
+
addProseMirrorPlugins() {
|
|
135
|
+
return [E()];
|
|
136
|
+
},
|
|
137
|
+
extendNodeSchema(e) {
|
|
138
|
+
var t;
|
|
139
|
+
const n = {
|
|
140
|
+
name: e.name,
|
|
141
|
+
options: e.options,
|
|
142
|
+
storage: e.storage
|
|
143
|
+
};
|
|
144
|
+
return {
|
|
145
|
+
allowGapCursor: (t = w(S(e, "allowGapCursor", n))) != null ? t : null
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
var k = u.create({
|
|
150
|
+
name: "placeholder",
|
|
151
|
+
addOptions() {
|
|
152
|
+
return {
|
|
153
|
+
emptyEditorClass: "is-editor-empty",
|
|
154
|
+
emptyNodeClass: "is-empty",
|
|
155
|
+
placeholder: "Write something …",
|
|
156
|
+
showOnlyWhenEditable: !0,
|
|
157
|
+
showOnlyCurrent: !0,
|
|
158
|
+
includeChildren: !1
|
|
159
|
+
};
|
|
160
|
+
},
|
|
161
|
+
addProseMirrorPlugins() {
|
|
162
|
+
return [
|
|
163
|
+
new p({
|
|
164
|
+
key: new m("placeholder"),
|
|
165
|
+
props: {
|
|
166
|
+
decorations: ({ doc: e, selection: t }) => {
|
|
167
|
+
const n = this.editor.isEditable || !this.options.showOnlyWhenEditable, { anchor: r } = t, o = [];
|
|
168
|
+
if (!n)
|
|
169
|
+
return null;
|
|
170
|
+
const s = this.editor.isEmpty;
|
|
171
|
+
return e.descendants((i, d) => {
|
|
172
|
+
const a = r >= d && r <= d + i.nodeSize, c = !i.isLeaf && P(i);
|
|
173
|
+
if ((a || !this.options.showOnlyCurrent) && c) {
|
|
174
|
+
const l = [this.options.emptyNodeClass];
|
|
175
|
+
s && l.push(this.options.emptyEditorClass);
|
|
176
|
+
const h = g.node(d, d + i.nodeSize, {
|
|
177
|
+
class: l.join(" "),
|
|
178
|
+
"data-placeholder": typeof this.options.placeholder == "function" ? this.options.placeholder({
|
|
179
|
+
editor: this.editor,
|
|
180
|
+
node: i,
|
|
181
|
+
pos: d,
|
|
182
|
+
hasAnchor: a
|
|
183
|
+
}) : this.options.placeholder
|
|
184
|
+
});
|
|
185
|
+
o.push(h);
|
|
186
|
+
}
|
|
187
|
+
return this.options.includeChildren;
|
|
188
|
+
}), f.create(e, o);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
})
|
|
192
|
+
];
|
|
193
|
+
}
|
|
194
|
+
}), F = u.create({
|
|
195
|
+
name: "selection",
|
|
196
|
+
addOptions() {
|
|
197
|
+
return {
|
|
198
|
+
className: "selection"
|
|
199
|
+
};
|
|
200
|
+
},
|
|
201
|
+
addProseMirrorPlugins() {
|
|
202
|
+
const { editor: e, options: t } = this;
|
|
203
|
+
return [
|
|
204
|
+
new p({
|
|
205
|
+
key: new m("selection"),
|
|
206
|
+
props: {
|
|
207
|
+
decorations(n) {
|
|
208
|
+
return n.selection.empty || e.isFocused || !e.isEditable || v(n.selection) || e.view.dragging ? null : f.create(n.doc, [
|
|
209
|
+
g.inline(n.selection.from, n.selection.to, {
|
|
210
|
+
class: t.className
|
|
211
|
+
})
|
|
212
|
+
]);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
})
|
|
216
|
+
];
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
function y({ types: e, node: t }) {
|
|
220
|
+
return t && Array.isArray(e) && e.includes(t.type) || t?.type === e;
|
|
221
|
+
}
|
|
222
|
+
u.create({
|
|
223
|
+
name: "trailingNode",
|
|
224
|
+
addOptions() {
|
|
225
|
+
return {
|
|
226
|
+
node: void 0,
|
|
227
|
+
notAfter: []
|
|
228
|
+
};
|
|
229
|
+
},
|
|
230
|
+
addProseMirrorPlugins() {
|
|
231
|
+
var e;
|
|
232
|
+
const t = new m(this.name), n = ((e = this.editor.schema.topNodeType.contentMatch.defaultType) == null ? void 0 : e.name) || this.options.node || "paragraph", r = Object.entries(this.editor.schema.nodes).map(([, o]) => o).filter((o) => (this.options.notAfter || []).concat(n).includes(o.name));
|
|
233
|
+
return [
|
|
234
|
+
new p({
|
|
235
|
+
key: t,
|
|
236
|
+
appendTransaction: (o, s, i) => {
|
|
237
|
+
const { doc: d, tr: a, schema: c } = i, l = t.getState(i), h = d.content.size, C = c.nodes[n];
|
|
238
|
+
if (l)
|
|
239
|
+
return a.insert(h, C.create());
|
|
240
|
+
},
|
|
241
|
+
state: {
|
|
242
|
+
init: (o, s) => {
|
|
243
|
+
const i = s.tr.doc.lastChild;
|
|
244
|
+
return !y({ node: i, types: r });
|
|
245
|
+
},
|
|
246
|
+
apply: (o, s) => {
|
|
247
|
+
if (!o.docChanged || o.getMeta("__uniqueIDTransaction"))
|
|
248
|
+
return s;
|
|
249
|
+
const i = o.doc.lastChild;
|
|
250
|
+
return !y({ node: i, types: r });
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
})
|
|
254
|
+
];
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
u.create({
|
|
258
|
+
name: "undoRedo",
|
|
259
|
+
addOptions() {
|
|
260
|
+
return {
|
|
261
|
+
depth: 100,
|
|
262
|
+
newGroupDelay: 500
|
|
263
|
+
};
|
|
264
|
+
},
|
|
265
|
+
addCommands() {
|
|
266
|
+
return {
|
|
267
|
+
undo: () => ({ state: e, dispatch: t }) => O(e, t),
|
|
268
|
+
redo: () => ({ state: e, dispatch: t }) => N(e, t)
|
|
269
|
+
};
|
|
270
|
+
},
|
|
271
|
+
addProseMirrorPlugins() {
|
|
272
|
+
return [M(this.options)];
|
|
273
|
+
},
|
|
274
|
+
addKeyboardShortcuts() {
|
|
275
|
+
return {
|
|
276
|
+
"Mod-z": () => this.editor.commands.undo(),
|
|
277
|
+
"Shift-Mod-z": () => this.editor.commands.redo(),
|
|
278
|
+
"Mod-y": () => this.editor.commands.redo(),
|
|
279
|
+
// Russian keyboard layouts
|
|
280
|
+
"Mod-я": () => this.editor.commands.undo(),
|
|
281
|
+
"Shift-Mod-я": () => this.editor.commands.redo()
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
export {
|
|
286
|
+
k as Placeholder,
|
|
287
|
+
F as Selection
|
|
288
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
var S = function(r) {
|
|
2
|
+
if (typeof document > "u")
|
|
3
|
+
return null;
|
|
4
|
+
var u = Array.isArray(r) ? r[0] : r;
|
|
5
|
+
return u.ownerDocument.body;
|
|
6
|
+
}, f = /* @__PURE__ */ new WeakMap(), v = /* @__PURE__ */ new WeakMap(), p = {}, h = 0, W = function(r) {
|
|
7
|
+
return r && (r.host || W(r.parentNode));
|
|
8
|
+
}, D = function(r, u) {
|
|
9
|
+
return u.map(function(e) {
|
|
10
|
+
if (r.contains(e))
|
|
11
|
+
return e;
|
|
12
|
+
var n = W(e);
|
|
13
|
+
return n && r.contains(n) ? n : (console.error("aria-hidden", e, "in not contained inside", r, ". Doing nothing"), null);
|
|
14
|
+
}).filter(function(e) {
|
|
15
|
+
return !!e;
|
|
16
|
+
});
|
|
17
|
+
}, E = function(r, u, e, n) {
|
|
18
|
+
var i = D(u, Array.isArray(r) ? r : [r]);
|
|
19
|
+
p[e] || (p[e] = /* @__PURE__ */ new WeakMap());
|
|
20
|
+
var s = p[e], l = [], o = /* @__PURE__ */ new Set(), b = new Set(i), y = function(t) {
|
|
21
|
+
!t || o.has(t) || (o.add(t), y(t.parentNode));
|
|
22
|
+
};
|
|
23
|
+
i.forEach(y);
|
|
24
|
+
var A = function(t) {
|
|
25
|
+
!t || b.has(t) || Array.prototype.forEach.call(t.children, function(a) {
|
|
26
|
+
if (o.has(a))
|
|
27
|
+
A(a);
|
|
28
|
+
else
|
|
29
|
+
try {
|
|
30
|
+
var c = a.getAttribute(n), w = c !== null && c !== "false", d = (f.get(a) || 0) + 1, M = (s.get(a) || 0) + 1;
|
|
31
|
+
f.set(a, d), s.set(a, M), l.push(a), d === 1 && w && v.set(a, !0), M === 1 && a.setAttribute(e, "true"), w || a.setAttribute(n, "true");
|
|
32
|
+
} catch (k) {
|
|
33
|
+
console.error("aria-hidden: cannot operate on ", a, k);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
return A(u), o.clear(), h++, function() {
|
|
38
|
+
l.forEach(function(t) {
|
|
39
|
+
var a = f.get(t) - 1, c = s.get(t) - 1;
|
|
40
|
+
f.set(t, a), s.set(t, c), a || (v.has(t) || t.removeAttribute(n), v.delete(t)), c || t.removeAttribute(e);
|
|
41
|
+
}), h--, h || (f = /* @__PURE__ */ new WeakMap(), f = /* @__PURE__ */ new WeakMap(), v = /* @__PURE__ */ new WeakMap(), p = {});
|
|
42
|
+
};
|
|
43
|
+
}, C = function(r, u, e) {
|
|
44
|
+
e === void 0 && (e = "data-aria-hidden");
|
|
45
|
+
var n = Array.from(Array.isArray(r) ? r : [r]), i = S(r);
|
|
46
|
+
return i ? (n.push.apply(n, Array.from(i.querySelectorAll("[aria-live], script"))), E(n, i, e, "aria-hidden")) : function() {
|
|
47
|
+
return null;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
export {
|
|
51
|
+
C as hideOthers
|
|
52
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { commonjsGlobal as y } from "../../_virtual/_commonjsHelpers.js";
|
|
2
|
+
var p, _;
|
|
3
|
+
function Z() {
|
|
4
|
+
if (_) return p;
|
|
5
|
+
_ = 1;
|
|
6
|
+
var x = "Expected a function", I = NaN, W = "[object Symbol]", C = /^\s+|\s+$/g, M = /^[-+]0x[0-9a-f]+$/i, N = /^0b[01]+$/i, R = /^0o[0-7]+$/i, $ = parseInt, q = typeof y == "object" && y && y.Object === Object && y, A = typeof self == "object" && self && self.Object === Object && self, B = q || A || Function("return this")(), F = Object.prototype, G = F.toString, P = Math.max, D = Math.min, h = function() {
|
|
7
|
+
return B.Date.now();
|
|
8
|
+
};
|
|
9
|
+
function H(e, r, n) {
|
|
10
|
+
var f, a, g, c, i, u, s = 0, S = !1, d = !1, j = !0;
|
|
11
|
+
if (typeof e != "function")
|
|
12
|
+
throw new TypeError(x);
|
|
13
|
+
r = O(r) || 0, m(n) && (S = !!n.leading, d = "maxWait" in n, g = d ? P(O(n.maxWait) || 0, r) : g, j = "trailing" in n ? !!n.trailing : j);
|
|
14
|
+
function v(t) {
|
|
15
|
+
var o = f, l = a;
|
|
16
|
+
return f = a = void 0, s = t, c = e.apply(l, o), c;
|
|
17
|
+
}
|
|
18
|
+
function J(t) {
|
|
19
|
+
return s = t, i = setTimeout(b, r), S ? v(t) : c;
|
|
20
|
+
}
|
|
21
|
+
function K(t) {
|
|
22
|
+
var o = t - u, l = t - s, L = r - o;
|
|
23
|
+
return d ? D(L, g - l) : L;
|
|
24
|
+
}
|
|
25
|
+
function E(t) {
|
|
26
|
+
var o = t - u, l = t - s;
|
|
27
|
+
return u === void 0 || o >= r || o < 0 || d && l >= g;
|
|
28
|
+
}
|
|
29
|
+
function b() {
|
|
30
|
+
var t = h();
|
|
31
|
+
if (E(t))
|
|
32
|
+
return k(t);
|
|
33
|
+
i = setTimeout(b, K(t));
|
|
34
|
+
}
|
|
35
|
+
function k(t) {
|
|
36
|
+
return i = void 0, j && f ? v(t) : (f = a = void 0, c);
|
|
37
|
+
}
|
|
38
|
+
function Q() {
|
|
39
|
+
i !== void 0 && clearTimeout(i), s = 0, f = u = a = i = void 0;
|
|
40
|
+
}
|
|
41
|
+
function V() {
|
|
42
|
+
return i === void 0 ? c : k(h());
|
|
43
|
+
}
|
|
44
|
+
function T() {
|
|
45
|
+
var t = h(), o = E(t);
|
|
46
|
+
if (f = arguments, a = this, u = t, o) {
|
|
47
|
+
if (i === void 0)
|
|
48
|
+
return J(u);
|
|
49
|
+
if (d)
|
|
50
|
+
return i = setTimeout(b, r), v(u);
|
|
51
|
+
}
|
|
52
|
+
return i === void 0 && (i = setTimeout(b, r)), c;
|
|
53
|
+
}
|
|
54
|
+
return T.cancel = Q, T.flush = V, T;
|
|
55
|
+
}
|
|
56
|
+
function U(e, r, n) {
|
|
57
|
+
var f = !0, a = !0;
|
|
58
|
+
if (typeof e != "function")
|
|
59
|
+
throw new TypeError(x);
|
|
60
|
+
return m(n) && (f = "leading" in n ? !!n.leading : f, a = "trailing" in n ? !!n.trailing : a), H(e, r, {
|
|
61
|
+
leading: f,
|
|
62
|
+
maxWait: r,
|
|
63
|
+
trailing: a
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
function m(e) {
|
|
67
|
+
var r = typeof e;
|
|
68
|
+
return !!e && (r == "object" || r == "function");
|
|
69
|
+
}
|
|
70
|
+
function X(e) {
|
|
71
|
+
return !!e && typeof e == "object";
|
|
72
|
+
}
|
|
73
|
+
function z(e) {
|
|
74
|
+
return typeof e == "symbol" || X(e) && G.call(e) == W;
|
|
75
|
+
}
|
|
76
|
+
function O(e) {
|
|
77
|
+
if (typeof e == "number")
|
|
78
|
+
return e;
|
|
79
|
+
if (z(e))
|
|
80
|
+
return I;
|
|
81
|
+
if (m(e)) {
|
|
82
|
+
var r = typeof e.valueOf == "function" ? e.valueOf() : e;
|
|
83
|
+
e = m(r) ? r + "" : r;
|
|
84
|
+
}
|
|
85
|
+
if (typeof e != "string")
|
|
86
|
+
return e === 0 ? e : +e;
|
|
87
|
+
e = e.replace(C, "");
|
|
88
|
+
var n = N.test(e);
|
|
89
|
+
return n || R.test(e) ? $(e.slice(2), n ? 2 : 8) : M.test(e) ? I : +e;
|
|
90
|
+
}
|
|
91
|
+
return p = U, p;
|
|
92
|
+
}
|
|
93
|
+
export {
|
|
94
|
+
Z as __require
|
|
95
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useRef as b, useCallback as W, useContext as
|
|
1
|
+
import { useRef as b, useCallback as W, useContext as R, useLayoutEffect as F, useEffect as G, createContext as H } from "react";
|
|
2
2
|
import "react/jsx-runtime";
|
|
3
|
-
const
|
|
3
|
+
const j = ["shift", "alt", "meta", "mod", "ctrl", "control"], Q = {
|
|
4
4
|
esc: "escape",
|
|
5
5
|
return: "enter",
|
|
6
6
|
left: "arrowleft",
|
|
@@ -18,18 +18,18 @@ const N = ["shift", "alt", "meta", "mod", "ctrl", "control"], Q = {
|
|
|
18
18
|
ControlLeft: "ctrl",
|
|
19
19
|
ControlRight: "ctrl"
|
|
20
20
|
};
|
|
21
|
-
function
|
|
21
|
+
function k(e) {
|
|
22
22
|
return (Q[e.trim()] || e.trim()).toLowerCase().replace(/key|digit|numpad/, "");
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
return
|
|
24
|
+
function N(e) {
|
|
25
|
+
return j.includes(e);
|
|
26
26
|
}
|
|
27
27
|
function C(e, t = ",") {
|
|
28
28
|
return e.toLowerCase().split(t);
|
|
29
29
|
}
|
|
30
|
-
function S(e, t = "+", n = ">", a = !1,
|
|
31
|
-
let i = [],
|
|
32
|
-
e = e.trim(), e.includes(n) ? (
|
|
30
|
+
function S(e, t = "+", n = ">", a = !1, s) {
|
|
31
|
+
let i = [], c = !1;
|
|
32
|
+
e = e.trim(), e.includes(n) ? (c = !0, i = e.toLocaleLowerCase().split(n).map((d) => k(d))) : i = e.toLocaleLowerCase().split(t).map((d) => k(d));
|
|
33
33
|
const w = {
|
|
34
34
|
alt: i.includes("alt"),
|
|
35
35
|
ctrl: i.includes("ctrl") || i.includes("control"),
|
|
@@ -37,19 +37,19 @@ function S(e, t = "+", n = ">", a = !1, c) {
|
|
|
37
37
|
meta: i.includes("meta"),
|
|
38
38
|
mod: i.includes("mod"),
|
|
39
39
|
useKey: a
|
|
40
|
-
}, u = i.filter((d) => !
|
|
40
|
+
}, u = i.filter((d) => !j.includes(d));
|
|
41
41
|
return {
|
|
42
42
|
...w,
|
|
43
43
|
keys: u,
|
|
44
|
-
description:
|
|
45
|
-
isSequence:
|
|
44
|
+
description: s,
|
|
45
|
+
isSequence: c,
|
|
46
46
|
hotkey: e
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
49
|
typeof document < "u" && (document.addEventListener("keydown", (e) => {
|
|
50
|
-
e.code !== void 0 &&
|
|
50
|
+
e.code !== void 0 && T([k(e.code)]);
|
|
51
51
|
}), document.addEventListener("keyup", (e) => {
|
|
52
|
-
e.code !== void 0 &&
|
|
52
|
+
e.code !== void 0 && D([k(e.code)]);
|
|
53
53
|
})), typeof window < "u" && (window.addEventListener("blur", () => {
|
|
54
54
|
h.clear();
|
|
55
55
|
}), window.addEventListener("contextmenu", () => {
|
|
@@ -64,11 +64,11 @@ function A(e) {
|
|
|
64
64
|
function U(e, t = ",") {
|
|
65
65
|
return (A(e) ? e : e.split(t)).every((n) => h.has(n.trim().toLowerCase()));
|
|
66
66
|
}
|
|
67
|
-
function
|
|
67
|
+
function T(e) {
|
|
68
68
|
const t = Array.isArray(e) ? e : [e];
|
|
69
|
-
h.has("meta") && h.forEach((n) => !
|
|
69
|
+
h.has("meta") && h.forEach((n) => !N(n) && h.delete(n.toLowerCase())), t.forEach((n) => h.add(n.toLowerCase()));
|
|
70
70
|
}
|
|
71
|
-
function
|
|
71
|
+
function D(e) {
|
|
72
72
|
const t = Array.isArray(e) ? e : [e];
|
|
73
73
|
e === "meta" ? h.clear() : t.forEach((n) => h.delete(n.toLowerCase()));
|
|
74
74
|
}
|
|
@@ -97,8 +97,8 @@ function Z(e) {
|
|
|
97
97
|
}
|
|
98
98
|
function M(e, t = !1) {
|
|
99
99
|
const { target: n, composed: a } = e;
|
|
100
|
-
let
|
|
101
|
-
return _(n) && a ? (
|
|
100
|
+
let s, i;
|
|
101
|
+
return _(n) && a ? (s = e.composedPath()[0] && e.composedPath()[0].tagName, i = e.composedPath()[0] && e.composedPath()[0].role) : (s = n && n.tagName, i = n && n.role), A(t) ? !!(s && t && t.some((c) => c.toLowerCase() === s.toLowerCase() || c === i)) : !!(s && t && t);
|
|
102
102
|
}
|
|
103
103
|
function _(e) {
|
|
104
104
|
return !!e.tagName && !e.tagName.startsWith("-") && e.tagName.includes("-");
|
|
@@ -109,27 +109,27 @@ function z(e, t) {
|
|
|
109
109
|
), !0) : t ? e.some((n) => t.includes(n)) || e.includes("*") : !0;
|
|
110
110
|
}
|
|
111
111
|
const J = (e, t, n = !1) => {
|
|
112
|
-
const { alt: a, meta:
|
|
112
|
+
const { alt: a, meta: s, mod: i, shift: c, ctrl: w, keys: u, useKey: d } = t, { code: g, key: o, ctrlKey: L, metaKey: v, shiftKey: y, altKey: p } = e, l = k(g);
|
|
113
113
|
if (d && u?.length === 1 && u.includes(o))
|
|
114
114
|
return !0;
|
|
115
115
|
if (!u?.includes(l) && !["ctrl", "control", "unknown", "meta", "alt", "shift", "os"].includes(l))
|
|
116
116
|
return !1;
|
|
117
117
|
if (!n) {
|
|
118
|
-
if (a !==
|
|
118
|
+
if (a !== p && l !== "alt" || c !== y && l !== "shift")
|
|
119
119
|
return !1;
|
|
120
120
|
if (i) {
|
|
121
|
-
if (!
|
|
121
|
+
if (!v && !L)
|
|
122
122
|
return !1;
|
|
123
|
-
} else if (
|
|
123
|
+
} else if (s !== v && l !== "meta" && l !== "os" || w !== L && l !== "ctrl" && l !== "control")
|
|
124
124
|
return !1;
|
|
125
125
|
}
|
|
126
126
|
return u && u.length === 1 && u.includes(l) ? !0 : u ? U(u) : !u;
|
|
127
|
-
}, B =
|
|
127
|
+
}, B = H(void 0), ee = () => R(B);
|
|
128
128
|
function $(e, t) {
|
|
129
129
|
return e && t && typeof e == "object" && typeof t == "object" ? Object.keys(e).length === Object.keys(t).length && // @ts-expect-error TS7053
|
|
130
130
|
Object.keys(e).reduce((n, a) => n && $(e[a], t[a]), !0) : e === t;
|
|
131
131
|
}
|
|
132
|
-
const te =
|
|
132
|
+
const te = H({
|
|
133
133
|
hotkeys: [],
|
|
134
134
|
activeScopes: [],
|
|
135
135
|
// This array has to be empty instead of containing '*' as default, to check if the provider is set or not
|
|
@@ -139,28 +139,28 @@ const te = j({
|
|
|
139
139
|
},
|
|
140
140
|
disableScope: () => {
|
|
141
141
|
}
|
|
142
|
-
}), ne = () =>
|
|
142
|
+
}), ne = () => R(te);
|
|
143
143
|
function oe(e) {
|
|
144
144
|
const t = b(void 0);
|
|
145
145
|
return $(t.current, e) || (t.current = e), t.current;
|
|
146
146
|
}
|
|
147
|
-
const
|
|
147
|
+
const P = (e) => {
|
|
148
148
|
e.stopPropagation(), e.preventDefault(), e.stopImmediatePropagation();
|
|
149
149
|
}, re = typeof window < "u" ? F : G;
|
|
150
|
-
function
|
|
151
|
-
const
|
|
152
|
-
u ?
|
|
153
|
-
const o = oe(
|
|
150
|
+
function ce(e, t, n, a) {
|
|
151
|
+
const s = b(null), i = b(!1), c = Array.isArray(n) ? Array.isArray(a) ? void 0 : a : n, w = A(e) ? e.join(c?.delimiter) : e, u = Array.isArray(n) ? n : Array.isArray(a) ? a : void 0, d = W(t, u ?? []), g = b(d);
|
|
152
|
+
u ? g.current = d : g.current = t;
|
|
153
|
+
const o = oe(c), { activeScopes: L } = ne(), v = ee();
|
|
154
154
|
return re(() => {
|
|
155
155
|
if (o?.enabled === !1 || !z(L, o?.scopes))
|
|
156
156
|
return;
|
|
157
|
-
let
|
|
157
|
+
let y = [], p;
|
|
158
158
|
const l = (r, q = !1) => {
|
|
159
159
|
if (!(Z(r) && !M(r, o?.enableOnFormTags))) {
|
|
160
|
-
if (
|
|
161
|
-
const m =
|
|
162
|
-
if ((m instanceof Document || m instanceof ShadowRoot) && m.activeElement !==
|
|
163
|
-
|
|
160
|
+
if (s.current !== null) {
|
|
161
|
+
const m = s.current.getRootNode();
|
|
162
|
+
if ((m instanceof Document || m instanceof ShadowRoot) && m.activeElement !== s.current && !s.current.contains(m.activeElement)) {
|
|
163
|
+
P(r);
|
|
164
164
|
return;
|
|
165
165
|
}
|
|
166
166
|
}
|
|
@@ -179,37 +179,37 @@ function se(e, t, n, a) {
|
|
|
179
179
|
o?.description
|
|
180
180
|
);
|
|
181
181
|
if (f.isSequence) {
|
|
182
|
-
|
|
183
|
-
|
|
182
|
+
p = setTimeout(() => {
|
|
183
|
+
y = [];
|
|
184
184
|
}, o?.sequenceTimeoutMs ?? 1e3);
|
|
185
|
-
const K = f.useKey ? r.key :
|
|
186
|
-
if (
|
|
185
|
+
const K = f.useKey ? r.key : k(r.code);
|
|
186
|
+
if (N(K.toLowerCase()))
|
|
187
187
|
return;
|
|
188
|
-
|
|
189
|
-
const I = f.keys?.[
|
|
188
|
+
y.push(K);
|
|
189
|
+
const I = f.keys?.[y.length - 1];
|
|
190
190
|
if (K !== I) {
|
|
191
|
-
|
|
191
|
+
y = [], p && clearTimeout(p);
|
|
192
192
|
return;
|
|
193
193
|
}
|
|
194
|
-
|
|
194
|
+
y.length === f.keys?.length && (g.current(r, f), p && clearTimeout(p), y = []);
|
|
195
195
|
} else if (J(r, f, o?.ignoreModifiers) || f.keys?.includes("*")) {
|
|
196
196
|
if (o?.ignoreEventWhen?.(r) || q && i.current)
|
|
197
197
|
return;
|
|
198
198
|
if (V(r, f, o?.preventDefault), !X(r, f, o?.enabled)) {
|
|
199
|
-
|
|
199
|
+
P(r);
|
|
200
200
|
return;
|
|
201
201
|
}
|
|
202
|
-
|
|
202
|
+
g.current(r, f), q || (i.current = !0);
|
|
203
203
|
}
|
|
204
204
|
});
|
|
205
205
|
}
|
|
206
206
|
}, O = (r) => {
|
|
207
|
-
r.code !== void 0 && (
|
|
207
|
+
r.code !== void 0 && (T(k(r.code)), (o?.keydown === void 0 && o?.keyup !== !0 || o?.keydown) && l(r));
|
|
208
208
|
}, x = (r) => {
|
|
209
|
-
r.code !== void 0 && (
|
|
210
|
-
}, E =
|
|
211
|
-
return E.addEventListener("keyup", x,
|
|
212
|
-
(r) =>
|
|
209
|
+
r.code !== void 0 && (D(k(r.code)), i.current = !1, o?.keyup && l(r, !0));
|
|
210
|
+
}, E = s.current || c?.document || document;
|
|
211
|
+
return E.addEventListener("keyup", x, c?.eventListenerOptions), E.addEventListener("keydown", O, c?.eventListenerOptions), v && C(w, o?.delimiter).forEach(
|
|
212
|
+
(r) => v.addHotkey(
|
|
213
213
|
S(
|
|
214
214
|
r,
|
|
215
215
|
o?.splitKey,
|
|
@@ -219,8 +219,8 @@ function se(e, t, n, a) {
|
|
|
219
219
|
)
|
|
220
220
|
)
|
|
221
221
|
), () => {
|
|
222
|
-
E.removeEventListener("keyup", x,
|
|
223
|
-
(r) =>
|
|
222
|
+
E.removeEventListener("keyup", x, c?.eventListenerOptions), E.removeEventListener("keydown", O, c?.eventListenerOptions), v && C(w, o?.delimiter).forEach(
|
|
223
|
+
(r) => v.removeHotkey(
|
|
224
224
|
S(
|
|
225
225
|
r,
|
|
226
226
|
o?.splitKey,
|
|
@@ -229,10 +229,12 @@ function se(e, t, n, a) {
|
|
|
229
229
|
o?.description
|
|
230
230
|
)
|
|
231
231
|
)
|
|
232
|
-
),
|
|
232
|
+
), y = [], p && clearTimeout(p);
|
|
233
233
|
};
|
|
234
|
-
}, [w, o, L]),
|
|
234
|
+
}, [w, o, L]), s;
|
|
235
235
|
}
|
|
236
236
|
export {
|
|
237
|
-
|
|
237
|
+
U as isHotkeyPressed,
|
|
238
|
+
ce as useHotkeys,
|
|
239
|
+
ne as useHotkeysContext
|
|
238
240
|
};
|