@pie-lib/editable-html-tip-tap 3.1.3-next.20261027184745 → 3.1.3-next.20261102105711

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.
@@ -8,9 +8,9 @@ import { arabicConfig as ee, spanishConfig as te, specialConfig as ne } from "./
8
8
  import re from "./ToolbarDisclosure.js";
9
9
  import ie from "./icons/TextAlign.js";
10
10
  import ae from "./icons/CssIcon.js";
11
- import { AddColumn as oe, AddRow as se, RemoveColumn as ce, RemoveRow as le, RemoveTable as ue } from "./icons/TableIcons.js";
12
- import { CharacterIcon as c, CharacterPicker as de } from "./CharacterPicker.js";
13
- import fe, { useEffect as l, useLayoutEffect as pe, useMemo as me, useRef as u, useState as d } from "react";
11
+ import { AddColumn as oe, AddRow as se, RemoveColumn as ce, RemoveRow as le, RemoveTable as c } from "./icons/TableIcons.js";
12
+ import { CharacterIcon as l, CharacterPicker as ue } from "./CharacterPicker.js";
13
+ import de, { useEffect as u, useLayoutEffect as fe, useMemo as pe, useRef as me, useState as d } from "react";
14
14
  import { useEditorState as he } from "@tiptap/react";
15
15
  import { styled as f, useTheme as p } from "@mui/material/styles";
16
16
  import { NodeSelection as ge } from "prosemirror-state";
@@ -18,27 +18,28 @@ import { color as m } from "@pie-lib/render-ui";
18
18
  import _e from "@mui/icons-material/Delete";
19
19
  import h from "@pie-lib/translator";
20
20
  import { jsx as g, jsxs as _ } from "react/jsx-runtime";
21
- import ve from "@mui/icons-material/FormatBold";
22
- import ye from "@mui/icons-material/FormatItalic";
23
- import v from "@mui/icons-material/FormatStrikethrough";
24
- import y from "@mui/icons-material/Code";
25
- import b from "@mui/icons-material/GridOn";
26
- import x from "@mui/icons-material/FormatListBulleted";
27
- import S from "@mui/icons-material/FormatListNumbered";
28
- import C from "@mui/icons-material/FormatUnderlined";
29
- import w from "@mui/icons-material/Functions";
30
- import T from "@mui/icons-material/Image";
31
- import E from "@mui/icons-material/Redo";
32
- import D from "@mui/icons-material/Undo";
33
- import O from "@mui/icons-material/FormatQuote";
34
- import k from "@mui/icons-material/Theaters";
35
- import A from "@mui/icons-material/VolumeUp";
36
- import j from "@mui/icons-material/BorderAll";
37
- import M from "@mui/icons-material/FormatTextdirectionLToR";
38
- import N from "@mui/icons-material/FormatTextdirectionRToL";
39
- import P from "@mui/icons-material/Translate";
21
+ import { inlineSideOfArrow as ve } from "@pie-element/shared-utils";
22
+ import ye from "@mui/icons-material/FormatBold";
23
+ import v from "@mui/icons-material/FormatItalic";
24
+ import y from "@mui/icons-material/FormatStrikethrough";
25
+ import b from "@mui/icons-material/Code";
26
+ import x from "@mui/icons-material/GridOn";
27
+ import S from "@mui/icons-material/FormatListBulleted";
28
+ import C from "@mui/icons-material/FormatListNumbered";
29
+ import w from "@mui/icons-material/FormatUnderlined";
30
+ import T from "@mui/icons-material/Functions";
31
+ import E from "@mui/icons-material/Image";
32
+ import D from "@mui/icons-material/Redo";
33
+ import O from "@mui/icons-material/Undo";
34
+ import k from "@mui/icons-material/FormatQuote";
35
+ import A from "@mui/icons-material/Theaters";
36
+ import j from "@mui/icons-material/VolumeUp";
37
+ import M from "@mui/icons-material/BorderAll";
38
+ import N from "@mui/icons-material/FormatTextdirectionLToR";
39
+ import P from "@mui/icons-material/FormatTextdirectionRToL";
40
+ import be from "@mui/icons-material/Translate";
40
41
  //#region src/components/MenuBar.tsx
41
- var { translator: F } = h, be = () => /* @__PURE__ */ g("svg", {
42
+ var { translator: F } = h, xe = () => /* @__PURE__ */ g("svg", {
42
43
  xmlns: "http://www.w3.org/2000/svg",
43
44
  height: "24px",
44
45
  viewBox: "0 0 24 24",
@@ -50,7 +51,7 @@ var { translator: F } = h, be = () => /* @__PURE__ */ g("svg", {
50
51
  d: "M22,7h-2v1h3v1h-4V7c0-0.55,0.45-1,1-1h2V5h-3V4h3c0.55,0,1,0.45,1,1v1C23,6.55,22.55,7,22,7z M5.88,20h2.66l3.4-5.42h0.12 l3.4,5.42h2.66l-4.65-7.27L17.81,6h-2.68l-3.07,4.99h-0.12L8.85,6H6.19l4.32,6.73L5.88,20z",
51
52
  fill: "currentColor"
52
53
  })
53
- }), xe = () => /* @__PURE__ */ g("svg", {
54
+ }), Se = () => /* @__PURE__ */ g("svg", {
54
55
  xmlns: "http://www.w3.org/2000/svg",
55
56
  height: "24px",
56
57
  viewBox: "0 0 24 24",
@@ -62,7 +63,7 @@ var { translator: F } = h, be = () => /* @__PURE__ */ g("svg", {
62
63
  d: "M22,18h-2v1h3v1h-4v-2c0-0.55,0.45-1,1-1h2v-1h-3v-1h3c0.55,0,1,0.45,1,1v1C23,17.55,22.55,18,22,18z M5.88,18h2.66 l3.4-5.42h0.12l3.4,5.42h2.66l-4.65-7.27L17.81,4h-2.68l-3.07,4.99h-0.12L8.85,4H6.19l4.32,6.73L5.88,18z",
63
64
  fill: "currentColor"
64
65
  })
65
- }), Se = () => /* @__PURE__ */ g("svg", {
66
+ }), Ce = () => /* @__PURE__ */ g("svg", {
66
67
  width: "30",
67
68
  height: "28",
68
69
  viewBox: "0 0 30 28",
@@ -80,11 +81,11 @@ var { translator: F } = h, be = () => /* @__PURE__ */ g("svg", {
80
81
  })
81
82
  }), I = (e) => e?.extensionManager?.extensions.find(({ name: e }) => e === "contentLanguage")?.options.languages() ?? [];
82
83
  function L({ editor: t, classes: f, activePlugins: p, toolbarOpts: m, responseAreaProps: h, onChange: L, autoWidthToolbar: R, hasFocus: z, language: B }) {
83
- let [V, H] = d(!1), [U, Ce] = d({
84
+ let [V, H] = d(!1), [U, we] = d({
84
85
  el: null,
85
86
  keyboard: !1
86
- }), [W, G] = d(!1), K = u(null), q = (e, t) => {
87
- Ce({
87
+ }), [W, G] = d(!1), K = me(null), q = (e, t) => {
88
+ we({
88
89
  el: t?.currentTarget ?? null,
89
90
  keyboard: t?.detail === 0
90
91
  }), H(e);
@@ -136,18 +137,18 @@ function L({ editor: t, classes: f, activePlugins: p, toolbarOpts: m, responseAr
136
137
  };
137
138
  }
138
139
  }), X = !!R, Z = Y.hideDefaultToolbar && Y.currentNode?.type?.name === "drag_in_the_blank", Q = J.alwaysVisible || z && !W && !Y.toolbarOpened && (!Y.hideDefaultToolbar || Z);
139
- l(() => {
140
+ u(() => {
140
141
  z || G(!1);
141
- }, [z]), l(() => {
142
+ }, [z]), u(() => {
142
143
  if (!W || !t) return;
143
144
  let e = () => G(!1), n = t.view.dom;
144
145
  return t.on("update", e), t.on("selectionUpdate", e), n.addEventListener("mousedown", e), () => {
145
146
  t.off("update", e), t.off("selectionUpdate", e), n.removeEventListener("mousedown", e);
146
147
  };
147
- }, [W, t]), pe(() => {
148
+ }, [W, t]), fe(() => {
148
149
  K.current?.toggleAttribute("inert", !Q);
149
150
  }, [Q]);
150
- let we = r(f.toolbar, e, {
151
+ let Te = r(f.toolbar, e, {
151
152
  [f.toolbarWithNoDone]: !0,
152
153
  [f.toolbarTop]: J.position === "top",
153
154
  [f.toolbarRight]: J.alignment === "right",
@@ -155,11 +156,18 @@ function L({ editor: t, classes: f, activePlugins: p, toolbarOpts: m, responseAr
155
156
  [f.autoWidth]: X,
156
157
  [f.fullWidth]: !X,
157
158
  [f.hidden]: J.isHidden === !0
158
- }), Te = J.minWidth === void 0 ? {} : { minWidth: J.minWidth }, Ee = (e) => {
159
+ }), Ee = J.minWidth === void 0 ? {} : { minWidth: J.minWidth }, De = (e) => {
160
+ let t = ve(e.key, e.currentTarget);
161
+ if (!t || e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) return;
162
+ let n = e.target;
163
+ if (n.tagName !== "BUTTON") return;
164
+ let r = Array.from(e.currentTarget.querySelectorAll("button:not(:disabled)")).filter((e) => !e.closest("[hidden]")), i = r[r.indexOf(n) + (t === "inline-end" ? 1 : -1)];
165
+ i && (e.preventDefault(), i.focus());
166
+ }, Oe = (e) => {
159
167
  e.preventDefault();
160
- }, $ = (e) => F.t(`editableHtml.buttons.${e}`, { lng: B }), De = me(() => [
168
+ }, $ = (e) => F.t(`editableHtml.buttons.${e}`, { lng: B }), ke = pe(() => [
161
169
  {
162
- icon: /* @__PURE__ */ g(b, {}),
170
+ icon: /* @__PURE__ */ g(x, {}),
163
171
  label: $("insertTable"),
164
172
  onClick: (e) => e.chain().focus().insertTable({
165
173
  rows: 2,
@@ -203,7 +211,7 @@ function L({ editor: t, classes: f, activePlugins: p, toolbarOpts: m, responseAr
203
211
  isDisabled: (e) => !e.canTable
204
212
  },
205
213
  {
206
- icon: /* @__PURE__ */ g(ue, {}),
214
+ icon: /* @__PURE__ */ g(c, {}),
207
215
  label: $("removeTable"),
208
216
  onClick: (e) => e.chain().focus().deleteTable().run(),
209
217
  hidden: (e) => !(e.isTable && !e.hasTextSelectionInTable),
@@ -211,7 +219,7 @@ function L({ editor: t, classes: f, activePlugins: p, toolbarOpts: m, responseAr
211
219
  isDisabled: (e) => !e.canTable
212
220
  },
213
221
  {
214
- icon: /* @__PURE__ */ g(j, {}),
222
+ icon: /* @__PURE__ */ g(M, {}),
215
223
  label: $("tableBorders"),
216
224
  toggle: !0,
217
225
  onClick: (e) => {
@@ -226,7 +234,7 @@ function L({ editor: t, classes: f, activePlugins: p, toolbarOpts: m, responseAr
226
234
  isDisabled: (e) => !e.canTable
227
235
  },
228
236
  {
229
- icon: /* @__PURE__ */ g(ve, {}),
237
+ icon: /* @__PURE__ */ g(ye, {}),
230
238
  label: $("bold"),
231
239
  toggle: !0,
232
240
  onClick: (e) => e.chain().focus().toggleBold().run(),
@@ -235,7 +243,7 @@ function L({ editor: t, classes: f, activePlugins: p, toolbarOpts: m, responseAr
235
243
  isDisabled: (e) => !e.canBold
236
244
  },
237
245
  {
238
- icon: /* @__PURE__ */ g(ye, {}),
246
+ icon: /* @__PURE__ */ g(v, {}),
239
247
  label: $("italic"),
240
248
  toggle: !0,
241
249
  onClick: (e) => e.chain().focus().toggleItalic().run(),
@@ -244,7 +252,7 @@ function L({ editor: t, classes: f, activePlugins: p, toolbarOpts: m, responseAr
244
252
  isDisabled: (e) => !e.canItalic
245
253
  },
246
254
  {
247
- icon: /* @__PURE__ */ g(v, {}),
255
+ icon: /* @__PURE__ */ g(y, {}),
248
256
  label: $("strikethrough"),
249
257
  toggle: !0,
250
258
  onClick: (e) => e.chain().focus().toggleStrike().run(),
@@ -253,7 +261,7 @@ function L({ editor: t, classes: f, activePlugins: p, toolbarOpts: m, responseAr
253
261
  isDisabled: (e) => !e.canStrike
254
262
  },
255
263
  {
256
- icon: /* @__PURE__ */ g(y, {}),
264
+ icon: /* @__PURE__ */ g(b, {}),
257
265
  label: $("code"),
258
266
  toggle: !0,
259
267
  onClick: (e) => e.chain().focus().toggleCode().run(),
@@ -262,7 +270,7 @@ function L({ editor: t, classes: f, activePlugins: p, toolbarOpts: m, responseAr
262
270
  isDisabled: (e) => !e.canCode
263
271
  },
264
272
  {
265
- icon: /* @__PURE__ */ g(C, {}),
273
+ icon: /* @__PURE__ */ g(w, {}),
266
274
  label: $("underline"),
267
275
  toggle: !0,
268
276
  onClick: (e) => e.chain().focus().toggleUnderline().run(),
@@ -270,7 +278,7 @@ function L({ editor: t, classes: f, activePlugins: p, toolbarOpts: m, responseAr
270
278
  isActive: (e) => e.isUnderline
271
279
  },
272
280
  {
273
- icon: /* @__PURE__ */ g(xe, {}),
281
+ icon: /* @__PURE__ */ g(Se, {}),
274
282
  label: $("subscript"),
275
283
  toggle: !0,
276
284
  onClick: (e) => e.chain().focus().toggleSubscript().run(),
@@ -278,7 +286,7 @@ function L({ editor: t, classes: f, activePlugins: p, toolbarOpts: m, responseAr
278
286
  isActive: (e) => e.isSubScript
279
287
  },
280
288
  {
281
- icon: /* @__PURE__ */ g(be, {}),
289
+ icon: /* @__PURE__ */ g(xe, {}),
282
290
  label: $("superscript"),
283
291
  toggle: !0,
284
292
  onClick: (e) => e.chain().focus().toggleSuperscript().run(),
@@ -286,19 +294,19 @@ function L({ editor: t, classes: f, activePlugins: p, toolbarOpts: m, responseAr
286
294
  isActive: (e) => e.isSuperScript
287
295
  },
288
296
  {
289
- icon: /* @__PURE__ */ g(T, {}),
297
+ icon: /* @__PURE__ */ g(E, {}),
290
298
  label: $("insertImage"),
291
299
  hidden: () => !p?.includes("image"),
292
300
  onClick: (e) => e.chain().focus().setImageUploadNode().run()
293
301
  },
294
302
  {
295
- icon: /* @__PURE__ */ g(k, {}),
303
+ icon: /* @__PURE__ */ g(A, {}),
296
304
  label: $("insertVideo"),
297
305
  hidden: () => !p?.includes("video"),
298
306
  onClick: (e) => e.chain().focus().insertMedia({ type: "video" }).run()
299
307
  },
300
308
  {
301
- icon: /* @__PURE__ */ g(A, {}),
309
+ icon: /* @__PURE__ */ g(j, {}),
302
310
  label: $("insertAudio"),
303
311
  hidden: () => !p?.includes("audio"),
304
312
  onClick: (e) => e.chain().focus().insertMedia({
@@ -313,7 +321,7 @@ function L({ editor: t, classes: f, activePlugins: p, toolbarOpts: m, responseAr
313
321
  onClick: (e) => e.commands.openCSSClassDialog()
314
322
  },
315
323
  {
316
- icon: /* @__PURE__ */ g(O, {}),
324
+ icon: /* @__PURE__ */ g(k, {}),
317
325
  label: $("blockquote"),
318
326
  toggle: !0,
319
327
  hidden: () => !p?.includes("blockquote"),
@@ -321,7 +329,7 @@ function L({ editor: t, classes: f, activePlugins: p, toolbarOpts: m, responseAr
321
329
  isActive: (e) => e.isBlockquote
322
330
  },
323
331
  {
324
- icon: /* @__PURE__ */ g(Se, {}),
332
+ icon: /* @__PURE__ */ g(Ce, {}),
325
333
  label: $("heading"),
326
334
  toggle: !0,
327
335
  hidden: () => !p?.includes("h3"),
@@ -329,25 +337,25 @@ function L({ editor: t, classes: f, activePlugins: p, toolbarOpts: m, responseAr
329
337
  isActive: (e) => e.isHeadingParagraph
330
338
  },
331
339
  {
332
- icon: /* @__PURE__ */ g(w, {}),
340
+ icon: /* @__PURE__ */ g(T, {}),
333
341
  label: $("insertMath"),
334
342
  hidden: () => !p?.includes("math"),
335
343
  onClick: (e) => e.chain().focus().insertMath("").run()
336
344
  },
337
345
  {
338
- icon: /* @__PURE__ */ g(c, { letter: "ñ" }),
346
+ icon: /* @__PURE__ */ g(l, { letter: "ñ" }),
339
347
  label: $("spanishCharacters"),
340
348
  hidden: () => !p?.includes("languageCharacters"),
341
349
  onClick: (e, t) => q(te, t)
342
350
  },
343
351
  {
344
- icon: /* @__PURE__ */ g(c, { letter: "€" }),
352
+ icon: /* @__PURE__ */ g(l, { letter: "€" }),
345
353
  label: $("specialCharacters"),
346
354
  hidden: () => p?.filter((e) => e === "languageCharacters").length !== 2,
347
355
  onClick: (e, t) => q(ne, t)
348
356
  },
349
357
  {
350
- icon: /* @__PURE__ */ g(c, { letter: "ع" }),
358
+ icon: /* @__PURE__ */ g(l, { letter: "ع" }),
351
359
  label: $("arabicCharacters"),
352
360
  hidden: () => !p?.includes("arabicCharacters"),
353
361
  onClick: (e, t) => q(ee, t)
@@ -365,11 +373,11 @@ function L({ editor: t, classes: f, activePlugins: p, toolbarOpts: m, responseAr
365
373
  },
366
374
  ...[[
367
375
  "ltr",
368
- /* @__PURE__ */ g(M, {}),
376
+ /* @__PURE__ */ g(N, {}),
369
377
  "leftToRight"
370
378
  ], [
371
379
  "rtl",
372
- /* @__PURE__ */ g(N, {}),
380
+ /* @__PURE__ */ g(P, {}),
373
381
  "rightToLeft"
374
382
  ]].map(([e, t, n]) => ({
375
383
  icon: t,
@@ -389,7 +397,7 @@ function L({ editor: t, classes: f, activePlugins: p, toolbarOpts: m, responseAr
389
397
  return /* @__PURE__ */ g(re, {
390
398
  editor: t,
391
399
  label: $("contentLanguage"),
392
- trigger: /* @__PURE__ */ g(P, {}),
400
+ trigger: /* @__PURE__ */ g(be, {}),
393
401
  options: [...n && !i ? [{
394
402
  value: e.contentLanguage,
395
403
  label: e.contentLanguage
@@ -408,7 +416,7 @@ function L({ editor: t, classes: f, activePlugins: p, toolbarOpts: m, responseAr
408
416
  }
409
417
  },
410
418
  {
411
- icon: /* @__PURE__ */ g(x, {}),
419
+ icon: /* @__PURE__ */ g(S, {}),
412
420
  label: $("bulletedList"),
413
421
  toggle: !0,
414
422
  hidden: () => !p?.includes("bulleted-list"),
@@ -416,7 +424,7 @@ function L({ editor: t, classes: f, activePlugins: p, toolbarOpts: m, responseAr
416
424
  isActive: (e) => e.isBulletList
417
425
  },
418
426
  {
419
- icon: /* @__PURE__ */ g(S, {}),
427
+ icon: /* @__PURE__ */ g(C, {}),
420
428
  label: $("numberedList"),
421
429
  toggle: !0,
422
430
  hidden: () => !p?.includes("numbered-list"),
@@ -424,14 +432,14 @@ function L({ editor: t, classes: f, activePlugins: p, toolbarOpts: m, responseAr
424
432
  isActive: (e) => e.isOrderedList
425
433
  },
426
434
  {
427
- icon: /* @__PURE__ */ g(D, {}),
435
+ icon: /* @__PURE__ */ g(O, {}),
428
436
  label: F.t("common:undo", { lng: B }),
429
437
  hidden: () => !p?.includes("undo"),
430
438
  onClick: (e) => e.chain().focus().undo().run(),
431
439
  isDisabled: (e) => !e.canUndo
432
440
  },
433
441
  {
434
- icon: /* @__PURE__ */ g(E, {}),
442
+ icon: /* @__PURE__ */ g(D, {}),
435
443
  label: F.t("graphing.redo", { lng: B }),
436
444
  hidden: () => !p?.includes("redo"),
437
445
  onClick: (e) => e.chain().focus().redo().run(),
@@ -444,9 +452,9 @@ function L({ editor: t, classes: f, activePlugins: p, toolbarOpts: m, responseAr
444
452
  ]);
445
453
  return /* @__PURE__ */ _("div", {
446
454
  ref: K,
447
- className: we,
448
- style: { ...Te },
449
- onMouseDown: Ee,
455
+ className: Te,
456
+ style: { ...Ee },
457
+ onMouseDown: Oe,
450
458
  children: [
451
459
  Z && /* @__PURE__ */ g("div", {
452
460
  className: f.defaultToolbar,
@@ -472,11 +480,12 @@ function L({ editor: t, classes: f, activePlugins: p, toolbarOpts: m, responseAr
472
480
  role: "toolbar",
473
481
  tabIndex: -1,
474
482
  "aria-label": F.t("editableHtml.toolbar", { lng: B }),
483
+ onKeyDown: De,
475
484
  children: [
476
485
  /* @__PURE__ */ g("div", {
477
486
  className: f.buttonsContainer,
478
- children: De.filter((e) => !e.hidden?.(Y)).map((e, n) => {
479
- if (e.render) return /* @__PURE__ */ g(fe.Fragment, { children: e.render(Y) }, n);
487
+ children: ke.filter((e) => !e.hidden?.(Y)).map((e, n) => {
488
+ if (e.render) return /* @__PURE__ */ g(de.Fragment, { children: e.render(Y) }, n);
480
489
  let i = e.isDisabled?.(Y), a = e.isActive?.(Y);
481
490
  return /* @__PURE__ */ g("button", {
482
491
  type: "button",
@@ -510,7 +519,7 @@ function L({ editor: t, classes: f, activePlugins: p, toolbarOpts: m, responseAr
510
519
  })
511
520
  ]
512
521
  }),
513
- V && /* @__PURE__ */ g(de, {
522
+ V && /* @__PURE__ */ g(ue, {
514
523
  editor: t,
515
524
  triggerEl: U.el,
516
525
  focusOnOpen: U.keyboard,
@@ -62,7 +62,7 @@ var u = o("div", { shouldForwardProp: (e) => !["noBorder", "error"].includes(e)
62
62
  },
63
63
  "& blockquote": {
64
64
  background: "#f9f9f9",
65
- borderLeft: "5px solid #ccc",
65
+ borderInlineStart: "5px solid #ccc",
66
66
  margin: "1.5em 10px",
67
67
  padding: ".5em 10px"
68
68
  },
@@ -27,6 +27,7 @@ var a = (e, t, n, r) => {
27
27
  ...d,
28
28
  style: {
29
29
  display: "inline-flex",
30
+ verticalAlign: "middle",
30
31
  minHeight: "50px",
31
32
  minWidth: "178px",
32
33
  position: "relative",
@@ -48,7 +48,8 @@ function m({ n: e, children: a, isDragging: o, isOver: u, dragItem: d, value: p,
48
48
  borderRadius: "3px",
49
49
  overflow: "hidden",
50
50
  position: "relative",
51
- padding: "8px 8px 8px 35px",
51
+ paddingBlock: "8px",
52
+ paddingInline: "35px 8px",
52
53
  width: h ? h.width : void 0,
53
54
  height: h ? h.height : void 0,
54
55
  touchAction: "none"
@@ -60,7 +61,7 @@ function m({ n: e, children: a, isDragging: o, isOver: u, dragItem: d, value: p,
60
61
  style: {
61
62
  position: "absolute",
62
63
  top: "6px",
63
- left: "15px",
64
+ insetInlineStart: "15px",
64
65
  color: "#9B9B9B"
65
66
  },
66
67
  contentEditable: !1
@@ -78,7 +78,7 @@ var h = (u) => {
78
78
  style: {
79
79
  flex: 1,
80
80
  overflow: "hidden",
81
- padding: "0 25px 0 8px",
81
+ paddingInline: "8px 25px",
82
82
  whiteSpace: "nowrap",
83
83
  textOverflow: "ellipsis"
84
84
  },
@@ -94,7 +94,7 @@ var h = (u) => {
94
94
  style: {
95
95
  position: "absolute",
96
96
  top: "5px",
97
- right: "5px"
97
+ insetInlineEnd: "5px"
98
98
  }
99
99
  })]
100
100
  }), A && /* @__PURE__ */ p(r.Fragment, { children: [l.createPortal(/* @__PURE__ */ f("div", {
@@ -20,7 +20,7 @@ var s = t("span")(() => ({
20
20
  background: r.backgroundDark(),
21
21
  color: r.text(),
22
22
  display: "inline-flex",
23
- borderRight: `2px solid ${r.borderDark()}`,
23
+ borderInlineEnd: `2px solid ${r.borderDark()}`,
24
24
  boxSizing: "border-box",
25
25
  overflow: "hidden",
26
26
  fontSize: "12px",
@@ -24,4 +24,12 @@ export declare const sanitizeMathMl: (html: any) => string;
24
24
  export declare const EnsureTextAfterMathPlugin: (mathNodeName: any) => Plugin<any>;
25
25
  export declare const ZeroWidthSpaceHandlingPlugin: Plugin<any>;
26
26
  export declare const MathNode: Node<any, any>;
27
+ /**
28
+ * The math toolbar's viewport left edge. Its inline-start edge meets the anchor's, so it opens
29
+ * rightwards in LTR text and leftwards in RTL, and it stays `margin` inside the viewport.
30
+ */
31
+ export declare const mathToolbarLeft: (anchor: {
32
+ left: number;
33
+ right: number;
34
+ }, toolbarWidth: number, rtl: boolean, viewportWidth: number, margin: number) => number;
27
35
  export declare const MathNodeView: (props: any) => React.JSX.Element;
@@ -9,54 +9,55 @@ import { jsx as p, jsxs as m } from "react/jsx-runtime";
9
9
  import { latexToMml as h, mmlToLatex as g, unWrapMath as _, wrapMath as v } from "@pie-element/shared-math-rendering-mathjax";
10
10
  import { MathMLToLaTeX as y } from "@pie-framework/mathml-to-latex";
11
11
  import { MathPreview as b, MathToolbar as x } from "@pie-lib/math-toolbar";
12
+ import { inlineSideOfArrow as S, isRightToLeft as C } from "@pie-element/shared-utils";
12
13
  //#region src/extensions/math.tsx
13
- var S = /\\left\.\s*|\\right\.\s*/g, C = /<mo(?: [^>]*)?>&#x2061;<\/mo>/g, w = {
14
+ var w = /\\left\.\s*|\\right\.\s*/g, T = /<mo(?: [^>]*)?>&#x2061;<\/mo>/g, E = {
14
15
  open: "\\[",
15
16
  close: "\\]"
16
- }, T = "data-pie-latex", E = (e) => e.replaceAll("&", "&amp;").replaceAll("\"", "&quot;").replaceAll("<", "&lt;").replaceAll(">", "&gt;"), D = (e) => typeof e == "string" ? e === "double_dollar" : ["$$", "\\["].includes(e?.open), O = (e) => {
17
+ }, D = "data-pie-latex", O = (e) => e.replaceAll("&", "&amp;").replaceAll("\"", "&quot;").replaceAll("<", "&lt;").replaceAll(">", "&gt;"), k = (e) => typeof e == "string" ? e === "double_dollar" : ["$$", "\\["].includes(e?.open), A = (e) => {
17
18
  let t = e.replaceAll("&nbsp;", " "), n = g(t);
18
19
  if (n === t) try {
19
20
  n = y.convert(t);
20
21
  } catch {
21
22
  return null;
22
23
  }
23
- return !n || n === t ? null : n.replace(S, "") || null;
24
- }, k = (e, t) => {
25
- let n = h(e, { display: D(t) });
26
- return !n || !n.startsWith("<math") ? null : n.replace(C, "").replace("<math", () => `<math ${T}="${E(e)}"`);
27
- }, A = (e, t, n) => {
24
+ return !n || n === t ? null : n.replace(w, "") || null;
25
+ }, j = (e, t) => {
26
+ let n = h(e, { display: k(t) });
27
+ return !n || !n.startsWith("<math") ? null : n.replace(T, "").replace("<math", () => `<math ${D}="${O(e)}"`);
28
+ }, M = (e, t, n) => {
28
29
  if (!t?.mathMlOptions?.mmlEditing) return !1;
29
- let r = n?.getAttribute("display") === "block" ? w : null, i = (n?.getAttribute(T) ?? n?.getAttribute("data-latex"))?.trim();
30
+ let r = n?.getAttribute("display") === "block" ? E : null, i = (n?.getAttribute(D) ?? n?.getAttribute("data-latex"))?.trim();
30
31
  if (i) return {
31
32
  latex: i,
32
33
  wrapper: r
33
34
  };
34
- let a = O(e);
35
+ let a = A(e);
35
36
  if (a === null) return !1;
36
37
  let { unwrapped: o, wrapper: s } = _(a);
37
38
  return {
38
39
  latex: o,
39
40
  wrapper: s || r
40
41
  };
41
- }, j = (e) => {
42
+ }, N = (e) => {
42
43
  let t = document.implementation.createHTMLDocument("").createElement("span");
43
44
  return t.setAttribute("data-type", "mathml"), t.innerHTML = e, t;
44
- }, M = new Set("math maction maligngroup malignmark menclose merror mfenced mfrac mglyph mi mlabeledtr mlongdiv mmultiscripts mn mo mover mpadded mphantom mprescripts mroot mrow ms mscarries mscarry msgroup msline mspace msqrt msrow mstack mstyle msub msubsup msup mtable mtd mtext mtr munder munderover semantics".split(" ")), N = (e) => {
45
- let t = j(e), n = (e) => {
46
- for (let t of Array.from(e.children)) if (!M.has(t.localName)) t.remove();
45
+ }, P = new Set("math maction maligngroup malignmark menclose merror mfenced mfrac mglyph mi mlabeledtr mlongdiv mmultiscripts mn mo mover mpadded mphantom mprescripts mroot mrow ms mscarries mscarry msgroup msline mspace msqrt msrow mstack mstyle msub msubsup msup mtable mtd mtext mtr munder munderover semantics".split(" ")), F = (e) => {
46
+ let t = N(e), n = (e) => {
47
+ for (let t of Array.from(e.children)) if (!P.has(t.localName)) t.remove();
47
48
  else {
48
49
  for (let { name: e, value: n } of Array.from(t.attributes)) (/^on/i.test(e) || /^\s*javascript:/i.test(n)) && t.removeAttribute(e);
49
50
  n(t);
50
51
  }
51
52
  };
52
53
  return n(t), t.innerHTML;
53
- }, P = new u("ensureTextAfterMath"), F = (e = []) => e.map((e) => ({
54
+ }, I = new u("ensureTextAfterMath"), L = (e = []) => e.map((e) => ({
54
55
  name: e,
55
56
  latex: e,
56
57
  write: e,
57
58
  label: e
58
- })), I = (e) => new l({
59
- key: P,
59
+ })), R = (e) => new l({
60
+ key: I,
60
61
  appendTransaction: (t, n, r) => {
61
62
  if (!t.some((e) => e.docChanged)) return null;
62
63
  let i = r.tr, a = !1;
@@ -67,7 +68,7 @@ var S = /\\left\.\s*|\\right\.\s*/g, C = /<mo(?: [^>]*)?>&#x2061;<\/mo>/g, w = {
67
68
  }
68
69
  }), a ? i : null;
69
70
  }
70
- }), L = (e, t) => {
71
+ }), z = (e, t) => {
71
72
  let n;
72
73
  for (n = t; n > 0; n--) {
73
74
  let t = e.nodeAt(n);
@@ -75,16 +76,19 @@ var S = /\\left\.\s*|\\right\.\s*/g, C = /<mo(?: [^>]*)?>&#x2061;<\/mo>/g, w = {
75
76
  if (t && t?.type?.name !== "text") break;
76
77
  }
77
78
  return n;
78
- }, R = new l({
79
+ }, B = (e, t) => {
80
+ let { node: n } = e.domAtPos(t);
81
+ return n.nodeType === 1 ? n : n.parentElement;
82
+ }, V = new l({
79
83
  key: new u("zeroWidthSpaceHandling"),
80
84
  props: { handleKeyDown(e, t) {
81
85
  let { state: n, dispatch: r } = e, { selection: i, doc: a } = n, { from: o, empty: s } = i;
82
86
  if (s && t.key === "Backspace" && o > 0) {
83
- let e = L(a, o);
87
+ let e = z(a, o);
84
88
  return e !== -1 && (r(n.tr.delete(e, o)), !0);
85
89
  }
86
- if (s && t.key === "ArrowLeft" && o > 0) {
87
- let e = L(a, o);
90
+ if (s && o > 0 && S(t.key, B(e, o)) === "inline-start") {
91
+ let e = z(a, o);
88
92
  if (e === -1) return !1;
89
93
  let t = n.doc.resolve(e);
90
94
  if (t.nodeAfter || t.nodeBefore) {
@@ -95,7 +99,7 @@ var S = /\\left\.\s*|\\right\.\s*/g, C = /<mo(?: [^>]*)?>&#x2061;<\/mo>/g, w = {
95
99
  }
96
100
  return !1;
97
101
  } }
98
- }), z = s.create({
102
+ }), H = s.create({
99
103
  name: "math",
100
104
  group: "inline",
101
105
  inline: !0,
@@ -108,7 +112,7 @@ var S = /\\left\.\s*|\\right\.\s*/g, C = /<mo(?: [^>]*)?>&#x2061;<\/mo>/g, w = {
108
112
  };
109
113
  },
110
114
  addProseMirrorPlugins() {
111
- return [I(this.name), R];
115
+ return [R(this.name), V];
112
116
  },
113
117
  parseHTML() {
114
118
  return [
@@ -121,12 +125,12 @@ var S = /\\left\.\s*|\\right\.\s*/g, C = /<mo(?: [^>]*)?>&#x2061;<\/mo>/g, w = {
121
125
  priority: 60,
122
126
  getAttrs: (e) => {
123
127
  let t = e.querySelector("math");
124
- return A(t?.outerHTML || e.innerHTML, this.options, t);
128
+ return M(t?.outerHTML || e.innerHTML, this.options, t);
125
129
  }
126
130
  },
127
131
  {
128
132
  tag: "math",
129
- getAttrs: (e) => A(e.outerHTML, this.options, e)
133
+ getAttrs: (e) => M(e.outerHTML, this.options, e)
130
134
  },
131
135
  {
132
136
  tag: "span[data-type=\"mathml\"]",
@@ -149,10 +153,10 @@ var S = /\\left\.\s*|\\right\.\s*/g, C = /<mo(?: [^>]*)?>&#x2061;<\/mo>/g, w = {
149
153
  } };
150
154
  },
151
155
  renderHTML({ HTMLAttributes: e }) {
152
- if (e.html) return j(e.html);
156
+ if (e.html) return N(e.html);
153
157
  if (this.options.mathMlOptions?.mmlOutput) {
154
- let t = k(e.latex, e.wrapper);
155
- if (t) return j(t);
158
+ let t = j(e.latex, e.wrapper);
159
+ if (t) return N(t);
156
160
  }
157
161
  return [
158
162
  "span",
@@ -164,16 +168,19 @@ var S = /\\left\.\s*|\\right\.\s*/g, C = /<mo(?: [^>]*)?>&#x2061;<\/mo>/g, w = {
164
168
  ];
165
169
  },
166
170
  addNodeView() {
167
- return o((e) => /* @__PURE__ */ p(B, {
171
+ return o((e) => /* @__PURE__ */ p(W, {
168
172
  ...e,
169
173
  options: this.options
170
174
  }));
171
175
  }
172
- }), B = (o) => {
173
- let { node: s, updateAttributes: c, editor: l, selected: u, options: h, getPos: g } = o, [_, v] = i(u), y = r(null), S = r(null), C = r(Date.now()), [w, T] = i({
176
+ }), U = (e, t, n, r, i) => {
177
+ let a = n ? e.right - t : e.left;
178
+ return Math.max(i, Math.min(a, r - t - i));
179
+ }, W = (o) => {
180
+ let { node: s, updateAttributes: c, editor: l, selected: u, options: h, getPos: g } = o, [_, v] = i(u), y = r(null), S = r(null), w = r(Date.now()), [T, E] = i({
174
181
  top: 0,
175
182
  left: 0
176
- }), { math: E = {} } = h || {}, { keypadMode: D, controlledKeypadMode: O = !0, customKeys: k = [], keyPadCharacterRef: A, setKeypadInteraction: j } = E, M = s.attrs.latex || "", P = (e) => {
183
+ }), { math: D = {} } = h || {}, { keypadMode: O, controlledKeypadMode: k = !0, customKeys: A = [], keyPadCharacterRef: j, setKeypadInteraction: M } = D, N = s.attrs.latex || "", P = (e) => {
177
184
  c({ latex: e });
178
185
  }, I = (e, { moveCursorAfterNode: t = !0 } = {}) => {
179
186
  if (c({ latex: e }), v(!1), t && typeof g == "function") {
@@ -194,7 +201,7 @@ var S = /\\left\.\s*|\\right\.\s*/g, C = /<mo(?: [^>]*)?>&#x2061;<\/mo>/g, w = {
194
201
  u
195
202
  ]), n(() => {
196
203
  if (!l || !_) {
197
- T({
204
+ E({
198
205
  top: 0,
199
206
  left: 0
200
207
  });
@@ -202,10 +209,10 @@ var S = /\\left\.\s*|\\right\.\s*/g, C = /<mo(?: [^>]*)?>&#x2061;<\/mo>/g, w = {
202
209
  }
203
210
  let e = () => {
204
211
  if (!y.current) return;
205
- let { from: e } = l.state.selection, t = l.view.coordsAtPos(e), n = S.current?.getBoundingClientRect?.(), r = n?.height ? n.top : t.top, i = n?.width ? n.left : t.left, a = n?.height ? n.bottom : t.bottom ?? t.top, o = y.current.offsetHeight, s = y.current.offsetWidth, c = window.innerHeight - (a + 0) >= o ? a + 0 : r - o - 0, u = i;
206
- c = Math.max(8, Math.min(c, window.innerHeight - o - 8)), u = Math.max(8, Math.min(u, window.innerWidth - s - 8));
207
- let d = (l._tiptapContainerEl || document.body).getBoundingClientRect();
208
- T({
212
+ let { from: e } = l.state.selection, t = l.view.coordsAtPos(e), n = S.current?.getBoundingClientRect?.(), r = C(S.current ?? l.view.dom), i = n?.height ? n.top : t.top, a = n?.height ? n.bottom : t.bottom ?? t.top, o = y.current.offsetHeight, s = y.current.offsetWidth, c = window.innerHeight - (a + 0) >= o ? a + 0 : i - o - 0;
213
+ c = Math.max(8, Math.min(c, window.innerHeight - o - 8));
214
+ let u = U(n?.width ? n : t, s, r, window.innerWidth, 8), d = (l._tiptapContainerEl || document.body).getBoundingClientRect();
215
+ E({
209
216
  top: c - d.top,
210
217
  left: u - d.left
211
218
  });
@@ -224,7 +231,7 @@ var S = /\\left\.\s*|\\right\.\s*/g, C = /<mo(?: [^>]*)?>&#x2061;<\/mo>/g, w = {
224
231
  }, [l, _]), n(() => {
225
232
  let e = performance.now(), t = (t) => {
226
233
  if (t?.timeStamp < e) return;
227
- let n = t?.target, r = (document.querySelectorAll?.("[id^=\"equation-editor-select\"][id*=\"listbox\"], [aria-labelledby=\"equation-editor-label\"][role=\"listbox\"]") || []).length > 0, i = !!(n?.id && n.id.includes("equation-editor-select")) || !!n?.closest?.("[id*=\"equation-editor-select\"]"), a = !!n?.closest?.(`.math-node-${C.current}`);
234
+ let n = t?.target, r = (document.querySelectorAll?.("[id^=\"equation-editor-select\"][id*=\"listbox\"], [aria-labelledby=\"equation-editor-label\"][role=\"listbox\"]") || []).length > 0, i = !!(n?.id && n.id.includes("equation-editor-select")) || !!n?.closest?.("[id*=\"equation-editor-select\"]"), a = !!n?.closest?.(`.math-node-${w.current}`);
228
235
  if (y.current && !y.current.contains(n) && !n?.closest?.("[data-inline-node]") && !r && !i && !a) {
229
236
  v(!1);
230
237
  let e = !!l?.view?.dom?.contains(n);
@@ -236,7 +243,7 @@ var S = /\\left\.\s*|\\right\.\s*/g, C = /<mo(?: [^>]*)?>&#x2061;<\/mo>/g, w = {
236
243
  l,
237
244
  _,
238
245
  s
239
- ]), s.attrs.html && !M ? /* @__PURE__ */ p(a, {
246
+ ]), s.attrs.html && !N ? /* @__PURE__ */ p(a, {
240
247
  as: "span",
241
248
  "data-type": "mathml",
242
249
  style: {
@@ -244,9 +251,9 @@ var S = /\\left\.\s*|\\right\.\s*/g, C = /<mo(?: [^>]*)?>&#x2061;<\/mo>/g, w = {
244
251
  margin: "0 4px"
245
252
  },
246
253
  contentEditable: !1,
247
- dangerouslySetInnerHTML: { __html: N(s.attrs.html) }
254
+ dangerouslySetInnerHTML: { __html: F(s.attrs.html) }
248
255
  }) : /* @__PURE__ */ m(a, {
249
- className: `math-node-${C.current}`,
256
+ className: `math-node-${w.current}`,
250
257
  style: {
251
258
  display: "inline-flex",
252
259
  cursor: "pointer",
@@ -257,31 +264,31 @@ var S = /\\left\.\s*|\\right\.\s*/g, C = /<mo(?: [^>]*)?>&#x2061;<\/mo>/g, w = {
257
264
  ref: S,
258
265
  onClick: () => v(!0),
259
266
  contentEditable: !1,
260
- children: /* @__PURE__ */ p(b, { latex: M })
267
+ children: /* @__PURE__ */ p(b, { latex: N })
261
268
  }), _ && f.createPortal(/* @__PURE__ */ p("div", {
262
269
  ref: y,
263
270
  "data-toolbar-for": l.instanceId,
264
271
  style: {
265
272
  position: "absolute",
266
- top: `${w.top}px`,
267
- left: `${w.left}px`,
273
+ top: `${T.top}px`,
274
+ left: `${T.left}px`,
268
275
  zIndex: 1e3,
269
276
  background: e,
270
277
  boxShadow: "0px 1px 5px 0px rgba(0, 0, 0, 0.2), 0px 2px 2px 0px rgba(0, 0, 0, 0.14), 0px 3px 1px -2px rgba(0, 0, 0, 0.12)"
271
278
  },
272
279
  children: /* @__PURE__ */ p(x, {
273
- latex: M,
280
+ latex: N,
274
281
  autoFocus: !0,
275
282
  onChange: P,
276
283
  onDone: I,
277
- keypadMode: D,
278
- controlledKeypadMode: O,
279
- additionalKeys: F(k),
280
- keyPadCharacterRef: A,
281
- setKeypadInteraction: j
284
+ keypadMode: O,
285
+ controlledKeypadMode: k,
286
+ additionalKeys: L(A),
287
+ keyPadCharacterRef: j,
288
+ setKeypadInteraction: M
282
289
  })
283
290
  }), l?._tiptapContainerEl || document.body)]
284
291
  });
285
292
  };
286
293
  //#endregion
287
- export { I as EnsureTextAfterMathPlugin, z as MathNode, B as MathNodeView, R as ZeroWidthSpaceHandlingPlugin, k as convertLatexToMathMl, O as convertMathMlToLatex, N as sanitizeMathMl };
294
+ export { R as EnsureTextAfterMathPlugin, H as MathNode, W as MathNodeView, V as ZeroWidthSpaceHandlingPlugin, j as convertLatexToMathMl, A as convertMathMlToLatex, U as mathToolbarLeft, F as sanitizeMathMl };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-lib/editable-html-tip-tap",
3
- "version": "3.1.3-next.20261027184745",
3
+ "version": "3.1.3-next.20261102105711",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,10 +14,10 @@
14
14
  "@mui/icons-material": "^7.3.4",
15
15
  "@mui/material": "^7.3.4",
16
16
  "@pie-framework/mathml-to-latex": "1.4.4",
17
- "@pie-lib/drag": "5.0.8-next.20261026212738",
18
- "@pie-lib/math-input": "9.0.8-next.20261027184745",
19
- "@pie-lib/math-toolbar": "4.0.8-next.20261027184745",
20
- "@pie-lib/render-ui": "8.0.8-next.20261026212738",
17
+ "@pie-lib/drag": "5.0.8-next.20261027193325",
18
+ "@pie-lib/math-input": "9.0.8-next.20261027193325",
19
+ "@pie-lib/math-toolbar": "4.0.8-next.20261027193325",
20
+ "@pie-lib/render-ui": "8.0.8-next.20261027193325",
21
21
  "@pie-lib/translator": "5.0.3-next.20261027184745",
22
22
  "@tiptap/core": "3.32.0",
23
23
  "@tiptap/extension-character-count": "3.32.0",
@@ -45,6 +45,7 @@
45
45
  "to-style": "^1.3.3",
46
46
  "@pie-element/shared-i18n": "0.1.3-next.20261026212738",
47
47
  "@pie-element/shared-lodash": "0.1.4-next.20261026212738",
48
+ "@pie-element/shared-utils": "0.1.7-next.20261027193325",
48
49
  "clsx": "^2.1.1",
49
50
  "prosemirror-state": "^1.4.4",
50
51
  "@pie-element/shared-math-rendering-mathjax": "0.1.9-next.20261026200905",