@forgedevstack/ink 1.0.1 → 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 +34 -0
- package/README.md +78 -122
- package/dist/components/InkEditor/InkEditor.cjs +1 -1
- package/dist/components/InkEditor/InkEditor.d.ts.map +1 -1
- package/dist/components/InkEditor/InkEditor.js +524 -172
- package/dist/components/InkEditor/components/AiPanel/AiPanel.cjs +1 -0
- package/dist/components/InkEditor/components/AiPanel/AiPanel.d.ts +11 -0
- package/dist/components/InkEditor/components/AiPanel/AiPanel.d.ts.map +1 -0
- package/dist/components/InkEditor/components/AiPanel/AiPanel.js +179 -0
- package/dist/components/InkEditor/components/AiPanel/index.d.ts +3 -0
- package/dist/components/InkEditor/components/AiPanel/index.d.ts.map +1 -0
- package/dist/components/InkEditor/components/BlockHandles/BlockHandles.cjs +1 -0
- package/dist/components/InkEditor/components/BlockHandles/BlockHandles.d.ts +9 -0
- package/dist/components/InkEditor/components/BlockHandles/BlockHandles.d.ts.map +1 -0
- package/dist/components/InkEditor/components/BlockHandles/BlockHandles.js +12 -0
- package/dist/components/InkEditor/components/BlockHandles/index.d.ts +3 -0
- package/dist/components/InkEditor/components/BlockHandles/index.d.ts.map +1 -0
- package/dist/components/InkEditor/components/CommentsPanel/CommentsPanel.cjs +1 -0
- package/dist/components/InkEditor/components/CommentsPanel/CommentsPanel.d.ts +11 -0
- package/dist/components/InkEditor/components/CommentsPanel/CommentsPanel.d.ts.map +1 -0
- package/dist/components/InkEditor/components/CommentsPanel/CommentsPanel.js +61 -0
- package/dist/components/InkEditor/components/CommentsPanel/index.d.ts +3 -0
- package/dist/components/InkEditor/components/CommentsPanel/index.d.ts.map +1 -0
- package/dist/components/InkEditor/components/SlashMenu/SlashMenu.cjs +1 -0
- package/dist/components/InkEditor/components/SlashMenu/SlashMenu.d.ts +10 -0
- package/dist/components/InkEditor/components/SlashMenu/SlashMenu.d.ts.map +1 -0
- package/dist/components/InkEditor/components/SlashMenu/SlashMenu.js +20 -0
- package/dist/components/InkEditor/components/SlashMenu/index.d.ts +3 -0
- package/dist/components/InkEditor/components/SlashMenu/index.d.ts.map +1 -0
- package/dist/components/InkEditor/components/ToolbarButton/ToolbarButton.cjs +1 -1
- package/dist/components/InkEditor/components/ToolbarButton/ToolbarButton.js +3 -2
- package/dist/components/InkEditor/components/TrackChangesBar/TrackChangesBar.cjs +1 -0
- package/dist/components/InkEditor/components/TrackChangesBar/TrackChangesBar.d.ts +11 -0
- package/dist/components/InkEditor/components/TrackChangesBar/TrackChangesBar.d.ts.map +1 -0
- package/dist/components/InkEditor/components/TrackChangesBar/TrackChangesBar.js +27 -0
- package/dist/components/InkEditor/components/TrackChangesBar/index.d.ts +3 -0
- package/dist/components/InkEditor/components/TrackChangesBar/index.d.ts.map +1 -0
- package/dist/components/InkEditor/components/index.d.ts +5 -0
- package/dist/components/InkEditor/components/index.d.ts.map +1 -1
- package/dist/constants/aiModels.const.cjs +1 -0
- package/dist/constants/aiModels.const.d.ts +5 -0
- package/dist/constants/aiModels.const.d.ts.map +1 -0
- package/dist/constants/aiModels.const.js +31 -0
- package/dist/constants/defaults.const.cjs +1 -1
- package/dist/constants/defaults.const.d.ts +32 -1
- package/dist/constants/defaults.const.d.ts.map +1 -1
- package/dist/constants/defaults.const.js +124 -20
- package/dist/constants/index.d.ts +2 -0
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/constants/numbers.const.cjs +1 -1
- package/dist/constants/numbers.const.d.ts +13 -0
- package/dist/constants/numbers.const.d.ts.map +1 -1
- package/dist/constants/numbers.const.js +13 -3
- 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 +43 -11
- package/dist/plugins/ai/aiPlugin.cjs +1 -1
- package/dist/plugins/ai/aiPlugin.d.ts.map +1 -1
- package/dist/plugins/ai/aiPlugin.js +40 -18
- package/dist/plugins/ai/demoProvider.cjs +1 -0
- package/dist/plugins/ai/demoProvider.d.ts +3 -0
- package/dist/plugins/ai/demoProvider.d.ts.map +1 -0
- package/dist/plugins/ai/demoProvider.js +130 -0
- package/dist/plugins/ai/index.cjs +1 -1
- package/dist/plugins/ai/index.d.ts +4 -1
- package/dist/plugins/ai/index.d.ts.map +1 -1
- package/dist/plugins/ai/index.js +15 -3
- package/dist/plugins/ai/stubs.cjs +1 -0
- package/dist/plugins/ai/stubs.d.ts +7 -0
- package/dist/plugins/ai/stubs.d.ts.map +1 -0
- package/dist/plugins/ai/stubs.js +23 -0
- package/dist/styles.css +486 -19
- package/dist/types/ai.types.d.ts +111 -2
- package/dist/types/ai.types.d.ts.map +1 -1
- package/dist/types/comments.types.d.ts +17 -0
- package/dist/types/comments.types.d.ts.map +1 -0
- package/dist/types/features.types.d.ts +5 -0
- package/dist/types/features.types.d.ts.map +1 -0
- package/dist/types/index.d.ts +6 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/ink.types.d.ts +33 -1
- 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/types/trackChanges.types.d.ts +12 -0
- package/dist/types/trackChanges.types.d.ts.map +1 -0
- package/dist/utils/blocks.utils.cjs +1 -0
- package/dist/utils/blocks.utils.d.ts +4 -0
- package/dist/utils/blocks.utils.d.ts.map +1 -0
- package/dist/utils/blocks.utils.js +41 -0
- package/dist/utils/comments.utils.cjs +1 -0
- package/dist/utils/comments.utils.d.ts +5 -0
- package/dist/utils/comments.utils.d.ts.map +1 -0
- package/dist/utils/comments.utils.js +32 -0
- package/dist/utils/history.utils.cjs +1 -0
- package/dist/utils/history.utils.d.ts +13 -0
- package/dist/utils/history.utils.d.ts.map +1 -0
- package/dist/utils/history.utils.js +29 -0
- package/dist/utils/id.utils.cjs +1 -0
- package/dist/utils/id.utils.d.ts +2 -0
- package/dist/utils/id.utils.d.ts.map +1 -0
- package/dist/utils/id.utils.js +4 -0
- package/dist/utils/index.d.ts +10 -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/dist/utils/slash.utils.cjs +1 -0
- package/dist/utils/slash.utils.d.ts +4 -0
- package/dist/utils/slash.utils.d.ts.map +1 -0
- package/dist/utils/slash.utils.js +13 -0
- package/dist/utils/table.utils.cjs +1 -0
- package/dist/utils/table.utils.d.ts +2 -0
- package/dist/utils/table.utils.d.ts.map +1 -0
- package/dist/utils/table.utils.js +13 -0
- package/dist/utils/trackChanges.utils.cjs +1 -0
- package/dist/utils/trackChanges.utils.d.ts +7 -0
- package/dist/utils/trackChanges.utils.d.ts.map +1 -0
- package/dist/utils/trackChanges.utils.js +34 -0
- package/package.json +2 -2
|
@@ -1,225 +1,577 @@
|
|
|
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 {
|
|
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";
|
|
8
18
|
import { ToolbarButton as C } from "./components/ToolbarButton/ToolbarButton.js";
|
|
9
|
-
import { ToolbarDropdown as
|
|
10
|
-
import { ToolbarColorPicker as
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
alignRight: "⫸",
|
|
24
|
-
alignJustify: "≡",
|
|
25
|
-
indent: "→",
|
|
26
|
-
outdent: "←",
|
|
27
|
-
blockquote: "“",
|
|
28
|
-
code: "</>"
|
|
29
|
-
}, St = (y) => {
|
|
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");
|
|
30
|
+
return b.appendChild(h.cloneContents()), b.innerHTML;
|
|
31
|
+
}, no = (N) => {
|
|
32
|
+
var He;
|
|
30
33
|
const {
|
|
31
|
-
value:
|
|
32
|
-
defaultValue:
|
|
33
|
-
onChange:
|
|
34
|
-
placeholder:
|
|
35
|
-
disabled:
|
|
36
|
-
readOnly:
|
|
37
|
-
minHeight:
|
|
38
|
-
maxHeight:
|
|
39
|
-
toolbar:
|
|
40
|
-
className:
|
|
41
|
-
testId:
|
|
42
|
-
allowImagePaste:
|
|
43
|
-
showCharCount:
|
|
44
|
-
charCountMax:
|
|
45
|
-
typoAutoFix:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
34
|
+
value: h,
|
|
35
|
+
defaultValue: b = "",
|
|
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,
|
|
58
|
+
showCommentsPanel: _,
|
|
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(() => {
|
|
82
|
+
!o.current || h === void 0 || o.current.innerHTML !== h && (o.current.innerHTML = h);
|
|
83
|
+
}, [h]), y(() => {
|
|
84
|
+
!o.current || h || !b || (o.current.innerHTML = b, P.current = new xe(b));
|
|
52
85
|
}, []);
|
|
53
|
-
const
|
|
54
|
-
var
|
|
55
|
-
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
e
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
(
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
(a = r.current) == null || a.focus(), O(l, e.name), c();
|
|
89
|
-
}, t.click();
|
|
90
|
-
}, Y = async (t) => {
|
|
91
|
-
var l;
|
|
92
|
-
if (!K || n || o) return;
|
|
93
|
-
const e = (l = t.clipboardData) == null ? void 0 : l.items;
|
|
94
|
-
if (e)
|
|
95
|
-
for (const i of Array.from(e)) {
|
|
96
|
-
if (!i.type.startsWith("image/")) continue;
|
|
97
|
-
t.preventDefault();
|
|
98
|
-
const a = i.getAsFile();
|
|
99
|
-
if (!a) continue;
|
|
100
|
-
const rt = await A(a);
|
|
101
|
-
O(rt), c();
|
|
86
|
+
const Q = (e) => {
|
|
87
|
+
var t;
|
|
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);
|
|
107
|
+
} else
|
|
108
|
+
he(!1);
|
|
109
|
+
}, l = () => {
|
|
110
|
+
var t, n, r;
|
|
111
|
+
if (!o.current) return;
|
|
112
|
+
let e = o.current.innerHTML;
|
|
113
|
+
if (L && u.trackChanges) {
|
|
114
|
+
const c = window.getSelection();
|
|
115
|
+
if (c && !c.isCollapsed) {
|
|
116
|
+
const f = ee();
|
|
117
|
+
if (f) {
|
|
118
|
+
const T = Z("delete", f, w);
|
|
119
|
+
x([...k, T]), wt(T.id), e = o.current.innerHTML;
|
|
120
|
+
}
|
|
102
121
|
}
|
|
103
|
-
|
|
104
|
-
if (
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
122
|
+
}
|
|
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);
|
|
125
|
+
if (f !== null) {
|
|
126
|
+
U(fn(f));
|
|
127
|
+
const T = (r = window.getSelection()) == null ? void 0 : r.getRangeAt(0);
|
|
128
|
+
if (T && o.current) {
|
|
129
|
+
const R = T.getBoundingClientRect(), B = o.current.getBoundingClientRect();
|
|
130
|
+
bt({
|
|
131
|
+
top: R.bottom - B.top + 8,
|
|
132
|
+
left: R.left - B.left
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
} else
|
|
136
|
+
U([]);
|
|
137
|
+
}
|
|
138
|
+
}, wt = (e) => {
|
|
139
|
+
const t = window.getSelection();
|
|
140
|
+
if (!t || t.rangeCount === 0) return;
|
|
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) => {
|
|
148
|
+
var n;
|
|
149
|
+
if (s || a) return;
|
|
150
|
+
(n = o.current) == null || n.focus();
|
|
151
|
+
const t = Ne[e];
|
|
152
|
+
t && (t.value ? g(t.command, t.value) : g(t.command), l());
|
|
153
|
+
}, Ht = (e) => {
|
|
154
|
+
var t;
|
|
155
|
+
s || a || ((t = o.current) == null || t.focus(), g("formatBlock", e), ae(e), l());
|
|
156
|
+
}, yt = () => {
|
|
157
|
+
var t;
|
|
158
|
+
if (s || a) return;
|
|
159
|
+
const e = window.prompt("Enter URL:", "https://");
|
|
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;
|
|
163
|
+
const e = document.createElement("input");
|
|
164
|
+
e.type = "file", e.accept = "image/*", e.onchange = async () => {
|
|
165
|
+
var r, c;
|
|
166
|
+
const t = (r = e.files) == null ? void 0 : r[0];
|
|
167
|
+
if (!t) return;
|
|
168
|
+
const n = await Ce(t);
|
|
169
|
+
(c = o.current) == null || c.focus(), Re(n, t.name), l();
|
|
170
|
+
}, e.click();
|
|
171
|
+
}, ke = () => {
|
|
172
|
+
var t;
|
|
173
|
+
if (s || a || !u.table) return;
|
|
174
|
+
(t = o.current) == null || t.focus();
|
|
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));
|
|
179
|
+
} else
|
|
180
|
+
I(e);
|
|
181
|
+
l();
|
|
182
|
+
}, Te = () => {
|
|
183
|
+
const e = P.current.undo();
|
|
184
|
+
if (e === null || !o.current) {
|
|
185
|
+
g("undo"), l();
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
H(e);
|
|
189
|
+
}, be = () => {
|
|
190
|
+
const e = P.current.redo();
|
|
191
|
+
if (e === null || !o.current) {
|
|
192
|
+
g("redo"), l();
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
H(e);
|
|
196
|
+
}, St = () => {
|
|
197
|
+
var c;
|
|
198
|
+
if (s || a || !u.comments) return;
|
|
199
|
+
const e = window.prompt("Comment:");
|
|
200
|
+
if (!(e != null && e.trim())) return;
|
|
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) => {
|
|
206
|
+
if (!o.current) return;
|
|
207
|
+
const t = sn(o.current.innerHTML, e);
|
|
208
|
+
H(t), x(
|
|
209
|
+
k.map((n) => n.id === e ? { ...n, accepted: !0 } : n)
|
|
210
|
+
);
|
|
211
|
+
}, we = (e) => {
|
|
212
|
+
if (!o.current) return;
|
|
213
|
+
const t = cn(o.current.innerHTML, e);
|
|
214
|
+
H(t), x(
|
|
215
|
+
k.map((n) => n.id === e ? { ...n, rejected: !0 } : n)
|
|
216
|
+
);
|
|
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)) {
|
|
254
|
+
if (!r.type.startsWith("image/")) continue;
|
|
255
|
+
e.preventDefault();
|
|
256
|
+
const c = r.getAsFile();
|
|
257
|
+
c && await Ae(c);
|
|
258
|
+
}
|
|
259
|
+
}, _t = (e) => {
|
|
260
|
+
e.key === "Escape" && U([]), (e.metaKey || e.ctrlKey) && e.key === "z" && (e.preventDefault(), e.shiftKey ? be() : Te());
|
|
261
|
+
}, Et = (e) => {
|
|
262
|
+
var n, r;
|
|
263
|
+
(n = o.current) == null || n.focus();
|
|
264
|
+
const t = window.getSelection();
|
|
265
|
+
if ((r = t == null ? void 0 : t.anchorNode) != null && r.textContent) {
|
|
266
|
+
const f = t.anchorNode.textContent.replace(/(?:^|\s)\/[^\s]*$/, " ");
|
|
267
|
+
t.anchorNode.nodeType === Node.TEXT_NODE && (t.anchorNode.textContent = f);
|
|
268
|
+
}
|
|
269
|
+
switch (U([]), e.insert) {
|
|
270
|
+
case "heading1":
|
|
271
|
+
g("formatBlock", "h1");
|
|
272
|
+
break;
|
|
273
|
+
case "heading2":
|
|
274
|
+
g("formatBlock", "h2");
|
|
275
|
+
break;
|
|
276
|
+
case "bulletList":
|
|
277
|
+
g("insertUnorderedList");
|
|
278
|
+
break;
|
|
279
|
+
case "orderedList":
|
|
280
|
+
g("insertOrderedList");
|
|
281
|
+
break;
|
|
282
|
+
case "table":
|
|
283
|
+
ke();
|
|
284
|
+
return;
|
|
285
|
+
case "ai":
|
|
286
|
+
z(!0);
|
|
287
|
+
break;
|
|
288
|
+
}
|
|
289
|
+
l();
|
|
290
|
+
}, Le = (e) => {
|
|
291
|
+
if (!o.current) return;
|
|
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) => {
|
|
295
|
+
if (e === "divider")
|
|
296
|
+
return /* @__PURE__ */ i("span", { className: Yt }, `divider-${t}`);
|
|
297
|
+
if (e === "headingDropdown")
|
|
298
|
+
return /* @__PURE__ */ i(
|
|
299
|
+
Hn,
|
|
109
300
|
{
|
|
110
301
|
title: "Heading",
|
|
111
|
-
options:
|
|
112
|
-
value:
|
|
113
|
-
disabled:
|
|
114
|
-
onChange:
|
|
302
|
+
options: Jt,
|
|
303
|
+
value: ct || "p",
|
|
304
|
+
disabled: s || a,
|
|
305
|
+
onChange: Ht
|
|
115
306
|
},
|
|
116
307
|
"heading"
|
|
117
308
|
);
|
|
118
|
-
if (
|
|
119
|
-
return /* @__PURE__ */
|
|
120
|
-
|
|
309
|
+
if (e === "textColor")
|
|
310
|
+
return /* @__PURE__ */ i(
|
|
311
|
+
Be,
|
|
121
312
|
{
|
|
122
313
|
title: "Text color",
|
|
123
314
|
type: "text",
|
|
124
|
-
value:
|
|
125
|
-
disabled:
|
|
126
|
-
onChange: (
|
|
127
|
-
var
|
|
128
|
-
(
|
|
315
|
+
value: it,
|
|
316
|
+
disabled: s || a,
|
|
317
|
+
onChange: (r) => {
|
|
318
|
+
var c;
|
|
319
|
+
(c = o.current) == null || c.focus(), Tn(r), lt(r), l();
|
|
129
320
|
}
|
|
130
321
|
},
|
|
131
322
|
"textColor"
|
|
132
323
|
);
|
|
133
|
-
if (
|
|
134
|
-
return /* @__PURE__ */
|
|
135
|
-
|
|
324
|
+
if (e === "highlightColor")
|
|
325
|
+
return /* @__PURE__ */ i(
|
|
326
|
+
Be,
|
|
136
327
|
{
|
|
137
328
|
title: "Highlight color",
|
|
138
329
|
type: "highlight",
|
|
139
|
-
value:
|
|
140
|
-
disabled:
|
|
141
|
-
onChange: (
|
|
142
|
-
var
|
|
143
|
-
(
|
|
330
|
+
value: ut,
|
|
331
|
+
disabled: s || a,
|
|
332
|
+
onChange: (r) => {
|
|
333
|
+
var c;
|
|
334
|
+
(c = o.current) == null || c.focus(), bn(r), mt(r), l();
|
|
144
335
|
}
|
|
145
336
|
},
|
|
146
337
|
"highlightColor"
|
|
147
338
|
);
|
|
148
|
-
if (
|
|
149
|
-
return /* @__PURE__ */
|
|
339
|
+
if (e === "link")
|
|
340
|
+
return /* @__PURE__ */ i(
|
|
150
341
|
C,
|
|
151
342
|
{
|
|
152
|
-
icon:
|
|
343
|
+
icon: p.link,
|
|
153
344
|
title: "Insert link",
|
|
154
|
-
disabled:
|
|
155
|
-
onClick:
|
|
345
|
+
disabled: s || a,
|
|
346
|
+
onClick: yt
|
|
156
347
|
},
|
|
157
348
|
"link"
|
|
158
349
|
);
|
|
159
|
-
if (
|
|
160
|
-
return /* @__PURE__ */
|
|
350
|
+
if (e === "image")
|
|
351
|
+
return /* @__PURE__ */ i(
|
|
161
352
|
C,
|
|
162
353
|
{
|
|
163
|
-
icon:
|
|
354
|
+
icon: p.image,
|
|
164
355
|
title: "Insert image",
|
|
165
|
-
disabled:
|
|
356
|
+
disabled: s || a,
|
|
166
357
|
onClick: () => {
|
|
167
|
-
|
|
358
|
+
Nt();
|
|
168
359
|
}
|
|
169
360
|
},
|
|
170
361
|
"image"
|
|
171
362
|
);
|
|
172
|
-
|
|
173
|
-
|
|
363
|
+
if (e === "table")
|
|
364
|
+
return u.table ? /* @__PURE__ */ i(
|
|
365
|
+
C,
|
|
366
|
+
{
|
|
367
|
+
icon: p.table,
|
|
368
|
+
title: "Insert table",
|
|
369
|
+
disabled: s || a,
|
|
370
|
+
onClick: ke
|
|
371
|
+
},
|
|
372
|
+
"table"
|
|
373
|
+
) : null;
|
|
374
|
+
if (e === "undo")
|
|
375
|
+
return /* @__PURE__ */ i(
|
|
376
|
+
C,
|
|
377
|
+
{
|
|
378
|
+
icon: p.undo,
|
|
379
|
+
title: "Undo",
|
|
380
|
+
disabled: s || a,
|
|
381
|
+
onClick: Te
|
|
382
|
+
},
|
|
383
|
+
"undo"
|
|
384
|
+
);
|
|
385
|
+
if (e === "redo")
|
|
386
|
+
return /* @__PURE__ */ i(
|
|
387
|
+
C,
|
|
388
|
+
{
|
|
389
|
+
icon: p.redo,
|
|
390
|
+
title: "Redo",
|
|
391
|
+
disabled: s || a,
|
|
392
|
+
onClick: be
|
|
393
|
+
},
|
|
394
|
+
"redo"
|
|
395
|
+
);
|
|
396
|
+
if (e === "trackChanges")
|
|
397
|
+
return u.trackChanges ? /* @__PURE__ */ i(
|
|
398
|
+
C,
|
|
399
|
+
{
|
|
400
|
+
icon: p.trackChanges,
|
|
401
|
+
title: "Track changes",
|
|
402
|
+
active: L,
|
|
403
|
+
disabled: s || a,
|
|
404
|
+
onClick: () => It(!L)
|
|
405
|
+
},
|
|
406
|
+
"trackChanges"
|
|
407
|
+
) : null;
|
|
408
|
+
if (e === "comments")
|
|
409
|
+
return u.comments ? /* @__PURE__ */ i(
|
|
410
|
+
C,
|
|
411
|
+
{
|
|
412
|
+
icon: p.comments,
|
|
413
|
+
title: "Comments",
|
|
414
|
+
active: X,
|
|
415
|
+
disabled: s || a,
|
|
416
|
+
onClick: () => {
|
|
417
|
+
X ? J(!1) : St();
|
|
418
|
+
}
|
|
419
|
+
},
|
|
420
|
+
"comments"
|
|
421
|
+
) : null;
|
|
422
|
+
if (e === "ai")
|
|
423
|
+
return !u.ai || !(d != null && d.enabled) ? null : /* @__PURE__ */ i(
|
|
424
|
+
C,
|
|
425
|
+
{
|
|
426
|
+
icon: p.ai,
|
|
427
|
+
title: "Ink AI",
|
|
428
|
+
active: de,
|
|
429
|
+
disabled: s || a,
|
|
430
|
+
onClick: () => z((r) => !r)
|
|
431
|
+
},
|
|
432
|
+
"ai"
|
|
433
|
+
);
|
|
434
|
+
const n = Ne[e];
|
|
435
|
+
return n ? /* @__PURE__ */ i(
|
|
174
436
|
C,
|
|
175
437
|
{
|
|
176
|
-
icon:
|
|
177
|
-
title:
|
|
178
|
-
active:
|
|
179
|
-
disabled:
|
|
180
|
-
onClick: () =>
|
|
438
|
+
icon: p[e] ?? e.slice(0, 1).toUpperCase(),
|
|
439
|
+
title: n.title,
|
|
440
|
+
active: ot.has(e),
|
|
441
|
+
disabled: s || a,
|
|
442
|
+
onClick: () => Lt(e)
|
|
181
443
|
},
|
|
182
|
-
|
|
444
|
+
e
|
|
183
445
|
) : null;
|
|
184
|
-
},
|
|
185
|
-
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(
|
|
186
448
|
"div",
|
|
187
449
|
{
|
|
188
|
-
className:
|
|
189
|
-
"data-testid":
|
|
190
|
-
"data-disabled":
|
|
191
|
-
|
|
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,
|
|
192
458
|
children: [
|
|
193
|
-
/* @__PURE__ */
|
|
194
|
-
/* @__PURE__ */
|
|
195
|
-
|
|
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,
|
|
196
462
|
{
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
"aria-placeholder": L,
|
|
203
|
-
"data-placeholder": L,
|
|
204
|
-
suppressContentEditableWarning: !0,
|
|
205
|
-
style: { minHeight: tt, maxHeight: et },
|
|
206
|
-
onInput: c,
|
|
207
|
-
onBlur: W,
|
|
208
|
-
onKeyUp: g,
|
|
209
|
-
onMouseUp: g,
|
|
210
|
-
onPaste: (t) => {
|
|
211
|
-
Y(t);
|
|
212
|
-
}
|
|
463
|
+
changes: k,
|
|
464
|
+
onAccept: Ie,
|
|
465
|
+
onReject: we,
|
|
466
|
+
onAcceptAll: () => k.forEach((e) => Ie(e.id)),
|
|
467
|
+
onRejectAll: () => k.forEach((e) => we(e.id))
|
|
213
468
|
}
|
|
214
|
-
),
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
469
|
+
) : null,
|
|
470
|
+
/* @__PURE__ */ F("div", { className: qt, children: [
|
|
471
|
+
/* @__PURE__ */ F("div", { className: zt, children: [
|
|
472
|
+
u.blocks ? /* @__PURE__ */ i(
|
|
473
|
+
Sn,
|
|
474
|
+
{
|
|
475
|
+
visible: kt && !s && !a,
|
|
476
|
+
top: gt,
|
|
477
|
+
onMoveUp: () => Le("up"),
|
|
478
|
+
onMoveDown: () => Le("down")
|
|
479
|
+
}
|
|
480
|
+
) : null,
|
|
481
|
+
/* @__PURE__ */ i(
|
|
482
|
+
"div",
|
|
483
|
+
{
|
|
484
|
+
ref: o,
|
|
485
|
+
className: Xt,
|
|
486
|
+
contentEditable: !s && !a,
|
|
487
|
+
role: "textbox",
|
|
488
|
+
"aria-multiline": "true",
|
|
489
|
+
"aria-placeholder": te,
|
|
490
|
+
"data-placeholder": te,
|
|
491
|
+
suppressContentEditableWarning: !0,
|
|
492
|
+
style: { minHeight: Rt, maxHeight: Bt },
|
|
493
|
+
onInput: l,
|
|
494
|
+
onBlur: At,
|
|
495
|
+
onKeyUp: K,
|
|
496
|
+
onKeyDown: _t,
|
|
497
|
+
onMouseUp: K,
|
|
498
|
+
onPaste: (e) => {
|
|
499
|
+
vt(e);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
),
|
|
503
|
+
ge ? /* @__PURE__ */ i(
|
|
504
|
+
vn,
|
|
505
|
+
{
|
|
506
|
+
items: Tt,
|
|
507
|
+
top: pe.top,
|
|
508
|
+
left: pe.left,
|
|
509
|
+
onSelect: Et
|
|
510
|
+
}
|
|
511
|
+
) : null
|
|
512
|
+
] }),
|
|
513
|
+
X && u.comments ? /* @__PURE__ */ i(
|
|
514
|
+
yn,
|
|
515
|
+
{
|
|
516
|
+
comments: E,
|
|
517
|
+
author: w,
|
|
518
|
+
onClose: () => J(!1),
|
|
519
|
+
onResolve: (e) => {
|
|
520
|
+
const t = E.find((n) => n.id === e);
|
|
521
|
+
Y(
|
|
522
|
+
E.map(
|
|
523
|
+
(n) => n.id === e ? { ...n, resolved: !0 } : n
|
|
524
|
+
)
|
|
525
|
+
), t && o.current && H(ln(o.current.innerHTML, t.highlightId));
|
|
526
|
+
},
|
|
527
|
+
onAddReply: (e, t) => {
|
|
528
|
+
Y(
|
|
529
|
+
E.map(
|
|
530
|
+
(n) => n.id === e ? {
|
|
531
|
+
...n,
|
|
532
|
+
replies: [
|
|
533
|
+
...n.replies,
|
|
534
|
+
{
|
|
535
|
+
id: ve("reply"),
|
|
536
|
+
author: w,
|
|
537
|
+
body: t,
|
|
538
|
+
timestamp: Date.now()
|
|
539
|
+
}
|
|
540
|
+
]
|
|
541
|
+
} : n
|
|
542
|
+
)
|
|
543
|
+
);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
) : null,
|
|
547
|
+
Dt && d ? /* @__PURE__ */ i(
|
|
548
|
+
Nn,
|
|
549
|
+
{
|
|
550
|
+
config: d,
|
|
551
|
+
documentHtml: ((He = o.current) == null ? void 0 : He.innerHTML) ?? h ?? "",
|
|
552
|
+
selectionHtml: fe,
|
|
553
|
+
onClose: () => z(!1),
|
|
554
|
+
onApplyHtml: (e) => {
|
|
555
|
+
var t;
|
|
556
|
+
if ((t = o.current) == null || t.focus(), fe)
|
|
557
|
+
I(e);
|
|
558
|
+
else {
|
|
559
|
+
H(e);
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
l();
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
) : null
|
|
566
|
+
] }),
|
|
567
|
+
oe ? /* @__PURE__ */ F("div", { className: Qt, children: [
|
|
568
|
+
st,
|
|
569
|
+
re ? ` / ${re}` : ""
|
|
218
570
|
] }) : null
|
|
219
571
|
]
|
|
220
572
|
}
|
|
221
573
|
);
|
|
222
574
|
};
|
|
223
575
|
export {
|
|
224
|
-
|
|
576
|
+
no as InkEditor
|
|
225
577
|
};
|