@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,183 @@
|
|
|
1
|
+
import * as c from "react";
|
|
2
|
+
import { composeEventHandlers as p } from "../../primitive/dist/index.js";
|
|
3
|
+
import { createCollection as V } from "../../react-collection/dist/index.js";
|
|
4
|
+
import { useComposedRefs as j } from "../../react-compose-refs/dist/index.js";
|
|
5
|
+
import { createContextScope as z } from "../../react-context/dist/index.js";
|
|
6
|
+
import { useId as q } from "../../react-id/dist/index.js";
|
|
7
|
+
import { Primitive as G } from "../../react-primitive/dist/index.js";
|
|
8
|
+
import { useCallbackRef as J } from "../../react-use-callback-ref/dist/index.js";
|
|
9
|
+
import { useControllableState as Q } from "../../react-use-controllable-state/dist/index.js";
|
|
10
|
+
import { useDirection as W } from "../../react-direction/dist/index.js";
|
|
11
|
+
import { jsx as d } from "react/jsx-runtime";
|
|
12
|
+
var y = "rovingFocusGroup.onEntryFocus", X = { bubbles: !1, cancelable: !0 }, I = "RovingFocusGroup", [D, N, Z] = V(I), [$, Fe] = z(
|
|
13
|
+
I,
|
|
14
|
+
[Z]
|
|
15
|
+
), [ee, oe] = $(I), O = c.forwardRef(
|
|
16
|
+
(e, r) => /* @__PURE__ */ d(D.Provider, { scope: e.__scopeRovingFocusGroup, children: /* @__PURE__ */ d(D.Slot, { scope: e.__scopeRovingFocusGroup, children: /* @__PURE__ */ d(te, { ...e, ref: r }) }) })
|
|
17
|
+
);
|
|
18
|
+
O.displayName = I;
|
|
19
|
+
var te = c.forwardRef((e, r) => {
|
|
20
|
+
const {
|
|
21
|
+
__scopeRovingFocusGroup: s,
|
|
22
|
+
orientation: o,
|
|
23
|
+
loop: T = !1,
|
|
24
|
+
dir: w,
|
|
25
|
+
currentTabStopId: v,
|
|
26
|
+
defaultCurrentTabStopId: C,
|
|
27
|
+
onCurrentTabStopIdChange: S,
|
|
28
|
+
onEntryFocus: m,
|
|
29
|
+
preventScrollOnEntryFocus: u = !1,
|
|
30
|
+
...b
|
|
31
|
+
} = e, F = c.useRef(null), g = j(r, F), R = W(w), [E, t] = Q({
|
|
32
|
+
prop: v,
|
|
33
|
+
defaultProp: C ?? null,
|
|
34
|
+
onChange: S,
|
|
35
|
+
caller: I
|
|
36
|
+
}), [i, h] = c.useState(!1), a = J(m), l = N(s), A = c.useRef(!1), [L, P] = c.useState(0);
|
|
37
|
+
return c.useEffect(() => {
|
|
38
|
+
const n = F.current;
|
|
39
|
+
if (n)
|
|
40
|
+
return n.addEventListener(y, a), () => n.removeEventListener(y, a);
|
|
41
|
+
}, [a]), /* @__PURE__ */ d(
|
|
42
|
+
ee,
|
|
43
|
+
{
|
|
44
|
+
scope: s,
|
|
45
|
+
orientation: o,
|
|
46
|
+
dir: R,
|
|
47
|
+
loop: T,
|
|
48
|
+
currentTabStopId: E,
|
|
49
|
+
onItemFocus: c.useCallback(
|
|
50
|
+
(n) => t(n),
|
|
51
|
+
[t]
|
|
52
|
+
),
|
|
53
|
+
onItemShiftTab: c.useCallback(() => h(!0), []),
|
|
54
|
+
onFocusableItemAdd: c.useCallback(
|
|
55
|
+
() => P((n) => n + 1),
|
|
56
|
+
[]
|
|
57
|
+
),
|
|
58
|
+
onFocusableItemRemove: c.useCallback(
|
|
59
|
+
() => P((n) => n - 1),
|
|
60
|
+
[]
|
|
61
|
+
),
|
|
62
|
+
children: /* @__PURE__ */ d(
|
|
63
|
+
G.div,
|
|
64
|
+
{
|
|
65
|
+
tabIndex: i || L === 0 ? -1 : 0,
|
|
66
|
+
"data-orientation": o,
|
|
67
|
+
...b,
|
|
68
|
+
ref: g,
|
|
69
|
+
style: { outline: "none", ...e.style },
|
|
70
|
+
onMouseDown: p(e.onMouseDown, () => {
|
|
71
|
+
A.current = !0;
|
|
72
|
+
}),
|
|
73
|
+
onFocus: p(e.onFocus, (n) => {
|
|
74
|
+
const U = !A.current;
|
|
75
|
+
if (n.target === n.currentTarget && U && !i) {
|
|
76
|
+
const x = new CustomEvent(y, X);
|
|
77
|
+
if (n.currentTarget.dispatchEvent(x), !x.defaultPrevented) {
|
|
78
|
+
const _ = l().filter((f) => f.focusable), B = _.find((f) => f.active), Y = _.find((f) => f.id === E), H = [B, Y, ..._].filter(
|
|
79
|
+
Boolean
|
|
80
|
+
).map((f) => f.ref.current);
|
|
81
|
+
k(H, u);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
A.current = !1;
|
|
85
|
+
}),
|
|
86
|
+
onBlur: p(e.onBlur, () => h(!1))
|
|
87
|
+
}
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
}), K = "RovingFocusGroupItem", M = c.forwardRef(
|
|
92
|
+
(e, r) => {
|
|
93
|
+
const {
|
|
94
|
+
__scopeRovingFocusGroup: s,
|
|
95
|
+
focusable: o = !0,
|
|
96
|
+
active: T = !1,
|
|
97
|
+
tabStopId: w,
|
|
98
|
+
children: v,
|
|
99
|
+
...C
|
|
100
|
+
} = e, S = q(), m = w || S, u = oe(K, s), b = u.currentTabStopId === m, F = N(s), { onFocusableItemAdd: g, onFocusableItemRemove: R, currentTabStopId: E } = u;
|
|
101
|
+
return c.useEffect(() => {
|
|
102
|
+
if (o)
|
|
103
|
+
return g(), () => R();
|
|
104
|
+
}, [o, g, R]), /* @__PURE__ */ d(
|
|
105
|
+
D.ItemSlot,
|
|
106
|
+
{
|
|
107
|
+
scope: s,
|
|
108
|
+
id: m,
|
|
109
|
+
focusable: o,
|
|
110
|
+
active: T,
|
|
111
|
+
children: /* @__PURE__ */ d(
|
|
112
|
+
G.span,
|
|
113
|
+
{
|
|
114
|
+
tabIndex: b ? 0 : -1,
|
|
115
|
+
"data-orientation": u.orientation,
|
|
116
|
+
...C,
|
|
117
|
+
ref: r,
|
|
118
|
+
onMouseDown: p(e.onMouseDown, (t) => {
|
|
119
|
+
o ? u.onItemFocus(m) : t.preventDefault();
|
|
120
|
+
}),
|
|
121
|
+
onFocus: p(e.onFocus, () => u.onItemFocus(m)),
|
|
122
|
+
onKeyDown: p(e.onKeyDown, (t) => {
|
|
123
|
+
if (t.key === "Tab" && t.shiftKey) {
|
|
124
|
+
u.onItemShiftTab();
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (t.target !== t.currentTarget) return;
|
|
128
|
+
const i = ce(t, u.orientation, u.dir);
|
|
129
|
+
if (i !== void 0) {
|
|
130
|
+
if (t.metaKey || t.ctrlKey || t.altKey || t.shiftKey) return;
|
|
131
|
+
t.preventDefault();
|
|
132
|
+
let a = F().filter((l) => l.focusable).map((l) => l.ref.current);
|
|
133
|
+
if (i === "last") a.reverse();
|
|
134
|
+
else if (i === "prev" || i === "next") {
|
|
135
|
+
i === "prev" && a.reverse();
|
|
136
|
+
const l = a.indexOf(t.currentTarget);
|
|
137
|
+
a = u.loop ? se(a, l + 1) : a.slice(l + 1);
|
|
138
|
+
}
|
|
139
|
+
setTimeout(() => k(a));
|
|
140
|
+
}
|
|
141
|
+
}),
|
|
142
|
+
children: typeof v == "function" ? v({ isCurrentTabStop: b, hasTabStop: E != null }) : v
|
|
143
|
+
}
|
|
144
|
+
)
|
|
145
|
+
}
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
);
|
|
149
|
+
M.displayName = K;
|
|
150
|
+
var re = {
|
|
151
|
+
ArrowLeft: "prev",
|
|
152
|
+
ArrowUp: "prev",
|
|
153
|
+
ArrowRight: "next",
|
|
154
|
+
ArrowDown: "next",
|
|
155
|
+
PageUp: "first",
|
|
156
|
+
Home: "first",
|
|
157
|
+
PageDown: "last",
|
|
158
|
+
End: "last"
|
|
159
|
+
};
|
|
160
|
+
function ne(e, r) {
|
|
161
|
+
return r !== "rtl" ? e : e === "ArrowLeft" ? "ArrowRight" : e === "ArrowRight" ? "ArrowLeft" : e;
|
|
162
|
+
}
|
|
163
|
+
function ce(e, r, s) {
|
|
164
|
+
const o = ne(e.key, s);
|
|
165
|
+
if (!(r === "vertical" && ["ArrowLeft", "ArrowRight"].includes(o)) && !(r === "horizontal" && ["ArrowUp", "ArrowDown"].includes(o)))
|
|
166
|
+
return re[o];
|
|
167
|
+
}
|
|
168
|
+
function k(e, r = !1) {
|
|
169
|
+
const s = document.activeElement;
|
|
170
|
+
for (const o of e)
|
|
171
|
+
if (o === s || (o.focus({ preventScroll: r }), document.activeElement !== s)) return;
|
|
172
|
+
}
|
|
173
|
+
function se(e, r) {
|
|
174
|
+
return e.map((s, o) => e[(r + o) % e.length]);
|
|
175
|
+
}
|
|
176
|
+
var ge = O, Re = M;
|
|
177
|
+
export {
|
|
178
|
+
Re as Item,
|
|
179
|
+
ge as Root,
|
|
180
|
+
O as RovingFocusGroup,
|
|
181
|
+
M as RovingFocusGroupItem,
|
|
182
|
+
Fe as createRovingFocusGroupScope
|
|
183
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as l from "react";
|
|
2
|
+
import { composeRefs as m } from "../../react-compose-refs/dist/index.js";
|
|
3
|
+
import { jsx as u } from "react/jsx-runtime";
|
|
4
|
+
// @__NO_SIDE_EFFECTS__
|
|
5
|
+
function b(e) {
|
|
6
|
+
const r = /* @__PURE__ */ y(e), t = l.forwardRef((o, n) => {
|
|
7
|
+
const { children: i, ...c } = o, s = l.Children.toArray(i), a = s.find(E);
|
|
8
|
+
if (a) {
|
|
9
|
+
const f = a.props.children, d = s.map((p) => p === a ? l.Children.count(f) > 1 ? l.Children.only(null) : l.isValidElement(f) ? f.props.children : null : p);
|
|
10
|
+
return /* @__PURE__ */ u(r, { ...c, ref: n, children: l.isValidElement(f) ? l.cloneElement(f, void 0, d) : null });
|
|
11
|
+
}
|
|
12
|
+
return /* @__PURE__ */ u(r, { ...c, ref: n, children: i });
|
|
13
|
+
});
|
|
14
|
+
return t.displayName = `${e}.Slot`, t;
|
|
15
|
+
}
|
|
16
|
+
// @__NO_SIDE_EFFECTS__
|
|
17
|
+
function y(e) {
|
|
18
|
+
const r = l.forwardRef((t, o) => {
|
|
19
|
+
const { children: n, ...i } = t;
|
|
20
|
+
if (l.isValidElement(n)) {
|
|
21
|
+
const c = S(n), s = C(i, n.props);
|
|
22
|
+
return n.type !== l.Fragment && (s.ref = o ? m(o, c) : c), l.cloneElement(n, s);
|
|
23
|
+
}
|
|
24
|
+
return l.Children.count(n) > 1 ? l.Children.only(null) : null;
|
|
25
|
+
});
|
|
26
|
+
return r.displayName = `${e}.SlotClone`, r;
|
|
27
|
+
}
|
|
28
|
+
var g = Symbol("radix.slottable");
|
|
29
|
+
function E(e) {
|
|
30
|
+
return l.isValidElement(e) && typeof e.type == "function" && "__radixId" in e.type && e.type.__radixId === g;
|
|
31
|
+
}
|
|
32
|
+
function C(e, r) {
|
|
33
|
+
const t = { ...r };
|
|
34
|
+
for (const o in r) {
|
|
35
|
+
const n = e[o], i = r[o];
|
|
36
|
+
/^on[A-Z]/.test(o) ? n && i ? t[o] = (...s) => {
|
|
37
|
+
const a = i(...s);
|
|
38
|
+
return n(...s), a;
|
|
39
|
+
} : n && (t[o] = n) : o === "style" ? t[o] = { ...n, ...i } : o === "className" && (t[o] = [n, i].filter(Boolean).join(" "));
|
|
40
|
+
}
|
|
41
|
+
return { ...e, ...t };
|
|
42
|
+
}
|
|
43
|
+
function S(e) {
|
|
44
|
+
let r = Object.getOwnPropertyDescriptor(e.props, "ref")?.get, t = r && "isReactWarning" in r && r.isReactWarning;
|
|
45
|
+
return t ? e.ref : (r = Object.getOwnPropertyDescriptor(e, "ref")?.get, t = r && "isReactWarning" in r && r.isReactWarning, t ? e.props.ref : e.props.ref || e.ref);
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
b as createSlot
|
|
49
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as o from "react";
|
|
2
|
+
import { useLayoutEffect as m } from "../../react-use-layout-effect/dist/index.js";
|
|
3
|
+
var v = o[" useInsertionEffect ".trim().toString()] || m;
|
|
4
|
+
function w({
|
|
5
|
+
prop: e,
|
|
6
|
+
defaultProp: s,
|
|
7
|
+
onChange: t = () => {
|
|
8
|
+
},
|
|
9
|
+
caller: f
|
|
10
|
+
}) {
|
|
11
|
+
const [u, c, i] = R({
|
|
12
|
+
defaultProp: s,
|
|
13
|
+
onChange: t
|
|
14
|
+
}), n = e !== void 0, a = n ? e : u;
|
|
15
|
+
{
|
|
16
|
+
const r = o.useRef(e !== void 0);
|
|
17
|
+
o.useEffect(() => {
|
|
18
|
+
const l = r.current;
|
|
19
|
+
l !== n && console.warn(
|
|
20
|
+
`${f} is changing from ${l ? "controlled" : "uncontrolled"} to ${n ? "controlled" : "uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`
|
|
21
|
+
), r.current = n;
|
|
22
|
+
}, [n, f]);
|
|
23
|
+
}
|
|
24
|
+
const d = o.useCallback(
|
|
25
|
+
(r) => {
|
|
26
|
+
if (n) {
|
|
27
|
+
const l = C(r) ? r(e) : r;
|
|
28
|
+
l !== e && i.current?.(l);
|
|
29
|
+
} else
|
|
30
|
+
c(r);
|
|
31
|
+
},
|
|
32
|
+
[n, e, c, i]
|
|
33
|
+
);
|
|
34
|
+
return [a, d];
|
|
35
|
+
}
|
|
36
|
+
function R({
|
|
37
|
+
defaultProp: e,
|
|
38
|
+
onChange: s
|
|
39
|
+
}) {
|
|
40
|
+
const [t, f] = o.useState(e), u = o.useRef(t), c = o.useRef(s);
|
|
41
|
+
return v(() => {
|
|
42
|
+
c.current = s;
|
|
43
|
+
}, [s]), o.useEffect(() => {
|
|
44
|
+
u.current !== t && (c.current?.(t), u.current = t);
|
|
45
|
+
}, [t, u]), [t, f, c];
|
|
46
|
+
}
|
|
47
|
+
function C(e) {
|
|
48
|
+
return typeof e == "function";
|
|
49
|
+
}
|
|
50
|
+
export {
|
|
51
|
+
w as useControllableState
|
|
52
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as r from "react";
|
|
2
|
+
import { useCallbackRef as s } from "../../react-use-callback-ref/dist/index.js";
|
|
3
|
+
function p(n, e = globalThis?.document) {
|
|
4
|
+
const t = s(n);
|
|
5
|
+
r.useEffect(() => {
|
|
6
|
+
const o = (a) => {
|
|
7
|
+
a.key === "Escape" && t(a);
|
|
8
|
+
};
|
|
9
|
+
return e.addEventListener("keydown", o, { capture: !0 }), () => e.removeEventListener("keydown", o, { capture: !0 });
|
|
10
|
+
}, [t, e]);
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
p as useEscapeKeydown
|
|
14
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as h from "react";
|
|
2
|
+
import { useLayoutEffect as z } from "../../react-use-layout-effect/dist/index.js";
|
|
3
|
+
function c(r) {
|
|
4
|
+
const [d, e] = h.useState(void 0);
|
|
5
|
+
return z(() => {
|
|
6
|
+
if (r) {
|
|
7
|
+
e({ width: r.offsetWidth, height: r.offsetHeight });
|
|
8
|
+
const f = new ResizeObserver((i) => {
|
|
9
|
+
if (!Array.isArray(i) || !i.length)
|
|
10
|
+
return;
|
|
11
|
+
const b = i[0];
|
|
12
|
+
let o, t;
|
|
13
|
+
if ("borderBoxSize" in b) {
|
|
14
|
+
const s = b.borderBoxSize, u = Array.isArray(s) ? s[0] : s;
|
|
15
|
+
o = u.inlineSize, t = u.blockSize;
|
|
16
|
+
} else
|
|
17
|
+
o = r.offsetWidth, t = r.offsetHeight;
|
|
18
|
+
e({ width: o, height: t });
|
|
19
|
+
});
|
|
20
|
+
return f.observe(r, { box: "border-box" }), () => f.unobserve(r);
|
|
21
|
+
} else
|
|
22
|
+
e(void 0);
|
|
23
|
+
}, [r]), d;
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
c as useSize
|
|
27
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Mark as a, markPasteRule as s, markInputRule as l, mergeAttributes as u } from "@tiptap/core";
|
|
2
|
+
var h = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/, d = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g, m = a.create({
|
|
3
|
+
name: "highlight",
|
|
4
|
+
addOptions() {
|
|
5
|
+
return {
|
|
6
|
+
multicolor: !1,
|
|
7
|
+
HTMLAttributes: {}
|
|
8
|
+
};
|
|
9
|
+
},
|
|
10
|
+
addAttributes() {
|
|
11
|
+
return this.options.multicolor ? {
|
|
12
|
+
color: {
|
|
13
|
+
default: null,
|
|
14
|
+
parseHTML: (r) => r.getAttribute("data-color") || r.style.backgroundColor,
|
|
15
|
+
renderHTML: (r) => r.color ? {
|
|
16
|
+
"data-color": r.color,
|
|
17
|
+
style: `background-color: ${r.color}; color: inherit`
|
|
18
|
+
} : {}
|
|
19
|
+
}
|
|
20
|
+
} : {};
|
|
21
|
+
},
|
|
22
|
+
parseHTML() {
|
|
23
|
+
return [
|
|
24
|
+
{
|
|
25
|
+
tag: "mark"
|
|
26
|
+
}
|
|
27
|
+
];
|
|
28
|
+
},
|
|
29
|
+
renderHTML({ HTMLAttributes: r }) {
|
|
30
|
+
return ["mark", u(this.options.HTMLAttributes, r), 0];
|
|
31
|
+
},
|
|
32
|
+
renderMarkdown: (r, t) => `==${t.renderChildren(r)}==`,
|
|
33
|
+
parseMarkdown: (r, t) => t.applyMark("highlight", t.parseInline(r.tokens || [])),
|
|
34
|
+
markdownTokenizer: {
|
|
35
|
+
name: "highlight",
|
|
36
|
+
level: "inline",
|
|
37
|
+
start: (r) => r.indexOf("=="),
|
|
38
|
+
tokenize(r, t, i) {
|
|
39
|
+
const e = /^(==)([^=]+)(==)/.exec(r);
|
|
40
|
+
if (e) {
|
|
41
|
+
const n = e[2].trim(), o = i.inlineTokens(n);
|
|
42
|
+
return {
|
|
43
|
+
type: "highlight",
|
|
44
|
+
raw: e[0],
|
|
45
|
+
text: n,
|
|
46
|
+
tokens: o
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
addCommands() {
|
|
52
|
+
return {
|
|
53
|
+
setHighlight: (r) => ({ commands: t }) => t.setMark(this.name, r),
|
|
54
|
+
toggleHighlight: (r) => ({ commands: t }) => t.toggleMark(this.name, r),
|
|
55
|
+
unsetHighlight: () => ({ commands: r }) => r.unsetMark(this.name)
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
addKeyboardShortcuts() {
|
|
59
|
+
return {
|
|
60
|
+
"Mod-Shift-h": () => this.editor.commands.toggleHighlight()
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
addInputRules() {
|
|
64
|
+
return [
|
|
65
|
+
l({
|
|
66
|
+
find: h,
|
|
67
|
+
type: this.type
|
|
68
|
+
})
|
|
69
|
+
];
|
|
70
|
+
},
|
|
71
|
+
addPasteRules() {
|
|
72
|
+
return [
|
|
73
|
+
s({
|
|
74
|
+
find: d,
|
|
75
|
+
type: this.type
|
|
76
|
+
})
|
|
77
|
+
];
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
export {
|
|
81
|
+
m as Highlight,
|
|
82
|
+
h as inputRegex,
|
|
83
|
+
d as pasteRegex
|
|
84
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Node as f, nodeInputRule as m, canInsertNode as h, isNodeSelection as T, mergeAttributes as y } from "@tiptap/core";
|
|
2
|
+
import { TextSelection as s, NodeSelection as k } from "prosemirror-state";
|
|
3
|
+
var A = f.create({
|
|
4
|
+
name: "horizontalRule",
|
|
5
|
+
addOptions() {
|
|
6
|
+
return {
|
|
7
|
+
HTMLAttributes: {},
|
|
8
|
+
nextNodeType: "paragraph"
|
|
9
|
+
};
|
|
10
|
+
},
|
|
11
|
+
group: "block",
|
|
12
|
+
parseHTML() {
|
|
13
|
+
return [{ tag: "hr" }];
|
|
14
|
+
},
|
|
15
|
+
renderHTML({ HTMLAttributes: o }) {
|
|
16
|
+
return ["hr", y(this.options.HTMLAttributes, o)];
|
|
17
|
+
},
|
|
18
|
+
markdownTokenName: "hr",
|
|
19
|
+
parseMarkdown: (o, n) => n.createNode("horizontalRule"),
|
|
20
|
+
renderMarkdown: () => "---",
|
|
21
|
+
addCommands() {
|
|
22
|
+
return {
|
|
23
|
+
setHorizontalRule: () => ({ chain: o, state: n }) => {
|
|
24
|
+
if (!h(n, n.schema.nodes[this.name]))
|
|
25
|
+
return !1;
|
|
26
|
+
const { selection: i } = n, { $to: l } = i, r = o();
|
|
27
|
+
return T(i) ? r.insertContentAt(l.pos, {
|
|
28
|
+
type: this.name
|
|
29
|
+
}) : r.insertContent({ type: this.name }), r.command(({ state: u, tr: e, dispatch: p }) => {
|
|
30
|
+
if (p) {
|
|
31
|
+
const { $to: t } = e.selection, a = t.end();
|
|
32
|
+
if (t.nodeAfter)
|
|
33
|
+
t.nodeAfter.isTextblock ? e.setSelection(s.create(e.doc, t.pos + 1)) : t.nodeAfter.isBlock ? e.setSelection(k.create(e.doc, t.pos)) : e.setSelection(s.create(e.doc, t.pos));
|
|
34
|
+
else {
|
|
35
|
+
const d = u.schema.nodes[this.options.nextNodeType] || t.parent.type.contentMatch.defaultType, c = d?.create();
|
|
36
|
+
c && (e.insert(a, c), e.setSelection(s.create(e.doc, a + 1)));
|
|
37
|
+
}
|
|
38
|
+
e.scrollIntoView();
|
|
39
|
+
}
|
|
40
|
+
return !0;
|
|
41
|
+
}).run();
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
addInputRules() {
|
|
46
|
+
return [
|
|
47
|
+
m({
|
|
48
|
+
find: /^(?:---|—-|___\s|\*\*\*\s)$/,
|
|
49
|
+
type: this.type
|
|
50
|
+
})
|
|
51
|
+
];
|
|
52
|
+
}
|
|
53
|
+
}), S = A;
|
|
54
|
+
export {
|
|
55
|
+
A as HorizontalRule,
|
|
56
|
+
S as default
|
|
57
|
+
};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { Node as h, nodeInputRule as m, ResizableNodeView as f, mergeAttributes as g } from "@tiptap/core";
|
|
2
|
+
var b = /(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/, y = h.create({
|
|
3
|
+
name: "image",
|
|
4
|
+
addOptions() {
|
|
5
|
+
return {
|
|
6
|
+
inline: !1,
|
|
7
|
+
allowBase64: !1,
|
|
8
|
+
HTMLAttributes: {},
|
|
9
|
+
resize: !1
|
|
10
|
+
};
|
|
11
|
+
},
|
|
12
|
+
inline() {
|
|
13
|
+
return this.options.inline;
|
|
14
|
+
},
|
|
15
|
+
group() {
|
|
16
|
+
return this.options.inline ? "inline" : "block";
|
|
17
|
+
},
|
|
18
|
+
draggable: !0,
|
|
19
|
+
addAttributes() {
|
|
20
|
+
return {
|
|
21
|
+
src: {
|
|
22
|
+
default: null
|
|
23
|
+
},
|
|
24
|
+
alt: {
|
|
25
|
+
default: null
|
|
26
|
+
},
|
|
27
|
+
title: {
|
|
28
|
+
default: null
|
|
29
|
+
},
|
|
30
|
+
width: {
|
|
31
|
+
default: null
|
|
32
|
+
},
|
|
33
|
+
height: {
|
|
34
|
+
default: null
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
parseHTML() {
|
|
39
|
+
return [
|
|
40
|
+
{
|
|
41
|
+
tag: this.options.allowBase64 ? "img[src]" : 'img[src]:not([src^="data:"])'
|
|
42
|
+
}
|
|
43
|
+
];
|
|
44
|
+
},
|
|
45
|
+
renderHTML({ HTMLAttributes: t }) {
|
|
46
|
+
return ["img", g(this.options.HTMLAttributes, t)];
|
|
47
|
+
},
|
|
48
|
+
parseMarkdown: (t, e) => e.createNode("image", {
|
|
49
|
+
src: t.href,
|
|
50
|
+
title: t.title,
|
|
51
|
+
alt: t.text
|
|
52
|
+
}),
|
|
53
|
+
renderMarkdown: (t) => {
|
|
54
|
+
var e, l, a, o, u, d;
|
|
55
|
+
const i = (l = (e = t.attrs) == null ? void 0 : e.src) != null ? l : "", c = (o = (a = t.attrs) == null ? void 0 : a.alt) != null ? o : "", r = (d = (u = t.attrs) == null ? void 0 : u.title) != null ? d : "";
|
|
56
|
+
return r ? `` : ``;
|
|
57
|
+
},
|
|
58
|
+
addNodeView() {
|
|
59
|
+
if (!this.options.resize || !this.options.resize.enabled || typeof document > "u" || !this.editor.isEditable)
|
|
60
|
+
return null;
|
|
61
|
+
const { directions: t, minWidth: e, minHeight: l, alwaysPreserveAspectRatio: a } = this.options.resize;
|
|
62
|
+
return ({ node: o, getPos: u, HTMLAttributes: d }) => {
|
|
63
|
+
const i = document.createElement("img");
|
|
64
|
+
Object.entries(d).forEach(([n, s]) => {
|
|
65
|
+
if (s != null)
|
|
66
|
+
switch (n) {
|
|
67
|
+
case "width":
|
|
68
|
+
case "height":
|
|
69
|
+
break;
|
|
70
|
+
default:
|
|
71
|
+
i.setAttribute(n, s);
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
}), i.src = d.src;
|
|
75
|
+
const c = new f({
|
|
76
|
+
element: i,
|
|
77
|
+
node: o,
|
|
78
|
+
getPos: u,
|
|
79
|
+
onResize: (n, s) => {
|
|
80
|
+
i.style.width = `${n}px`, i.style.height = `${s}px`;
|
|
81
|
+
},
|
|
82
|
+
onCommit: (n, s) => {
|
|
83
|
+
const p = u();
|
|
84
|
+
p !== void 0 && this.editor.chain().setNodeSelection(p).updateAttributes(this.name, {
|
|
85
|
+
width: n,
|
|
86
|
+
height: s
|
|
87
|
+
}).run();
|
|
88
|
+
},
|
|
89
|
+
onUpdate: (n, s, p) => n.type === o.type,
|
|
90
|
+
options: {
|
|
91
|
+
directions: t,
|
|
92
|
+
min: {
|
|
93
|
+
width: e,
|
|
94
|
+
height: l
|
|
95
|
+
},
|
|
96
|
+
preserveAspectRatio: a === !0
|
|
97
|
+
}
|
|
98
|
+
}), r = c.dom;
|
|
99
|
+
return r.style.visibility = "hidden", r.style.pointerEvents = "none", i.onload = () => {
|
|
100
|
+
r.style.visibility = "", r.style.pointerEvents = "";
|
|
101
|
+
}, c;
|
|
102
|
+
};
|
|
103
|
+
},
|
|
104
|
+
addCommands() {
|
|
105
|
+
return {
|
|
106
|
+
setImage: (t) => ({ commands: e }) => e.insertContent({
|
|
107
|
+
type: this.name,
|
|
108
|
+
attrs: t
|
|
109
|
+
})
|
|
110
|
+
};
|
|
111
|
+
},
|
|
112
|
+
addInputRules() {
|
|
113
|
+
return [
|
|
114
|
+
m({
|
|
115
|
+
find: b,
|
|
116
|
+
type: this.type,
|
|
117
|
+
getAttributes: (t) => {
|
|
118
|
+
const [, , e, l, a] = t;
|
|
119
|
+
return { src: l, alt: e, title: a };
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
];
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
export {
|
|
126
|
+
y as Image,
|
|
127
|
+
b as inputRegex
|
|
128
|
+
};
|