@pie-lib/editable-html-tip-tap 3.0.1-next.20261004011201 → 3.0.1-next.20261004020741

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.
@@ -3,44 +3,44 @@ import { normalizeInitialMarkup as t } from "../utils/helper.js";
3
3
  import n from "../extensions/extended-table.js";
4
4
  import { ExtendedTableCell as r, ExtendedTableHeader as i } from "../extensions/extended-table-cell.js";
5
5
  import { DivNode as a } from "../extensions/div-node.js";
6
- import { EnsureEmptyRootIsDiv as ee } from "../extensions/ensure-empty-root-div.js";
7
- import { EnsureListItemContentIsDiv as o } from "../extensions/ensure-list-item-content-is-div.js";
8
- import { DragInTheBlankNode as s, ExplicitConstructedResponseNode as c, InlineDropdownNode as te, MathTemplatedNode as ne, ResponseAreaExtension as re } from "../extensions/responseArea.js";
9
- import { MathNode as l } from "../extensions/math.js";
10
- import { ImageUploadNode as u } from "../extensions/image.js";
11
- import { Media as d } from "../extensions/media.js";
12
- import { CSSMark as f } from "../extensions/css.js";
13
- import { ExtendedListItem as ie } from "../extensions/extended-list-item.js";
14
- import { HeadingParagraph as p } from "../extensions/heading-paragraph.js";
15
- import { valueToSize as m } from "../utils/size.js";
16
- import ae from "./TiptapContainer.js";
17
- import { PLUGINS_MAP as h, buildExtensions as g } from "../extensions/index.js";
18
- import { useCallback as _, useEffect as v, useMemo as y, useState as b } from "react";
19
- import { debounce as x } from "@pie-element/shared-lodash";
20
- import { EditorContent as S, useEditor as C, useEditorState as w } from "@tiptap/react";
21
- import { styled as T } from "@mui/material/styles";
22
- import E from "@tiptap/starter-kit";
23
- import { TextStyleKit as D } from "@tiptap/extension-text-style";
24
- import { CharacterCount as O } from "@tiptap/extension-character-count";
25
- import k from "@tiptap/extension-superscript";
26
- import A from "@tiptap/extension-subscript";
27
- import j from "@tiptap/extension-text-align";
28
- import M from "@tiptap/extension-image";
29
- import N from "@tiptap/extension-placeholder";
30
- import { TableRow as P } from "@tiptap/extension-table-row";
31
- import { jsx as F } from "react/jsx-runtime";
6
+ import { EnsureEmptyRootIsDiv as o } from "../extensions/ensure-empty-root-div.js";
7
+ import { EnsureListItemContentIsDiv as ee } from "../extensions/ensure-list-item-content-is-div.js";
8
+ import { DragInTheBlankNode as s, ExplicitConstructedResponseNode as te, InlineDropdownNode as ne, MathTemplatedNode as re, ResponseAreaExtension as ie } from "../extensions/responseArea.js";
9
+ import { MathNode as c } from "../extensions/math.js";
10
+ import { ImageUploadNode as l } from "../extensions/image.js";
11
+ import { Media as u } from "../extensions/media.js";
12
+ import { CSSMark as d } from "../extensions/css.js";
13
+ import { ExtendedListItem as ae } from "../extensions/extended-list-item.js";
14
+ import { HeadingParagraph as oe } from "../extensions/heading-paragraph.js";
15
+ import { valueToSize as f } from "../utils/size.js";
16
+ import p from "./TiptapContainer.js";
17
+ import { PLUGINS_MAP as m, buildExtensions as h } from "../extensions/index.js";
18
+ import { useCallback as g, useEffect as _, useMemo as v, useState as y } from "react";
19
+ import { debounce as se } from "@pie-element/shared-lodash";
20
+ import { EditorContent as b, useEditor as x, useEditorState as S } from "@tiptap/react";
21
+ import { styled as C } from "@mui/material/styles";
22
+ import w from "@tiptap/starter-kit";
23
+ import { TextStyleKit as T } from "@tiptap/extension-text-style";
24
+ import { CharacterCount as E } from "@tiptap/extension-character-count";
25
+ import D from "@tiptap/extension-superscript";
26
+ import O from "@tiptap/extension-subscript";
27
+ import k from "@tiptap/extension-text-align";
28
+ import A from "@tiptap/extension-image";
29
+ import j from "@tiptap/extension-placeholder";
30
+ import { TableRow as M } from "@tiptap/extension-table-row";
31
+ import { jsx as N } from "react/jsx-runtime";
32
32
  //#region src/components/EditableHtml.tsx
33
- var I = {
33
+ var P = {
34
34
  position: "bottom",
35
35
  alignment: "left",
36
36
  alwaysVisible: !1,
37
37
  showDone: !0,
38
38
  doneOn: "blur"
39
- }, L = {
39
+ }, F = {
40
40
  options: {},
41
41
  respAreaToolbar: () => {},
42
42
  onHandleAreaChange: () => {}
43
- }, R = [
43
+ }, ce = [
44
44
  "bold",
45
45
  "italic",
46
46
  "underline",
@@ -62,7 +62,7 @@ var I = {
62
62
  "h3",
63
63
  "undo",
64
64
  "redo"
65
- ], z = {
65
+ ], I = {
66
66
  "--white": "#fff",
67
67
  "--black": "#2e2b29",
68
68
  "--black-contrast": "#110f0e",
@@ -81,57 +81,59 @@ var I = {
81
81
  "--red": "#ff5c33",
82
82
  "--red-light": "#ffebe5",
83
83
  "--shadow": "0px 12px 33px 0px rgba(0, 0, 0, .06),\n 0px 3.618px 9.949px 0px rgba(0, 0, 0, .04)"
84
- }, B = (e) => ({
84
+ }, L = (e, t, n) => ({
85
85
  role: "textbox",
86
86
  "data-pie-editor": "true",
87
87
  class: "mathjax_ignore",
88
88
  spellcheck: e ? "true" : "false",
89
89
  autocorrect: e ? "on" : "off",
90
- autocapitalize: e ? "on" : "off"
91
- }), V = (S) => {
92
- let { showParagraphs: T, separateParagraphs: V } = S.pluginProps || {}, [oe, U] = b([]), [W, G] = b(!1), { toolbarOpts: K } = S, q = _((e) => {
93
- U((t) => {
90
+ autocapitalize: e ? "on" : "off",
91
+ ...t && { "aria-label": t },
92
+ ...n && { "aria-labelledby": n }
93
+ }), R = ["aria-label", "aria-labelledby"], z = (b) => {
94
+ let { showParagraphs: C, separateParagraphs: z } = b.pluginProps || {}, [le, V] = y([]), [H, U] = y(!1), { toolbarOpts: W } = b, G = g((e) => {
95
+ V((t) => {
94
96
  let n = t.filter((t) => t.pos !== e);
95
- return n.length === 0 && G(!1), n;
97
+ return n.length === 0 && U(!1), n;
96
98
  });
97
- }, [U]), J = {
98
- ...I,
99
- ...K
100
- }, Y = _((e) => {
99
+ }, [V]), K = {
100
+ ...P,
101
+ ...W
102
+ }, q = g((e) => {
101
103
  let t = e.getHTML();
102
- S.markup !== t && S.onChange?.(t), J.doneOn === "blur" && S.onDone?.(t);
104
+ b.markup !== t && b.onChange?.(t), K.doneOn === "blur" && b.onDone?.(t);
103
105
  }, [
104
- S.markup,
105
- S.onChange,
106
- S.onDone,
107
- J.doneOn
108
- ]), X = y(() => ({
109
- ...L,
110
- ...S.responseAreaProps,
111
- onInlineDropdownToolbarClose: Y
112
- }), [S.responseAreaProps, Y]), se = y(() => {
113
- let { customPlugins: e, ...t } = S.pluginProps || {};
106
+ b.markup,
107
+ b.onChange,
108
+ b.onDone,
109
+ K.doneOn
110
+ ]), J = v(() => ({
111
+ ...F,
112
+ ...b.responseAreaProps,
113
+ onInlineDropdownToolbarClose: q
114
+ }), [b.responseAreaProps, q]), ue = v(() => {
115
+ let { customPlugins: e, ...t } = b.pluginProps || {};
114
116
  e ||= [];
115
- let n = (S.activePlugins || R)?.filter((e) => {
116
- let n = h[e] || e, r = t[n] || {};
117
+ let n = (b.activePlugins || ce)?.filter((e) => {
118
+ let n = m[e] || e, r = t[n] || {};
117
119
  return !r || !r.disabled;
118
120
  });
119
- return g(n, e, {
121
+ return h(n, e, {
120
122
  math: {},
121
- textAlign: S.textAlign,
123
+ textAlign: b.textAlign,
122
124
  html: {},
123
- extraCSSRules: S.extraCSSRules || {},
124
- image: { ...S.imageSupport },
125
+ extraCSSRules: b.extraCSSRules || {},
126
+ image: { ...b.imageSupport },
125
127
  toolbar: {},
126
128
  table: {},
127
- responseArea: { type: X.type },
128
- languageCharacters: S.languageCharactersProps,
129
+ responseArea: { type: J.type },
130
+ languageCharacters: b.languageCharactersProps,
129
131
  keyPadCharacterRef: {},
130
132
  setKeypadInteraction: {},
131
133
  media: {}
132
134
  });
133
- }, [S, X.type]), ce = [
134
- j.configure({
135
+ }, [b, J.type]), de = [
136
+ k.configure({
135
137
  types: [
136
138
  "heading",
137
139
  "paragraph",
@@ -153,10 +155,10 @@ var I = {
153
155
  "justify"
154
156
  ]
155
157
  }),
156
- D,
158
+ T,
157
159
  e,
158
- O.configure({ limit: S.charactersLimit || 1e6 }),
159
- E.configure({
160
+ E.configure({ limit: b.charactersLimit || 1e6 }),
161
+ w.configure({
160
162
  trailingNode: {
161
163
  node: "paragraph",
162
164
  notAfter: ["paragraph", "div"]
@@ -166,141 +168,148 @@ var I = {
166
168
  linkOnPaste: !1
167
169
  }
168
170
  }),
169
- ie,
171
+ ae,
170
172
  a,
171
- p,
172
- ee,
173
+ oe,
173
174
  o,
174
- N.configure({
175
- placeholder: S.placeholder,
175
+ ee,
176
+ j.configure({
177
+ placeholder: b.placeholder,
176
178
  showOnlyWhenEditable: !0,
177
179
  showOnlyCurrent: !1,
178
180
  includeChildren: !0
179
181
  }),
180
182
  n,
181
- P,
183
+ M,
182
184
  i,
183
185
  r,
184
- re.configure(X),
185
- c.configure(X),
186
- s.configure(X),
187
- te.configure(X),
188
- ne.configure(X),
189
- l.configure({
190
- toolbarOpts: J,
191
- math: S.pluginProps?.math || {}
186
+ ie.configure(J),
187
+ te.configure(J),
188
+ s.configure(J),
189
+ ne.configure(J),
190
+ re.configure(J),
191
+ c.configure({
192
+ toolbarOpts: K,
193
+ math: b.pluginProps?.math || {}
192
194
  }),
195
+ O,
196
+ D,
193
197
  A,
194
- k,
195
- M,
196
- u.configure({
197
- toolbarOpts: J,
198
+ l.configure({
199
+ toolbarOpts: K,
198
200
  imageHandling: {
199
- disableImageAlignmentButtons: S.disableImageAlignmentButtons,
200
- onDone: (e) => S.onDone?.(e.getHTML()),
201
- onDelete: S.imageSupport && S.imageSupport.delete && ((e) => {
201
+ disableImageAlignmentButtons: b.disableImageAlignmentButtons,
202
+ onDone: (e) => b.onDone?.(e.getHTML()),
203
+ onDelete: b.imageSupport && b.imageSupport.delete && ((e) => {
202
204
  let { src: t } = e.attrs;
203
- S.imageSupport.delete(t, (t) => {
204
- q(e.pos);
205
+ b.imageSupport.delete(t, (t) => {
206
+ G(e.pos);
205
207
  });
206
208
  }),
207
- insertImageRequested: S.imageSupport && ((e, t, n) => {
209
+ insertImageRequested: b.imageSupport && ((e, t, n) => {
208
210
  let [r, i] = t, a = (t) => {
209
211
  let n;
210
- W && t && (n = S.onChange), q(i), n?.(e.getHTML());
212
+ H && t && (n = b.onChange), G(i), n?.(e.getHTML());
211
213
  };
212
- e._insertingImage = !0, U((e) => [...e, r]), (() => {
213
- let t = n(a), r = x(() => {
214
+ e._insertingImage = !0, V((e) => [...e, r]), (() => {
215
+ let t = n(a), r = se(() => {
214
216
  let t = () => window.removeEventListener("focus", r);
215
217
  if (!e._insertingImage) {
216
218
  t();
217
219
  return;
218
220
  }
219
- q(i), e._insertingImage = !1, t();
221
+ G(i), e._insertingImage = !1, t();
220
222
  }, 500);
221
- window.addEventListener("focus", r), S.imageSupport.add(t);
223
+ window.addEventListener("focus", r), b.imageSupport.add(t);
222
224
  })();
223
225
  }),
224
- maxImageWidth: S.maxImageWidth,
225
- maxImageHeight: S.maxImageHeight
226
+ maxImageWidth: b.maxImageWidth,
227
+ maxImageHeight: b.maxImageHeight
226
228
  },
227
229
  limit: 3
228
230
  }),
229
- d.configure({ uploadSoundSupport: S.uploadSoundSupport }),
230
- f.configure({ extraCSSRules: S.extraCSSRules })
231
- ], Z = S.spellCheck !== !1, Q = C({
232
- extensions: ce,
231
+ u.configure({ uploadSoundSupport: b.uploadSoundSupport }),
232
+ d.configure({ extraCSSRules: b.extraCSSRules })
233
+ ], Y = b.spellCheck !== !1, { ariaLabel: X, ariaLabelledBy: Z } = b, Q = x({
234
+ extensions: de,
233
235
  immediatelyRender: !1,
234
236
  editorProps: {
235
- attributes: B(Z),
237
+ attributes: L(Y, X, Z),
236
238
  handleKeyDown(e, t) {
237
- return S.onKeyDown ? S.onKeyDown(t) : !1;
239
+ return b.onKeyDown ? b.onKeyDown(t) : !1;
238
240
  }
239
241
  },
240
- editable: !S.disabled,
241
- content: t(S.markup),
242
+ editable: !b.disabled,
243
+ content: t(b.markup),
242
244
  onUpdate: ({ editor: e, transaction: t }) => {
243
- t.isDone && S.onChange?.(e.getHTML());
245
+ t.isDone && b.onChange?.(e.getHTML());
244
246
  },
245
247
  onBlur: ({ editor: e }) => {
246
- e._insertingImage || e._toolbarOpened || e.isActive("inline_dropdown") || e.isActive("explicit_constructed_response") || !e.schema || Y(e);
248
+ e._insertingImage || e._toolbarOpened || e.isActive("inline_dropdown") || e.isActive("explicit_constructed_response") || !e.schema || q(e);
247
249
  }
248
- }, [S.charactersLimit]);
249
- v(() => {
250
- S.editorRef && S.editorRef(Q);
251
- }, [S.editorRef, Q]), v(() => {
252
- Q?.setEditable(!S.disabled);
253
- }, [S.disabled, Q]), v(() => {
250
+ }, [b.charactersLimit]);
251
+ _(() => {
252
+ b.editorRef && b.editorRef(Q);
253
+ }, [b.editorRef, Q]), _(() => {
254
+ Q?.setEditable(!b.disabled);
255
+ }, [b.disabled, Q]), _(() => {
254
256
  if (!Q) return;
255
- let e = Q.options?.editorProps, t = {
256
- ...e?.attributes,
257
- ...B(Z)
258
- };
259
- e?.attributes?.spellcheck !== t.spellcheck && Q.setOptions({ editorProps: {
257
+ let e = Q.options?.editorProps, t = e?.attributes || {}, n = L(Y, X, Z);
258
+ if (["spellcheck", ...R].every((e) => t[e] === n[e])) return;
259
+ let r = Object.fromEntries(Object.entries(t).filter(([e]) => !R.includes(e)));
260
+ Q.setOptions({ editorProps: {
260
261
  ...e,
261
- attributes: t
262
+ attributes: {
263
+ ...r,
264
+ ...n
265
+ }
262
266
  } });
263
- }, [Z, Q]), v(() => {
267
+ }, [
268
+ Y,
269
+ X,
270
+ Z,
271
+ Q
272
+ ]), _(() => {
264
273
  if (!Q) return;
265
- let e = t(S.markup);
274
+ let e = t(b.markup);
266
275
  e !== Q.getHTML() && Q.commands.setContent(e, { emitUpdate: !1 });
267
- }, [S.markup, Q]), v(() => {
268
- Object.entries(z).forEach(([e, t]) => {
276
+ }, [b.markup, Q]), _(() => {
277
+ Object.entries(I).forEach(([e, t]) => {
269
278
  document.documentElement.style.setProperty(e, t);
270
279
  });
271
280
  }, []);
272
- let le = w({
281
+ let fe = S({
273
282
  editor: Q,
274
283
  selector: (e) => ({ isFocused: e.editor?.isFocused })
275
- }), $ = y(() => {
276
- let { minWidth: e, width: t, maxWidth: n, minHeight: r, height: i, maxHeight: a } = S;
284
+ }), $ = v(() => {
285
+ let { minWidth: e, width: t, maxWidth: n, minHeight: r, height: i, maxHeight: a } = b;
277
286
  return {
278
- width: m(t),
279
- minWidth: m(e),
280
- maxWidth: m(n),
281
- height: m(i),
282
- minHeight: m(r),
283
- maxHeight: m(a)
287
+ width: f(t),
288
+ minWidth: f(e),
289
+ maxWidth: f(n),
290
+ height: f(i),
291
+ minHeight: f(r),
292
+ maxHeight: f(a)
284
293
  };
285
- }, [S]);
286
- return /* @__PURE__ */ F(ae, {
287
- ...S,
288
- activePlugins: se,
289
- toolbarOpts: J,
290
- editorState: le,
294
+ }, [b]);
295
+ return /* @__PURE__ */ N(p, {
296
+ ...b,
297
+ activePlugins: ue,
298
+ toolbarOpts: K,
299
+ editorState: fe,
291
300
  editor: Q,
292
- children: Q && /* @__PURE__ */ F(H, {
301
+ children: Q && /* @__PURE__ */ N(B, {
293
302
  style: {
294
303
  minHeight: $.minHeight,
295
304
  height: $.height,
296
305
  maxHeight: $.maxHeight
297
306
  },
298
- showParagraph: T && !T.disabled,
299
- separateParagraph: V && !V.disabled,
307
+ showParagraph: C && !C.disabled,
308
+ separateParagraph: z && !z.disabled,
300
309
  editor: Q
301
310
  })
302
311
  });
303
- }, H = T(S, { shouldForwardProp: (e) => !["showParagraph", "separateParagraph"].includes(e) })(({ showParagraph: e, separateParagraph: t }) => ({
312
+ }, B = C(b, { shouldForwardProp: (e) => !["showParagraph", "separateParagraph"].includes(e) })(({ showParagraph: e, separateParagraph: t }) => ({
304
313
  display: "flex",
305
314
  outline: "none !important",
306
315
  "& .ProseMirror": {
@@ -330,4 +339,4 @@ var I = {
330
339
  }
331
340
  }));
332
341
  //#endregion
333
- export { V as EditableHtml, V as default };
342
+ export { z as EditableHtml, z as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-lib/editable-html-tip-tap",
3
- "version": "3.0.1-next.20261004011201",
3
+ "version": "3.0.1-next.20261004020741",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,8 +14,8 @@
14
14
  "@mui/icons-material": "^7.3.4",
15
15
  "@mui/material": "^7.3.4",
16
16
  "@pie-lib/drag": "5.0.1-next.20261004003105",
17
- "@pie-lib/math-input": "9.0.1-next.20261004011201",
18
- "@pie-lib/math-toolbar": "4.0.1-next.20261004011201",
17
+ "@pie-lib/math-input": "9.0.1-next.20261004020741",
18
+ "@pie-lib/math-toolbar": "4.0.1-next.20261004020741",
19
19
  "@pie-lib/render-ui": "8.0.1-next.20261003161149",
20
20
  "@tiptap/core": "3.31.3",
21
21
  "@tiptap/extension-character-count": "3.31.3",