@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.
- package/CHANGELOG.md +9 -0
- package/dist/components/InkEditor/InkEditor.cjs +1 -1
- package/dist/components/InkEditor/InkEditor.d.ts.map +1 -1
- package/dist/components/InkEditor/InkEditor.js +344 -331
- package/dist/components/InkEditor/components/AiPanel/AiPanel.cjs +1 -1
- package/dist/components/InkEditor/components/AiPanel/AiPanel.js +7 -6
- package/dist/components/InkEditor/components/ToolbarButton/ToolbarButton.cjs +1 -1
- package/dist/components/InkEditor/components/ToolbarButton/ToolbarButton.js +3 -2
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/constants/premium.const.cjs +1 -0
- package/dist/constants/premium.const.d.ts +8 -0
- package/dist/constants/premium.const.d.ts.map +1 -0
- package/dist/constants/premium.const.js +97 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +42 -29
- package/dist/styles.css +23 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/ink.types.d.ts +7 -0
- package/dist/types/ink.types.d.ts.map +1 -1
- package/dist/types/premium.types.d.ts +30 -0
- package/dist/types/premium.types.d.ts.map +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/license.utils.cjs +1 -0
- package/dist/utils/license.utils.d.ts +2 -0
- package/dist/utils/license.utils.d.ts.map +1 -0
- package/dist/utils/license.utils.js +16 -0
- package/dist/utils/paste.utils.cjs +1 -0
- package/dist/utils/paste.utils.d.ts +4 -0
- package/dist/utils/paste.utils.d.ts.map +1 -0
- package/dist/utils/paste.utils.js +31 -0
- package/dist/utils/premium.utils.cjs +1 -0
- package/dist/utils/premium.utils.d.ts +6 -0
- package/dist/utils/premium.utils.d.ts.map +1 -0
- package/dist/utils/premium.utils.js +30 -0
- package/package.json +1 -1
|
@@ -1,254 +1,264 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { INK_MIN_HEIGHT as
|
|
4
|
-
import { INK_PLACEHOLDER_DEFAULT as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
},
|
|
53
|
-
var
|
|
31
|
+
}, no = (N) => {
|
|
32
|
+
var He;
|
|
54
33
|
const {
|
|
55
34
|
value: h,
|
|
56
35
|
defaultValue: b = "",
|
|
57
|
-
onChange:
|
|
58
|
-
placeholder:
|
|
59
|
-
disabled:
|
|
60
|
-
readOnly:
|
|
61
|
-
minHeight:
|
|
62
|
-
maxHeight:
|
|
63
|
-
toolbar:
|
|
64
|
-
className:
|
|
65
|
-
testId:
|
|
66
|
-
allowImagePaste:
|
|
67
|
-
showCharCount:
|
|
68
|
-
charCountMax:
|
|
69
|
-
typoAutoFix:
|
|
70
|
-
variant:
|
|
71
|
-
features:
|
|
72
|
-
author:
|
|
73
|
-
trackChanges:
|
|
74
|
-
onTrackChangesChange:
|
|
75
|
-
trackChangesEnabled:
|
|
76
|
-
onTrackChangesEnabledChange:
|
|
77
|
-
comments:
|
|
78
|
-
onCommentsChange:
|
|
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:
|
|
82
|
-
slashCommands:
|
|
83
|
-
tableRows:
|
|
84
|
-
tableCols:
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}, [S]),
|
|
94
|
-
|
|
95
|
-
|
|
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]),
|
|
98
|
-
!o.current || h || !b || (o.current.innerHTML = b,
|
|
83
|
+
}, [h]), y(() => {
|
|
84
|
+
!o.current || h || !b || (o.current.innerHTML = b, P.current = new xe(b));
|
|
99
85
|
}, []);
|
|
100
|
-
const
|
|
86
|
+
const Q = (e) => {
|
|
101
87
|
var t;
|
|
102
|
-
|
|
103
|
-
},
|
|
104
|
-
o.current && (o.current.innerHTML = e,
|
|
105
|
-
},
|
|
106
|
-
|
|
107
|
-
},
|
|
108
|
-
|
|
109
|
-
},
|
|
110
|
-
|
|
111
|
-
},
|
|
112
|
-
|
|
113
|
-
},
|
|
114
|
-
|
|
115
|
-
const e =
|
|
116
|
-
if (e &&
|
|
117
|
-
const t = window.getSelection(), n = (t == null ? void 0 : t.anchorNode) ?? null, r =
|
|
118
|
-
if (
|
|
119
|
-
const
|
|
120
|
-
|
|
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
|
-
|
|
123
|
-
},
|
|
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 (
|
|
128
|
-
const
|
|
129
|
-
if (
|
|
130
|
-
const f =
|
|
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 =
|
|
133
|
-
|
|
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 (
|
|
138
|
-
const
|
|
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
|
-
|
|
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
|
|
144
|
-
|
|
145
|
-
top:
|
|
146
|
-
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
|
-
|
|
136
|
+
U([]);
|
|
151
137
|
}
|
|
152
|
-
},
|
|
138
|
+
}, wt = (e) => {
|
|
153
139
|
const t = window.getSelection();
|
|
154
140
|
if (!t || t.rangeCount === 0) return;
|
|
155
|
-
const n =
|
|
156
|
-
n &&
|
|
157
|
-
},
|
|
158
|
-
if (!o.current || !
|
|
159
|
-
const e = o.current.innerHTML, t =
|
|
160
|
-
t.html !== e && (o.current.innerHTML = t.html,
|
|
161
|
-
},
|
|
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 (
|
|
149
|
+
if (s || a) return;
|
|
164
150
|
(n = o.current) == null || n.focus();
|
|
165
|
-
const t =
|
|
166
|
-
t && (t.value ?
|
|
167
|
-
},
|
|
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
|
-
|
|
170
|
-
},
|
|
155
|
+
s || a || ((t = o.current) == null || t.focus(), g("formatBlock", e), ae(e), l());
|
|
156
|
+
}, yt = () => {
|
|
171
157
|
var t;
|
|
172
|
-
if (
|
|
158
|
+
if (s || a) return;
|
|
173
159
|
const e = window.prompt("Enter URL:", "https://");
|
|
174
|
-
e && ((t = o.current) == null || t.focus(),
|
|
175
|
-
},
|
|
176
|
-
if (
|
|
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,
|
|
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
|
|
183
|
-
(
|
|
168
|
+
const n = await Ce(t);
|
|
169
|
+
(c = o.current) == null || c.focus(), Re(n, t.name), l();
|
|
184
170
|
}, e.click();
|
|
185
|
-
},
|
|
171
|
+
}, ke = () => {
|
|
186
172
|
var t;
|
|
187
|
-
if (
|
|
173
|
+
if (s || a || !u.table) return;
|
|
188
174
|
(t = o.current) == null || t.focus();
|
|
189
|
-
const e =
|
|
190
|
-
if (
|
|
191
|
-
const n =
|
|
192
|
-
|
|
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
|
-
|
|
195
|
-
|
|
196
|
-
},
|
|
197
|
-
const e =
|
|
180
|
+
I(e);
|
|
181
|
+
l();
|
|
182
|
+
}, Te = () => {
|
|
183
|
+
const e = P.current.undo();
|
|
198
184
|
if (e === null || !o.current) {
|
|
199
|
-
|
|
185
|
+
g("undo"), l();
|
|
200
186
|
return;
|
|
201
187
|
}
|
|
202
|
-
|
|
203
|
-
},
|
|
204
|
-
const e =
|
|
188
|
+
H(e);
|
|
189
|
+
}, be = () => {
|
|
190
|
+
const e = P.current.redo();
|
|
205
191
|
if (e === null || !o.current) {
|
|
206
|
-
|
|
192
|
+
g("redo"), l();
|
|
207
193
|
return;
|
|
208
194
|
}
|
|
209
|
-
|
|
210
|
-
},
|
|
211
|
-
var
|
|
212
|
-
if (
|
|
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 =
|
|
216
|
-
if ((
|
|
217
|
-
const r =
|
|
218
|
-
|
|
219
|
-
},
|
|
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 =
|
|
222
|
-
|
|
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
|
-
},
|
|
211
|
+
}, we = (e) => {
|
|
226
212
|
if (!o.current) return;
|
|
227
|
-
const t =
|
|
228
|
-
|
|
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
|
-
},
|
|
232
|
-
|
|
233
|
-
if (
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
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
|
|
240
|
-
|
|
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
|
-
},
|
|
250
|
-
e.key === "Escape" &&
|
|
251
|
-
},
|
|
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 (
|
|
269
|
+
switch (U([]), e.insert) {
|
|
260
270
|
case "heading1":
|
|
261
|
-
|
|
271
|
+
g("formatBlock", "h1");
|
|
262
272
|
break;
|
|
263
273
|
case "heading2":
|
|
264
|
-
|
|
274
|
+
g("formatBlock", "h2");
|
|
265
275
|
break;
|
|
266
276
|
case "bulletList":
|
|
267
|
-
|
|
277
|
+
g("insertUnorderedList");
|
|
268
278
|
break;
|
|
269
279
|
case "orderedList":
|
|
270
|
-
|
|
280
|
+
g("insertOrderedList");
|
|
271
281
|
break;
|
|
272
282
|
case "table":
|
|
273
|
-
|
|
283
|
+
ke();
|
|
274
284
|
return;
|
|
275
285
|
case "ai":
|
|
276
|
-
|
|
286
|
+
z(!0);
|
|
277
287
|
break;
|
|
278
288
|
}
|
|
279
|
-
|
|
280
|
-
},
|
|
289
|
+
l();
|
|
290
|
+
}, Le = (e) => {
|
|
281
291
|
if (!o.current) return;
|
|
282
|
-
const t = window.getSelection(), n =
|
|
283
|
-
n &&
|
|
284
|
-
},
|
|
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:
|
|
296
|
+
return /* @__PURE__ */ i("span", { className: Yt }, `divider-${t}`);
|
|
287
297
|
if (e === "headingDropdown")
|
|
288
298
|
return /* @__PURE__ */ i(
|
|
289
|
-
|
|
299
|
+
Hn,
|
|
290
300
|
{
|
|
291
301
|
title: "Heading",
|
|
292
|
-
options:
|
|
293
|
-
value:
|
|
294
|
-
disabled:
|
|
295
|
-
onChange:
|
|
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
|
-
|
|
311
|
+
Be,
|
|
302
312
|
{
|
|
303
313
|
title: "Text color",
|
|
304
314
|
type: "text",
|
|
305
|
-
value:
|
|
306
|
-
disabled:
|
|
315
|
+
value: it,
|
|
316
|
+
disabled: s || a,
|
|
307
317
|
onChange: (r) => {
|
|
308
|
-
var
|
|
309
|
-
(
|
|
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
|
-
|
|
326
|
+
Be,
|
|
317
327
|
{
|
|
318
328
|
title: "Highlight color",
|
|
319
329
|
type: "highlight",
|
|
320
|
-
value:
|
|
321
|
-
disabled:
|
|
330
|
+
value: ut,
|
|
331
|
+
disabled: s || a,
|
|
322
332
|
onChange: (r) => {
|
|
323
|
-
var
|
|
324
|
-
(
|
|
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
|
-
|
|
341
|
+
C,
|
|
332
342
|
{
|
|
333
|
-
icon:
|
|
343
|
+
icon: p.link,
|
|
334
344
|
title: "Insert link",
|
|
335
|
-
disabled:
|
|
336
|
-
onClick:
|
|
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
|
-
|
|
352
|
+
C,
|
|
343
353
|
{
|
|
344
|
-
icon:
|
|
354
|
+
icon: p.image,
|
|
345
355
|
title: "Insert image",
|
|
346
|
-
disabled:
|
|
356
|
+
disabled: s || a,
|
|
347
357
|
onClick: () => {
|
|
348
|
-
|
|
358
|
+
Nt();
|
|
349
359
|
}
|
|
350
360
|
},
|
|
351
361
|
"image"
|
|
352
362
|
);
|
|
353
363
|
if (e === "table")
|
|
354
|
-
return
|
|
355
|
-
|
|
364
|
+
return u.table ? /* @__PURE__ */ i(
|
|
365
|
+
C,
|
|
356
366
|
{
|
|
357
|
-
icon:
|
|
367
|
+
icon: p.table,
|
|
358
368
|
title: "Insert table",
|
|
359
|
-
disabled:
|
|
360
|
-
onClick:
|
|
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
|
-
|
|
376
|
+
C,
|
|
367
377
|
{
|
|
368
|
-
icon:
|
|
378
|
+
icon: p.undo,
|
|
369
379
|
title: "Undo",
|
|
370
|
-
disabled:
|
|
371
|
-
onClick:
|
|
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
|
-
|
|
387
|
+
C,
|
|
378
388
|
{
|
|
379
|
-
icon:
|
|
389
|
+
icon: p.redo,
|
|
380
390
|
title: "Redo",
|
|
381
|
-
disabled:
|
|
382
|
-
onClick:
|
|
391
|
+
disabled: s || a,
|
|
392
|
+
onClick: be
|
|
383
393
|
},
|
|
384
394
|
"redo"
|
|
385
395
|
);
|
|
386
396
|
if (e === "trackChanges")
|
|
387
|
-
return
|
|
388
|
-
|
|
397
|
+
return u.trackChanges ? /* @__PURE__ */ i(
|
|
398
|
+
C,
|
|
389
399
|
{
|
|
390
|
-
icon:
|
|
400
|
+
icon: p.trackChanges,
|
|
391
401
|
title: "Track changes",
|
|
392
|
-
active:
|
|
393
|
-
disabled:
|
|
394
|
-
onClick: () =>
|
|
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
|
|
400
|
-
|
|
409
|
+
return u.comments ? /* @__PURE__ */ i(
|
|
410
|
+
C,
|
|
401
411
|
{
|
|
402
|
-
icon:
|
|
412
|
+
icon: p.comments,
|
|
403
413
|
title: "Comments",
|
|
404
|
-
active:
|
|
405
|
-
disabled:
|
|
414
|
+
active: X,
|
|
415
|
+
disabled: s || a,
|
|
406
416
|
onClick: () => {
|
|
407
|
-
|
|
417
|
+
X ? J(!1) : St();
|
|
408
418
|
}
|
|
409
419
|
},
|
|
410
420
|
"comments"
|
|
411
421
|
) : null;
|
|
412
422
|
if (e === "ai")
|
|
413
|
-
return !
|
|
414
|
-
|
|
423
|
+
return !u.ai || !(d != null && d.enabled) ? null : /* @__PURE__ */ i(
|
|
424
|
+
C,
|
|
415
425
|
{
|
|
416
|
-
icon:
|
|
426
|
+
icon: p.ai,
|
|
417
427
|
title: "Ink AI",
|
|
418
|
-
active:
|
|
419
|
-
disabled:
|
|
420
|
-
onClick: () =>
|
|
428
|
+
active: de,
|
|
429
|
+
disabled: s || a,
|
|
430
|
+
onClick: () => z((r) => !r)
|
|
421
431
|
},
|
|
422
432
|
"ai"
|
|
423
433
|
);
|
|
424
|
-
const n =
|
|
434
|
+
const n = Ne[e];
|
|
425
435
|
return n ? /* @__PURE__ */ i(
|
|
426
|
-
|
|
436
|
+
C,
|
|
427
437
|
{
|
|
428
|
-
icon:
|
|
438
|
+
icon: p[e] ?? e.slice(0, 1).toUpperCase(),
|
|
429
439
|
title: n.title,
|
|
430
|
-
active:
|
|
431
|
-
disabled:
|
|
432
|
-
onClick: () =>
|
|
440
|
+
active: ot.has(e),
|
|
441
|
+
disabled: s || a,
|
|
442
|
+
onClick: () => Lt(e)
|
|
433
443
|
},
|
|
434
444
|
e
|
|
435
445
|
) : null;
|
|
436
|
-
},
|
|
437
|
-
return /* @__PURE__ */
|
|
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:
|
|
441
|
-
"data-testid":
|
|
442
|
-
"data-disabled":
|
|
443
|
-
"data-variant":
|
|
444
|
-
|
|
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:
|
|
447
|
-
|
|
448
|
-
|
|
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:
|
|
452
|
-
onReject:
|
|
453
|
-
onAcceptAll: () => k.forEach((e) =>
|
|
454
|
-
onRejectAll: () => k.forEach((e) =>
|
|
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__ */
|
|
458
|
-
/* @__PURE__ */
|
|
459
|
-
|
|
460
|
-
|
|
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:
|
|
463
|
-
top:
|
|
464
|
-
onMoveUp: () =>
|
|
465
|
-
onMoveDown: () =>
|
|
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:
|
|
473
|
-
contentEditable: !
|
|
485
|
+
className: Xt,
|
|
486
|
+
contentEditable: !s && !a,
|
|
474
487
|
role: "textbox",
|
|
475
488
|
"aria-multiline": "true",
|
|
476
|
-
"aria-placeholder":
|
|
477
|
-
"data-placeholder":
|
|
489
|
+
"aria-placeholder": te,
|
|
490
|
+
"data-placeholder": te,
|
|
478
491
|
suppressContentEditableWarning: !0,
|
|
479
|
-
style: { minHeight:
|
|
480
|
-
onInput:
|
|
481
|
-
onBlur:
|
|
482
|
-
onKeyUp:
|
|
483
|
-
onKeyDown:
|
|
484
|
-
onMouseUp:
|
|
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
|
-
|
|
499
|
+
vt(e);
|
|
487
500
|
}
|
|
488
501
|
}
|
|
489
502
|
),
|
|
490
|
-
|
|
491
|
-
|
|
503
|
+
ge ? /* @__PURE__ */ i(
|
|
504
|
+
vn,
|
|
492
505
|
{
|
|
493
|
-
items:
|
|
494
|
-
top:
|
|
495
|
-
left:
|
|
496
|
-
onSelect:
|
|
506
|
+
items: Tt,
|
|
507
|
+
top: pe.top,
|
|
508
|
+
left: pe.left,
|
|
509
|
+
onSelect: Et
|
|
497
510
|
}
|
|
498
511
|
) : null
|
|
499
512
|
] }),
|
|
500
|
-
|
|
501
|
-
|
|
513
|
+
X && u.comments ? /* @__PURE__ */ i(
|
|
514
|
+
yn,
|
|
502
515
|
{
|
|
503
516
|
comments: E,
|
|
504
|
-
author:
|
|
505
|
-
onClose: () =>
|
|
517
|
+
author: w,
|
|
518
|
+
onClose: () => J(!1),
|
|
506
519
|
onResolve: (e) => {
|
|
507
520
|
const t = E.find((n) => n.id === e);
|
|
508
|
-
|
|
521
|
+
Y(
|
|
509
522
|
E.map(
|
|
510
523
|
(n) => n.id === e ? { ...n, resolved: !0 } : n
|
|
511
524
|
)
|
|
512
|
-
), t && o.current &&
|
|
525
|
+
), t && o.current && H(ln(o.current.innerHTML, t.highlightId));
|
|
513
526
|
},
|
|
514
527
|
onAddReply: (e, t) => {
|
|
515
|
-
|
|
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:
|
|
523
|
-
author:
|
|
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
|
-
|
|
535
|
-
|
|
547
|
+
Dt && d ? /* @__PURE__ */ i(
|
|
548
|
+
Nn,
|
|
536
549
|
{
|
|
537
|
-
config:
|
|
538
|
-
documentHtml: ((
|
|
539
|
-
selectionHtml:
|
|
540
|
-
onClose: () =>
|
|
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(),
|
|
544
|
-
|
|
556
|
+
if ((t = o.current) == null || t.focus(), fe)
|
|
557
|
+
I(e);
|
|
545
558
|
else {
|
|
546
|
-
|
|
559
|
+
H(e);
|
|
547
560
|
return;
|
|
548
561
|
}
|
|
549
|
-
|
|
562
|
+
l();
|
|
550
563
|
}
|
|
551
564
|
}
|
|
552
565
|
) : null
|
|
553
566
|
] }),
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
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
|
-
|
|
576
|
+
no as InkEditor
|
|
564
577
|
};
|