@forgedevstack/ink 1.0.0 → 1.1.0
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 +103 -38
- package/dist/components/InkEditor/InkEditor.cjs +1 -1
- package/dist/components/InkEditor/InkEditor.d.ts.map +1 -1
- package/dist/components/InkEditor/InkEditor.js +495 -156
- 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 +178 -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/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 +1 -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/index.cjs +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +32 -13
- 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 +515 -16
- 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 +5 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/ink.types.d.ts +26 -1
- package/dist/types/ink.types.d.ts.map +1 -1
- 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 +7 -0
- package/dist/utils/index.d.ts.map +1 -1
- 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,14 +1,26 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { INK_MIN_HEIGHT as
|
|
4
|
-
import { INK_PLACEHOLDER_DEFAULT as
|
|
5
|
-
import { cn as
|
|
6
|
-
import { applyTypoAutoFix as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
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 = {
|
|
12
24
|
bold: "B",
|
|
13
25
|
italic: "I",
|
|
14
26
|
underline: "U",
|
|
@@ -17,6 +29,12 @@ const I = {
|
|
|
17
29
|
orderedList: "1.",
|
|
18
30
|
link: "🔗",
|
|
19
31
|
image: "🖼",
|
|
32
|
+
table: "▦",
|
|
33
|
+
undo: "↶",
|
|
34
|
+
redo: "↷",
|
|
35
|
+
trackChanges: "±",
|
|
36
|
+
comments: "💬",
|
|
37
|
+
ai: "✦",
|
|
20
38
|
clearFormat: "⌫",
|
|
21
39
|
alignLeft: "⫷",
|
|
22
40
|
alignCenter: "☰",
|
|
@@ -26,200 +44,521 @@ const I = {
|
|
|
26
44
|
outdent: "←",
|
|
27
45
|
blockquote: "“",
|
|
28
46
|
code: "</>"
|
|
29
|
-
},
|
|
47
|
+
}, Q = () => {
|
|
48
|
+
const w = window.getSelection();
|
|
49
|
+
if (!w || w.rangeCount === 0) return "";
|
|
50
|
+
const h = w.getRangeAt(0), b = document.createElement("div");
|
|
51
|
+
return b.appendChild(h.cloneContents()), b.innerHTML;
|
|
52
|
+
}, En = (w) => {
|
|
53
|
+
var Ce;
|
|
30
54
|
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
|
-
|
|
55
|
+
value: h,
|
|
56
|
+
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,
|
|
79
|
+
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(() => {
|
|
96
|
+
!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));
|
|
52
99
|
}, []);
|
|
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
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
100
|
+
const q = (e) => {
|
|
101
|
+
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);
|
|
121
|
+
} else
|
|
122
|
+
ie(!1);
|
|
123
|
+
}, u = () => {
|
|
124
|
+
var t, n, r;
|
|
125
|
+
if (!o.current) return;
|
|
126
|
+
let e = o.current.innerHTML;
|
|
127
|
+
if (I && s.trackChanges) {
|
|
128
|
+
const a = window.getSelection();
|
|
129
|
+
if (a && !a.isCollapsed) {
|
|
130
|
+
const f = Q();
|
|
131
|
+
if (f) {
|
|
132
|
+
const T = J("delete", f, L);
|
|
133
|
+
v([...k, T]), rt(T.id), e = o.current.innerHTML;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
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);
|
|
139
|
+
if (f !== null) {
|
|
140
|
+
O(Xt(f));
|
|
141
|
+
const T = (r = window.getSelection()) == null ? void 0 : r.getRangeAt(0);
|
|
142
|
+
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
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
} else
|
|
150
|
+
O([]);
|
|
151
|
+
}
|
|
152
|
+
}, rt = (e) => {
|
|
153
|
+
const t = window.getSelection();
|
|
154
|
+
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) => {
|
|
162
|
+
var n;
|
|
163
|
+
if (c || l) return;
|
|
164
|
+
(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) => {
|
|
168
|
+
var t;
|
|
169
|
+
c || l || ((t = o.current) == null || t.focus(), p("formatBlock", e), te(e), u());
|
|
170
|
+
}, it = () => {
|
|
171
|
+
var t;
|
|
172
|
+
if (c || l) return;
|
|
173
|
+
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;
|
|
177
|
+
const e = document.createElement("input");
|
|
178
|
+
e.type = "file", e.accept = "image/*", e.onchange = async () => {
|
|
179
|
+
var r, a;
|
|
180
|
+
const t = (r = e.files) == null ? void 0 : r[0];
|
|
181
|
+
if (!t) return;
|
|
182
|
+
const n = await we(t);
|
|
183
|
+
(a = o.current) == null || a.focus(), Ne(n, t.name), u();
|
|
184
|
+
}, e.click();
|
|
185
|
+
}, de = () => {
|
|
186
|
+
var t;
|
|
187
|
+
if (c || l || !s.table) return;
|
|
188
|
+
(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));
|
|
193
|
+
} else
|
|
194
|
+
R(e);
|
|
195
|
+
u();
|
|
196
|
+
}, me = () => {
|
|
197
|
+
const e = x.current.undo();
|
|
198
|
+
if (e === null || !o.current) {
|
|
199
|
+
p("undo"), u();
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
A(e);
|
|
203
|
+
}, fe = () => {
|
|
204
|
+
const e = x.current.redo();
|
|
205
|
+
if (e === null || !o.current) {
|
|
206
|
+
p("redo"), u();
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
A(e);
|
|
210
|
+
}, ut = () => {
|
|
211
|
+
var a;
|
|
212
|
+
if (c || l || !s.comments) return;
|
|
213
|
+
const e = window.prompt("Comment:");
|
|
214
|
+
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) => {
|
|
220
|
+
if (!o.current) return;
|
|
221
|
+
const t = Vt(o.current.innerHTML, e);
|
|
222
|
+
A(t), v(
|
|
223
|
+
k.map((n) => n.id === e ? { ...n, accepted: !0 } : n)
|
|
224
|
+
);
|
|
225
|
+
}, pe = (e) => {
|
|
226
|
+
if (!o.current) return;
|
|
227
|
+
const t = Pt(o.current.innerHTML, e);
|
|
228
|
+
A(t), v(
|
|
229
|
+
k.map((n) => n.id === e ? { ...n, rejected: !0 } : n)
|
|
230
|
+
);
|
|
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)) {
|
|
237
|
+
if (!r.type.startsWith("image/")) continue;
|
|
238
|
+
e.preventDefault();
|
|
239
|
+
const a = r.getAsFile();
|
|
99
240
|
if (!a) continue;
|
|
100
|
-
const
|
|
101
|
-
|
|
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();
|
|
102
248
|
}
|
|
103
|
-
},
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
249
|
+
}, mt = (e) => {
|
|
250
|
+
e.key === "Escape" && O([]), (e.metaKey || e.ctrlKey) && e.key === "z" && (e.preventDefault(), e.shiftKey ? fe() : me());
|
|
251
|
+
}, ft = (e) => {
|
|
252
|
+
var n, r;
|
|
253
|
+
(n = o.current) == null || n.focus();
|
|
254
|
+
const t = window.getSelection();
|
|
255
|
+
if ((r = t == null ? void 0 : t.anchorNode) != null && r.textContent) {
|
|
256
|
+
const f = t.anchorNode.textContent.replace(/(?:^|\s)\/[^\s]*$/, " ");
|
|
257
|
+
t.anchorNode.nodeType === Node.TEXT_NODE && (t.anchorNode.textContent = f);
|
|
258
|
+
}
|
|
259
|
+
switch (O([]), e.insert) {
|
|
260
|
+
case "heading1":
|
|
261
|
+
p("formatBlock", "h1");
|
|
262
|
+
break;
|
|
263
|
+
case "heading2":
|
|
264
|
+
p("formatBlock", "h2");
|
|
265
|
+
break;
|
|
266
|
+
case "bulletList":
|
|
267
|
+
p("insertUnorderedList");
|
|
268
|
+
break;
|
|
269
|
+
case "orderedList":
|
|
270
|
+
p("insertOrderedList");
|
|
271
|
+
break;
|
|
272
|
+
case "table":
|
|
273
|
+
de();
|
|
274
|
+
return;
|
|
275
|
+
case "ai":
|
|
276
|
+
G(!0);
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
u();
|
|
280
|
+
}, ge = (e) => {
|
|
281
|
+
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) => {
|
|
285
|
+
if (e === "divider")
|
|
286
|
+
return /* @__PURE__ */ i("span", { className: Bt }, `divider-${t}`);
|
|
287
|
+
if (e === "headingDropdown")
|
|
288
|
+
return /* @__PURE__ */ i(
|
|
289
|
+
en,
|
|
109
290
|
{
|
|
110
291
|
title: "Heading",
|
|
111
|
-
options:
|
|
112
|
-
value:
|
|
113
|
-
disabled:
|
|
114
|
-
onChange:
|
|
292
|
+
options: xt,
|
|
293
|
+
value: Pe || "p",
|
|
294
|
+
disabled: c || l,
|
|
295
|
+
onChange: at
|
|
115
296
|
},
|
|
116
297
|
"heading"
|
|
117
298
|
);
|
|
118
|
-
if (
|
|
119
|
-
return /* @__PURE__ */
|
|
120
|
-
|
|
299
|
+
if (e === "textColor")
|
|
300
|
+
return /* @__PURE__ */ i(
|
|
301
|
+
Se,
|
|
121
302
|
{
|
|
122
303
|
title: "Text color",
|
|
123
304
|
type: "text",
|
|
124
|
-
value:
|
|
125
|
-
disabled:
|
|
126
|
-
onChange: (
|
|
305
|
+
value: $e,
|
|
306
|
+
disabled: c || l,
|
|
307
|
+
onChange: (r) => {
|
|
127
308
|
var a;
|
|
128
|
-
(a =
|
|
309
|
+
(a = o.current) == null || a.focus(), zt(r), Ge(r), u();
|
|
129
310
|
}
|
|
130
311
|
},
|
|
131
312
|
"textColor"
|
|
132
313
|
);
|
|
133
|
-
if (
|
|
134
|
-
return /* @__PURE__ */
|
|
135
|
-
|
|
314
|
+
if (e === "highlightColor")
|
|
315
|
+
return /* @__PURE__ */ i(
|
|
316
|
+
Se,
|
|
136
317
|
{
|
|
137
318
|
title: "Highlight color",
|
|
138
319
|
type: "highlight",
|
|
139
|
-
value:
|
|
140
|
-
disabled:
|
|
141
|
-
onChange: (
|
|
320
|
+
value: We,
|
|
321
|
+
disabled: c || l,
|
|
322
|
+
onChange: (r) => {
|
|
142
323
|
var a;
|
|
143
|
-
(a =
|
|
324
|
+
(a = o.current) == null || a.focus(), Jt(r), qe(r), u();
|
|
144
325
|
}
|
|
145
326
|
},
|
|
146
327
|
"highlightColor"
|
|
147
328
|
);
|
|
148
|
-
if (
|
|
149
|
-
return /* @__PURE__ */
|
|
150
|
-
|
|
329
|
+
if (e === "link")
|
|
330
|
+
return /* @__PURE__ */ i(
|
|
331
|
+
g,
|
|
151
332
|
{
|
|
152
|
-
icon:
|
|
333
|
+
icon: C.link,
|
|
153
334
|
title: "Insert link",
|
|
154
|
-
disabled:
|
|
155
|
-
onClick:
|
|
335
|
+
disabled: c || l,
|
|
336
|
+
onClick: it
|
|
156
337
|
},
|
|
157
338
|
"link"
|
|
158
339
|
);
|
|
159
|
-
if (
|
|
160
|
-
return /* @__PURE__ */
|
|
161
|
-
|
|
340
|
+
if (e === "image")
|
|
341
|
+
return /* @__PURE__ */ i(
|
|
342
|
+
g,
|
|
162
343
|
{
|
|
163
|
-
icon:
|
|
344
|
+
icon: C.image,
|
|
164
345
|
title: "Insert image",
|
|
165
|
-
disabled:
|
|
346
|
+
disabled: c || l,
|
|
166
347
|
onClick: () => {
|
|
167
|
-
|
|
348
|
+
st();
|
|
168
349
|
}
|
|
169
350
|
},
|
|
170
351
|
"image"
|
|
171
352
|
);
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
353
|
+
if (e === "table")
|
|
354
|
+
return s.table ? /* @__PURE__ */ i(
|
|
355
|
+
g,
|
|
356
|
+
{
|
|
357
|
+
icon: C.table,
|
|
358
|
+
title: "Insert table",
|
|
359
|
+
disabled: c || l,
|
|
360
|
+
onClick: de
|
|
361
|
+
},
|
|
362
|
+
"table"
|
|
363
|
+
) : null;
|
|
364
|
+
if (e === "undo")
|
|
365
|
+
return /* @__PURE__ */ i(
|
|
366
|
+
g,
|
|
367
|
+
{
|
|
368
|
+
icon: C.undo,
|
|
369
|
+
title: "Undo",
|
|
370
|
+
disabled: c || l,
|
|
371
|
+
onClick: me
|
|
372
|
+
},
|
|
373
|
+
"undo"
|
|
374
|
+
);
|
|
375
|
+
if (e === "redo")
|
|
376
|
+
return /* @__PURE__ */ i(
|
|
377
|
+
g,
|
|
378
|
+
{
|
|
379
|
+
icon: C.redo,
|
|
380
|
+
title: "Redo",
|
|
381
|
+
disabled: c || l,
|
|
382
|
+
onClick: fe
|
|
383
|
+
},
|
|
384
|
+
"redo"
|
|
385
|
+
);
|
|
386
|
+
if (e === "trackChanges")
|
|
387
|
+
return s.trackChanges ? /* @__PURE__ */ i(
|
|
388
|
+
g,
|
|
389
|
+
{
|
|
390
|
+
icon: C.trackChanges,
|
|
391
|
+
title: "Track changes",
|
|
392
|
+
active: I,
|
|
393
|
+
disabled: c || l,
|
|
394
|
+
onClick: () => ot(!I)
|
|
395
|
+
},
|
|
396
|
+
"trackChanges"
|
|
397
|
+
) : null;
|
|
398
|
+
if (e === "comments")
|
|
399
|
+
return s.comments ? /* @__PURE__ */ i(
|
|
400
|
+
g,
|
|
401
|
+
{
|
|
402
|
+
icon: C.comments,
|
|
403
|
+
title: "Comments",
|
|
404
|
+
active: W,
|
|
405
|
+
disabled: c || l,
|
|
406
|
+
onClick: () => {
|
|
407
|
+
W ? z(!1) : ut();
|
|
408
|
+
}
|
|
409
|
+
},
|
|
410
|
+
"comments"
|
|
411
|
+
) : null;
|
|
412
|
+
if (e === "ai")
|
|
413
|
+
return !s.ai || !(m != null && m.enabled) ? null : /* @__PURE__ */ i(
|
|
414
|
+
g,
|
|
415
|
+
{
|
|
416
|
+
icon: C.ai,
|
|
417
|
+
title: "Ink AI",
|
|
418
|
+
active: le,
|
|
419
|
+
disabled: c || l,
|
|
420
|
+
onClick: () => G((r) => !r)
|
|
421
|
+
},
|
|
422
|
+
"ai"
|
|
423
|
+
);
|
|
424
|
+
const n = be[e];
|
|
425
|
+
return n ? /* @__PURE__ */ i(
|
|
426
|
+
g,
|
|
175
427
|
{
|
|
176
|
-
icon:
|
|
177
|
-
title:
|
|
178
|
-
active:
|
|
179
|
-
disabled:
|
|
180
|
-
onClick: () =>
|
|
428
|
+
icon: C[e] ?? e.slice(0, 1).toUpperCase(),
|
|
429
|
+
title: n.title,
|
|
430
|
+
active: Fe.has(e),
|
|
431
|
+
disabled: c || l,
|
|
432
|
+
onClick: () => lt(e)
|
|
181
433
|
},
|
|
182
|
-
|
|
434
|
+
e
|
|
183
435
|
) : null;
|
|
184
|
-
},
|
|
185
|
-
return /* @__PURE__ */
|
|
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(
|
|
186
438
|
"div",
|
|
187
439
|
{
|
|
188
|
-
className:
|
|
189
|
-
"data-testid":
|
|
190
|
-
"data-disabled":
|
|
191
|
-
|
|
440
|
+
className: Dt(Ot, Ee),
|
|
441
|
+
"data-testid": ve,
|
|
442
|
+
"data-disabled": c || void 0,
|
|
443
|
+
"data-variant": Be,
|
|
444
|
+
...Ue,
|
|
192
445
|
children: [
|
|
193
|
-
/* @__PURE__ */
|
|
194
|
-
/* @__PURE__ */
|
|
195
|
-
|
|
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,
|
|
196
449
|
{
|
|
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
|
-
}
|
|
450
|
+
changes: k,
|
|
451
|
+
onAccept: he,
|
|
452
|
+
onReject: pe,
|
|
453
|
+
onAcceptAll: () => k.forEach((e) => he(e.id)),
|
|
454
|
+
onRejectAll: () => k.forEach((e) => pe(e.id))
|
|
213
455
|
}
|
|
214
|
-
),
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
456
|
+
) : null,
|
|
457
|
+
/* @__PURE__ */ K("div", { className: Et, children: [
|
|
458
|
+
/* @__PURE__ */ K("div", { className: vt, children: [
|
|
459
|
+
s.blocks ? /* @__PURE__ */ i(
|
|
460
|
+
on,
|
|
461
|
+
{
|
|
462
|
+
visible: et && !c && !l,
|
|
463
|
+
top: Ye,
|
|
464
|
+
onMoveUp: () => ge("up"),
|
|
465
|
+
onMoveDown: () => ge("down")
|
|
466
|
+
}
|
|
467
|
+
) : null,
|
|
468
|
+
/* @__PURE__ */ i(
|
|
469
|
+
"div",
|
|
470
|
+
{
|
|
471
|
+
ref: o,
|
|
472
|
+
className: yt,
|
|
473
|
+
contentEditable: !c && !l,
|
|
474
|
+
role: "textbox",
|
|
475
|
+
"aria-multiline": "true",
|
|
476
|
+
"aria-placeholder": Y,
|
|
477
|
+
"data-placeholder": Y,
|
|
478
|
+
suppressContentEditableWarning: !0,
|
|
479
|
+
style: { minHeight: pt, maxHeight: gt },
|
|
480
|
+
onInput: u,
|
|
481
|
+
onBlur: ct,
|
|
482
|
+
onKeyUp: D,
|
|
483
|
+
onKeyDown: mt,
|
|
484
|
+
onMouseUp: D,
|
|
485
|
+
onPaste: (e) => {
|
|
486
|
+
dt(e);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
),
|
|
490
|
+
ue ? /* @__PURE__ */ i(
|
|
491
|
+
rn,
|
|
492
|
+
{
|
|
493
|
+
items: tt,
|
|
494
|
+
top: se.top,
|
|
495
|
+
left: se.left,
|
|
496
|
+
onSelect: ft
|
|
497
|
+
}
|
|
498
|
+
) : null
|
|
499
|
+
] }),
|
|
500
|
+
W && s.comments ? /* @__PURE__ */ i(
|
|
501
|
+
tn,
|
|
502
|
+
{
|
|
503
|
+
comments: E,
|
|
504
|
+
author: L,
|
|
505
|
+
onClose: () => z(!1),
|
|
506
|
+
onResolve: (e) => {
|
|
507
|
+
const t = E.find((n) => n.id === e);
|
|
508
|
+
X(
|
|
509
|
+
E.map(
|
|
510
|
+
(n) => n.id === e ? { ...n, resolved: !0 } : n
|
|
511
|
+
)
|
|
512
|
+
), t && o.current && A($t(o.current.innerHTML, t.highlightId));
|
|
513
|
+
},
|
|
514
|
+
onAddReply: (e, t) => {
|
|
515
|
+
X(
|
|
516
|
+
E.map(
|
|
517
|
+
(n) => n.id === e ? {
|
|
518
|
+
...n,
|
|
519
|
+
replies: [
|
|
520
|
+
...n.replies,
|
|
521
|
+
{
|
|
522
|
+
id: Le("reply"),
|
|
523
|
+
author: L,
|
|
524
|
+
body: t,
|
|
525
|
+
timestamp: Date.now()
|
|
526
|
+
}
|
|
527
|
+
]
|
|
528
|
+
} : n
|
|
529
|
+
)
|
|
530
|
+
);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
) : null,
|
|
534
|
+
Ct && m ? /* @__PURE__ */ i(
|
|
535
|
+
nn,
|
|
536
|
+
{
|
|
537
|
+
config: m,
|
|
538
|
+
documentHtml: ((Ce = o.current) == null ? void 0 : Ce.innerHTML) ?? h ?? "",
|
|
539
|
+
selectionHtml: ae,
|
|
540
|
+
onClose: () => G(!1),
|
|
541
|
+
onApplyHtml: (e) => {
|
|
542
|
+
var t;
|
|
543
|
+
if ((t = o.current) == null || t.focus(), ae)
|
|
544
|
+
R(e);
|
|
545
|
+
else {
|
|
546
|
+
A(e);
|
|
547
|
+
return;
|
|
548
|
+
}
|
|
549
|
+
u();
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
) : null
|
|
553
|
+
] }),
|
|
554
|
+
Z ? /* @__PURE__ */ K("div", { className: Rt, children: [
|
|
555
|
+
Ve,
|
|
556
|
+
ee ? ` / ${ee}` : ""
|
|
218
557
|
] }) : null
|
|
219
558
|
]
|
|
220
559
|
}
|
|
221
560
|
);
|
|
222
561
|
};
|
|
223
562
|
export {
|
|
224
|
-
|
|
563
|
+
En as InkEditor
|
|
225
564
|
};
|