@forgedevstack/ink 1.1.0 → 1.1.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/components/InkEditor/InkEditor.cjs +1 -1
  3. package/dist/components/InkEditor/InkEditor.d.ts.map +1 -1
  4. package/dist/components/InkEditor/InkEditor.js +344 -331
  5. package/dist/components/InkEditor/components/AiPanel/AiPanel.cjs +1 -1
  6. package/dist/components/InkEditor/components/AiPanel/AiPanel.js +7 -6
  7. package/dist/components/InkEditor/components/ToolbarButton/ToolbarButton.cjs +1 -1
  8. package/dist/components/InkEditor/components/ToolbarButton/ToolbarButton.js +3 -2
  9. package/dist/constants/index.d.ts +1 -0
  10. package/dist/constants/index.d.ts.map +1 -1
  11. package/dist/constants/premium.const.cjs +1 -0
  12. package/dist/constants/premium.const.d.ts +8 -0
  13. package/dist/constants/premium.const.d.ts.map +1 -0
  14. package/dist/constants/premium.const.js +97 -0
  15. package/dist/index.cjs +1 -1
  16. package/dist/index.d.ts +3 -3
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +42 -29
  19. package/dist/styles.css +23 -1
  20. package/dist/types/index.d.ts +1 -0
  21. package/dist/types/index.d.ts.map +1 -1
  22. package/dist/types/ink.types.d.ts +7 -0
  23. package/dist/types/ink.types.d.ts.map +1 -1
  24. package/dist/types/premium.types.d.ts +30 -0
  25. package/dist/types/premium.types.d.ts.map +1 -0
  26. package/dist/utils/index.d.ts +3 -0
  27. package/dist/utils/index.d.ts.map +1 -1
  28. package/dist/utils/license.utils.cjs +1 -0
  29. package/dist/utils/license.utils.d.ts +2 -0
  30. package/dist/utils/license.utils.d.ts.map +1 -0
  31. package/dist/utils/license.utils.js +16 -0
  32. package/dist/utils/paste.utils.cjs +1 -0
  33. package/dist/utils/paste.utils.d.ts +4 -0
  34. package/dist/utils/paste.utils.d.ts.map +1 -0
  35. package/dist/utils/paste.utils.js +31 -0
  36. package/dist/utils/premium.utils.cjs +1 -0
  37. package/dist/utils/premium.utils.d.ts +6 -0
  38. package/dist/utils/premium.utils.d.ts.map +1 -0
  39. package/dist/utils/premium.utils.js +30 -0
  40. package/package.json +1 -1
@@ -1,254 +1,264 @@
1
- import { jsxs as K, jsx as i } from "react/jsx-runtime";
2
- import { useRef as Te, useState as d, useEffect as H } from "react";
3
- import { INK_MIN_HEIGHT as kt, INK_DEFAULT_TEXT_COLOR as Tt, INK_DEFAULT_HIGHLIGHT_COLOR as bt } from "../../constants/numbers.const.js";
4
- import { INK_PLACEHOLDER_DEFAULT as Lt, INK_DEFAULT_TOOLBAR as It, INK_DEFAULT_VARIANT as At, INK_DEFAULT_AUTHOR as Ht, INK_TABLE_DEFAULT_ROWS as wt, INK_TABLE_DEFAULT_COLS as Nt, INK_DEFAULT_FEATURES as St, INK_CLASS_TOOLBAR as _t, INK_CLASS_SHELL as Et, INK_CLASS_BODY as vt, INK_CLASS_CONTENT as yt, INK_CLASS_FOOTER as Rt, INK_CLASS_DIVIDER as Bt, INK_HEADING_OPTIONS as xt, INK_BUTTON_CONFIG as be, INK_CLASS_ROOT as Ot } from "../../constants/defaults.const.js";
5
- import { cn as Dt } from "../../utils/cn.utils.js";
6
- import { applyTypoAutoFix as Kt } from "../../utils/typo.utils.js";
7
- import { createInkId as Le } from "../../utils/id.utils.js";
8
- import { buildTableHtml as Ut } from "../../utils/table.utils.js";
9
- import { getBlockElement as Ie, moveBlock as Ft, markActiveBlock as Mt } from "../../utils/blocks.utils.js";
10
- import { rejectTrackChangeInHtml as Pt, acceptTrackChangeInHtml as Vt, createTrackChange as J, wrapInsertHtml as Ae, wrapDeleteHtml as jt } from "../../utils/trackChanges.utils.js";
11
- import { removeCommentMark as $t, wrapSelectionAsComment as Gt, createCommentThread as Wt } from "../../utils/comments.utils.js";
12
- import { InkHistoryStack as He } from "../../utils/history.utils.js";
13
- import { extractSlashQuery as qt, filterSlashCommands as Xt } from "../../utils/slash.utils.js";
14
- import { insertHTML as R, setTextColor as zt, setHighlightColor as Jt, getActiveFormats as Qt, queryCommandValue as Yt, fileToDataUrl as we, insertImage as Ne, execCommand as p, insertLink as Zt } from "./helpers/format.utils.js";
15
- import { ToolbarButton as g } from "./components/ToolbarButton/ToolbarButton.js";
16
- import { ToolbarDropdown as en } from "./components/ToolbarDropdown/ToolbarDropdown.js";
17
- import { ToolbarColorPicker as Se } from "./components/ToolbarColorPicker/ToolbarColorPicker.js";
18
- import { CommentsPanel as tn } from "./components/CommentsPanel/CommentsPanel.js";
19
- import { AiPanel as nn } from "./components/AiPanel/AiPanel.js";
20
- import { BlockHandles as on } from "./components/BlockHandles/BlockHandles.js";
21
- import { SlashMenu as rn } from "./components/SlashMenu/SlashMenu.js";
22
- import { TrackChangesBar as cn } from "./components/TrackChangesBar/TrackChangesBar.js";
23
- const C = {
24
- bold: "B",
25
- italic: "I",
26
- underline: "U",
27
- strikethrough: "S",
28
- bulletList: "•",
29
- orderedList: "1.",
30
- link: "🔗",
31
- image: "🖼",
32
- table: "▦",
33
- undo: "↶",
34
- redo: "↷",
35
- trackChanges: "±",
36
- comments: "💬",
37
- ai: "✦",
38
- clearFormat: "⌫",
39
- alignLeft: "⫷",
40
- alignCenter: "☰",
41
- alignRight: "⫸",
42
- alignJustify: "≡",
43
- indent: "→",
44
- outdent: "←",
45
- blockquote: "“",
46
- code: "</>"
47
- }, Q = () => {
48
- const w = window.getSelection();
49
- if (!w || w.rangeCount === 0) return "";
50
- const h = w.getRangeAt(0), b = document.createElement("div");
1
+ import { jsxs as F, jsx as i } from "react/jsx-runtime";
2
+ import { useRef as ye, useState as m, useEffect as y } from "react";
3
+ import { INK_MIN_HEIGHT as Ot, INK_DEFAULT_TEXT_COLOR as Pt, INK_DEFAULT_HIGHLIGHT_COLOR as Ut } from "../../constants/numbers.const.js";
4
+ import { INK_PLACEHOLDER_DEFAULT as Kt, INK_DEFAULT_TOOLBAR as Ft, INK_DEFAULT_VARIANT as Mt, INK_DEFAULT_AUTHOR as Vt, INK_TABLE_DEFAULT_ROWS as jt, INK_TABLE_DEFAULT_COLS as Wt, INK_DEFAULT_FEATURES as $t, INK_CLASS_TOOLBAR as Gt, INK_CLASS_SHELL as qt, INK_CLASS_BODY as zt, INK_CLASS_CONTENT as Xt, INK_CLASS_FOOTER as Qt, INK_CLASS_DIVIDER as Yt, INK_HEADING_OPTIONS as Jt, INK_BUTTON_CONFIG as Ne, INK_CLASS_ROOT as Zt } from "../../constants/defaults.const.js";
5
+ import { INK_DEFAULT_ICONS as Se } from "../../constants/premium.const.js";
6
+ import { cn as en } from "../../utils/cn.utils.js";
7
+ import { applyTypoAutoFix as tn } from "../../utils/typo.utils.js";
8
+ import { createInkId as ve } from "../../utils/id.utils.js";
9
+ import { buildTableHtml as nn } from "../../utils/table.utils.js";
10
+ import { getBlockElement as _e, moveBlock as on, markActiveBlock as rn } from "../../utils/blocks.utils.js";
11
+ import { rejectTrackChangeInHtml as cn, acceptTrackChangeInHtml as sn, createTrackChange as Z, wrapInsertHtml as Ee, wrapDeleteHtml as an } from "../../utils/trackChanges.utils.js";
12
+ import { removeCommentMark as ln, wrapSelectionAsComment as un, createCommentThread as mn } from "../../utils/comments.utils.js";
13
+ import { InkHistoryStack as xe } from "../../utils/history.utils.js";
14
+ import { extractSlashQuery as dn, filterSlashCommands as fn } from "../../utils/slash.utils.js";
15
+ import { resolveInkPremium as hn, hasInkPremiumFeature as D, themeTokensToStyle as pn } from "../../utils/premium.utils.js";
16
+ import { extractClipboardHtml as gn, sanitizePastedHtml as Cn, extractClipboardText as kn } from "../../utils/paste.utils.js";
17
+ import { insertHTML as I, setTextColor as Tn, setHighlightColor as bn, getActiveFormats as In, queryCommandValue as wn, execCommand as g, insertLink as An, insertImage as Re, fileToDataUrl as Ln } from "./helpers/format.utils.js";
18
+ import { ToolbarButton as C } from "./components/ToolbarButton/ToolbarButton.js";
19
+ import { ToolbarDropdown as Hn } from "./components/ToolbarDropdown/ToolbarDropdown.js";
20
+ import { ToolbarColorPicker as Be } from "./components/ToolbarColorPicker/ToolbarColorPicker.js";
21
+ import { CommentsPanel as yn } from "./components/CommentsPanel/CommentsPanel.js";
22
+ import { AiPanel as Nn } from "./components/AiPanel/AiPanel.js";
23
+ import { BlockHandles as Sn } from "./components/BlockHandles/BlockHandles.js";
24
+ import { SlashMenu as vn } from "./components/SlashMenu/SlashMenu.js";
25
+ import { TrackChangesBar as _n } from "./components/TrackChangesBar/TrackChangesBar.js";
26
+ const ee = () => {
27
+ const N = window.getSelection();
28
+ if (!N || N.rangeCount === 0) return "";
29
+ const h = N.getRangeAt(0), b = document.createElement("div");
51
30
  return b.appendChild(h.cloneContents()), b.innerHTML;
52
- }, En = (w) => {
53
- var Ce;
31
+ }, no = (N) => {
32
+ var He;
54
33
  const {
55
34
  value: h,
56
35
  defaultValue: b = "",
57
- onChange: U,
58
- placeholder: Y = Lt,
59
- disabled: c = !1,
60
- readOnly: l = !1,
61
- minHeight: F = kt,
62
- maxHeight: M,
63
- toolbar: _e = It,
64
- className: Ee = "",
65
- testId: ve,
66
- allowImagePaste: ye = !0,
67
- showCharCount: Z = !1,
68
- charCountMax: ee,
69
- typoAutoFix: Re = !0,
70
- variant: Be = At,
71
- features: xe,
72
- author: L = Ht,
73
- trackChanges: N,
74
- onTrackChangesChange: P,
75
- trackChangesEnabled: B,
76
- onTrackChangesEnabledChange: V,
77
- comments: S,
78
- onCommentsChange: j,
36
+ onChange: M,
37
+ placeholder: te = Kt,
38
+ disabled: s = !1,
39
+ readOnly: a = !1,
40
+ minHeight: V = Ot,
41
+ maxHeight: j,
42
+ toolbar: De = Ft,
43
+ className: Oe = "",
44
+ testId: Pe,
45
+ allowImagePaste: ne = !0,
46
+ showCharCount: oe = !1,
47
+ charCountMax: re,
48
+ typoAutoFix: Ue = !0,
49
+ variant: Ke = Mt,
50
+ features: Fe,
51
+ author: w = Vt,
52
+ trackChanges: S,
53
+ onTrackChangesChange: W,
54
+ trackChangesEnabled: O,
55
+ onTrackChangesEnabledChange: $,
56
+ comments: v,
57
+ onCommentsChange: G,
79
58
  showCommentsPanel: _,
80
- onShowCommentsPanelChange: $,
81
- ai: m,
82
- slashCommands: Oe,
83
- tableRows: De = wt,
84
- tableCols: Ke = Nt,
85
- ...Ue
86
- } = w, s = { ...St, ...xe }, o = Te(null), x = Te(new He(h ?? b)), [Fe, Me] = d(/* @__PURE__ */ new Set()), [Pe, te] = d("p"), [Ve, je] = d(0), [$e, Ge] = d(Tt), [We, qe] = d(bt), [I, ne] = d(B ?? !1), [Xe, oe] = d(N ?? []), [ze, re] = d(S ?? []), [Je, ce] = d(_ ?? !1), [le, G] = d(!!(m != null && m.enabled && m.openOnInit)), [ae, Qe] = d(""), [Ye, Ze] = d(0), [et, ie] = d(!1), [tt, O] = d([]), [se, nt] = d({ top: 0, left: 0 }), k = N ?? Xe, E = S ?? ze, W = _ ?? Je, ue = Oe ?? s.slash;
87
- H(() => {
88
- B !== void 0 && ne(B);
89
- }, [B]), H(() => {
90
- N && oe(N);
91
- }, [N]), H(() => {
92
- S && re(S);
93
- }, [S]), H(() => {
94
- _ !== void 0 && ce(_);
95
- }, [_]), H(() => {
59
+ onShowCommentsPanelChange: q,
60
+ ai: d,
61
+ slashCommands: Me,
62
+ tableRows: Ve = jt,
63
+ tableCols: je = Wt,
64
+ premium: We,
65
+ theme: $e,
66
+ icons: ce,
67
+ pasteMode: Ge = "plain",
68
+ onImageUpload: se,
69
+ wysiwyg: qe = !1,
70
+ style: ze,
71
+ ...Xe
72
+ } = N, u = { ...$t, ...Fe }, A = hn(We), Qe = D(A, "icons"), Ye = D(A, "theme"), Je = D(A, "richPaste"), Ze = D(A, "imageUpload"), et = D(A, "wysiwyg") && qe, p = Qe && ce ? { ...Se, ...ce } : Se, tt = Ye ? pn($e) : {}, nt = Je && Ge === "rich", o = ye(null), P = ye(new xe(h ?? b)), [ot, rt] = m(/* @__PURE__ */ new Set()), [ct, ae] = m("p"), [st, at] = m(0), [it, lt] = m(Pt), [ut, mt] = m(Ut), [L, ie] = m(O ?? !1), [dt, le] = m(S ?? []), [ft, ue] = m(v ?? []), [ht, me] = m(_ ?? !1), [de, z] = m(!!(d != null && d.enabled && d.openOnInit)), [fe, pt] = m(""), [gt, Ct] = m(0), [kt, he] = m(!1), [Tt, U] = m([]), [pe, bt] = m({ top: 0, left: 0 }), k = S ?? dt, E = v ?? ft, X = _ ?? ht, ge = Me ?? u.slash;
73
+ y(() => {
74
+ O !== void 0 && ie(O);
75
+ }, [O]), y(() => {
76
+ S && le(S);
77
+ }, [S]), y(() => {
78
+ v && ue(v);
79
+ }, [v]), y(() => {
80
+ _ !== void 0 && me(_);
81
+ }, [_]), y(() => {
96
82
  !o.current || h === void 0 || o.current.innerHTML !== h && (o.current.innerHTML = h);
97
- }, [h]), H(() => {
98
- !o.current || h || !b || (o.current.innerHTML = b, x.current = new He(b));
83
+ }, [h]), y(() => {
84
+ !o.current || h || !b || (o.current.innerHTML = b, P.current = new xe(b));
99
85
  }, []);
100
- const q = (e) => {
86
+ const Q = (e) => {
101
87
  var t;
102
- x.current.push(e), U == null || U(e), Z && o.current && je(((t = o.current.textContent) == null ? void 0 : t.length) ?? 0);
103
- }, A = (e) => {
104
- o.current && (o.current.innerHTML = e, q(e));
105
- }, v = (e) => {
106
- oe(e), P == null || P(e);
107
- }, X = (e) => {
108
- re(e), j == null || j(e);
109
- }, z = (e) => {
110
- ce(e), $ == null || $(e);
111
- }, ot = (e) => {
112
- ne(e), V == null || V(e);
113
- }, D = () => {
114
- Me(Qt());
115
- const e = Yt("formatBlock");
116
- if (e && te(e.toLowerCase().replace(/[<>]/g, "")), Qe(Q()), !o.current || !s.blocks) return;
117
- const t = window.getSelection(), n = (t == null ? void 0 : t.anchorNode) ?? null, r = Ie(n, o.current);
118
- if (Mt(o.current, r), r) {
119
- const a = o.current.getBoundingClientRect(), f = r.getBoundingClientRect();
120
- Ze(f.top - a.top + o.current.scrollTop), ie(!0);
88
+ P.current.push(e), M == null || M(e), oe && o.current && at(((t = o.current.textContent) == null ? void 0 : t.length) ?? 0);
89
+ }, H = (e) => {
90
+ o.current && (o.current.innerHTML = e, Q(e));
91
+ }, x = (e) => {
92
+ le(e), W == null || W(e);
93
+ }, Y = (e) => {
94
+ ue(e), G == null || G(e);
95
+ }, J = (e) => {
96
+ me(e), q == null || q(e);
97
+ }, It = (e) => {
98
+ ie(e), $ == null || $(e);
99
+ }, K = () => {
100
+ rt(In());
101
+ const e = wn("formatBlock");
102
+ if (e && ae(e.toLowerCase().replace(/[<>]/g, "")), pt(ee()), !o.current || !u.blocks) return;
103
+ const t = window.getSelection(), n = (t == null ? void 0 : t.anchorNode) ?? null, r = _e(n, o.current);
104
+ if (rn(o.current, r), r) {
105
+ const c = o.current.getBoundingClientRect(), f = r.getBoundingClientRect();
106
+ Ct(f.top - c.top + o.current.scrollTop), he(!0);
121
107
  } else
122
- ie(!1);
123
- }, u = () => {
108
+ he(!1);
109
+ }, l = () => {
124
110
  var t, n, r;
125
111
  if (!o.current) return;
126
112
  let e = o.current.innerHTML;
127
- if (I && s.trackChanges) {
128
- const a = window.getSelection();
129
- if (a && !a.isCollapsed) {
130
- const f = Q();
113
+ if (L && u.trackChanges) {
114
+ const c = window.getSelection();
115
+ if (c && !c.isCollapsed) {
116
+ const f = ee();
131
117
  if (f) {
132
- const T = J("delete", f, L);
133
- v([...k, T]), rt(T.id), e = o.current.innerHTML;
118
+ const T = Z("delete", f, w);
119
+ x([...k, T]), wt(T.id), e = o.current.innerHTML;
134
120
  }
135
121
  }
136
122
  }
137
- if (q(e), D(), ue && o.current) {
138
- const a = ((n = (t = window.getSelection()) == null ? void 0 : t.anchorNode) == null ? void 0 : n.textContent) ?? "", f = qt(a);
123
+ if (Q(e), K(), ge && o.current) {
124
+ const c = ((n = (t = window.getSelection()) == null ? void 0 : t.anchorNode) == null ? void 0 : n.textContent) ?? "", f = dn(c);
139
125
  if (f !== null) {
140
- O(Xt(f));
126
+ U(fn(f));
141
127
  const T = (r = window.getSelection()) == null ? void 0 : r.getRangeAt(0);
142
128
  if (T && o.current) {
143
- const y = T.getBoundingClientRect(), ke = o.current.getBoundingClientRect();
144
- nt({
145
- top: y.bottom - ke.top + 8,
146
- left: y.left - ke.left
129
+ const R = T.getBoundingClientRect(), B = o.current.getBoundingClientRect();
130
+ bt({
131
+ top: R.bottom - B.top + 8,
132
+ left: R.left - B.left
147
133
  });
148
134
  }
149
135
  } else
150
- O([]);
136
+ U([]);
151
137
  }
152
- }, rt = (e) => {
138
+ }, wt = (e) => {
153
139
  const t = window.getSelection();
154
140
  if (!t || t.rangeCount === 0) return;
155
- const n = Q();
156
- n && R(jt(n, e));
157
- }, ct = () => {
158
- if (!o.current || !Re || !s.typoAutoFix || c || l) return;
159
- const e = o.current.innerHTML, t = Kt(e);
160
- t.html !== e && (o.current.innerHTML = t.html, q(t.html));
161
- }, lt = (e) => {
141
+ const n = ee();
142
+ n && I(an(n, e));
143
+ }, At = () => {
144
+ if (!o.current || !Ue || !u.typoAutoFix || s || a) return;
145
+ const e = o.current.innerHTML, t = tn(e);
146
+ t.html !== e && (o.current.innerHTML = t.html, Q(t.html));
147
+ }, Lt = (e) => {
162
148
  var n;
163
- if (c || l) return;
149
+ if (s || a) return;
164
150
  (n = o.current) == null || n.focus();
165
- const t = be[e];
166
- t && (t.value ? p(t.command, t.value) : p(t.command), u());
167
- }, at = (e) => {
151
+ const t = Ne[e];
152
+ t && (t.value ? g(t.command, t.value) : g(t.command), l());
153
+ }, Ht = (e) => {
168
154
  var t;
169
- c || l || ((t = o.current) == null || t.focus(), p("formatBlock", e), te(e), u());
170
- }, it = () => {
155
+ s || a || ((t = o.current) == null || t.focus(), g("formatBlock", e), ae(e), l());
156
+ }, yt = () => {
171
157
  var t;
172
- if (c || l) return;
158
+ if (s || a) return;
173
159
  const e = window.prompt("Enter URL:", "https://");
174
- e && ((t = o.current) == null || t.focus(), Zt(e), u());
175
- }, st = async () => {
176
- if (c || l) return;
160
+ e && ((t = o.current) == null || t.focus(), An(e), l());
161
+ }, Ce = async (e) => Ze && se ? se(e) : Ln(e), Nt = async () => {
162
+ if (s || a) return;
177
163
  const e = document.createElement("input");
178
164
  e.type = "file", e.accept = "image/*", e.onchange = async () => {
179
- var r, a;
165
+ var r, c;
180
166
  const t = (r = e.files) == null ? void 0 : r[0];
181
167
  if (!t) return;
182
- const n = await we(t);
183
- (a = o.current) == null || a.focus(), Ne(n, t.name), u();
168
+ const n = await Ce(t);
169
+ (c = o.current) == null || c.focus(), Re(n, t.name), l();
184
170
  }, e.click();
185
- }, de = () => {
171
+ }, ke = () => {
186
172
  var t;
187
- if (c || l || !s.table) return;
173
+ if (s || a || !u.table) return;
188
174
  (t = o.current) == null || t.focus();
189
- const e = Ut(De, Ke);
190
- if (I && s.trackChanges) {
191
- const n = J("insert", e, L);
192
- v([...k, n]), R(Ae(e, n.id));
175
+ const e = nn(Ve, je);
176
+ if (L && u.trackChanges) {
177
+ const n = Z("insert", e, w);
178
+ x([...k, n]), I(Ee(e, n.id));
193
179
  } else
194
- R(e);
195
- u();
196
- }, me = () => {
197
- const e = x.current.undo();
180
+ I(e);
181
+ l();
182
+ }, Te = () => {
183
+ const e = P.current.undo();
198
184
  if (e === null || !o.current) {
199
- p("undo"), u();
185
+ g("undo"), l();
200
186
  return;
201
187
  }
202
- A(e);
203
- }, fe = () => {
204
- const e = x.current.redo();
188
+ H(e);
189
+ }, be = () => {
190
+ const e = P.current.redo();
205
191
  if (e === null || !o.current) {
206
- p("redo"), u();
192
+ g("redo"), l();
207
193
  return;
208
194
  }
209
- A(e);
210
- }, ut = () => {
211
- var a;
212
- if (c || l || !s.comments) return;
195
+ H(e);
196
+ }, St = () => {
197
+ var c;
198
+ if (s || a || !u.comments) return;
213
199
  const e = window.prompt("Comment:");
214
200
  if (!(e != null && e.trim())) return;
215
- const t = Le("hl");
216
- if ((a = o.current) == null || a.focus(), !Gt(t)) return;
217
- const r = Wt(L, e.trim(), t);
218
- X([r, ...E]), z(!0), u();
219
- }, he = (e) => {
201
+ const t = ve("hl");
202
+ if ((c = o.current) == null || c.focus(), !un(t)) return;
203
+ const r = mn(w, e.trim(), t);
204
+ Y([r, ...E]), J(!0), l();
205
+ }, Ie = (e) => {
220
206
  if (!o.current) return;
221
- const t = Vt(o.current.innerHTML, e);
222
- A(t), v(
207
+ const t = sn(o.current.innerHTML, e);
208
+ H(t), x(
223
209
  k.map((n) => n.id === e ? { ...n, accepted: !0 } : n)
224
210
  );
225
- }, pe = (e) => {
211
+ }, we = (e) => {
226
212
  if (!o.current) return;
227
- const t = Pt(o.current.innerHTML, e);
228
- A(t), v(
213
+ const t = cn(o.current.innerHTML, e);
214
+ H(t), x(
229
215
  k.map((n) => n.id === e ? { ...n, rejected: !0 } : n)
230
216
  );
231
- }, dt = async (e) => {
232
- var n;
233
- if (!ye || c || l) return;
234
- const t = (n = e.clipboardData) == null ? void 0 : n.items;
235
- if (t)
236
- for (const r of Array.from(t)) {
217
+ }, Ae = async (e) => {
218
+ const t = await Ce(e), n = `<img src="${t}" alt="" style="max-width:100%;height:auto;" />`;
219
+ if (L && u.trackChanges) {
220
+ const r = Z("insert", n, w);
221
+ x([...k, r]), I(Ee(n, r.id));
222
+ } else
223
+ Re(t);
224
+ l();
225
+ }, vt = async (e) => {
226
+ if (s || a) return;
227
+ const t = e.clipboardData;
228
+ if (!t) return;
229
+ if (nt) {
230
+ const r = gn(t);
231
+ if (r) {
232
+ e.preventDefault();
233
+ const f = Cn(r);
234
+ f && (I(f), l());
235
+ const T = t.items;
236
+ if (ne && T)
237
+ for (const R of Array.from(T)) {
238
+ if (!R.type.startsWith("image/")) continue;
239
+ const B = R.getAsFile();
240
+ B && await Ae(B);
241
+ }
242
+ return;
243
+ }
244
+ const c = kn(t);
245
+ if (c) {
246
+ e.preventDefault(), I(c.replace(/\n/g, "<br />")), l();
247
+ return;
248
+ }
249
+ }
250
+ if (!ne) return;
251
+ const n = t.items;
252
+ if (n)
253
+ for (const r of Array.from(n)) {
237
254
  if (!r.type.startsWith("image/")) continue;
238
255
  e.preventDefault();
239
- const a = r.getAsFile();
240
- if (!a) continue;
241
- const f = await we(a);
242
- if (I && s.trackChanges) {
243
- const T = `<img src="${f}" alt="" style="max-width:100%;height:auto;" />`, y = J("insert", T, L);
244
- v([...k, y]), R(Ae(T, y.id));
245
- } else
246
- Ne(f);
247
- u();
256
+ const c = r.getAsFile();
257
+ c && await Ae(c);
248
258
  }
249
- }, mt = (e) => {
250
- e.key === "Escape" && O([]), (e.metaKey || e.ctrlKey) && e.key === "z" && (e.preventDefault(), e.shiftKey ? fe() : me());
251
- }, ft = (e) => {
259
+ }, _t = (e) => {
260
+ e.key === "Escape" && U([]), (e.metaKey || e.ctrlKey) && e.key === "z" && (e.preventDefault(), e.shiftKey ? be() : Te());
261
+ }, Et = (e) => {
252
262
  var n, r;
253
263
  (n = o.current) == null || n.focus();
254
264
  const t = window.getSelection();
@@ -256,271 +266,274 @@ const C = {
256
266
  const f = t.anchorNode.textContent.replace(/(?:^|\s)\/[^\s]*$/, " ");
257
267
  t.anchorNode.nodeType === Node.TEXT_NODE && (t.anchorNode.textContent = f);
258
268
  }
259
- switch (O([]), e.insert) {
269
+ switch (U([]), e.insert) {
260
270
  case "heading1":
261
- p("formatBlock", "h1");
271
+ g("formatBlock", "h1");
262
272
  break;
263
273
  case "heading2":
264
- p("formatBlock", "h2");
274
+ g("formatBlock", "h2");
265
275
  break;
266
276
  case "bulletList":
267
- p("insertUnorderedList");
277
+ g("insertUnorderedList");
268
278
  break;
269
279
  case "orderedList":
270
- p("insertOrderedList");
280
+ g("insertOrderedList");
271
281
  break;
272
282
  case "table":
273
- de();
283
+ ke();
274
284
  return;
275
285
  case "ai":
276
- G(!0);
286
+ z(!0);
277
287
  break;
278
288
  }
279
- u();
280
- }, ge = (e) => {
289
+ l();
290
+ }, Le = (e) => {
281
291
  if (!o.current) return;
282
- const t = window.getSelection(), n = Ie((t == null ? void 0 : t.anchorNode) ?? null, o.current);
283
- n && Ft(n, e) && (u(), D());
284
- }, ht = (e, t) => {
292
+ const t = window.getSelection(), n = _e((t == null ? void 0 : t.anchorNode) ?? null, o.current);
293
+ n && on(n, e) && (l(), K());
294
+ }, xt = (e, t) => {
285
295
  if (e === "divider")
286
- return /* @__PURE__ */ i("span", { className: Bt }, `divider-${t}`);
296
+ return /* @__PURE__ */ i("span", { className: Yt }, `divider-${t}`);
287
297
  if (e === "headingDropdown")
288
298
  return /* @__PURE__ */ i(
289
- en,
299
+ Hn,
290
300
  {
291
301
  title: "Heading",
292
- options: xt,
293
- value: Pe || "p",
294
- disabled: c || l,
295
- onChange: at
302
+ options: Jt,
303
+ value: ct || "p",
304
+ disabled: s || a,
305
+ onChange: Ht
296
306
  },
297
307
  "heading"
298
308
  );
299
309
  if (e === "textColor")
300
310
  return /* @__PURE__ */ i(
301
- Se,
311
+ Be,
302
312
  {
303
313
  title: "Text color",
304
314
  type: "text",
305
- value: $e,
306
- disabled: c || l,
315
+ value: it,
316
+ disabled: s || a,
307
317
  onChange: (r) => {
308
- var a;
309
- (a = o.current) == null || a.focus(), zt(r), Ge(r), u();
318
+ var c;
319
+ (c = o.current) == null || c.focus(), Tn(r), lt(r), l();
310
320
  }
311
321
  },
312
322
  "textColor"
313
323
  );
314
324
  if (e === "highlightColor")
315
325
  return /* @__PURE__ */ i(
316
- Se,
326
+ Be,
317
327
  {
318
328
  title: "Highlight color",
319
329
  type: "highlight",
320
- value: We,
321
- disabled: c || l,
330
+ value: ut,
331
+ disabled: s || a,
322
332
  onChange: (r) => {
323
- var a;
324
- (a = o.current) == null || a.focus(), Jt(r), qe(r), u();
333
+ var c;
334
+ (c = o.current) == null || c.focus(), bn(r), mt(r), l();
325
335
  }
326
336
  },
327
337
  "highlightColor"
328
338
  );
329
339
  if (e === "link")
330
340
  return /* @__PURE__ */ i(
331
- g,
341
+ C,
332
342
  {
333
- icon: C.link,
343
+ icon: p.link,
334
344
  title: "Insert link",
335
- disabled: c || l,
336
- onClick: it
345
+ disabled: s || a,
346
+ onClick: yt
337
347
  },
338
348
  "link"
339
349
  );
340
350
  if (e === "image")
341
351
  return /* @__PURE__ */ i(
342
- g,
352
+ C,
343
353
  {
344
- icon: C.image,
354
+ icon: p.image,
345
355
  title: "Insert image",
346
- disabled: c || l,
356
+ disabled: s || a,
347
357
  onClick: () => {
348
- st();
358
+ Nt();
349
359
  }
350
360
  },
351
361
  "image"
352
362
  );
353
363
  if (e === "table")
354
- return s.table ? /* @__PURE__ */ i(
355
- g,
364
+ return u.table ? /* @__PURE__ */ i(
365
+ C,
356
366
  {
357
- icon: C.table,
367
+ icon: p.table,
358
368
  title: "Insert table",
359
- disabled: c || l,
360
- onClick: de
369
+ disabled: s || a,
370
+ onClick: ke
361
371
  },
362
372
  "table"
363
373
  ) : null;
364
374
  if (e === "undo")
365
375
  return /* @__PURE__ */ i(
366
- g,
376
+ C,
367
377
  {
368
- icon: C.undo,
378
+ icon: p.undo,
369
379
  title: "Undo",
370
- disabled: c || l,
371
- onClick: me
380
+ disabled: s || a,
381
+ onClick: Te
372
382
  },
373
383
  "undo"
374
384
  );
375
385
  if (e === "redo")
376
386
  return /* @__PURE__ */ i(
377
- g,
387
+ C,
378
388
  {
379
- icon: C.redo,
389
+ icon: p.redo,
380
390
  title: "Redo",
381
- disabled: c || l,
382
- onClick: fe
391
+ disabled: s || a,
392
+ onClick: be
383
393
  },
384
394
  "redo"
385
395
  );
386
396
  if (e === "trackChanges")
387
- return s.trackChanges ? /* @__PURE__ */ i(
388
- g,
397
+ return u.trackChanges ? /* @__PURE__ */ i(
398
+ C,
389
399
  {
390
- icon: C.trackChanges,
400
+ icon: p.trackChanges,
391
401
  title: "Track changes",
392
- active: I,
393
- disabled: c || l,
394
- onClick: () => ot(!I)
402
+ active: L,
403
+ disabled: s || a,
404
+ onClick: () => It(!L)
395
405
  },
396
406
  "trackChanges"
397
407
  ) : null;
398
408
  if (e === "comments")
399
- return s.comments ? /* @__PURE__ */ i(
400
- g,
409
+ return u.comments ? /* @__PURE__ */ i(
410
+ C,
401
411
  {
402
- icon: C.comments,
412
+ icon: p.comments,
403
413
  title: "Comments",
404
- active: W,
405
- disabled: c || l,
414
+ active: X,
415
+ disabled: s || a,
406
416
  onClick: () => {
407
- W ? z(!1) : ut();
417
+ X ? J(!1) : St();
408
418
  }
409
419
  },
410
420
  "comments"
411
421
  ) : null;
412
422
  if (e === "ai")
413
- return !s.ai || !(m != null && m.enabled) ? null : /* @__PURE__ */ i(
414
- g,
423
+ return !u.ai || !(d != null && d.enabled) ? null : /* @__PURE__ */ i(
424
+ C,
415
425
  {
416
- icon: C.ai,
426
+ icon: p.ai,
417
427
  title: "Ink AI",
418
- active: le,
419
- disabled: c || l,
420
- onClick: () => G((r) => !r)
428
+ active: de,
429
+ disabled: s || a,
430
+ onClick: () => z((r) => !r)
421
431
  },
422
432
  "ai"
423
433
  );
424
- const n = be[e];
434
+ const n = Ne[e];
425
435
  return n ? /* @__PURE__ */ i(
426
- g,
436
+ C,
427
437
  {
428
- icon: C[e] ?? e.slice(0, 1).toUpperCase(),
438
+ icon: p[e] ?? e.slice(0, 1).toUpperCase(),
429
439
  title: n.title,
430
- active: Fe.has(e),
431
- disabled: c || l,
432
- onClick: () => lt(e)
440
+ active: ot.has(e),
441
+ disabled: s || a,
442
+ onClick: () => Lt(e)
433
443
  },
434
444
  e
435
445
  ) : null;
436
- }, pt = typeof F == "number" ? `${F}px` : F, gt = typeof M == "number" ? `${M}px` : M, Ct = !!(m != null && m.enabled && le);
437
- return /* @__PURE__ */ K(
446
+ }, Rt = typeof V == "number" ? `${V}px` : V, Bt = typeof j == "number" ? `${j}px` : j, Dt = !!(d != null && d.enabled && de);
447
+ return /* @__PURE__ */ F(
438
448
  "div",
439
449
  {
440
- className: Dt(Ot, Ee),
441
- "data-testid": ve,
442
- "data-disabled": c || void 0,
443
- "data-variant": Be,
444
- ...Ue,
450
+ className: en(Zt, Oe),
451
+ "data-testid": Pe,
452
+ "data-disabled": s || void 0,
453
+ "data-variant": Ke,
454
+ "data-premium": A.active || void 0,
455
+ "data-wysiwyg": et || void 0,
456
+ style: { ...tt, ...ze },
457
+ ...Xe,
445
458
  children: [
446
- /* @__PURE__ */ i("div", { className: _t, role: "toolbar", "aria-label": "Ink formatting toolbar", children: _e.map(ht) }),
447
- I && s.trackChanges ? /* @__PURE__ */ i(
448
- cn,
459
+ /* @__PURE__ */ i("div", { className: Gt, role: "toolbar", "aria-label": "Ink formatting toolbar", children: De.map(xt) }),
460
+ L && u.trackChanges ? /* @__PURE__ */ i(
461
+ _n,
449
462
  {
450
463
  changes: k,
451
- onAccept: he,
452
- onReject: pe,
453
- onAcceptAll: () => k.forEach((e) => he(e.id)),
454
- onRejectAll: () => k.forEach((e) => pe(e.id))
464
+ onAccept: Ie,
465
+ onReject: we,
466
+ onAcceptAll: () => k.forEach((e) => Ie(e.id)),
467
+ onRejectAll: () => k.forEach((e) => we(e.id))
455
468
  }
456
469
  ) : null,
457
- /* @__PURE__ */ K("div", { className: Et, children: [
458
- /* @__PURE__ */ K("div", { className: vt, children: [
459
- s.blocks ? /* @__PURE__ */ i(
460
- on,
470
+ /* @__PURE__ */ F("div", { className: qt, children: [
471
+ /* @__PURE__ */ F("div", { className: zt, children: [
472
+ u.blocks ? /* @__PURE__ */ i(
473
+ Sn,
461
474
  {
462
- visible: et && !c && !l,
463
- top: Ye,
464
- onMoveUp: () => ge("up"),
465
- onMoveDown: () => ge("down")
475
+ visible: kt && !s && !a,
476
+ top: gt,
477
+ onMoveUp: () => Le("up"),
478
+ onMoveDown: () => Le("down")
466
479
  }
467
480
  ) : null,
468
481
  /* @__PURE__ */ i(
469
482
  "div",
470
483
  {
471
484
  ref: o,
472
- className: yt,
473
- contentEditable: !c && !l,
485
+ className: Xt,
486
+ contentEditable: !s && !a,
474
487
  role: "textbox",
475
488
  "aria-multiline": "true",
476
- "aria-placeholder": Y,
477
- "data-placeholder": Y,
489
+ "aria-placeholder": te,
490
+ "data-placeholder": te,
478
491
  suppressContentEditableWarning: !0,
479
- style: { minHeight: pt, maxHeight: gt },
480
- onInput: u,
481
- onBlur: ct,
482
- onKeyUp: D,
483
- onKeyDown: mt,
484
- onMouseUp: D,
492
+ style: { minHeight: Rt, maxHeight: Bt },
493
+ onInput: l,
494
+ onBlur: At,
495
+ onKeyUp: K,
496
+ onKeyDown: _t,
497
+ onMouseUp: K,
485
498
  onPaste: (e) => {
486
- dt(e);
499
+ vt(e);
487
500
  }
488
501
  }
489
502
  ),
490
- ue ? /* @__PURE__ */ i(
491
- rn,
503
+ ge ? /* @__PURE__ */ i(
504
+ vn,
492
505
  {
493
- items: tt,
494
- top: se.top,
495
- left: se.left,
496
- onSelect: ft
506
+ items: Tt,
507
+ top: pe.top,
508
+ left: pe.left,
509
+ onSelect: Et
497
510
  }
498
511
  ) : null
499
512
  ] }),
500
- W && s.comments ? /* @__PURE__ */ i(
501
- tn,
513
+ X && u.comments ? /* @__PURE__ */ i(
514
+ yn,
502
515
  {
503
516
  comments: E,
504
- author: L,
505
- onClose: () => z(!1),
517
+ author: w,
518
+ onClose: () => J(!1),
506
519
  onResolve: (e) => {
507
520
  const t = E.find((n) => n.id === e);
508
- X(
521
+ Y(
509
522
  E.map(
510
523
  (n) => n.id === e ? { ...n, resolved: !0 } : n
511
524
  )
512
- ), t && o.current && A($t(o.current.innerHTML, t.highlightId));
525
+ ), t && o.current && H(ln(o.current.innerHTML, t.highlightId));
513
526
  },
514
527
  onAddReply: (e, t) => {
515
- X(
528
+ Y(
516
529
  E.map(
517
530
  (n) => n.id === e ? {
518
531
  ...n,
519
532
  replies: [
520
533
  ...n.replies,
521
534
  {
522
- id: Le("reply"),
523
- author: L,
535
+ id: ve("reply"),
536
+ author: w,
524
537
  body: t,
525
538
  timestamp: Date.now()
526
539
  }
@@ -531,34 +544,34 @@ const C = {
531
544
  }
532
545
  }
533
546
  ) : null,
534
- Ct && m ? /* @__PURE__ */ i(
535
- nn,
547
+ Dt && d ? /* @__PURE__ */ i(
548
+ Nn,
536
549
  {
537
- config: m,
538
- documentHtml: ((Ce = o.current) == null ? void 0 : Ce.innerHTML) ?? h ?? "",
539
- selectionHtml: ae,
540
- onClose: () => G(!1),
550
+ config: d,
551
+ documentHtml: ((He = o.current) == null ? void 0 : He.innerHTML) ?? h ?? "",
552
+ selectionHtml: fe,
553
+ onClose: () => z(!1),
541
554
  onApplyHtml: (e) => {
542
555
  var t;
543
- if ((t = o.current) == null || t.focus(), ae)
544
- R(e);
556
+ if ((t = o.current) == null || t.focus(), fe)
557
+ I(e);
545
558
  else {
546
- A(e);
559
+ H(e);
547
560
  return;
548
561
  }
549
- u();
562
+ l();
550
563
  }
551
564
  }
552
565
  ) : null
553
566
  ] }),
554
- Z ? /* @__PURE__ */ K("div", { className: Rt, children: [
555
- Ve,
556
- ee ? ` / ${ee}` : ""
567
+ oe ? /* @__PURE__ */ F("div", { className: Qt, children: [
568
+ st,
569
+ re ? ` / ${re}` : ""
557
570
  ] }) : null
558
571
  ]
559
572
  }
560
573
  );
561
574
  };
562
575
  export {
563
- En as InkEditor
576
+ no as InkEditor
564
577
  };