reactjs-tiptap-editor 1.0.10 → 1.0.12
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/lib/{ActionMenuButton-CKTxYtl7.js → ActionMenuButton-BKqin6Kz.js} +17 -13
- package/lib/ActionMenuButton-CPPHERbq.cjs +1 -0
- package/lib/Attachment.cjs +2 -2
- package/lib/Attachment.js +24 -21
- package/lib/Blockquote.cjs +2 -2
- package/lib/Blockquote.js +7 -5
- package/lib/Bold.cjs +1 -1
- package/lib/Bold.js +11 -9
- package/lib/BulletList.cjs +1 -1
- package/lib/BulletList.js +14 -12
- package/lib/Clear.cjs +1 -1
- package/lib/Clear.js +3 -3
- package/lib/Code.cjs +1 -1
- package/lib/Code.js +11 -9
- package/lib/CodeBlock.cjs +22 -22
- package/lib/CodeBlock.js +102 -100
- package/lib/CodeView.cjs +1 -1
- package/lib/CodeView.js +10 -8
- package/lib/Color.cjs +1 -1
- package/lib/Color.js +20 -18
- package/lib/Column.cjs +1 -1
- package/lib/Column.js +7 -5
- package/lib/{Drawer-Cfx115up.js → Drawer-DUPsBE0H.js} +10 -9
- package/lib/Drawer-fplzqNI6.cjs +1 -0
- package/lib/Drawer.cjs +1 -1
- package/lib/Drawer.js +3 -3
- package/lib/Emoji.cjs +1 -1
- package/lib/Emoji.js +11 -9
- package/lib/{Excalidraw-CO93Tsmb.js → Excalidraw-BEzpvRLx.js} +20 -19
- package/lib/Excalidraw-qjnQspLq.cjs +1 -0
- package/lib/Excalidraw.cjs +1 -1
- package/lib/Excalidraw.js +2 -2
- package/lib/ExportPdf.cjs +2 -2
- package/lib/ExportPdf.js +7 -5
- package/lib/ExportWord.cjs +1 -1
- package/lib/ExportWord.js +7 -5
- package/lib/FontFamily.cjs +1 -1
- package/lib/FontFamily.js +9 -8
- package/lib/FontSize.cjs +1 -1
- package/lib/FontSize.js +13 -12
- package/lib/Heading.cjs +1 -1
- package/lib/Heading.js +25 -24
- package/lib/Highlight.cjs +1 -1
- package/lib/Highlight.js +9 -7
- package/lib/History.cjs +1 -1
- package/lib/History.js +18 -15
- package/lib/HorizontalRule.cjs +1 -1
- package/lib/HorizontalRule.js +7 -5
- package/lib/Icon-CiR8RqdQ.cjs +1 -0
- package/lib/Icon-ONE1AwKo.js +12 -0
- package/lib/{Iframe-DwhclppJ.js → Iframe-CBTnv2mk.js} +41 -39
- package/lib/Iframe-DsUNJ2n2.cjs +1 -0
- package/lib/Iframe.cjs +1 -1
- package/lib/Iframe.js +2 -2
- package/lib/Image.cjs +1 -1
- package/lib/Image.js +25 -23
- package/lib/ImageGif.cjs +1 -1
- package/lib/ImageGif.js +53 -51
- package/lib/ImportWord.cjs +31 -31
- package/lib/ImportWord.js +8 -6
- package/lib/{Indent-BOsymiZ7.js → Indent-B00o0P0M.js} +26 -24
- package/lib/Indent-CaGP0qTp.cjs +1 -0
- package/lib/Indent.cjs +1 -1
- package/lib/Indent.js +2 -2
- package/lib/Italic.cjs +1 -1
- package/lib/Italic.js +12 -10
- package/lib/Katex-XsfpKgJU.cjs +4 -0
- package/lib/{Katex-BYK-b9X2.js → Katex-x370CSXZ.js} +12 -10
- package/lib/Katex.cjs +1 -1
- package/lib/Katex.js +2 -2
- package/lib/LineHeight.cjs +1 -1
- package/lib/LineHeight.js +10 -8
- package/lib/Link.cjs +1 -1
- package/lib/Link.js +2 -2
- package/lib/{LinkEditBlock-DgrLUMsJ.js → LinkEditBlock-C_ipl3EA.js} +23 -21
- package/lib/{LinkEditBlock-4-iRXH7m.cjs → LinkEditBlock-xt88G5fb.cjs} +2 -2
- package/lib/Mention.cjs +1 -1
- package/lib/Mention.js +3 -3
- package/lib/Mermaid.cjs +2 -2
- package/lib/Mermaid.js +18 -17
- package/lib/MoreMark.cjs +1 -1
- package/lib/MoreMark.js +25 -22
- package/lib/OrderedList.cjs +1 -1
- package/lib/OrderedList.js +10 -8
- package/lib/SearchAndReplace.cjs +1 -1
- package/lib/SearchAndReplace.js +43 -41
- package/lib/SlashCommand.cjs +1 -1
- package/lib/SlashCommand.js +6 -6
- package/lib/SlashCommandNodeView-BT5ystah.cjs +1 -0
- package/lib/{SlashCommandNodeView-BpNNU7Sm.js → SlashCommandNodeView-DX6axvLs.js} +75 -66
- package/lib/Strike.cjs +1 -1
- package/lib/Strike.js +7 -5
- package/lib/Table-DSRSwtXx.cjs +9 -0
- package/lib/{Table-CT9R9Sdq.js → Table-DidusYID.js} +10 -8
- package/lib/Table.cjs +1 -1
- package/lib/Table.js +1 -1
- package/lib/TaskList.cjs +1 -1
- package/lib/TaskList.js +15 -13
- package/lib/TextAlign.cjs +1 -1
- package/lib/TextAlign.js +20 -17
- package/lib/TextDirection.cjs +1 -1
- package/lib/TextDirection.js +20 -17
- package/lib/TextUnderline.cjs +1 -1
- package/lib/TextUnderline.js +7 -5
- package/lib/Twitter-CBuVBQM1.cjs +1 -0
- package/lib/{Twitter-mowilxRd.js → Twitter-D58T0Zt3.js} +51 -49
- package/lib/Twitter.cjs +1 -1
- package/lib/Twitter.js +2 -2
- package/lib/Video.cjs +1 -1
- package/lib/Video.js +13 -11
- package/lib/bubble.cjs +4 -4
- package/lib/bubble.js +403 -407
- package/lib/{button-CBO-WDXK.js → button-9_8t7ca7.js} +4 -3
- package/lib/button-Cs9TroWr.cjs +1 -0
- package/lib/{checkbox-DUcLSGZD.cjs → checkbox-BQRKTXXr.cjs} +1 -1
- package/lib/{checkbox-D1h32VWM.js → checkbox-DnkkV6qo.js} +1 -1
- package/lib/{index-BBNITgNi.cjs → clsx-CXbNJWDD.cjs} +13 -13
- package/lib/{index-sVScpCFG.js → clsx-DmuN0U_8.js} +228 -228
- package/lib/{dialog-DY868Uji.cjs → dialog-BS3zm-T9.cjs} +1 -1
- package/lib/{dialog-DSvgtlDI.js → dialog-DhayAPvV.js} +1 -1
- package/lib/{dropdown-menu-BripAeGB.cjs → dropdown-menu-CxwWX0yj.cjs} +1 -1
- package/lib/{dropdown-menu-B88Qn2KR.js → dropdown-menu-DQqKeZcx.js} +1 -1
- package/lib/events.constant-Dq21NPdV.cjs +1 -0
- package/lib/events.constant-do95b767.js +21 -0
- package/lib/{index-CApXPpjF.cjs → index-BCzvbrf5.cjs} +1 -1
- package/lib/{index-0OnGZkVF.js → index-BDX1uE62.js} +78 -312
- package/lib/index-CBFmXCcU.cjs +1 -0
- package/lib/{index-DmPwbBqm.js → index-CKmT9KAQ.js} +1 -1
- package/lib/index-CVFzP1Dc.cjs +1 -0
- package/lib/index-CX4pNJlH.cjs +1 -0
- package/lib/index-CjhjjJsN.cjs +1 -0
- package/lib/index-Cs6cp0Y6.cjs +1 -0
- package/lib/{index-9A6-kVBM.js → index-D1jd7elj.js} +1 -1
- package/lib/{index-BIqaogQg.js → index-D9JOHlso.js} +449 -1216
- package/lib/{index-DRHrDScg.js → index-DdEmgiAA.js} +1 -1
- package/lib/{index-DKt5wfAc.js → index-DvvwJvau.js} +23 -23
- package/lib/index-EAK64CCA.js +425 -0
- package/lib/{index--nUS7Y66.cjs → index-neeeY2o7.cjs} +3 -3
- package/lib/index.cjs +9 -2
- package/lib/index.js +142 -26
- package/lib/{input-BeD5GdMv.cjs → input-BJ7ihMq-.cjs} +1 -1
- package/lib/{input-Bx4uo4gO.js → input-YoheBL2D.js} +1 -1
- package/lib/{isNumber-Bv1Qhmw8.cjs → isNumber-BTYSVlKo.cjs} +1 -1
- package/lib/{isNumber-DF0fU3ob.js → isNumber-DmQXlKp3.js} +1 -1
- package/lib/label-C8PLcjFI.js +19 -0
- package/lib/label-Y7_hvqf2.cjs +1 -0
- package/lib/locale-bundle.cjs +1 -1
- package/lib/locale-bundle.js +6 -7
- package/lib/locales/index.d.ts +3 -4316
- package/lib/{popover-Csk538NC.cjs → popover-BiSrlM4j.cjs} +1 -1
- package/lib/{popover-BVX8otO9.js → popover-CWmTzHSy.js} +1 -1
- package/lib/react-BEoMZB61.cjs +1 -0
- package/lib/react-c9FSfB30.js +27 -0
- package/lib/separator-C-DKMYmg.js +329 -0
- package/lib/separator-CJ_adziN.cjs +1 -0
- package/lib/store/EditorEditableReactive.d.ts +1 -0
- package/lib/store/ThemeColorReactive.d.ts +1 -0
- package/lib/store/commandList.d.ts +1 -1
- package/lib/store/store.d.ts +6 -7
- package/lib/store-BKMaw1AW.cjs +1 -0
- package/lib/store-DG7cMfET.js +10 -0
- package/lib/style.css +1 -1
- package/lib/{tabs-DOasUMDU.cjs → tabs-DpHSMyF_.cjs} +1 -1
- package/lib/{tabs-BKpr0QQB.js → tabs-DxlKKM-N.js} +1 -1
- package/lib/{textarea-Ba9OOzba.js → textarea-D7m-apUh.js} +1 -1
- package/lib/{textarea-D9egO4qC.cjs → textarea-DU9RMi6u.cjs} +1 -1
- package/lib/theme/theme.d.ts +5 -0
- package/lib/theme.cjs +1 -1
- package/lib/theme.js +37 -8
- package/lib/{throttle-DsowOft0.js → throttle-BRtichEP.js} +1 -1
- package/lib/throttle-gTTvqDTW.cjs +1 -0
- package/lib/toggle-BYvLnjCL.cjs +1 -0
- package/lib/toggle-Bxwwb_Kp.js +99 -0
- package/lib/tooltip-BTy5CRrN.js +24 -0
- package/lib/tooltip-COvf4_R-.cjs +1 -0
- package/lib/{updatePosition-Bbd8ETMv.js → updatePosition-CUukgu-Q.js} +2 -2
- package/lib/updatePosition-Cjuj2E26.cjs +1 -0
- package/lib/{useButtonProps-C_bqxmHi.js → useButtonProps-CfYtuEnd.js} +48 -36
- package/lib/useButtonProps-CydzndG1.cjs +1 -0
- package/lib/utils/customEvents/events.constant.d.ts +0 -5
- package/package.json +3 -3
- package/lib/ActionMenuButton-BPdRqzDX.cjs +0 -1
- package/lib/Drawer-hHj4Opkg.cjs +0 -1
- package/lib/Excalidraw-8pWJ17Ye.cjs +0 -1
- package/lib/Icon-D7GJZzoa.js +0 -10
- package/lib/Icon-gtc3g-VK.cjs +0 -1
- package/lib/Iframe-BmXO2c65.cjs +0 -1
- package/lib/Indent-DPkMWfcv.cjs +0 -1
- package/lib/Katex-B1XbT8-X.cjs +0 -4
- package/lib/SlashCommandNodeView-CQvMTXys.cjs +0 -1
- package/lib/Table-LnWGm2m8.cjs +0 -9
- package/lib/Twitter-Bo4JkBTL.cjs +0 -1
- package/lib/button-wt49IYwP.cjs +0 -1
- package/lib/events.constant-DQYeJpu5.cjs +0 -1
- package/lib/events.constant-wrlJ_7JZ.js +0 -26
- package/lib/index-BZ6DfR2r.cjs +0 -1
- package/lib/index-BvIJKpX1.cjs +0 -8
- package/lib/index-Cv9Z6dyV.cjs +0 -1
- package/lib/index-FSRjMsxW.cjs +0 -1
- package/lib/label--161UPH6.cjs +0 -1
- package/lib/label-uKG7RzFU.js +0 -18
- package/lib/separator-DLRVddHS.cjs +0 -1
- package/lib/separator-DtrEdjAF.js +0 -241
- package/lib/store/ProviderUniqueId.d.ts +0 -6
- package/lib/store-B8IkVz1J.cjs +0 -1
- package/lib/store-CsIFDUKR.js +0 -10
- package/lib/throttle-BM3Bmbf_.cjs +0 -1
- package/lib/updatePosition-M2IyqkI1.cjs +0 -1
- package/lib/useButtonProps-DEtmDVPr.cjs +0 -1
package/lib/Image.js
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as q, c as pe } from "./throttle-
|
|
1
|
+
import { o as he, m as fe, s as ge } from "./clsx-DmuN0U_8.js";
|
|
2
|
+
import { a as q, c as pe } from "./throttle-BRtichEP.js";
|
|
3
3
|
import { jsx as o, jsxs as b, Fragment as H } from "react/jsx-runtime";
|
|
4
4
|
import j, { useState as L, useMemo as P, useCallback as F, useEffect as W, useRef as ae } from "react";
|
|
5
|
-
import { I as Z,
|
|
6
|
-
import { i as K, c as xe } from "./isNumber-
|
|
7
|
-
import { A as ye } from "./
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
5
|
+
import { I as Z, i as J, j as be, u as ne } from "./index-BDX1uE62.js";
|
|
6
|
+
import { i as K, c as xe } from "./isNumber-DmQXlKp3.js";
|
|
7
|
+
import { A as ye } from "./toggle-Bxwwb_Kp.js";
|
|
8
|
+
import "./index-D9JOHlso.js";
|
|
9
|
+
import "./theme.js";
|
|
10
|
+
import { B } from "./button-9_8t7ca7.js";
|
|
11
|
+
import { I as Q } from "./input-YoheBL2D.js";
|
|
12
|
+
import { L as ee } from "./label-C8PLcjFI.js";
|
|
13
|
+
import { T as we, a as Ie, b as te, c as ie } from "./tabs-DxlKKM-N.js";
|
|
12
14
|
import { u as re } from "./use-toast-Crf7-q5H.js";
|
|
13
|
-
import { C as ve } from "./checkbox-
|
|
14
|
-
import { D as le, a as oe, b as se, c as ce, d as Te } from "./dialog-
|
|
15
|
+
import { C as ve } from "./checkbox-DnkkV6qo.js";
|
|
16
|
+
import { D as le, a as oe, b as se, c as ce, d as Te } from "./dialog-DhayAPvV.js";
|
|
15
17
|
import Ae from "react-image-crop";
|
|
16
|
-
import { d as Ce,
|
|
17
|
-
import { d as
|
|
18
|
-
import { I as $ } from "./Icon-
|
|
19
|
-
import { a as Se } from "./store-
|
|
20
|
-
import { l as _e, E as ze } from "./events.constant-
|
|
18
|
+
import { d as de, c as Ce, u as Ee, a as Me } from "./useButtonProps-CfYtuEnd.js";
|
|
19
|
+
import { d as Le, r as Ne } from "./file-BLas99n7.js";
|
|
20
|
+
import { I as $ } from "./Icon-ONE1AwKo.js";
|
|
21
|
+
import { a as Se } from "./store-DG7cMfET.js";
|
|
22
|
+
import { l as _e, E as ze } from "./events.constant-do95b767.js";
|
|
21
23
|
const X = {
|
|
22
24
|
TOP_LEFT: "tl",
|
|
23
25
|
TOP_RIGHT: "tr",
|
|
@@ -262,14 +264,14 @@ function Ue({ editor: e, imageInline: t, onClose: a, disabled: s, alt: f }) {
|
|
|
262
264
|
if (!x) {
|
|
263
265
|
C(!0);
|
|
264
266
|
try {
|
|
265
|
-
const r =
|
|
267
|
+
const r = Le(k, ((i = E == null ? void 0 : E.file) == null ? void 0 : i.name) || "image.png");
|
|
266
268
|
let h = "";
|
|
267
269
|
p.upload ? h = await p.upload(r) : h = URL.createObjectURL(r), e.chain().focus().setImageInline({ src: h, inline: t, alt: f }).run(), m(!1), z({
|
|
268
270
|
src: "",
|
|
269
271
|
file: null
|
|
270
272
|
}), N(), a();
|
|
271
273
|
} catch (r) {
|
|
272
|
-
console.
|
|
274
|
+
console.error("Error cropping image", r);
|
|
273
275
|
} finally {
|
|
274
276
|
C(!1);
|
|
275
277
|
}
|
|
@@ -297,7 +299,7 @@ function Ue({ editor: e, imageInline: t, onClose: a, disabled: s, alt: f }) {
|
|
|
297
299
|
i.target.value = "";
|
|
298
300
|
return;
|
|
299
301
|
}
|
|
300
|
-
const l = h[0], w = await
|
|
302
|
+
const l = h[0], w = await Ne(l);
|
|
301
303
|
m(!0), z({
|
|
302
304
|
src: w.src,
|
|
303
305
|
file: l
|
|
@@ -412,11 +414,11 @@ function Ue({ editor: e, imageInline: t, onClose: a, disabled: s, alt: f }) {
|
|
|
412
414
|
)
|
|
413
415
|
] });
|
|
414
416
|
}
|
|
415
|
-
function
|
|
416
|
-
const { t: e } = ne(), { toast: t } = re(), a =
|
|
417
|
+
function lt() {
|
|
418
|
+
const { t: e } = ne(), { toast: t } = re(), a = Ce(), s = Ee(G.name), {
|
|
417
419
|
icon: f,
|
|
418
420
|
tooltip: u
|
|
419
|
-
} = (s == null ? void 0 : s.componentProps) ?? {}, { editorDisabled: g } =
|
|
421
|
+
} = (s == null ? void 0 : s.componentProps) ?? {}, { editorDisabled: g } = Me(), [v, m] = L(!1), [x, C] = L(!1), T = de(G.name), _ = (d) => {
|
|
420
422
|
m(d.detail);
|
|
421
423
|
}, [S, k] = L(""), [R, M] = L(""), E = ae(null), z = (T == null ? void 0 : T.options.defaultInline) || !1, [A, p] = L(z), c = P(() => T == null ? void 0 : T.options, [T]);
|
|
422
424
|
W(() => {
|
|
@@ -824,5 +826,5 @@ const De = {
|
|
|
824
826
|
});
|
|
825
827
|
export {
|
|
826
828
|
G as Image,
|
|
827
|
-
|
|
829
|
+
lt as RichTextImage
|
|
828
830
|
};
|
package/lib/ImageGif.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("./clsx-CXbNJWDD.cjs"),N=require("./throttle-gTTvqDTW.cjs"),l=require("react/jsx-runtime"),d=require("react"),G=require("./index-CVFzP1Dc.cjs"),L=require("./isNumber-BTYSVlKo.cjs"),W=require("./toggle-BYvLnjCL.cjs");require("./index-CX4pNJlH.cjs");require("./theme.cjs");const D=require("./input-BJ7ihMq-.cjs"),P=require("./popover-BiSrlM4j.cjs"),k=require("./useButtonProps-CydzndG1.cjs"),S={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function B(e){var C,$;const[t,n]=d.useState({width:G.IMAGE_MAX_SIZE,height:G.IMAGE_MAX_SIZE}),[c,i]=d.useState({width:0,height:0}),[r]=d.useState([S.TOP_LEFT,S.TOP_RIGHT,S.BOTTOM_LEFT,S.BOTTOM_RIGHT]),[s,a]=d.useState(!1),[h,b]=d.useState({x:0,y:0,w:0,h:0,dir:""}),{align:x}=(C=e==null?void 0:e.node)==null?void 0:C.attrs,m=d.useMemo(()=>{var v;const{src:o,alt:f,width:w,height:M}=(v=e==null?void 0:e.node)==null?void 0:v.attrs,A=L.isNumber(w)?`${w}px`:w,u=L.isNumber(M)?`${M}px`:M;return{src:o||void 0,alt:f||void 0,style:{width:A||void 0,height:u||void 0}}},[($=e==null?void 0:e.node)==null?void 0:$.attrs]),T=d.useMemo(()=>{const{style:{width:o}}=m;return{width:o==="100%"?o:void 0}},[m]);function g(o){i({width:o.target.width,height:o.target.height})}function _(){const{editor:o,getPos:f}=e;o.commands.setNodeSelection(f())}const y=d.useCallback(N.throttle(()=>{const{editor:o}=e,{width:f}=getComputedStyle(o.view.dom);n(w=>({...w,width:Number.parseInt(f,10)}))},G.IMAGE_THROTTLE_WAIT_TIME),[e==null?void 0:e.editor]);function p(o,f){o.preventDefault(),o.stopPropagation();const w=c.width,M=c.height,A=w/M;let u=Number(e.node.attrs.width),v=Number(e.node.attrs.height);const I=t.width;u&&!v?(u=u>I?I:u,v=Math.round(u/A)):v&&!u?(u=Math.round(v*A),u=u>I?I:u):!u&&!v?(u=w>I?I:w,v=Math.round(u/A)):u=u>I?I:u,a(!0),b({x:o.clientX,y:o.clientY,w:u,h:v,dir:f})}const j=d.useCallback(N.throttle(o=>{if(o.preventDefault(),o.stopPropagation(),!s)return;const{x:f,w,dir:M}=h,A=(o.clientX-f)*(/l/.test(M)?-1:1),u=L.clamp(w+A,G.IMAGE_MIN_SIZE,t.width);e.updateAttributes({width:u,height:null})},G.IMAGE_THROTTLE_WAIT_TIME),[s,h,t,e.updateAttributes]),E=d.useCallback(o=>{o.preventDefault(),o.stopPropagation(),s&&(b({x:0,y:0,w:0,h:0,dir:""}),a(!1),_())},[s,_]),z=d.useCallback(()=>{document==null||document.addEventListener("mousemove",j,!0),document==null||document.addEventListener("mouseup",E,!0)},[j,E]),O=d.useCallback(()=>{document==null||document.removeEventListener("mousemove",j,!0),document==null||document.removeEventListener("mouseup",E,!0)},[j,E]);d.useEffect(()=>(s?z():O(),()=>{O()}),[s,z,O]);const R=d.useMemo(()=>new ResizeObserver(()=>y()),[y]);return d.useEffect(()=>(R.observe(e.editor.view.dom),()=>{R.disconnect()}),[e.editor.view.dom,R]),l.jsx(q.NodeViewWrapper,{className:"image-view",style:{...T,width:"100%",textAlign:x},children:l.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:T,className:`image-view__body ${e!=null&&e.selected?"image-view__body--focused":""} ${s?"image-view__body--resizing":""}`,children:[l.jsx("img",{alt:m.alt,className:"image-view__body__image block",height:"auto",onClick:_,onLoad:g,src:m.src,style:m.style}),(e==null?void 0:e.editor.view.editable)&&((e==null?void 0:e.selected)||s)&&l.jsx("div",{className:"image-resizer",children:r==null?void 0:r.map(o=>l.jsx("span",{className:`image-resizer__handler image-resizer__handler--${o}`,onMouseDown:f=>p(f,o)},`image-dir-${o}`))})]})})}async function F(e){var c;const n=await(await fetch(`https://api.giphy.com/v1/gifs/trending?q=&limit=15&api_key=${e}`)).json();return(c=n==null?void 0:n.data)==null?void 0:c.map(i=>{var r,s,a;return{id:i==null?void 0:i.id,src:(r=i==null?void 0:i.images.original)==null?void 0:r.url,width:+((s=i==null?void 0:i.images.original)==null?void 0:s.width),height:+((a=i==null?void 0:i.images.original)==null?void 0:a.width)}})}async function V(e,t){var i;const c=await(await fetch(`https://api.giphy.com/v1/gifs/search?q=${e}&limit=15&api_key=${t}`)).json();return(i=c==null?void 0:c.data)==null?void 0:i.map(r=>{var s,a,h;return{id:r==null?void 0:r.id,src:(s=r==null?void 0:r.images.original)==null?void 0:s.url,width:+((a=r==null?void 0:r.images.original)==null?void 0:a.width),height:+((h=r==null?void 0:r.images.original)==null?void 0:h.width)}})}async function X(e){var r,s;const t=await fetch(`https://tenor.googleapis.com/v2/trending_terms?key=${e}&limit=10`),n=await(t==null?void 0:t.json()),i=await(await fetch(`https://tenor.googleapis.com/v2/search?key=${e}&q=${(r=n==null?void 0:n.results)==null?void 0:r[0]}&limit=15`)).json();return(s=i==null?void 0:i.results)==null?void 0:s.map(a=>{var h,b,x,m,T,g,_,y;return{id:a==null?void 0:a.id,src:(b=(h=a==null?void 0:a.media_formats)==null?void 0:h.gif)==null?void 0:b.url,width:(T=(m=(x=a==null?void 0:a.media_formats)==null?void 0:x.gif)==null?void 0:m.dims)==null?void 0:T[0],height:(y=(_=(g=a==null?void 0:a.media_formats)==null?void 0:g.gif)==null?void 0:_.dims)==null?void 0:y[1]}})}async function Y(e,t){var i;const c=await(await fetch(`https://tenor.googleapis.com/v2/search?key=${t}&q=${e}&limit=15`)).json();return(i=c==null?void 0:c.results)==null?void 0:i.map(r=>{var s,a,h,b,x,m,T,g;return{id:r==null?void 0:r.id,src:(a=(s=r==null?void 0:r.media_formats)==null?void 0:s.gif)==null?void 0:a.url,width:(x=(b=(h=r==null?void 0:r.media_formats)==null?void 0:h.gif)==null?void 0:b.dims)==null?void 0:x[0],height:(g=(T=(m=r==null?void 0:r.media_formats)==null?void 0:m.gif)==null?void 0:T.dims)==null?void 0:g[1]}})}function Z(e,t){return{searchTrending:async()=>t?e==="giphy"?F(t):e==="tenor"?X(t):[]:[],searchWord:async i=>t?e==="giphy"?V(i,t):e==="tenor"?Y(i,t):[]:[]}}function U({selectImage:e,apiKey:t,provider:n,children:c}){const[i,r]=d.useState(!1),[s,a]=d.useState([]),{editorDisabled:h}=k.useToggleActive(),b=d.useRef(null),{searchTrending:x,searchWord:m}=Z(n,t);d.useEffect(()=>{(async()=>{const g=await x();a(g)})()},[]);const T=d.useCallback(N.debounce(async g=>{if(!g.target.value){const y=await x();a(y);return}const _=await m(g.target.value);a(_)},350),[]);return l.jsxs(P.Popover,{modal:!0,onOpenChange:r,open:i,children:[l.jsx(P.PopoverTrigger,{asChild:!0,disabled:h,children:c}),l.jsx(P.PopoverContent,{align:"start",className:"richtext-size-full richtext-p-2",hideWhenDetached:!0,side:"bottom",children:t?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"richtext-mb-[10px] richtext-w-full",children:l.jsx(D.Input,{onChange:T,placeholder:"Search GIF",ref:b,type:"text"})}),l.jsx("div",{className:"richtext-max-h-[280px] !richtext-max-w-[400px] richtext-overflow-y-auto",children:l.jsx("div",{className:"richtext-grid richtext-grid-cols-2 richtext-gap-1 ",children:s!=null&&s.length?s==null?void 0:s.map(g=>l.jsx("img",{alt:"",className:"richtext-cursor-pointer richtext-object-contain richtext-text-center",src:g.src,onClick:()=>{e(g.src),r(!1)}},g.id)):l.jsx("p",{children:"No GIFs found"})})})]}):l.jsx("div",{children:l.jsx("p",{children:"Missing Giphy API Key"})})})]})}function J(){const e=k.useButtonProps(H.name),{action:t,icon:n,tooltip:c,apiKey:i,provider:r}=(e==null?void 0:e.componentProps)??{},{editorDisabled:s}=k.useToggleActive(),a=h=>{s||t&&t(h)};return l.jsx(U,{apiKey:i,provider:r,selectImage:a,children:l.jsx(W.ActionButton,{disabled:s,icon:n,tooltip:c})})}const H=N.index_default.extend({name:"imageGif",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),inline:!1,content:"",marks:"",group:"block",API_KEY:"",provider:"giphy",draggable:!1,selectable:!0,atom:!0,button:({editor:t,extension:n,t:c})=>{var s,a;const i=((s=n==null?void 0:n.options)==null?void 0:s.provider)||"",r=((a=n==null?void 0:n.options)==null?void 0:a.API_KEY)||"";return{componentProps:{action:h=>{t.chain().focus().setImageGif({src:h}).run()},isActive:()=>!1,disabled:!1,icon:"GifIcon",tooltip:c("editor.imageGif.tooltip"),apiKey:r,provider:i}}}}},addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),width:{default:null,parseHTML:t=>{const n=t.style.width||t.getAttribute("width")||"10";return n===void 0?null:Number.parseInt(`${n}`,10)},renderHTML:t=>({width:t.width})},align:{default:"center",parseHTML:t=>t.getAttribute("align"),renderHTML:t=>({align:t.align})}}},addNodeView(){return q.ReactNodeViewRenderer(B)},addCommands(){var e;return{...(e=this.parent)==null?void 0:e.call(this),setImageGif:t=>({commands:n})=>n.insertContent({type:this.name,attrs:t}),updateImageGif:t=>({commands:n})=>n.updateAttributes(this.name,t),setAlignImageGif:t=>({commands:n})=>n.updateAttributes(this.name,{align:t})}},renderHTML({HTMLAttributes:e}){const{align:t}=e;return["div",{style:t?`text-align: ${t};`:"",class:"imageGIf"},["img",q.mergeAttributes({height:"auto"},this.options.HTMLAttributes,e)]]},parseHTML(){return[{tag:"div[class=imageGIf]",getAttrs:e=>{const t=e.querySelector("img"),n=t==null?void 0:t.getAttribute("width");return{src:t==null?void 0:t.getAttribute("src"),alt:t==null?void 0:t.getAttribute("alt"),title:t==null?void 0:t.getAttribute("title"),width:n?Number.parseInt(n,10):null,align:(t==null?void 0:t.getAttribute("align"))||e.style.textAlign||null}}}]}});exports.ImageGif=H;exports.RichTextImageGif=J;
|
package/lib/ImageGif.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as
|
|
3
|
-
import { jsx as u, jsxs as
|
|
4
|
-
import { useState as G, useMemo as
|
|
5
|
-
import { I as C, j,
|
|
6
|
-
import { i as W, c as Q } from "./isNumber-
|
|
7
|
-
import { A as K } from "./
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
1
|
+
import { o as B, m as q, s as V } from "./clsx-DmuN0U_8.js";
|
|
2
|
+
import { a as k, d as X, c as Y } from "./throttle-BRtichEP.js";
|
|
3
|
+
import { jsx as u, jsxs as P, Fragment as Z } from "react/jsx-runtime";
|
|
4
|
+
import { useState as G, useMemo as L, useCallback as M, useEffect as z, useRef as U } from "react";
|
|
5
|
+
import { I as C, i as j, j as J } from "./index-BDX1uE62.js";
|
|
6
|
+
import { i as W, c as Q } from "./isNumber-DmQXlKp3.js";
|
|
7
|
+
import { A as K } from "./toggle-Bxwwb_Kp.js";
|
|
8
|
+
import "./index-D9JOHlso.js";
|
|
9
|
+
import "./theme.js";
|
|
10
|
+
import { I as ee } from "./input-YoheBL2D.js";
|
|
11
|
+
import { P as te, a as re, b as ne } from "./popover-CWmTzHSy.js";
|
|
12
|
+
import { u as ie, a as D } from "./useButtonProps-CfYtuEnd.js";
|
|
11
13
|
const O = {
|
|
12
14
|
TOP_LEFT: "tl",
|
|
13
15
|
TOP_RIGHT: "tr",
|
|
@@ -15,7 +17,7 @@ const O = {
|
|
|
15
17
|
BOTTOM_RIGHT: "br"
|
|
16
18
|
};
|
|
17
19
|
function ae(e) {
|
|
18
|
-
var R,
|
|
20
|
+
var R, H;
|
|
19
21
|
const [t, n] = G({
|
|
20
22
|
width: C,
|
|
21
23
|
height: C
|
|
@@ -33,23 +35,23 @@ function ae(e) {
|
|
|
33
35
|
w: 0,
|
|
34
36
|
h: 0,
|
|
35
37
|
dir: ""
|
|
36
|
-
}), { align: b } = (R = e == null ? void 0 : e.node) == null ? void 0 : R.attrs,
|
|
38
|
+
}), { align: b } = (R = e == null ? void 0 : e.node) == null ? void 0 : R.attrs, m = L(() => {
|
|
37
39
|
var w;
|
|
38
|
-
const { src: o, alt:
|
|
40
|
+
const { src: o, alt: g, width: f, height: x } = (w = e == null ? void 0 : e.node) == null ? void 0 : w.attrs, A = W(f) ? `${f}px` : f, d = W(x) ? `${x}px` : x;
|
|
39
41
|
return {
|
|
40
42
|
src: o || void 0,
|
|
41
|
-
alt:
|
|
43
|
+
alt: g || void 0,
|
|
42
44
|
style: {
|
|
43
45
|
width: A || void 0,
|
|
44
46
|
height: d || void 0
|
|
45
47
|
}
|
|
46
48
|
};
|
|
47
|
-
}, [(
|
|
49
|
+
}, [(H = e == null ? void 0 : e.node) == null ? void 0 : H.attrs]), _ = L(() => {
|
|
48
50
|
const {
|
|
49
51
|
style: { width: o }
|
|
50
|
-
} =
|
|
52
|
+
} = m;
|
|
51
53
|
return { width: o === "100%" ? o : void 0 };
|
|
52
|
-
}, [
|
|
54
|
+
}, [m]);
|
|
53
55
|
function h(o) {
|
|
54
56
|
i({
|
|
55
57
|
width: o.target.width,
|
|
@@ -57,20 +59,20 @@ function ae(e) {
|
|
|
57
59
|
});
|
|
58
60
|
}
|
|
59
61
|
function y() {
|
|
60
|
-
const { editor: o, getPos:
|
|
61
|
-
o.commands.setNodeSelection(
|
|
62
|
+
const { editor: o, getPos: g } = e;
|
|
63
|
+
o.commands.setNodeSelection(g());
|
|
62
64
|
}
|
|
63
65
|
const T = M(
|
|
64
|
-
|
|
65
|
-
const { editor: o } = e, { width:
|
|
66
|
+
k(() => {
|
|
67
|
+
const { editor: o } = e, { width: g } = getComputedStyle(o.view.dom);
|
|
66
68
|
n((f) => ({
|
|
67
69
|
...f,
|
|
68
|
-
width: Number.parseInt(
|
|
70
|
+
width: Number.parseInt(g, 10)
|
|
69
71
|
}));
|
|
70
72
|
}, j),
|
|
71
73
|
[e == null ? void 0 : e.editor]
|
|
72
74
|
);
|
|
73
|
-
function F(o,
|
|
75
|
+
function F(o, g) {
|
|
74
76
|
o.preventDefault(), o.stopPropagation();
|
|
75
77
|
const f = c.width, x = c.height, A = f / x;
|
|
76
78
|
let d = Number(e.node.attrs.width), w = Number(e.node.attrs.height);
|
|
@@ -80,14 +82,14 @@ function ae(e) {
|
|
|
80
82
|
y: o.clientY,
|
|
81
83
|
w: d,
|
|
82
84
|
h: w,
|
|
83
|
-
dir:
|
|
85
|
+
dir: g
|
|
84
86
|
});
|
|
85
87
|
}
|
|
86
88
|
const N = M(
|
|
87
|
-
|
|
89
|
+
k((o) => {
|
|
88
90
|
if (o.preventDefault(), o.stopPropagation(), !a)
|
|
89
91
|
return;
|
|
90
|
-
const { x:
|
|
92
|
+
const { x: g, w: f, dir: x } = l, A = (o.clientX - g) * (/l/.test(x) ? -1 : 1), d = Q(f + A, J, t.width);
|
|
91
93
|
e.updateAttributes({
|
|
92
94
|
width: d,
|
|
93
95
|
height: null
|
|
@@ -107,21 +109,21 @@ function ae(e) {
|
|
|
107
109
|
[a, y]
|
|
108
110
|
), $ = M(() => {
|
|
109
111
|
document == null || document.addEventListener("mousemove", N, !0), document == null || document.addEventListener("mouseup", E, !0);
|
|
110
|
-
}, [N, E]),
|
|
112
|
+
}, [N, E]), p = M(() => {
|
|
111
113
|
document == null || document.removeEventListener("mousemove", N, !0), document == null || document.removeEventListener("mouseup", E, !0);
|
|
112
114
|
}, [N, E]);
|
|
113
|
-
z(() => (a ? $() :
|
|
114
|
-
|
|
115
|
-
}), [a, $,
|
|
116
|
-
const
|
|
117
|
-
return z(() => (
|
|
118
|
-
|
|
119
|
-
}), [e.editor.view.dom,
|
|
120
|
-
|
|
115
|
+
z(() => (a ? $() : p(), () => {
|
|
116
|
+
p();
|
|
117
|
+
}), [a, $, p]);
|
|
118
|
+
const S = L(() => new ResizeObserver(() => T()), [T]);
|
|
119
|
+
return z(() => (S.observe(e.editor.view.dom), () => {
|
|
120
|
+
S.disconnect();
|
|
121
|
+
}), [e.editor.view.dom, S]), /* @__PURE__ */ u(
|
|
122
|
+
B,
|
|
121
123
|
{
|
|
122
124
|
className: "image-view",
|
|
123
125
|
style: { ..._, width: "100%", textAlign: b },
|
|
124
|
-
children: /* @__PURE__ */
|
|
126
|
+
children: /* @__PURE__ */ P(
|
|
125
127
|
"div",
|
|
126
128
|
{
|
|
127
129
|
"data-drag-handle": !0,
|
|
@@ -132,20 +134,20 @@ function ae(e) {
|
|
|
132
134
|
/* @__PURE__ */ u(
|
|
133
135
|
"img",
|
|
134
136
|
{
|
|
135
|
-
alt:
|
|
137
|
+
alt: m.alt,
|
|
136
138
|
className: "image-view__body__image block",
|
|
137
139
|
height: "auto",
|
|
138
140
|
onClick: y,
|
|
139
141
|
onLoad: h,
|
|
140
|
-
src:
|
|
141
|
-
style:
|
|
142
|
+
src: m.src,
|
|
143
|
+
style: m.style
|
|
142
144
|
}
|
|
143
145
|
),
|
|
144
146
|
(e == null ? void 0 : e.editor.view.editable) && ((e == null ? void 0 : e.selected) || a) && /* @__PURE__ */ u("div", { className: "image-resizer", children: r == null ? void 0 : r.map((o) => /* @__PURE__ */ u(
|
|
145
147
|
"span",
|
|
146
148
|
{
|
|
147
149
|
className: `image-resizer__handler image-resizer__handler--${o}`,
|
|
148
|
-
onMouseDown: (
|
|
150
|
+
onMouseDown: (g) => F(g, o)
|
|
149
151
|
},
|
|
150
152
|
`image-dir-${o}`
|
|
151
153
|
)) })
|
|
@@ -185,11 +187,11 @@ async function ce(e) {
|
|
|
185
187
|
var r, a;
|
|
186
188
|
const t = await fetch(`https://tenor.googleapis.com/v2/trending_terms?key=${e}&limit=10`), n = await (t == null ? void 0 : t.json()), i = await (await fetch(`https://tenor.googleapis.com/v2/search?key=${e}&q=${(r = n == null ? void 0 : n.results) == null ? void 0 : r[0]}&limit=15`)).json();
|
|
187
189
|
return (a = i == null ? void 0 : i.results) == null ? void 0 : a.map((s) => {
|
|
188
|
-
var l, v, b,
|
|
190
|
+
var l, v, b, m, _, h, y, T;
|
|
189
191
|
return {
|
|
190
192
|
id: s == null ? void 0 : s.id,
|
|
191
193
|
src: (v = (l = s == null ? void 0 : s.media_formats) == null ? void 0 : l.gif) == null ? void 0 : v.url,
|
|
192
|
-
width: (_ = (
|
|
194
|
+
width: (_ = (m = (b = s == null ? void 0 : s.media_formats) == null ? void 0 : b.gif) == null ? void 0 : m.dims) == null ? void 0 : _[0],
|
|
193
195
|
height: (T = (y = (h = s == null ? void 0 : s.media_formats) == null ? void 0 : h.gif) == null ? void 0 : y.dims) == null ? void 0 : T[1]
|
|
194
196
|
};
|
|
195
197
|
});
|
|
@@ -198,12 +200,12 @@ async function de(e, t) {
|
|
|
198
200
|
var i;
|
|
199
201
|
const c = await (await fetch(`https://tenor.googleapis.com/v2/search?key=${t}&q=${e}&limit=15`)).json();
|
|
200
202
|
return (i = c == null ? void 0 : c.results) == null ? void 0 : i.map((r) => {
|
|
201
|
-
var a, s, l, v, b,
|
|
203
|
+
var a, s, l, v, b, m, _, h;
|
|
202
204
|
return {
|
|
203
205
|
id: r == null ? void 0 : r.id,
|
|
204
206
|
src: (s = (a = r == null ? void 0 : r.media_formats) == null ? void 0 : a.gif) == null ? void 0 : s.url,
|
|
205
207
|
width: (b = (v = (l = r == null ? void 0 : r.media_formats) == null ? void 0 : l.gif) == null ? void 0 : v.dims) == null ? void 0 : b[0],
|
|
206
|
-
height: (h = (_ = (
|
|
208
|
+
height: (h = (_ = (m = r == null ? void 0 : r.media_formats) == null ? void 0 : m.gif) == null ? void 0 : _.dims) == null ? void 0 : h[1]
|
|
207
209
|
};
|
|
208
210
|
});
|
|
209
211
|
}
|
|
@@ -214,7 +216,7 @@ function le(e, t) {
|
|
|
214
216
|
};
|
|
215
217
|
}
|
|
216
218
|
function he({ selectImage: e, apiKey: t, provider: n, children: c }) {
|
|
217
|
-
const [i, r] = G(!1), [a, s] = G([]), { editorDisabled: l } = D(), v = U(null), { searchTrending: b, searchWord:
|
|
219
|
+
const [i, r] = G(!1), [a, s] = G([]), { editorDisabled: l } = D(), v = U(null), { searchTrending: b, searchWord: m } = le(n, t);
|
|
218
220
|
z(() => {
|
|
219
221
|
(async () => {
|
|
220
222
|
const h = await b();
|
|
@@ -228,13 +230,13 @@ function he({ selectImage: e, apiKey: t, provider: n, children: c }) {
|
|
|
228
230
|
s(T);
|
|
229
231
|
return;
|
|
230
232
|
}
|
|
231
|
-
const y = await
|
|
233
|
+
const y = await m(h.target.value);
|
|
232
234
|
s(y);
|
|
233
235
|
}, 350),
|
|
234
236
|
// Adjust the debounce delay as needed
|
|
235
237
|
[]
|
|
236
238
|
);
|
|
237
|
-
return /* @__PURE__ */
|
|
239
|
+
return /* @__PURE__ */ P(
|
|
238
240
|
te,
|
|
239
241
|
{
|
|
240
242
|
modal: !0,
|
|
@@ -256,7 +258,7 @@ function he({ selectImage: e, apiKey: t, provider: n, children: c }) {
|
|
|
256
258
|
className: "richtext-size-full richtext-p-2",
|
|
257
259
|
hideWhenDetached: !0,
|
|
258
260
|
side: "bottom",
|
|
259
|
-
children: t ? /* @__PURE__ */
|
|
261
|
+
children: t ? /* @__PURE__ */ P(Z, { children: [
|
|
260
262
|
/* @__PURE__ */ u("div", { className: "richtext-mb-[10px] richtext-w-full", children: /* @__PURE__ */ u(
|
|
261
263
|
ee,
|
|
262
264
|
{
|
|
@@ -285,7 +287,7 @@ function he({ selectImage: e, apiKey: t, provider: n, children: c }) {
|
|
|
285
287
|
}
|
|
286
288
|
);
|
|
287
289
|
}
|
|
288
|
-
function
|
|
290
|
+
function Ge() {
|
|
289
291
|
const e = ie(ue.name), {
|
|
290
292
|
action: t,
|
|
291
293
|
icon: n,
|
|
@@ -397,7 +399,7 @@ const ue = /* @__PURE__ */ Y.extend({
|
|
|
397
399
|
},
|
|
398
400
|
[
|
|
399
401
|
"img",
|
|
400
|
-
|
|
402
|
+
q(
|
|
401
403
|
// Always render the `height="auto"`
|
|
402
404
|
{
|
|
403
405
|
height: "auto"
|
|
@@ -428,5 +430,5 @@ const ue = /* @__PURE__ */ Y.extend({
|
|
|
428
430
|
});
|
|
429
431
|
export {
|
|
430
432
|
ue as ImageGif,
|
|
431
|
-
|
|
433
|
+
Ge as RichTextImageGif
|
|
432
434
|
};
|