reactjs-tiptap-editor 1.0.18 → 1.0.20
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-Df077oOH.cjs → ActionMenuButton-BPgqKDXT.cjs} +1 -1
- package/lib/{ActionMenuButton-BOjCHFTA.js → ActionMenuButton-CMXWxvWu.js} +1 -1
- package/lib/Attachment.cjs +1 -1
- package/lib/Attachment.js +23 -23
- package/lib/Blockquote.cjs +3 -3
- package/lib/Blockquote.js +33 -28
- package/lib/Bold.cjs +1 -1
- package/lib/Bold.js +16 -10
- package/lib/BulletList.cjs +1 -1
- package/lib/BulletList.js +2 -2
- package/lib/Callout.cjs +1 -1
- package/lib/Callout.js +21 -22
- package/lib/Clear.cjs +1 -1
- package/lib/Clear.js +2 -2
- package/lib/Code.cjs +1 -1
- package/lib/Code.js +2 -2
- package/lib/CodeBlock.cjs +20 -44
- package/lib/CodeBlock.js +1385 -4012
- package/lib/CodeView.cjs +1 -1
- package/lib/CodeView.js +2 -2
- package/lib/Color.cjs +1 -1
- package/lib/Color.js +3 -3
- package/lib/Column.cjs +1 -1
- package/lib/Column.js +2 -2
- package/lib/{Drawer-DwrlY_lY.cjs → Drawer-BivLAzMN.cjs} +1 -1
- package/lib/{Drawer-DxOoRiGQ.js → Drawer-BmVmgJsc.js} +3 -3
- package/lib/Drawer.cjs +1 -1
- package/lib/Drawer.js +4 -4
- package/lib/Emoji.cjs +1 -1
- package/lib/Emoji.js +12 -12
- package/lib/Excalidraw.cjs +1 -1
- package/lib/Excalidraw.js +17 -17
- package/lib/ExportPdf.cjs +1 -1
- package/lib/ExportPdf.js +2 -2
- package/lib/ExportWord.cjs +1 -1
- package/lib/ExportWord.js +2 -2
- package/lib/FontFamily.cjs +1 -1
- package/lib/FontFamily.js +4 -4
- package/lib/FontSize.cjs +1 -1
- package/lib/FontSize.js +4 -4
- package/lib/Heading.cjs +1 -1
- package/lib/Heading.js +9 -9
- package/lib/Highlight.cjs +1 -1
- package/lib/Highlight.js +3 -3
- package/lib/History.cjs +1 -1
- package/lib/History.js +5 -3
- package/lib/HorizontalRule.cjs +1 -1
- package/lib/HorizontalRule.js +2 -2
- package/lib/{Iframe-AhNV5WH5.js → Iframe-CAUrccA0.js} +7 -7
- package/lib/{Iframe-C6pBw-AF.cjs → Iframe-hwg9FxhU.cjs} +1 -1
- package/lib/Iframe.cjs +1 -1
- package/lib/Iframe.js +3 -3
- package/lib/Image.cjs +1 -1
- package/lib/Image.js +6 -5
- package/lib/ImageGif.cjs +1 -1
- package/lib/ImageGif.js +36 -36
- package/lib/ImportWord.cjs +1 -1
- package/lib/ImportWord.js +13 -13
- package/lib/{Indent-DZ5PcJA4.js → Indent-3MoIatX1.js} +2 -2
- package/lib/{Indent-Do-X0AsY.cjs → Indent-MuSU0kXz.cjs} +1 -1
- package/lib/Indent.cjs +1 -1
- package/lib/Indent.js +2 -2
- package/lib/Italic.cjs +1 -1
- package/lib/Italic.js +24 -18
- package/lib/Katex-BPQ7_A3w.cjs +4 -0
- package/lib/{Katex-bIgoenn_.js → Katex-xS-XZKQc.js} +398 -421
- package/lib/Katex.cjs +1 -1
- package/lib/Katex.js +3 -3
- package/lib/LineHeight.cjs +1 -1
- package/lib/LineHeight.js +3 -3
- package/lib/Link.cjs +1 -1
- package/lib/Link.js +2 -2
- package/lib/{LinkEditBlock-B0ZaACZO.cjs → LinkEditBlock-DLDY-8Ax.cjs} +1 -1
- package/lib/{LinkEditBlock-D_cF9fnc.js → LinkEditBlock-Dhvz7DCA.js} +26 -26
- package/lib/MarkdownPaste.cjs +1 -1
- package/lib/MarkdownPaste.js +1 -1
- package/lib/Mention.cjs +1 -1
- package/lib/Mention.js +4 -4
- package/lib/Mermaid.cjs +2 -2
- package/lib/Mermaid.js +41 -42
- package/lib/MoreMark.cjs +1 -1
- package/lib/MoreMark.js +5 -5
- package/lib/OrderedList.cjs +1 -1
- package/lib/OrderedList.js +2 -2
- package/lib/SearchAndReplace.cjs +1 -1
- package/lib/SearchAndReplace.js +8 -8
- package/lib/SlashCommand.cjs +1 -1
- package/lib/SlashCommand.js +6 -6
- package/lib/{SlashCommandNodeView-Ba03hlVZ.cjs → SlashCommandNodeView-CavaOSwo.cjs} +1 -1
- package/lib/{SlashCommandNodeView-cg0x3NRF.js → SlashCommandNodeView-RnDRm4Z1.js} +6 -6
- package/lib/Strike.cjs +1 -1
- package/lib/Strike.js +2 -2
- package/lib/{Table-KqLiT5wG.js → Table-DN4TuDz1.js} +35 -35
- package/lib/{Table-ddU2LSc6.cjs → Table-m32ZhtxF.cjs} +1 -1
- package/lib/Table.cjs +1 -1
- package/lib/Table.js +1 -1
- package/lib/TaskList.cjs +1 -1
- package/lib/TaskList.js +2 -2
- package/lib/TextAlign.cjs +1 -1
- package/lib/TextAlign.js +3 -3
- package/lib/TextDirection.cjs +1 -1
- package/lib/TextDirection.js +3 -3
- package/lib/TextUnderline.cjs +1 -1
- package/lib/TextUnderline.js +2 -2
- package/lib/{Twitter-C1Lzqc7u.js → Twitter-B2FDarxE.js} +9 -9
- package/lib/{Twitter-BIiR78Jh.cjs → Twitter-CJhQLKYS.cjs} +1 -1
- package/lib/Twitter.cjs +1 -1
- package/lib/Twitter.js +3 -3
- package/lib/Video.cjs +1 -1
- package/lib/Video.js +4 -4
- package/lib/_commonjsHelpers-B4e78b8K.js +28 -0
- package/lib/_commonjsHelpers-BTDuMlIz.cjs +1 -0
- package/lib/bubble.cjs +6 -6
- package/lib/bubble.js +2136 -1822
- package/lib/{clsx-eGVyq7ot.js → clsx-Bg-2aTKh.js} +11 -11
- package/lib/{clsx-BWE7vnna.cjs → clsx-DSAWW32g.cjs} +1 -1
- package/lib/components/Bubble/RichTextBubbleCodeBlock.d.ts +1 -0
- package/lib/components/Bubble/index.d.ts +1 -0
- package/lib/{dropdown-menu-oSKIntXM.cjs → dropdown-menu-C0VlKIZC.cjs} +1 -1
- package/lib/{dropdown-menu-CexIkt_V.js → dropdown-menu-CWd8VVRO.js} +1 -1
- package/lib/extensions/CodeBlock/CodeBlock.d.ts +3 -18
- package/lib/extensions/Image/Image.d.ts +1 -0
- package/lib/{index-DHUN85fV.js → index-B2a7NqnN.js} +1149 -1019
- package/lib/{index-D0lc95kr.cjs → index-C3dgmjIF.cjs} +1 -1
- package/lib/{index-zig3Dj7A.cjs → index-C4WLt4NA.cjs} +9 -7
- package/lib/{index-RIXs7STX.js → index-CbkpBnTX.js} +1 -1
- package/lib/{index-BnW6t8z6.js → index-CjLxMm5d.js} +1 -1
- package/lib/{index-mfGK4pFo.js → index-D0EmqTpe.js} +167 -153
- package/lib/{index-C6xmkxrQ.js → index-DXtVL0al.js} +140 -138
- package/lib/{index-CJ9pyCM4.cjs → index-DlxZt4_j.cjs} +1 -1
- package/lib/{index-D_8P0LE5.js → index-P5_MyY0i.js} +1 -1
- package/lib/{index-DUpSE1Gb.cjs → index-TcJ2UKnv.cjs} +1 -1
- package/lib/index-czmcFIW7.cjs +1 -0
- package/lib/index-fbGGohBT.cjs +12 -0
- package/lib/index.cjs +1 -1
- package/lib/index.js +12 -12
- package/lib/{popover-BYSZ3zBi.js → popover-BrSDMb_n.js} +1 -1
- package/lib/{popover-BcHDZqBt.cjs → popover-UUKfPWue.cjs} +1 -1
- package/lib/{renderNodeView-BrM5kUj_.js → renderNodeView-CbxCTni3.js} +2 -2
- package/lib/{renderNodeView-D1zydtli.cjs → renderNodeView-DFVrJy0l.cjs} +1 -1
- package/lib/{separator-BmixLrnJ.cjs → separator-LH5EzF0T.cjs} +1 -1
- package/lib/{separator-CFKVxAea.js → separator-fpWkZkoh.js} +14 -14
- package/lib/style.css +1 -1
- package/lib/{updatePosition-CBRjbQMH.js → updatePosition-BGD41Hbg.js} +2 -2
- package/lib/{updatePosition-CfmY5Trk.cjs → updatePosition-CQE1ct18.cjs} +1 -1
- package/package.json +4 -2
- package/lib/Katex-CIC9ygbL.cjs +0 -4
- package/lib/delete-node-CosiBes5.cjs +0 -1
- package/lib/delete-node-eQHsyyhR.js +0 -24
- package/lib/extensions/CodeBlock/components/NodeViewCodeBlock/NodeViewCodeBlock.d.ts +0 -1
- package/lib/index-BUTn2LY6.cjs +0 -1
- package/lib/index-BtxvYLJ1.cjs +0 -12
- package/lib/select-C5SHDLFj.js +0 -120
- package/lib/select-DHjzKkcu.cjs +0 -1
- package/lib/textarea-CasDcv3u.cjs +0 -1
- package/lib/textarea-DNLrJoRl.js +0 -20
package/lib/HorizontalRule.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index-C4WLt4NA.cjs"),l=require("@tiptap/pm/state"),p=require("./index-czmcFIW7.cjs"),m=require("react/jsx-runtime");require("react");require("./theme.cjs");var y=i.Node3.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",i.mergeAttributes(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,n)=>n.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:n})=>{if(!i.canInsertNode(n,n.schema.nodes[this.name]))return!1;const{selection:r}=n,{$to:s}=r,c=t();return i.isNodeSelection(r)?c.insertContentAt(s.pos,{type:this.name}):c.insertContent({type:this.name}),c.command(({state:a,tr:e,dispatch:h})=>{if(h){const{$to:o}=e.selection,u=o.end();if(o.nodeAfter)o.nodeAfter.isTextblock?e.setSelection(l.TextSelection.create(e.doc,o.pos+1)):o.nodeAfter.isBlock?e.setSelection(l.NodeSelection.create(e.doc,o.pos)):e.setSelection(l.TextSelection.create(e.doc,o.pos));else{const d=a.schema.nodes[this.options.nextNodeType]||o.parent.type.contentMatch.defaultType,T=d==null?void 0:d.create();T&&(e.insert(u,T),e.setSelection(l.TextSelection.create(e.doc,u+1)))}e.scrollIntoView()}return!0}).run()}}},addInputRules(){return[i.nodeInputRule({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});function A(){const t=p.useButtonProps(f.name),{icon:n=void 0,tooltip:r=void 0,shortcutKeys:s=void 0,tooltipOptions:c={},action:a=void 0,isActive:e=void 0}=(t==null?void 0:t.componentProps)??{},{dataState:h,disabled:o,update:u}=p.useToggleActive(e),d=()=>{o||a&&(a(),u())};return t?m.jsx(p.ActionButton,{action:d,dataState:h,disabled:o,icon:n,shortcutKeys:s,tooltip:r,tooltipOptions:c}):m.jsx(m.Fragment,{})}const f=y.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),button:({editor:n,t:r,extension:s})=>({component:p.ActionButton,componentProps:{action:()=>n.commands.setHorizontalRule(),disabled:!n.can().setHorizontalRule(),icon:"Minus",shortcutKeys:s.options.shortcutKeys??["mod","alt","S"],tooltip:r("editor.horizontalrule.tooltip")}})}},addKeyboardShortcuts(){return{"Mod-Alt-s":()=>this.editor.commands.setHorizontalRule()}},renderHTML(){return["div",i.mergeAttributes(this.options.HTMLAttributes,{"data-type":this.name}),["hr"]]}});exports.HorizontalRule=f;exports.RichTextHorizontalRule=A;
|
package/lib/HorizontalRule.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { N as T, n as A, k as y, l as H, m as h } from "./index-
|
|
1
|
+
import { N as T, n as A, k as y, l as H, m as h } from "./index-D0EmqTpe.js";
|
|
2
2
|
import { TextSelection as u, NodeSelection as R } from "@tiptap/pm/state";
|
|
3
|
-
import { u as M, d as v, A as f } from "./index-
|
|
3
|
+
import { u as M, d as v, A as f } from "./index-B2a7NqnN.js";
|
|
4
4
|
import { jsx as m, Fragment as z } from "react/jsx-runtime";
|
|
5
5
|
import "react";
|
|
6
6
|
import "./theme.js";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { N as v, n as x, m as k } from "./index-
|
|
2
|
-
import { N as y, c as S, a as I } from "./clsx-
|
|
1
|
+
import { N as v, n as x, m as k } from "./index-D0EmqTpe.js";
|
|
2
|
+
import { N as y, c as S, a as I } from "./clsx-Bg-2aTKh.js";
|
|
3
3
|
import { jsxs as f, jsx as d, Fragment as P } from "react/jsx-runtime";
|
|
4
4
|
import { Resizable as M } from "re-resizable";
|
|
5
5
|
import { useState as N, useCallback as R } from "react";
|
|
6
|
+
import { M as j, j as U, B as q, u as A, d as L, A as D } from "./index-B2a7NqnN.js";
|
|
6
7
|
import { g as l } from "./dom-dataset-CIEeltF6.js";
|
|
7
|
-
import { F as j, j as U, B as q, u as A, d as L, A as D } from "./index-DHUN85fV.js";
|
|
8
8
|
import "./theme.js";
|
|
9
9
|
const m = {
|
|
10
10
|
youtube: {
|
|
@@ -169,10 +169,10 @@ function X(e) {
|
|
|
169
169
|
function J(e, t) {
|
|
170
170
|
return t.src = `${t.matchedUrl}?background=white&banner=show&embedded=true`, t.validId = !0, t.originalLink = e, t;
|
|
171
171
|
}
|
|
172
|
-
function
|
|
172
|
+
function W(e, t) {
|
|
173
173
|
return t.src = `${t.matchedUrl}`, t.validId = !0, t.originalLink = e, t;
|
|
174
174
|
}
|
|
175
|
-
function
|
|
175
|
+
function F(e, t, i) {
|
|
176
176
|
if (e === "googlemaps")
|
|
177
177
|
return i.validLink = !0, i.matchedUrl = t, i;
|
|
178
178
|
const n = m[e].linkRule;
|
|
@@ -197,7 +197,7 @@ function Z(e) {
|
|
|
197
197
|
src: ""
|
|
198
198
|
};
|
|
199
199
|
const i = G(e);
|
|
200
|
-
if (t =
|
|
200
|
+
if (t = F(i, e, t), !t.validLink)
|
|
201
201
|
return t;
|
|
202
202
|
switch (i) {
|
|
203
203
|
case "youtube":
|
|
@@ -229,7 +229,7 @@ function Z(e) {
|
|
|
229
229
|
case "jinshuju":
|
|
230
230
|
return J(e, t);
|
|
231
231
|
case "iframe":
|
|
232
|
-
return
|
|
232
|
+
return W(e, t);
|
|
233
233
|
default:
|
|
234
234
|
return e;
|
|
235
235
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const h=require("./index-
|
|
1
|
+
"use strict";const h=require("./index-C4WLt4NA.cjs"),w=require("./clsx-DSAWW32g.cjs"),s=require("react/jsx-runtime"),S=require("re-resizable"),v=require("react"),u=require("./index-czmcFIW7.cjs"),f=require("./dom-dataset-BqoJhJXt.cjs");require("./theme.cjs");const m={youtube:{example:"https://www.youtube.com/watch?v=I4sMhHbHYXM",src:"https://www.youtube.com/embed/I4sMhHbHYXM",srcPrefix:"https://www.youtube.com/embed",linkRule:[/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\s/]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[&?]v=)|youtu\.be\/)([\w-]{11})/]},youku:{example:"https://v.youku.com/v_show/id_XNDM0NDM4MTcy.html?spm=a2h0c.8166622.PhoneSokuUgc_4.dtitle",src:"https://player.youku.com/embed/XNDM0NDM4MTcy",srcPrefix:"https://player.youku.com/embed",linkRule:[String.raw`v.youku.com\/v_show\/id_\w+\=*`],idRule:String.raw`id_\w+\=*`},bilibili:{example:"https://www.bilibili.com/video/BV1EJ411u7DN",src:"https://player.bilibili.com/player.html?bvid=BV1EJ411u7DN",srcPrefix:"https://player.bilibili.com/player.html?bvid",linkRule:[String.raw`www.bilibili.com\/video\/\w+`]},qqvideo:{example:"https://v.qq.com/x/cover/mzc0020006aw1mn/u0033nvzb5v.html",src:"https://v.qq.com/txp/iframe/player.html?vid=u0033nvzb5v",srcPrefix:"https://v.qq.com/txp/iframe/player.html?vid",linkRule:[String.raw`v.qq.com\/x\/cover\/\w+\/\w+`]},amap:{example:"https://ditu.amap.com/",src:"https://www.amap.com/place/B000A45467",srcPrefix:"",linkRule:[String.raw`\.amap\.com`]},baidu_map:{example:"https://j.map.baidu.com/15/fo",src:"https://j.map.baidu.com/15/fo",srcPrefix:"",linkRule:[String.raw`map\.baidu\.com`]},modao:{example:"https://free.modao.cc/app/2cd26580a6717a147454df7470e7ec464093cba3/embed/v2#screen=sk71k6d1dfxulzx",src:"https://free.modao.cc/app/6UkpAxcGE3nPz52GLqhnOZgC7MATBSy/embed/v2",srcPrefix:"",linkRule:[String.raw`https:\/\/\w+.modao.cc\/app\/\w+\/embed\/v2`],tips:"Modao > More > Share > Embed > COPY"},lanhu:{example:"https://lanhuapp.com/link/#/invite?sid=evP7L",src:"https://lanhuapp.com/url/evP7L",srcPrefix:"",linkRule:[String.raw`https:\/\/lanhuapp.com\/url\/\w+`],tips:"Lanhu > Project > Share > Copy Link"},figma:{example:"https://www.figma.com/file/aS9uSgPXoNpaPkzbjNcK8v/Demo?node-id=0%3A1",src:"https://www.figma.com/file/aS9uSgPXoNpaPkzbjNcK8v/Demo?node-id=0%3A1",srcPrefix:"https://www.figma.com/embed?embed_host=share&url",linkRule:[String.raw`https:\/\/www.figma.com\/file\/\w+`]},canva:{example:"https://www.canva.cn/design/DAD61-t29UI/view",src:"https://www.canva.cn/design/DAD61-t29UI/view",srcPrefix:"",linkRule:[String.raw`https:\/\/www.canva.cn\/design\/.+\/view`]},processon:{example:"https://www.processon.com/embed/5ea99d8607912948b0e6fe78",src:"https://www.processon.com/embed/5ea99d8607912948b0e6fe78",srcPrefix:"",linkRule:[String.raw`https:\/\/www.processon.com\/embed\/\w+`]},codepen:{example:"https://codepen.io/mekery/embed/YzyrKOJ",src:"https://codepen.io/mekery/embed/YzyrKOJ",srcPrefix:"",linkRule:[String.raw`https:\/\/codepen.io\/.+\/embed\/\w+`]},jinshuju:{example:"https://jinshuju.net/f/q9YvVf",src:"https://jinshuju.net/f/q9YvVf",srcPrefix:"",linkRule:[String.raw`https:\/\/jinshuju.net\/f\/\w+`]},iframe:{example:"https://v.youku.com/v_show/id_XNDM0NDM4MTcy.html",src:"https://player.youku.com/embed/XNDM0NDM4MTcy",srcPrefix:"",linkRule:[".+"]},googlemaps:{example:"https://goo.gl/maps/8Ys8b4K1ZJY2",src:"https://www.google.com/maps/embed?pb=https://goo.gl/maps/8Ys8b4K1ZJY2",srcPrefix:"",linkRule:[String.raw`https:\/\/goo.gl\/maps\/\w+`]}};function I(e){const t=m.youtube,i=e.matchedUrl;e.validLink=!0;const r=i.split("="),n=r.length;if(n>0){const c=r[n-1];e.src=`${t.srcPrefix}/${c}`,e.validId=!0}return e}function R(e){const t=m.youku,i=e.matchedUrl,r=t.idRule,n=new RegExp(r),c=i.match(n);if(c&&c.length>0){const o=c[0].slice(3);e.validId=!0,e.src=`${t.srcPrefix}/${o}`}else e.validId=!1;return e}function P(e){const t=m.bilibili,r=e.matchedUrl.split("/"),n=r.length;if(n>0){const c=r[n-1];e.src=`${t.srcPrefix}=${c}`,e.validId=!0}return e}function j(e){const t=m.qqvideo,r=e.matchedUrl.split("/"),n=r.length;if(n>0){const c=r[n-1];e.src=`${t.srcPrefix}=${c}`,e.validId=!0}return e}function M(e,t){return t.src=e,t.validId=!0,t}function N(e,t){return t.src=e,t.validId=!0,t}function q(e,t){return t.src=e,t.validId=!0,t.originalLink=e,t}function U(e){return e.src=e.matchedUrl,e.validId=!0,e.originalLink=e.src,e}function A(e){return e.src=e.matchedUrl,e.validId=!0,e.originalLink=e.src,e}function D(e){const t=m.figma;return e.src=`${t.srcPrefix}=${encodeURIComponent(e.matchedUrl)}`,e.validId=!0,e.originalLink=e.matchedUrl,e}function L(e,t){return t.src=`${t.matchedUrl}?embed`,t.validId=!0,t.originalLink=e,t}function _(e,t){return t.src=`${t.matchedUrl}`,t.validId=!0,t.originalLink=e,t}function $(e){return e.src=`${e.matchedUrl}`,e.validId=!0,e.originalLink=e.src,e}function T(e,t){return t.src=`${t.matchedUrl}?background=white&banner=show&embedded=true`,t.validId=!0,t.originalLink=e,t}function z(e,t){return t.src=`${t.matchedUrl}`,t.validId=!0,t.originalLink=e,t}function Y(e,t,i){if(e==="googlemaps")return i.validLink=!0,i.matchedUrl=t,i;const n=m[e].linkRule;for(const c of n){const o=new RegExp(c),a=t.match(o);if(a&&a.length>0)return i.validLink=!0,i.matchedUrl=e==="youtube"?a[1]:a[0],i}return i}function C(e){var i,r;let t="iframe";return((i=e.includes)!=null&&i.call(e,"youtube")||(r=e.includes)!=null&&r.call(e,"youtu.be"))&&(t="youtube"),e.includes("youku")&&(t="youku"),e.includes("bilibili")&&(t="bilibili"),e.includes("qq")&&(t="qqvideo"),e.includes("amap")&&(t="amap"),e.includes("map.baidu")&&(t="baidu_map"),(e.includes("google.com/maps")||e.includes("maps.app.goo.gl"))&&(t="googlemaps"),e.includes("modao")&&(t="modao"),e.includes("lanhuapp")&&(t="lanhu"),e.includes("figma")&&(t="figma"),e.includes("canva")&&(t="canva"),e.includes("processon")&&(t="processon"),e.includes("codepen")&&(t="codepen"),e.includes("jinshuju")&&(t="jinshuju"),e.includes("iframe")&&(t="iframe"),t}function k(e){let t={validLink:!1,validId:!1,matchedUrl:"",originalLink:e,src:""};const i=C(e);if(t=Y(i,e,t),!t.validLink)return t;switch(i){case"youtube":return I(t);case"youku":return R(t);case"bilibili":return P(t);case"qqvideo":return j(t);case"amap":return M(e,t);case"baidu_map":return N(e,t);case"googlemaps":return q(e,t);case"modao":return U(t);case"lanhu":return A(t);case"figma":return D(t);case"canva":return L(e,t);case"processon":return _(e,t);case"codepen":return $(t);case"jinshuju":return T(e,t);case"iframe":return z(e,t);default:return e}}const E="_wrap_5y04w_1",H="_innerWrap_5y04w_15",x={wrap:E,innerWrap:H};function B({editor:e,node:t,updateAttributes:i}){const r=u.useEditableEditor(),{src:n,width:c,height:o}=t.attrs,[a,p]=v.useState("");function l(){if(!a)return;const d=k(a);e.chain().updateAttributes(b.name,{src:(d==null?void 0:d.src)||a}).setNodeSelection(e.state.selection.from).focus().run()}const y=v.useCallback(d=>{i({width:d.width,height:d.height})},[i]);return s.jsxs(w.NodeViewWrapper,{children:[!n&&s.jsxs("div",{className:"richtext-mx-auto richtext-my-[12px] richtext-flex richtext-max-w-[600px] richtext-items-center richtext-justify-center richtext-gap-[10px] richtext-rounded-[12px] richtext-border richtext-border-solid richtext-border-border richtext-p-[10px]",children:[s.jsx(u.Input,{autoFocus:!0,className:"richtext-flex-1",onInput:d=>p(d.target.value),placeholder:"Enter link",type:"url",value:a}),s.jsx(u.Button,{className:"richtext-w-[60px]",onClick:l,children:"OK"})]}),n&&s.jsx(S.Resizable,{size:{width:Number.parseInt(c),height:Number.parseInt(o)},onResizeStop:(d,K,O,g)=>{y({width:Number.parseInt(c)+g.width,height:Number.parseInt(o)+g.height})},children:s.jsx("div",{className:w.clsx(x.wrap,"render-wrapper"),children:s.jsx("div",{className:x.innerWrap,style:{pointerEvents:r?"none":"auto"},children:s.jsx("iframe",{className:"richtext-my-[12px]",src:n})})})})]})}function V(){const e=u.useButtonProps(b.name),{icon:t=void 0,tooltip:i=void 0,shortcutKeys:r=void 0,tooltipOptions:n={},action:c=void 0,isActive:o=void 0}=(e==null?void 0:e.componentProps)??{},{editorDisabled:a,update:p}=u.useToggleActive(o),l=()=>{a||c&&(c(),p())};return e?s.jsx(u.ActionButton,{action:l,disabled:a,icon:t,shortcutKeys:r,tooltip:i,tooltipOptions:n}):s.jsx(s.Fragment,{})}const b=h.Node3.create({name:"iframe",content:"",marks:"",group:"block",selectable:!0,atom:!0,draggable:!0,addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:"iframe"},button:({editor:t,extension:i,t:r})=>({componentProps:{action:n=>t.commands.setIframe(n),upload:i.options.upload,icon:"Iframe",tooltip:r("editor.iframe.tooltip")}})}},addAttributes(){return{width:{default:600,parseHTML:f.getDatasetAttribute("width")},height:{default:300,parseHTML:f.getDatasetAttribute("height")},src:{default:null,parseHTML:f.getDatasetAttribute("src")},defaultShowPicker:{default:!1},frameborder:{default:0},allowfullscreen:{default:this.options.allowFullscreen,parseHTML:()=>this.options.allowFullscreen}}},parseHTML(){return[{tag:"iframe"}]},renderHTML({HTMLAttributes:e}){return["iframe",h.mergeAttributes(this.options.HTMLAttributes,e)]},addCommands(){return{setIframe:e=>({tr:t,commands:i,chain:r})=>{var c,o,a;if(((a=(o=(c=t.selection)==null?void 0:c.node)==null?void 0:o.type)==null?void 0:a.name)==this.name)return i.updateAttributes(this.name,e);const n=e||{url:""};return r().insertContent({type:this.name,attrs:n}).run()}}},addInputRules(){return[h.nodeInputRule({find:/^\$iframe\$$/,type:this.type,getAttributes:()=>({width:"100%"})})]},addNodeView(){return w.ReactNodeViewRenderer(B)}});exports.Iframe=b;exports.RichTextIframe=V;exports.getServiceSrc=k;
|
package/lib/Iframe.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./index-C4WLt4NA.cjs");require("./clsx-DSAWW32g.cjs");const e=require("./Iframe-hwg9FxhU.cjs");require("./dom-dataset-BqoJhJXt.cjs");exports.Iframe=e.Iframe;exports.RichTextIframe=e.RichTextIframe;
|
package/lib/Iframe.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./index-
|
|
2
|
-
import "./clsx-
|
|
3
|
-
import { I as e, R as i } from "./Iframe-
|
|
1
|
+
import "./index-D0EmqTpe.js";
|
|
2
|
+
import "./clsx-Bg-2aTKh.js";
|
|
3
|
+
import { I as e, R as i } from "./Iframe-CAUrccA0.js";
|
|
4
4
|
import "./dom-dataset-CIEeltF6.js";
|
|
5
5
|
export {
|
|
6
6
|
e as Iframe,
|
package/lib/Image.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./index-C4WLt4NA.cjs");const e=require("./index-czmcFIW7.cjs");require("./clsx-DSAWW32g.cjs");exports.DEFAULT_OPTIONS=e.DEFAULT_OPTIONS;exports.Image=e.Image;exports.RichTextImage=e.RichTextImage;
|
package/lib/Image.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import "./index-
|
|
2
|
-
import {
|
|
3
|
-
import "./clsx-
|
|
1
|
+
import "./index-D0EmqTpe.js";
|
|
2
|
+
import { a4 as r, y as t, a5 as i } from "./index-B2a7NqnN.js";
|
|
3
|
+
import "./clsx-Bg-2aTKh.js";
|
|
4
4
|
export {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
r as DEFAULT_OPTIONS,
|
|
6
|
+
t as Image,
|
|
7
|
+
i as RichTextImage
|
|
7
8
|
};
|
package/lib/ImageGif.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const H=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const H=require("./index-C4WLt4NA.cjs"),f=require("./index-czmcFIW7.cjs"),z=require("./clsx-DSAWW32g.cjs"),l=require("react/jsx-runtime"),u=require("react"),j=require("./index-BqL4vAWE.cjs");require("./theme.cjs");const L=require("./popover-UUKfPWue.cjs"),N={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function W(e){var P,k;const[t,r]=u.useState({width:j.IMAGE_MAX_SIZE,height:j.IMAGE_MAX_SIZE}),[o,i]=u.useState({width:0,height:0}),[n]=u.useState([N.TOP_LEFT,N.TOP_RIGHT,N.BOTTOM_LEFT,N.BOTTOM_RIGHT]),[s,a]=u.useState(!1),[h,b]=u.useState({x:0,y:0,w:0,h:0,dir:""}),{align:T}=(P=e==null?void 0:e.node)==null?void 0:P.attrs,m=u.useMemo(()=>{var x;const{src:c,alt:w,width:v,height:A}=(x=e==null?void 0:e.node)==null?void 0:x.attrs,G=f.isNumber(v)?`${v}px`:v,d=f.isNumber(A)?`${A}px`:A;return{src:c||void 0,alt:w||void 0,style:{width:G||void 0,height:d||void 0}}},[(k=e==null?void 0:e.node)==null?void 0:k.attrs]),_=u.useMemo(()=>{const{style:{width:c}}=m;return{width:c==="100%"?c:void 0}},[m]);function g(c){i({width:c.target.width,height:c.target.height})}function I(){const{editor:c,getPos:w}=e;c.commands.setNodeSelection(w())}const M=u.useCallback(f.throttle(()=>{const{editor:c}=e,{width:w}=getComputedStyle(c.view.dom);r(v=>({...v,width:Number.parseInt(w,10)}))},j.IMAGE_THROTTLE_WAIT_TIME),[e==null?void 0:e.editor]);function q(c,w){c.preventDefault(),c.stopPropagation();const v=o.width,A=o.height,G=v/A;let d=Number(e.node.attrs.width),x=Number(e.node.attrs.height);const y=t.width;d&&!x?(d=d>y?y:d,x=Math.round(d/G)):x&&!d?(d=Math.round(x*G),d=d>y?y:d):!d&&!x?(d=v>y?y:v,x=Math.round(d/G)):d=d>y?y:d,a(!0),b({x:c.clientX,y:c.clientY,w:d,h:x,dir:w})}const E=u.useCallback(f.throttle(c=>{if(c.preventDefault(),c.stopPropagation(),!s)return;const{x:w,w:v,dir:A}=h,G=(c.clientX-w)*(/l/.test(A)?-1:1),d=f.clamp$1(v+G,j.IMAGE_MIN_SIZE,t.width);e.updateAttributes({width:d,height:null})},j.IMAGE_THROTTLE_WAIT_TIME),[s,h,t,e.updateAttributes]),S=u.useCallback(c=>{c.preventDefault(),c.stopPropagation(),s&&(b({x:0,y:0,w:0,h:0,dir:""}),a(!1),I())},[s,I]),$=u.useCallback(()=>{document==null||document.addEventListener("mousemove",E,!0),document==null||document.addEventListener("mouseup",S,!0)},[E,S]),O=u.useCallback(()=>{document==null||document.removeEventListener("mousemove",E,!0),document==null||document.removeEventListener("mouseup",S,!0)},[E,S]);u.useEffect(()=>(s?$():O(),()=>{O()}),[s,$,O]);const R=u.useMemo(()=>new ResizeObserver(()=>M()),[M]);return u.useEffect(()=>(R.observe(e.editor.view.dom),()=>{R.disconnect()}),[e.editor.view.dom,R]),l.jsx(z.NodeViewWrapper,{className:"image-view",style:{..._,width:"100%",textAlign:T},children:l.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:_,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:I,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:n==null?void 0:n.map(c=>l.jsx("span",{className:`image-resizer__handler image-resizer__handler--${c}`,onMouseDown:w=>q(w,c)},`image-dir-${c}`))})]})})}async function p(e){var o;const r=await(await fetch(`https://api.giphy.com/v1/gifs/trending?q=&limit=15&api_key=${e}`)).json();return(o=r==null?void 0:r.data)==null?void 0:o.map(i=>{var n,s,a;return{id:i==null?void 0:i.id,src:(n=i==null?void 0:i.images.original)==null?void 0:n.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 D(e,t){var i;const o=await(await fetch(`https://api.giphy.com/v1/gifs/search?q=${e}&limit=15&api_key=${t}`)).json();return(i=o==null?void 0:o.data)==null?void 0:i.map(n=>{var s,a,h;return{id:n==null?void 0:n.id,src:(s=n==null?void 0:n.images.original)==null?void 0:s.url,width:+((a=n==null?void 0:n.images.original)==null?void 0:a.width),height:+((h=n==null?void 0:n.images.original)==null?void 0:h.width)}})}async function F(e){var n,s;const t=await fetch(`https://tenor.googleapis.com/v2/trending_terms?key=${e}&limit=10`),r=await(t==null?void 0:t.json()),i=await(await fetch(`https://tenor.googleapis.com/v2/search?key=${e}&q=${(n=r==null?void 0:r.results)==null?void 0:n[0]}&limit=15`)).json();return(s=i==null?void 0:i.results)==null?void 0:s.map(a=>{var h,b,T,m,_,g,I,M;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:(_=(m=(T=a==null?void 0:a.media_formats)==null?void 0:T.gif)==null?void 0:m.dims)==null?void 0:_[0],height:(M=(I=(g=a==null?void 0:a.media_formats)==null?void 0:g.gif)==null?void 0:I.dims)==null?void 0:M[1]}})}async function B(e,t){var i;const o=await(await fetch(`https://tenor.googleapis.com/v2/search?key=${t}&q=${e}&limit=15`)).json();return(i=o==null?void 0:o.results)==null?void 0:i.map(n=>{var s,a,h,b,T,m,_,g;return{id:n==null?void 0:n.id,src:(a=(s=n==null?void 0:n.media_formats)==null?void 0:s.gif)==null?void 0:a.url,width:(T=(b=(h=n==null?void 0:n.media_formats)==null?void 0:h.gif)==null?void 0:b.dims)==null?void 0:T[0],height:(g=(_=(m=n==null?void 0:n.media_formats)==null?void 0:m.gif)==null?void 0:_.dims)==null?void 0:g[1]}})}function V(e,t){return{searchTrending:async()=>t?e==="giphy"?p(t):e==="tenor"?F(t):[]:[],searchWord:async i=>t?e==="giphy"?D(i,t):e==="tenor"?B(i,t):[]:[]}}function X({selectImage:e,apiKey:t,provider:r,children:o}){const[i,n]=u.useState(!1),[s,a]=u.useState([]),{editorDisabled:h}=f.useToggleActive(),b=u.useRef(null),{searchTrending:T,searchWord:m}=V(r,t);u.useEffect(()=>{(async()=>{const g=await T();a(g)})()},[]);const _=u.useCallback(f.debounce(async g=>{if(!g.target.value){const M=await T();a(M);return}const I=await m(g.target.value);a(I)},350),[]);return l.jsxs(L.Popover,{modal:!0,onOpenChange:n,open:i,children:[l.jsx(L.PopoverTrigger,{asChild:!0,disabled:h,children:o}),l.jsx(L.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(f.Input,{onChange:_,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),n(!1)}},g.id)):l.jsx("p",{children:"No GIFs found"})})})]}):l.jsx("div",{children:l.jsx("p",{children:"Missing Giphy API Key"})})})]})}function Y(){const e=f.useButtonProps(C.name),{action:t,icon:r,tooltip:o,apiKey:i,provider:n}=(e==null?void 0:e.componentProps)??{},{editorDisabled:s}=f.useToggleActive(),a=h=>{s||t&&t(h)};return l.jsx(X,{apiKey:i,provider:n,selectImage:a,children:l.jsx(f.ActionButton,{disabled:s,icon:r,tooltip:o})})}const C=f.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:r,t:o})=>{var s,a;const i=((s=r==null?void 0:r.options)==null?void 0:s.provider)||"",n=((a=r==null?void 0:r.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:o("editor.imageGif.tooltip"),apiKey:n,provider:i}}}}},addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),width:{default:null,parseHTML:t=>{const r=t.style.width||t.getAttribute("width")||"10";return r===void 0?null:Number.parseInt(`${r}`,10)},renderHTML:t=>({width:t.width})},align:{default:"center",parseHTML:t=>t.getAttribute("align"),renderHTML:t=>({align:t.align})}}},addNodeView(){return z.ReactNodeViewRenderer(W)},addCommands(){var e;return{...(e=this.parent)==null?void 0:e.call(this),setImageGif:t=>({commands:r})=>r.insertContent({type:this.name,attrs:t}),updateImageGif:t=>({commands:r})=>r.updateAttributes(this.name,t),setAlignImageGif:t=>({commands:r})=>r.updateAttributes(this.name,{align:t})}},renderHTML({HTMLAttributes:e}){const{align:t}=e;return["div",{style:t?`text-align: ${t};`:"",class:"imageGIf"},["img",H.mergeAttributes({height:"auto"},this.options.HTMLAttributes,e)]]},parseHTML(){return[{tag:"div[class=imageGIf]",getAttrs:e=>{const t=e.querySelector("img"),r=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:r?Number.parseInt(r,10):null,align:(t==null?void 0:t.getAttribute("align"))||e.style.textAlign||null}}}]}});exports.ImageGif=C;exports.RichTextImageGif=Y;
|
package/lib/ImageGif.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { m as B } from "./index-
|
|
2
|
-
import {
|
|
3
|
-
import { N as U, a as
|
|
4
|
-
import { jsx as u, jsxs as
|
|
5
|
-
import { useState as G, useMemo as
|
|
1
|
+
import { m as B } from "./index-D0EmqTpe.js";
|
|
2
|
+
import { O as k, z as C, P as q, u as V, d as D, A as X, Q as Y, j as Z, H as Q } from "./index-B2a7NqnN.js";
|
|
3
|
+
import { N as U, a as J } from "./clsx-Bg-2aTKh.js";
|
|
4
|
+
import { jsx as u, jsxs as L, Fragment as K } from "react/jsx-runtime";
|
|
5
|
+
import { useState as G, useMemo as z, useCallback as M, useEffect as $, useRef as ee } from "react";
|
|
6
6
|
import { I as j, i as W, j as te } from "./index-BlXGgvT-.js";
|
|
7
7
|
import "./theme.js";
|
|
8
|
-
import { P as ne, a as re, b as ie } from "./popover-
|
|
8
|
+
import { P as ne, a as re, b as ie } from "./popover-BrSDMb_n.js";
|
|
9
9
|
const O = {
|
|
10
10
|
TOP_LEFT: "tl",
|
|
11
11
|
TOP_RIGHT: "tr",
|
|
@@ -31,7 +31,7 @@ function ae(e) {
|
|
|
31
31
|
w: 0,
|
|
32
32
|
h: 0,
|
|
33
33
|
dir: ""
|
|
34
|
-
}), { align: b } = (p = e == null ? void 0 : e.node) == null ? void 0 : p.attrs, g =
|
|
34
|
+
}), { align: b } = (p = e == null ? void 0 : e.node) == null ? void 0 : p.attrs, g = z(() => {
|
|
35
35
|
var w;
|
|
36
36
|
const { src: o, alt: m, width: f, height: x } = (w = e == null ? void 0 : e.node) == null ? void 0 : w.attrs, A = k(f) ? `${f}px` : f, d = k(x) ? `${x}px` : x;
|
|
37
37
|
return {
|
|
@@ -42,7 +42,7 @@ function ae(e) {
|
|
|
42
42
|
height: d || void 0
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
|
-
}, [(H = e == null ? void 0 : e.node) == null ? void 0 : H.attrs]),
|
|
45
|
+
}, [(H = e == null ? void 0 : e.node) == null ? void 0 : H.attrs]), _ = z(() => {
|
|
46
46
|
const {
|
|
47
47
|
style: { width: o }
|
|
48
48
|
} = g;
|
|
@@ -54,7 +54,7 @@ function ae(e) {
|
|
|
54
54
|
height: o.target.height
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
-
function
|
|
57
|
+
function y() {
|
|
58
58
|
const { editor: o, getPos: m } = e;
|
|
59
59
|
o.commands.setNodeSelection(m());
|
|
60
60
|
}
|
|
@@ -100,31 +100,31 @@ function ae(e) {
|
|
|
100
100
|
w: 0,
|
|
101
101
|
h: 0,
|
|
102
102
|
dir: ""
|
|
103
|
-
}), s(!1),
|
|
103
|
+
}), s(!1), y());
|
|
104
104
|
},
|
|
105
|
-
[a,
|
|
105
|
+
[a, y]
|
|
106
106
|
), R = M(() => {
|
|
107
107
|
document == null || document.addEventListener("mousemove", N, !0), document == null || document.addEventListener("mouseup", E, !0);
|
|
108
|
-
}, [N, E]),
|
|
108
|
+
}, [N, E]), P = M(() => {
|
|
109
109
|
document == null || document.removeEventListener("mousemove", N, !0), document == null || document.removeEventListener("mouseup", E, !0);
|
|
110
110
|
}, [N, E]);
|
|
111
|
-
$(() => (a ? R() :
|
|
112
|
-
|
|
113
|
-
}), [a, R,
|
|
114
|
-
const
|
|
115
|
-
return $(() => (
|
|
116
|
-
|
|
117
|
-
}), [e.editor.view.dom,
|
|
111
|
+
$(() => (a ? R() : P(), () => {
|
|
112
|
+
P();
|
|
113
|
+
}), [a, R, P]);
|
|
114
|
+
const S = z(() => new ResizeObserver(() => I()), [I]);
|
|
115
|
+
return $(() => (S.observe(e.editor.view.dom), () => {
|
|
116
|
+
S.disconnect();
|
|
117
|
+
}), [e.editor.view.dom, S]), /* @__PURE__ */ u(
|
|
118
118
|
U,
|
|
119
119
|
{
|
|
120
120
|
className: "image-view",
|
|
121
|
-
style: { ...
|
|
122
|
-
children: /* @__PURE__ */
|
|
121
|
+
style: { ..._, width: "100%", textAlign: b },
|
|
122
|
+
children: /* @__PURE__ */ L(
|
|
123
123
|
"div",
|
|
124
124
|
{
|
|
125
125
|
"data-drag-handle": !0,
|
|
126
126
|
draggable: "true",
|
|
127
|
-
style:
|
|
127
|
+
style: _,
|
|
128
128
|
className: `image-view__body ${e != null && e.selected ? "image-view__body--focused" : ""} ${a ? "image-view__body--resizing" : ""}`,
|
|
129
129
|
children: [
|
|
130
130
|
/* @__PURE__ */ u(
|
|
@@ -133,7 +133,7 @@ function ae(e) {
|
|
|
133
133
|
alt: g.alt,
|
|
134
134
|
className: "image-view__body__image block",
|
|
135
135
|
height: "auto",
|
|
136
|
-
onClick:
|
|
136
|
+
onClick: y,
|
|
137
137
|
onLoad: h,
|
|
138
138
|
src: g.src,
|
|
139
139
|
style: g.style
|
|
@@ -189,12 +189,12 @@ async function ce(e) {
|
|
|
189
189
|
`https://tenor.googleapis.com/v2/search?key=${e}&q=${(n = r == null ? void 0 : r.results) == null ? void 0 : n[0]}&limit=15`
|
|
190
190
|
)).json();
|
|
191
191
|
return (a = i == null ? void 0 : i.results) == null ? void 0 : a.map((s) => {
|
|
192
|
-
var l, v, b, g,
|
|
192
|
+
var l, v, b, g, _, h, y, I;
|
|
193
193
|
return {
|
|
194
194
|
id: s == null ? void 0 : s.id,
|
|
195
195
|
src: (v = (l = s == null ? void 0 : s.media_formats) == null ? void 0 : l.gif) == null ? void 0 : v.url,
|
|
196
|
-
width: (
|
|
197
|
-
height: (I = (
|
|
196
|
+
width: (_ = (g = (b = s == null ? void 0 : s.media_formats) == null ? void 0 : b.gif) == null ? void 0 : g.dims) == null ? void 0 : _[0],
|
|
197
|
+
height: (I = (y = (h = s == null ? void 0 : s.media_formats) == null ? void 0 : h.gif) == null ? void 0 : y.dims) == null ? void 0 : I[1]
|
|
198
198
|
};
|
|
199
199
|
});
|
|
200
200
|
}
|
|
@@ -204,12 +204,12 @@ async function de(e, t) {
|
|
|
204
204
|
`https://tenor.googleapis.com/v2/search?key=${t}&q=${e}&limit=15`
|
|
205
205
|
)).json();
|
|
206
206
|
return (i = c == null ? void 0 : c.results) == null ? void 0 : i.map((n) => {
|
|
207
|
-
var a, s, l, v, b, g,
|
|
207
|
+
var a, s, l, v, b, g, _, h;
|
|
208
208
|
return {
|
|
209
209
|
id: n == null ? void 0 : n.id,
|
|
210
210
|
src: (s = (a = n == null ? void 0 : n.media_formats) == null ? void 0 : a.gif) == null ? void 0 : s.url,
|
|
211
211
|
width: (b = (v = (l = n == null ? void 0 : n.media_formats) == null ? void 0 : l.gif) == null ? void 0 : v.dims) == null ? void 0 : b[0],
|
|
212
|
-
height: (h = (
|
|
212
|
+
height: (h = (_ = (g = n == null ? void 0 : n.media_formats) == null ? void 0 : g.gif) == null ? void 0 : _.dims) == null ? void 0 : h[1]
|
|
213
213
|
};
|
|
214
214
|
});
|
|
215
215
|
}
|
|
@@ -227,20 +227,20 @@ function he({ selectImage: e, apiKey: t, provider: r, children: c }) {
|
|
|
227
227
|
s(h);
|
|
228
228
|
})();
|
|
229
229
|
}, []);
|
|
230
|
-
const
|
|
230
|
+
const _ = M(
|
|
231
231
|
Y(async (h) => {
|
|
232
232
|
if (!h.target.value) {
|
|
233
233
|
const I = await b();
|
|
234
234
|
s(I);
|
|
235
235
|
return;
|
|
236
236
|
}
|
|
237
|
-
const
|
|
238
|
-
s(
|
|
237
|
+
const y = await g(h.target.value);
|
|
238
|
+
s(y);
|
|
239
239
|
}, 350),
|
|
240
240
|
// Adjust the debounce delay as needed
|
|
241
241
|
[]
|
|
242
242
|
);
|
|
243
|
-
return /* @__PURE__ */
|
|
243
|
+
return /* @__PURE__ */ L(ne, { modal: !0, onOpenChange: n, open: i, children: [
|
|
244
244
|
/* @__PURE__ */ u(re, { asChild: !0, disabled: l, children: c }),
|
|
245
245
|
/* @__PURE__ */ u(
|
|
246
246
|
ie,
|
|
@@ -249,11 +249,11 @@ function he({ selectImage: e, apiKey: t, provider: r, children: c }) {
|
|
|
249
249
|
className: "richtext-size-full richtext-p-2",
|
|
250
250
|
hideWhenDetached: !0,
|
|
251
251
|
side: "bottom",
|
|
252
|
-
children: t ? /* @__PURE__ */
|
|
252
|
+
children: t ? /* @__PURE__ */ L(K, { children: [
|
|
253
253
|
/* @__PURE__ */ u("div", { className: "richtext-mb-[10px] richtext-w-full", children: /* @__PURE__ */ u(
|
|
254
254
|
Z,
|
|
255
255
|
{
|
|
256
|
-
onChange:
|
|
256
|
+
onChange: _,
|
|
257
257
|
placeholder: "Search GIF",
|
|
258
258
|
ref: v,
|
|
259
259
|
type: "text"
|
|
@@ -282,7 +282,7 @@ function Te() {
|
|
|
282
282
|
a || t && t(l);
|
|
283
283
|
}, children: /* @__PURE__ */ u(X, { disabled: a, icon: r, tooltip: c }) });
|
|
284
284
|
}
|
|
285
|
-
const ue = /* @__PURE__ */
|
|
285
|
+
const ue = /* @__PURE__ */ Q.extend({
|
|
286
286
|
name: "imageGif",
|
|
287
287
|
//@ts-expect-error
|
|
288
288
|
addOptions() {
|
|
@@ -341,7 +341,7 @@ const ue = /* @__PURE__ */ J.extend({
|
|
|
341
341
|
};
|
|
342
342
|
},
|
|
343
343
|
addNodeView() {
|
|
344
|
-
return
|
|
344
|
+
return J(ae);
|
|
345
345
|
},
|
|
346
346
|
addCommands() {
|
|
347
347
|
var e;
|
package/lib/ImportWord.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const M=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const M=require("./index-C4WLt4NA.cjs"),u=require("react/jsx-runtime"),H=require("mammoth"),A=require("react"),s=require("./index-czmcFIW7.cjs");require("./theme.cjs");const P=require("./index-BqL4vAWE.cjs");function N(o,t){const a=atob(o.split(",")[1]),l=Array.from({length:a.length});for(let i=0;i<a.length;i++)l[i]=a.charCodeAt(i);const m=new Uint8Array(l);return new Blob([m],{type:t})}function k(o,t){return new File([o],t,{type:o.type})}function z(){const o=s.useEditorInstance(),t=s.useButtonProps(y.name),{icon:a=void 0,tooltip:l=void 0,tooltipOptions:m={},isActive:i=void 0,mammothOptions:w,limit:j,convert:b}=(t==null?void 0:t.componentProps)??{},{editorDisabled:W}=s.useToggleActive(i),p=s.useExtension(y.name),{toast:q}=s.useToast(),{t:S}=P.useLocale(),[C,v]=A.useState(!1),x=A.useRef(null);function O(){var e;(e=x.current)==null||e.click()}function R(e){const n=e.target.files[0];if(n){if(n.size>j){q({variant:"destructive",title:S("editor.importWord.limitSize")});return}E(n)}}async function B(e){const c=new DOMParser().parseFromString(e,"text/html"),f=c.querySelectorAll("img");if(f.length===0)return c.body.innerHTML;if(s.hasExtension(o,s.Image.name)){const g=p==null?void 0:p.options;if(g&&typeof g.upload=="function"){const T=[];for(const h of f){const d=h.getAttribute("src"),r=N(d,"image/jpeg"),L=k(r,"image.jpeg");T.push(L)}const F=await g.upload(T);for(const[h,d]of f.entries()){d.setAttribute("src",F[h].src);const r=d.parentElement;(r==null?void 0:r.tagName)==="P"&&(r.insertAdjacentElement("beforebegin",d),!r.hasChildNodes()&&r.textContent===""&&r.remove())}return c.body.innerHTML}else return console.warn("Image Upload method found, skip image conversion"),c.body.innerHTML}else return console.error("Image extension not found, unable to convert image"),c.body.innerHTML}async function E(e){v(!0);try{if(b){const n=await b(e);I(n)}else{const n=await e.arrayBuffer(),{value:c}=await H.convertToHtml({arrayBuffer:n},w);I(c)}}finally{v(!1)}}async function I(e){const n=await B(e);o.chain().setContent(n,!0).run()}return t?u.jsxs(u.Fragment,{children:[u.jsx(s.ActionButton,{action:O,disabled:W,icon:a,loading:C,tooltip:l,tooltipOptions:m}),u.jsx("input",{accept:".docx",onChange:R,ref:x,type:"file",style:{display:"none"}})]}):u.jsx(u.Fragment,{})}const y=M.Extension.create({name:"importWord",addOptions(){var o;return{...(o=this.parent)==null?void 0:o.call(this),upload:void 0,convert:void 0,limit:1024*1024*10,button:({extension:t,t:a})=>{const{convert:l,limit:m,mammothOptions:i}=t.options;return{componentProps:{convert:l,limit:m,mammothOptions:i,icon:"Word",shortcutKeys:t.options.shortcutKeys??["alt","mod","S"],tooltip:a("editor.importWord.tooltip")}}}}}});exports.ImportWord=y;exports.RichTextImportWord=z;
|
package/lib/ImportWord.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { E as M } from "./index-
|
|
2
|
-
import { jsx as g, Fragment as
|
|
1
|
+
import { E as M } from "./index-D0EmqTpe.js";
|
|
2
|
+
import { jsx as g, Fragment as w, jsxs as P } from "react/jsx-runtime";
|
|
3
3
|
import R from "mammoth";
|
|
4
4
|
import { useState as N, useRef as k } from "react";
|
|
5
|
-
import { h as
|
|
5
|
+
import { h as z, u as D, d as K, v as U, w as q, A as G, x as J, y as Q } from "./index-B2a7NqnN.js";
|
|
6
6
|
import "./theme.js";
|
|
7
7
|
import { u as V } from "./index-BlXGgvT-.js";
|
|
8
8
|
function X(e, t) {
|
|
@@ -16,15 +16,15 @@ function Y(e, t) {
|
|
|
16
16
|
return new File([e], t, { type: e.type });
|
|
17
17
|
}
|
|
18
18
|
function it() {
|
|
19
|
-
const e =
|
|
19
|
+
const e = z(), t = D(I.name), {
|
|
20
20
|
icon: s = void 0,
|
|
21
21
|
tooltip: c = void 0,
|
|
22
22
|
tooltipOptions: l = {},
|
|
23
23
|
isActive: i = void 0,
|
|
24
|
-
mammothOptions:
|
|
25
|
-
limit:
|
|
24
|
+
mammothOptions: x,
|
|
25
|
+
limit: T,
|
|
26
26
|
convert: h
|
|
27
|
-
} = (t == null ? void 0 : t.componentProps) ?? {}, { editorDisabled: C } =
|
|
27
|
+
} = (t == null ? void 0 : t.componentProps) ?? {}, { editorDisabled: C } = K(i), u = U(I.name), { toast: E } = q(), { t: W } = V(), [B, y] = N(!1), b = k(null);
|
|
28
28
|
function L() {
|
|
29
29
|
var o;
|
|
30
30
|
(o = b.current) == null || o.click();
|
|
@@ -32,7 +32,7 @@ function it() {
|
|
|
32
32
|
function O(o) {
|
|
33
33
|
const n = o.target.files[0];
|
|
34
34
|
if (n) {
|
|
35
|
-
if (n.size >
|
|
35
|
+
if (n.size > T) {
|
|
36
36
|
E({
|
|
37
37
|
variant: "destructive",
|
|
38
38
|
title: W("editor.importWord.limitSize")
|
|
@@ -73,7 +73,7 @@ function it() {
|
|
|
73
73
|
const n = await h(o);
|
|
74
74
|
v(n);
|
|
75
75
|
} else {
|
|
76
|
-
const n = await o.arrayBuffer(), { value: a } = await R.convertToHtml({ arrayBuffer: n },
|
|
76
|
+
const n = await o.arrayBuffer(), { value: a } = await R.convertToHtml({ arrayBuffer: n }, x);
|
|
77
77
|
v(a);
|
|
78
78
|
}
|
|
79
79
|
} finally {
|
|
@@ -84,7 +84,7 @@ function it() {
|
|
|
84
84
|
const n = await S(o);
|
|
85
85
|
e.chain().setContent(n, !0).run();
|
|
86
86
|
}
|
|
87
|
-
return t ? /* @__PURE__ */ P(
|
|
87
|
+
return t ? /* @__PURE__ */ P(w, { children: [
|
|
88
88
|
/* @__PURE__ */ g(
|
|
89
89
|
G,
|
|
90
90
|
{
|
|
@@ -108,9 +108,9 @@ function it() {
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
)
|
|
111
|
-
] }) : /* @__PURE__ */ g(
|
|
111
|
+
] }) : /* @__PURE__ */ g(w, {});
|
|
112
112
|
}
|
|
113
|
-
const
|
|
113
|
+
const I = /* @__PURE__ */ M.create({
|
|
114
114
|
name: "importWord",
|
|
115
115
|
//@ts-expect-error
|
|
116
116
|
addOptions() {
|
|
@@ -140,6 +140,6 @@ const w = /* @__PURE__ */ M.create({
|
|
|
140
140
|
}
|
|
141
141
|
});
|
|
142
142
|
export {
|
|
143
|
-
|
|
143
|
+
I as ImportWord,
|
|
144
144
|
it as RichTextImportWord
|
|
145
145
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { o as y, E as x } from "./index-
|
|
1
|
+
import { o as y, E as x } from "./index-D0EmqTpe.js";
|
|
2
2
|
import { TextSelection as b, AllSelection as I } from "@tiptap/pm/state";
|
|
3
3
|
import { jsx as d, Fragment as m, jsxs as A } from "react/jsx-runtime";
|
|
4
|
-
import { u as T, d as K, A as p } from "./index-
|
|
4
|
+
import { u as T, d as K, A as p } from "./index-B2a7NqnN.js";
|
|
5
5
|
import "react";
|
|
6
6
|
import "./theme.js";
|
|
7
7
|
var a = /* @__PURE__ */ ((t) => (t[t.max = 7] = "max", t[t.min = 0] = "min", t[t.more = 1] = "more", t[t.less = -1] = "less", t))(a || {});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const p=require("./index-
|
|
1
|
+
"use strict";const p=require("./index-C4WLt4NA.cjs"),l=require("@tiptap/pm/state"),c=require("react/jsx-runtime"),u=require("./index-czmcFIW7.cjs");require("react");require("./theme.cjs");var a=(t=>(t[t.max=7]="max",t[t.min=0]="min",t[t.more=1]="more",t[t.less=-1]="less",t))(a||{});function b(t,e,n){return t<e?e:t>n?n:t}function T(t,e,n,o){const{doc:s,selection:i}=t;if(!s||!i||!(i instanceof l.TextSelection||i instanceof l.AllSelection))return t;const{from:r,to:d}=i;return s.nodesBetween(r,d,(m,x)=>{const I=m.type;return n.includes(I.name)?(t=h(t,x,e),!1):!p.isList(m.type.name,o.extensionManager.extensions)}),t}function h(t,e,n){if(!t.doc)return t;const o=t.doc.nodeAt(e);if(!o)return t;const r=b((o.attrs.indent||0)+n,0,7);if(r===o.attrs.indent)return t;const d={...o.attrs,indent:r};return t.setNodeMarkup(e,o.type,d,o.marks)}function f({delta:t,types:e}){return({state:n,dispatch:o,editor:s})=>{const{selection:i}=n;let{tr:r}=n;return r=r.setSelection(i),r=T(r,t,e,s),r.docChanged?(o&&o(r),!0):!1}}function A(){const t=u.useButtonProps(y.name),{indent:e,outdent:n}=(t==null?void 0:t.componentProps)??{},{editorDisabled:o}=u.useToggleActive(),s=()=>{o||e!=null&&e.action&&(e==null||e.action())},i=()=>{o||n!=null&&n.action&&(n==null||n.action())};return t?c.jsxs(c.Fragment,{children:[c.jsx(u.ActionButton,{action:s,disabled:o,icon:e==null?void 0:e.icon,shortcutKeys:e==null?void 0:e.shortcutKeys,tooltip:e==null?void 0:e.tooltip}),c.jsx(u.ActionButton,{action:i,disabled:o,icon:n==null?void 0:n.icon,shortcutKeys:n==null?void 0:n.shortcutKeys,tooltip:n==null?void 0:n.tooltip})]}):c.jsx(c.Fragment,{})}const y=p.Extension.create({name:"richtextIndentOutdent",addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),types:["paragraph","heading","blockquote"],minIndent:a.min,maxIndent:a.max,button({editor:e,t:n,extension:o}){var s,i;return{componentProps:{indent:{action:()=>{e.commands.indent()},shortcutKeys:((s=o.options.shortcutKeys)==null?void 0:s[0])??["Tab"],icon:"IndentIncrease",tooltip:n("editor.indent.tooltip")},outdent:{action:()=>{e.commands.outdent()},shortcutKeys:((i=o.options.shortcutKeys)==null?void 0:i[1])??["Shift","Tab"],icon:"IndentDecrease",tooltip:n("editor.outdent.tooltip")}}}}}},addGlobalAttributes(){return[{types:this.options.types,attributes:{indent:{default:0,parseHTML:t=>{const e=t.dataset.indent;return(e?Number.parseInt(e,10):0)||0},renderHTML:t=>t.indent?{"data-indent":t.indent}:{}}}}]},addCommands(){return{indent:()=>f({delta:a.more,types:this.options.types}),outdent:()=>f({delta:a.less,types:this.options.types})}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.indent(),"Shift-Tab":()=>this.editor.commands.outdent()}}});exports.Indent=y;exports.IndentProps=a;exports.RichTextIndent=A;exports.setNodeIndentMarkup=h;
|
package/lib/Indent.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./index-C4WLt4NA.cjs");const e=require("./Indent-MuSU0kXz.cjs");exports.Indent=e.Indent;exports.RichTextIndent=e.RichTextIndent;
|
package/lib/Indent.js
CHANGED
package/lib/Italic.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index-C4WLt4NA.cjs"),s=require("react/jsx-runtime"),a=require("./index-czmcFIW7.cjs");require("react");require("./theme.cjs");var y=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,I=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,h=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,k=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,v=r.Mark.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",r.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"<em>",close:"</em>"}},renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[r.markInputRule({find:y,type:this.type}),r.markInputRule({find:h,type:this.type})]},addPasteRules(){return[r.markPasteRule({find:I,type:this.type}),r.markPasteRule({find:k,type:this.type})]}}),f=v;function M(){const t=a.useButtonProps(u.name),{icon:e=void 0,tooltip:n=void 0,shortcutKeys:i=void 0,tooltipOptions:c={},action:o=void 0,isActive:d=void 0}=(t==null?void 0:t.componentProps)??{},{dataState:m,disabled:l,update:p}=a.useToggleActive(d),g=()=>{l||o&&(o(),p())};return t?s.jsx(a.ActionButton,{action:g,dataState:m,disabled:l,icon:e,shortcutKeys:i,tooltip:n,tooltipOptions:c}):s.jsx(s.Fragment,{})}const u=f.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),button({editor:e,t:n,extension:i}){return{componentProps:{action:()=>e.commands.toggleItalic(),isActive:()=>e.isActive("italic")||!1,disabled:!1,shortcutKeys:i.options.shortcutKeys??["mod","I"],icon:"Italic",tooltip:n("editor.italic.tooltip")}}}}}});exports.Italic=u;exports.RichTextItalic=M;
|