@pie-lib/editable-html-tip-tap 3.1.3-next.20261109082044 → 3.1.3-next.20261109125924

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.
@@ -4,46 +4,47 @@ import { setPendingSaveFlush as n } from "../pending-save.js";
4
4
  import r from "../extensions/extended-table.js";
5
5
  import { ExtendedTableCell as i, ExtendedTableHeader as a } from "../extensions/extended-table-cell.js";
6
6
  import { DivNode as ee } from "../extensions/div-node.js";
7
- import { EnsureEmptyRootIsDiv as te } from "../extensions/ensure-empty-root-div.js";
8
- import { EnsureListItemContentIsDiv as ne } from "../extensions/ensure-list-item-content-is-div.js";
9
- import { DragInTheBlankNode as re, ExplicitConstructedResponseNode as ie, InlineDropdownNode as ae, MathTemplatedNode as oe, ResponseAreaExtension as se } from "../extensions/responseArea.js";
7
+ import { InactiveCaret as te } from "../extensions/inactive-caret.js";
8
+ import { EnsureEmptyRootIsDiv as ne } from "../extensions/ensure-empty-root-div.js";
9
+ import { EnsureListItemContentIsDiv as re } from "../extensions/ensure-list-item-content-is-div.js";
10
+ import { DragInTheBlankNode as ie, ExplicitConstructedResponseNode as ae, InlineDropdownNode as oe, MathTemplatedNode as o, ResponseAreaExtension as se } from "../extensions/responseArea.js";
10
11
  import { MathNode as ce } from "../extensions/math.js";
11
- import { ImageUploadNode as le, uploadPastedImage as o } from "../extensions/image.js";
12
- import { Media as s } from "../extensions/media.js";
13
- import { CSSMark as ue } from "../extensions/css.js";
14
- import { ExtendedListItem as de } from "../extensions/extended-list-item.js";
15
- import { HeadingParagraph as fe } from "../extensions/heading-paragraph.js";
16
- import { BlockDirection as pe, ContentLanguage as me } from "../extensions/text-direction.js";
17
- import { valueToSize as c } from "../utils/size.js";
18
- import { contentLanguageChoices as he } from "../utils/content-languages.js";
19
- import ge from "./TiptapContainer.js";
20
- import { PLUGINS_MAP as _e, buildExtensions as ve } from "../extensions/index.js";
21
- import { useCallback as l, useEffect as u, useMemo as d, useRef as f, useState as p } from "react";
22
- import { debounce as m } from "@pie-element/shared-lodash";
23
- import { elementLanguageAttributes as h, subscribeInterfaceLocale as ye } from "@pie-element/shared-i18n";
24
- import { EditorContent as g, useEditor as be, useEditorState as xe } from "@tiptap/react";
25
- import { styled as _ } from "@mui/material/styles";
26
- import Se from "@tiptap/starter-kit";
27
- import { TextStyleKit as Ce } from "@tiptap/extension-text-style";
28
- import { CharacterCount as we } from "@tiptap/extension-character-count";
29
- import Te from "@tiptap/extension-superscript";
30
- import Ee from "@tiptap/extension-subscript";
31
- import De from "@tiptap/extension-text-align";
32
- import Oe from "@tiptap/extension-placeholder";
33
- import { TableRow as v } from "@tiptap/extension-table-row";
34
- import { jsx as y } from "react/jsx-runtime";
12
+ import { ImageUploadNode as le, uploadPastedImage as ue } from "../extensions/image.js";
13
+ import { Media as de } from "../extensions/media.js";
14
+ import { CSSMark as fe } from "../extensions/css.js";
15
+ import { ExtendedListItem as pe } from "../extensions/extended-list-item.js";
16
+ import { HeadingParagraph as me } from "../extensions/heading-paragraph.js";
17
+ import { BlockDirection as he, ContentLanguage as ge } from "../extensions/text-direction.js";
18
+ import { valueToSize as s } from "../utils/size.js";
19
+ import { contentLanguageChoices as _e } from "../utils/content-languages.js";
20
+ import ve from "./TiptapContainer.js";
21
+ import { PLUGINS_MAP as ye, buildExtensions as be } from "../extensions/index.js";
22
+ import { useCallback as c, useEffect as l, useMemo as u, useRef as d, useState as f } from "react";
23
+ import { debounce as p } from "@pie-element/shared-lodash";
24
+ import { elementLanguageAttributes as m, subscribeInterfaceLocale as xe } from "@pie-element/shared-i18n";
25
+ import { EditorContent as h, useEditor as Se, useEditorState as Ce } from "@tiptap/react";
26
+ import { styled as g } from "@mui/material/styles";
27
+ import we from "@tiptap/starter-kit";
28
+ import { TextStyleKit as Te } from "@tiptap/extension-text-style";
29
+ import { CharacterCount as Ee } from "@tiptap/extension-character-count";
30
+ import De from "@tiptap/extension-superscript";
31
+ import Oe from "@tiptap/extension-subscript";
32
+ import ke from "@tiptap/extension-text-align";
33
+ import Ae from "@tiptap/extension-placeholder";
34
+ import { TableRow as _ } from "@tiptap/extension-table-row";
35
+ import { jsx as v } from "react/jsx-runtime";
35
36
  //#region src/components/EditableHtml.tsx
36
- var b = {
37
+ var y = {
37
38
  position: "bottom",
38
39
  alignment: "left",
39
40
  alwaysVisible: !1,
40
41
  showDone: !0,
41
42
  doneOn: "blur"
42
- }, x = {
43
+ }, b = {
43
44
  options: {},
44
45
  respAreaToolbar: () => {},
45
46
  onHandleAreaChange: () => {}
46
- }, S = [
47
+ }, x = [
47
48
  "bold",
48
49
  "italic",
49
50
  "underline",
@@ -65,7 +66,7 @@ var b = {
65
66
  "h3",
66
67
  "undo",
67
68
  "redo"
68
- ], C = {
69
+ ], S = {
69
70
  bold: "bold",
70
71
  italic: "italic",
71
72
  underline: "underline",
@@ -76,7 +77,7 @@ var b = {
76
77
  "numbered-list": "orderedList",
77
78
  table: "table",
78
79
  image: "image"
79
- }, w = {
80
+ }, C = {
80
81
  "--white": "#fff",
81
82
  "--black": "#2e2b29",
82
83
  "--black-contrast": "#110f0e",
@@ -95,7 +96,7 @@ var b = {
95
96
  "--red": "#ff5c33",
96
97
  "--red-light": "#ffebe5",
97
98
  "--shadow": "0px 12px 33px 0px rgba(0, 0, 0, .06),\n 0px 3.618px 9.949px 0px rgba(0, 0, 0, .04)"
98
- }, T = (e, t, n, r) => ({
99
+ }, w = (e, t, n, r) => ({
99
100
  role: "textbox",
100
101
  "data-pie-editor": "true",
101
102
  class: "mathjax_ignore",
@@ -104,40 +105,40 @@ var b = {
104
105
  autocapitalize: e ? "on" : "off",
105
106
  ...t && { "aria-label": t },
106
107
  ...n && { "aria-labelledby": n },
107
- ...h(r)
108
- }), E = [
108
+ ...m(r)
109
+ }), T = [
109
110
  "aria-label",
110
111
  "aria-labelledby",
111
112
  "lang",
112
113
  "dir"
113
- ], D = (e) => e._insertingImage || e._toolbarOpened || e.isActive("inline_dropdown") || e.isActive("explicit_constructed_response"), O = (g) => {
114
- let { showParagraphs: _, separateParagraphs: O } = g.pluginProps || {}, [Ae, k] = p([]), [je, Me] = p(!1), { toolbarOpts: Ne } = g, A = l((e) => {
115
- k((t) => {
114
+ ], E = (e) => e._insertingImage || e._toolbarOpened || e.isActive("inline_dropdown") || e.isActive("explicit_constructed_response"), D = (h) => {
115
+ let { showParagraphs: g, separateParagraphs: D } = h.pluginProps || {}, [Me, O] = f([]), [Ne, k] = f(!1), { toolbarOpts: Pe } = h, A = c((e) => {
116
+ O((t) => {
116
117
  let n = t.filter((t) => t.pos !== e);
117
- return n.length === 0 && Me(!1), n;
118
+ return n.length === 0 && k(!1), n;
118
119
  });
119
- }, [k]), j = {
120
- ...b,
121
- ...Ne
122
- }, M = f([]), N = (e) => {
123
- M.current = [...M.current.slice(-4), e], g.onChange?.(e);
124
- }, P = f(N);
120
+ }, [O]), j = {
121
+ ...y,
122
+ ...Pe
123
+ }, M = d([]), N = (e) => {
124
+ M.current = [...M.current.slice(-4), e], h.onChange?.(e);
125
+ }, P = d(N);
125
126
  P.current = N;
126
- let F = l((e) => {
127
+ let F = c((e) => {
127
128
  let t = e.getHTML();
128
- g.markup !== t && P.current(t), j.doneOn === "blur" && g.onDone?.(t);
129
+ h.markup !== t && P.current(t), j.doneOn === "blur" && h.onDone?.(t);
129
130
  }, [
130
- g.markup,
131
- g.onChange,
132
- g.onDone,
131
+ h.markup,
132
+ h.onChange,
133
+ h.onDone,
133
134
  j.doneOn
134
- ]), I = f(F);
135
+ ]), I = d(F);
135
136
  I.current = F;
136
- let { idleSaveDelay: L } = g, R = f(!1), z = d(() => L > 0 ? m((e) => {
137
- e.isDestroyed || (!R.current && (e.view.composing || D(e)) ? B.current?.(e) : I.current(e));
138
- }, L) : null, [L]), B = f(z);
137
+ let { idleSaveDelay: L } = h, R = d(!1), z = u(() => L > 0 ? p((e) => {
138
+ e.isDestroyed || (!R.current && (e.view.composing || E(e)) ? B.current?.(e) : I.current(e));
139
+ }, L) : null, [L]), B = d(z);
139
140
  B.current = z;
140
- let V = l((e) => {
141
+ let V = c((e) => {
141
142
  R.current = !0;
142
143
  try {
143
144
  e?.flush();
@@ -145,43 +146,43 @@ var b = {
145
146
  R.current = !1;
146
147
  }
147
148
  }, []);
148
- u(() => () => V(z), [z, V]);
149
- let Pe = l(() => V(B.current), [V]), H = d(() => ({
150
- ...x,
151
- ...g.responseAreaProps,
149
+ l(() => () => V(z), [z, V]);
150
+ let Fe = c(() => V(B.current), [V]), H = u(() => ({
151
+ ...b,
152
+ ...h.responseAreaProps,
152
153
  onInlineDropdownToolbarClose: F
153
- }), [g.responseAreaProps, F]), U = d(() => {
154
- let { customPlugins: e, ...t } = g.pluginProps || {};
154
+ }), [h.responseAreaProps, F]), U = u(() => {
155
+ let { customPlugins: e, ...t } = h.pluginProps || {};
155
156
  e ||= [];
156
- let n = t.textDirection?.disabled === !1 || h(g.language)?.dir === "rtl", r = [...g.activePlugins || S, ...n ? ["text-direction"] : []].filter((e) => {
157
- let n = _e[e] || e, r = t[n] || {};
157
+ let n = t.textDirection?.disabled === !1 || m(h.language)?.dir === "rtl", r = [...h.activePlugins || x, ...n ? ["text-direction"] : []].filter((e) => {
158
+ let n = ye[e] || e, r = t[n] || {};
158
159
  return !r || !r.disabled;
159
160
  });
160
- return ve(r, e, {
161
+ return be(r, e, {
161
162
  math: {},
162
- textAlign: g.textAlign,
163
+ textAlign: h.textAlign,
163
164
  html: {},
164
- extraCSSRules: g.extraCSSRules || {},
165
- image: { ...g.imageSupport },
165
+ extraCSSRules: h.extraCSSRules || {},
166
+ image: { ...h.imageSupport },
166
167
  toolbar: {},
167
168
  table: {},
168
169
  responseArea: { type: H.type },
169
- languageCharacters: g.languageCharactersProps,
170
+ languageCharacters: h.languageCharactersProps,
170
171
  keyPadCharacterRef: {},
171
172
  setKeypadInteraction: {},
172
173
  media: {}
173
174
  });
174
- }, [g, H.type]), W = f(null);
175
+ }, [h, H.type]), W = d(null);
175
176
  W.current = {
176
- plainText: g.pluginProps?.pasteFormatting?.disabled === !0,
177
- formatting: U.map((e) => C[e]).filter(Boolean)
177
+ plainText: h.pluginProps?.pasteFormatting?.disabled === !0,
178
+ formatting: U.map((e) => S[e]).filter(Boolean)
178
179
  };
179
- let G = f("ltr");
180
- G.current = h(g.language)?.dir ?? "ltr";
181
- let [Fe, Ie] = p(null), K = f(() => []);
182
- K.current = () => he(g.language, Fe);
183
- let q = [
184
- De.configure({
180
+ let G = d("ltr");
181
+ G.current = m(h.language)?.dir ?? "ltr";
182
+ let [K, Ie] = f(null), q = d(() => []);
183
+ q.current = () => _e(h.language, K);
184
+ let Le = [
185
+ ke.configure({
185
186
  types: [
186
187
  "heading",
187
188
  "paragraph",
@@ -205,15 +206,15 @@ var b = {
205
206
  "right"
206
207
  ]
207
208
  }),
208
- pe.configure({ baseDirection: () => G.current }),
209
- me.configure({ languages: () => K.current() }),
210
- Ce,
209
+ he.configure({ baseDirection: () => G.current }),
210
+ ge.configure({ languages: () => q.current() }),
211
+ Te,
211
212
  e.configure({
212
213
  settings: () => W.current,
213
- uploadImage: g.imageSupport && o
214
+ uploadImage: h.imageSupport && ue
214
215
  }),
215
- we.configure({ limit: g.charactersLimit || 1e6 }),
216
- Se.configure({
216
+ Ee.configure({ limit: h.charactersLimit || 1e6 }),
217
+ we.configure({
217
218
  trailingNode: {
218
219
  node: "paragraph",
219
220
  notAfter: ["paragraph", "div"]
@@ -223,104 +224,105 @@ var b = {
223
224
  linkOnPaste: !1
224
225
  }
225
226
  }),
226
- de,
227
+ pe,
227
228
  ee,
228
- fe,
229
- te,
229
+ me,
230
230
  ne,
231
- Oe.configure({
232
- placeholder: g.placeholder,
231
+ re,
232
+ Ae.configure({
233
+ placeholder: h.placeholder,
233
234
  showOnlyWhenEditable: !0,
234
235
  showOnlyCurrent: !1,
235
236
  includeChildren: !0
236
237
  }),
238
+ te,
237
239
  r,
238
- v,
240
+ _,
239
241
  a,
240
242
  i,
241
243
  se.configure(H),
242
- ie.configure(H),
243
- re.configure(H),
244
244
  ae.configure(H),
245
+ ie.configure(H),
245
246
  oe.configure(H),
247
+ o.configure(H),
246
248
  ce.configure({
247
249
  toolbarOpts: j,
248
- math: g.pluginProps?.math || {},
249
- mathMlOptions: g.mathMlOptions || {}
250
+ math: h.pluginProps?.math || {},
251
+ mathMlOptions: h.mathMlOptions || {}
250
252
  }),
251
- Ee,
252
- Te,
253
+ Oe,
254
+ De,
253
255
  le.configure({
254
256
  toolbarOpts: j,
255
257
  imageHandling: {
256
- disableImageAlignmentButtons: g.disableImageAlignmentButtons,
257
- onDone: (e) => g.onDone?.(e.getHTML()),
258
- onDelete: g.imageSupport && g.imageSupport.delete && ((e) => {
258
+ disableImageAlignmentButtons: h.disableImageAlignmentButtons,
259
+ onDone: (e) => h.onDone?.(e.getHTML()),
260
+ onDelete: h.imageSupport && h.imageSupport.delete && ((e) => {
259
261
  let { src: t } = e.attrs;
260
- g.imageSupport.delete(t, (t) => {
262
+ h.imageSupport.delete(t, (t) => {
261
263
  A(e.pos);
262
264
  });
263
265
  }),
264
- insertImageRequested: g.imageSupport && ((e, t, n) => {
266
+ insertImageRequested: h.imageSupport && ((e, t, n) => {
265
267
  let [r, i] = t, a = (t) => {
266
268
  let n;
267
- je && t && (n = P.current), A(i), n?.(e.getHTML());
269
+ Ne && t && (n = P.current), A(i), n?.(e.getHTML());
268
270
  };
269
- e._insertingImage = !0, k((e) => [...e, r]), (() => {
270
- let t = n(a), r = m(() => {
271
+ e._insertingImage = !0, O((e) => [...e, r]), (() => {
272
+ let t = n(a), r = p(() => {
271
273
  e._insertingImage &&= (A(i), !1), window.removeEventListener("focus", r);
272
274
  }, 500);
273
- window.addEventListener("focus", r), g.imageSupport.add(t);
275
+ window.addEventListener("focus", r), h.imageSupport.add(t);
274
276
  })();
275
277
  }),
276
- maxImageWidth: g.maxImageWidth,
277
- maxImageHeight: g.maxImageHeight
278
+ maxImageWidth: h.maxImageWidth,
279
+ maxImageHeight: h.maxImageHeight
278
280
  },
279
281
  limit: 3
280
282
  }),
281
- s.configure({ uploadSoundSupport: g.uploadSoundSupport }),
282
- ue.configure({ extraCSSRules: g.extraCSSRules })
283
- ], J = g.spellCheck !== !1, { ariaLabel: Y, ariaLabelledBy: X, language: Z } = g, Q = be({
284
- extensions: q,
283
+ de.configure({ uploadSoundSupport: h.uploadSoundSupport }),
284
+ fe.configure({ extraCSSRules: h.extraCSSRules })
285
+ ], J = h.spellCheck !== !1, { ariaLabel: Y, ariaLabelledBy: X, language: Z } = h, Q = Se({
286
+ extensions: Le,
285
287
  immediatelyRender: !1,
286
288
  editorProps: {
287
- attributes: T(J, Y, X, Z),
289
+ attributes: w(J, Y, X, Z),
288
290
  handleKeyDown(e, t) {
289
- return g.onKeyDown ? g.onKeyDown(t) : !1;
291
+ return h.onKeyDown ? h.onKeyDown(t) : !1;
290
292
  }
291
293
  },
292
- editable: !g.disabled,
293
- content: t(g.markup),
294
+ editable: !h.disabled,
295
+ content: t(h.markup),
294
296
  onUpdate: ({ editor: e, transaction: t }) => {
295
- t.isDone && P.current(e.getHTML()), t.docChanged && B.current && (B.current(e), n(e.view.dom, Pe));
297
+ t.isDone && P.current(e.getHTML()), t.docChanged && B.current && (B.current(e), n(e.view.dom, Fe));
296
298
  },
297
299
  onBlur: ({ editor: e }) => {
298
- !D(e) && e.schema && (B.current?.cancel(), F(e));
300
+ !E(e) && e.schema && (B.current?.cancel(), F(e));
299
301
  }
300
302
  }, [
301
- g.charactersLimit,
302
- g.mathMlOptions?.mmlEditing,
303
- g.mathMlOptions?.mmlOutput
303
+ h.charactersLimit,
304
+ h.mathMlOptions?.mmlEditing,
305
+ h.mathMlOptions?.mmlOutput
304
306
  ]);
305
- u(() => {
306
- g.editorRef && g.editorRef(Q);
307
- }, [g.editorRef, Q]), u(() => {
308
- Q?.setEditable(!g.disabled);
309
- }, [g.disabled, Q]), u(() => {
307
+ l(() => {
308
+ h.editorRef && h.editorRef(Q);
309
+ }, [h.editorRef, Q]), l(() => {
310
+ Q?.setEditable(!h.disabled);
311
+ }, [h.disabled, Q]), l(() => {
310
312
  let e;
311
313
  try {
312
314
  e = Q?.view?.dom;
313
315
  } catch {
314
316
  return;
315
317
  }
316
- return e ? ye(e, (e) => Ie(e?.locale ?? null)) : void 0;
317
- }, [Q]), u(() => {
318
+ return e ? xe(e, (e) => Ie(e?.locale ?? null)) : void 0;
319
+ }, [Q]), l(() => {
318
320
  Q?.on("destroy", () => V(B.current));
319
- }, [Q, V]), u(() => {
321
+ }, [Q, V]), l(() => {
320
322
  if (!Q) return;
321
- let e = Q.options?.editorProps, t = e?.attributes || {}, n = T(J, Y, X, Z);
322
- if (["spellcheck", ...E].every((e) => t[e] === n[e])) return;
323
- let r = Object.fromEntries(Object.entries(t).filter(([e]) => !E.includes(e)));
323
+ let e = Q.options?.editorProps, t = e?.attributes || {}, n = w(J, Y, X, Z);
324
+ if (["spellcheck", ...T].every((e) => t[e] === n[e])) return;
325
+ let r = Object.fromEntries(Object.entries(t).filter(([e]) => !T.includes(e)));
324
326
  Q.setOptions({ editorProps: {
325
327
  ...e,
326
328
  attributes: {
@@ -334,50 +336,58 @@ var b = {
334
336
  X,
335
337
  Z,
336
338
  Q
337
- ]), u(() => {
338
- if (!Q || M.current.includes(g.markup)) return;
339
+ ]), l(() => {
340
+ if (!Q || M.current.includes(h.markup)) return;
339
341
  M.current = [];
340
- let e = t(g.markup);
342
+ let e = t(h.markup);
341
343
  e !== Q.getHTML() && Q.commands.setContent(e, { emitUpdate: !1 });
342
- }, [g.markup, Q]), u(() => {
343
- Object.entries(w).forEach(([e, t]) => {
344
+ }, [h.markup, Q]), l(() => {
345
+ Object.entries(C).forEach(([e, t]) => {
344
346
  document.documentElement.style.setProperty(e, t);
345
347
  });
346
348
  }, []);
347
- let Le = xe({
349
+ let Re = Ce({
348
350
  editor: Q,
349
351
  selector: (e) => ({ isFocused: e.editor?.isFocused })
350
- }), $ = d(() => {
351
- let { minWidth: e, width: t, maxWidth: n, minHeight: r, height: i, maxHeight: a } = g;
352
+ }), $ = u(() => {
353
+ let { minWidth: e, width: t, maxWidth: n, minHeight: r, height: i, maxHeight: a } = h;
352
354
  return {
353
- width: c(t),
354
- minWidth: c(e),
355
- maxWidth: c(n),
356
- height: c(i),
357
- minHeight: c(r),
358
- maxHeight: c(a)
355
+ width: s(t),
356
+ minWidth: s(e),
357
+ maxWidth: s(n),
358
+ height: s(i),
359
+ minHeight: s(r),
360
+ maxHeight: s(a)
359
361
  };
360
- }, [g]);
361
- return /* @__PURE__ */ y(ge, {
362
- ...g,
362
+ }, [h]);
363
+ return /* @__PURE__ */ v(ve, {
364
+ ...h,
363
365
  activePlugins: U,
364
366
  toolbarOpts: j,
365
- editorState: Le,
367
+ language: K ?? h.language,
368
+ editorState: Re,
366
369
  editor: Q,
367
- children: Q && /* @__PURE__ */ y(ke, {
370
+ children: Q && /* @__PURE__ */ v(je, {
368
371
  style: {
369
372
  minHeight: $.minHeight,
370
373
  height: $.height,
371
374
  maxHeight: $.maxHeight
372
375
  },
373
- showParagraph: _ && !_.disabled,
374
- separateParagraph: O && !O.disabled,
376
+ showParagraph: g && !g.disabled,
377
+ separateParagraph: D && !D.disabled,
375
378
  editor: Q
376
379
  })
377
380
  });
378
- }, ke = _(g, { shouldForwardProp: (e) => !["showParagraph", "separateParagraph"].includes(e) })(({ showParagraph: e, separateParagraph: t }) => ({
381
+ }, je = g(h, { shouldForwardProp: (e) => !["showParagraph", "separateParagraph"].includes(e) })(({ showParagraph: e, separateParagraph: t }) => ({
379
382
  display: "flex",
380
383
  outline: "none !important",
384
+ position: "relative",
385
+ "& > .pie-inactive-caret": {
386
+ position: "absolute",
387
+ width: 0,
388
+ borderLeft: "1px solid currentColor",
389
+ pointerEvents: "none"
390
+ },
381
391
  "& .ProseMirror": {
382
392
  flex: 1,
383
393
  padding: "5px",
@@ -405,4 +415,4 @@ var b = {
405
415
  }
406
416
  }));
407
417
  //#endregion
408
- export { O as EditableHtml, O as default };
418
+ export { D as EditableHtml, D as default };