@solibo/solibo-ui 2.2.9 → 2.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/assets/index43.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
._field_1trki_3{min-width:0;width:100%}._editor_1trki_8{display:grid;grid-template-areas:"toolbar submit" "content content" "files files";grid-template-columns:minmax(0,1fr) auto;background-color:var(--colors-semantic-bg-surface);border:var(--scale-1) solid var(--colors-semantic-border-default);border-radius:var(--shape-border-radius-radius-md);box-shadow:var(--shape-box-shadow-xs-position-x) var(--shape-box-shadow-xs-position-y) var(--shape-box-shadow-xs-blur) var(--shape-box-shadow-xs-spread) var(--shape-box-shadow-xs-color)}._editor_1trki_8>[data-component=toolbar]{grid-area:toolbar}._editor_1trki_8:has(>._submit_1trki_26)>[data-component=toolbar]{border-top-right-radius:0}._editor_1trki_8 [role=textbox]{border-radius:inherit;box-sizing:border-box;line-height:1.25;max-height:var(--editor-max-height);min-height:var(--editor-min-height);overflow-y:auto;padding:var(--scale-8) var(--utils-tokens-unit)}._editor_1trki_8 img{max-width:100%}@media (width <= 370px){._editor_1trki_8 [data-component=toolbar]:first-of-type{justify-content:space-between}._editor_1trki_8 button:not(._image-resize-handle_1trki_50){padding-inline:calc(var(--scale-12) - var(--scale-1))!important}}._resizable_1trki_56 [role=textbox]{resize:vertical}._resized_1trki_60 [role=textbox]{max-height:none}._resize-handle_1trki_64{align-items:center;cursor:ns-resize;display:flex;height:var(--scale-12);justify-content:center;touch-action:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}._resize-handle_1trki_64:after{background:var(--colors-semantic-border-default);border-radius:var(--shape-border-radius-radius-md);content:"";height:var(--scale-2);width:var(--scale-32)}._resize-handle_1trki_64:focus-visible{outline:solid var(--scale-2) var(--colors-semantic-border-focus);outline-offset:var(--shape-outline-offset, calc(var(--scale-2) * -1))}._invalid_1trki_86{border-color:var(--colors-semantic-status-error-border)}._error_1trki_90{color:var(--colors-semantic-status-error-content);font-size:var(--typography-font-sizes-body-sm);margin-top:var(--scale-4)}._dragging_1trki_96{background-color:var(--colors-semantic-primary-primary-subtle)}._content_1trki_100{grid-area:content;border-radius:0 0 var(--shape-border-radius-radius-md) var(--shape-border-radius-radius-md);position:relative;transition:background-color var(--utils-tokens-transition-duration) var(--utils-tokens-transition-timing-function)}._content_1trki_100:has([role=textbox]:focus-visible){outline:solid var(--scale-2) var(--colors-semantic-border-focus);outline-offset:var(--shape-outline-offset, calc(var(--scale-2) * -1))}._has-files_1trki_112 ._content_1trki_100{border-radius:0}._files_1trki_116{grid-area:files;border-top:var(--scale-1) solid var(--colors-semantic-border-default);display:flex;flex-wrap:wrap;gap:var(--scale-8);padding:var(--scale-8) var(--utils-tokens-unit)}._placeholder_1trki_125{color:var(--colors-semantic-content-secondary);left:var(--utils-tokens-unit);pointer-events:none;position:absolute;top:var(--scale-8)}._fill_1trki_133{display:grid;flex:1;grid-template-rows:minmax(0,1fr) auto;height:100%;min-height:0}._fill-editor_1trki_141{display:grid;grid-template-rows:auto minmax(0,1fr) auto;height:100%;min-height:0}._fill-editor_1trki_141 ._content_1trki_100{min-height:0}._fill-editor_1trki_141 [role=textbox]{height:100%;max-height:none}._editor_1trki_8 [role=textbox]:focus-visible{outline:0}._meta_1trki_161{align-items:center;display:grid;flex-basis:100%;grid-template-columns:minmax(0,1fr) auto auto auto;opacity:0;transition:all var(--utils-tokens-transition-duration) var(--utils-tokens-transition-timing-function)}._meta_1trki_161._active_1trki_170{border-top:var(--scale-1) solid var(--colors-semantic-border-default);height:auto;opacity:1}._meta_1trki_161 input{border-radius:0;width:100%}._inline-image_1trki_182{display:inline-block;max-width:100%;position:relative;vertical-align:bottom}._inline-image_1trki_182 img{display:block;height:auto}._inline-image_1trki_182:focus-visible{outline:solid var(--scale-2) var(--colors-semantic-border-focus);outline-offset:var(--shape-outline-offset, calc(var(--scale-2) * -1))}._image-resize-handle_1trki_50{background:transparent;border:0;bottom:0;cursor:ew-resize;height:var(--scale-24);padding:0;position:absolute;right:0;touch-action:none;width:var(--scale-24)}._image-resize-handle_1trki_50:after{background:var(--colors-semantic-bg-surface);border:var(--scale-2) solid var(--colors-semantic-primary-primary);bottom:0;box-sizing:border-box;content:"";height:var(--scale-12);position:absolute;right:0;width:var(--scale-12)}._image-resize-handle_1trki_50:focus-visible{outline:solid var(--scale-2) var(--colors-semantic-border-focus);outline-offset:var(--shape-outline-offset, calc(var(--scale-2) * -1))}._submit_1trki_26{align-items:flex-start;background-color:var(--colors-semantic-bg-page);border-bottom:var(--scale-1) solid var(--colors-semantic-border-default);border-top-right-radius:var(--shape-border-radius-radius-md);display:flex;grid-area:submit}._submit_1trki_26>button{margin:var(--shape-outline-focus) var(--shape-spacing-2xs)}._bold_1trki_240{font-weight:700}._italic_1trki_244{font-style:italic}._underline_1trki_248{text-decoration:underline}._link_1trki_252{color:var(--colors-semantic-primary-primary);cursor:pointer;text-decoration:underline}._list_1trki_258,._paragraph_1trki_259{margin:var(--scale-8) 0}._paragraph_1trki_259:first-child{margin-top:0}._list_1trki_258{list-style-type:disc!important}._list_1trki_258 li{list-style:inherit;margin-bottom:var(--scale-8);margin-left:var(--scale-16)}@media (width < 480px){._submit_1trki_26>button>span:not([data-component=icon]){display:none}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";require('../../assets/index43.css');var De=Object.defineProperty;var Ie=(l,n,t)=>n in l?De(l,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[n]=t;var F=(l,n,t)=>Ie(l,typeof n!="symbol"?n+"":n,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),xe=require("@lexical/html"),E=require("@lexical/link"),$=require("@lexical/list"),Le=require("@lexical/react/LexicalAutoFocusPlugin"),ke=require("@lexical/react/LexicalAutoLinkPlugin"),ge=require("@lexical/react/LexicalComposerContext"),Ce=require("@lexical/react/LexicalContentEditable"),Se=require("@lexical/react/LexicalErrorBoundary"),Ne=require("@lexical/react/LexicalExtensionComposer"),Me=require("@lexical/react/LexicalHistoryPlugin"),je=require("@lexical/react/LexicalLinkPlugin"),we=require("@lexical/react/LexicalListPlugin"),Ae=require("@lexical/react/LexicalOnChangePlugin"),Ee=require("@lexical/react/LexicalRichTextPlugin"),re=require("classix"),a=require("lexical"),s=require("react"),me=require("sanitize-html"),k=require("../button/index.cjs"),$e=require("../file/index.cjs"),Te=require("@lexical/utils"),A=require("../icon/index.cjs"),be=require("../../index-7blZaPiA.cjs"),ye=require("../toolbar/index.cjs"),ve=a.createCommand();class se extends a.DecoratorNode{constructor(t,c,f,g,p,o,h){super(p);F(this,"__src");F(this,"__alt");F(this,"__width");F(this,"__height");F(this,"__soliboDocumentId");F(this,"__soliboDocumentSlot");this.__src=t,this.__alt=c,this.__width=f,this.__height=g,this.__soliboDocumentId=o,this.__soliboDocumentSlot=h}static getType(){return"image"}static clone(t){return new se(t.__src,t.__alt,t.__width,t.__height,t.__key,t.__soliboDocumentId,t.__soliboDocumentSlot)}static importJSON(t){return de({alt:t.alt,height:t.height,soliboDocumentId:t.soliboDocumentId,soliboDocumentSlot:t.soliboDocumentSlot,src:t.src,width:t.width})}exportJSON(){return{alt:this.__alt,height:this.__height,...this.__soliboDocumentId?{soliboDocumentId:this.__soliboDocumentId}:void 0,...this.__soliboDocumentSlot?{soliboDocumentSlot:this.__soliboDocumentSlot}:void 0,src:this.__src,type:"image",version:1,width:this.__width}}static importDOM(){return{img:t=>({conversion:c=>{if(!(c instanceof HTMLImageElement))return null;const f=c.getAttribute("src")??"";if(!f)return null;const g=c.getAttribute("width"),p=c.getAttribute("height");return{node:de({alt:c.getAttribute("alt")??"",height:p?Number(p):void 0,soliboDocumentId:c.getAttribute("data-solibo-document-id")??void 0,soliboDocumentSlot:c.getAttribute("data-solibo-document-slot")??void 0,src:f,width:g?Number(g):void 0})}},priority:0})}}exportDOM(){const t=document.createElement("img");return this.__soliboDocumentSlot||t.setAttribute("src",this.__src),this.__soliboDocumentId&&t.setAttribute("data-solibo-document-id",this.__soliboDocumentId),this.__soliboDocumentSlot&&t.setAttribute("data-solibo-document-slot",this.__soliboDocumentSlot),this.__alt&&t.setAttribute("alt",this.__alt),this.__width&&t.setAttribute("width",String(this.__width)),this.__height&&t.setAttribute("height",String(this.__height)),{element:t}}createDOM(){return document.createElement("span")}updateDOM(){return!1}isInline(){return!0}getSrc(){return this.__src}setSrc(t){const c=this.getWritable();return c.__src=t,c}setWidth(t){const c=this.getWritable();return c.__width=t,c.__height=void 0,c}decorate(t){return i.jsx("img",{alt:this.__alt,height:this.__height,"data-solibo-document-id":this.__soliboDocumentId,"data-solibo-document-slot":this.__soliboDocumentSlot,onClick:c=>{c.preventDefault(),t.dispatchCommand(ve,{key:this.getKey(),soliboDocumentSlot:this.__soliboDocumentSlot,src:this.__src,width:this.__width})},src:this.__src,width:this.__width})}}function de({alt:l="",height:n,soliboDocumentId:t,soliboDocumentSlot:c,src:f,width:g}){return a.$applyNodeReplacement(new se(f,l,g,n,void 0,t,c))}function he(l){return l instanceof se}const Oe=({createImages:l})=>{const[n]=ge.useLexicalComposerContext();return s.useEffect(()=>n.registerCommand(a.PASTE_COMMAND,t=>{var p;if(!("clipboardData"in t))return!1;const c=t,f=Array.from(((p=c.clipboardData)==null?void 0:p.items)??[]).flatMap(o=>{if(o.kind!=="file"||!o.type.startsWith("image/"))return[];const h=o.getAsFile();return h?[h]:[]});if(f.length===0)return!1;c.preventDefault();const g=l(f);return n.update(()=>{a.$insertNodes(g.map(o=>de(o)))}),!0},a.COMMAND_PRIORITY_HIGH),[l,n]),null},Re=/(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/,Pe=/((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/,Be=[l=>{const n=Re.exec(l);return n!=null&&n.length?{index:n.index,length:n[0].length,text:n[0],url:`mailto:${n[0]}`}:null},l=>{const n=Pe.exec(l);return n!=null&&n.length?{index:n.index,length:n[0].length,text:n[0],url:n[0].startsWith("http")?n[0]:`https://${n[0]}`}:null}];function _e(l){try{const n=new URL(l);return n.protocol==="http:"||n.protocol==="https:"}catch{return!1}}const qe="_field_1clme_3",Ue="_editor_1clme_8",ze="_submit_1clme_26",He="_resizable_1clme_56",Fe="_resized_1clme_60",Ke="_invalid_1clme_86",We="_error_1clme_90",Ge="_dragging_1clme_96",Ze="_content_1clme_100",Ye="_files_1clme_116",Ve="_placeholder_1clme_125",Xe="_fill_1clme_133",Je="_meta_1clme_161",Qe="_active_1clme_170",et="_bold_1clme_202",tt="_italic_1clme_206",it="_underline_1clme_210",nt="_link_1clme_214",rt="_list_1clme_220",st="_paragraph_1clme_221",_={field:qe,editor:Ue,submit:ze,resizable:He,resized:Fe,"resize-handle":"_resize-handle_1clme_64",invalid:Ke,error:We,dragging:Ge,content:Ze,"has-files":"_has-files_1clme_112",files:Ye,placeholder:Ve,fill:Xe,"fill-editor":"_fill-editor_1clme_141",meta:Je,active:Qe,"image-sizes":"_image-sizes_1clme_182",bold:et,italic:tt,underline:it,link:nt,list:rt,paragraph:st};function ot({editableRef:l}){const n=s.useRef(null),[t,c]=s.useState(0),[f,g]=s.useState(0);s.useEffect(()=>{const o=l.current;if(!o)return;const h=()=>{c(Math.round(o.getBoundingClientRect().height)),g(Math.round(parseFloat(getComputedStyle(o).minHeight)||0))};if(h(),typeof ResizeObserver>"u")return;const C=new ResizeObserver(h);return C.observe(o),()=>C.disconnect()},[l]);const p=o=>{const h=l.current;if(!h)return;const C=parseFloat(getComputedStyle(h).minHeight)||0;h.style.height=`${Math.max(C,o)}px`};return i.jsx("div",{"aria-label":"Resize editor","aria-orientation":"horizontal","aria-valuemin":f,"aria-valuenow":t,"aria-valuetext":`${t} pixels`,className:_["resize-handle"],role:"separator",tabIndex:0,onDoubleClick:()=>{var o;return(o=l.current)==null?void 0:o.style.removeProperty("height")},onKeyDown:o=>{const h=l.current;h&&(o.key==="Home"?(o.preventDefault(),h.style.removeProperty("height")):(o.key==="ArrowUp"||o.key==="ArrowDown")&&(o.preventDefault(),p(h.getBoundingClientRect().height+(o.key==="ArrowUp"?20:-20))))},onPointerDown:o=>{const h=l.current;o.button!==0||!h||(o.preventDefault(),o.currentTarget.focus({preventScroll:!0}),o.currentTarget.setPointerCapture(o.pointerId),n.current={pointerId:o.pointerId,y:o.clientY,height:h.getBoundingClientRect().height})},onPointerMove:o=>{!n.current||n.current.pointerId!==o.pointerId||p(n.current.height+n.current.y-o.clientY)},onPointerUp:o=>{!n.current||n.current.pointerId!==o.pointerId||(n.current=null,o.currentTarget.releasePointerCapture(o.pointerId))},onLostPointerCapture:()=>{n.current=null},onPointerCancel:()=>{n.current=null},"data-component":"editorresizehandle"})}const lt=[{label:"Small",width:320},{label:"Medium",width:640},{label:"Large",width:960},{label:"Original",width:void 0}],at=({onFilesSelected:l,onInlineImageRemove:n})=>{const[t]=ge.useLexicalComposerContext(),[c,f]=s.useState(!1),[g,p]=s.useState(!1),[o,h]=s.useState(!1),[C,J]=s.useState(!1),[z,j]=s.useState(!1),[Q,S]=s.useState(!1),[T,O]=s.useState(""),[b,K]=s.useState(null),[W,R]=s.useState(null),[oe,G]=s.useState(void 0),[P,v]=s.useState(""),le=_e(P.trim()),ee=s.useRef(null),ae=s.useRef(null),B=s.useRef(null),y=s.useRef(null),Z=s.useRef(!1),te=e=>e.preventDefault(),Y=s.useCallback(e=>{y.current=a.$isRangeSelection(e)?e.clone():null},[]),D=s.useCallback(e=>{t.update(()=>{y.current&&a.$setSelection(y.current),e()}),y.current=null},[t]),I=e=>{Z.current=!0,e.preventDefault()},q=()=>{if(Z.current){Z.current=!1;return}ne()},x=s.useCallback(()=>{p(!1),O(""),K(null),R(null),G(void 0)},[]),N=s.useCallback(()=>{j(!1),v("")},[]),ce=s.useCallback(e=>{p(!0),O((e==null?void 0:e.src)??""),K((e==null?void 0:e.key)??null),R((e==null?void 0:e.soliboDocumentSlot)??null),G(e==null?void 0:e.width),N(),e!=null&&e.soliboDocumentSlot||setTimeout(()=>{var d;return(d=ae.current)==null?void 0:d.focus()},0)},[N]),ue=s.useCallback(e=>{t.getEditorState().read(()=>{Y(a.$getSelection())}),j(!0),v(e),x(),setTimeout(()=>{var d;return(d=B.current)==null?void 0:d.focus()},0)},[x,t,Y]),ie=s.useCallback(()=>{const e=P.trim();_e(e)&&(D(()=>{t.dispatchCommand(E.TOGGLE_LINK_COMMAND,{url:e,target:"_blank"});const d=a.$getSelection();if(!a.$isRangeSelection(d))return;const w=d.getNodes().at(-1)??null,H=(w==null?void 0:w.getParent())??null,L=E.$isLinkNode(w)?w:E.$isLinkNode(H)?H:null;if(L){const U=L.getLastChild();if(a.$isTextNode(U)){const fe=U.getTextContent(),pe=fe.replace(/\s+$/,"");pe!==fe&&U.setTextContent(pe)}const X=L.getNextSibling();if(a.$isTextNode(X)&&/^\s/.test(X.getTextContent())){X.select(1,1);return}const M=a.$createTextNode(" ");L.insertAfter(M),M.selectEnd()}}),N())},[N,t,P,D]),ne=s.useCallback(()=>{const e=T.trim();if(!e){x();return}t.update(()=>{if(b){const d=a.$getNodeByKey(b);he(d)&&d.setSrc(e);return}a.$insertNodes([de({src:e})])}),x()},[x,t,b,T]),V=s.useCallback(()=>{if(!b){x();return}t.update(()=>{const e=a.$getNodeByKey(b);if(he(e)){const d=e.getParent();a.$isParagraphNode(d)&&d.getChildrenSize()===1?d.remove():e.remove(),W&&(n==null||n(W))}}),x()},[x,t,b,W,n]),r=s.useCallback(e=>{b&&(t.update(()=>{const d=a.$getNodeByKey(b);he(d)&&d.setWidth(e)}),G(e))},[t,b]),u=s.useCallback(()=>{D(()=>{t.dispatchCommand(E.TOGGLE_LINK_COMMAND,null)}),N()},[N,t,D]),m=s.useCallback(()=>{const e=a.$getSelection();if(!a.$isRangeSelection(e)){if(a.$isNodeSelection(e)){const H=e.getNodes(),L=H[0]??null,U=(L==null?void 0:L.getParent())??null;f(H.some(M=>a.$isTextNode(M)&&M.hasFormat("bold"))),h(H.some(M=>a.$isTextNode(M)&&M.hasFormat("italic"))),J(H.some(M=>a.$isTextNode(M)&&M.hasFormat("underline"))),S($.$isListNode(U)||$.$isListItemNode(U)||$.$isListNode(L)||$.$isListItemNode(L));const X=E.$isLinkNode(L)?L:E.$isLinkNode(U)?U:null;if(X){j(!0),v(X.getURL());return}j(!1),v(""),y.current=null;return}f(!1),h(!1),J(!1),S(!1),j(!1),v(""),y.current=null;return}const[d]=e.getNodes(),w=(d==null?void 0:d.getParent())??null;if(f(e.hasFormat("bold")),h(e.hasFormat("italic")),J(e.hasFormat("underline")),S($.$isListNode(w)||$.$isListItemNode(w)),E.$isLinkNode(w)){j(!0),v(w.getURL()),Y(e);return}j(!1),v(""),y.current=null},[Y]);return s.useEffect(()=>Te.mergeRegister(t.registerUpdateListener(({editorState:e})=>{e.read(()=>{m()})}),t.registerCommand(ve,e=>(ce(e),!0),a.COMMAND_PRIORITY_LOW),t.registerCommand(a.SELECTION_CHANGE_COMMAND,()=>(t.getEditorState().read(()=>{m()}),!1),a.COMMAND_PRIORITY_LOW)),[t,ce,m]),i.jsxs(ye.Toolbar,{variant:"editor","data-component":"editortoolbar",children:[i.jsx(k.Button,{"aria-label":"Bold","data-active":c,onClick:()=>{t.dispatchCommand(a.FORMAT_TEXT_COMMAND,"bold")},title:"Bold",variant:"tertiary",children:i.jsx(A.Icon,{name:"TextB"})}),i.jsx(k.Button,{"aria-label":"Italic","data-active":o,onClick:()=>{t.dispatchCommand(a.FORMAT_TEXT_COMMAND,"italic")},title:"Italic",variant:"tertiary",children:i.jsx(A.Icon,{name:"TextItalic"})}),i.jsx(k.Button,{"aria-label":"Underline","data-active":C,onClick:()=>{t.dispatchCommand(a.FORMAT_TEXT_COMMAND,"underline")},title:"Underline",variant:"tertiary",children:i.jsx(A.Icon,{name:"TextUnderline"})}),i.jsx(k.Button,{"aria-label":"List","data-active":Q,onClick:()=>{Q?t.dispatchCommand($.REMOVE_LIST_COMMAND,void 0):t.dispatchCommand($.INSERT_UNORDERED_LIST_COMMAND,void 0)},title:"List",variant:"tertiary",children:i.jsx(A.Icon,{name:"ListBullets"})}),i.jsx(k.Button,{"aria-label":"Link","data-active":z,onClick:()=>{z?ue(P):(t.dispatchCommand(E.TOGGLE_LINK_COMMAND,{url:"https://"}),ue("https://"))},title:"Link",variant:"tertiary",children:i.jsx(A.Icon,{name:"Link"})}),l&&i.jsxs(i.Fragment,{children:[i.jsx("input",{hidden:!0,multiple:!0,onChange:e=>{e.target.files&&l(e.target.files),e.target.value=""},ref:ee,type:"file"}),i.jsx(k.Button,{"aria-label":"Upload files",onClick:()=>{var e;return(e=ee.current)==null?void 0:e.click()},title:"Upload files",variant:"tertiary",children:i.jsx(A.Icon,{name:"Paperclip"})})]}),i.jsxs("div",{className:re(_.meta,z||g?_.active:""),children:[z&&i.jsxs(i.Fragment,{children:[i.jsx(be.Input,{"aria-invalid":!le,onBlur:()=>ie(),onChange:e=>v(e.target.value),onKeyDown:e=>{e.key==="Enter"&&(e.preventDefault(),ie())},ref:B,value:P}),i.jsx(k.Button,{"aria-label":"Apply link",disabled:!le,onClick:()=>{ie()},onMouseDown:te,variant:"tertiary",children:i.jsx(A.Icon,{name:"Check"})}),i.jsx(k.Button,{"aria-label":"Remove link",onClick:()=>u(),onMouseDown:te,variant:"tertiary",children:i.jsx(A.Icon,{name:"Trash",variant:"danger"})})]}),g&&i.jsxs(i.Fragment,{children:[!W&&i.jsxs(i.Fragment,{children:[i.jsx(be.Input,{className:re(_.active),onBlur:q,onChange:e=>O(e.target.value),onKeyDown:e=>{e.key==="Enter"&&(e.preventDefault(),Z.current=!0,ne())},ref:ae,value:T}),i.jsx(k.Button,{"aria-label":"Apply image",onClick:()=>ne(),onMouseDown:I,variant:"tertiary",children:i.jsx(A.Icon,{name:"Check"})})]}),i.jsx("div",{className:_["image-sizes"],children:lt.map(({label:e,width:d})=>i.jsx(k.Button,{"aria-label":`${e} image`,"data-active":oe===d,onClick:()=>r(d),onMouseDown:te,variant:"tertiary",children:e},e))}),i.jsx(k.Button,{"aria-label":"Remove image",onClick:()=>V(),onMouseDown:I,variant:"tertiary",children:i.jsx(A.Icon,{name:"Trash",variant:"danger"})})]})]})]})},ct=a.defineExtension({name:"solibo-editor",namespace:"Editor",nodes:[E.AutoLinkNode,E.LinkNode,$.ListNode,$.ListItemNode,se],onError(l){throw l},theme:{link:_.link,list:{ol:_.list,ul:_.list},paragraph:_.paragraph,text:{bold:_.bold,italic:_.italic,underline:_.underline}}});function ut({autofocus:l,content:n="",lastEmittedContentRef:t}){const[c]=ge.useLexicalComposerContext();return s.useEffect(()=>{t.current!==n&&c.update(()=>{const g=new DOMParser().parseFromString(n,"text/html"),p=xe.$generateNodesFromDOM(c,g),o=a.$getRoot();o.clear().select(),a.$insertNodes(p),l?o.selectEnd():a.$setSelection(null)})},[l,n,c,t]),null}const dt=({autofocus:l=!1,autolink:n=!1,content:t,disabled:c=!1,errorMessage:f,fill:g=!1,files:p,inline:o=!1,inlineImages:h,invalid:C=!1,isSubmitting:J=!1,maxRows:z=12,minRows:j=1,onChange:Q,onFilesChange:S,onInlineImagesChange:T,onSubmit:O,onUpload:b,placeholder:K,required:W=!1,resizable:R=!1,submitLabel:oe="Submit"})=>{const G=s.useId(),P=s.useRef(void 0),v=s.useRef(null),[le,ee]=s.useState(!1),[ae,B]=s.useState(!1),[y,Z]=s.useState([]),[te,Y]=s.useState([]),D=s.useRef(new Map),I=p??y,q=h??te;s.useEffect(()=>{const r=v.current;if(!r)return;if(!R||g){r.style.removeProperty("height"),ee(!1);return}const u=()=>ee(r.style.height!==""),m=new MutationObserver(u);return m.observe(r,{attributes:!0,attributeFilter:["style"]}),u(),()=>m.disconnect()},[g,R]);const x=r=>{p===void 0&&Z(r),S==null||S(r)},N=s.useCallback(r=>{h===void 0&&Y(r),T==null||T(r)},[h,T]),ce=s.useCallback(r=>{const u=r.map(m=>{const e=`pasted-${crypto.randomUUID()}`,d=URL.createObjectURL(m);return D.current.set(e,d),{image:{alt:m.name,soliboDocumentSlot:e,src:d},pending:{file:m,slot:e}}});return N([...q,...u.map(({pending:m})=>m)]),u.map(({image:m})=>m)},[q,N]),ue=s.useCallback(r=>{N(q.filter(m=>m.slot!==r));const u=D.current.get(r);u&&URL.revokeObjectURL(u),D.current.delete(r)},[q,N]);s.useEffect(()=>()=>{D.current.forEach(r=>URL.revokeObjectURL(r)),D.current.clear()},[]),s.useEffect(()=>{const r=new Set(q.map(u=>u.slot));D.current.forEach((u,m)=>{r.has(m)||(URL.revokeObjectURL(u),D.current.delete(m))})},[q]);const ie=r=>{if(typeof DataTransfer<"u"){const u=new DataTransfer;return r.forEach(m=>u.items.add(m)),u.files}return Object.assign([...r],{item:u=>r[u]??null})},ne=async()=>{try{I.length>0&&await(b==null?void 0:b(ie(I))),await(O==null?void 0:O()),I.length>0&&x([])}catch{return}},V=r=>{r.preventDefault(),r.stopPropagation()};return i.jsxs("div",{className:re(_.field,g&&_.fill),"data-max-rows":z,"data-min-rows":j,onDragEnter:r=>{V(r),B(!!S)},onDragOver:r=>{V(r),B(!!S)},onDragLeave:r=>{V(r),B(!1)},onDropCapture:r=>{var m;const u=(m=r.dataTransfer)==null?void 0:m.files;u!=null&&u.length&&(V(r),(S||b)&&x([...I,...Array.from(u)]),B(!1))},onDrop:r=>{r.preventDefault(),B(!1)},"data-component":"editor",children:[R==="top"&&!g&&i.jsx(ot,{editableRef:v}),i.jsx("div",{className:re(_.editor,g&&_["fill-editor"],R===!0&&!g&&_.resizable,R&&!g&&le&&_.resized,C&&_.invalid,I.length>0&&_["has-files"]),style:{"--editor-max-height":`calc(${z*1.25}em + (2 * var(--scale-8)))`,"--editor-min-height":`calc(${j*1.25}em + (2 * var(--scale-8)))`},children:i.jsxs(Ne.LexicalExtensionComposer,{contentEditable:null,extension:ct,children:[!o&&i.jsx(at,{onInlineImageRemove:ue,onFilesSelected:b||S?r=>{x([...I,...Array.from(r)])}:void 0}),i.jsx("div",{className:re(_.content,ae&&_.dragging),children:i.jsx(Ee.RichTextPlugin,{contentEditable:i.jsx(Ce.ContentEditable,{ref:v,"aria-placeholder":K??"",ariaErrorMessage:C&&f?G:void 0,ariaInvalid:C||void 0,ariaRequired:W||void 0,placeholder:()=>K?i.jsx("div",{className:_.placeholder,children:K}):null}),ErrorBoundary:Se.LexicalErrorBoundary})}),!o&&O&&i.jsx("div",{className:_.submit,children:i.jsx(k.Button,{"aria-label":oe,"data-cy":"toolbar-submit-button",disabled:c,icon:"PaperPlaneTilt",isLoading:J,onClick:()=>void ne(),variant:"primary",children:i.jsx("span",{children:oe})})}),I.length>0&&i.jsx("div",{"aria-label":"Files to upload",className:_.files,role:"region",children:I.map((r,u)=>i.jsx($e.File,{deleteAccessibleLabel:`Remove ${r.name} from upload queue`,name:r.name,onDelete:()=>x(I.filter((m,e)=>e!==u))},`${r.name}-${r.size}-${r.lastModified}-${u}`))}),l&&i.jsx(Le.AutoFocusPlugin,{}),n&&i.jsx(ke.AutoLinkPlugin,{matchers:Be}),i.jsx(Me.HistoryPlugin,{}),T&&i.jsx(Oe,{createImages:ce}),t!==void 0&&i.jsx(ut,{autofocus:l,content:t,lastEmittedContentRef:P}),i.jsx(je.LinkPlugin,{validateUrl:_e}),i.jsx(we.ListPlugin,{}),Q&&i.jsx(Ae.OnChangePlugin,{onChange:(r,u)=>{r.read(()=>{const m=xe.$generateHtmlFromNodes(u,null),e=me(m,{allowedAttributes:{...me.defaults.allowedAttributes,img:[...me.defaults.allowedAttributes.img??[],"data-solibo-document-id","data-solibo-document-slot"]},allowedTags:["a","b","br","i","img","li","ol","p","u","ul"]});P.current=e,Q(e)})}})]})}),C&&f&&i.jsx("div",{className:_.error,id:G,children:f})]})};exports.Editor=dt;
|
|
1
|
+
"use strict";require('../../assets/index43.css');var xt=Object.defineProperty;var kt=(l,r,e)=>r in l?xt(l,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[r]=e;var F=(l,r,e)=>kt(l,typeof r!="symbol"?r+"":r,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),ft=require("@lexical/html"),j=require("@lexical/link"),E=require("@lexical/list"),It=require("@lexical/react/LexicalAutoFocusPlugin"),Dt=require("@lexical/react/LexicalAutoLinkPlugin"),mt=require("@lexical/react/LexicalComposerContext"),Ct=require("@lexical/react/LexicalContentEditable"),Lt=require("@lexical/react/LexicalErrorBoundary"),vt=require("@lexical/react/LexicalExtensionComposer"),Nt=require("@lexical/react/LexicalHistoryPlugin"),wt=require("@lexical/react/LexicalLinkPlugin"),Mt=require("@lexical/react/LexicalListPlugin"),At=require("@lexical/react/LexicalOnChangePlugin"),St=require("@lexical/react/LexicalRichTextPlugin"),et=require("classix"),c=require("lexical"),s=require("react"),ut=require("sanitize-html"),A=require("../button/index.cjs"),yt=require("../file/index.cjs"),jt=require("@lexical/utils"),y=require("../icon/index.cjs"),_t=require("../../index-7blZaPiA.cjs"),Et=require("../toolbar/index.cjs"),Rt="_field_1trki_3",Tt="_editor_1trki_8",$t="_submit_1trki_26",Pt="_resizable_1trki_56",Ot="_resized_1trki_60",Bt="_invalid_1trki_86",qt="_error_1trki_90",Ut="_dragging_1trki_96",zt="_content_1trki_100",Ht="_files_1trki_116",Ft="_placeholder_1trki_125",Kt="_fill_1trki_133",Wt="_meta_1trki_161",Gt="_active_1trki_170",Xt="_bold_1trki_240",Yt="_italic_1trki_244",Zt="_underline_1trki_248",Vt="_link_1trki_252",Jt="_list_1trki_258",Qt="_paragraph_1trki_259",_={field:Rt,editor:Tt,submit:$t,"image-resize-handle":"_image-resize-handle_1trki_50",resizable:Pt,resized:Ot,"resize-handle":"_resize-handle_1trki_64",invalid:Bt,error:qt,dragging:Ut,content:zt,"has-files":"_has-files_1trki_112",files:Ht,placeholder:Ft,fill:Kt,"fill-editor":"_fill-editor_1trki_141",meta:Wt,active:Gt,"inline-image":"_inline-image_1trki_182",bold:Xt,italic:Yt,underline:Zt,link:Vt,list:Jt,paragraph:Qt};function te({alt:l="",editor:r,height:e,nodeKey:d,soliboDocumentId:f,soliboDocumentSlot:g,src:b,width:o}){const m=s.useRef(null),p=s.useRef(null),[P,N]=s.useState(),v=()=>{const n=r.getRootElement();if(!n)return 1/0;const u=getComputedStyle(n);return Math.max(1,n.clientWidth-(parseFloat(u.paddingLeft)||0)-(parseFloat(u.paddingRight)||0))},R=(n,u=v())=>Math.round(Math.min(u,Math.max(Math.min(32,u),n))),L=n=>{r.update(()=>{const u=c.$getNodeByKey(d);at(u)&&u.setWidth(n)}),N(void 0)};return i.jsxs("span",{className:_["inline-image"],contentEditable:!1,tabIndex:g?0:void 0,onKeyDown:n=>{!g||n.target!==n.currentTarget||!["Backspace","Delete"].includes(n.key)||(n.preventDefault(),n.stopPropagation(),r.update(()=>{const u=c.$getNodeByKey(d);if(!at(u))return;const k=u.getParent();c.$isParagraphNode(k)&&k.getChildrenSize()===1?k.remove():u.remove(),r.dispatchCommand(pt,g)}),r.focus())},"data-component":"editorimage",children:[i.jsx("img",{alt:l,"data-solibo-document-id":f,"data-solibo-document-slot":g,draggable:!1,height:P===void 0?e:void 0,ref:m,src:b,width:P??o,onClick:n=>{var u;n.preventDefault(),g&&((u=n.currentTarget.parentElement)==null||u.focus()),r.dispatchCommand(bt,{key:d,soliboDocumentSlot:g,src:b,width:o})}}),i.jsx("button",{type:"button","aria-label":`Resize image${l?`: ${l}`:""}`,title:"Drag to resize; use arrow keys to adjust width",className:_["image-resize-handle"],tabIndex:0,onClick:n=>{n.preventDefault(),n.stopPropagation()},onKeyDown:n=>{var k;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(n.key))return;n.preventDefault(),n.stopPropagation();const u=((k=m.current)==null?void 0:k.getBoundingClientRect().width)??o??32;L(R(u+(["ArrowRight","ArrowUp"].includes(n.key)?10:-10)))},onPointerDown:n=>{n.button!==0||!m.current||(n.preventDefault(),n.stopPropagation(),n.currentTarget.focus({preventScroll:!0}),n.currentTarget.setPointerCapture(n.pointerId),p.current={pointerId:n.pointerId,x:n.clientX,width:m.current.getBoundingClientRect().width,maximum:v()})},onPointerMove:n=>{const u=p.current;!u||u.pointerId!==n.pointerId||N(R(u.width+n.clientX-u.x,u.maximum))},onPointerUp:n=>{const u=p.current;!u||u.pointerId!==n.pointerId||(p.current=null,L(R(u.width+n.clientX-u.x,u.maximum)),n.currentTarget.releasePointerCapture(n.pointerId))},onPointerCancel:()=>{p.current=null,N(void 0)},onLostPointerCapture:()=>{p.current=null,N(void 0)}})]})}const pt=c.createCommand(),bt=c.createCommand();class rt extends c.DecoratorNode{constructor(e,d,f,g,b,o,m){super(b);F(this,"__src");F(this,"__alt");F(this,"__width");F(this,"__height");F(this,"__soliboDocumentId");F(this,"__soliboDocumentSlot");this.__src=e,this.__alt=d,this.__width=f,this.__height=g,this.__soliboDocumentId=o,this.__soliboDocumentSlot=m}static getType(){return"image"}static clone(e){return new rt(e.__src,e.__alt,e.__width,e.__height,e.__key,e.__soliboDocumentId,e.__soliboDocumentSlot)}static importJSON(e){return ot({alt:e.alt,height:e.height,soliboDocumentId:e.soliboDocumentId,soliboDocumentSlot:e.soliboDocumentSlot,src:e.src,width:e.width})}exportJSON(){return{alt:this.__alt,height:this.__height,...this.__soliboDocumentId?{soliboDocumentId:this.__soliboDocumentId}:void 0,...this.__soliboDocumentSlot?{soliboDocumentSlot:this.__soliboDocumentSlot}:void 0,src:this.__src,type:"image",version:1,width:this.__width}}static importDOM(){return{img:e=>({conversion:d=>{if(!(d instanceof HTMLImageElement))return null;const f=d.getAttribute("src")??"";if(!f)return null;const g=d.getAttribute("width"),b=d.getAttribute("height");return{node:ot({alt:d.getAttribute("alt")??"",height:b?Number(b):void 0,soliboDocumentId:d.getAttribute("data-solibo-document-id")??void 0,soliboDocumentSlot:d.getAttribute("data-solibo-document-slot")??void 0,src:f,width:g?Number(g):void 0})}},priority:0})}}exportDOM(){const e=document.createElement("img");return this.__soliboDocumentSlot||e.setAttribute("src",this.__src),this.__soliboDocumentId&&e.setAttribute("data-solibo-document-id",this.__soliboDocumentId),this.__soliboDocumentSlot&&e.setAttribute("data-solibo-document-slot",this.__soliboDocumentSlot),this.__alt&&e.setAttribute("alt",this.__alt),this.__width&&e.setAttribute("width",String(this.__width)),this.__height&&e.setAttribute("height",String(this.__height)),{element:e}}createDOM(){return document.createElement("span")}updateDOM(){return!1}isInline(){return!0}getSrc(){return this.__src}setSrc(e){const d=this.getWritable();return d.__src=e,d}setWidth(e){const d=this.getWritable();return d.__width=e,d.__height=void 0,d}decorate(e){return i.jsx(te,{alt:this.__alt,editor:e,height:this.__height,nodeKey:this.getKey(),soliboDocumentId:this.__soliboDocumentId,soliboDocumentSlot:this.__soliboDocumentSlot,src:this.__src,width:this.__width})}}function ot({alt:l="",height:r,soliboDocumentId:e,soliboDocumentSlot:d,src:f,width:g}){return c.$applyNodeReplacement(new rt(f,l,g,r,void 0,e,d))}function at(l){return l instanceof rt}const ee=({createImages:l,onRemove:r})=>{const[e]=mt.useLexicalComposerContext();return s.useEffect(()=>e.registerCommand(pt,d=>(r(d),!0),c.COMMAND_PRIORITY_HIGH),[e,r]),s.useEffect(()=>e.registerCommand(c.PASTE_COMMAND,d=>{var o;if(!("clipboardData"in d))return!1;const f=d,g=Array.from(((o=f.clipboardData)==null?void 0:o.items)??[]).flatMap(m=>{if(m.kind!=="file"||!m.type.startsWith("image/"))return[];const p=m.getAsFile();return p?[p]:[]});if(g.length===0)return!1;f.preventDefault();const b=l(g);return e.update(()=>{c.$insertNodes(b.map(m=>ot(m)))}),!0},c.COMMAND_PRIORITY_HIGH),[l,e]),null},re=/(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/,ie=/((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/,ne=[l=>{const r=re.exec(l);return r!=null&&r.length?{index:r.index,length:r[0].length,text:r[0],url:`mailto:${r[0]}`}:null},l=>{const r=ie.exec(l);return r!=null&&r.length?{index:r.index,length:r[0].length,text:r[0],url:r[0].startsWith("http")?r[0]:`https://${r[0]}`}:null}];function dt(l){try{const r=new URL(l);return r.protocol==="http:"||r.protocol==="https:"}catch{return!1}}function se({editableRef:l}){const r=s.useRef(null),[e,d]=s.useState(0),[f,g]=s.useState(0);s.useEffect(()=>{const o=l.current;if(!o)return;const m=()=>{d(Math.round(o.getBoundingClientRect().height)),g(Math.round(parseFloat(getComputedStyle(o).minHeight)||0))};if(m(),typeof ResizeObserver>"u")return;const p=new ResizeObserver(m);return p.observe(o),()=>p.disconnect()},[l]);const b=o=>{const m=l.current;if(!m)return;const p=parseFloat(getComputedStyle(m).minHeight)||0;m.style.height=`${Math.max(p,o)}px`};return i.jsx("div",{"aria-label":"Resize editor","aria-orientation":"horizontal","aria-valuemin":f,"aria-valuenow":e,"aria-valuetext":`${e} pixels`,className:_["resize-handle"],role:"separator",tabIndex:0,onDoubleClick:()=>{var o;return(o=l.current)==null?void 0:o.style.removeProperty("height")},onKeyDown:o=>{const m=l.current;m&&(o.key==="Home"?(o.preventDefault(),m.style.removeProperty("height")):(o.key==="ArrowUp"||o.key==="ArrowDown")&&(o.preventDefault(),b(m.getBoundingClientRect().height+(o.key==="ArrowUp"?20:-20))))},onPointerDown:o=>{const m=l.current;o.button!==0||!m||(o.preventDefault(),o.currentTarget.focus({preventScroll:!0}),o.currentTarget.setPointerCapture(o.pointerId),r.current={pointerId:o.pointerId,y:o.clientY,height:m.getBoundingClientRect().height})},onPointerMove:o=>{!r.current||r.current.pointerId!==o.pointerId||b(r.current.height+r.current.y-o.clientY)},onPointerUp:o=>{!r.current||r.current.pointerId!==o.pointerId||(r.current=null,o.currentTarget.releasePointerCapture(o.pointerId))},onLostPointerCapture:()=>{r.current=null},onPointerCancel:()=>{r.current=null},"data-component":"editorresizehandle"})}const oe=({onFilesSelected:l,onInlineImageRemove:r})=>{const[e]=mt.useLexicalComposerContext(),[d,f]=s.useState(!1),[g,b]=s.useState(!1),[o,m]=s.useState(!1),[p,P]=s.useState(!1),[N,v]=s.useState(!1),[R,L]=s.useState(!1),[n,u]=s.useState(""),[k,K]=s.useState(null),[W,O]=s.useState(null),[B,w]=s.useState(""),J=dt(B.trim()),G=s.useRef(null),it=s.useRef(null),Q=s.useRef(null),T=s.useRef(null),S=s.useRef(!1),nt=t=>t.preventDefault(),X=s.useCallback(t=>{T.current=c.$isRangeSelection(t)?t.clone():null},[]),Y=s.useCallback(t=>{e.update(()=>{T.current&&c.$setSelection(T.current),t()}),T.current=null},[e]),st=t=>{S.current=!0,t.preventDefault()},$=()=>{if(S.current){S.current=!1;return}Z()},x=s.useCallback(()=>{b(!1),u(""),K(null),O(null)},[]),D=s.useCallback(()=>{v(!1),w("")},[]),z=s.useCallback(t=>{b(!0),u((t==null?void 0:t.src)??""),K((t==null?void 0:t.key)??null),O((t==null?void 0:t.soliboDocumentSlot)??null),D(),t!=null&&t.soliboDocumentSlot||setTimeout(()=>{var a;return(a=it.current)==null?void 0:a.focus()},0)},[D]),H=s.useCallback(t=>{e.getEditorState().read(()=>{X(c.$getSelection())}),v(!0),w(t),x(),setTimeout(()=>{var a;return(a=Q.current)==null?void 0:a.focus()},0)},[x,e,X]),tt=s.useCallback(()=>{const t=B.trim();dt(t)&&(Y(()=>{e.dispatchCommand(j.TOGGLE_LINK_COMMAND,{url:t,target:"_blank"});const a=c.$getSelection();if(!c.$isRangeSelection(a))return;const h=a.getNodes().at(-1)??null,I=(h==null?void 0:h.getParent())??null,C=j.$isLinkNode(h)?h:j.$isLinkNode(I)?I:null;if(C){const U=C.getLastChild();if(c.$isTextNode(U)){const ht=U.getTextContent(),gt=ht.replace(/\s+$/,"");gt!==ht&&U.setTextContent(gt)}const V=C.getNextSibling();if(c.$isTextNode(V)&&/^\s/.test(V.getTextContent())){V.select(1,1);return}const M=c.$createTextNode(" ");C.insertAfter(M),M.selectEnd()}}),D())},[D,e,B,Y]),Z=s.useCallback(()=>{const t=n.trim();if(!t){x();return}e.update(()=>{if(k){const a=c.$getNodeByKey(k);at(a)&&a.setSrc(t);return}c.$insertNodes([ot({src:t})])}),x()},[x,e,k,n]),lt=s.useCallback(()=>{if(!k){x();return}e.update(()=>{const t=c.$getNodeByKey(k);if(at(t)){const a=t.getParent();c.$isParagraphNode(a)&&a.getChildrenSize()===1?a.remove():t.remove(),W&&(r==null||r(W))}}),x()},[x,e,k,W,r]),ct=s.useCallback(()=>{Y(()=>{e.dispatchCommand(j.TOGGLE_LINK_COMMAND,null)}),D()},[D,e,Y]),q=s.useCallback(()=>{const t=c.$getSelection();if(!c.$isRangeSelection(t)){if(c.$isNodeSelection(t)){const I=t.getNodes(),C=I[0]??null,U=(C==null?void 0:C.getParent())??null;f(I.some(M=>c.$isTextNode(M)&&M.hasFormat("bold"))),m(I.some(M=>c.$isTextNode(M)&&M.hasFormat("italic"))),P(I.some(M=>c.$isTextNode(M)&&M.hasFormat("underline"))),L(E.$isListNode(U)||E.$isListItemNode(U)||E.$isListNode(C)||E.$isListItemNode(C));const V=j.$isLinkNode(C)?C:j.$isLinkNode(U)?U:null;if(V){v(!0),w(V.getURL());return}v(!1),w(""),T.current=null;return}f(!1),m(!1),P(!1),L(!1),v(!1),w(""),T.current=null;return}const[a]=t.getNodes(),h=(a==null?void 0:a.getParent())??null;if(f(t.hasFormat("bold")),m(t.hasFormat("italic")),P(t.hasFormat("underline")),L(E.$isListNode(h)||E.$isListItemNode(h)),j.$isLinkNode(h)){v(!0),w(h.getURL()),X(t);return}v(!1),w(""),T.current=null},[X]);return s.useEffect(()=>jt.mergeRegister(e.registerUpdateListener(({editorState:t})=>{t.read(()=>{q()})}),e.registerCommand(bt,t=>(t.soliboDocumentSlot?(x(),D()):z(t),!0),c.COMMAND_PRIORITY_LOW),e.registerCommand(c.SELECTION_CHANGE_COMMAND,()=>(e.getEditorState().read(()=>{q()}),!1),c.COMMAND_PRIORITY_LOW)),[x,D,e,z,q]),i.jsxs(Et.Toolbar,{variant:"editor","data-component":"editortoolbar",children:[i.jsx(A.Button,{"aria-label":"Bold","data-active":d,onClick:()=>{e.dispatchCommand(c.FORMAT_TEXT_COMMAND,"bold")},title:"Bold",variant:"tertiary",children:i.jsx(y.Icon,{name:"TextB"})}),i.jsx(A.Button,{"aria-label":"Italic","data-active":o,onClick:()=>{e.dispatchCommand(c.FORMAT_TEXT_COMMAND,"italic")},title:"Italic",variant:"tertiary",children:i.jsx(y.Icon,{name:"TextItalic"})}),i.jsx(A.Button,{"aria-label":"Underline","data-active":p,onClick:()=>{e.dispatchCommand(c.FORMAT_TEXT_COMMAND,"underline")},title:"Underline",variant:"tertiary",children:i.jsx(y.Icon,{name:"TextUnderline"})}),i.jsx(A.Button,{"aria-label":"List","data-active":R,onClick:()=>{R?e.dispatchCommand(E.REMOVE_LIST_COMMAND,void 0):e.dispatchCommand(E.INSERT_UNORDERED_LIST_COMMAND,void 0)},title:"List",variant:"tertiary",children:i.jsx(y.Icon,{name:"ListBullets"})}),i.jsx(A.Button,{"aria-label":"Link","data-active":N,onClick:()=>{N?H(B):(e.dispatchCommand(j.TOGGLE_LINK_COMMAND,{url:"https://"}),H("https://"))},title:"Link",variant:"tertiary",children:i.jsx(y.Icon,{name:"Link"})}),l&&i.jsxs(i.Fragment,{children:[i.jsx("input",{hidden:!0,multiple:!0,onChange:t=>{t.target.files&&l(t.target.files),t.target.value=""},ref:G,type:"file"}),i.jsx(A.Button,{"aria-label":"Upload files",onClick:()=>{var t;return(t=G.current)==null?void 0:t.click()},title:"Upload files",variant:"tertiary",children:i.jsx(y.Icon,{name:"Paperclip"})})]}),i.jsxs("div",{className:et(_.meta,N||g?_.active:""),children:[N&&i.jsxs(i.Fragment,{children:[i.jsx(_t.Input,{"aria-invalid":!J,onBlur:()=>tt(),onChange:t=>w(t.target.value),onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),tt())},ref:Q,value:B}),i.jsx(A.Button,{"aria-label":"Apply link",disabled:!J,onClick:()=>{tt()},onMouseDown:nt,variant:"tertiary",children:i.jsx(y.Icon,{name:"Check"})}),i.jsx(A.Button,{"aria-label":"Remove link",onClick:()=>ct(),onMouseDown:nt,variant:"tertiary",children:i.jsx(y.Icon,{name:"Trash",variant:"danger"})})]}),g&&i.jsxs(i.Fragment,{children:[!W&&i.jsxs(i.Fragment,{children:[i.jsx(_t.Input,{className:et(_.active),onBlur:$,onChange:t=>u(t.target.value),onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),S.current=!0,Z())},ref:it,value:n}),i.jsx(A.Button,{"aria-label":"Apply image",onClick:()=>Z(),onMouseDown:st,variant:"tertiary",children:i.jsx(y.Icon,{name:"Check"})})]}),i.jsx(A.Button,{"aria-label":"Remove image",onClick:()=>lt(),onMouseDown:st,variant:"tertiary",children:i.jsx(y.Icon,{name:"Trash",variant:"danger"})})]})]})]})},ae=c.defineExtension({name:"solibo-editor",namespace:"Editor",nodes:[j.AutoLinkNode,j.LinkNode,E.ListNode,E.ListItemNode,rt],onError(l){throw l},theme:{link:_.link,list:{ol:_.list,ul:_.list},paragraph:_.paragraph,text:{bold:_.bold,italic:_.italic,underline:_.underline}}});function le({autofocus:l,content:r="",lastEmittedContentRef:e}){const[d]=mt.useLexicalComposerContext();return s.useEffect(()=>{e.current!==r&&d.update(()=>{const g=new DOMParser().parseFromString(r,"text/html"),b=ft.$generateNodesFromDOM(d,g),o=c.$getRoot();o.clear().select(),c.$insertNodes(b),l?o.selectEnd():c.$setSelection(null)})},[l,r,d,e]),null}const ce=({autofocus:l=!1,autolink:r=!1,content:e,disabled:d=!1,errorMessage:f,fill:g=!1,files:b,inline:o=!1,inlineImages:m,invalid:p=!1,isSubmitting:P=!1,maxRows:N=12,minRows:v=1,onChange:R,onFilesChange:L,onInlineImagesChange:n,onSubmit:u,onUpload:k,placeholder:K,required:W=!1,resizable:O=!1,submitLabel:B="Submit"})=>{const w=s.useId(),J=s.useRef(void 0),G=s.useRef(null),[it,Q]=s.useState(!1),[T,S]=s.useState(!1),[nt,X]=s.useState([]),[Y,st]=s.useState([]),$=s.useRef(new Map),x=b??nt,D=m??Y;s.useEffect(()=>{const t=G.current;if(!t)return;if(!O||g){t.style.removeProperty("height"),Q(!1);return}const a=()=>Q(t.style.height!==""),h=new MutationObserver(a);return h.observe(t,{attributes:!0,attributeFilter:["style"]}),a(),()=>h.disconnect()},[g,O]);const z=t=>{b===void 0&&X(t),L==null||L(t)},H=s.useCallback(t=>{m===void 0&&st(t),n==null||n(t)},[m,n]),tt=s.useCallback(t=>{const a=t.map(h=>{const I=`pasted-${crypto.randomUUID()}`,C=URL.createObjectURL(h);return $.current.set(I,C),{image:{alt:h.name,soliboDocumentSlot:I,src:C},pending:{file:h,slot:I}}});return H([...D,...a.map(({pending:h})=>h)]),a.map(({image:h})=>h)},[D,H]),Z=s.useCallback(t=>{H(D.filter(h=>h.slot!==t));const a=$.current.get(t);a&&URL.revokeObjectURL(a),$.current.delete(t)},[D,H]);s.useEffect(()=>()=>{$.current.forEach(t=>URL.revokeObjectURL(t)),$.current.clear()},[]),s.useEffect(()=>{const t=new Set(D.map(a=>a.slot));$.current.forEach((a,h)=>{t.has(h)||(URL.revokeObjectURL(a),$.current.delete(h))})},[D]);const lt=t=>{if(typeof DataTransfer<"u"){const a=new DataTransfer;return t.forEach(h=>a.items.add(h)),a.files}return Object.assign([...t],{item:a=>t[a]??null})},ct=async()=>{try{x.length>0&&await(k==null?void 0:k(lt(x))),await(u==null?void 0:u()),x.length>0&&z([])}catch{return}},q=t=>{t.preventDefault(),t.stopPropagation()};return i.jsxs("div",{className:et(_.field,g&&_.fill),"data-max-rows":N,"data-min-rows":v,onDragEnter:t=>{q(t),S(!!L)},onDragOver:t=>{q(t),S(!!L)},onDragLeave:t=>{q(t),S(!1)},onDropCapture:t=>{var h;const a=(h=t.dataTransfer)==null?void 0:h.files;a!=null&&a.length&&(q(t),(L||k)&&z([...x,...Array.from(a)]),S(!1))},onDrop:t=>{t.preventDefault(),S(!1)},"data-component":"editor",children:[O==="top"&&!g&&i.jsx(se,{editableRef:G}),i.jsx("div",{className:et(_.editor,g&&_["fill-editor"],O===!0&&!g&&_.resizable,O&&!g&&it&&_.resized,p&&_.invalid,x.length>0&&_["has-files"]),style:{"--editor-max-height":`calc(${N*1.25}em + (2 * var(--scale-8)))`,"--editor-min-height":`calc(${v*1.25}em + (2 * var(--scale-8)))`},children:i.jsxs(vt.LexicalExtensionComposer,{contentEditable:null,extension:ae,children:[!o&&i.jsx(oe,{onInlineImageRemove:Z,onFilesSelected:k||L?t=>{z([...x,...Array.from(t)])}:void 0}),i.jsx("div",{className:et(_.content,T&&_.dragging),children:i.jsx(St.RichTextPlugin,{contentEditable:i.jsx(Ct.ContentEditable,{ref:G,"aria-placeholder":K??"",ariaErrorMessage:p&&f?w:void 0,ariaInvalid:p||void 0,ariaRequired:W||void 0,placeholder:()=>K?i.jsx("div",{className:_.placeholder,children:K}):null}),ErrorBoundary:Lt.LexicalErrorBoundary})}),!o&&u&&i.jsx("div",{className:_.submit,children:i.jsx(A.Button,{"aria-label":B,"data-cy":"toolbar-submit-button",disabled:d,icon:"PaperPlaneTilt",isLoading:P,onClick:()=>void ct(),variant:"primary",children:i.jsx("span",{children:B})})}),x.length>0&&i.jsx("div",{"aria-label":"Files to upload",className:_.files,role:"region",children:x.map((t,a)=>i.jsx(yt.File,{deleteAccessibleLabel:`Remove ${t.name} from upload queue`,name:t.name,onDelete:()=>z(x.filter((h,I)=>I!==a))},`${t.name}-${t.size}-${t.lastModified}-${a}`))}),l&&i.jsx(It.AutoFocusPlugin,{}),r&&i.jsx(Dt.AutoLinkPlugin,{matchers:ne}),i.jsx(Nt.HistoryPlugin,{}),n&&i.jsx(ee,{createImages:tt,onRemove:Z}),e!==void 0&&i.jsx(le,{autofocus:l,content:e,lastEmittedContentRef:J}),i.jsx(wt.LinkPlugin,{validateUrl:dt}),i.jsx(Mt.ListPlugin,{}),R&&i.jsx(At.OnChangePlugin,{onChange:(t,a)=>{t.read(()=>{const h=ft.$generateHtmlFromNodes(a,null),I=ut(h,{allowedAttributes:{...ut.defaults.allowedAttributes,img:[...ut.defaults.allowedAttributes.img??[],"data-solibo-document-id","data-solibo-document-slot"]},allowedTags:["a","b","br","i","img","li","ol","p","u","ul"]});J.current=I,R(I)})}})]})}),p&&f&&i.jsx("div",{className:_.error,id:w,children:f})]})};exports.Editor=ce;
|
|
@@ -1,51 +1,146 @@
|
|
|
1
|
-
import '../../assets/index43.css';var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import {
|
|
5
|
-
import { $generateHtmlFromNodes as $t, $generateNodesFromDOM as
|
|
6
|
-
import { TOGGLE_LINK_COMMAND as ft, $isLinkNode as
|
|
7
|
-
import { $isListNode as pt, $isListItemNode as
|
|
8
|
-
import { AutoFocusPlugin as
|
|
9
|
-
import { AutoLinkPlugin as
|
|
10
|
-
import { useLexicalComposerContext as
|
|
11
|
-
import { ContentEditable as
|
|
12
|
-
import { LexicalErrorBoundary as
|
|
13
|
-
import { LexicalExtensionComposer as
|
|
14
|
-
import { HistoryPlugin as
|
|
15
|
-
import { LinkPlugin as
|
|
1
|
+
import '../../assets/index43.css';var Rt = Object.defineProperty;
|
|
2
|
+
var Ot = (s, r, e) => r in s ? Rt(s, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[r] = e;
|
|
3
|
+
var j = (s, r, e) => Ot(s, typeof r != "symbol" ? r + "" : r, e);
|
|
4
|
+
import { jsxs as O, jsx as o, Fragment as ct } from "react/jsx-runtime";
|
|
5
|
+
import { $generateHtmlFromNodes as $t, $generateNodesFromDOM as Ut } from "@lexical/html";
|
|
6
|
+
import { TOGGLE_LINK_COMMAND as ft, $isLinkNode as rt, AutoLinkNode as zt, LinkNode as Bt } from "@lexical/link";
|
|
7
|
+
import { $isListNode as pt, $isListItemNode as _t, REMOVE_LIST_COMMAND as Ht, INSERT_UNORDERED_LIST_COMMAND as Ft, ListNode as Wt, ListItemNode as Kt } from "@lexical/list";
|
|
8
|
+
import { AutoFocusPlugin as jt } from "@lexical/react/LexicalAutoFocusPlugin";
|
|
9
|
+
import { AutoLinkPlugin as Gt } from "@lexical/react/LexicalAutoLinkPlugin";
|
|
10
|
+
import { useLexicalComposerContext as wt } from "@lexical/react/LexicalComposerContext";
|
|
11
|
+
import { ContentEditable as Zt } from "@lexical/react/LexicalContentEditable";
|
|
12
|
+
import { LexicalErrorBoundary as qt } from "@lexical/react/LexicalErrorBoundary";
|
|
13
|
+
import { LexicalExtensionComposer as Vt } from "@lexical/react/LexicalExtensionComposer";
|
|
14
|
+
import { HistoryPlugin as Xt } from "@lexical/react/LexicalHistoryPlugin";
|
|
15
|
+
import { LinkPlugin as Yt } from "@lexical/react/LexicalLinkPlugin";
|
|
16
16
|
import { ListPlugin as Jt } from "@lexical/react/LexicalListPlugin";
|
|
17
|
-
import { OnChangePlugin as
|
|
18
|
-
import { RichTextPlugin as
|
|
19
|
-
import
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import
|
|
23
|
-
import { Button as
|
|
24
|
-
import { File as
|
|
25
|
-
import { mergeRegister as
|
|
26
|
-
import { Icon as
|
|
27
|
-
import { I as
|
|
28
|
-
import { Toolbar as
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
17
|
+
import { OnChangePlugin as Qt } from "@lexical/react/LexicalOnChangePlugin";
|
|
18
|
+
import { RichTextPlugin as te } from "@lexical/react/LexicalRichTextPlugin";
|
|
19
|
+
import nt from "classix";
|
|
20
|
+
import { $getNodeByKey as ut, $isParagraphNode as xt, DecoratorNode as ee, $applyNodeReplacement as re, createCommand as Et, COMMAND_PRIORITY_HIGH as Mt, PASTE_COMMAND as ie, $insertNodes as Ct, $isRangeSelection as bt, $setSelection as Pt, $getSelection as kt, $isTextNode as it, $createTextNode as ne, $isNodeSelection as oe, COMMAND_PRIORITY_LOW as yt, SELECTION_CHANGE_COMMAND as ae, FORMAT_TEXT_COMMAND as Dt, defineExtension as se, $getRoot as le } from "lexical";
|
|
21
|
+
import { useRef as x, useState as k, useEffect as F, useCallback as C, useId as ce } from "react";
|
|
22
|
+
import vt from "sanitize-html";
|
|
23
|
+
import { Button as N } from "../button/index.js";
|
|
24
|
+
import { File as ue } from "../file/index.js";
|
|
25
|
+
import { mergeRegister as de } from "@lexical/utils";
|
|
26
|
+
import { Icon as P } from "../icon/index.js";
|
|
27
|
+
import { I as Nt } from "../../index-Dd20d_9U.js";
|
|
28
|
+
import { Toolbar as me } from "../toolbar/index.js";
|
|
29
|
+
const he = "_field_1trki_3", ge = "_editor_1trki_8", fe = "_submit_1trki_26", pe = "_resizable_1trki_56", _e = "_resized_1trki_60", be = "_invalid_1trki_86", ke = "_error_1trki_90", De = "_dragging_1trki_96", ve = "_content_1trki_100", Ie = "_files_1trki_116", we = "_placeholder_1trki_125", Ce = "_fill_1trki_133", Le = "_meta_1trki_161", Ae = "_active_1trki_170", Me = "_bold_1trki_240", ye = "_italic_1trki_244", Ne = "_underline_1trki_248", xe = "_link_1trki_252", Ee = "_list_1trki_258", Pe = "_paragraph_1trki_259", h = {
|
|
30
|
+
field: he,
|
|
31
|
+
editor: ge,
|
|
32
|
+
submit: fe,
|
|
33
|
+
"image-resize-handle": "_image-resize-handle_1trki_50",
|
|
34
|
+
resizable: pe,
|
|
35
|
+
resized: _e,
|
|
36
|
+
"resize-handle": "_resize-handle_1trki_64",
|
|
37
|
+
invalid: be,
|
|
38
|
+
error: ke,
|
|
39
|
+
dragging: De,
|
|
40
|
+
content: ve,
|
|
41
|
+
"has-files": "_has-files_1trki_112",
|
|
42
|
+
files: Ie,
|
|
43
|
+
placeholder: we,
|
|
44
|
+
fill: Ce,
|
|
45
|
+
"fill-editor": "_fill-editor_1trki_141",
|
|
46
|
+
meta: Le,
|
|
47
|
+
active: Ae,
|
|
48
|
+
"inline-image": "_inline-image_1trki_182",
|
|
49
|
+
bold: Me,
|
|
50
|
+
italic: ye,
|
|
51
|
+
underline: Ne,
|
|
52
|
+
link: xe,
|
|
53
|
+
list: Ee,
|
|
54
|
+
paragraph: Pe
|
|
55
|
+
};
|
|
56
|
+
function Se({
|
|
57
|
+
alt: s = "",
|
|
58
|
+
editor: r,
|
|
59
|
+
height: e,
|
|
60
|
+
nodeKey: c,
|
|
61
|
+
soliboDocumentId: g,
|
|
62
|
+
soliboDocumentSlot: m,
|
|
63
|
+
src: p,
|
|
64
|
+
width: n
|
|
65
|
+
}) {
|
|
66
|
+
const u = x(null), f = x(null), [$, A] = k(), L = () => {
|
|
67
|
+
const i = r.getRootElement();
|
|
68
|
+
if (!i) return 1 / 0;
|
|
69
|
+
const l = getComputedStyle(i);
|
|
70
|
+
return Math.max(1, i.clientWidth - (parseFloat(l.paddingLeft) || 0) - (parseFloat(l.paddingRight) || 0));
|
|
71
|
+
}, S = (i, l = L()) => Math.round(Math.min(l, Math.max(Math.min(32, l), i))), w = (i) => {
|
|
72
|
+
r.update(() => {
|
|
73
|
+
const l = ut(c);
|
|
74
|
+
mt(l) && l.setWidth(i);
|
|
75
|
+
}), A(void 0);
|
|
76
|
+
};
|
|
77
|
+
return /* @__PURE__ */ O("span", { className: h["inline-image"], contentEditable: !1, tabIndex: m ? 0 : void 0, onKeyDown: (i) => {
|
|
78
|
+
!m || i.target !== i.currentTarget || !["Backspace", "Delete"].includes(i.key) || (i.preventDefault(), i.stopPropagation(), r.update(() => {
|
|
79
|
+
const l = ut(c);
|
|
80
|
+
if (!mt(l)) return;
|
|
81
|
+
const b = l.getParent();
|
|
82
|
+
xt(b) && b.getChildrenSize() === 1 ? b.remove() : l.remove(), r.dispatchCommand(St, m);
|
|
83
|
+
}), r.focus());
|
|
84
|
+
}, "data-component": "editorimage", children: [
|
|
85
|
+
/* @__PURE__ */ o("img", { alt: s, "data-solibo-document-id": g, "data-solibo-document-slot": m, draggable: !1, height: $ === void 0 ? e : void 0, ref: u, src: p, width: $ ?? n, onClick: (i) => {
|
|
86
|
+
var l;
|
|
87
|
+
i.preventDefault(), m && ((l = i.currentTarget.parentElement) == null || l.focus()), r.dispatchCommand(Tt, {
|
|
88
|
+
key: c,
|
|
89
|
+
soliboDocumentSlot: m,
|
|
90
|
+
src: p,
|
|
91
|
+
width: n
|
|
92
|
+
});
|
|
93
|
+
} }),
|
|
94
|
+
/* @__PURE__ */ o("button", { type: "button", "aria-label": `Resize image${s ? `: ${s}` : ""}`, title: "Drag to resize; use arrow keys to adjust width", className: h["image-resize-handle"], tabIndex: 0, onClick: (i) => {
|
|
95
|
+
i.preventDefault(), i.stopPropagation();
|
|
96
|
+
}, onKeyDown: (i) => {
|
|
97
|
+
var b;
|
|
98
|
+
if (!["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"].includes(i.key)) return;
|
|
99
|
+
i.preventDefault(), i.stopPropagation();
|
|
100
|
+
const l = ((b = u.current) == null ? void 0 : b.getBoundingClientRect().width) ?? n ?? 32;
|
|
101
|
+
w(S(l + (["ArrowRight", "ArrowUp"].includes(i.key) ? 10 : -10)));
|
|
102
|
+
}, onPointerDown: (i) => {
|
|
103
|
+
i.button !== 0 || !u.current || (i.preventDefault(), i.stopPropagation(), i.currentTarget.focus({
|
|
104
|
+
preventScroll: !0
|
|
105
|
+
}), i.currentTarget.setPointerCapture(i.pointerId), f.current = {
|
|
106
|
+
pointerId: i.pointerId,
|
|
107
|
+
x: i.clientX,
|
|
108
|
+
width: u.current.getBoundingClientRect().width,
|
|
109
|
+
maximum: L()
|
|
110
|
+
});
|
|
111
|
+
}, onPointerMove: (i) => {
|
|
112
|
+
const l = f.current;
|
|
113
|
+
!l || l.pointerId !== i.pointerId || A(S(l.width + i.clientX - l.x, l.maximum));
|
|
114
|
+
}, onPointerUp: (i) => {
|
|
115
|
+
const l = f.current;
|
|
116
|
+
!l || l.pointerId !== i.pointerId || (f.current = null, w(S(l.width + i.clientX - l.x, l.maximum)), i.currentTarget.releasePointerCapture(i.pointerId));
|
|
117
|
+
}, onPointerCancel: () => {
|
|
118
|
+
f.current = null, A(void 0);
|
|
119
|
+
}, onLostPointerCapture: () => {
|
|
120
|
+
f.current = null, A(void 0);
|
|
121
|
+
} })
|
|
122
|
+
] });
|
|
123
|
+
}
|
|
124
|
+
const St = Et(), Tt = Et();
|
|
125
|
+
class ot extends ee {
|
|
126
|
+
constructor(e, c, g, m, p, n, u) {
|
|
127
|
+
super(p);
|
|
128
|
+
j(this, "__src");
|
|
129
|
+
j(this, "__alt");
|
|
130
|
+
j(this, "__width");
|
|
131
|
+
j(this, "__height");
|
|
132
|
+
j(this, "__soliboDocumentId");
|
|
133
|
+
j(this, "__soliboDocumentSlot");
|
|
134
|
+
this.__src = e, this.__alt = c, this.__width = g, this.__height = m, this.__soliboDocumentId = n, this.__soliboDocumentSlot = u;
|
|
40
135
|
}
|
|
41
136
|
static getType() {
|
|
42
137
|
return "image";
|
|
43
138
|
}
|
|
44
139
|
static clone(e) {
|
|
45
|
-
return new
|
|
140
|
+
return new ot(e.__src, e.__alt, e.__width, e.__height, e.__key, e.__soliboDocumentId, e.__soliboDocumentSlot);
|
|
46
141
|
}
|
|
47
142
|
static importJSON(e) {
|
|
48
|
-
return
|
|
143
|
+
return dt({
|
|
49
144
|
alt: e.alt,
|
|
50
145
|
height: e.height,
|
|
51
146
|
soliboDocumentId: e.soliboDocumentId,
|
|
@@ -74,21 +169,21 @@ class at extends te {
|
|
|
74
169
|
return {
|
|
75
170
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
76
171
|
img: (e) => ({
|
|
77
|
-
conversion: (
|
|
78
|
-
if (!(
|
|
172
|
+
conversion: (c) => {
|
|
173
|
+
if (!(c instanceof HTMLImageElement))
|
|
79
174
|
return null;
|
|
80
|
-
const
|
|
81
|
-
if (!
|
|
175
|
+
const g = c.getAttribute("src") ?? "";
|
|
176
|
+
if (!g)
|
|
82
177
|
return null;
|
|
83
|
-
const
|
|
178
|
+
const m = c.getAttribute("width"), p = c.getAttribute("height");
|
|
84
179
|
return {
|
|
85
|
-
node:
|
|
86
|
-
alt:
|
|
87
|
-
height:
|
|
88
|
-
soliboDocumentId:
|
|
89
|
-
soliboDocumentSlot:
|
|
90
|
-
src:
|
|
91
|
-
width:
|
|
180
|
+
node: dt({
|
|
181
|
+
alt: c.getAttribute("alt") ?? "",
|
|
182
|
+
height: p ? Number(p) : void 0,
|
|
183
|
+
soliboDocumentId: c.getAttribute("data-solibo-document-id") ?? void 0,
|
|
184
|
+
soliboDocumentSlot: c.getAttribute("data-solibo-document-slot") ?? void 0,
|
|
185
|
+
src: g,
|
|
186
|
+
width: m ? Number(m) : void 0
|
|
92
187
|
})
|
|
93
188
|
};
|
|
94
189
|
},
|
|
@@ -115,58 +210,52 @@ class at extends te {
|
|
|
115
210
|
return this.__src;
|
|
116
211
|
}
|
|
117
212
|
setSrc(e) {
|
|
118
|
-
const
|
|
119
|
-
return
|
|
213
|
+
const c = this.getWritable();
|
|
214
|
+
return c.__src = e, c;
|
|
120
215
|
}
|
|
121
216
|
setWidth(e) {
|
|
122
|
-
const
|
|
123
|
-
return
|
|
217
|
+
const c = this.getWritable();
|
|
218
|
+
return c.__width = e, c.__height = void 0, c;
|
|
124
219
|
}
|
|
125
220
|
decorate(e) {
|
|
126
|
-
return /* @__PURE__ */
|
|
127
|
-
l.preventDefault(), e.dispatchCommand(Tt, {
|
|
128
|
-
key: this.getKey(),
|
|
129
|
-
soliboDocumentSlot: this.__soliboDocumentSlot,
|
|
130
|
-
src: this.__src,
|
|
131
|
-
width: this.__width
|
|
132
|
-
});
|
|
133
|
-
}, src: this.__src, width: this.__width });
|
|
221
|
+
return /* @__PURE__ */ o(Se, { alt: this.__alt, editor: e, height: this.__height, nodeKey: this.getKey(), soliboDocumentId: this.__soliboDocumentId, soliboDocumentSlot: this.__soliboDocumentSlot, src: this.__src, width: this.__width });
|
|
134
222
|
}
|
|
135
223
|
}
|
|
136
|
-
function
|
|
224
|
+
function dt({
|
|
137
225
|
alt: s = "",
|
|
138
226
|
height: r,
|
|
139
227
|
soliboDocumentId: e,
|
|
140
|
-
soliboDocumentSlot:
|
|
141
|
-
src:
|
|
142
|
-
width:
|
|
228
|
+
soliboDocumentSlot: c,
|
|
229
|
+
src: g,
|
|
230
|
+
width: m
|
|
143
231
|
}) {
|
|
144
|
-
return
|
|
232
|
+
return re(new ot(g, s, m, r, void 0, e, c));
|
|
145
233
|
}
|
|
146
|
-
function
|
|
147
|
-
return s instanceof
|
|
234
|
+
function mt(s) {
|
|
235
|
+
return s instanceof ot;
|
|
148
236
|
}
|
|
149
|
-
const
|
|
150
|
-
createImages: s
|
|
237
|
+
const Te = ({
|
|
238
|
+
createImages: s,
|
|
239
|
+
onRemove: r
|
|
151
240
|
}) => {
|
|
152
|
-
const [
|
|
153
|
-
return
|
|
154
|
-
var
|
|
155
|
-
if (!("clipboardData" in
|
|
156
|
-
const
|
|
157
|
-
if (
|
|
158
|
-
const
|
|
159
|
-
return
|
|
241
|
+
const [e] = wt();
|
|
242
|
+
return F(() => e.registerCommand(St, (c) => (r(c), !0), Mt), [e, r]), F(() => e.registerCommand(ie, (c) => {
|
|
243
|
+
var n;
|
|
244
|
+
if (!("clipboardData" in c)) return !1;
|
|
245
|
+
const g = c, m = Array.from(((n = g.clipboardData) == null ? void 0 : n.items) ?? []).flatMap((u) => {
|
|
246
|
+
if (u.kind !== "file" || !u.type.startsWith("image/")) return [];
|
|
247
|
+
const f = u.getAsFile();
|
|
248
|
+
return f ? [f] : [];
|
|
160
249
|
});
|
|
161
|
-
if (
|
|
162
|
-
|
|
163
|
-
const
|
|
164
|
-
return
|
|
165
|
-
|
|
250
|
+
if (m.length === 0) return !1;
|
|
251
|
+
g.preventDefault();
|
|
252
|
+
const p = s(m);
|
|
253
|
+
return e.update(() => {
|
|
254
|
+
Ct(p.map((u) => dt(u)));
|
|
166
255
|
}), !0;
|
|
167
|
-
},
|
|
168
|
-
},
|
|
169
|
-
const r =
|
|
256
|
+
}, Mt), [s, e]), null;
|
|
257
|
+
}, Re = /(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/, Oe = /((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/, $e = [(s) => {
|
|
258
|
+
const r = Re.exec(s);
|
|
170
259
|
return r != null && r.length ? {
|
|
171
260
|
index: r.index,
|
|
172
261
|
length: r[0].length,
|
|
@@ -174,7 +263,7 @@ const ge = ({
|
|
|
174
263
|
url: `mailto:${r[0]}`
|
|
175
264
|
} : null;
|
|
176
265
|
}, (s) => {
|
|
177
|
-
const r =
|
|
266
|
+
const r = Oe.exec(s);
|
|
178
267
|
return r != null && r.length ? {
|
|
179
268
|
index: r.index,
|
|
180
269
|
length: r[0].length,
|
|
@@ -182,7 +271,7 @@ const ge = ({
|
|
|
182
271
|
url: r[0].startsWith("http") ? r[0] : `https://${r[0]}`
|
|
183
272
|
} : null;
|
|
184
273
|
}];
|
|
185
|
-
function
|
|
274
|
+
function It(s) {
|
|
186
275
|
try {
|
|
187
276
|
const r = new URL(s);
|
|
188
277
|
return r.protocol === "http:" || r.protocol === "https:";
|
|
@@ -190,442 +279,395 @@ function Ct(s) {
|
|
|
190
279
|
return !1;
|
|
191
280
|
}
|
|
192
281
|
}
|
|
193
|
-
|
|
194
|
-
field: ve,
|
|
195
|
-
editor: De,
|
|
196
|
-
submit: Ie,
|
|
197
|
-
resizable: ke,
|
|
198
|
-
resized: we,
|
|
199
|
-
"resize-handle": "_resize-handle_1clme_64",
|
|
200
|
-
invalid: Le,
|
|
201
|
-
error: Ce,
|
|
202
|
-
dragging: Ae,
|
|
203
|
-
content: Me,
|
|
204
|
-
"has-files": "_has-files_1clme_112",
|
|
205
|
-
files: Se,
|
|
206
|
-
placeholder: Ne,
|
|
207
|
-
fill: Ee,
|
|
208
|
-
"fill-editor": "_fill-editor_1clme_141",
|
|
209
|
-
meta: ye,
|
|
210
|
-
active: xe,
|
|
211
|
-
"image-sizes": "_image-sizes_1clme_182",
|
|
212
|
-
bold: Te,
|
|
213
|
-
italic: Oe,
|
|
214
|
-
underline: Pe,
|
|
215
|
-
link: $e,
|
|
216
|
-
list: Re,
|
|
217
|
-
paragraph: Ue
|
|
218
|
-
};
|
|
219
|
-
function ze({
|
|
282
|
+
function Ue({
|
|
220
283
|
editableRef: s
|
|
221
284
|
}) {
|
|
222
|
-
const r =
|
|
223
|
-
|
|
224
|
-
const
|
|
225
|
-
if (!
|
|
226
|
-
const
|
|
227
|
-
|
|
285
|
+
const r = x(null), [e, c] = k(0), [g, m] = k(0);
|
|
286
|
+
F(() => {
|
|
287
|
+
const n = s.current;
|
|
288
|
+
if (!n) return;
|
|
289
|
+
const u = () => {
|
|
290
|
+
c(Math.round(n.getBoundingClientRect().height)), m(Math.round(parseFloat(getComputedStyle(n).minHeight) || 0));
|
|
228
291
|
};
|
|
229
|
-
if (
|
|
230
|
-
const
|
|
231
|
-
return
|
|
292
|
+
if (u(), typeof ResizeObserver > "u") return;
|
|
293
|
+
const f = new ResizeObserver(u);
|
|
294
|
+
return f.observe(n), () => f.disconnect();
|
|
232
295
|
}, [s]);
|
|
233
|
-
const
|
|
234
|
-
const
|
|
235
|
-
if (!
|
|
236
|
-
const
|
|
237
|
-
|
|
296
|
+
const p = (n) => {
|
|
297
|
+
const u = s.current;
|
|
298
|
+
if (!u) return;
|
|
299
|
+
const f = parseFloat(getComputedStyle(u).minHeight) || 0;
|
|
300
|
+
u.style.height = `${Math.max(f, n)}px`;
|
|
238
301
|
};
|
|
239
|
-
return /* @__PURE__ */
|
|
240
|
-
var
|
|
241
|
-
return (
|
|
242
|
-
}, onKeyDown: (
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
}, onPointerDown: (
|
|
246
|
-
const
|
|
247
|
-
|
|
302
|
+
return /* @__PURE__ */ o("div", { "aria-label": "Resize editor", "aria-orientation": "horizontal", "aria-valuemin": g, "aria-valuenow": e, "aria-valuetext": `${e} pixels`, className: h["resize-handle"], role: "separator", tabIndex: 0, onDoubleClick: () => {
|
|
303
|
+
var n;
|
|
304
|
+
return (n = s.current) == null ? void 0 : n.style.removeProperty("height");
|
|
305
|
+
}, onKeyDown: (n) => {
|
|
306
|
+
const u = s.current;
|
|
307
|
+
u && (n.key === "Home" ? (n.preventDefault(), u.style.removeProperty("height")) : (n.key === "ArrowUp" || n.key === "ArrowDown") && (n.preventDefault(), p(u.getBoundingClientRect().height + (n.key === "ArrowUp" ? 20 : -20))));
|
|
308
|
+
}, onPointerDown: (n) => {
|
|
309
|
+
const u = s.current;
|
|
310
|
+
n.button !== 0 || !u || (n.preventDefault(), n.currentTarget.focus({
|
|
248
311
|
preventScroll: !0
|
|
249
|
-
}),
|
|
250
|
-
pointerId:
|
|
251
|
-
y:
|
|
252
|
-
height:
|
|
312
|
+
}), n.currentTarget.setPointerCapture(n.pointerId), r.current = {
|
|
313
|
+
pointerId: n.pointerId,
|
|
314
|
+
y: n.clientY,
|
|
315
|
+
height: u.getBoundingClientRect().height
|
|
253
316
|
});
|
|
254
|
-
}, onPointerMove: (
|
|
255
|
-
!r.current || r.current.pointerId !==
|
|
256
|
-
}, onPointerUp: (
|
|
257
|
-
!r.current || r.current.pointerId !==
|
|
317
|
+
}, onPointerMove: (n) => {
|
|
318
|
+
!r.current || r.current.pointerId !== n.pointerId || p(r.current.height + r.current.y - n.clientY);
|
|
319
|
+
}, onPointerUp: (n) => {
|
|
320
|
+
!r.current || r.current.pointerId !== n.pointerId || (r.current = null, n.currentTarget.releasePointerCapture(n.pointerId));
|
|
258
321
|
}, onLostPointerCapture: () => {
|
|
259
322
|
r.current = null;
|
|
260
323
|
}, onPointerCancel: () => {
|
|
261
324
|
r.current = null;
|
|
262
325
|
}, "data-component": "editorresizehandle" });
|
|
263
326
|
}
|
|
264
|
-
const
|
|
265
|
-
label: "Small",
|
|
266
|
-
width: 320
|
|
267
|
-
}, {
|
|
268
|
-
label: "Medium",
|
|
269
|
-
width: 640
|
|
270
|
-
}, {
|
|
271
|
-
label: "Large",
|
|
272
|
-
width: 960
|
|
273
|
-
}, {
|
|
274
|
-
label: "Original",
|
|
275
|
-
width: void 0
|
|
276
|
-
}], Be = ({
|
|
327
|
+
const ze = ({
|
|
277
328
|
onFilesSelected: s,
|
|
278
329
|
onInlineImageRemove: r
|
|
279
330
|
}) => {
|
|
280
|
-
const [e] =
|
|
281
|
-
T.current =
|
|
282
|
-
}, []),
|
|
331
|
+
const [e] = wt(), [c, g] = k(!1), [m, p] = k(!1), [n, u] = k(!1), [f, $] = k(!1), [A, L] = k(!1), [S, w] = k(!1), [i, l] = k(""), [b, G] = k(null), [Z, U] = k(null), [z, M] = k(""), Q = It(z.trim()), q = x(null), at = x(null), tt = x(null), T = x(null), E = x(!1), st = (t) => t.preventDefault(), V = C((t) => {
|
|
332
|
+
T.current = bt(t) ? t.clone() : null;
|
|
333
|
+
}, []), X = C((t) => {
|
|
283
334
|
e.update(() => {
|
|
284
|
-
T.current &&
|
|
335
|
+
T.current && Pt(T.current), t();
|
|
285
336
|
}), T.current = null;
|
|
286
|
-
}, [e]),
|
|
287
|
-
|
|
288
|
-
},
|
|
289
|
-
if (
|
|
290
|
-
|
|
337
|
+
}, [e]), lt = (t) => {
|
|
338
|
+
E.current = !0, t.preventDefault();
|
|
339
|
+
}, R = () => {
|
|
340
|
+
if (E.current) {
|
|
341
|
+
E.current = !1;
|
|
291
342
|
return;
|
|
292
343
|
}
|
|
293
|
-
|
|
294
|
-
},
|
|
295
|
-
|
|
296
|
-
}, []),
|
|
297
|
-
|
|
298
|
-
}, []),
|
|
299
|
-
|
|
300
|
-
var
|
|
301
|
-
return (
|
|
344
|
+
Y();
|
|
345
|
+
}, _ = C(() => {
|
|
346
|
+
p(!1), l(""), G(null), U(null);
|
|
347
|
+
}, []), v = C(() => {
|
|
348
|
+
L(!1), M("");
|
|
349
|
+
}, []), W = C((t) => {
|
|
350
|
+
p(!0), l((t == null ? void 0 : t.src) ?? ""), G((t == null ? void 0 : t.key) ?? null), U((t == null ? void 0 : t.soliboDocumentSlot) ?? null), v(), t != null && t.soliboDocumentSlot || setTimeout(() => {
|
|
351
|
+
var a;
|
|
352
|
+
return (a = at.current) == null ? void 0 : a.focus();
|
|
302
353
|
}, 0);
|
|
303
|
-
}, [
|
|
354
|
+
}, [v]), K = C((t) => {
|
|
304
355
|
e.getEditorState().read(() => {
|
|
305
|
-
V(
|
|
306
|
-
}),
|
|
307
|
-
var
|
|
308
|
-
return (
|
|
356
|
+
V(kt());
|
|
357
|
+
}), L(!0), M(t), _(), setTimeout(() => {
|
|
358
|
+
var a;
|
|
359
|
+
return (a = tt.current) == null ? void 0 : a.focus();
|
|
309
360
|
}, 0);
|
|
310
|
-
}, [
|
|
311
|
-
const t =
|
|
312
|
-
|
|
361
|
+
}, [_, e, V]), et = C(() => {
|
|
362
|
+
const t = z.trim();
|
|
363
|
+
It(t) && (X(() => {
|
|
313
364
|
e.dispatchCommand(ft, {
|
|
314
365
|
url: t,
|
|
315
366
|
target: "_blank"
|
|
316
367
|
});
|
|
317
|
-
const
|
|
318
|
-
if (!
|
|
319
|
-
const
|
|
320
|
-
if (
|
|
321
|
-
const H =
|
|
322
|
-
if (
|
|
323
|
-
const
|
|
324
|
-
|
|
368
|
+
const a = kt();
|
|
369
|
+
if (!bt(a)) return;
|
|
370
|
+
const d = a.getNodes().at(-1) ?? null, D = (d == null ? void 0 : d.getParent()) ?? null, I = rt(d) ? d : rt(D) ? D : null;
|
|
371
|
+
if (I) {
|
|
372
|
+
const H = I.getLastChild();
|
|
373
|
+
if (it(H)) {
|
|
374
|
+
const Lt = H.getTextContent(), At = Lt.replace(/\s+$/, "");
|
|
375
|
+
At !== Lt && H.setTextContent(At);
|
|
325
376
|
}
|
|
326
|
-
const
|
|
327
|
-
if (
|
|
328
|
-
|
|
377
|
+
const J = I.getNextSibling();
|
|
378
|
+
if (it(J) && /^\s/.test(J.getTextContent())) {
|
|
379
|
+
J.select(1, 1);
|
|
329
380
|
return;
|
|
330
381
|
}
|
|
331
|
-
const
|
|
332
|
-
|
|
382
|
+
const y = ne(" ");
|
|
383
|
+
I.insertAfter(y), y.selectEnd();
|
|
333
384
|
}
|
|
334
|
-
}),
|
|
335
|
-
}, [
|
|
336
|
-
const t =
|
|
385
|
+
}), v());
|
|
386
|
+
}, [v, e, z, X]), Y = C(() => {
|
|
387
|
+
const t = i.trim();
|
|
337
388
|
if (!t) {
|
|
338
|
-
|
|
389
|
+
_();
|
|
339
390
|
return;
|
|
340
391
|
}
|
|
341
392
|
e.update(() => {
|
|
342
|
-
if (
|
|
343
|
-
const
|
|
344
|
-
|
|
393
|
+
if (b) {
|
|
394
|
+
const a = ut(b);
|
|
395
|
+
mt(a) && a.setSrc(t);
|
|
345
396
|
return;
|
|
346
397
|
}
|
|
347
|
-
|
|
398
|
+
Ct([dt({
|
|
348
399
|
src: t
|
|
349
400
|
})]);
|
|
350
|
-
}),
|
|
351
|
-
}, [
|
|
352
|
-
if (!
|
|
353
|
-
|
|
401
|
+
}), _();
|
|
402
|
+
}, [_, e, b, i]), ht = C(() => {
|
|
403
|
+
if (!b) {
|
|
404
|
+
_();
|
|
354
405
|
return;
|
|
355
406
|
}
|
|
356
407
|
e.update(() => {
|
|
357
|
-
const t =
|
|
358
|
-
if (
|
|
359
|
-
const
|
|
360
|
-
|
|
408
|
+
const t = ut(b);
|
|
409
|
+
if (mt(t)) {
|
|
410
|
+
const a = t.getParent();
|
|
411
|
+
xt(a) && a.getChildrenSize() === 1 ? a.remove() : t.remove(), Z && (r == null || r(Z));
|
|
361
412
|
}
|
|
362
|
-
}),
|
|
363
|
-
}, [
|
|
364
|
-
|
|
365
|
-
const c = It(p);
|
|
366
|
-
Lt(c) && c.setWidth(t);
|
|
367
|
-
}), q(t));
|
|
368
|
-
}, [e, p]), a = b(() => {
|
|
369
|
-
I(() => {
|
|
413
|
+
}), _();
|
|
414
|
+
}, [_, e, b, Z, r]), gt = C(() => {
|
|
415
|
+
X(() => {
|
|
370
416
|
e.dispatchCommand(ft, null);
|
|
371
|
-
}),
|
|
372
|
-
}, [
|
|
373
|
-
const t =
|
|
374
|
-
if (!
|
|
375
|
-
if (
|
|
376
|
-
const
|
|
377
|
-
|
|
378
|
-
const
|
|
379
|
-
if (
|
|
380
|
-
|
|
417
|
+
}), v();
|
|
418
|
+
}, [v, e, X]), B = C(() => {
|
|
419
|
+
const t = kt();
|
|
420
|
+
if (!bt(t)) {
|
|
421
|
+
if (oe(t)) {
|
|
422
|
+
const D = t.getNodes(), I = D[0] ?? null, H = (I == null ? void 0 : I.getParent()) ?? null;
|
|
423
|
+
g(D.some((y) => it(y) && y.hasFormat("bold"))), u(D.some((y) => it(y) && y.hasFormat("italic"))), $(D.some((y) => it(y) && y.hasFormat("underline"))), w(pt(H) || _t(H) || pt(I) || _t(I));
|
|
424
|
+
const J = rt(I) ? I : rt(H) ? H : null;
|
|
425
|
+
if (J) {
|
|
426
|
+
L(!0), M(J.getURL());
|
|
381
427
|
return;
|
|
382
428
|
}
|
|
383
|
-
|
|
429
|
+
L(!1), M(""), T.current = null;
|
|
384
430
|
return;
|
|
385
431
|
}
|
|
386
|
-
|
|
432
|
+
g(!1), u(!1), $(!1), w(!1), L(!1), M(""), T.current = null;
|
|
387
433
|
return;
|
|
388
434
|
}
|
|
389
|
-
const [
|
|
390
|
-
if (
|
|
391
|
-
|
|
435
|
+
const [a] = t.getNodes(), d = (a == null ? void 0 : a.getParent()) ?? null;
|
|
436
|
+
if (g(t.hasFormat("bold")), u(t.hasFormat("italic")), $(t.hasFormat("underline")), w(pt(d) || _t(d)), rt(d)) {
|
|
437
|
+
L(!0), M(d.getURL()), V(t);
|
|
392
438
|
return;
|
|
393
439
|
}
|
|
394
|
-
|
|
440
|
+
L(!1), M(""), T.current = null;
|
|
395
441
|
}, [V]);
|
|
396
|
-
return
|
|
442
|
+
return F(() => de(e.registerUpdateListener(({
|
|
397
443
|
editorState: t
|
|
398
444
|
}) => {
|
|
399
445
|
t.read(() => {
|
|
400
|
-
|
|
446
|
+
B();
|
|
401
447
|
});
|
|
402
|
-
}), e.registerCommand(Tt, (t) => (
|
|
403
|
-
|
|
404
|
-
}), !1),
|
|
405
|
-
/* @__PURE__ */
|
|
406
|
-
e.dispatchCommand(
|
|
407
|
-
}, title: "Bold", variant: "tertiary", children: /* @__PURE__ */
|
|
408
|
-
/* @__PURE__ */
|
|
409
|
-
e.dispatchCommand(
|
|
410
|
-
}, title: "Italic", variant: "tertiary", children: /* @__PURE__ */
|
|
411
|
-
/* @__PURE__ */
|
|
412
|
-
e.dispatchCommand(
|
|
413
|
-
}, title: "Underline", variant: "tertiary", children: /* @__PURE__ */
|
|
414
|
-
/* @__PURE__ */
|
|
415
|
-
|
|
416
|
-
}, title: "List", variant: "tertiary", children: /* @__PURE__ */
|
|
417
|
-
/* @__PURE__ */
|
|
418
|
-
|
|
448
|
+
}), e.registerCommand(Tt, (t) => (t.soliboDocumentSlot ? (_(), v()) : W(t), !0), yt), e.registerCommand(ae, () => (e.getEditorState().read(() => {
|
|
449
|
+
B();
|
|
450
|
+
}), !1), yt)), [_, v, e, W, B]), /* @__PURE__ */ O(me, { variant: "editor", "data-component": "editortoolbar", children: [
|
|
451
|
+
/* @__PURE__ */ o(N, { "aria-label": "Bold", "data-active": c, onClick: () => {
|
|
452
|
+
e.dispatchCommand(Dt, "bold");
|
|
453
|
+
}, title: "Bold", variant: "tertiary", children: /* @__PURE__ */ o(P, { name: "TextB" }) }),
|
|
454
|
+
/* @__PURE__ */ o(N, { "aria-label": "Italic", "data-active": n, onClick: () => {
|
|
455
|
+
e.dispatchCommand(Dt, "italic");
|
|
456
|
+
}, title: "Italic", variant: "tertiary", children: /* @__PURE__ */ o(P, { name: "TextItalic" }) }),
|
|
457
|
+
/* @__PURE__ */ o(N, { "aria-label": "Underline", "data-active": f, onClick: () => {
|
|
458
|
+
e.dispatchCommand(Dt, "underline");
|
|
459
|
+
}, title: "Underline", variant: "tertiary", children: /* @__PURE__ */ o(P, { name: "TextUnderline" }) }),
|
|
460
|
+
/* @__PURE__ */ o(N, { "aria-label": "List", "data-active": S, onClick: () => {
|
|
461
|
+
S ? e.dispatchCommand(Ht, void 0) : e.dispatchCommand(Ft, void 0);
|
|
462
|
+
}, title: "List", variant: "tertiary", children: /* @__PURE__ */ o(P, { name: "ListBullets" }) }),
|
|
463
|
+
/* @__PURE__ */ o(N, { "aria-label": "Link", "data-active": A, onClick: () => {
|
|
464
|
+
A ? K(z) : (e.dispatchCommand(ft, {
|
|
419
465
|
url: "https://"
|
|
420
|
-
}),
|
|
421
|
-
}, title: "Link", variant: "tertiary", children: /* @__PURE__ */
|
|
422
|
-
s && /* @__PURE__ */
|
|
423
|
-
/* @__PURE__ */
|
|
466
|
+
}), K("https://"));
|
|
467
|
+
}, title: "Link", variant: "tertiary", children: /* @__PURE__ */ o(P, { name: "Link" }) }),
|
|
468
|
+
s && /* @__PURE__ */ O(ct, { children: [
|
|
469
|
+
/* @__PURE__ */ o("input", { hidden: !0, multiple: !0, onChange: (t) => {
|
|
424
470
|
t.target.files && s(t.target.files), t.target.value = "";
|
|
425
|
-
}, ref:
|
|
426
|
-
/* @__PURE__ */
|
|
471
|
+
}, ref: q, type: "file" }),
|
|
472
|
+
/* @__PURE__ */ o(N, { "aria-label": "Upload files", onClick: () => {
|
|
427
473
|
var t;
|
|
428
|
-
return (t =
|
|
429
|
-
}, title: "Upload files", variant: "tertiary", children: /* @__PURE__ */
|
|
474
|
+
return (t = q.current) == null ? void 0 : t.click();
|
|
475
|
+
}, title: "Upload files", variant: "tertiary", children: /* @__PURE__ */ o(P, { name: "Paperclip" }) })
|
|
430
476
|
] }),
|
|
431
|
-
/* @__PURE__ */
|
|
432
|
-
|
|
433
|
-
/* @__PURE__ */
|
|
434
|
-
t.key === "Enter" && (t.preventDefault(),
|
|
435
|
-
}, ref:
|
|
436
|
-
/* @__PURE__ */
|
|
437
|
-
|
|
438
|
-
}, onMouseDown:
|
|
439
|
-
/* @__PURE__ */
|
|
477
|
+
/* @__PURE__ */ O("div", { className: nt(h.meta, A || m ? h.active : ""), children: [
|
|
478
|
+
A && /* @__PURE__ */ O(ct, { children: [
|
|
479
|
+
/* @__PURE__ */ o(Nt, { "aria-invalid": !Q, onBlur: () => et(), onChange: (t) => M(t.target.value), onKeyDown: (t) => {
|
|
480
|
+
t.key === "Enter" && (t.preventDefault(), et());
|
|
481
|
+
}, ref: tt, value: z }),
|
|
482
|
+
/* @__PURE__ */ o(N, { "aria-label": "Apply link", disabled: !Q, onClick: () => {
|
|
483
|
+
et();
|
|
484
|
+
}, onMouseDown: st, variant: "tertiary", children: /* @__PURE__ */ o(P, { name: "Check" }) }),
|
|
485
|
+
/* @__PURE__ */ o(N, { "aria-label": "Remove link", onClick: () => gt(), onMouseDown: st, variant: "tertiary", children: /* @__PURE__ */ o(P, { name: "Trash", variant: "danger" }) })
|
|
440
486
|
] }),
|
|
441
|
-
|
|
442
|
-
!Z && /* @__PURE__ */
|
|
443
|
-
/* @__PURE__ */
|
|
444
|
-
t.key === "Enter" && (t.preventDefault(),
|
|
445
|
-
}, ref:
|
|
446
|
-
/* @__PURE__ */
|
|
487
|
+
m && /* @__PURE__ */ O(ct, { children: [
|
|
488
|
+
!Z && /* @__PURE__ */ O(ct, { children: [
|
|
489
|
+
/* @__PURE__ */ o(Nt, { className: nt(h.active), onBlur: R, onChange: (t) => l(t.target.value), onKeyDown: (t) => {
|
|
490
|
+
t.key === "Enter" && (t.preventDefault(), E.current = !0, Y());
|
|
491
|
+
}, ref: at, value: i }),
|
|
492
|
+
/* @__PURE__ */ o(N, { "aria-label": "Apply image", onClick: () => Y(), onMouseDown: lt, variant: "tertiary", children: /* @__PURE__ */ o(P, { name: "Check" }) })
|
|
447
493
|
] }),
|
|
448
|
-
/* @__PURE__ */
|
|
449
|
-
label: t,
|
|
450
|
-
width: c
|
|
451
|
-
}) => /* @__PURE__ */ n(L, { "aria-label": `${t} image`, "data-active": ct === c, onClick: () => i(c), onMouseDown: rt, variant: "tertiary", children: t }, t)) }),
|
|
452
|
-
/* @__PURE__ */ n(L, { "aria-label": "Remove image", onClick: () => J(), onMouseDown: k, variant: "tertiary", children: /* @__PURE__ */ n(y, { name: "Trash", variant: "danger" }) })
|
|
494
|
+
/* @__PURE__ */ o(N, { "aria-label": "Remove image", onClick: () => ht(), onMouseDown: lt, variant: "tertiary", children: /* @__PURE__ */ o(P, { name: "Trash", variant: "danger" }) })
|
|
453
495
|
] })
|
|
454
496
|
] })
|
|
455
497
|
] });
|
|
456
|
-
},
|
|
498
|
+
}, Be = se({
|
|
457
499
|
name: "solibo-editor",
|
|
458
500
|
namespace: "Editor",
|
|
459
|
-
nodes: [
|
|
501
|
+
nodes: [zt, Bt, Wt, Kt, ot],
|
|
460
502
|
onError(s) {
|
|
461
503
|
throw s;
|
|
462
504
|
},
|
|
463
505
|
theme: {
|
|
464
|
-
link:
|
|
506
|
+
link: h.link,
|
|
465
507
|
list: {
|
|
466
|
-
ol:
|
|
467
|
-
ul:
|
|
508
|
+
ol: h.list,
|
|
509
|
+
ul: h.list
|
|
468
510
|
},
|
|
469
|
-
paragraph:
|
|
511
|
+
paragraph: h.paragraph,
|
|
470
512
|
text: {
|
|
471
|
-
bold:
|
|
472
|
-
italic:
|
|
473
|
-
underline:
|
|
513
|
+
bold: h.bold,
|
|
514
|
+
italic: h.italic,
|
|
515
|
+
underline: h.underline
|
|
474
516
|
}
|
|
475
517
|
}
|
|
476
518
|
});
|
|
477
|
-
function
|
|
519
|
+
function He({
|
|
478
520
|
autofocus: s,
|
|
479
521
|
content: r = "",
|
|
480
522
|
lastEmittedContentRef: e
|
|
481
523
|
}) {
|
|
482
|
-
const [
|
|
483
|
-
return
|
|
484
|
-
e.current !== r &&
|
|
485
|
-
const
|
|
486
|
-
|
|
524
|
+
const [c] = wt();
|
|
525
|
+
return F(() => {
|
|
526
|
+
e.current !== r && c.update(() => {
|
|
527
|
+
const m = new DOMParser().parseFromString(r, "text/html"), p = Ut(c, m), n = le();
|
|
528
|
+
n.clear().select(), Ct(p), s ? n.selectEnd() : Pt(null);
|
|
487
529
|
});
|
|
488
|
-
}, [s, r,
|
|
530
|
+
}, [s, r, c, e]), null;
|
|
489
531
|
}
|
|
490
|
-
const
|
|
532
|
+
const gr = ({
|
|
491
533
|
autofocus: s = !1,
|
|
492
534
|
autolink: r = !1,
|
|
493
535
|
content: e,
|
|
494
|
-
disabled:
|
|
495
|
-
errorMessage:
|
|
496
|
-
fill:
|
|
497
|
-
files:
|
|
498
|
-
inline:
|
|
499
|
-
inlineImages:
|
|
500
|
-
invalid:
|
|
501
|
-
isSubmitting:
|
|
502
|
-
maxRows:
|
|
503
|
-
minRows:
|
|
504
|
-
onChange:
|
|
505
|
-
onFilesChange:
|
|
506
|
-
onInlineImagesChange:
|
|
507
|
-
onSubmit:
|
|
508
|
-
onUpload:
|
|
536
|
+
disabled: c = !1,
|
|
537
|
+
errorMessage: g,
|
|
538
|
+
fill: m = !1,
|
|
539
|
+
files: p,
|
|
540
|
+
inline: n = !1,
|
|
541
|
+
inlineImages: u,
|
|
542
|
+
invalid: f = !1,
|
|
543
|
+
isSubmitting: $ = !1,
|
|
544
|
+
maxRows: A = 12,
|
|
545
|
+
minRows: L = 1,
|
|
546
|
+
onChange: S,
|
|
547
|
+
onFilesChange: w,
|
|
548
|
+
onInlineImagesChange: i,
|
|
549
|
+
onSubmit: l,
|
|
550
|
+
onUpload: b,
|
|
509
551
|
placeholder: G,
|
|
510
552
|
required: Z = !1,
|
|
511
|
-
resizable:
|
|
512
|
-
submitLabel:
|
|
553
|
+
resizable: U = !1,
|
|
554
|
+
submitLabel: z = "Submit"
|
|
513
555
|
}) => {
|
|
514
|
-
const
|
|
515
|
-
|
|
516
|
-
const
|
|
517
|
-
if (!
|
|
518
|
-
if (
|
|
519
|
-
|
|
556
|
+
const M = ce(), Q = x(void 0), q = x(null), [at, tt] = k(!1), [T, E] = k(!1), [st, V] = k([]), [X, lt] = k([]), R = x(/* @__PURE__ */ new Map()), _ = p ?? st, v = u ?? X;
|
|
557
|
+
F(() => {
|
|
558
|
+
const t = q.current;
|
|
559
|
+
if (!t) return;
|
|
560
|
+
if (!U || m) {
|
|
561
|
+
t.style.removeProperty("height"), tt(!1);
|
|
520
562
|
return;
|
|
521
563
|
}
|
|
522
|
-
const a = () =>
|
|
523
|
-
return
|
|
564
|
+
const a = () => tt(t.style.height !== ""), d = new MutationObserver(a);
|
|
565
|
+
return d.observe(t, {
|
|
524
566
|
attributes: !0,
|
|
525
567
|
attributeFilter: ["style"]
|
|
526
|
-
}), a(), () =>
|
|
527
|
-
}, [
|
|
528
|
-
const
|
|
529
|
-
|
|
530
|
-
},
|
|
531
|
-
|
|
532
|
-
}, [
|
|
533
|
-
const a =
|
|
534
|
-
const
|
|
535
|
-
return
|
|
568
|
+
}), a(), () => d.disconnect();
|
|
569
|
+
}, [m, U]);
|
|
570
|
+
const W = (t) => {
|
|
571
|
+
p === void 0 && V(t), w == null || w(t);
|
|
572
|
+
}, K = C((t) => {
|
|
573
|
+
u === void 0 && lt(t), i == null || i(t);
|
|
574
|
+
}, [u, i]), et = C((t) => {
|
|
575
|
+
const a = t.map((d) => {
|
|
576
|
+
const D = `pasted-${crypto.randomUUID()}`, I = URL.createObjectURL(d);
|
|
577
|
+
return R.current.set(D, I), {
|
|
536
578
|
image: {
|
|
537
|
-
alt:
|
|
538
|
-
soliboDocumentSlot:
|
|
539
|
-
src:
|
|
579
|
+
alt: d.name,
|
|
580
|
+
soliboDocumentSlot: D,
|
|
581
|
+
src: I
|
|
540
582
|
},
|
|
541
583
|
pending: {
|
|
542
|
-
file:
|
|
543
|
-
slot:
|
|
584
|
+
file: d,
|
|
585
|
+
slot: D
|
|
544
586
|
}
|
|
545
587
|
};
|
|
546
588
|
});
|
|
547
|
-
return
|
|
548
|
-
pending:
|
|
549
|
-
}) =>
|
|
550
|
-
image:
|
|
551
|
-
}) =>
|
|
552
|
-
}, [
|
|
553
|
-
|
|
554
|
-
const a =
|
|
555
|
-
a && URL.revokeObjectURL(a),
|
|
556
|
-
}, [
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
}, []),
|
|
560
|
-
const
|
|
561
|
-
|
|
562
|
-
|
|
589
|
+
return K([...v, ...a.map(({
|
|
590
|
+
pending: d
|
|
591
|
+
}) => d)]), a.map(({
|
|
592
|
+
image: d
|
|
593
|
+
}) => d);
|
|
594
|
+
}, [v, K]), Y = C((t) => {
|
|
595
|
+
K(v.filter((d) => d.slot !== t));
|
|
596
|
+
const a = R.current.get(t);
|
|
597
|
+
a && URL.revokeObjectURL(a), R.current.delete(t);
|
|
598
|
+
}, [v, K]);
|
|
599
|
+
F(() => () => {
|
|
600
|
+
R.current.forEach((t) => URL.revokeObjectURL(t)), R.current.clear();
|
|
601
|
+
}, []), F(() => {
|
|
602
|
+
const t = new Set(v.map((a) => a.slot));
|
|
603
|
+
R.current.forEach((a, d) => {
|
|
604
|
+
t.has(d) || (URL.revokeObjectURL(a), R.current.delete(d));
|
|
563
605
|
});
|
|
564
|
-
}, [
|
|
565
|
-
const
|
|
606
|
+
}, [v]);
|
|
607
|
+
const ht = (t) => {
|
|
566
608
|
if (typeof DataTransfer < "u") {
|
|
567
609
|
const a = new DataTransfer();
|
|
568
|
-
return
|
|
610
|
+
return t.forEach((d) => a.items.add(d)), a.files;
|
|
569
611
|
}
|
|
570
|
-
return Object.assign([...
|
|
571
|
-
item: (a) =>
|
|
612
|
+
return Object.assign([...t], {
|
|
613
|
+
item: (a) => t[a] ?? null
|
|
572
614
|
});
|
|
573
|
-
},
|
|
615
|
+
}, gt = async () => {
|
|
574
616
|
try {
|
|
575
|
-
|
|
617
|
+
_.length > 0 && await (b == null ? void 0 : b(ht(_))), await (l == null ? void 0 : l()), _.length > 0 && W([]);
|
|
576
618
|
} catch {
|
|
577
619
|
return;
|
|
578
620
|
}
|
|
579
|
-
},
|
|
580
|
-
|
|
621
|
+
}, B = (t) => {
|
|
622
|
+
t.preventDefault(), t.stopPropagation();
|
|
581
623
|
};
|
|
582
|
-
return /* @__PURE__ */
|
|
583
|
-
|
|
584
|
-
}, onDragOver: (
|
|
585
|
-
|
|
586
|
-
}, onDragLeave: (
|
|
587
|
-
|
|
588
|
-
}, onDropCapture: (
|
|
589
|
-
var
|
|
590
|
-
const a = (
|
|
591
|
-
a != null && a.length && (
|
|
592
|
-
}, onDrop: (
|
|
593
|
-
|
|
624
|
+
return /* @__PURE__ */ O("div", { className: nt(h.field, m && h.fill), "data-max-rows": A, "data-min-rows": L, onDragEnter: (t) => {
|
|
625
|
+
B(t), E(!!w);
|
|
626
|
+
}, onDragOver: (t) => {
|
|
627
|
+
B(t), E(!!w);
|
|
628
|
+
}, onDragLeave: (t) => {
|
|
629
|
+
B(t), E(!1);
|
|
630
|
+
}, onDropCapture: (t) => {
|
|
631
|
+
var d;
|
|
632
|
+
const a = (d = t.dataTransfer) == null ? void 0 : d.files;
|
|
633
|
+
a != null && a.length && (B(t), (w || b) && W([..._, ...Array.from(a)]), E(!1));
|
|
634
|
+
}, onDrop: (t) => {
|
|
635
|
+
t.preventDefault(), E(!1);
|
|
594
636
|
}, "data-component": "editor", children: [
|
|
595
|
-
|
|
596
|
-
/* @__PURE__ */
|
|
597
|
-
"--editor-max-height": `calc(${
|
|
598
|
-
"--editor-min-height": `calc(${
|
|
599
|
-
}, children: /* @__PURE__ */
|
|
600
|
-
!
|
|
601
|
-
|
|
637
|
+
U === "top" && !m && /* @__PURE__ */ o(Ue, { editableRef: q }),
|
|
638
|
+
/* @__PURE__ */ o("div", { className: nt(h.editor, m && h["fill-editor"], U === !0 && !m && h.resizable, U && !m && at && h.resized, f && h.invalid, _.length > 0 && h["has-files"]), style: {
|
|
639
|
+
"--editor-max-height": `calc(${A * 1.25}em + (2 * var(--scale-8)))`,
|
|
640
|
+
"--editor-min-height": `calc(${L * 1.25}em + (2 * var(--scale-8)))`
|
|
641
|
+
}, children: /* @__PURE__ */ O(Vt, { contentEditable: null, extension: Be, children: [
|
|
642
|
+
!n && /* @__PURE__ */ o(ze, { onInlineImageRemove: Y, onFilesSelected: b || w ? (t) => {
|
|
643
|
+
W([..._, ...Array.from(t)]);
|
|
602
644
|
} : void 0 }),
|
|
603
|
-
/* @__PURE__ */
|
|
604
|
-
!
|
|
605
|
-
|
|
606
|
-
s && /* @__PURE__ */
|
|
607
|
-
r && /* @__PURE__ */
|
|
608
|
-
/* @__PURE__ */
|
|
609
|
-
|
|
610
|
-
e !== void 0 && /* @__PURE__ */
|
|
611
|
-
/* @__PURE__ */
|
|
612
|
-
/* @__PURE__ */
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
const
|
|
645
|
+
/* @__PURE__ */ o("div", { className: nt(h.content, T && h.dragging), children: /* @__PURE__ */ o(te, { contentEditable: /* @__PURE__ */ o(Zt, { ref: q, "aria-placeholder": G ?? "", ariaErrorMessage: f && g ? M : void 0, ariaInvalid: f || void 0, ariaRequired: Z || void 0, placeholder: () => G ? /* @__PURE__ */ o("div", { className: h.placeholder, children: G }) : null }), ErrorBoundary: qt }) }),
|
|
646
|
+
!n && l && /* @__PURE__ */ o("div", { className: h.submit, children: /* @__PURE__ */ o(N, { "aria-label": z, "data-cy": "toolbar-submit-button", disabled: c, icon: "PaperPlaneTilt", isLoading: $, onClick: () => void gt(), variant: "primary", children: /* @__PURE__ */ o("span", { children: z }) }) }),
|
|
647
|
+
_.length > 0 && /* @__PURE__ */ o("div", { "aria-label": "Files to upload", className: h.files, role: "region", children: _.map((t, a) => /* @__PURE__ */ o(ue, { deleteAccessibleLabel: `Remove ${t.name} from upload queue`, name: t.name, onDelete: () => W(_.filter((d, D) => D !== a)) }, `${t.name}-${t.size}-${t.lastModified}-${a}`)) }),
|
|
648
|
+
s && /* @__PURE__ */ o(jt, {}),
|
|
649
|
+
r && /* @__PURE__ */ o(Gt, { matchers: $e }),
|
|
650
|
+
/* @__PURE__ */ o(Xt, {}),
|
|
651
|
+
i && /* @__PURE__ */ o(Te, { createImages: et, onRemove: Y }),
|
|
652
|
+
e !== void 0 && /* @__PURE__ */ o(He, { autofocus: s, content: e, lastEmittedContentRef: Q }),
|
|
653
|
+
/* @__PURE__ */ o(Yt, { validateUrl: It }),
|
|
654
|
+
/* @__PURE__ */ o(Jt, {}),
|
|
655
|
+
S && /* @__PURE__ */ o(Qt, { onChange: (t, a) => {
|
|
656
|
+
t.read(() => {
|
|
657
|
+
const d = $t(a, null), D = vt(d, {
|
|
616
658
|
allowedAttributes: {
|
|
617
|
-
...
|
|
618
|
-
img: [...
|
|
659
|
+
...vt.defaults.allowedAttributes,
|
|
660
|
+
img: [...vt.defaults.allowedAttributes.img ?? [], "data-solibo-document-id", "data-solibo-document-slot"]
|
|
619
661
|
},
|
|
620
662
|
allowedTags: ["a", "b", "br", "i", "img", "li", "ol", "p", "u", "ul"]
|
|
621
663
|
});
|
|
622
|
-
|
|
664
|
+
Q.current = D, S(D);
|
|
623
665
|
});
|
|
624
666
|
} })
|
|
625
667
|
] }) }),
|
|
626
|
-
|
|
668
|
+
f && g && /* @__PURE__ */ o("div", { className: h.error, id: M, children: g })
|
|
627
669
|
] });
|
|
628
670
|
};
|
|
629
671
|
export {
|
|
630
|
-
|
|
672
|
+
gr as Editor
|
|
631
673
|
};
|
package/dist/tokens.json
CHANGED