@pie-lib/editable-html-tip-tap 3.1.2-next.20261019223635 → 3.1.2-next.20261020155912
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/components/EditableHtml.js +80 -82
- package/dist/extensions/css.d.ts +0 -1
- package/dist/extensions/css.js +19 -16
- package/dist/extensions/extended-list-item.js +1 -1
- package/dist/extensions/extended-table-cell.js +1 -1
- package/dist/extensions/image-component.d.ts +0 -2
- package/dist/extensions/image-component.js +86 -69
- package/dist/extensions/image.js +17 -5
- package/package.json +6 -6
|
@@ -6,11 +6,11 @@ import { ExtendedTableCell as i, ExtendedTableHeader as a } from "../extensions/
|
|
|
6
6
|
import { DivNode as o } from "../extensions/div-node.js";
|
|
7
7
|
import { EnsureEmptyRootIsDiv as ee } from "../extensions/ensure-empty-root-div.js";
|
|
8
8
|
import { EnsureListItemContentIsDiv as s } from "../extensions/ensure-list-item-content-is-div.js";
|
|
9
|
-
import { DragInTheBlankNode as c, ExplicitConstructedResponseNode as
|
|
10
|
-
import { MathNode as
|
|
11
|
-
import { ImageUploadNode as
|
|
12
|
-
import { Media as
|
|
13
|
-
import { CSSMark as
|
|
9
|
+
import { DragInTheBlankNode as c, ExplicitConstructedResponseNode as l, InlineDropdownNode as u, MathTemplatedNode as te, ResponseAreaExtension as ne } from "../extensions/responseArea.js";
|
|
10
|
+
import { MathNode as re } from "../extensions/math.js";
|
|
11
|
+
import { ImageUploadNode as ie, uploadPastedImage as ae } from "../extensions/image.js";
|
|
12
|
+
import { Media as oe } from "../extensions/media.js";
|
|
13
|
+
import { CSSMark as se } from "../extensions/css.js";
|
|
14
14
|
import { ExtendedListItem as ce } from "../extensions/extended-list-item.js";
|
|
15
15
|
import { HeadingParagraph as le } from "../extensions/heading-paragraph.js";
|
|
16
16
|
import { valueToSize as d } from "../utils/size.js";
|
|
@@ -26,22 +26,21 @@ import { CharacterCount as ge } from "@tiptap/extension-character-count";
|
|
|
26
26
|
import _e from "@tiptap/extension-superscript";
|
|
27
27
|
import ve from "@tiptap/extension-subscript";
|
|
28
28
|
import ye from "@tiptap/extension-text-align";
|
|
29
|
-
import be from "@tiptap/extension-
|
|
30
|
-
import xe from "@tiptap/extension-
|
|
31
|
-
import {
|
|
32
|
-
import { jsx as S } from "react/jsx-runtime";
|
|
29
|
+
import be from "@tiptap/extension-placeholder";
|
|
30
|
+
import { TableRow as xe } from "@tiptap/extension-table-row";
|
|
31
|
+
import { jsx as x } from "react/jsx-runtime";
|
|
33
32
|
//#region src/components/EditableHtml.tsx
|
|
34
|
-
var
|
|
33
|
+
var S = {
|
|
35
34
|
position: "bottom",
|
|
36
35
|
alignment: "left",
|
|
37
36
|
alwaysVisible: !1,
|
|
38
37
|
showDone: !0,
|
|
39
38
|
doneOn: "blur"
|
|
40
|
-
},
|
|
39
|
+
}, C = {
|
|
41
40
|
options: {},
|
|
42
41
|
respAreaToolbar: () => {},
|
|
43
42
|
onHandleAreaChange: () => {}
|
|
44
|
-
},
|
|
43
|
+
}, w = [
|
|
45
44
|
"bold",
|
|
46
45
|
"italic",
|
|
47
46
|
"underline",
|
|
@@ -63,7 +62,7 @@ var C = {
|
|
|
63
62
|
"h3",
|
|
64
63
|
"undo",
|
|
65
64
|
"redo"
|
|
66
|
-
],
|
|
65
|
+
], T = {
|
|
67
66
|
bold: "bold",
|
|
68
67
|
italic: "italic",
|
|
69
68
|
underline: "underline",
|
|
@@ -74,7 +73,7 @@ var C = {
|
|
|
74
73
|
"numbered-list": "orderedList",
|
|
75
74
|
table: "table",
|
|
76
75
|
image: "image"
|
|
77
|
-
},
|
|
76
|
+
}, E = {
|
|
78
77
|
"--white": "#fff",
|
|
79
78
|
"--black": "#2e2b29",
|
|
80
79
|
"--black-contrast": "#110f0e",
|
|
@@ -93,7 +92,7 @@ var C = {
|
|
|
93
92
|
"--red": "#ff5c33",
|
|
94
93
|
"--red-light": "#ffebe5",
|
|
95
94
|
"--shadow": "0px 12px 33px 0px rgba(0, 0, 0, .06),\n 0px 3.618px 9.949px 0px rgba(0, 0, 0, .04)"
|
|
96
|
-
},
|
|
95
|
+
}, D = (e, t, n) => ({
|
|
97
96
|
role: "textbox",
|
|
98
97
|
"data-pie-editor": "true",
|
|
99
98
|
class: "mathjax_ignore",
|
|
@@ -102,50 +101,50 @@ var C = {
|
|
|
102
101
|
autocapitalize: e ? "on" : "off",
|
|
103
102
|
...t && { "aria-label": t },
|
|
104
103
|
...n && { "aria-labelledby": n }
|
|
105
|
-
}),
|
|
106
|
-
let { showParagraphs: b, separateParagraphs:
|
|
107
|
-
|
|
104
|
+
}), O = ["aria-label", "aria-labelledby"], k = (e) => e._insertingImage || e._toolbarOpened || e.isActive("inline_dropdown") || e.isActive("explicit_constructed_response"), A = (y) => {
|
|
105
|
+
let { showParagraphs: b, separateParagraphs: A } = y.pluginProps || {}, [Se, M] = _([]), [Ce, we] = _(!1), { toolbarOpts: Te } = y, N = p((e) => {
|
|
106
|
+
M((t) => {
|
|
108
107
|
let n = t.filter((t) => t.pos !== e);
|
|
109
108
|
return n.length === 0 && we(!1), n;
|
|
110
109
|
});
|
|
111
|
-
}, [
|
|
112
|
-
...
|
|
110
|
+
}, [M]), P = {
|
|
111
|
+
...S,
|
|
113
112
|
...Te
|
|
114
|
-
},
|
|
115
|
-
|
|
116
|
-
},
|
|
117
|
-
|
|
118
|
-
let
|
|
113
|
+
}, F = g([]), I = (e) => {
|
|
114
|
+
F.current = [...F.current.slice(-4), e], y.onChange?.(e);
|
|
115
|
+
}, L = g(I);
|
|
116
|
+
L.current = I;
|
|
117
|
+
let R = p((e) => {
|
|
119
118
|
let t = e.getHTML();
|
|
120
|
-
y.markup !== t &&
|
|
119
|
+
y.markup !== t && L.current(t), P.doneOn === "blur" && y.onDone?.(t);
|
|
121
120
|
}, [
|
|
122
121
|
y.markup,
|
|
123
122
|
y.onChange,
|
|
124
123
|
y.onDone,
|
|
125
|
-
|
|
126
|
-
]),
|
|
127
|
-
|
|
128
|
-
let { idleSaveDelay:
|
|
129
|
-
e.isDestroyed || (!
|
|
130
|
-
},
|
|
131
|
-
|
|
132
|
-
let
|
|
133
|
-
|
|
124
|
+
P.doneOn
|
|
125
|
+
]), z = g(R);
|
|
126
|
+
z.current = R;
|
|
127
|
+
let { idleSaveDelay: B } = y, V = g(!1), H = h(() => B > 0 ? v((e) => {
|
|
128
|
+
e.isDestroyed || (!V.current && (e.view.composing || k(e)) ? U.current?.(e) : z.current(e));
|
|
129
|
+
}, B) : null, [B]), U = g(H);
|
|
130
|
+
U.current = H;
|
|
131
|
+
let W = p((e) => {
|
|
132
|
+
V.current = !0;
|
|
134
133
|
try {
|
|
135
134
|
e?.flush();
|
|
136
135
|
} finally {
|
|
137
|
-
|
|
136
|
+
V.current = !1;
|
|
138
137
|
}
|
|
139
138
|
}, []);
|
|
140
|
-
m(() => () =>
|
|
141
|
-
let
|
|
142
|
-
...
|
|
139
|
+
m(() => () => W(H), [H, W]);
|
|
140
|
+
let G = p(() => W(U.current), [W]), K = h(() => ({
|
|
141
|
+
...C,
|
|
143
142
|
...y.responseAreaProps,
|
|
144
|
-
onInlineDropdownToolbarClose:
|
|
145
|
-
}), [y.responseAreaProps,
|
|
143
|
+
onInlineDropdownToolbarClose: R
|
|
144
|
+
}), [y.responseAreaProps, R]), q = h(() => {
|
|
146
145
|
let { customPlugins: e, ...t } = y.pluginProps || {};
|
|
147
146
|
e ||= [];
|
|
148
|
-
let n = (y.activePlugins ||
|
|
147
|
+
let n = (y.activePlugins || w)?.filter((e) => {
|
|
149
148
|
let n = de[e] || e, r = t[n] || {};
|
|
150
149
|
return !r || !r.disabled;
|
|
151
150
|
});
|
|
@@ -166,9 +165,9 @@ var C = {
|
|
|
166
165
|
}, [y, K.type]), J = g(null);
|
|
167
166
|
J.current = {
|
|
168
167
|
plainText: y.pluginProps?.pasteFormatting?.disabled === !0,
|
|
169
|
-
formatting: q.map((e) =>
|
|
168
|
+
formatting: q.map((e) => T[e]).filter(Boolean)
|
|
170
169
|
};
|
|
171
|
-
let
|
|
170
|
+
let Ee = [
|
|
172
171
|
ye.configure({
|
|
173
172
|
types: [
|
|
174
173
|
"heading",
|
|
@@ -194,7 +193,7 @@ var C = {
|
|
|
194
193
|
he,
|
|
195
194
|
e.configure({
|
|
196
195
|
settings: () => J.current,
|
|
197
|
-
uploadImage: y.imageSupport &&
|
|
196
|
+
uploadImage: y.imageSupport && ae
|
|
198
197
|
}),
|
|
199
198
|
ge.configure({ limit: y.charactersLimit || 1e6 }),
|
|
200
199
|
me.configure({
|
|
@@ -212,47 +211,46 @@ var C = {
|
|
|
212
211
|
le,
|
|
213
212
|
ee,
|
|
214
213
|
s,
|
|
215
|
-
|
|
214
|
+
be.configure({
|
|
216
215
|
placeholder: y.placeholder,
|
|
217
216
|
showOnlyWhenEditable: !0,
|
|
218
217
|
showOnlyCurrent: !1,
|
|
219
218
|
includeChildren: !0
|
|
220
219
|
}),
|
|
221
220
|
r,
|
|
222
|
-
|
|
221
|
+
xe,
|
|
223
222
|
a,
|
|
224
223
|
i,
|
|
225
|
-
re.configure(K),
|
|
226
|
-
te.configure(K),
|
|
227
|
-
c.configure(K),
|
|
228
|
-
l.configure(K),
|
|
229
224
|
ne.configure(K),
|
|
230
|
-
|
|
231
|
-
|
|
225
|
+
l.configure(K),
|
|
226
|
+
c.configure(K),
|
|
227
|
+
u.configure(K),
|
|
228
|
+
te.configure(K),
|
|
229
|
+
re.configure({
|
|
230
|
+
toolbarOpts: P,
|
|
232
231
|
math: y.pluginProps?.math || {}
|
|
233
232
|
}),
|
|
234
233
|
ve,
|
|
235
234
|
_e,
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
toolbarOpts: F,
|
|
235
|
+
ie.configure({
|
|
236
|
+
toolbarOpts: P,
|
|
239
237
|
imageHandling: {
|
|
240
238
|
disableImageAlignmentButtons: y.disableImageAlignmentButtons,
|
|
241
239
|
onDone: (e) => y.onDone?.(e.getHTML()),
|
|
242
240
|
onDelete: y.imageSupport && y.imageSupport.delete && ((e) => {
|
|
243
241
|
let { src: t } = e.attrs;
|
|
244
242
|
y.imageSupport.delete(t, (t) => {
|
|
245
|
-
|
|
243
|
+
N(e.pos);
|
|
246
244
|
});
|
|
247
245
|
}),
|
|
248
246
|
insertImageRequested: y.imageSupport && ((e, t, n) => {
|
|
249
247
|
let [r, i] = t, a = (t) => {
|
|
250
248
|
let n;
|
|
251
|
-
Ce && t && (n =
|
|
249
|
+
Ce && t && (n = L.current), N(i), n?.(e.getHTML());
|
|
252
250
|
};
|
|
253
|
-
e._insertingImage = !0,
|
|
251
|
+
e._insertingImage = !0, M((e) => [...e, r]), (() => {
|
|
254
252
|
let t = n(a), r = v(() => {
|
|
255
|
-
e._insertingImage &&= (
|
|
253
|
+
e._insertingImage &&= (N(i), !1), window.removeEventListener("focus", r);
|
|
256
254
|
}, 500);
|
|
257
255
|
window.addEventListener("focus", r), y.imageSupport.add(t);
|
|
258
256
|
})();
|
|
@@ -262,13 +260,13 @@ var C = {
|
|
|
262
260
|
},
|
|
263
261
|
limit: 3
|
|
264
262
|
}),
|
|
265
|
-
|
|
266
|
-
|
|
263
|
+
oe.configure({ uploadSoundSupport: y.uploadSoundSupport }),
|
|
264
|
+
se.configure({ extraCSSRules: y.extraCSSRules })
|
|
267
265
|
], Y = y.spellCheck !== !1, { ariaLabel: X, ariaLabelledBy: Z } = y, Q = fe({
|
|
268
|
-
extensions:
|
|
266
|
+
extensions: Ee,
|
|
269
267
|
immediatelyRender: !1,
|
|
270
268
|
editorProps: {
|
|
271
|
-
attributes:
|
|
269
|
+
attributes: D(Y, X, Z),
|
|
272
270
|
handleKeyDown(e, t) {
|
|
273
271
|
return y.onKeyDown ? y.onKeyDown(t) : !1;
|
|
274
272
|
}
|
|
@@ -276,10 +274,10 @@ var C = {
|
|
|
276
274
|
editable: !y.disabled,
|
|
277
275
|
content: t(y.markup),
|
|
278
276
|
onUpdate: ({ editor: e, transaction: t }) => {
|
|
279
|
-
t.isDone &&
|
|
277
|
+
t.isDone && L.current(e.getHTML()), t.docChanged && U.current && (U.current(e), n(e.view.dom, G));
|
|
280
278
|
},
|
|
281
279
|
onBlur: ({ editor: e }) => {
|
|
282
|
-
!
|
|
280
|
+
!k(e) && e.schema && (U.current?.cancel(), R(e));
|
|
283
281
|
}
|
|
284
282
|
}, [y.charactersLimit]);
|
|
285
283
|
m(() => {
|
|
@@ -287,12 +285,12 @@ var C = {
|
|
|
287
285
|
}, [y.editorRef, Q]), m(() => {
|
|
288
286
|
Q?.setEditable(!y.disabled);
|
|
289
287
|
}, [y.disabled, Q]), m(() => {
|
|
290
|
-
Q?.on("destroy", () =>
|
|
291
|
-
}, [Q,
|
|
288
|
+
Q?.on("destroy", () => W(U.current));
|
|
289
|
+
}, [Q, W]), m(() => {
|
|
292
290
|
if (!Q) return;
|
|
293
|
-
let e = Q.options?.editorProps, t = e?.attributes || {}, n =
|
|
294
|
-
if (["spellcheck", ...
|
|
295
|
-
let r = Object.fromEntries(Object.entries(t).filter(([e]) => !
|
|
291
|
+
let e = Q.options?.editorProps, t = e?.attributes || {}, n = D(Y, X, Z);
|
|
292
|
+
if (["spellcheck", ...O].every((e) => t[e] === n[e])) return;
|
|
293
|
+
let r = Object.fromEntries(Object.entries(t).filter(([e]) => !O.includes(e)));
|
|
296
294
|
Q.setOptions({ editorProps: {
|
|
297
295
|
...e,
|
|
298
296
|
attributes: {
|
|
@@ -306,16 +304,16 @@ var C = {
|
|
|
306
304
|
Z,
|
|
307
305
|
Q
|
|
308
306
|
]), m(() => {
|
|
309
|
-
if (!Q ||
|
|
310
|
-
|
|
307
|
+
if (!Q || F.current.includes(y.markup)) return;
|
|
308
|
+
F.current = [];
|
|
311
309
|
let e = t(y.markup);
|
|
312
310
|
e !== Q.getHTML() && Q.commands.setContent(e, { emitUpdate: !1 });
|
|
313
311
|
}, [y.markup, Q]), m(() => {
|
|
314
|
-
Object.entries(
|
|
312
|
+
Object.entries(E).forEach(([e, t]) => {
|
|
315
313
|
document.documentElement.style.setProperty(e, t);
|
|
316
314
|
});
|
|
317
315
|
}, []);
|
|
318
|
-
let
|
|
316
|
+
let De = pe({
|
|
319
317
|
editor: Q,
|
|
320
318
|
selector: (e) => ({ isFocused: e.editor?.isFocused })
|
|
321
319
|
}), $ = h(() => {
|
|
@@ -329,24 +327,24 @@ var C = {
|
|
|
329
327
|
maxHeight: d(a)
|
|
330
328
|
};
|
|
331
329
|
}, [y]);
|
|
332
|
-
return /* @__PURE__ */
|
|
330
|
+
return /* @__PURE__ */ x(ue, {
|
|
333
331
|
...y,
|
|
334
332
|
activePlugins: q,
|
|
335
|
-
toolbarOpts:
|
|
336
|
-
editorState:
|
|
333
|
+
toolbarOpts: P,
|
|
334
|
+
editorState: De,
|
|
337
335
|
editor: Q,
|
|
338
|
-
children: Q && /* @__PURE__ */
|
|
336
|
+
children: Q && /* @__PURE__ */ x(j, {
|
|
339
337
|
style: {
|
|
340
338
|
minHeight: $.minHeight,
|
|
341
339
|
height: $.height,
|
|
342
340
|
maxHeight: $.maxHeight
|
|
343
341
|
},
|
|
344
342
|
showParagraph: b && !b.disabled,
|
|
345
|
-
separateParagraph:
|
|
343
|
+
separateParagraph: A && !A.disabled,
|
|
346
344
|
editor: Q
|
|
347
345
|
})
|
|
348
346
|
});
|
|
349
|
-
},
|
|
347
|
+
}, j = b(y, { shouldForwardProp: (e) => !["showParagraph", "separateParagraph"].includes(e) })(({ showParagraph: e, separateParagraph: t }) => ({
|
|
350
348
|
display: "flex",
|
|
351
349
|
outline: "none !important",
|
|
352
350
|
"& .ProseMirror": {
|
|
@@ -376,4 +374,4 @@ var C = {
|
|
|
376
374
|
}
|
|
377
375
|
}));
|
|
378
376
|
//#endregion
|
|
379
|
-
export {
|
|
377
|
+
export { A as EditableHtml, A as default };
|
package/dist/extensions/css.d.ts
CHANGED
package/dist/extensions/css.js
CHANGED
|
@@ -6,28 +6,31 @@ import { createRoot as a } from "react-dom/client";
|
|
|
6
6
|
import o from "@mui/material/List";
|
|
7
7
|
import s from "@mui/material/ListItem";
|
|
8
8
|
//#region src/extensions/css.tsx
|
|
9
|
-
var c = () => {
|
|
10
|
-
|
|
11
|
-
}, l = ({ editor: e, callback: t, opts: l, selectedText: u, parentNode: d }) => {
|
|
9
|
+
var c = null, l = ({ editor: e, callback: t, opts: l, selectedText: u, parentNode: d }) => {
|
|
10
|
+
c?.();
|
|
12
11
|
let f = e.options.element, p = document.createElement("div"), { selection: m } = e.state;
|
|
13
|
-
|
|
12
|
+
p.className = "insert-css-dialog";
|
|
14
13
|
let h = a(p), g, _ = !1, v = (e) => {
|
|
15
14
|
if (_) {
|
|
16
15
|
let t = p.contains(e.target) || g, n = f.contains(e.target);
|
|
17
|
-
t || n ||
|
|
16
|
+
t || n || b();
|
|
18
17
|
} else _ = !0;
|
|
19
18
|
}, y = () => {
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
h.unmount(), p.remove(), document.body.removeEventListener("click", v), c === y && (c = null);
|
|
20
|
+
};
|
|
21
|
+
c = y;
|
|
22
|
+
let b = () => {
|
|
23
|
+
t(void 0, !0), y();
|
|
24
|
+
}, x = (e) => {
|
|
25
|
+
t(e, !0), y();
|
|
26
|
+
}, S = d?.attrs.class, C = (e) => {
|
|
24
27
|
let t = `<span class="${e}">${u}</span>`;
|
|
25
28
|
if (d) {
|
|
26
29
|
let e = "span";
|
|
27
|
-
d?.object === "inline" && (e = "span"), d?.object === "block" && (e = "div"), t = `<${e} class="${
|
|
30
|
+
d?.object === "inline" && (e = "span"), d?.object === "block" && (e = "div"), t = `<${e} class="${S}">${d.text.slice(0, m.$anchor.textOffset)}${t}${d.text.slice(m.$head.textOffset)}</${e}>`;
|
|
28
31
|
}
|
|
29
32
|
return t;
|
|
30
|
-
},
|
|
33
|
+
}, w = /* @__PURE__ */ i("div", {
|
|
31
34
|
style: {
|
|
32
35
|
background: "white",
|
|
33
36
|
height: 500,
|
|
@@ -38,22 +41,22 @@ var c = () => {
|
|
|
38
41
|
},
|
|
39
42
|
children: [
|
|
40
43
|
/* @__PURE__ */ r("h2", { children: "Please choose a css class" }),
|
|
41
|
-
|
|
44
|
+
S && /* @__PURE__ */ i("div", { children: ["The current parent has this class ", S] }),
|
|
42
45
|
/* @__PURE__ */ r(o, {
|
|
43
46
|
component: "nav",
|
|
44
47
|
style: { overflow: "scroll" },
|
|
45
48
|
children: l.names.map((e, t) => /* @__PURE__ */ i(s, {
|
|
46
49
|
button: !0,
|
|
47
|
-
onClick: () =>
|
|
50
|
+
onClick: () => x(e),
|
|
48
51
|
children: [/* @__PURE__ */ r("div", {
|
|
49
52
|
style: { marginRight: 20 },
|
|
50
53
|
children: e
|
|
51
|
-
}), /* @__PURE__ */ r("div", { dangerouslySetInnerHTML: { __html:
|
|
54
|
+
}), /* @__PURE__ */ r("div", { dangerouslySetInnerHTML: { __html: C(e) } })]
|
|
52
55
|
}, `rule-${t}`))
|
|
53
56
|
})
|
|
54
57
|
]
|
|
55
58
|
});
|
|
56
|
-
n(() => h.render(
|
|
59
|
+
n(() => h.render(w)), (() => {
|
|
57
60
|
let t = e.view.nodeDOM(e.state.selection.from)?.parentNode;
|
|
58
61
|
if (t) {
|
|
59
62
|
let e = f.parentElement.parentElement.parentElement.getBoundingClientRect(), n = t.getBoundingClientRect();
|
|
@@ -118,4 +121,4 @@ var c = () => {
|
|
|
118
121
|
}
|
|
119
122
|
});
|
|
120
123
|
//#endregion
|
|
121
|
-
export { u as CSSMark
|
|
124
|
+
export { u as CSSMark };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ListItem as e } from "@tiptap/extension-list-item";
|
|
2
2
|
//#region src/extensions/extended-list-item.tsx
|
|
3
|
-
var t = e.extend({ content: "(div | paragraph | heading | bulletList | orderedList | blockquote | codeBlock | horizontalRule |
|
|
3
|
+
var t = e.extend({ content: "(div | paragraph | heading | bulletList | orderedList | blockquote | codeBlock | horizontalRule | imageUploadNode)+" });
|
|
4
4
|
//#endregion
|
|
5
5
|
export { t as ExtendedListItem };
|
|
@@ -2,7 +2,7 @@ import { scopeAttribute as e } from "./table-semantics.js";
|
|
|
2
2
|
import { TableCell as t } from "@tiptap/extension-table-cell";
|
|
3
3
|
import { TableHeader as n } from "@tiptap/extension-table-header";
|
|
4
4
|
//#region src/extensions/extended-table-cell.ts
|
|
5
|
-
var r = "(div | paragraph | heading | bulletList | orderedList | blockquote | codeBlock | horizontalRule |
|
|
5
|
+
var r = "(div | paragraph | heading | bulletList | orderedList | blockquote | codeBlock | horizontalRule | imageUploadNode)+", i = t.extend({ content: r }), a = n.extend({
|
|
6
6
|
content: r,
|
|
7
7
|
addAttributes() {
|
|
8
8
|
return {
|
|
@@ -7,8 +7,6 @@ declare namespace ImageComponent {
|
|
|
7
7
|
editor: PropTypes.Validator<object>;
|
|
8
8
|
attributes: PropTypes.Requireable<object>;
|
|
9
9
|
onFocus: PropTypes.Requireable<(...args: any[]) => any>;
|
|
10
|
-
maxImageWidth: PropTypes.Requireable<number>;
|
|
11
|
-
maxImageHeight: PropTypes.Requireable<number>;
|
|
12
10
|
};
|
|
13
11
|
}
|
|
14
12
|
export default ImageComponent;
|
|
@@ -46,60 +46,74 @@ var y = f(v, { shouldForwardProp: (e) => e !== "hideProgress" })(({ hideProgress
|
|
|
46
46
|
marginLeft: "5px",
|
|
47
47
|
marginRight: "10px",
|
|
48
48
|
display: "none"
|
|
49
|
-
})), w = (e) => e ? `${e}px` : "calc(20px)"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
})), w = (e) => e ? `${e}px` : "calc(20px)", T = 700, E = 900, D = ({ width: e, height: t }, n, r) => {
|
|
50
|
+
let i = Math.min(1, n / e, r / t);
|
|
51
|
+
return i < 1 ? {
|
|
52
|
+
width: Math.round(e * i),
|
|
53
|
+
height: Math.round(t * i)
|
|
54
|
+
} : {
|
|
55
|
+
width: e,
|
|
56
|
+
height: t
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
function O(f) {
|
|
60
|
+
let { node: m, editor: _, attributes: v, onFocus: O, getPos: k, selected: A, options: j } = f;
|
|
61
|
+
console.log({ ...f.options });
|
|
62
|
+
let M = j?.imageHandling?.maxImageWidth || T, N = j?.imageHandling?.maxImageHeight || E, { alt: ee } = m.attrs, P = k(), F = _.state.selection.from, I = _.state.selection.to, L = s(() => F + m.nodeSize === I, [
|
|
63
|
+
F,
|
|
64
|
+
I,
|
|
54
65
|
m.nodeSize
|
|
55
|
-
]), [
|
|
56
|
-
let t = e /
|
|
66
|
+
]), [R, z] = l(!1), B = c(m), V = c(null), H = c(null), U = c(null), W = a((e) => {
|
|
67
|
+
let t = e / V.current.naturalWidth * 4;
|
|
57
68
|
return parseInt(t.toFixed(0) * 25, 10);
|
|
58
|
-
}, []),
|
|
59
|
-
let e = n(_,
|
|
69
|
+
}, []), G = a(() => {
|
|
70
|
+
let e = n(_, B.current.attrs.nodeKey);
|
|
60
71
|
return e ? e[1] : null;
|
|
61
|
-
}, [_]),
|
|
62
|
-
let t =
|
|
72
|
+
}, [_]), K = a((e) => {
|
|
73
|
+
let t = G();
|
|
63
74
|
if (t === null) return;
|
|
64
75
|
let n = _.state.doc.nodeAt(t);
|
|
65
76
|
n && _.view.dispatch(_.state.tr.setNodeMarkup(t, void 0, {
|
|
66
77
|
...n.attrs,
|
|
67
78
|
...e
|
|
68
79
|
}));
|
|
69
|
-
}, [_,
|
|
70
|
-
if (!m.attrs.width || !
|
|
71
|
-
let e =
|
|
72
|
-
m.attrs.resizePercent !== e &&
|
|
80
|
+
}, [_, G]), q = a(() => {
|
|
81
|
+
if (!m.attrs.width || !V.current || !V.current.naturalWidth) return;
|
|
82
|
+
let e = W(m.attrs.width);
|
|
83
|
+
m.attrs.resizePercent !== e && K({ resizePercent: e });
|
|
73
84
|
}, [
|
|
74
85
|
m.attrs.width,
|
|
75
86
|
m.attrs.resizePercent,
|
|
76
|
-
|
|
77
|
-
|
|
87
|
+
W,
|
|
88
|
+
K
|
|
78
89
|
]);
|
|
79
90
|
o(() => {
|
|
80
|
-
|
|
91
|
+
B.current = {
|
|
81
92
|
...m,
|
|
82
|
-
pos:
|
|
93
|
+
pos: P
|
|
83
94
|
};
|
|
84
|
-
}, [m,
|
|
85
|
-
|
|
95
|
+
}, [m, P]), o(() => {
|
|
96
|
+
A ? L && _.isEditable && (!String(m.attrs?.src ?? "").trim() && j.imageHandling?.insertImageRequested && j.imageHandling.insertImageRequested(_, [m, P], (e) => new r(_, [m, P], e)), z(A)) : z(A);
|
|
86
97
|
}, [
|
|
87
|
-
|
|
88
|
-
|
|
98
|
+
L,
|
|
99
|
+
A,
|
|
89
100
|
_.isEditable
|
|
90
101
|
]), o(() => {
|
|
91
|
-
|
|
92
|
-
let e =
|
|
93
|
-
return e && _.isEditable && e.addEventListener("mousedown",
|
|
94
|
-
e && e.removeEventListener("mousedown",
|
|
102
|
+
q();
|
|
103
|
+
let e = H?.current;
|
|
104
|
+
return e && _.isEditable && e.addEventListener("mousedown", $, !1), () => {
|
|
105
|
+
e && e.removeEventListener("mousedown", $, !1);
|
|
95
106
|
};
|
|
96
107
|
}, []), o(() => {
|
|
97
|
-
|
|
108
|
+
q();
|
|
98
109
|
});
|
|
99
|
-
let
|
|
100
|
-
let e =
|
|
110
|
+
let J = a(() => {
|
|
111
|
+
let e = V.current;
|
|
101
112
|
if (e && (!e.style.width || e.style.width === "calc(20px)")) {
|
|
102
|
-
let
|
|
113
|
+
let { width: t, height: n } = D({
|
|
114
|
+
width: e.naturalWidth,
|
|
115
|
+
height: e.naturalHeight
|
|
116
|
+
}, M, N);
|
|
103
117
|
e.style.width = `${t}px`, e.style.height = `${n}px`;
|
|
104
118
|
let r = {
|
|
105
119
|
width: t,
|
|
@@ -108,15 +122,15 @@ function T(f) {
|
|
|
108
122
|
u(r, {
|
|
109
123
|
width: m.attrs.width,
|
|
110
124
|
height: m.attrs.height
|
|
111
|
-
}) ||
|
|
125
|
+
}) || K(r);
|
|
112
126
|
}
|
|
113
127
|
}, [
|
|
114
128
|
m.attrs.width,
|
|
115
129
|
m.attrs.height,
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
]),
|
|
130
|
+
M,
|
|
131
|
+
N,
|
|
132
|
+
K
|
|
133
|
+
]), Y = (e, t, n = !0, r) => {
|
|
120
134
|
if (n) {
|
|
121
135
|
let n = e.width / e.height;
|
|
122
136
|
return r === "height" ? {
|
|
@@ -128,40 +142,45 @@ function T(f) {
|
|
|
128
142
|
};
|
|
129
143
|
}
|
|
130
144
|
return t;
|
|
131
|
-
},
|
|
132
|
-
let t =
|
|
145
|
+
}, X = a((e) => {
|
|
146
|
+
let t = V.current;
|
|
133
147
|
if (!t) return;
|
|
134
148
|
let n = e.target.getBoundingClientRect(), r = {
|
|
135
149
|
width: t.naturalWidth,
|
|
136
150
|
height: t.naturalHeight
|
|
137
|
-
}, i =
|
|
151
|
+
}, i = D(Y(r, {
|
|
138
152
|
width: e.clientX - n.left,
|
|
139
153
|
height: e.clientY - n.top
|
|
140
|
-
});
|
|
141
|
-
i.width > 50 && i.height > 50 &&
|
|
154
|
+
}), M, N);
|
|
155
|
+
i.width > 50 && i.height > 50 && (t.style.width = `${i.width}px`, t.style.height = `${i.height}px`, K({
|
|
142
156
|
width: i.width,
|
|
143
157
|
height: i.height
|
|
144
158
|
}));
|
|
145
|
-
}, [
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
159
|
+
}, [
|
|
160
|
+
_,
|
|
161
|
+
K,
|
|
162
|
+
M,
|
|
163
|
+
N
|
|
164
|
+
]), Z = a((e) => {
|
|
165
|
+
K(e);
|
|
166
|
+
}, [_, K]), Q = a(() => {
|
|
167
|
+
window.removeEventListener("mousemove", X), window.removeEventListener("mouseup", Q);
|
|
168
|
+
}, [X]), $ = a(() => {
|
|
169
|
+
window.addEventListener("mousemove", X), window.addEventListener("mouseup", Q);
|
|
170
|
+
}, [X, Q]), te = {
|
|
152
171
|
width: w(m.attrs.width),
|
|
153
172
|
height: w(m.attrs.height),
|
|
154
173
|
objectFit: "contain"
|
|
155
|
-
},
|
|
174
|
+
}, ne = {
|
|
156
175
|
left: "flex-start",
|
|
157
176
|
center: "center",
|
|
158
177
|
right: "flex-end"
|
|
159
178
|
}[m.attrs.alignment] || "flex-start";
|
|
160
179
|
return /* @__PURE__ */ g(d, { children: [/* @__PURE__ */ g(b, {
|
|
161
|
-
onFocus:
|
|
180
|
+
onFocus: O,
|
|
162
181
|
loading: !m.attrs.loaded,
|
|
163
182
|
pendingDelete: m.attrs.deleteStatus === "pending",
|
|
164
|
-
style: { justifyContent:
|
|
183
|
+
style: { justifyContent: ne },
|
|
165
184
|
children: [/* @__PURE__ */ h(y, {
|
|
166
185
|
mode: "determinate",
|
|
167
186
|
value: m.attrs.percent || 0,
|
|
@@ -170,21 +189,21 @@ function T(f) {
|
|
|
170
189
|
onDragStart: (e) => e.preventDefault(),
|
|
171
190
|
children: [/* @__PURE__ */ h(S, {
|
|
172
191
|
...v,
|
|
173
|
-
active:
|
|
192
|
+
active: A && m.attrs.loaded,
|
|
174
193
|
draggable: !1,
|
|
175
|
-
ref:
|
|
194
|
+
ref: V,
|
|
176
195
|
src: m.attrs.src,
|
|
177
|
-
style:
|
|
178
|
-
onLoad:
|
|
196
|
+
style: te,
|
|
197
|
+
onLoad: J,
|
|
179
198
|
alt: m.attrs.alt
|
|
180
199
|
}), /* @__PURE__ */ h(C, {
|
|
181
|
-
ref:
|
|
200
|
+
ref: H,
|
|
182
201
|
className: "resize",
|
|
183
202
|
style: { display: _.isEditable ? void 0 : "none" }
|
|
184
203
|
})]
|
|
185
204
|
})]
|
|
186
|
-
}),
|
|
187
|
-
ref:
|
|
205
|
+
}), R && _._tiptapContainerEl && p.createPortal(/* @__PURE__ */ h("div", {
|
|
206
|
+
ref: U,
|
|
188
207
|
style: {
|
|
189
208
|
zIndex: 20,
|
|
190
209
|
background: e,
|
|
@@ -194,31 +213,29 @@ function T(f) {
|
|
|
194
213
|
children: /* @__PURE__ */ h(t, {
|
|
195
214
|
showDone: !0,
|
|
196
215
|
deletable: !0,
|
|
197
|
-
toolbarOpts:
|
|
216
|
+
toolbarOpts: j.toolbarOpts || {},
|
|
198
217
|
onDelete: () => {
|
|
199
|
-
let e =
|
|
200
|
-
e !== null && (
|
|
218
|
+
let e = G();
|
|
219
|
+
e !== null && (j.imageHandling?.onDelete?.(B.current), _.view.dispatch(_.state.tr.delete(e, e + _.state.doc.nodeAt(e).nodeSize)), z(!1), _.commands.focus());
|
|
201
220
|
},
|
|
202
221
|
onDone: () => {
|
|
203
|
-
|
|
222
|
+
z(!1), j.imageHandling?.onDone?.(_), _.commands.focus("end");
|
|
204
223
|
},
|
|
205
224
|
children: /* @__PURE__ */ h(i, {
|
|
206
|
-
disableImageAlignmentButtons:
|
|
225
|
+
disableImageAlignmentButtons: j.imageHandling?.disableImageAlignmentButtons,
|
|
207
226
|
alt: m.attrs.alt,
|
|
208
227
|
imageLoaded: m.attrs.loaded,
|
|
209
228
|
alignment: m.attrs.alignment || "left",
|
|
210
|
-
onChange:
|
|
229
|
+
onChange: Z
|
|
211
230
|
})
|
|
212
231
|
})
|
|
213
232
|
}), _._tiptapContainerEl)] });
|
|
214
233
|
}
|
|
215
|
-
|
|
234
|
+
O.propTypes = {
|
|
216
235
|
node: m.object.isRequired,
|
|
217
236
|
editor: m.object.isRequired,
|
|
218
237
|
attributes: m.object,
|
|
219
|
-
onFocus: m.func
|
|
220
|
-
maxImageWidth: m.number,
|
|
221
|
-
maxImageHeight: m.number
|
|
238
|
+
onFocus: m.func
|
|
222
239
|
};
|
|
223
240
|
//#endregion
|
|
224
|
-
export {
|
|
241
|
+
export { O as default };
|
package/dist/extensions/image.js
CHANGED
|
@@ -34,19 +34,31 @@ var f = a.create({
|
|
|
34
34
|
draggable: !0,
|
|
35
35
|
addAttributes() {
|
|
36
36
|
return {
|
|
37
|
-
nodeKey: {
|
|
38
|
-
|
|
37
|
+
nodeKey: {
|
|
38
|
+
default: null,
|
|
39
|
+
parseHTML: (e) => e.getAttribute("nodeKey") || t()
|
|
40
|
+
},
|
|
41
|
+
loaded: {
|
|
42
|
+
default: !1,
|
|
43
|
+
parseHTML: (e) => e.hasAttribute("loaded") ? e.getAttribute("loaded") !== "false" : !/^data:/i.test(e.getAttribute("src") ?? "")
|
|
44
|
+
},
|
|
39
45
|
deleteStatus: { default: null },
|
|
40
46
|
alignment: { default: null },
|
|
41
47
|
percent: { default: null },
|
|
42
|
-
width: {
|
|
43
|
-
|
|
48
|
+
width: {
|
|
49
|
+
default: null,
|
|
50
|
+
parseHTML: (e) => parseInt(e.getAttribute("width"), 10) || null
|
|
51
|
+
},
|
|
52
|
+
height: {
|
|
53
|
+
default: null,
|
|
54
|
+
parseHTML: (e) => parseInt(e.getAttribute("height"), 10) || null
|
|
55
|
+
},
|
|
44
56
|
src: { default: null },
|
|
45
57
|
alt: { default: null }
|
|
46
58
|
};
|
|
47
59
|
},
|
|
48
60
|
parseHTML() {
|
|
49
|
-
return [{ tag: "img[data-type=\"image-upload-node\"]" }];
|
|
61
|
+
return [{ tag: "img[data-type=\"image-upload-node\"]" }, { tag: "img[src]" }];
|
|
50
62
|
},
|
|
51
63
|
renderHTML({ HTMLAttributes: e }) {
|
|
52
64
|
return ["img", o(e, { "data-type": "image-upload-node" })];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-lib/editable-html-tip-tap",
|
|
3
|
-
"version": "3.1.2-next.
|
|
3
|
+
"version": "3.1.2-next.20261020155912",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
"@dnd-kit/utilities": "3.2.2",
|
|
14
14
|
"@mui/icons-material": "^7.3.4",
|
|
15
15
|
"@mui/material": "^7.3.4",
|
|
16
|
-
"@pie-lib/drag": "5.0.7-next.
|
|
17
|
-
"@pie-lib/math-input": "9.0.7-next.
|
|
18
|
-
"@pie-lib/math-toolbar": "4.0.7-next.
|
|
19
|
-
"@pie-lib/render-ui": "8.0.7-next.
|
|
16
|
+
"@pie-lib/drag": "5.0.7-next.20261020155912",
|
|
17
|
+
"@pie-lib/math-input": "9.0.7-next.20261020155912",
|
|
18
|
+
"@pie-lib/math-toolbar": "4.0.7-next.20261020155912",
|
|
19
|
+
"@pie-lib/render-ui": "8.0.7-next.20261020155912",
|
|
20
20
|
"@pie-lib/translator": "5.0.2-next.20261019155156",
|
|
21
21
|
"@tiptap/core": "3.32.0",
|
|
22
22
|
"@tiptap/extension-character-count": "3.32.0",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"react-portal": "^4.2.0",
|
|
44
44
|
"tippy.js": "latest",
|
|
45
45
|
"to-style": "^1.3.3",
|
|
46
|
-
"@pie-element/shared-lodash": "0.1.3-next.
|
|
46
|
+
"@pie-element/shared-lodash": "0.1.3-next.20261020155912",
|
|
47
47
|
"clsx": "^2.1.1",
|
|
48
48
|
"prosemirror-state": "^1.4.4",
|
|
49
49
|
"@pie-element/shared-math-rendering-mathjax": "0.1.8-next.20261019155156",
|