@graphysdk/react-renderer 1.9.0-beta.1795708068076 → 1.9.0-beta.1795773309240
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/editable.cjs +1 -1
- package/dist/editable.css +1 -1
- package/dist/editable.d.ts +155 -1
- package/dist/editable.mjs +3385 -7201
- package/dist/history-chords-B2-10FJz.cjs +2 -0
- package/dist/{history-chords-Buxa3waC.js → history-chords-D0dxpjAS.js} +1778 -1804
- package/dist/history-chords.css +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +0 -7
- package/dist/index.mjs +163 -163
- package/dist/rich-text-editor-module-Bwgb_RyF.js +891 -0
- package/dist/rich-text-editor-module-q1jI1hQi.cjs +1 -0
- package/dist/rich-text-editor-module.css +1 -1
- package/dist/start-arrow-button-B1mfKZVJ.cjs +1 -0
- package/dist/start-arrow-button-B3eETYt0.js +5506 -0
- package/dist/start-arrow-button.css +1 -1
- package/package.json +4 -4
- package/dist/history-chords-DDZ_6FBc.cjs +0 -2
- package/dist/rich-text-editor-module-BjO3665Z.js +0 -974
- package/dist/rich-text-editor-module-DiUIhnGd.cjs +0 -1
- package/dist/start-arrow-button-CGhJeFr2.js +0 -1569
- package/dist/start-arrow-button-DjGnXDVD.cjs +0 -1
|
@@ -0,0 +1,891 @@
|
|
|
1
|
+
import { $ as Ht, Bn as A, Cr as _t, Lt as Rt, Mr as Dt, Rn as st, Tn as Bt, Tr as Q, Y as Ut, Zt as x, _ as jt, at as Wt, dt as U, et as $t, h as Gt, it as Kt, n as V, nn as Xt, ot as tt, q as L, rn as Vt, rt as Jt, ut as Yt, zt as ct } from "./history-chords-D0dxpjAS.js";
|
|
2
|
+
import { Bt as Zt, M as qt, Q as Qt, Qt as te, _, a as d, b as ee, c as ne, g as re, h as oe, i as ae, j as ie, m as le, n as se, on as dt, r as ce, s as de, t as ue, v as ut, x as fe, y as ft } from "./start-arrow-button-B3eETYt0.js";
|
|
3
|
+
import { AUTO_COLOR as et, SetContentCaptionCommand as he, SetContentSubtitleCommand as pe, SetContentTitleCommand as me, SetStyleRuleCommand as ge, TEXT_ANNOTATION_FADE_ALPHA as ve, UpdateAnnotationCommand as ht, alignUnitFractions as be, findStyleRule as ye, readStyleCoord as Te, resolveTextAnnotationStyle as ke, toPaintColor as nt } from "@graphysdk/viz-engine";
|
|
4
|
+
import { useEffect as k, useLayoutEffect as pt, useMemo as E, useRef as R, useState as K } from "react";
|
|
5
|
+
import { Fragment as mt, jsx as e, jsxs as h } from "react/jsx-runtime";
|
|
6
|
+
import { EditorContent as gt, useEditor as xe, useEditorState as I } from "@tiptap/react";
|
|
7
|
+
import { Extension as vt } from "@tiptap/core";
|
|
8
|
+
import { Bold as Se } from "@tiptap/extension-bold";
|
|
9
|
+
import { Document as D } from "@tiptap/extension-document";
|
|
10
|
+
import { HardBreak as Ce } from "@tiptap/extension-hard-break";
|
|
11
|
+
import { Heading as Ae } from "@tiptap/extension-heading";
|
|
12
|
+
import { Italic as Fe } from "@tiptap/extension-italic";
|
|
13
|
+
import { Link as Ee } from "@tiptap/extension-link";
|
|
14
|
+
import { Text as Le } from "@tiptap/extension-text";
|
|
15
|
+
import { TextAlign as ze } from "@tiptap/extension-text-align";
|
|
16
|
+
import { Color as Ne, FontFamily as bt, TextStyle as Ie } from "@tiptap/extension-text-style";
|
|
17
|
+
import { Underline as Me } from "@tiptap/extension-underline";
|
|
18
|
+
import { Placeholder as J, UndoRedo as Pe } from "@tiptap/extensions";
|
|
19
|
+
import { Paragraph as yt } from "@tiptap/extension-paragraph";
|
|
20
|
+
import './rich-text-editor-module.css';var Tt = (t) => /* @__PURE__ */ e(L, {
|
|
21
|
+
...t,
|
|
22
|
+
children: /* @__PURE__ */ h("g", {
|
|
23
|
+
stroke: "currentColor",
|
|
24
|
+
strokeWidth: 2,
|
|
25
|
+
strokeLinecap: "round",
|
|
26
|
+
strokeLinejoin: "round",
|
|
27
|
+
children: [
|
|
28
|
+
/* @__PURE__ */ e("path", { d: "M21 5H3" }),
|
|
29
|
+
/* @__PURE__ */ e("path", { d: "M17 12H7" }),
|
|
30
|
+
/* @__PURE__ */ e("path", { d: "M19 19H5" })
|
|
31
|
+
]
|
|
32
|
+
})
|
|
33
|
+
}), kt = (t) => /* @__PURE__ */ e(L, {
|
|
34
|
+
...t,
|
|
35
|
+
children: /* @__PURE__ */ h("g", {
|
|
36
|
+
stroke: "currentColor",
|
|
37
|
+
strokeWidth: 2,
|
|
38
|
+
strokeLinecap: "round",
|
|
39
|
+
strokeLinejoin: "round",
|
|
40
|
+
children: [
|
|
41
|
+
/* @__PURE__ */ e("path", { d: "M21 5H3" }),
|
|
42
|
+
/* @__PURE__ */ e("path", { d: "M21 12H9" }),
|
|
43
|
+
/* @__PURE__ */ e("path", { d: "M21 19H7" })
|
|
44
|
+
]
|
|
45
|
+
})
|
|
46
|
+
}), xt = (t) => /* @__PURE__ */ e(L, {
|
|
47
|
+
...t,
|
|
48
|
+
children: /* @__PURE__ */ h("g", {
|
|
49
|
+
stroke: "currentColor",
|
|
50
|
+
strokeWidth: 2,
|
|
51
|
+
strokeLinecap: "round",
|
|
52
|
+
strokeLinejoin: "round",
|
|
53
|
+
children: [
|
|
54
|
+
/* @__PURE__ */ e("path", { d: "M21 5H3" }),
|
|
55
|
+
/* @__PURE__ */ e("path", { d: "M15 12H3" }),
|
|
56
|
+
/* @__PURE__ */ e("path", { d: "M17 19H3" })
|
|
57
|
+
]
|
|
58
|
+
})
|
|
59
|
+
}), Oe = ({ textColor: t, ...n }) => /* @__PURE__ */ h(L, {
|
|
60
|
+
...n,
|
|
61
|
+
children: [/* @__PURE__ */ h("g", {
|
|
62
|
+
stroke: "currentColor",
|
|
63
|
+
strokeWidth: 2,
|
|
64
|
+
strokeLinecap: "round",
|
|
65
|
+
children: [/* @__PURE__ */ e("path", { d: "M6 4h12" }), /* @__PURE__ */ e("path", { d: "M12 4v12" })]
|
|
66
|
+
}), /* @__PURE__ */ e("path", {
|
|
67
|
+
d: "M5 20h14",
|
|
68
|
+
stroke: t ?? "currentColor",
|
|
69
|
+
strokeWidth: 3,
|
|
70
|
+
strokeLinecap: "round"
|
|
71
|
+
})]
|
|
72
|
+
});
|
|
73
|
+
var St = [
|
|
74
|
+
{
|
|
75
|
+
id: "modern",
|
|
76
|
+
key: "graph.annotations.textToolbar.font.modern"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
id: "fresh",
|
|
80
|
+
key: "graph.annotations.textToolbar.font.fresh"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
id: "timeless",
|
|
84
|
+
key: "graph.annotations.textToolbar.font.timeless"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
id: "technical",
|
|
88
|
+
key: "graph.annotations.textToolbar.font.technical"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
id: "fineliner",
|
|
92
|
+
key: "graph.annotations.textToolbar.font.fineliner"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
id: "handwritten",
|
|
96
|
+
key: "graph.annotations.textToolbar.font.handwritten"
|
|
97
|
+
}
|
|
98
|
+
].map(({ id: t, key: n }) => ({
|
|
99
|
+
id: t,
|
|
100
|
+
key: n,
|
|
101
|
+
fontFamily: Rt[t] ?? t
|
|
102
|
+
})), we = (t) => St.find((n) => n.id === (t ?? "modern")) ?? null;
|
|
103
|
+
var Ct = [
|
|
104
|
+
{
|
|
105
|
+
size: 12,
|
|
106
|
+
key: "graph.annotations.textToolbar.fontSize.small"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
size: 15,
|
|
110
|
+
key: "graph.annotations.textToolbar.fontSize.medium"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
size: 18,
|
|
114
|
+
key: "graph.annotations.textToolbar.fontSize.large"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
size: 24,
|
|
118
|
+
key: "graph.annotations.textToolbar.fontSize.extraLarge"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
size: 30,
|
|
122
|
+
key: "graph.annotations.textToolbar.fontSize.huge"
|
|
123
|
+
}
|
|
124
|
+
], He = (t) => Ct.find((n) => n.size === (t ?? 15)) ?? null, _e = (t) => `${t}px`, Re = [
|
|
125
|
+
{
|
|
126
|
+
alignment: "left",
|
|
127
|
+
Icon: xt
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
alignment: "center",
|
|
131
|
+
Icon: Tt
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
alignment: "right",
|
|
135
|
+
Icon: kt
|
|
136
|
+
}
|
|
137
|
+
], Un = ({ annotation: t, textBox: n, panelRect: r, frameElement: l }) => {
|
|
138
|
+
const o = x(), { commands: i } = Dt(), s = Qt(r), c = Q((a) => a.spec.styles.overrides), u = Q((a) => Te(a.spec)), f = U(), p = se(), S = ie(), g = ke(_t(), t.id), v = ee(t.content), m = Yt((a) => a.caret?.editor ?? null), j = I({
|
|
139
|
+
editor: m,
|
|
140
|
+
selector: () => ft(m)
|
|
141
|
+
}), y = I({
|
|
142
|
+
editor: m,
|
|
143
|
+
selector: () => ut(m)
|
|
144
|
+
}), C = we(v.font ?? y), z = He(v.fontSize ?? j), F = Gt(g), M = v.color ?? F, P = E(() => ({
|
|
145
|
+
target: "annotation",
|
|
146
|
+
kind: "text",
|
|
147
|
+
annotation: t.id
|
|
148
|
+
}), [t.id]), O = (a, b) => {
|
|
149
|
+
const T = ye(c, { select: P }, u)?.declarations ?? {};
|
|
150
|
+
i.dispatch(new ge({
|
|
151
|
+
list: "overrides",
|
|
152
|
+
rule: {
|
|
153
|
+
select: P,
|
|
154
|
+
declarations: {
|
|
155
|
+
...T,
|
|
156
|
+
...a
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}), b);
|
|
160
|
+
}, W = (a, b) => {
|
|
161
|
+
i.dispatch(new ht({
|
|
162
|
+
kind: "text",
|
|
163
|
+
id: t.id,
|
|
164
|
+
patch: a
|
|
165
|
+
}), b);
|
|
166
|
+
}, N = () => f.getState().caret?.editor?.getJSON() ?? t.content, $ = (a, b) => {
|
|
167
|
+
const T = N(), H = f.getState().caret?.editor ?? null;
|
|
168
|
+
if (H !== null && !_(T)) {
|
|
169
|
+
H.chain().focus().setMark(le, a).run();
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
W({ content: re(T, a) }, b);
|
|
173
|
+
}, zt = () => {
|
|
174
|
+
s(t.id), l.focus({ preventScroll: !0 });
|
|
175
|
+
}, Nt = (a) => O(De(a), { transient: !0 }), It = (a) => O({ fillAlpha: a }, { transient: !0 }), w = g.fill !== dt, Mt = (a) => $({ color: a === et ? void 0 : a }, { transient: !0 }), Pt = (a) => () => {
|
|
176
|
+
_(N()) || q({ font: a }), $({ font: a }), p.close();
|
|
177
|
+
}, Ot = (a) => () => {
|
|
178
|
+
_(N()) || q({ fontSize: a }), $({ fontSize: a }), p.close();
|
|
179
|
+
}, q = (a) => {
|
|
180
|
+
const b = (n.x + be(t.align).x * n.width) / r.width, T = S({
|
|
181
|
+
annotationId: t.id,
|
|
182
|
+
anchorX: b,
|
|
183
|
+
align: t.align,
|
|
184
|
+
panelWidth: r.width,
|
|
185
|
+
minWidth: t.width,
|
|
186
|
+
pickedFontSize: a.fontSize ?? j,
|
|
187
|
+
pickedFont: a.font ?? y
|
|
188
|
+
});
|
|
189
|
+
T > t.width && W({ width: T });
|
|
190
|
+
}, wt = (a) => {
|
|
191
|
+
const b = f.getState().caret?.editor ?? null;
|
|
192
|
+
if (b === null || _(N())) {
|
|
193
|
+
W({ content: oe(N(), a) });
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
const T = b.state.storedMarks;
|
|
197
|
+
b.chain().focus().setTextAlign(a).command(({ tr: H }) => (H.setStoredMarks(T), !0)).run();
|
|
198
|
+
};
|
|
199
|
+
return /* @__PURE__ */ h(ce.Root, {
|
|
200
|
+
anchorBox: n,
|
|
201
|
+
panelRect: r,
|
|
202
|
+
frameElement: l,
|
|
203
|
+
label: o("graph.annotations.textToolbar.label"),
|
|
204
|
+
testId: "text-toolbar",
|
|
205
|
+
children: [
|
|
206
|
+
/* @__PURE__ */ e(d.ColorPicker, {
|
|
207
|
+
color: nt(g.fill),
|
|
208
|
+
label: o("graph.annotations.textToolbar.background"),
|
|
209
|
+
hasTransparentOption: !0,
|
|
210
|
+
onChange: Nt,
|
|
211
|
+
opacity: w ? g.fillAlpha : void 0,
|
|
212
|
+
onOpacityChange: w ? It : void 0,
|
|
213
|
+
...p.bind("background"),
|
|
214
|
+
children: /* @__PURE__ */ e(d.Swatch, {
|
|
215
|
+
color: w ? nt(g.fill) : ne,
|
|
216
|
+
opacity: w ? g.fillAlpha : void 0
|
|
217
|
+
})
|
|
218
|
+
}),
|
|
219
|
+
/* @__PURE__ */ e(d.ColorPicker, {
|
|
220
|
+
color: v.color ?? et,
|
|
221
|
+
label: o("graph.annotations.textToolbar.color"),
|
|
222
|
+
hasAutomaticOption: !0,
|
|
223
|
+
onChange: Mt,
|
|
224
|
+
...p.bind("color"),
|
|
225
|
+
children: /* @__PURE__ */ e(Oe, {
|
|
226
|
+
size: "sm",
|
|
227
|
+
textColor: M,
|
|
228
|
+
title: ""
|
|
229
|
+
})
|
|
230
|
+
}),
|
|
231
|
+
/* @__PURE__ */ e(d.Dropdown, {
|
|
232
|
+
label: o("graph.annotations.textToolbar.font.ariaLabel"),
|
|
233
|
+
trigger: /* @__PURE__ */ e("span", {
|
|
234
|
+
style: { fontFamily: C?.fontFamily },
|
|
235
|
+
children: "Aa"
|
|
236
|
+
}),
|
|
237
|
+
...p.bind("font"),
|
|
238
|
+
children: St.map((a) => /* @__PURE__ */ e(d.MenuItem, {
|
|
239
|
+
selected: a.id === C?.id,
|
|
240
|
+
onClick: Pt(a.id),
|
|
241
|
+
children: /* @__PURE__ */ e("span", {
|
|
242
|
+
style: { fontFamily: a.fontFamily },
|
|
243
|
+
children: o(a.key)
|
|
244
|
+
})
|
|
245
|
+
}, a.id))
|
|
246
|
+
}),
|
|
247
|
+
/* @__PURE__ */ e(d.Dropdown, {
|
|
248
|
+
label: o("graph.annotations.textToolbar.fontSize.ariaLabel"),
|
|
249
|
+
trigger: z === null ? "" : o(z.key),
|
|
250
|
+
...p.bind("fontSize"),
|
|
251
|
+
children: Ct.map((a) => /* @__PURE__ */ e(d.MenuItem, {
|
|
252
|
+
selected: a.size === z?.size,
|
|
253
|
+
onClick: Ot(a.size),
|
|
254
|
+
children: /* @__PURE__ */ e("span", {
|
|
255
|
+
style: { fontSize: _e(a.size) },
|
|
256
|
+
children: o(a.key)
|
|
257
|
+
})
|
|
258
|
+
}, a.size))
|
|
259
|
+
}),
|
|
260
|
+
/* @__PURE__ */ e(d.Separator, {}),
|
|
261
|
+
/* @__PURE__ */ e(Be, {
|
|
262
|
+
current: v.alignment ?? "center",
|
|
263
|
+
onPick: wt
|
|
264
|
+
}),
|
|
265
|
+
/* @__PURE__ */ e(d.Separator, {}),
|
|
266
|
+
/* @__PURE__ */ e(ue, { annotationId: t.id }),
|
|
267
|
+
/* @__PURE__ */ e(d.Button, {
|
|
268
|
+
label: o("graph.annotations.textToolbar.remove"),
|
|
269
|
+
onClick: zt,
|
|
270
|
+
children: /* @__PURE__ */ e(fe, {
|
|
271
|
+
size: "sm",
|
|
272
|
+
title: ""
|
|
273
|
+
})
|
|
274
|
+
})
|
|
275
|
+
]
|
|
276
|
+
});
|
|
277
|
+
}, De = (t) => t === "transparent" ? { fill: dt } : {
|
|
278
|
+
fill: t,
|
|
279
|
+
fillAlpha: de(t) ? ve : 1
|
|
280
|
+
}, Be = ({ current: t, onPick: n }) => {
|
|
281
|
+
const r = x(), l = (o) => () => n(o);
|
|
282
|
+
return /* @__PURE__ */ e(mt, { children: Re.map((o) => /* @__PURE__ */ e(d.Button, {
|
|
283
|
+
label: r(`graph.annotations.textToolbar.align.${o.alignment}`),
|
|
284
|
+
pressed: o.alignment === t,
|
|
285
|
+
onClick: l(o.alignment),
|
|
286
|
+
children: /* @__PURE__ */ e(o.Icon, {
|
|
287
|
+
size: "sm",
|
|
288
|
+
title: ""
|
|
289
|
+
})
|
|
290
|
+
}, o.alignment)) });
|
|
291
|
+
}, Ue = "data-variant", At = yt.extend({ addAttributes() {
|
|
292
|
+
return { variant: {
|
|
293
|
+
default: null,
|
|
294
|
+
parseHTML: (t) => t.getAttribute("data-variant") ?? null,
|
|
295
|
+
renderHTML: (t) => t.variant ? { [Ue]: t.variant } : {}
|
|
296
|
+
} };
|
|
297
|
+
} }), je = vt.create({
|
|
298
|
+
name: "preventBackspaceAcrossTitleBoundary",
|
|
299
|
+
addOptions() {
|
|
300
|
+
return { showTitle: !0 };
|
|
301
|
+
},
|
|
302
|
+
addKeyboardShortcuts() {
|
|
303
|
+
return { Backspace: ({ editor: t }) => {
|
|
304
|
+
if (!this.options.showTitle) return !1;
|
|
305
|
+
const { selection: n } = t.state;
|
|
306
|
+
if (!n.empty) return !1;
|
|
307
|
+
const { $from: r } = n;
|
|
308
|
+
return r.depth !== 1 || r.parentOffset !== 0 ? !1 : r.index(0) === 1;
|
|
309
|
+
} };
|
|
310
|
+
}
|
|
311
|
+
}), Y = () => [
|
|
312
|
+
Le,
|
|
313
|
+
Pe,
|
|
314
|
+
Ae.configure({ levels: [
|
|
315
|
+
1,
|
|
316
|
+
2,
|
|
317
|
+
3
|
|
318
|
+
] }),
|
|
319
|
+
Se,
|
|
320
|
+
Fe,
|
|
321
|
+
Me,
|
|
322
|
+
ze.configure({ types: ["heading", "paragraph"] }),
|
|
323
|
+
Ee.configure({
|
|
324
|
+
openOnClick: !1,
|
|
325
|
+
autolink: !0
|
|
326
|
+
}),
|
|
327
|
+
Ie,
|
|
328
|
+
Ne,
|
|
329
|
+
Ce
|
|
330
|
+
], We = ({ titlePlaceholder: t, subtitlePlaceholder: n, showTitle: r, showSubtitle: l }) => [
|
|
331
|
+
Ge({
|
|
332
|
+
showTitle: r,
|
|
333
|
+
showSubtitle: l
|
|
334
|
+
}),
|
|
335
|
+
At,
|
|
336
|
+
...Y(),
|
|
337
|
+
bt,
|
|
338
|
+
je.configure({ showTitle: r }),
|
|
339
|
+
J.configure({
|
|
340
|
+
showOnlyCurrent: !1,
|
|
341
|
+
placeholder: ({ pos: o, editor: i }) => {
|
|
342
|
+
if (r && o === 0) return t;
|
|
343
|
+
const s = r ? i.state.doc.firstChild?.nodeSize ?? -1 : 0;
|
|
344
|
+
return l && o === s ? n : "";
|
|
345
|
+
}
|
|
346
|
+
})
|
|
347
|
+
], $e = ({ placeholder: t }) => [
|
|
348
|
+
D,
|
|
349
|
+
At,
|
|
350
|
+
...Y(),
|
|
351
|
+
bt,
|
|
352
|
+
J.configure({
|
|
353
|
+
showOnlyCurrent: !1,
|
|
354
|
+
placeholder: ({ pos: n }) => n === 0 ? t : ""
|
|
355
|
+
})
|
|
356
|
+
], Ge = ({ showTitle: t, showSubtitle: n }) => t && n ? D.extend({ content: "block{2,}" }) : D, Ft = (t, n) => {
|
|
357
|
+
if (n === null) return;
|
|
358
|
+
let r = null;
|
|
359
|
+
try {
|
|
360
|
+
r = t.view.posAtCoords({
|
|
361
|
+
left: n.x,
|
|
362
|
+
top: n.y
|
|
363
|
+
});
|
|
364
|
+
} catch {
|
|
365
|
+
r = null;
|
|
366
|
+
}
|
|
367
|
+
t.commands.focus(r === null ? "end" : r.pos, { scrollIntoView: !1 });
|
|
368
|
+
}, Ke = "'Noto Serif', Georgia, 'Times New Roman', serif, 'Apple Color Emoji', 'NotoColorEmoji'", Xe = `'Aeonik', 'Aeonik Fallback', ${st}`, Ve = "'PT Mono', 'Courier New', monospace, 'Apple Color Emoji', 'NotoColorEmoji'", Je = "'Intruding Cat', cursive, 'Apple Color Emoji', 'NotoColorEmoji'", X = [
|
|
369
|
+
{
|
|
370
|
+
id: "modern",
|
|
371
|
+
label: "Modern",
|
|
372
|
+
preview: "Aa",
|
|
373
|
+
fontFamily: st
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
id: "fresh",
|
|
377
|
+
label: "Fresh",
|
|
378
|
+
preview: "Aa",
|
|
379
|
+
fontFamily: Xe
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
id: "timeless",
|
|
383
|
+
label: "Timeless",
|
|
384
|
+
preview: "Aa",
|
|
385
|
+
fontFamily: Ke
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
id: "technical",
|
|
389
|
+
label: "Technical",
|
|
390
|
+
preview: "00",
|
|
391
|
+
fontFamily: Ve
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
id: "fineliner",
|
|
395
|
+
label: "Fineliner",
|
|
396
|
+
preview: "Aa",
|
|
397
|
+
fontFamily: Je
|
|
398
|
+
}
|
|
399
|
+
], Ye = (t) => t ? X.find((n) => n.fontFamily === t) ?? null : null, Ze = ({ editor: t, currentFontFamily: n, open: r, onOpenChange: l }) => {
|
|
400
|
+
const o = x(), i = Ye(n) ?? X[0], s = (c) => {
|
|
401
|
+
t.chain().focus().setFontFamily(c.fontFamily).run();
|
|
402
|
+
};
|
|
403
|
+
return /* @__PURE__ */ e(d.Dropdown, {
|
|
404
|
+
label: o("graph.toolbar.font.ariaLabel"),
|
|
405
|
+
trigger: /* @__PURE__ */ e("span", {
|
|
406
|
+
style: { fontFamily: i?.fontFamily },
|
|
407
|
+
children: i?.preview
|
|
408
|
+
}),
|
|
409
|
+
open: r,
|
|
410
|
+
onOpenChange: l,
|
|
411
|
+
children: X.map((c) => /* @__PURE__ */ e(d.MenuItem, {
|
|
412
|
+
selected: c.id === i?.id,
|
|
413
|
+
onClick: () => s(c),
|
|
414
|
+
children: /* @__PURE__ */ e("span", {
|
|
415
|
+
style: { fontFamily: c.fontFamily },
|
|
416
|
+
children: c.label
|
|
417
|
+
})
|
|
418
|
+
}, c.id))
|
|
419
|
+
});
|
|
420
|
+
}, Et = {
|
|
421
|
+
id: "text",
|
|
422
|
+
translationKey: "graph.toolbar.heading.text",
|
|
423
|
+
previewFont: A.fontTextEditorBody
|
|
424
|
+
}, rt = [
|
|
425
|
+
{
|
|
426
|
+
id: "caption",
|
|
427
|
+
translationKey: "graph.toolbar.heading.caption",
|
|
428
|
+
previewFont: A.fontTextEditorH6
|
|
429
|
+
},
|
|
430
|
+
Et,
|
|
431
|
+
{
|
|
432
|
+
id: "h3",
|
|
433
|
+
translationKey: "graph.toolbar.heading.heading3",
|
|
434
|
+
previewFont: A.fontTextEditorH3
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
id: "h2",
|
|
438
|
+
translationKey: "graph.toolbar.heading.heading2",
|
|
439
|
+
previewFont: A.fontTextEditorH2
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
id: "h1",
|
|
443
|
+
translationKey: "graph.toolbar.heading.heading1",
|
|
444
|
+
previewFont: A.fontTextEditorH1
|
|
445
|
+
}
|
|
446
|
+
], qe = ({ editor: t, activeStyle: n, open: r, onOpenChange: l }) => {
|
|
447
|
+
const o = x(), i = rt.find((s) => s.id === n) ?? Et;
|
|
448
|
+
return /* @__PURE__ */ e(d.Dropdown, {
|
|
449
|
+
label: o("graph.toolbar.heading.ariaLabel"),
|
|
450
|
+
trigger: o(i.translationKey),
|
|
451
|
+
open: r,
|
|
452
|
+
onOpenChange: l,
|
|
453
|
+
children: rt.map((s) => /* @__PURE__ */ e(d.MenuItem, {
|
|
454
|
+
selected: s.id === i.id,
|
|
455
|
+
onClick: () => Qe(t, s.id),
|
|
456
|
+
children: /* @__PURE__ */ e(tn, {
|
|
457
|
+
font: s.previewFont,
|
|
458
|
+
children: o(s.translationKey)
|
|
459
|
+
})
|
|
460
|
+
}, s.id))
|
|
461
|
+
});
|
|
462
|
+
}, Qe = (t, n) => {
|
|
463
|
+
switch (n) {
|
|
464
|
+
case "caption":
|
|
465
|
+
t.chain().focus().setNode("paragraph", { variant: "caption" }).run();
|
|
466
|
+
return;
|
|
467
|
+
case "text":
|
|
468
|
+
t.chain().focus().setNode("paragraph", { variant: null }).run();
|
|
469
|
+
return;
|
|
470
|
+
case "h1":
|
|
471
|
+
t.chain().focus().setHeading({ level: 1 }).run();
|
|
472
|
+
return;
|
|
473
|
+
case "h2":
|
|
474
|
+
t.chain().focus().setHeading({ level: 2 }).run();
|
|
475
|
+
return;
|
|
476
|
+
case "h3":
|
|
477
|
+
t.chain().focus().setHeading({ level: 3 }).run();
|
|
478
|
+
}
|
|
479
|
+
}, tn = ({ font: t, children: n }) => /* @__PURE__ */ e("span", {
|
|
480
|
+
style: {
|
|
481
|
+
font: t,
|
|
482
|
+
margin: 0
|
|
483
|
+
},
|
|
484
|
+
children: n
|
|
485
|
+
}), en = (t) => /* @__PURE__ */ e(L, {
|
|
486
|
+
...t,
|
|
487
|
+
children: /* @__PURE__ */ h("g", {
|
|
488
|
+
stroke: "currentColor",
|
|
489
|
+
strokeWidth: 2,
|
|
490
|
+
strokeLinecap: "round",
|
|
491
|
+
strokeLinejoin: "round",
|
|
492
|
+
children: [/* @__PURE__ */ e("path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" }), /* @__PURE__ */ e("path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" })]
|
|
493
|
+
})
|
|
494
|
+
}), nn = (t) => /* @__PURE__ */ e(L, {
|
|
495
|
+
...t,
|
|
496
|
+
children: /* @__PURE__ */ h("g", {
|
|
497
|
+
stroke: "currentColor",
|
|
498
|
+
strokeWidth: 2,
|
|
499
|
+
strokeLinecap: "round",
|
|
500
|
+
strokeLinejoin: "round",
|
|
501
|
+
children: [/* @__PURE__ */ e("path", { d: "M18 6 6 18" }), /* @__PURE__ */ e("path", { d: "m6 6 12 12" })]
|
|
502
|
+
})
|
|
503
|
+
}), rn = (t) => !t.content || t.content.length === 0 ? !0 : t.content.every((n) => !n.content || n.content.length === 0), on = (t) => {
|
|
504
|
+
const { $from: n } = t.state.selection, r = n.parent.textContent, l = n.parentOffset, o = n.start();
|
|
505
|
+
let i = l;
|
|
506
|
+
for (; i > 0 && ot(r[i - 1]); ) i -= 1;
|
|
507
|
+
let s = l;
|
|
508
|
+
for (; s < r.length && ot(r[s]); ) s += 1;
|
|
509
|
+
return {
|
|
510
|
+
from: o + i,
|
|
511
|
+
to: o + s
|
|
512
|
+
};
|
|
513
|
+
}, ot = (t) => t !== void 0 && /\S/.test(t), an = "fop13s0", ln = "fop13s1 uz3g760", at = "fop13s2 l9kff6 l9kff3", sn = ({ editor: t, currentUrl: n, active: r, open: l, onOpenChange: o }) => {
|
|
514
|
+
const i = x(), [s, c] = K(""), u = R(null);
|
|
515
|
+
k(() => {
|
|
516
|
+
l && c(n ?? "");
|
|
517
|
+
}, [l, n]);
|
|
518
|
+
const f = () => {
|
|
519
|
+
cn(t, s), o(!1);
|
|
520
|
+
}, p = () => {
|
|
521
|
+
c(""), o(!1);
|
|
522
|
+
}, S = (v) => {
|
|
523
|
+
c(v.target.value);
|
|
524
|
+
}, g = (v) => {
|
|
525
|
+
v.key === "Enter" && (v.preventDefault(), f());
|
|
526
|
+
};
|
|
527
|
+
return /* @__PURE__ */ h(d.Submenu, {
|
|
528
|
+
open: l,
|
|
529
|
+
onOpenChange: o,
|
|
530
|
+
children: [/* @__PURE__ */ e(d.SubmenuTrigger, {
|
|
531
|
+
label: i("graph.toolbar.formatting.link"),
|
|
532
|
+
pressed: r,
|
|
533
|
+
children: /* @__PURE__ */ e(en, {})
|
|
534
|
+
}), /* @__PURE__ */ e(d.SubmenuContent, {
|
|
535
|
+
align: "end",
|
|
536
|
+
initialFocus: u,
|
|
537
|
+
children: /* @__PURE__ */ h("div", {
|
|
538
|
+
className: an,
|
|
539
|
+
children: [
|
|
540
|
+
/* @__PURE__ */ e("input", {
|
|
541
|
+
ref: u,
|
|
542
|
+
type: "url",
|
|
543
|
+
value: s,
|
|
544
|
+
placeholder: i("graph.toolbar.link.placeholder"),
|
|
545
|
+
"aria-label": i("graph.toolbar.link.urlLabel"),
|
|
546
|
+
className: ln,
|
|
547
|
+
onChange: S,
|
|
548
|
+
onKeyDown: g
|
|
549
|
+
}),
|
|
550
|
+
/* @__PURE__ */ e("button", {
|
|
551
|
+
type: "button",
|
|
552
|
+
"aria-label": i("common.cancel"),
|
|
553
|
+
className: at,
|
|
554
|
+
onClick: p,
|
|
555
|
+
children: /* @__PURE__ */ e(nn, {})
|
|
556
|
+
}),
|
|
557
|
+
/* @__PURE__ */ e("button", {
|
|
558
|
+
type: "button",
|
|
559
|
+
"aria-label": i("graph.toolbar.link.apply"),
|
|
560
|
+
className: at,
|
|
561
|
+
onClick: f,
|
|
562
|
+
children: /* @__PURE__ */ e(Zt, {})
|
|
563
|
+
})
|
|
564
|
+
]
|
|
565
|
+
})
|
|
566
|
+
})]
|
|
567
|
+
});
|
|
568
|
+
}, cn = (t, n) => {
|
|
569
|
+
const r = n.trim(), { selection: l } = t.state;
|
|
570
|
+
if (!r) {
|
|
571
|
+
t.chain().focus().extendMarkRange("link").unsetLink().run();
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
if (!l.empty) {
|
|
575
|
+
t.chain().focus().setLink({ href: r }).run();
|
|
576
|
+
return;
|
|
577
|
+
}
|
|
578
|
+
if (t.isActive("link")) {
|
|
579
|
+
t.chain().focus().extendMarkRange("link").setLink({ href: r }).run();
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
const o = on(t);
|
|
583
|
+
t.chain().focus().setTextSelection(o).setLink({ href: r }).run();
|
|
584
|
+
}, dn = ({ editor: t, activeAlignment: n = "left" }) => {
|
|
585
|
+
const r = x();
|
|
586
|
+
return /* @__PURE__ */ h(mt, { children: [
|
|
587
|
+
/* @__PURE__ */ e(d.Button, {
|
|
588
|
+
label: r("graph.toolbar.textAlign.left"),
|
|
589
|
+
pressed: n === "left",
|
|
590
|
+
onClick: () => t.chain().focus().setTextAlign("left").run(),
|
|
591
|
+
children: /* @__PURE__ */ e(xt, {})
|
|
592
|
+
}),
|
|
593
|
+
/* @__PURE__ */ e(d.Button, {
|
|
594
|
+
label: r("graph.toolbar.textAlign.center"),
|
|
595
|
+
pressed: n === "center",
|
|
596
|
+
onClick: () => t.chain().focus().setTextAlign("center").run(),
|
|
597
|
+
children: /* @__PURE__ */ e(Tt, {})
|
|
598
|
+
}),
|
|
599
|
+
/* @__PURE__ */ e(d.Button, {
|
|
600
|
+
label: r("graph.toolbar.textAlign.right"),
|
|
601
|
+
pressed: n === "right",
|
|
602
|
+
onClick: () => t.chain().focus().setTextAlign("right").run(),
|
|
603
|
+
children: /* @__PURE__ */ e(kt, {})
|
|
604
|
+
})
|
|
605
|
+
] });
|
|
606
|
+
}, un = ({ editor: t }) => ({
|
|
607
|
+
bold: t?.isActive("bold") ?? !1,
|
|
608
|
+
italic: t?.isActive("italic") ?? !1,
|
|
609
|
+
underlined: t?.isActive("underline") ?? !1,
|
|
610
|
+
linked: t?.isActive("link") ?? !1,
|
|
611
|
+
linkUrl: t?.getAttributes("link").href ?? null,
|
|
612
|
+
color: t?.getAttributes("textStyle").color ?? null,
|
|
613
|
+
fontFamily: t?.getAttributes("textStyle").fontFamily ?? null,
|
|
614
|
+
fontSize: fn(t),
|
|
615
|
+
textAlign: hn(t)
|
|
616
|
+
}), fn = (t) => t ? t.isActive("heading", { level: 1 }) ? "h1" : t.isActive("heading", { level: 2 }) ? "h2" : t.isActive("heading", { level: 3 }) ? "h3" : t.isActive("paragraph", { variant: "caption" }) ? "caption" : "text" : "text", hn = (t) => t ? t.isActive({ textAlign: "center" }) ? "center" : t.isActive({ textAlign: "right" }) ? "right" : "left" : "left", pn = ({ editor: t }) => {
|
|
617
|
+
const n = x(), [r, l] = K(!1), [o, i] = K(null), s = o !== null, c = (y) => (C) => {
|
|
618
|
+
i(C ? y : null);
|
|
619
|
+
}, u = R(null), { width: f, height: p, setElement: S } = Xt(), g = t?.view.dom ?? null, v = E(() => ({
|
|
620
|
+
x: 0,
|
|
621
|
+
y: 0,
|
|
622
|
+
width: f,
|
|
623
|
+
height: p
|
|
624
|
+
}), [f, p]), m = I({
|
|
625
|
+
editor: t,
|
|
626
|
+
selector: un
|
|
627
|
+
});
|
|
628
|
+
return k(() => (S(g), () => S(null)), [S, g]), k(() => {
|
|
629
|
+
if (!t) return;
|
|
630
|
+
const y = () => l(!0), C = ({ event: z }) => {
|
|
631
|
+
const { relatedTarget: F, currentTarget: M } = z, P = F instanceof Node && u.current?.contains(F), O = F instanceof Node && M instanceof Node && M.contains(F);
|
|
632
|
+
!P && !O && l(!1);
|
|
633
|
+
};
|
|
634
|
+
return t.on("focus", y), t.on("blur", C), () => {
|
|
635
|
+
t.off("focus", y), t.off("blur", C);
|
|
636
|
+
};
|
|
637
|
+
}, [t]), !t || g === null || !r && !s ? null : /* @__PURE__ */ e(qt, {
|
|
638
|
+
frameElement: g,
|
|
639
|
+
boundary: v,
|
|
640
|
+
side: "bottom",
|
|
641
|
+
align: "start",
|
|
642
|
+
takesFocus: !1,
|
|
643
|
+
onEscape: () => {
|
|
644
|
+
u.current?.contains(document.activeElement) && t.commands.focus();
|
|
645
|
+
},
|
|
646
|
+
children: /* @__PURE__ */ h(ae, {
|
|
647
|
+
ref: u,
|
|
648
|
+
...te,
|
|
649
|
+
children: [
|
|
650
|
+
/* @__PURE__ */ h(d.Group, { children: [/* @__PURE__ */ e(d.ColorPicker, {
|
|
651
|
+
color: m?.color ?? null,
|
|
652
|
+
onChange: (y) => t.chain().setColor(y).run(),
|
|
653
|
+
open: o === "color",
|
|
654
|
+
onOpenChange: c("color")
|
|
655
|
+
}), /* @__PURE__ */ e(Ze, {
|
|
656
|
+
editor: t,
|
|
657
|
+
currentFontFamily: m?.fontFamily ?? null,
|
|
658
|
+
open: o === "fontFamily",
|
|
659
|
+
onOpenChange: c("fontFamily")
|
|
660
|
+
})] }),
|
|
661
|
+
/* @__PURE__ */ e(d.Separator, {}),
|
|
662
|
+
/* @__PURE__ */ e(d.Group, { children: /* @__PURE__ */ e(qe, {
|
|
663
|
+
editor: t,
|
|
664
|
+
activeStyle: m?.fontSize ?? "text",
|
|
665
|
+
open: o === "fontSize",
|
|
666
|
+
onOpenChange: c("fontSize")
|
|
667
|
+
}) }),
|
|
668
|
+
/* @__PURE__ */ e(d.Separator, {}),
|
|
669
|
+
/* @__PURE__ */ h(d.Group, { children: [
|
|
670
|
+
/* @__PURE__ */ e(d.Button, {
|
|
671
|
+
label: n("graph.toolbar.formatting.bold"),
|
|
672
|
+
pressed: m?.bold ?? !1,
|
|
673
|
+
onClick: () => t.chain().focus().toggleBold().run(),
|
|
674
|
+
children: /* @__PURE__ */ e("strong", { children: "B" })
|
|
675
|
+
}),
|
|
676
|
+
/* @__PURE__ */ e(d.Button, {
|
|
677
|
+
label: n("graph.toolbar.formatting.italic"),
|
|
678
|
+
pressed: m?.italic ?? !1,
|
|
679
|
+
onClick: () => t.chain().focus().toggleItalic().run(),
|
|
680
|
+
children: /* @__PURE__ */ e("em", { children: "I" })
|
|
681
|
+
}),
|
|
682
|
+
/* @__PURE__ */ e(d.Button, {
|
|
683
|
+
label: n("graph.toolbar.formatting.underline"),
|
|
684
|
+
pressed: m?.underlined ?? !1,
|
|
685
|
+
onClick: () => t.chain().focus().toggleUnderline().run(),
|
|
686
|
+
children: /* @__PURE__ */ e("u", { children: "U" })
|
|
687
|
+
})
|
|
688
|
+
] }),
|
|
689
|
+
/* @__PURE__ */ e(d.Separator, {}),
|
|
690
|
+
/* @__PURE__ */ e(d.Group, { children: /* @__PURE__ */ e(dn, {
|
|
691
|
+
editor: t,
|
|
692
|
+
activeAlignment: m?.textAlign
|
|
693
|
+
}) }),
|
|
694
|
+
/* @__PURE__ */ e(d.Separator, {}),
|
|
695
|
+
/* @__PURE__ */ e(d.Group, { children: /* @__PURE__ */ e(sn, {
|
|
696
|
+
editor: t,
|
|
697
|
+
currentUrl: m?.linkUrl ?? null,
|
|
698
|
+
active: m?.linked ?? !1,
|
|
699
|
+
open: o === "link",
|
|
700
|
+
onOpenChange: c("link")
|
|
701
|
+
}) })
|
|
702
|
+
]
|
|
703
|
+
})
|
|
704
|
+
});
|
|
705
|
+
}, mn = "_1uy50v30", Lt = ({ editor: t, ariaLabel: n }) => /* @__PURE__ */ h("div", {
|
|
706
|
+
className: mn,
|
|
707
|
+
children: [/* @__PURE__ */ e(pn, { editor: t }), /* @__PURE__ */ e(gt, {
|
|
708
|
+
editor: t,
|
|
709
|
+
"aria-label": n
|
|
710
|
+
})]
|
|
711
|
+
}), gn = 200, Z = ({ content: t, extensions: n, editable: r, onUpdate: l, updateDebounceMs: o = gn }) => {
|
|
712
|
+
const i = R(it(t)), s = R(i.current), c = Vt((f) => {
|
|
713
|
+
s.current = f, l?.(f);
|
|
714
|
+
}, o), u = xe({
|
|
715
|
+
extensions: n,
|
|
716
|
+
content: i.current,
|
|
717
|
+
editable: r,
|
|
718
|
+
immediatelyRender: !1,
|
|
719
|
+
onUpdate: ({ editor: f }) => {
|
|
720
|
+
const p = f.getJSON();
|
|
721
|
+
if (G(s.current, p)) return c.cancel();
|
|
722
|
+
c.run(p);
|
|
723
|
+
}
|
|
724
|
+
});
|
|
725
|
+
return k(() => {
|
|
726
|
+
u?.setEditable(r);
|
|
727
|
+
}, [u, r]), k(() => {
|
|
728
|
+
if (!u) return;
|
|
729
|
+
const f = it(t);
|
|
730
|
+
G(s.current, f) || (s.current = f, !G(u.getJSON(), f) && (c.cancel(), vn(u, f)));
|
|
731
|
+
}, [
|
|
732
|
+
u,
|
|
733
|
+
t,
|
|
734
|
+
c
|
|
735
|
+
]), k(() => () => c.flush(), [c]), u;
|
|
736
|
+
}, it = (t) => t === null ? {
|
|
737
|
+
type: "doc",
|
|
738
|
+
content: []
|
|
739
|
+
} : typeof t == "string" ? {
|
|
740
|
+
type: "doc",
|
|
741
|
+
content: [{
|
|
742
|
+
type: "paragraph",
|
|
743
|
+
content: t ? [{
|
|
744
|
+
type: "text",
|
|
745
|
+
text: t
|
|
746
|
+
}] : []
|
|
747
|
+
}]
|
|
748
|
+
} : t, vn = (t, n) => {
|
|
749
|
+
const { from: r, to: l } = t.state.selection;
|
|
750
|
+
t.commands.setContent(n, { emitUpdate: !1 });
|
|
751
|
+
const o = t.state.doc.content.size;
|
|
752
|
+
t.commands.setTextSelection({
|
|
753
|
+
from: Math.min(r, o),
|
|
754
|
+
to: Math.min(l, o)
|
|
755
|
+
});
|
|
756
|
+
}, G = (t, n) => JSON.stringify(B(t)) === JSON.stringify(B(n)), B = (t) => Array.isArray(t) ? t.map(B) : t === null || typeof t != "object" ? t : Object.fromEntries(Object.entries(t).map(([n, r]) => [n, B(r)]).filter(([, n]) => !bn(n)).sort(([n], [r]) => String(n).localeCompare(String(r)))), bn = (t) => t == null || typeof t == "object" && Object.keys(t).length === 0, jn = ({ caption: t, captionStyle: n }) => {
|
|
757
|
+
const { dispatch: r } = V(), l = U(), o = Z({
|
|
758
|
+
content: t,
|
|
759
|
+
extensions: E(() => $e({ placeholder: Wt }), []),
|
|
760
|
+
editable: !0,
|
|
761
|
+
onUpdate: (i) => {
|
|
762
|
+
const s = rn(i) ? null : i;
|
|
763
|
+
r(new he({ caption: s }));
|
|
764
|
+
}
|
|
765
|
+
});
|
|
766
|
+
return pt(() => {
|
|
767
|
+
o !== null && Ft(o, l.getState().takePendingTextCaret("caption"));
|
|
768
|
+
}, [o, l]), /* @__PURE__ */ e("div", {
|
|
769
|
+
"data-testid": "caption-editor",
|
|
770
|
+
style: Bt(n),
|
|
771
|
+
children: o === null ? /* @__PURE__ */ e(Ht, { caption: t }) : /* @__PURE__ */ e(Lt, {
|
|
772
|
+
editor: o,
|
|
773
|
+
ariaLabel: "Chart caption"
|
|
774
|
+
})
|
|
775
|
+
});
|
|
776
|
+
}, yn = (t) => [
|
|
777
|
+
D,
|
|
778
|
+
yt,
|
|
779
|
+
...Y(),
|
|
780
|
+
Tn,
|
|
781
|
+
J.configure({
|
|
782
|
+
showOnlyCurrent: !1,
|
|
783
|
+
placeholder: ({ pos: n }) => n === 0 ? t : ""
|
|
784
|
+
})
|
|
785
|
+
], Wn = ({ annotation: t }) => {
|
|
786
|
+
const n = x(), { dispatch: r } = V(), l = U(), o = E(() => yn(n("graph.annotations.text.placeholder")), [n]), i = Z({
|
|
787
|
+
content: t.content,
|
|
788
|
+
extensions: o,
|
|
789
|
+
editable: !0,
|
|
790
|
+
onUpdate: (u) => {
|
|
791
|
+
r(new ht({
|
|
792
|
+
kind: "text",
|
|
793
|
+
id: t.id,
|
|
794
|
+
patch: { content: u }
|
|
795
|
+
}));
|
|
796
|
+
}
|
|
797
|
+
});
|
|
798
|
+
k(() => {
|
|
799
|
+
const { setCaretEditor: u } = l.getState();
|
|
800
|
+
return u(i), () => u(null);
|
|
801
|
+
}, [i, l]), k(() => {
|
|
802
|
+
i?.commands.focus("end", { scrollIntoView: !1 });
|
|
803
|
+
}, [i]);
|
|
804
|
+
const s = I({
|
|
805
|
+
editor: i,
|
|
806
|
+
selector: ({ editor: u }) => ft(u)
|
|
807
|
+
}), c = I({
|
|
808
|
+
editor: i,
|
|
809
|
+
selector: ({ editor: u }) => ut(u)
|
|
810
|
+
});
|
|
811
|
+
return /* @__PURE__ */ e(gt, {
|
|
812
|
+
"aria-label": n("graph.annotations.text.editLabel"),
|
|
813
|
+
className: jt,
|
|
814
|
+
editor: i,
|
|
815
|
+
style: {
|
|
816
|
+
...s === null ? {} : { fontSize: `calc(${s}px * ${A.textScale})` },
|
|
817
|
+
...c === null ? {} : { fontFamily: ct(c) }
|
|
818
|
+
},
|
|
819
|
+
"data-testid": "text-annotation-editor"
|
|
820
|
+
});
|
|
821
|
+
}, lt = (t) => {
|
|
822
|
+
const n = ct(t);
|
|
823
|
+
return n === void 0 ? {} : { style: `font-family: ${n}` };
|
|
824
|
+
}, Tn = vt.create({
|
|
825
|
+
name: "annotationTextStyleAttributes",
|
|
826
|
+
addGlobalAttributes() {
|
|
827
|
+
return [{
|
|
828
|
+
types: ["textStyle"],
|
|
829
|
+
attributes: {
|
|
830
|
+
fontFamily: {
|
|
831
|
+
default: null,
|
|
832
|
+
renderHTML: (t) => lt(t.fontFamily)
|
|
833
|
+
},
|
|
834
|
+
font: {
|
|
835
|
+
default: null,
|
|
836
|
+
renderHTML: (t) => lt(t.font)
|
|
837
|
+
},
|
|
838
|
+
fontSize: {
|
|
839
|
+
default: null,
|
|
840
|
+
renderHTML: (t) => typeof t.fontSize == "number" && Number.isFinite(t.fontSize) ? { style: `font-size: calc(${t.fontSize}px * ${A.textScale})` } : {}
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
}];
|
|
844
|
+
}
|
|
845
|
+
}), $n = ({ title: t, showTitle: n, showSubtitle: r, subtitle: l }) => {
|
|
846
|
+
const { dispatch: o } = V(), i = U(), s = E(() => We({
|
|
847
|
+
titlePlaceholder: tt,
|
|
848
|
+
subtitlePlaceholder: tt,
|
|
849
|
+
showTitle: n,
|
|
850
|
+
showSubtitle: r
|
|
851
|
+
}), [n, r]), c = Z({
|
|
852
|
+
content: E(() => Jt({
|
|
853
|
+
title: t,
|
|
854
|
+
showTitle: n,
|
|
855
|
+
subtitle: l,
|
|
856
|
+
showSubtitle: r
|
|
857
|
+
}), [
|
|
858
|
+
t,
|
|
859
|
+
n,
|
|
860
|
+
l,
|
|
861
|
+
r
|
|
862
|
+
]),
|
|
863
|
+
extensions: s,
|
|
864
|
+
editable: !0,
|
|
865
|
+
onUpdate: (u) => {
|
|
866
|
+
const f = Kt(u, n);
|
|
867
|
+
n && o(new me({ title: f.title })), r && o(new pe({ subtitle: f.subtitle }));
|
|
868
|
+
}
|
|
869
|
+
});
|
|
870
|
+
return pt(() => {
|
|
871
|
+
c !== null && Ft(c, i.getState().takePendingTextCaret("header"));
|
|
872
|
+
}, [c, i]), /* @__PURE__ */ e("div", {
|
|
873
|
+
className: Ut,
|
|
874
|
+
"data-testid": "title-editor",
|
|
875
|
+
children: c === null ? /* @__PURE__ */ e($t, {
|
|
876
|
+
title: t,
|
|
877
|
+
showTitle: n,
|
|
878
|
+
showSubtitle: r,
|
|
879
|
+
subtitle: l
|
|
880
|
+
}) : /* @__PURE__ */ e(Lt, {
|
|
881
|
+
editor: c,
|
|
882
|
+
ariaLabel: "Chart title and subtitle"
|
|
883
|
+
})
|
|
884
|
+
});
|
|
885
|
+
};
|
|
886
|
+
export {
|
|
887
|
+
jn as CaptionEditor,
|
|
888
|
+
Wn as TextAnnotationEditor,
|
|
889
|
+
Un as TextToolbar,
|
|
890
|
+
$n as TitleEditor
|
|
891
|
+
};
|