@pie-lib/editable-html-tip-tap 2.1.2-next.32 → 2.1.2-next.33

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