@remarkablejames/editor 0.0.1 → 0.0.2
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-B0EHT9CC.js → ActionMenuButton-Bmn3RME4.js} +10 -9
- package/lib/ActionMenuButton-C5P0Kzrb.cjs +1 -0
- package/lib/Attachment.cjs +2 -2
- package/lib/Attachment.js +33 -31
- package/lib/Blockquote.cjs +2 -2
- package/lib/Blockquote.js +12 -13
- package/lib/Bold.cjs +1 -1
- package/lib/Bold.js +10 -11
- package/lib/BulletList.cjs +1 -1
- package/lib/BulletList.js +8 -9
- package/lib/Callout.cjs +1 -1
- package/lib/Callout.js +45 -41
- package/lib/Clear.cjs +1 -1
- package/lib/Clear.js +14 -13
- package/lib/Code.cjs +1 -1
- package/lib/Code.js +5 -6
- package/lib/CodeBlock.cjs +1 -44
- package/lib/CodeBlock.js +183 -3858
- package/lib/CodeView.cjs +1 -1
- package/lib/CodeView.js +8 -9
- package/lib/Color.cjs +1 -1
- package/lib/Color.js +19 -18
- package/lib/Column.cjs +1 -1
- package/lib/Column.js +8 -9
- package/lib/{Drawer-BCWVN-4l.js → Drawer-DvGh9aXG.js} +52 -46
- package/lib/Drawer-gz9U5ArC.cjs +2 -0
- package/lib/Drawer.cjs +1 -1
- package/lib/Drawer.js +3 -3
- package/lib/Emoji.cjs +1 -1
- package/lib/Emoji.js +15 -14
- package/lib/Excalidraw.cjs +1 -1
- package/lib/Excalidraw.js +20 -16
- package/lib/ExportPdf.cjs +3 -3
- package/lib/ExportPdf.js +13 -14
- package/lib/ExportWord.cjs +1 -1
- package/lib/ExportWord.js +6 -6
- package/lib/FontFamily.cjs +1 -1
- package/lib/FontFamily.js +6 -7
- package/lib/FontSize.cjs +1 -1
- package/lib/FontSize.js +14 -15
- package/lib/Heading.cjs +1 -1
- package/lib/Heading.js +26 -26
- package/lib/Highlight.cjs +1 -1
- package/lib/Highlight.js +23 -22
- package/lib/History.cjs +1 -1
- package/lib/History.js +11 -11
- package/lib/HorizontalRule.cjs +1 -1
- package/lib/HorizontalRule.js +9 -10
- package/lib/Icon-CKM0tYbW.js +15 -0
- package/lib/Icon-CQyFgXeo.cjs +1 -0
- package/lib/{Iframe-BdgiWGml.js → Iframe-CnnvV6cK.js} +21 -19
- package/lib/Iframe-Ds6gG2YO.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 +5 -4
- package/lib/ImageCropper-BKhXlnXN.cjs +1 -0
- package/lib/ImageCropper-DUzu_9-6.js +896 -0
- package/lib/ImageGif.cjs +1 -1
- package/lib/ImageGif.js +94 -91
- package/lib/ImportWord.cjs +1 -1
- package/lib/ImportWord.js +26 -25
- package/lib/{Indent-BpMcZKok.js → Indent-Bsj8gKvT.js} +30 -31
- package/lib/Indent-D_7HOYYd.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 +11 -12
- package/lib/{Katex-B8_uprkO.js → Katex-CilGTz7u.js} +22 -19
- package/lib/Katex-lL3bHXJd.cjs +4 -0
- package/lib/Katex.cjs +1 -1
- package/lib/Katex.js +2 -2
- package/lib/LineHeight.cjs +1 -1
- package/lib/LineHeight.js +20 -19
- package/lib/Link.cjs +1 -1
- package/lib/Link.js +2 -2
- package/lib/{LinkEditBlock-BX0fXXpF.js → LinkEditBlock-BD_WvA3r.js} +24 -19
- package/lib/LinkEditBlock-D3HSHmsU.cjs +5 -0
- package/lib/Mention.js +3 -3
- package/lib/Mermaid-BfeLPzoS.cjs +2 -0
- package/lib/{Mermaid-D8bbIgAl.js → Mermaid-BrjU75Bs.js} +48 -45
- package/lib/Mermaid.cjs +1 -1
- package/lib/Mermaid.js +2 -2
- package/lib/MoreMark.cjs +1 -1
- package/lib/MoreMark.js +28 -26
- package/lib/OrderedList.cjs +1 -1
- package/lib/OrderedList.js +10 -11
- package/lib/SearchAndReplace.cjs +1 -1
- package/lib/SearchAndReplace.js +42 -37
- package/lib/SlashCommand.cjs +1 -1
- package/lib/SlashCommand.js +5 -5
- package/lib/{SlashCommandNodeView-BcmtKbEE.js → SlashCommandNodeView-COx5qZ2y.js} +41 -39
- package/lib/SlashCommandNodeView-DD-nlhM-.cjs +1 -0
- package/lib/Strike.cjs +1 -1
- package/lib/Strike.js +11 -12
- package/lib/{Table-DbxuP5xh.js → Table-BlM8yMhr.js} +46 -46
- package/lib/Table-C21AlUrh.cjs +5 -0
- package/lib/Table.cjs +1 -1
- package/lib/Table.js +1 -1
- package/lib/TaskList.cjs +1 -1
- package/lib/TaskList.js +11 -12
- package/lib/TextAlign.cjs +1 -1
- package/lib/TextAlign.js +27 -26
- package/lib/TextDirection.cjs +1 -1
- package/lib/TextDirection.js +19 -18
- package/lib/TextUnderline.cjs +1 -1
- package/lib/TextUnderline.js +8 -9
- package/lib/{Twitter-9I6BLNmg.js → Twitter-BP8sYXX7.js} +22 -18
- package/lib/Twitter-D46MnvPr.cjs +1 -0
- package/lib/Twitter.cjs +1 -1
- package/lib/Twitter.js +2 -2
- package/lib/Video-Bpd8W8l6.js +231 -0
- package/lib/Video-BwrHx6B1.cjs +1 -0
- package/lib/Video.cjs +1 -1
- package/lib/Video.js +5 -4
- package/lib/bubble.cjs +3 -3
- package/lib/bubble.js +171 -162
- package/lib/button-BmTP96NR.cjs +1 -0
- package/lib/button-CDIxPURh.js +35 -0
- package/lib/checkbox-7sfSdzy9.js +29 -0
- package/lib/checkbox-DyVlLWHv.cjs +1 -0
- package/lib/{clsx-CDyrfCnw.js → clsx-m_C5j3RU.js} +24 -24
- package/lib/dialog-B-jOQ5i3.cjs +1 -0
- package/lib/dialog-QWWUWOGP.js +95 -0
- package/lib/{dropdown-menu-Bs69ZBbO.js → dropdown-menu-C1hdPLCZ.js} +1 -1
- package/lib/{dropdown-menu-DjWlG2-J.cjs → dropdown-menu-CkHN04Mx.cjs} +1 -1
- package/lib/events.constant-Bh2uzJud.js +71 -0
- package/lib/events.constant-ELn21EzG.cjs +1 -0
- package/lib/extensions/CodeBlock/CodeBlock.d.ts +1 -1
- package/lib/file-BLas99n7.js +43 -0
- package/lib/file-i7e4nQY2.cjs +1 -0
- package/lib/{index-C-tDsIKJ.js → index-B3Ijnbxs.js} +1 -1
- package/lib/{index-C1WCZhyA.js → index-C1KQsOcg.js} +1 -1
- package/lib/{index-CsSfYR30.js → index-C8FjP66D.js} +1 -1
- package/lib/index-CAiZY1nx.js +2741 -0
- package/lib/index-DWSAk_9a.cjs +1 -0
- package/lib/{index-DjDf4BK8.js → index-s3l5RdyW.js} +1 -1
- package/lib/index.cjs +4 -4
- package/lib/index.js +392 -147
- package/lib/input-qvpuOf-3.js +21 -0
- package/lib/input-s0JD5kf2.cjs +1 -0
- package/lib/isNumber-BTYSVlKo.cjs +1 -0
- package/lib/isNumber-WaBzl_0s.js +15 -0
- package/lib/label-CFax-gzo.cjs +1 -0
- package/lib/label-DC37f2RQ.js +11 -0
- package/lib/{popover-D-hUKDYu.cjs → popover-B05Fd8lC.cjs} +1 -1
- package/lib/{popover-CPr9bHYn.js → popover-CsSXh7w6.js} +1 -1
- package/lib/{renderNodeView-BJSrgyGj.js → renderNodeView-C_hPIdEs.js} +2 -2
- package/lib/{select-C2KF4RNg.cjs → select-7ubC1NF0.cjs} +1 -1
- package/lib/{select-CuE_HaQJ.js → select-B3-5wTqn.js} +1 -1
- package/lib/{separator-CHzYNMVt.js → separator-CYCA8tSn.js} +13 -12
- package/lib/separator-ncbdw4oq.cjs +1 -0
- package/lib/style.css +1 -1
- package/lib/tabs-BeHxylKH.js +46 -0
- package/lib/tabs-DBqNpGAq.cjs +1 -0
- package/lib/{textarea-gEoNp9CA.js → textarea-1FhpmBkP.js} +1 -1
- package/lib/{textarea-DZj6EY-N.cjs → textarea-Bjhcpp76.cjs} +1 -1
- package/lib/throttle-CRNq0z-O.js +249 -0
- package/lib/throttle-gTTvqDTW.cjs +1 -0
- package/lib/toggle-DoJTBdvy.js +89 -0
- package/lib/toggle-oFwBZC4x.cjs +1 -0
- package/lib/{updatePosition-e90ZrFWW.js → updatePosition-DvfTZHcH.js} +2 -2
- package/lib/useButtonProps-BE10eHkG.js +165 -0
- package/lib/useButtonProps-CFu0GHzW.cjs +1 -0
- package/package.json +1 -1
- package/lib/ActionMenuButton-J1el_e6Z.cjs +0 -1
- package/lib/Drawer-BTouEroZ.cjs +0 -2
- package/lib/Iframe-BfBLILDA.cjs +0 -1
- package/lib/Indent-Dvqz_WEn.cjs +0 -1
- package/lib/Katex-BQyeCeQ0.cjs +0 -4
- package/lib/LinkEditBlock-CIshn_8F.cjs +0 -5
- package/lib/Mermaid-0GiGVxn0.cjs +0 -2
- package/lib/SlashCommandNodeView-rDJ7OjRd.cjs +0 -1
- package/lib/Table-BEhNBeuA.cjs +0 -5
- package/lib/Twitter-BuEBgpi9.cjs +0 -1
- package/lib/index-D9oM__YW.cjs +0 -1
- package/lib/index-lj3VWExo.js +0 -4883
- package/lib/separator-_gvUNba_.cjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const u=require("./clsx-CXbNJWDD.cjs"),s=require("react/jsx-runtime"),y=require("re-resizable"),g=require("react"),h=require("./dom-dataset-BqoJhJXt.cjs"),S=require("./toggle-oFwBZC4x.cjs"),f=require("./useButtonProps-CFu0GHzW.cjs"),I=require("./input-s0JD5kf2.cjs"),P=require("./button-BmTP96NR.cjs"),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 R(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 j(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 M(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 q(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 N(e,t){return t.src=e,t.validId=!0,t}function U(e,t){return t.src=e,t.validId=!0,t}function A(e,t){return t.src=e,t.validId=!0,t.originalLink=e,t}function D(e){return e.src=e.matchedUrl,e.validId=!0,e.originalLink=e.src,e}function L(e){return e.src=e.matchedUrl,e.validId=!0,e.originalLink=e.src,e}function _(e){const t=m.figma;return e.src=`${t.srcPrefix}=${encodeURIComponent(e.matchedUrl)}`,e.validId=!0,e.originalLink=e.matchedUrl,e}function $(e,t){return t.src=`${t.matchedUrl}?embed`,t.validId=!0,t.originalLink=e,t}function T(e,t){return t.src=`${t.matchedUrl}`,t.validId=!0,t.originalLink=e,t}function z(e){return e.src=`${e.matchedUrl}`,e.validId=!0,e.originalLink=e.src,e}function Y(e,t){return t.src=`${t.matchedUrl}?background=white&banner=show&embedded=true`,t.validId=!0,t.originalLink=e,t}function C(e,t){return t.src=`${t.matchedUrl}`,t.validId=!0,t.originalLink=e,t}function E(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 H(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 x(e){let t={validLink:!1,validId:!1,matchedUrl:"",originalLink:e,src:""};const i=H(e);if(t=E(i,e,t),!t.validLink)return t;switch(i){case"youtube":return R(t);case"youku":return j(t);case"bilibili":return M(t);case"qqvideo":return q(t);case"amap":return N(e,t);case"baidu_map":return U(e,t);case"googlemaps":return A(e,t);case"modao":return D(t);case"lanhu":return L(t);case"figma":return _(t);case"canva":return $(e,t);case"processon":return T(e,t);case"codepen":return z(t);case"jinshuju":return Y(e,t);case"iframe":return C(e,t);default:return e}}const B="_wrap_5y04w_1",V="_innerWrap_5y04w_15",v={wrap:B,innerWrap:V};function K({editor:e,node:t,updateAttributes:i}){const r=f.useEditableEditor(),{src:n,width:c,height:o}=t.attrs,[a,p]=g.useState("");function l(){if(!a)return;const d=x(a);e.chain().updateAttributes(w.name,{src:(d==null?void 0:d.src)||a}).setNodeSelection(e.state.selection.from).focus().run()}const k=g.useCallback(d=>{i({width:d.width,height:d.height})},[i]);return s.jsxs(u.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(I.Input,{autoFocus:!0,className:"richtext-flex-1",onInput:d=>p(d.target.value),placeholder:"Enter link",type:"url",value:a}),s.jsx(P.Button,{className:"richtext-w-[60px]",onClick:l,children:"OK"})]}),n&&s.jsx(y.Resizable,{size:{width:Number.parseInt(c),height:Number.parseInt(o)},onResizeStop:(d,X,J,b)=>{k({width:Number.parseInt(c)+b.width,height:Number.parseInt(o)+b.height})},children:s.jsx("div",{className:u.clsx(v.wrap,"render-wrapper"),children:s.jsx("div",{className:v.innerWrap,style:{pointerEvents:r?"none":"auto"},children:s.jsx("iframe",{className:"richtext-my-[12px]",src:n})})})})]})}function O(){const e=f.useButtonProps(w.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}=f.useToggleActive(o),l=()=>{a||c&&(c(),p())};return e?s.jsx(S.ActionButton,{action:l,disabled:a,icon:t,shortcutKeys:r,tooltip:i,tooltipOptions:n}):s.jsx(s.Fragment,{})}const w=u.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:h.getDatasetAttribute("width")},height:{default:300,parseHTML:h.getDatasetAttribute("height")},src:{default:null,parseHTML:h.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",u.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[u.nodeInputRule({find:/^\$iframe\$$/,type:this.type,getAttributes:()=>({width:"100%"})})]},addNodeView(){return u.ReactNodeViewRenderer(K)}});exports.Iframe=w;exports.RichTextIframe=O;exports.getServiceSrc=x;
|
package/lib/Iframe.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./clsx-CXbNJWDD.cjs");const e=require("./Iframe-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./clsx-CXbNJWDD.cjs");const e=require("./Iframe-Ds6gG2YO.cjs");require("./dom-dataset-BqoJhJXt.cjs");exports.Iframe=e.Iframe;exports.RichTextIframe=e.RichTextIframe;
|
package/lib/Iframe.js
CHANGED
package/lib/Image.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./clsx-CXbNJWDD.cjs");const e=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./clsx-CXbNJWDD.cjs");require("./throttle-gTTvqDTW.cjs");const e=require("./ImageCropper-BKhXlnXN.cjs");exports.Image=e.Image;exports.RichTextImage=e.RichTextImage;
|
package/lib/Image.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import "./clsx-
|
|
2
|
-
import
|
|
1
|
+
import "./clsx-m_C5j3RU.js";
|
|
2
|
+
import "./throttle-CRNq0z-O.js";
|
|
3
|
+
import { I as r, R as t } from "./ImageCropper-DUzu_9-6.js";
|
|
3
4
|
export {
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
r as Image,
|
|
6
|
+
t as RichTextImage
|
|
6
7
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const i=require("react/jsx-runtime"),c=require("react"),ue=require("react-image-crop"),H=require("./button-BmTP96NR.cjs"),O=require("./dialog-B-jOQ5i3.cjs"),J=require("./clsx-CXbNJWDD.cjs"),K=require("./throttle-gTTvqDTW.cjs"),k=require("./index-bVGIXhRg.cjs"),V=require("./isNumber-BTYSVlKo.cjs"),de=require("./toggle-oFwBZC4x.cjs"),q=require("./useButtonProps-CFu0GHzW.cjs"),ie=require("./file-i7e4nQY2.cjs"),X=require("./Icon-CQyFgXeo.cjs"),U=require("./tabs-DBqNpGAq.cjs"),ge=require("./checkbox-DyVlLWHv.cjs"),ae=require("./label-CFax-gzo.cjs"),re=require("./input-s0JD5kf2.cjs");function he(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const se=he(c),me=1,fe=1e6;let Z=0;function pe(){return Z=(Z+1)%Number.MAX_SAFE_INTEGER,Z.toString()}const Q=new Map;function le(e){if(Q.has(e))return;const t=setTimeout(()=>{Q.delete(e),P({type:"REMOVE_TOAST",toastId:e})},fe);Q.set(e,t)}function xe(e,t){switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,me)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(n=>n.id===t.toast.id?{...n,...t.toast}:n)};case"DISMISS_TOAST":{const{toastId:n}=t;return n?le(n):e.toasts.forEach(s=>{le(s.id)}),{...e,toasts:e.toasts.map(s=>s.id===n||n===void 0?{...s,open:!1}:s)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(n=>n.id!==t.toastId)}}}const $=[];let Y={toasts:[]};function P(e){Y=xe(Y,e),$.forEach(t=>{t(Y)})}function be({...e}){const t=pe(),n=d=>P({type:"UPDATE_TOAST",toast:{...d,id:t}}),s=()=>P({type:"DISMISS_TOAST",toastId:t});return P({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:d=>{d||s()}}}),{id:t,dismiss:s,update:n}}function ee(){const[e,t]=se.useState(Y);return se.useEffect(()=>($.push(t),()=>{const n=$.indexOf(t);n>-1&&$.splice(n,1)}),[e]),{...e,toast:be,dismiss:n=>P({type:"DISMISS_TOAST",toastId:n})}}const B={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function Ie(e){var p,L,N;const[t,n]=c.useState({width:k.IMAGE_MAX_SIZE,height:k.IMAGE_MAX_SIZE}),[s,d]=c.useState({width:0,height:0}),[h]=c.useState([B.TOP_LEFT,B.TOP_RIGHT,B.BOTTOM_LEFT,B.BOTTOM_RIGHT]),[f,y]=c.useState(!1),[m,b]=c.useState({x:0,y:0,w:0,h:0,dir:""}),{align:A,inline:S}=(p=e==null?void 0:e.node)==null?void 0:p.attrs,E=S&&(A==="left"||A==="right"),M=c.useMemo(()=>{var ne;const{src:o,alt:x,width:a,height:l,flipX:g,flipY:u}=(ne=e==null?void 0:e.node)==null?void 0:ne.attrs,I=V.isNumber(a)?`${a}px`:a,T=V.isNumber(l)?`${l}px`:l,W=[];g&&W.push("rotateX(180deg)"),u&&W.push("rotateY(180deg)");const ce=W.join(" ");return{src:o||void 0,alt:x||void 0,style:{width:I||void 0,height:T||void 0,transform:ce||"none",...E?{float:A}:{}}}},[(L=e==null?void 0:e.node)==null?void 0:L.attrs]),C=c.useMemo(()=>{const{style:{width:o}}=M;return{width:o==="100%"?o:void 0}},[M]);function R(o){d({width:o.target.width,height:o.target.height})}function _(){const{editor:o,getPos:x}=e;o.commands.setNodeSelection(x())}const w=c.useCallback(K.throttle(()=>{const{editor:o}=e,{width:x}=getComputedStyle(o.view.dom);n(a=>({...a,width:Number.parseInt(x,10)}))},k.IMAGE_THROTTLE_WAIT_TIME),[e==null?void 0:e.editor]);function j(o,x){o.preventDefault(),o.stopPropagation();const a=s.width,l=s.height,g=a/l;let u=Number(e.node.attrs.width),I=Number(e.node.attrs.height);const T=t.width;u&&!I?(u=u>T?T:u,I=Math.round(u/g)):I&&!u?(u=Math.round(I*g),u=u>T?T:u):!u&&!I?(u=a>T?T:a,I=Math.round(u/g)):u=u>T?T:u,y(!0),b({x:o.clientX,y:o.clientY,w:u,h:I,dir:x})}const v=c.useCallback(K.throttle(o=>{if(o.preventDefault(),o.stopPropagation(),!f)return;const{x,w:a,dir:l}=m,g=(o.clientX-x)*(/l/.test(l)?-1:1),u=V.clamp(a+g,k.IMAGE_MIN_SIZE,t.width);e.updateAttributes({width:u,height:null})},k.IMAGE_THROTTLE_WAIT_TIME),[f,m,t,e.updateAttributes]),r=c.useCallback(o=>{o.preventDefault(),o.stopPropagation(),f&&(b({x:0,y:0,w:0,h:0,dir:""}),y(!1),_())},[f,_]),F=c.useCallback(()=>{document==null||document.addEventListener("mousemove",v,!0),document==null||document.addEventListener("mouseup",r,!0)},[v,r]),D=c.useCallback(()=>{document==null||document.removeEventListener("mousemove",v,!0),document==null||document.removeEventListener("mouseup",r,!0)},[v,r]);c.useEffect(()=>(f?F():D(),()=>{D()}),[f,F,D]);const z=c.useMemo(()=>new ResizeObserver(()=>w()),[w]);return c.useEffect(()=>(z.observe(e.editor.view.dom),()=>{z.disconnect()}),[e.editor.view.dom,z]),i.jsx(J.NodeViewWrapper,{as:S?"span":"div",className:"image-view",style:{float:E?A:void 0,margin:E?A==="left"?"1em 1em 1em 0":"1em 0 1em 1em":void 0,display:S?"inline":"block",textAlign:E?void 0:A,width:((N=M.style)==null?void 0:N.width)??"auto",...E?{}:C},children:i.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:C,className:`image-view__body ${e!=null&&e.selected?"image-view__body--focused":""} ${f?"image-view__body--resizing":""}`,children:[i.jsx("img",{alt:M.alt,className:"image-view__body__image block",height:"auto",onClick:_,onLoad:R,src:M.src,style:M.style}),(e==null?void 0:e.editor.view.editable)&&((e==null?void 0:e.selected)||f)&&i.jsx("div",{className:"image-resizer",children:h==null?void 0:h.map(o=>i.jsx("span",{className:`image-resizer__handler image-resizer__handler--${o}`,onMouseDown:x=>j(x,o)},`image-dir-${o}`))})]})})}function Te(e,t){const n=e.type,s=e.name.toLowerCase(),d=s.split(".").pop();if(!d)return!1;const f=n||{heif:"image/heif",heic:"image/heic",dng:"image/x-adobe-dng",cr2:"image/x-canon-cr2",nef:"image/x-nikon-nef",arw:"image/x-sony-arw",raf:"image/x-fuji-raf",orf:"image/x-olympus-orf"}[d];return t.some(y=>{if(y.startsWith("."))return s.endsWith(y);if(y.endsWith("/*")){const m=y.split("/")[0];return f==null?void 0:f.startsWith(m+"/")}return f===y})}function te(e,t){const{acceptMimes:n,maxSize:s,t:d,toast:h}=t,f=[];return(Array.isArray(e)?e:Object.values(e)).forEach(m=>{if(!Te(m,n)){t.onError?t.onError({type:"type",message:d("editor.upload.fileTypeNotSupported",{fileName:m.name}),file:m}):h({variant:"destructive",title:d("editor.upload.fileTypeNotSupported",{fileName:m.name})});return}if(m.size>s){const b=(s/1024/1024).toFixed(2);t.onError?t.onError({type:"size",message:d("editor.upload.fileSizeTooBig",{fileName:m.name,size:b}),file:m}):h({variant:"destructive",title:d("editor.upload.fileSizeTooBig",{fileName:m.name,size:b})});return}f.push(m)}),f}function ye(){const{t:e}=k.useLocale(),{toast:t}=ee(),n=q.useEditorInstance(),s=q.useButtonProps(G.name),{icon:d,tooltip:h}=(s==null?void 0:s.componentProps)??{},{editorDisabled:f}=q.useToggleActive(),[y,m]=c.useState(!1),[b,A]=c.useState(!1),S=q.useExtension(G.name),[E,M]=c.useState(""),[C,R]=c.useState(""),_=c.useRef(null),w=(S==null?void 0:S.options.defaultInline)||!1,[j,v]=c.useState(w),r=c.useMemo(()=>S==null?void 0:S.options,[S]);async function F(p){var o;const L=(o=p==null?void 0:p.target)==null?void 0:o.files;if(!n||n.isDestroyed||L.length===0||b){p.target.value="";return}const N=te(L,{acceptMimes:r==null?void 0:r.acceptMimes,maxSize:r==null?void 0:r.maxSize,t:e,toast:t,onError:r.onError});if(N.length<=0){p.target.value="";return}A(!0);try{if(r!=null&&r.multiple){const x=N.map(async l=>{if(r.upload){const g=await r.upload(l);return{imageId:g.imageId,src:g.cdnUrl}}else return{imageId:void 0,src:URL.createObjectURL(l)}});(await Promise.all(x)).forEach(({imageId:l,src:g})=>{n.chain().focus().setImageInline({imageId:l,src:g,inline:j,alt:C}).run()})}else{const x=N[0];let a,l="";if(r.upload){const g=await r.upload(x);a=g.imageId,l=g.cdnUrl}else l=URL.createObjectURL(x);n.chain().focus().setImageInline({imageId:a,src:l,inline:j,alt:C}).run()}m(!1),R(""),v(w)}catch(x){console.error("Error uploading image",x),r.onError?r.onError({type:"upload",message:e("editor.upload.error")}):t({variant:"destructive",title:e("editor.upload.error")})}finally{A(!1),p.target.value=""}}function D(p){p.preventDefault(),p.stopPropagation(),n.chain().focus().setImageInline({src:E,inline:j,alt:C}).run(),m(!1),v(w),M(""),R("")}function z(p){var L;p.preventDefault(),(L=_.current)==null||L.click()}return s?i.jsxs(O.Dialog,{onOpenChange:m,open:y,children:[i.jsx(O.DialogTrigger,{asChild:!0,children:i.jsx(de.ActionButton,{disabled:f,icon:d,tooltip:h,action:()=>{f||m(!0)}})}),i.jsxs(O.DialogContent,{children:[i.jsx(O.DialogTitle,{children:e("editor.image.dialog.title")}),i.jsxs(U.Tabs,{activationMode:"manual",defaultValue:r.resourceImage==="both"||r.resourceImage==="upload"?"upload":"link",children:[r.resourceImage==="both"&&i.jsxs(U.TabsList,{className:"richtext-grid richtext-w-full richtext-grid-cols-2",children:[i.jsx(U.TabsTrigger,{value:"upload",children:e("editor.image.dialog.tab.upload")}),i.jsx(U.TabsTrigger,{value:"link",children:e("editor.image.dialog.tab.url")})]}),i.jsxs("div",{className:"richtext-my-[10px] richtext-flex richtext-items-center richtext-gap-[4px]",children:[i.jsx(ge.Checkbox,{checked:j,onCheckedChange:p=>{v(p)}}),i.jsx(ae.Label,{children:e("editor.link.dialog.inline")})]}),r.enableAlt&&i.jsxs("div",{className:"richtext-my-[10px]",children:[i.jsx(ae.Label,{className:"mb-[6px]",children:e("editor.imageUpload.alt")}),i.jsx(re.Input,{onChange:p=>R(p.target.value),required:!0,type:"text",value:C})]}),i.jsxs(U.TabsContent,{value:"upload",children:[i.jsxs("div",{className:"richtext-flex richtext-items-center richtext-gap-[10px]",children:[i.jsx(H.Button,{className:"richtext-mt-1 richtext-w-full",disabled:b,onClick:z,size:"sm",children:b?i.jsxs(i.Fragment,{children:[e("editor.imageUpload.uploading"),i.jsx(X.IconComponent,{className:"richtext-ml-1 richtext-animate-spin",name:"Loader"})]}):e("editor.image.dialog.tab.upload")}),i.jsx(oe,{alt:C,disabled:b,editor:n,imageInline:j,onClose:()=>{R("")}})]}),i.jsx("input",{accept:r.acceptMimes.join(",")||"image/*",multiple:r.multiple,onChange:F,ref:_,style:{display:"none"},type:"file"})]}),i.jsx(U.TabsContent,{value:"link",children:i.jsx("form",{onSubmit:D,children:i.jsxs("div",{className:"richtext-flex richtext-items-center richtext-gap-2",children:[i.jsx(re.Input,{autoFocus:!0,onChange:p=>M(p.target.value),placeholder:e("editor.image.dialog.placeholder"),required:!0,type:"url",value:E}),i.jsx(H.Button,{type:"submit",children:e("editor.image.dialog.button.apply")})]})})})]})]})]}):i.jsx(i.Fragment,{})}const Se={acceptMimes:["image/jpeg","image/gif","image/png","image/jpg"],maxSize:1024*1024*5,multiple:!0,resourceImage:"both",defaultInline:!1,enableAlt:!0},G=K.index_default.extend({group:"inline",inline:!0,defining:!0,draggable:!0,selectable:!0,addOptions(){var e;return{...Se,...(e=this.parent)==null?void 0:e.call(this),upload:()=>Promise.reject("Image Upload Function"),button:({editor:t,extension:n,t:s})=>{var d,h;return{componentProps:{action:()=>!0,upload:n.options.upload,disabled:!((h=(d=t.can()).setImage)!=null&&h.call(d,{})),icon:"ImageUp",tooltip:s("editor.image.tooltip")}}}}},addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),imageId:{default:null,parseHTML:t=>t.getAttribute("data-image-id"),renderHTML:t=>t.imageId?{"data-image-id":t.imageId}:{}},flipX:{default:!1},flipY:{default:!1},width:{default:null,parseHTML:t=>{const n=t.style.width||t.getAttribute("width")||null;return n?Number.parseInt(n,10):null},renderHTML:t=>({width:t.width})},align:{default:"center",parseHTML:t=>t.getAttribute("align"),renderHTML:t=>({align:t.align})},inline:{default:!1,parseHTML:t=>!!t.getAttribute("inline"),renderHTML:t=>({inline:t.inline})},alt:{default:"",parseHTML:t=>t.getAttribute("alt"),renderHTML:t=>({alt:t.alt})}}},addNodeView(){return J.ReactNodeViewRenderer(Ie)},addCommands(){var e;return{...(e=this.parent)==null?void 0:e.call(this),setImageInline:t=>({commands:n})=>n.insertContent({type:this.name,attrs:{...t,imageId:t.imageId??null,inline:t.inline??this.options.defaultInline}}),updateImage:t=>({commands:n})=>n.updateAttributes(this.name,t),setAlignImage:t=>({commands:n})=>n.updateAttributes(this.name,{align:t})}},renderHTML({HTMLAttributes:e}){const{flipX:t,flipY:n,align:s,inline:d}=e,h=d&&(s==="left"||s==="right"),f=t||n?`transform: rotateX(${t?"180":"0"}deg) rotateY(${n?"180":"0"}deg);`:"",y=h?"":`text-align: ${s};`,A=`${h?`float: ${s};`:""}${h?s==="left"?"margin: 1em 1em 1em 0;":"margin: 1em 0 1em 1em;":""}${f}`;return[d?"span":"div",{style:y,class:"image"},["img",J.mergeAttributes({height:"auto",style:A},this.options.HTMLAttributes,e)]]},parseHTML(){return[{tag:"span.image img",getAttrs:e=>{var h;const t=e==null?void 0:e.parentElement,n=e==null?void 0:e.getAttribute("width"),s=(e==null?void 0:e.getAttribute("flipx"))||!1,d=(e==null?void 0:e.getAttribute("flipy"))||!1;return{src:e==null?void 0:e.getAttribute("src"),alt:e==null?void 0:e.getAttribute("alt"),caption:e==null?void 0:e.getAttribute("caption"),width:n?Number.parseInt(n,10):null,align:(e==null?void 0:e.getAttribute("align"))||((h=t==null?void 0:t.style)==null?void 0:h.textAlign)||null,inline:(e==null?void 0:e.getAttribute("inline"))||!1,flipX:s==="true",flipY:d==="true"}}},{tag:"div[class=image]",getAttrs:e=>{const t=e.querySelector("img"),n=t==null?void 0:t.getAttribute("width"),s=(t==null?void 0:t.getAttribute("flipx"))||!1,d=(t==null?void 0:t.getAttribute("flipy"))||!1;return{src:t==null?void 0:t.getAttribute("src"),alt:t==null?void 0:t.getAttribute("alt"),caption:t==null?void 0:t.getAttribute("caption"),width:n?Number.parseInt(n,10):null,align:(t==null?void 0:t.getAttribute("align"))||e.style.textAlign||null,inline:(t==null?void 0:t.getAttribute("inline"))||!1,flipX:s==="true",flipY:d==="true"}}},{tag:'img[src]:not([src^="data:"])'}]}});function oe({editor:e,imageInline:t,onClose:n,disabled:s,alt:d}){var o,x;const{t:h}=k.useLocale(),{toast:f}=ee(),[y,m]=c.useState(!1),[b,A]=c.useState(!1),S=c.useRef(null),[E,M]=c.useState(),[C,R]=c.useState(""),_=c.useRef(null),[w,j]=c.useState({src:"",file:null}),v=q.useExtension(G.name),r=c.useMemo(()=>(v==null?void 0:v.options)??{},[v]);function F(a){if(S.current&&a.width&&a.height){const l=D(S.current,a);R(l)}}function D(a,l){const g=document.createElement("canvas"),u=a.naturalWidth/a.width,I=a.naturalHeight/a.height;g.width=l.width*u,g.height=l.height*I;const T=g.getContext("2d");return T&&(T.imageSmoothingEnabled=!1,T.drawImage(a,l.x*u,l.y*I,l.width*u,l.height*I,0,0,l.width*u,l.height*I)),g.toDataURL("image/png",1)}const z=c.useCallback(async()=>{var a;if(!b){A(!0);try{const l=ie.dataURLtoFile(C,((a=w==null?void 0:w.file)==null?void 0:a.name)||"image.png");let g="";r.upload?g=await r.upload(l):g=URL.createObjectURL(l),e.chain().focus().setImageInline({src:g,inline:t,alt:d}).run(),m(!1),j({src:"",file:null}),N(),n()}catch(l){console.error("Error cropping image",l)}finally{A(!1)}}},[C,e,t,b,n,(o=w==null?void 0:w.file)==null?void 0:o.name,r]);function p(a){var l;a.preventDefault(),(l=_.current)==null||l.click()}const L=async a=>{var T;const l=(T=a==null?void 0:a.target)==null?void 0:T.files;if(!e||e.isDestroyed||l.length===0){a.target.value="";return}const g=te(l,{acceptMimes:r==null?void 0:r.acceptMimes,maxSize:r==null?void 0:r.maxSize,t:h,toast:f,onError:r.onError});if(g.length<=0){a.target.value="";return}const u=g[0],I=await ie.readImageAsBase64(u);m(!0),j({src:I.src,file:u})},N=()=>{_.current&&(_.current.value="")};return i.jsxs(i.Fragment,{children:[i.jsx(H.Button,{className:"richtext-mt-1 richtext-w-full",disabled:s,onClick:p,size:"sm",children:h("editor.image.dialog.tab.uploadCrop")}),i.jsxs(O.Dialog,{open:y,onOpenChange:a=>{m(a),a||(j({src:"",file:null}),N())},children:[i.jsx(O.DialogTrigger,{}),i.jsxs(O.DialogContent,{children:[i.jsx(O.DialogTitle,{children:h("editor.image.dialog.tab.uploadCrop")}),i.jsx("div",{children:w.src&&i.jsx(ue,{className:"richtext-w-full",crop:E,onChange:a=>M(a),onComplete:a=>F(a),children:i.jsx("img",{alt:"Crop me",ref:S,src:w.src})})}),i.jsxs(O.DialogFooter,{children:[i.jsxs(H.Button,{disabled:b,onClick:()=>{m(!1),j({src:"",file:null}),N()},children:[h("editor.imageUpload.cancel"),i.jsx(X.IconComponent,{className:"richtext-ml-1",name:"Trash2"})]}),i.jsx(H.Button,{className:"richtext-w-fit",disabled:b||!E,onClick:z,children:b?i.jsxs(i.Fragment,{children:[h("editor.imageUpload.uploading"),i.jsx(X.IconComponent,{className:"richtext-ml-1 richtext-animate-spin",name:"Loader"})]}):i.jsxs(i.Fragment,{children:[h("editor.imageUpload.crop"),i.jsx(X.IconComponent,{className:"richtext-ml-1",name:"Crop"})]})})]})]})]}),i.jsx("input",{accept:((x=r==null?void 0:r.acceptMimes)==null?void 0:x.join(","))||"image/*",multiple:!1,onChange:L,ref:_,style:{display:"none"},type:"file"})]})}exports.Image=G;exports.ImageCropper=oe;exports.RichTextImage=ye;exports.useToast=ee;exports.validateFiles=te;
|