@layers-app/editor 0.5.5-optimization → 0.5.6-optimization
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/README.md +19 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/dist/{layers.EKDSoJm1.js → layers.7jmq6tBR.js} +8 -8
- package/dist/{layers.CEMW9z_P.js → layers.B90YwJga.js} +1 -1
- package/dist/{layers.Cwao1pOZ.js → layers.C03OvlLb.js} +2 -2
- package/dist/{layers.B10sB-Vy.js → layers.CJiIq6YQ.js} +1 -1
- package/dist/{layers.BwyONivc.js → layers.CXffIp2y.js} +5 -5
- package/dist/{layers.eLiGm-eZ.js → layers.CZPeYQ9g.js} +2 -2
- package/dist/{layers.C69TrYD7.js → layers.CZ_Lt7IL.js} +1 -1
- package/dist/{layers.ahDFHQXD.js → layers.Ci1-qkbn.js} +3 -3
- package/dist/{layers.hgliNTDV.js → layers.Cnm-pECN.js} +1 -1
- package/dist/{layers.BDsvvINb.js → layers.D6d62qQ_.js} +6 -6
- package/dist/{layers.D0Z-zLAV.js → layers.Dev6Yrwi.js} +3 -3
- package/dist/{layers.CzNz0Zya.js → layers.Dgok89qX.js} +1 -1
- package/dist/{layers.BFJ7oQiY.js → layers.Dq3o7sh3.js} +5 -5
- package/dist/{layers.C2lacXcg.js → layers.Duy8YzsH.js} +6 -6
- package/package.json +1 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var dn=Object.defineProperty;var un=(e,t,n)=>t in e?dn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ae=(e,t,n)=>un(e,typeof t!="symbol"?t+"":t,n);const p=require("react"),H=require("@lexical/react/LexicalComposerContext"),ve=require("@lexical/selection"),K=require("@lexical/utils"),a=require("lexical"),s=require("react/jsx-runtime"),et=require("react-dom"),de=require("react-i18next"),Ee=require("@lexical/code"),c=require("@mantine/core"),V=require("@tabler/icons-react"),Ve=require("@layers-app/shared"),d=require("./layers.CEMW9z_P.js"),G=require("./layers.Cwao1pOZ.js"),D=require("./layers.CzNz0Zya.js"),Fe=require("@lexical/file"),Ae=require("@lexical/markdown"),An=require("@lexical/yjs"),ge=require("./layers.eLiGm-eZ.js"),Lt=require("@lexical/clipboard"),Xe=require("@lexical/rich-text"),je=require("lodash-es"),_e=require("@lexical/react/LexicalTypeaheadMenuPlugin"),mn=require("@lexical/react/LexicalAutoEmbedPlugin"),Ue=require("@lexical/react/LexicalHorizontalRuleNode"),He=require("./layers.B10sB-Vy.js"),ot=require("./layers.hgliNTDV.js"),ue=require("@lexical/link"),gn=require("@mantine/hooks"),pn=require("@lexical/react/LexicalLinkPlugin"),fn=require("@lexical/react/LexicalMarkdownShortcutPlugin"),se=require("@lexical/table");require("@lexical/hashtag");require("@lexical/mark");require("@lexical/overflow");const hn=require("react-selecto"),Cn=require("@lexical/react/useLexicalEditable"),bn=require("@lexical/react/LexicalTableOfContentsPlugin"),En=require("@lexical/react/LexicalTreeView"),tt=[".ContentEditable__root > *:not(ol):not(ul):not(.dsd__theme__table-scrollable-wrapper):not(.editor-image:not(:has(button))):not(div.video-container):not(div.editor-iframe)",".dsd__theme__table-scrollable-wrapper > table",".editor-image > div.resizable-container > div.resizable-container__inner",".video-container > div.resizable-container > div.resizable-container__inner",".editor-iframe > div.resizable-container > div.resizable-container__inner"],it=[...tt,"ul.dsd__theme__ul > li:not(.dsd__theme__nestedListItem)","ol.dsd__theme__ol1 > li:not(.dsd__theme__nestedListItem)","ol.dsd__theme__ol2 > li:not(.dsd__theme__nestedListItem)","ol.dsd__theme__ol3 > li:not(.dsd__theme__nestedListItem)","ol.dsd__theme__ol4 > li:not(.dsd__theme__nestedListItem)","ol.dsd__theme__ol5 > li:not(.dsd__theme__nestedListItem)"],xn=[...tt,"ul.dsd__theme__ul:not(.dsd__theme__nestedListItem ul) > li:not(.dsd__theme__nestedListItem)","ul.dsd__theme__ul:not(.dsd__theme__nestedListItem ul) > li.dsd__theme__nestedListItem","ol.dsd__theme__ol1:not(.dsd__theme__nestedListItem ol) > li:not(.dsd__theme__nestedListItem)","ol.dsd__theme__ol1:not(.dsd__theme__nestedListItem ol) > li.dsd__theme__nestedListItem"],Nn=[...tt,"ul.dsd__theme__ul:not(.dsd__theme__nestedListItem ul) > li:not(.dsd__theme__nestedListItem)","ul.dsd__theme__ul:not(.dsd__theme__nestedListItem ul) > li.dsd__theme__nestedListItem"],Tn=[...tt,"ol.dsd__theme__ol1:not(.dsd__theme__nestedListItem ol) > li:not(.dsd__theme__nestedListItem)","ol.dsd__theme__ol1:not(.dsd__theme__nestedListItem ol) > li.dsd__theme__nestedListItem"],Ot=e=>{const t=document.querySelectorAll(".selected-block");if(t.length===0)return;setTimeout(()=>{e.update(()=>{const o=a.$createNodeSelection();t.forEach(r=>{const l=a.$getNearestNodeFromDOMNode(r);l&&D.addNodeAndChildrenToSelection(l,o)}),a.$setSelection(o)})},100);const n=o=>{const r=!!document.querySelector(".mantine-Menu-dropdown");if(o.button===2||r){o.preventDefault();return}const l=o.target;l.closest(".draggable-block-menu")||l.closest(".mantine-Menu-dropdown")||(t.forEach(A=>{Ge(A)}),document.body.removeEventListener("mousedown",n))};setTimeout(()=>{document.body.addEventListener("mousedown",n)}),e.update(()=>{const o=document.querySelector(".ContentEditable__root");o==null||o.focus({preventScroll:!0})})},Sn={container:document.body,getScrollPosition:()=>[document.documentElement.scrollLeft,document.documentElement.scrollTop],throttleTime:30,threshold:0},ht=(e,t,n)=>function o(r){if(r instanceof KeyboardEvent&&r.key!=="Backspace"&&r.key!=="Delete"&&r.key!=="Escape")return!1;const l=r.target;l.closest(".draggable-block-menu")||l.closest(".toolbar")||l.closest(".mantine-Menu-dropdown")||(e==null||e.classList.remove(t),n.update(()=>{l.closest(".ContentEditable__root")||a.$setSelection(null),r instanceof KeyboardEvent&&t==="selected-all-document"&&r.key!=="Escape"&&n.update(()=>{var i;(i=a.$getRoot().getFirstChild())==null||i.selectStart()}),r instanceof KeyboardEvent&&t==="selected-all-document"&&r.key==="Escape"&&n.blur()}),setTimeout(()=>{document.body.removeEventListener("mousedown",o),document.removeEventListener("keydown",o)}))},Bt=(e,t)=>{var n,o;if(t&&t.block){const{block:r,isCreateEventListener:l}=t,A="selected-block";if(r.classList.add(A),r.classList.remove("selected-block-hidden"),l){const i=ht(r,A,e);document.body.addEventListener("mousedown",i),document.addEventListener("keydown",i)}}else{const r="selected-all-document",l=ht(e._rootElement,r,e);document.body.addEventListener("mousedown",l),document.addEventListener("keydown",l),(n=e._rootElement)==null||n.classList.add(r),(o=e._rootElement)==null||o.classList.remove("selected-block-hidden")}},Ge=e=>{e.classList.remove("selected-block"),e.classList.add("selected-block-hidden")},yn=e=>{e.querySelectorAll(".selected-block").forEach(n=>{Ge(n)})},wn=(e,t,n,o,r)=>{var l;if(((l=e.selected[0])==null?void 0:l.tagName)==="LI"){let A=e.added[0];if(!e.added.length&&e.beforeSelected.length>=2){const g=e.beforeSelected[0],h=e.beforeSelected[1],C=g.getBoundingClientRect().top;h.getBoundingClientRect().top<C?A=Dt(e.selected[0]):A=e.selected[0]}let m=(A==null?void 0:A.classList.contains("dsd__theme__nestedListItem"))&&e.added.length===0?1:0,u=A,f=null;for(;u;){const g=u.tagName.toUpperCase();if(g==="UL"||g==="OL")f||(f=g.toLowerCase()),m++;else if(g!=="LI")break;u=u.parentElement}if(m!==0&&n.depth!==m){if(!f)return;o({depth:m,targets:In(m,f)}),setTimeout(()=>{r==null||r.findSelectableTargets(),r==null||r.setSelectedTargets(e.selected)})}}else!n.depth&&e.added.length&&(o({depth:999,targets:xn}),setTimeout(()=>{r==null||r.findSelectableTargets(),r==null||r.setSelectedTargets(e.selected)}));e.added.forEach(A=>{Bt(t,{block:A,isCreateEventListener:!1})}),e.removed.forEach(A=>{Ge(A)})},ke=()=>{const e=document.querySelector("div.ContentEditable__root"),t=(e==null?void 0:e.querySelector(".selected-block"))!==null,n=e==null?void 0:e.classList.contains("selected-all-document");return{hasSelectedBlock:t,selectedAllDocument:n}},Ct=(e,t,n,o)=>{if(e==="ol"){const r=Array.from({length:t},(m,u)=>`ol.dsd__theme__ol${u+1}`).join(" ");let l="";t===1&&(l=":not(.dsd__theme__nestedListItem ol)");const A=`${r}${l} >`;return n?`${A} li.dsd__theme__nestedListItem`:`${A} li:not(.dsd__theme__nestedListItem)`}else{const r=" ul".repeat(t-1).trim(),l=" ul".repeat(t).trim(),i=`ul.dsd__theme__ul${r?` ${r}`:""}:not(.dsd__theme__nestedListItem ${l}) >`;let m=`${i} li:not(.dsd__theme__nestedListItem)`;return n?`${i} li.dsd__theme__nestedListItem`:m}};function In(e,t){if(e<1)throw new Error("Depth must be >= 1");const n=[];if(n.push(Ct(t,e,!1)),n.push(Ct(t,e,!0)),t==="ol"){if(e>1)for(let o=1;o<e;o++)n.push(`ol.dsd__theme__ol${o} > li:not(.dsd__theme__nestedListItem)`);return[...Nn,...n]}else if(t==="ul"){if(e>1)for(let o=1;o<e;o++)n.push(`ul.dsd__theme__ul${" ul".repeat(o-1)}:not(.dsd__theme__nestedListItem ${"ul ".repeat(o).trim()}) > li:not(.dsd__theme__nestedListItem):not(:has(ul))`);return[...Tn,...n]}return[...it,...n]}function Dt(e){const t=e.querySelector("ul, ol");let n=t==null?void 0:t.lastElementChild;for(;n&&n.tagName!=="LI";)n=n.previousElementSibling;return n!=null&&n.classList.contains("dsd__theme__nestedListItem")?Dt(n)??n:n}function Rn(e){var r;const t=e.getAttribute("open");return((r=e.firstElementChild)==null?void 0:r.tagName)==="SPAN"?{node:null}:{node:lt(t!==null)}}class Se extends a.ElementNode{constructor(n,o){super(o);ae(this,"__open");this.__open=n}static getType(){return"collapsible-container"}static clone(n){return new Se(n.__open,n.__key)}createDOM(n,o){let r;const l=document.createElement("details");return l.open=this.__open,l.addEventListener("toggle",()=>{o.getEditorState().read(()=>this.getOpen())!==l.open&&o.update(()=>this.toggleOpen())}),r=l,r.classList.add("Collapsible__container"),r}updateDOM(n,o){const r=this.__open;return n.__open!==r&&(o.open=this.__open),!1}static importDOM(){return{details:n=>({conversion:Rn,priority:1})}}static importJSON(n){return lt(n.open)}exportDOM(){const n=document.createElement("details");return n.classList.add("Collapsible__container"),this.__open&&n.setAttribute("open",""),{element:n}}exportJSON(){return{...super.exportJSON(),open:this.__open,type:"collapsible-container",version:1}}setOpen(n){const o=this.getWritable();o.__open=n}getOpen(){return this.getLatest().__open}toggleOpen(){this.setOpen(!this.getOpen())}}function lt(e){return new Se(e)}function ce(e){return e instanceof Se}function Mn(e){return{node:at()}}class ye extends a.ElementNode{static getType(){return"collapsible-content"}static clone(t){return new ye(t.__key)}createDOM(t,n){const o=document.createElement("div");return o.classList.add("Collapsible__content"),o}updateDOM(t,n){return!1}static importDOM(){return{div:t=>t.hasAttribute("data-lexical-collapsible-content")?{conversion:Mn,priority:2}:null}}exportDOM(){const t=document.createElement("div");return t.classList.add("Collapsible__content"),t.setAttribute("data-lexical-collapsible-content","true"),{element:t}}static importJSON(t){return at()}isShadowRoot(){return!0}exportJSON(){return{...super.exportJSON(),type:"collapsible-content",version:1}}}function at(){return new ye}function Ke(e){return e instanceof ye}function kn(e){return{node:ct()}}class we extends a.ElementNode{static getType(){return"collapsible-title"}static clone(t){return new we(t.__key)}createDOM(t,n){const o=document.createElement("summary");return o.classList.add("Collapsible__title"),ge.IS_SAFARI&&(o.style.cursor="pointer"),o}updateDOM(t,n){return!1}static importDOM(){return{summary:t=>({conversion:kn,priority:1})}}static importJSON(t){return ct()}exportJSON(){return{...super.exportJSON(),type:"collapsible-title",version:1}}collapseAtStart(t){return this.getParentOrThrow().insertBefore(this),!0}insertNewAfter(t,n=!0){const o=this.getParentOrThrow();if(!ce(o))throw new Error("CollapsibleTitleNode expects to be child of CollapsibleContainerNode");if(o.getOpen()){const r=this.getNextSibling();if(!Ke(r))throw new Error("CollapsibleTitleNode expects to have CollapsibleContentNode sibling");const l=r.getFirstChild();if(a.$isElementNode(l))return l;{const A=a.$createParagraphNode();return r.append(A),A}}else{const r=a.$createParagraphNode();return o.insertAfter(r,n),r}}}function ct(){return new we}function Le(e){return e instanceof we}const jn=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5),Pt=[{name:"alert",color:"rgb(250, 82, 82)",icon:s.jsx(V.IconExclamationCircle,{size:16}),emoji:"❗"},{name:"success",color:"rgb(18, 184, 134)",icon:s.jsx(V.IconCheck,{size:16}),emoji:"✅"},{name:"warning",color:"rgb(242, 188, 57)",icon:s.jsx(V.IconAlertTriangle,{size:16}),emoji:"⚠️"}],zt=e=>e.mode==="callout",Zt="calc(50% - 25px) calc(50% - 25px)",Ln=({setIsMenuOpen:e,onCodeLanguageSelect:t,codeLanguage:n,CODE_LANGUAGE_OPTIONS:o})=>(p.useEffect(()=>()=>{document.documentElement.classList.remove("disable-scroll"),e(!1)},[]),s.jsx(c.Select,{onChange:r=>t(r),data:o.map(([r,l])=>({value:r,label:l})),searchable:!0,defaultValue:n,allowDeselect:!1,style:{width:140},className:"dropdown-select-language",checkIconPosition:"right",rightSection:s.jsx(V.IconChevronDown,{style:{width:14,height:14,marginLeft:2}}),maxDropdownHeight:400,variant:"default",styles:{dropdown:{overflow:"auto",zIndex:1e3}}}));function On({codeLanguage:e,CODE_LANGUAGE_OPTIONS:t,onCodeLanguageSelect:n,onCollapsibleCode:o,copyToClipboard:r,pointerEvents:l,showExpandButton:A,isCollapsed:i}){const[m,u]=p.useState(!1),{t:f}=de.useTranslation(),g=()=>{u(h=>{const C=document.documentElement;return h?C.classList.remove("disable-scroll"):C.classList.add("disable-scroll"),!h})};return s.jsxs(c.Menu,{shadow:"md",styles:{dropdown:{overflow:"auto",zIndex:1e3}},children:[s.jsx(c.Menu.Target,{children:s.jsx(c.Button,{style:{pointerEvents:l},radius:"sm",h:25,px:5,size:"xs",variant:"default",children:s.jsx(V.IconMenu2,{size:18})})}),s.jsxs(c.Menu.Dropdown,{children:[s.jsx(c.Menu.Item,{style:{position:"relative",padding:0},disabled:m,closeMenuOnClick:!1,onClick:g,children:s.jsx(Ln,{setIsMenuOpen:u,codeLanguage:e,onCodeLanguageSelect:n,CODE_LANGUAGE_OPTIONS:t})}),s.jsx(c.Menu.Item,{rightSection:s.jsx(V.IconCopy,{size:14}),onClick:r,children:s.jsx(c.Text,{size:"12px",children:f("editor.menu.main.code.copy")})}),A&&s.jsx(c.Menu.Item,{onClick:o,rightSection:i?s.jsx(V.IconArrowsDiagonal,{size:14}):s.jsx(V.IconArrowsDiagonalMinimize2,{size:14}),children:s.jsx(c.Text,{size:"12px",children:f(i?"editor.menu.main.code.collapsible.hidden":"editor.menu.main.code.collapsible.expand")})})]})]})}function vt({onClick:e,ariaLabel:t,children:n,...o}){return s.jsx(c.Button,{radius:"sm",h:25,px:5,mr:3,size:"xs",variant:"default",onClick:e,"aria-label":t,...o,children:n})}const Bn={copy:V.IconCopy,success:V.IconCheck,loader:V.IconCircleDashed};function Dn({copyToClipboard:e,pointerEvents:t}){const[n,o]=p.useState("copy"),{t:r}=de.useTranslation();async function l(){await e()&&(o("loader"),setTimeout(()=>{o("success"),setTimeout(()=>{o("copy")},1e3)},1e3))}const A=Bn[n];return s.jsxs(vt,{style:{pointerEvents:t},onClick:l,ariaLabel:"copy",children:[s.jsx(c.Text,{mr:"4px",size:"12px",children:r("editor.menu.main.code.copy")}),s.jsx(A,{size:14})]})}function dt(e,t,n){const o=p.useRef(null);return o.current=e,p.useMemo(()=>je.debounce((...r)=>{o.current&&o.current(...r)},t,{maxWait:n}),[t,n])}const Ut={json:"JSON",...Ee.CODE_LANGUAGE_FRIENDLY_NAME_MAP};function Pn({anchorElem:e}){var B,z;const[t]=H.useLexicalComposerContext(),{t:n}=de.useTranslation(),[o,r]=p.useState(""),[l,A]=p.useState(!1),[i,m]=p.useState(null),[u,f]=p.useState(null),[g,h]=p.useState({right:"0",top:"0"}),C=p.useRef(null),S=p.useRef(null),y=(B=J())==null?void 0:B.classList.contains("dsd__theme__callout-wrapper"),x=S.current&&((z=S.current)==null?void 0:z.offsetWidth)<=300,j=S.current&&S.current.scrollHeight>280,R=l?"auto":"none",Q=T();function J(){return S.current}function T(){const E=[];for(const[L,U]of Object.entries(Ut))E.push([L,U]);return E.sort(([L],[U])=>L.localeCompare(U)),E}const I=dt(E=>{const{lexicalDOMNode:L,isOutside:U}=D.getMouseInfo(E,"code.dsd__theme__code, div.dsd__theme__callout-wrapper",["div.dropdown-select-language","div.mantine-Select-option","div.action-menu-container","div.mantine-Menu-dropdown"]);if(U){A(!1);return}if(!L)return;S.current=L;let $=null,X="";if(t.update(()=>{const q=a.$getNearestNodeFromDOMNode(L);q&&m(q.__key),d.$isExtendedCodeNode(q)?($=q,X=$.getLanguage()||"",r(X?Ee.CODE_LANGUAGE_MAP[X]||X:"Выберите форматирование"),f($.__isCollapsed)):d.$isCalloutWrapperNode(q)&&($=q)}),$){const{y:q,right:b,left:N}=e.getBoundingClientRect(),{y:w,right:k,left:M}=L.getBoundingClientRect();A(!0),C.current&&(C.current.style.visibility="visible");const Y=w-q,F=b-k,_=M-N;h(()=>({right:`${F}px`,left:`${_}px`,top:`${Y}px`}))}},50,500);p.useEffect(()=>K.mergeRegister(t.registerMutationListener(Ee.CodeNode,E=>{t.getEditorState().read(()=>{for(const[L,U]of E)U==="destroyed"&&A(!1)})}),t.registerUpdateListener(({dirtyElements:E,dirtyLeaves:L})=>{l&&(E.size>0||L.size>0)&&t.getEditorState().read(()=>{const U=D.getCurrentElement();(U==null?void 0:U.__type)!=="extend-code"&&(U==null?void 0:U.__type)!=="code-highlight"&&C.current&&(C.current.style.visibility="hidden")})})),[t,l]),p.useEffect(()=>(document.addEventListener("mousemove",I),()=>{A(!1),I.cancel(),document.removeEventListener("mousemove",I)}),[I]);const O=p.useCallback(()=>{f(E=>!E),t.update(()=>{if(i!==null){const E=a.$getNodeByKey(i);d.$isExtendedCodeNode(E)&&E.toggleCodeState()}})},[t,i]),P=p.useCallback(E=>{t.update(()=>{if(i!==null){const L=a.$getNodeByKey(i);if(d.$isExtendedCodeNode(L)){L.setLanguage(E),L.selectStart();const U=L.getLanguage()||"";r(U?Ee.CODE_LANGUAGE_MAP[U]||U:"")}}})},[t,i]),v=E=>{t.update(()=>{const L=a.$getNodeByKey(i);d.$isCalloutWrapperNode(L)&&t.update(()=>{const U=zt(E);L.setType(U?E.meta.type:void 0),L.setBackgroundColor(E.value),A(!1)})})};async function Z(){const E=J();if(!E)return!1;let L="";t.update(()=>{const U=a.$getNearestNodeFromDOMNode(E);d.$isExtendedCodeNode(U)&&(L=U.getTextContent());const $=a.$getSelection();a.$setSelection($)});try{return await navigator.clipboard.writeText(L),!0}catch(U){return console.error("Failed to copy: ",U),!1}}return y?s.jsx("div",{className:`action-menu-container callout-action ${l?"visible":""}`,ref:C,style:{right:g.right,top:g.top,pointerEvents:R},children:l&&s.jsx(Ve.NewColorPicker,{data:{callout:{label:n("editor.colors.theme"),filled:!0,palette:Pt.map(E=>({label:n(`editor.colors.callout.${E.name}`),value:c.alpha(E.color,.19),icon:E.icon,meta:{type:E.name,emoji:E.emoji}}))}},onChange:E=>{v(E)},modes:["callout","background"],hideInherit:!0,target:s.jsx(c.ActionIcon,{variant:"default","aria-label":"Settings",children:s.jsx(G.Icon,{name:"palette",style:{cursor:"pointer"}})}),menuProps:{trigger:"click",position:"right-start",offset:{mainAxis:0,alignmentAxis:0}},value:{background:"",callout:""}})}):s.jsxs("div",{className:`action-menu-container ${l?"visible":""}`,ref:C,style:{right:g.right,top:g.top,left:g.left,pointerEvents:R},children:[!x&&s.jsx(c.Select,{onChange:E=>P(E),data:Q.map(([E,L])=>({value:E,label:L})),searchable:!0,value:o,allowDeselect:!1,style:{pointerEvents:R,width:140},className:"dropdown-select-language",checkIconPosition:"right",rightSection:s.jsx(V.IconChevronDown,{style:{width:14,height:14,marginLeft:2}}),maxDropdownHeight:400,variant:"default"}),s.jsxs("div",{className:"code-action-button-container",children:[!x&&s.jsxs(s.Fragment,{children:[s.jsx(Dn,{pointerEvents:R,copyToClipboard:Z}),j?s.jsx(vt,{style:{pointerEvents:R},onClick:O,ariaLabel:"expand",children:u?s.jsx(c.Tooltip,{label:n("editor.menu.main.code.collapsible.hidden"),children:s.jsx(V.IconArrowsDiagonal,{size:14})}):s.jsx(c.Tooltip,{label:n("editor.menu.main.code.collapsible.expand"),children:s.jsx(V.IconArrowsDiagonalMinimize2,{size:14})})}):null]}),s.jsx(c.Tooltip,{label:n("editor.menu.main.code.exitCommandText"),children:s.jsx(c.Text,{truncate:"end",size:"sm",id:"exitCommandParagraph",children:"Shift + Enter"})})]}),x&&s.jsx(On,{onCodeLanguageSelect:P,CODE_LANGUAGE_OPTIONS:Q,codeLanguage:o,onCollapsibleCode:O,copyToClipboard:Z,pointerEvents:R,showExpandButton:j,isCollapsed:u})]})}function zn({anchorElem:e=document.body}){return et.createPortal(s.jsx(Pn,{anchorElem:e}),e)}function Zn(){return ge.useFlashMessageContext()}const Kt=4,vn={dependencies:[Ue.HorizontalRuleNode],export:e=>Ue.$isHorizontalRuleNode(e)?"***":null,regExp:/^(---|\*\*\*|___)\s?$/,replace:(e,t,n,o)=>{const r=Ue.$createHorizontalRuleNode();o||e.getNextSibling()!=null?e.replace(r):e.insertBefore(r),r.selectNext()},type:"element"},Un={dependencies:[d.ImageNode],export:e=>d.$isImageNode(e)?`})`:null,importRegExp:/!(?:\[([^[]*)\])(?:\(([^(]+)\))/,regExp:/!(?:\[([^[]*)\])(?:\(([^(]+)\))$/,replace:(e,t)=>{const[,n,o]=t,r=d.$createImageNode({altText:n,maxWidth:800,src:o});e.replace(r)},trigger:")",type:"text-match"};function Kn(e){const t=e.match(/\t/g),n=e.match(/ /g);let o=0;return t&&(o+=t.length),n&&(o+=Math.floor(n.length/Kt)),o}const Qt=e=>(t,n,o)=>{const r=t.getPreviousSibling(),l=t.getNextSibling(),A=d.$createListItemNode(e==="check"?o[3]==="x":void 0);if(d.$isListNode(l)&&l.getListType()===e){const m=l.getFirstChild();m!==null?m.insertBefore(A):l.append(A),t.remove()}else if(d.$isListNode(r)&&r.getListType()===e)r.append(A),t.remove();else{const m=d.$createListNode(e,e==="number"?Number(o[2]):void 0);m.append(A),t.replace(m)}A.append(...n),A.select(0,0);const i=Kn(o[1]);i&&A.setIndent(i)},ut=(e,t,n)=>{const o=[],r=e.getChildren();let l=0;for(const A of r)if(d.$isListItemNode(A)){if(A.getChildrenSize()===1){const f=A.getFirstChild();if(d.$isListNode(f)){o.push(ut(f,t,n+1));continue}}const i=" ".repeat(n*Kt),m=e.getListType(),u=m==="number"?`${e.getStart()+l}. `:m==="check"?`- [${A.getChecked()?"x":" "}] `:"- ";o.push(i+u+t(A)),l++}return o.join(`
|
|
1
|
+
"use strict";var dn=Object.defineProperty;var un=(e,t,n)=>t in e?dn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ae=(e,t,n)=>un(e,typeof t!="symbol"?t+"":t,n);const p=require("react"),H=require("@lexical/react/LexicalComposerContext"),ve=require("@lexical/selection"),K=require("@lexical/utils"),a=require("lexical"),s=require("react/jsx-runtime"),et=require("react-dom"),de=require("react-i18next"),Ee=require("@lexical/code"),c=require("@mantine/core"),V=require("@tabler/icons-react"),Ve=require("@layers-app/shared"),d=require("./layers.B90YwJga.js"),G=require("./layers.C03OvlLb.js"),D=require("./layers.Dgok89qX.js"),Fe=require("@lexical/file"),Ae=require("@lexical/markdown"),An=require("@lexical/yjs"),ge=require("./layers.CZPeYQ9g.js"),Lt=require("@lexical/clipboard"),Xe=require("@lexical/rich-text"),je=require("lodash-es"),_e=require("@lexical/react/LexicalTypeaheadMenuPlugin"),mn=require("@lexical/react/LexicalAutoEmbedPlugin"),Ue=require("@lexical/react/LexicalHorizontalRuleNode"),He=require("./layers.CJiIq6YQ.js"),ot=require("./layers.Cnm-pECN.js"),ue=require("@lexical/link"),gn=require("@mantine/hooks"),pn=require("@lexical/react/LexicalLinkPlugin"),fn=require("@lexical/react/LexicalMarkdownShortcutPlugin"),se=require("@lexical/table");require("@lexical/hashtag");require("@lexical/mark");require("@lexical/overflow");const hn=require("react-selecto"),Cn=require("@lexical/react/useLexicalEditable"),bn=require("@lexical/react/LexicalTableOfContentsPlugin"),En=require("@lexical/react/LexicalTreeView"),tt=[".ContentEditable__root > *:not(ol):not(ul):not(.dsd__theme__table-scrollable-wrapper):not(.editor-image:not(:has(button))):not(div.video-container):not(div.editor-iframe)",".dsd__theme__table-scrollable-wrapper > table",".editor-image > div.resizable-container > div.resizable-container__inner",".video-container > div.resizable-container > div.resizable-container__inner",".editor-iframe > div.resizable-container > div.resizable-container__inner"],it=[...tt,"ul.dsd__theme__ul > li:not(.dsd__theme__nestedListItem)","ol.dsd__theme__ol1 > li:not(.dsd__theme__nestedListItem)","ol.dsd__theme__ol2 > li:not(.dsd__theme__nestedListItem)","ol.dsd__theme__ol3 > li:not(.dsd__theme__nestedListItem)","ol.dsd__theme__ol4 > li:not(.dsd__theme__nestedListItem)","ol.dsd__theme__ol5 > li:not(.dsd__theme__nestedListItem)"],xn=[...tt,"ul.dsd__theme__ul:not(.dsd__theme__nestedListItem ul) > li:not(.dsd__theme__nestedListItem)","ul.dsd__theme__ul:not(.dsd__theme__nestedListItem ul) > li.dsd__theme__nestedListItem","ol.dsd__theme__ol1:not(.dsd__theme__nestedListItem ol) > li:not(.dsd__theme__nestedListItem)","ol.dsd__theme__ol1:not(.dsd__theme__nestedListItem ol) > li.dsd__theme__nestedListItem"],Nn=[...tt,"ul.dsd__theme__ul:not(.dsd__theme__nestedListItem ul) > li:not(.dsd__theme__nestedListItem)","ul.dsd__theme__ul:not(.dsd__theme__nestedListItem ul) > li.dsd__theme__nestedListItem"],Tn=[...tt,"ol.dsd__theme__ol1:not(.dsd__theme__nestedListItem ol) > li:not(.dsd__theme__nestedListItem)","ol.dsd__theme__ol1:not(.dsd__theme__nestedListItem ol) > li.dsd__theme__nestedListItem"],Ot=e=>{const t=document.querySelectorAll(".selected-block");if(t.length===0)return;setTimeout(()=>{e.update(()=>{const o=a.$createNodeSelection();t.forEach(r=>{const l=a.$getNearestNodeFromDOMNode(r);l&&D.addNodeAndChildrenToSelection(l,o)}),a.$setSelection(o)})},100);const n=o=>{const r=!!document.querySelector(".mantine-Menu-dropdown");if(o.button===2||r){o.preventDefault();return}const l=o.target;l.closest(".draggable-block-menu")||l.closest(".mantine-Menu-dropdown")||(t.forEach(A=>{Ge(A)}),document.body.removeEventListener("mousedown",n))};setTimeout(()=>{document.body.addEventListener("mousedown",n)}),e.update(()=>{const o=document.querySelector(".ContentEditable__root");o==null||o.focus({preventScroll:!0})})},Sn={container:document.body,getScrollPosition:()=>[document.documentElement.scrollLeft,document.documentElement.scrollTop],throttleTime:30,threshold:0},ht=(e,t,n)=>function o(r){if(r instanceof KeyboardEvent&&r.key!=="Backspace"&&r.key!=="Delete"&&r.key!=="Escape")return!1;const l=r.target;l.closest(".draggable-block-menu")||l.closest(".toolbar")||l.closest(".mantine-Menu-dropdown")||(e==null||e.classList.remove(t),n.update(()=>{l.closest(".ContentEditable__root")||a.$setSelection(null),r instanceof KeyboardEvent&&t==="selected-all-document"&&r.key!=="Escape"&&n.update(()=>{var i;(i=a.$getRoot().getFirstChild())==null||i.selectStart()}),r instanceof KeyboardEvent&&t==="selected-all-document"&&r.key==="Escape"&&n.blur()}),setTimeout(()=>{document.body.removeEventListener("mousedown",o),document.removeEventListener("keydown",o)}))},Bt=(e,t)=>{var n,o;if(t&&t.block){const{block:r,isCreateEventListener:l}=t,A="selected-block";if(r.classList.add(A),r.classList.remove("selected-block-hidden"),l){const i=ht(r,A,e);document.body.addEventListener("mousedown",i),document.addEventListener("keydown",i)}}else{const r="selected-all-document",l=ht(e._rootElement,r,e);document.body.addEventListener("mousedown",l),document.addEventListener("keydown",l),(n=e._rootElement)==null||n.classList.add(r),(o=e._rootElement)==null||o.classList.remove("selected-block-hidden")}},Ge=e=>{e.classList.remove("selected-block"),e.classList.add("selected-block-hidden")},yn=e=>{e.querySelectorAll(".selected-block").forEach(n=>{Ge(n)})},wn=(e,t,n,o,r)=>{var l;if(((l=e.selected[0])==null?void 0:l.tagName)==="LI"){let A=e.added[0];if(!e.added.length&&e.beforeSelected.length>=2){const g=e.beforeSelected[0],h=e.beforeSelected[1],C=g.getBoundingClientRect().top;h.getBoundingClientRect().top<C?A=Dt(e.selected[0]):A=e.selected[0]}let m=(A==null?void 0:A.classList.contains("dsd__theme__nestedListItem"))&&e.added.length===0?1:0,u=A,f=null;for(;u;){const g=u.tagName.toUpperCase();if(g==="UL"||g==="OL")f||(f=g.toLowerCase()),m++;else if(g!=="LI")break;u=u.parentElement}if(m!==0&&n.depth!==m){if(!f)return;o({depth:m,targets:In(m,f)}),setTimeout(()=>{r==null||r.findSelectableTargets(),r==null||r.setSelectedTargets(e.selected)})}}else!n.depth&&e.added.length&&(o({depth:999,targets:xn}),setTimeout(()=>{r==null||r.findSelectableTargets(),r==null||r.setSelectedTargets(e.selected)}));e.added.forEach(A=>{Bt(t,{block:A,isCreateEventListener:!1})}),e.removed.forEach(A=>{Ge(A)})},ke=()=>{const e=document.querySelector("div.ContentEditable__root"),t=(e==null?void 0:e.querySelector(".selected-block"))!==null,n=e==null?void 0:e.classList.contains("selected-all-document");return{hasSelectedBlock:t,selectedAllDocument:n}},Ct=(e,t,n,o)=>{if(e==="ol"){const r=Array.from({length:t},(m,u)=>`ol.dsd__theme__ol${u+1}`).join(" ");let l="";t===1&&(l=":not(.dsd__theme__nestedListItem ol)");const A=`${r}${l} >`;return n?`${A} li.dsd__theme__nestedListItem`:`${A} li:not(.dsd__theme__nestedListItem)`}else{const r=" ul".repeat(t-1).trim(),l=" ul".repeat(t).trim(),i=`ul.dsd__theme__ul${r?` ${r}`:""}:not(.dsd__theme__nestedListItem ${l}) >`;let m=`${i} li:not(.dsd__theme__nestedListItem)`;return n?`${i} li.dsd__theme__nestedListItem`:m}};function In(e,t){if(e<1)throw new Error("Depth must be >= 1");const n=[];if(n.push(Ct(t,e,!1)),n.push(Ct(t,e,!0)),t==="ol"){if(e>1)for(let o=1;o<e;o++)n.push(`ol.dsd__theme__ol${o} > li:not(.dsd__theme__nestedListItem)`);return[...Nn,...n]}else if(t==="ul"){if(e>1)for(let o=1;o<e;o++)n.push(`ul.dsd__theme__ul${" ul".repeat(o-1)}:not(.dsd__theme__nestedListItem ${"ul ".repeat(o).trim()}) > li:not(.dsd__theme__nestedListItem):not(:has(ul))`);return[...Tn,...n]}return[...it,...n]}function Dt(e){const t=e.querySelector("ul, ol");let n=t==null?void 0:t.lastElementChild;for(;n&&n.tagName!=="LI";)n=n.previousElementSibling;return n!=null&&n.classList.contains("dsd__theme__nestedListItem")?Dt(n)??n:n}function Rn(e){var r;const t=e.getAttribute("open");return((r=e.firstElementChild)==null?void 0:r.tagName)==="SPAN"?{node:null}:{node:lt(t!==null)}}class Se extends a.ElementNode{constructor(n,o){super(o);ae(this,"__open");this.__open=n}static getType(){return"collapsible-container"}static clone(n){return new Se(n.__open,n.__key)}createDOM(n,o){let r;const l=document.createElement("details");return l.open=this.__open,l.addEventListener("toggle",()=>{o.getEditorState().read(()=>this.getOpen())!==l.open&&o.update(()=>this.toggleOpen())}),r=l,r.classList.add("Collapsible__container"),r}updateDOM(n,o){const r=this.__open;return n.__open!==r&&(o.open=this.__open),!1}static importDOM(){return{details:n=>({conversion:Rn,priority:1})}}static importJSON(n){return lt(n.open)}exportDOM(){const n=document.createElement("details");return n.classList.add("Collapsible__container"),this.__open&&n.setAttribute("open",""),{element:n}}exportJSON(){return{...super.exportJSON(),open:this.__open,type:"collapsible-container",version:1}}setOpen(n){const o=this.getWritable();o.__open=n}getOpen(){return this.getLatest().__open}toggleOpen(){this.setOpen(!this.getOpen())}}function lt(e){return new Se(e)}function ce(e){return e instanceof Se}function Mn(e){return{node:at()}}class ye extends a.ElementNode{static getType(){return"collapsible-content"}static clone(t){return new ye(t.__key)}createDOM(t,n){const o=document.createElement("div");return o.classList.add("Collapsible__content"),o}updateDOM(t,n){return!1}static importDOM(){return{div:t=>t.hasAttribute("data-lexical-collapsible-content")?{conversion:Mn,priority:2}:null}}exportDOM(){const t=document.createElement("div");return t.classList.add("Collapsible__content"),t.setAttribute("data-lexical-collapsible-content","true"),{element:t}}static importJSON(t){return at()}isShadowRoot(){return!0}exportJSON(){return{...super.exportJSON(),type:"collapsible-content",version:1}}}function at(){return new ye}function Ke(e){return e instanceof ye}function kn(e){return{node:ct()}}class we extends a.ElementNode{static getType(){return"collapsible-title"}static clone(t){return new we(t.__key)}createDOM(t,n){const o=document.createElement("summary");return o.classList.add("Collapsible__title"),ge.IS_SAFARI&&(o.style.cursor="pointer"),o}updateDOM(t,n){return!1}static importDOM(){return{summary:t=>({conversion:kn,priority:1})}}static importJSON(t){return ct()}exportJSON(){return{...super.exportJSON(),type:"collapsible-title",version:1}}collapseAtStart(t){return this.getParentOrThrow().insertBefore(this),!0}insertNewAfter(t,n=!0){const o=this.getParentOrThrow();if(!ce(o))throw new Error("CollapsibleTitleNode expects to be child of CollapsibleContainerNode");if(o.getOpen()){const r=this.getNextSibling();if(!Ke(r))throw new Error("CollapsibleTitleNode expects to have CollapsibleContentNode sibling");const l=r.getFirstChild();if(a.$isElementNode(l))return l;{const A=a.$createParagraphNode();return r.append(A),A}}else{const r=a.$createParagraphNode();return o.insertAfter(r,n),r}}}function ct(){return new we}function Le(e){return e instanceof we}const jn=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5),Pt=[{name:"alert",color:"rgb(250, 82, 82)",icon:s.jsx(V.IconExclamationCircle,{size:16}),emoji:"❗"},{name:"success",color:"rgb(18, 184, 134)",icon:s.jsx(V.IconCheck,{size:16}),emoji:"✅"},{name:"warning",color:"rgb(242, 188, 57)",icon:s.jsx(V.IconAlertTriangle,{size:16}),emoji:"⚠️"}],zt=e=>e.mode==="callout",Zt="calc(50% - 25px) calc(50% - 25px)",Ln=({setIsMenuOpen:e,onCodeLanguageSelect:t,codeLanguage:n,CODE_LANGUAGE_OPTIONS:o})=>(p.useEffect(()=>()=>{document.documentElement.classList.remove("disable-scroll"),e(!1)},[]),s.jsx(c.Select,{onChange:r=>t(r),data:o.map(([r,l])=>({value:r,label:l})),searchable:!0,defaultValue:n,allowDeselect:!1,style:{width:140},className:"dropdown-select-language",checkIconPosition:"right",rightSection:s.jsx(V.IconChevronDown,{style:{width:14,height:14,marginLeft:2}}),maxDropdownHeight:400,variant:"default",styles:{dropdown:{overflow:"auto",zIndex:1e3}}}));function On({codeLanguage:e,CODE_LANGUAGE_OPTIONS:t,onCodeLanguageSelect:n,onCollapsibleCode:o,copyToClipboard:r,pointerEvents:l,showExpandButton:A,isCollapsed:i}){const[m,u]=p.useState(!1),{t:f}=de.useTranslation(),g=()=>{u(h=>{const C=document.documentElement;return h?C.classList.remove("disable-scroll"):C.classList.add("disable-scroll"),!h})};return s.jsxs(c.Menu,{shadow:"md",styles:{dropdown:{overflow:"auto",zIndex:1e3}},children:[s.jsx(c.Menu.Target,{children:s.jsx(c.Button,{style:{pointerEvents:l},radius:"sm",h:25,px:5,size:"xs",variant:"default",children:s.jsx(V.IconMenu2,{size:18})})}),s.jsxs(c.Menu.Dropdown,{children:[s.jsx(c.Menu.Item,{style:{position:"relative",padding:0},disabled:m,closeMenuOnClick:!1,onClick:g,children:s.jsx(Ln,{setIsMenuOpen:u,codeLanguage:e,onCodeLanguageSelect:n,CODE_LANGUAGE_OPTIONS:t})}),s.jsx(c.Menu.Item,{rightSection:s.jsx(V.IconCopy,{size:14}),onClick:r,children:s.jsx(c.Text,{size:"12px",children:f("editor.menu.main.code.copy")})}),A&&s.jsx(c.Menu.Item,{onClick:o,rightSection:i?s.jsx(V.IconArrowsDiagonal,{size:14}):s.jsx(V.IconArrowsDiagonalMinimize2,{size:14}),children:s.jsx(c.Text,{size:"12px",children:f(i?"editor.menu.main.code.collapsible.hidden":"editor.menu.main.code.collapsible.expand")})})]})]})}function vt({onClick:e,ariaLabel:t,children:n,...o}){return s.jsx(c.Button,{radius:"sm",h:25,px:5,mr:3,size:"xs",variant:"default",onClick:e,"aria-label":t,...o,children:n})}const Bn={copy:V.IconCopy,success:V.IconCheck,loader:V.IconCircleDashed};function Dn({copyToClipboard:e,pointerEvents:t}){const[n,o]=p.useState("copy"),{t:r}=de.useTranslation();async function l(){await e()&&(o("loader"),setTimeout(()=>{o("success"),setTimeout(()=>{o("copy")},1e3)},1e3))}const A=Bn[n];return s.jsxs(vt,{style:{pointerEvents:t},onClick:l,ariaLabel:"copy",children:[s.jsx(c.Text,{mr:"4px",size:"12px",children:r("editor.menu.main.code.copy")}),s.jsx(A,{size:14})]})}function dt(e,t,n){const o=p.useRef(null);return o.current=e,p.useMemo(()=>je.debounce((...r)=>{o.current&&o.current(...r)},t,{maxWait:n}),[t,n])}const Ut={json:"JSON",...Ee.CODE_LANGUAGE_FRIENDLY_NAME_MAP};function Pn({anchorElem:e}){var B,z;const[t]=H.useLexicalComposerContext(),{t:n}=de.useTranslation(),[o,r]=p.useState(""),[l,A]=p.useState(!1),[i,m]=p.useState(null),[u,f]=p.useState(null),[g,h]=p.useState({right:"0",top:"0"}),C=p.useRef(null),S=p.useRef(null),y=(B=J())==null?void 0:B.classList.contains("dsd__theme__callout-wrapper"),x=S.current&&((z=S.current)==null?void 0:z.offsetWidth)<=300,j=S.current&&S.current.scrollHeight>280,R=l?"auto":"none",Q=T();function J(){return S.current}function T(){const E=[];for(const[L,U]of Object.entries(Ut))E.push([L,U]);return E.sort(([L],[U])=>L.localeCompare(U)),E}const I=dt(E=>{const{lexicalDOMNode:L,isOutside:U}=D.getMouseInfo(E,"code.dsd__theme__code, div.dsd__theme__callout-wrapper",["div.dropdown-select-language","div.mantine-Select-option","div.action-menu-container","div.mantine-Menu-dropdown"]);if(U){A(!1);return}if(!L)return;S.current=L;let $=null,X="";if(t.update(()=>{const q=a.$getNearestNodeFromDOMNode(L);q&&m(q.__key),d.$isExtendedCodeNode(q)?($=q,X=$.getLanguage()||"",r(X?Ee.CODE_LANGUAGE_MAP[X]||X:"Выберите форматирование"),f($.__isCollapsed)):d.$isCalloutWrapperNode(q)&&($=q)}),$){const{y:q,right:b,left:N}=e.getBoundingClientRect(),{y:w,right:k,left:M}=L.getBoundingClientRect();A(!0),C.current&&(C.current.style.visibility="visible");const Y=w-q,F=b-k,_=M-N;h(()=>({right:`${F}px`,left:`${_}px`,top:`${Y}px`}))}},50,500);p.useEffect(()=>K.mergeRegister(t.registerMutationListener(Ee.CodeNode,E=>{t.getEditorState().read(()=>{for(const[L,U]of E)U==="destroyed"&&A(!1)})}),t.registerUpdateListener(({dirtyElements:E,dirtyLeaves:L})=>{l&&(E.size>0||L.size>0)&&t.getEditorState().read(()=>{const U=D.getCurrentElement();(U==null?void 0:U.__type)!=="extend-code"&&(U==null?void 0:U.__type)!=="code-highlight"&&C.current&&(C.current.style.visibility="hidden")})})),[t,l]),p.useEffect(()=>(document.addEventListener("mousemove",I),()=>{A(!1),I.cancel(),document.removeEventListener("mousemove",I)}),[I]);const O=p.useCallback(()=>{f(E=>!E),t.update(()=>{if(i!==null){const E=a.$getNodeByKey(i);d.$isExtendedCodeNode(E)&&E.toggleCodeState()}})},[t,i]),P=p.useCallback(E=>{t.update(()=>{if(i!==null){const L=a.$getNodeByKey(i);if(d.$isExtendedCodeNode(L)){L.setLanguage(E),L.selectStart();const U=L.getLanguage()||"";r(U?Ee.CODE_LANGUAGE_MAP[U]||U:"")}}})},[t,i]),v=E=>{t.update(()=>{const L=a.$getNodeByKey(i);d.$isCalloutWrapperNode(L)&&t.update(()=>{const U=zt(E);L.setType(U?E.meta.type:void 0),L.setBackgroundColor(E.value),A(!1)})})};async function Z(){const E=J();if(!E)return!1;let L="";t.update(()=>{const U=a.$getNearestNodeFromDOMNode(E);d.$isExtendedCodeNode(U)&&(L=U.getTextContent());const $=a.$getSelection();a.$setSelection($)});try{return await navigator.clipboard.writeText(L),!0}catch(U){return console.error("Failed to copy: ",U),!1}}return y?s.jsx("div",{className:`action-menu-container callout-action ${l?"visible":""}`,ref:C,style:{right:g.right,top:g.top,pointerEvents:R},children:l&&s.jsx(Ve.NewColorPicker,{data:{callout:{label:n("editor.colors.theme"),filled:!0,palette:Pt.map(E=>({label:n(`editor.colors.callout.${E.name}`),value:c.alpha(E.color,.19),icon:E.icon,meta:{type:E.name,emoji:E.emoji}}))}},onChange:E=>{v(E)},modes:["callout","background"],hideInherit:!0,target:s.jsx(c.ActionIcon,{variant:"default","aria-label":"Settings",children:s.jsx(G.Icon,{name:"palette",style:{cursor:"pointer"}})}),menuProps:{trigger:"click",position:"right-start",offset:{mainAxis:0,alignmentAxis:0}},value:{background:"",callout:""}})}):s.jsxs("div",{className:`action-menu-container ${l?"visible":""}`,ref:C,style:{right:g.right,top:g.top,left:g.left,pointerEvents:R},children:[!x&&s.jsx(c.Select,{onChange:E=>P(E),data:Q.map(([E,L])=>({value:E,label:L})),searchable:!0,value:o,allowDeselect:!1,style:{pointerEvents:R,width:140},className:"dropdown-select-language",checkIconPosition:"right",rightSection:s.jsx(V.IconChevronDown,{style:{width:14,height:14,marginLeft:2}}),maxDropdownHeight:400,variant:"default"}),s.jsxs("div",{className:"code-action-button-container",children:[!x&&s.jsxs(s.Fragment,{children:[s.jsx(Dn,{pointerEvents:R,copyToClipboard:Z}),j?s.jsx(vt,{style:{pointerEvents:R},onClick:O,ariaLabel:"expand",children:u?s.jsx(c.Tooltip,{label:n("editor.menu.main.code.collapsible.hidden"),children:s.jsx(V.IconArrowsDiagonal,{size:14})}):s.jsx(c.Tooltip,{label:n("editor.menu.main.code.collapsible.expand"),children:s.jsx(V.IconArrowsDiagonalMinimize2,{size:14})})}):null]}),s.jsx(c.Tooltip,{label:n("editor.menu.main.code.exitCommandText"),children:s.jsx(c.Text,{truncate:"end",size:"sm",id:"exitCommandParagraph",children:"Shift + Enter"})})]}),x&&s.jsx(On,{onCodeLanguageSelect:P,CODE_LANGUAGE_OPTIONS:Q,codeLanguage:o,onCollapsibleCode:O,copyToClipboard:Z,pointerEvents:R,showExpandButton:j,isCollapsed:u})]})}function zn({anchorElem:e=document.body}){return et.createPortal(s.jsx(Pn,{anchorElem:e}),e)}function Zn(){return ge.useFlashMessageContext()}const Kt=4,vn={dependencies:[Ue.HorizontalRuleNode],export:e=>Ue.$isHorizontalRuleNode(e)?"***":null,regExp:/^(---|\*\*\*|___)\s?$/,replace:(e,t,n,o)=>{const r=Ue.$createHorizontalRuleNode();o||e.getNextSibling()!=null?e.replace(r):e.insertBefore(r),r.selectNext()},type:"element"},Un={dependencies:[d.ImageNode],export:e=>d.$isImageNode(e)?`})`:null,importRegExp:/!(?:\[([^[]*)\])(?:\(([^(]+)\))/,regExp:/!(?:\[([^[]*)\])(?:\(([^(]+)\))$/,replace:(e,t)=>{const[,n,o]=t,r=d.$createImageNode({altText:n,maxWidth:800,src:o});e.replace(r)},trigger:")",type:"text-match"};function Kn(e){const t=e.match(/\t/g),n=e.match(/ /g);let o=0;return t&&(o+=t.length),n&&(o+=Math.floor(n.length/Kt)),o}const Qt=e=>(t,n,o)=>{const r=t.getPreviousSibling(),l=t.getNextSibling(),A=d.$createListItemNode(e==="check"?o[3]==="x":void 0);if(d.$isListNode(l)&&l.getListType()===e){const m=l.getFirstChild();m!==null?m.insertBefore(A):l.append(A),t.remove()}else if(d.$isListNode(r)&&r.getListType()===e)r.append(A),t.remove();else{const m=d.$createListNode(e,e==="number"?Number(o[2]):void 0);m.append(A),t.replace(m)}A.append(...n),A.select(0,0);const i=Kn(o[1]);i&&A.setIndent(i)},ut=(e,t,n)=>{const o=[],r=e.getChildren();let l=0;for(const A of r)if(d.$isListItemNode(A)){if(A.getChildrenSize()===1){const f=A.getFirstChild();if(d.$isListNode(f)){o.push(ut(f,t,n+1));continue}}const i=" ".repeat(n*Kt),m=e.getListType(),u=m==="number"?`${e.getStart()+l}. `:m==="check"?`- [${A.getChecked()?"x":" "}] `:"- ";o.push(i+u+t(A)),l++}return o.join(`
|
|
2
2
|
`)},Qn=/^(\s*)(\d{1,})\.\s/,Gn=/^(\s*)[-*+]\s/,Yn={dependencies:[d.ListNode,d.ListItemNode],export:(e,t)=>d.$isListNode(e)?ut(e,t,0):null,regExp:Qn,replace:Qt("number"),type:"element"},Fn={dependencies:[d.ListNode,d.ListItemNode],export:(e,t)=>d.$isListNode(e)?ut(e,t,0):null,regExp:Gn,replace:Qt("bullet"),type:"element"},Gt=/^(?:\|)(.+)(?:\|)\s?$/,Hn=/^(\| ?:?-*:? ?)+\|\s?$/,Jn={dependencies:[se.TableNode,se.TableRowNode,se.TableCellNode],export:e=>{if(!se.$isTableNode(e))return null;const t=[];for(const n of e.getChildren()){const o=[];if(!se.$isTableRowNode(n))continue;let r=!1;for(const l of n.getChildren())se.$isTableCellNode(l)&&(o.push(Ae.$convertToMarkdownString(Qe,l).replace(/\n/g,"\\n")),l.__headerState===se.TableCellHeaderStates.ROW&&(r=!0));t.push(`| ${o.join(" | ")} |`),r&&t.push(`| ${o.map(l=>"---").join(" | ")} |`)}return t.join(`
|
|
3
3
|
`)},regExp:Gt,replace:(e,t,n)=>{if(Hn.test(n[0])){const u=e.getPreviousSibling();if(!u||!se.$isTableNode(u))return;const f=u.getChildren(),g=f[f.length-1];if(!g||!se.$isTableRowNode(g))return;g.getChildren().forEach(h=>{se.$isTableCellNode(h)&&h.setHeaderStyles(se.TableCellHeaderStates.ROW,se.TableCellHeaderStates.ROW)}),e.remove();return}const o=bt(n[0]);if(o==null)return;const r=[o];let l=e.getPreviousSibling(),A=o.length;for(;l&&!(!a.$isParagraphNode(l)||l.getChildrenSize()!==1);){const u=l.getFirstChild();if(!d.$isExtendedTextNode(u))break;const f=bt(u.getTextContent());if(f==null)break;A=Math.max(A,f.length),r.unshift(f);const g=l.getPreviousSibling();l.remove(),l=g}const i=se.$createTableNode();for(const u of r){const f=se.$createTableRowNode();i.append(f);for(let g=0;g<A;g++)f.append(g<u.length?u[g]:Yt(""))}const m=e.getPreviousSibling();se.$isTableNode(m)&&qn(m)===A?(m.append(...i.getChildren()),e.remove()):e.replace(i),i.selectEnd()},type:"element"};function qn(e){const t=e.getFirstChild();return se.$isTableRowNode(t)?t.getChildrenSize():0}const Yt=e=>{e=e.replace(/\\n/g,`
|
|
4
4
|
`);const t=se.$createTableCellNode(se.TableCellHeaderStates.NO_STATUS);return Ae.$convertFromMarkdownString(e,Qe,t),t},bt=e=>{const t=e.match(Gt);return!t||!t[1]?null:t[1].split("|").map(n=>Yt(n))},Qe=[Jn,vn,Un,Ae.CHECK_LIST,Ae.HEADING,Ae.QUOTE,Fn,Yn,...Ae.MULTILINE_ELEMENT_TRANSFORMERS,...Ae.TEXT_FORMAT_TRANSFORMERS,...Ae.TEXT_MATCH_TRANSFORMERS],Wn=a.createCommand("SPEECH_TO_TEXT_COMMAND"),Vn="SpeechRecognition"in window||"webkitSpeechRecognition"in window;async function Xn(e){const t=JSON.stringify(e.getEditorState());try{await fetch("http://localhost:1235/setEditorState",{body:t,headers:{Accept:"application/json","Content-type":"application/json"},method:"POST"})}catch{}}async function _n(e){const t=JSON.stringify(e.getEditorState());let n=null;try{n=await fetch("http://localhost:1235/validateEditorState",{body:t,headers:{Accept:"application/json","Content-type":"application/json"},method:"POST"})}catch{}if(n!==null&&n.status===403)throw new Error("Editor state validation failed! Server did not accept changes.")}async function $n(e){const t=new URL(window.location.toString());t.hash=await D.docToHash(e);const n=t.toString();window.history.replaceState({},"",n),await window.navigator.clipboard.writeText(n)}function eo({isRichText:e,shouldPreserveNewLinesInMarkdown:t}){const[n]=H.useLexicalComposerContext(),[o,r]=p.useState(()=>n.isEditable()),[l,A]=p.useState(!1),[i,m]=p.useState(!1),[u,f]=p.useState(!0),[g,h]=d.useModal(),C=Zn(),S=!1;p.useEffect(()=>{ge.INITIAL_SETTINGS.isCollab||D.docFromHash(window.location.hash).then(x=>{x&&x.source==="Playground"&&(n.setEditorState(Fe.editorStateFromSerializedDocument(n,x)),n.dispatchCommand(a.CLEAR_HISTORY_COMMAND,void 0))})},[n]),p.useEffect(()=>K.mergeRegister(n.registerEditableListener(x=>{r(x)}),n.registerCommand(An.CONNECTED_COMMAND,x=>(m(x),!1),a.COMMAND_PRIORITY_EDITOR)),[n]),p.useEffect(()=>n.registerUpdateListener(({dirtyElements:x,prevEditorState:j,tags:R})=>{!o&&x.size>0&&!R.has(a.HISTORIC_TAG)&&!R.has(a.COLLABORATION_TAG)&&_n(n),n.getEditorState().read(()=>{const J=a.$getRoot().getChildren();if(J.length>1)f(!1);else if(a.$isParagraphNode(J[0])){const T=J[0].getChildren();f(T.length===0)}else f(!1)})}),[n,o]);const y=p.useCallback(()=>{n.update(()=>{const x=a.$getRoot(),j=x.getFirstChild();if(Ee.$isCodeNode(j)&&j.getLanguage()==="markdown")Ae.$convertFromMarkdownString(j.getTextContent(),Qe,void 0,t);else{const R=Ae.$convertToMarkdownString(Qe,void 0,t),Q=Ee.$createCodeNode("markdown");Q.append(a.$createTextNode(R)),x.clear().append(Q),R.length===0&&Q.select()}})},[n,t]);return s.jsxs("div",{className:"actions",children:[Vn&&s.jsx("button",{onClick:()=>{n.dispatchCommand(Wn,!l),A(!l)},className:"action-button action-button-mic "+(l?"active":""),title:"Speech To Text","aria-label":`${l?"Enable":"Disable"} speech to text`,children:s.jsx("i",{className:"mic"})}),s.jsx("button",{className:"action-button import",onClick:()=>Fe.importFile(n),title:"Import","aria-label":"Import editor state from JSON",children:s.jsx("i",{className:"import"})}),s.jsx("button",{className:"action-button export",onClick:()=>Fe.exportFile(n,{fileName:`Playground ${new Date().toISOString()}`,source:"Playground"}),title:"Export","aria-label":"Export editor state to JSON",children:s.jsx("i",{className:"export"})}),s.jsx("button",{className:"action-button share",disabled:ge.INITIAL_SETTINGS.isCollab,onClick:()=>$n(Fe.serializedDocumentFromEditorState(n.getEditorState(),{source:"Playground"})).then(()=>C("URL copied to clipboard"),()=>C("URL could not be copied to clipboard")),title:"Share","aria-label":"Share Playground link to current editor state",children:s.jsx("i",{className:"share"})}),s.jsx("button",{className:"action-button clear",disabled:u,onClick:()=>{h("Clear editor",x=>s.jsx(to,{editor:n,onClose:x}))},title:"Clear","aria-label":"Clear editor contents",children:s.jsx("i",{className:"clear"})}),s.jsx("button",{className:`action-button ${o?"lock":"unlock"}`,onClick:()=>{o&&Xn(n),n.setEditable(!n.isEditable())},title:"Read-Only Mode","aria-label":`${o?"Lock":"Unlock"} read-only mode`,children:s.jsx("i",{className:o?"lock":"unlock"})}),s.jsx("button",{className:"action-button",onClick:y,title:"Convert From Markdown","aria-label":"Convert from markdown",children:s.jsx("i",{className:"markdown"})}),S,g]})}function to({editor:e,onClose:t}){return s.jsxs(s.Fragment,{children:["Are you sure you want to clear the editor?",s.jsxs("div",{className:"Modal__content",children:[s.jsx(G.Button,{onClick:()=>{e.dispatchCommand(a.CLEAR_EDITOR_COMMAND,void 0),e.focus(),t()},children:"Clear"})," ",s.jsx(G.Button,{onClick:()=>{e.focus(),t()},children:"Cancel"})]})]})}const no=[".toolbar",'[role="menu"]',".floating-text-format-popup"],oo=({onBlur:e})=>{const[t]=H.useLexicalComposerContext();return p.useEffect(()=>{const n=t.getRootElement();if(!n)return;const o=(l,A,i)=>l>=i.left&&l<=i.right&&A>=i.top&&A<=i.bottom,r=l=>{const A=n.getBoundingClientRect(),i=l.target,m=i instanceof Element&&no.some(S=>i.closest(S)),{clientX:u,clientY:f}=l,g=o(u,f,A),h=document.activeElement;!n.contains(h)&&!g&&!m&&t.update(()=>{var S;a.$setSelection(null),t.dispatchCommand(a.SELECTION_CHANGE_COMMAND,void 0),(S=t._rootElement)==null||S.classList.remove("focused"),e&&(e==null||e(t.getEditorState(),t))})};return document.addEventListener("pointerdown",r,!0),()=>{document.removeEventListener("pointerdown",r,!0)}},[t,e]),null};a.createCommand("INSERT_FIGMA_COMMAND");const Et=e=>{for(;e;){if(d.$isCalloutWrapperNode(e))return e;const t=e.getParent();if(!t)break;e=t}return null},so=e=>{switch(e){case"warning":return{emoji:"e=%E2%9A%A0%EF%B8%8F",backgroundColor:"rgba(254, 247, 230, 1)",calloutType:"warning"};case"alert":return{emoji:"e=%E2%9D%97",backgroundColor:"rgba(255, 224, 223, 1)",calloutType:"alert"};case"success":return{emoji:"e=%E2%9C%85",backgroundColor:"rgba(219, 242, 233, 1)",calloutType:"success"};default:return{emoji:"e=%F0%9F%99%82",backgroundColor:"",calloutType:""}}},xt=e=>e.replace(/\s+/g," ").trim(),ro=e=>{const t=D.getCurrentElement();if(t){const n=K.$findMatchingParent(t,d.$isCalloutNode);if((n==null?void 0:n.__type)==="callout"){const o=a.$getSelection();if(a.$isRangeSelection(o)&&o.isCollapsed()){const r=o.anchor.getNode(),l=K.$findMatchingParent(r,d.$isCalloutWrapperNode);return D.handleEnterExitContainer(e,l,n)}}}return!0};function io(){const[e]=H.useLexicalComposerContext(),{imperativeHandleRef:t}=p.useContext(ge.Context),n=p.useCallback(o=>{const r=D.getCurrentElement(),{lexicalNode:l}=D.$getClosestParentNode(r,e,{"callout-wrapper":!0});return l&&a.$isElementNode(l)&&l.getChildren().length===1&&e.update(()=>{const A=a.$createParagraphNode();A.append(a.$createTextNode(""));const i=l.getParent();i&&(i.replace(A),A.selectStart())}),!1},[]);return t!=null&&t.current&&(t.current.onDeleteCallout=n),p.useEffect(()=>{if(!e.hasNodes([d.CalloutNode,d.CalloutWrapperNode,d.CalloutIcon]))throw new Error("CalloutPlugin: CalloutNode not registered on editor");return K.mergeRegister(e.registerMutationListener(d.CalloutIcon,o=>{e.getEditorState().read(()=>{for(const[r,l]of o)if(l==="destroyed"){const A=Number(r),i=String(A-1);e.update(()=>{const m=a.$getNodeByKey(i);if(m&&d.$isCalloutWrapperNode(m)){const u=m.getChildren();for(const f of u)m==null||m.insertBefore(f);m.remove()}},{tag:a.HISTORY_MERGE_TAG})}})}),e.registerCommand(D.INSERT_CALLOUT_COMMAND,o=>{var S;const{emoji:r,backgroundColor:l,calloutType:A}=so(o),i=D.getCurrentElement(),m=i!=null&&i.getTextContent()?(S=i==null?void 0:i.getParent())==null?void 0:S.getTextContent():i==null?void 0:i.getTextContent(),u=d.$createExtendedTextNode(m||""),f=d.$createCalloutWrapperNode(l,A),g=d.$createCalloutIcon(r),h=d.$createCalloutNode().append(a.$createParagraphNode().append(u));f.append(g),f.append(h);const C=i==null?void 0:i.getParent();return i&&Xe.$isQuoteNode(C)?(f.selectEnd(),C.replace(f)):i==null||i.replace(f),!0},a.COMMAND_PRIORITY_EDITOR),e.registerCommand(a.KEY_DELETE_COMMAND,n,a.COMMAND_PRIORITY_LOW),e.registerCommand(a.CONTROLLED_TEXT_INSERTION_COMMAND,()=>D.allEditorSelected()&&e._keyToDOMMap.size>2,a.COMMAND_PRIORITY_LOW),e.registerCommand(a.COPY_COMMAND,o=>{if(!o.clipboardData)return!1;const r=a.$getSelection();if(!a.$isRangeSelection(r))return!1;const l=Et(r.anchor.getNode()),A=Et(r.focus.getNode());if(!l||!A||l.__key!==A.__key)return!1;const{hasSelectedBlock:i,selectedAllDocument:m}=ke(),u=xt(r.getTextContent()),f=xt(l.getTextContent());if(!(u===f&&(i||m)))return!1;o.preventDefault();const S=l.__calloutType??"default",y=Lt.$getClipboardDataFromSelection(r)["text/html"],x=l.getTextContent(),j=`<div class="dsd__theme__callout-wrapper" style="background-color: ${l.__backgroundColor}" data-type="${S}">${y}</div>`;return o.clipboardData.setData("text/html",j),o.clipboardData.setData("text/plain",x),!0},a.COMMAND_PRIORITY_LOW))},[e]),null}let At=function(e,t){if(!e.parentElement)return null;if(e.parentElement.classList.contains("ContentEditable__root")){let n=[];if(!CSS.supports("selector(:has(*))"))n=e.querySelectorAll("li:has(+ .dsd__theme__nestedListItem)");else{const o=e.querySelectorAll("li");n=Array.from(o).filter(r=>{const l=r.nextElementSibling;return l&&l.classList.contains("dsd__theme__nestedListItem")})}return setTimeout(()=>{for(let o=0;o<n.length;o++){const r=n[o],l=r.nextElementSibling;if(!l)return;let A=!1,i=!0;Array.from(l.querySelectorAll("li:not(.dsd__theme__nestedListItem):not(:has(+ .dsd__theme__nestedListItem))")).forEach(u=>{const f=u.getAttribute("aria-checked");(f===null||f==="false")&&(i=!1),f==="true"&&(A=!0)}),t.update(()=>{if(!i&&A){const u=a.$getNearestNodeFromDOMNode(r);u instanceof d.ListItemNode&&(u.setChecked(!1),u.setIndeterminate(!0))}if(!A&&!i){const u=a.$getNearestNodeFromDOMNode(r);u instanceof d.ListItemNode&&(u.setChecked(!1),u.setIndeterminate(!1))}if(i){const u=a.$getNearestNodeFromDOMNode(r);u instanceof d.ListItemNode&&(u.setChecked(!0),u.setIndeterminate(!1))}}),A=!1,i=!0}},0),null}return At(e.parentElement,t)};const lo=()=>{const e=D.getCurrentElement();if(!e)return!1;try{const t=K.$getNearestBlockElementAncestorOrThrow(e);t instanceof d.ListItemNode&&!t.__opened&&t.setOpened(!0)}catch{return!1}return!1},ao=je.debounce((e,t)=>{const n=t.getElementByKey(e);At(n,t)},100);function co(){const[e]=H.useLexicalComposerContext();return p.useEffect(()=>{const t=e.registerMutationListener(d.ListNode,n=>{for(const[o,r]of n)r==="updated"&&ao(o,e)},{skipInitialization:!0});return()=>{t()}},[e]),p.useEffect(()=>K.mergeRegister(e.registerCommand(d.INSERT_CHECK_LIST_COMMAND,()=>(d.insertList(e,"check"),!0),a.COMMAND_PRIORITY_LOW),e.registerRootListener((t,n)=>{t!==null&&(t.addEventListener("click",Nt),t.addEventListener("pointerdown",Tt)),n!==null&&(n.removeEventListener("click",Nt),n.removeEventListener("pointerdown",Tt))})),[e]),null}function Ft(e,t,n=!1){const o=e.target;if(o===null||!K.isHTMLElement(o))return;const r=o.firstChild;if(r!=null&&K.isHTMLElement(r)&&(r.tagName==="UL"||r.tagName==="OL"))return;const l=o.parentNode,A=o.getBoundingClientRect(),i=e.pageX/K.calculateZoomLevel(o);if(l&&i>A.right){if(n){t();return}if(e.target instanceof HTMLElement){const m=a.getNearestEditorFromDOMNode(l);m!=null&&m.isEditable()&&m.update(()=>{const u=a.$getNearestNodeFromDOMNode(l);d.$isListItemNode(u)&&u.toggleOpen()})}}!l||l.__lexicalListType!=="check"||(o.dir==="rtl"?i<A.right&&i>A.right-20:i>A.left&&i<A.left+20)&&t()}function Nt(e){Ft(e,()=>{if(e.target instanceof HTMLElement){const t=e.target,n=a.getNearestEditorFromDOMNode(t);n!=null&&n.isEditable()&&(n.update(()=>{const o=a.$getNearestNodeFromDOMNode(t);if(d.$isListItemNode(o)&&(t.focus(),o.toggleChecked()),t.getAttribute("data-list")&&t.getAttribute("aria-checked")==="false"&&t.nextElementSibling){Array.from(t.nextElementSibling.querySelectorAll("[aria-checked]")).forEach(r=>{const l=a.$getNearestNodeFromDOMNode(r);l instanceof d.ListItemNode&&l.setChecked(!0)});return}if(t.getAttribute("data-list")&&t.getAttribute("aria-checked")==="true"&&t.nextElementSibling){Array.from(t.nextElementSibling.querySelectorAll("[aria-checked]")).forEach(r=>{const l=a.$getNearestNodeFromDOMNode(r);l instanceof d.ListItemNode&&l.setChecked(!1)});return}}),At(t,n))}})}function Tt(e){Ft(e,()=>{e.preventDefault()},!0)}const Ht=a.createCommand("INSERT_CHILD_DOCUMENTS_COMMAND");function uo(){const[e]=H.useLexicalComposerContext();return p.useEffect(()=>{if(!e.hasNodes([d.ChildDocsNode]))throw new Error("ChildDocsPlugin: ChildDocsNode not registered on editor");return e.registerCommand(Ht,t=>{const n=d.$createChildDocsNode(),o=D.getCurrentElement();return o==null||o.replace(n),!0},a.COMMAND_PRIORITY_EDITOR)},[e]),null}function Ao(){const[e]=H.useLexicalComposerContext();return p.useEffect(()=>Ee.registerCodeHighlighting(e),[e]),null}const Jt=a.createCommand();a.createCommand();const mo=e=>{const t=a.$getSelection();if(a.$isRangeSelection(t)&&t.isCollapsed()){const n=t.anchor.getNode(),o=K.$findMatchingParent(n,Ke),r=K.$findMatchingParent(n,ce);return D.handleEnterExitContainer(e,r,o)&&Ke(o)}return!0},go=()=>{const e=a.$getSelection();if(!a.$isRangeSelection(e)||!e.isCollapsed()||e.anchor.offset!==0)return!1;const n=e.anchor.getNode().getTopLevelElement();if(n===null)return!1;const o=n.getPreviousSibling();return!ce(o)||o.getOpen()?!1:(o.setOpen(!0),!0)},po=()=>{var t;const e=a.$getSelection();if(a.$isRangeSelection(e)&&e.isCollapsed()&&e.anchor.offset===0){const n=K.$findMatchingParent(e.anchor.getNode(),ce);if(ce(n)){const o=n.getParent();o!==null&&o.getFirstChild()===n&&e.anchor.key===((t=n.getFirstDescendant())==null?void 0:t.getKey())&&n.insertBefore(a.$createParagraphNode())}}return!1},fo=()=>{const e=a.$getSelection();if(a.$isRangeSelection(e)&&e.isCollapsed()){const t=K.$findMatchingParent(e.anchor.getNode(),ce);if(ce(t)){const n=t.getParent();if(n!==null&&n.getLastChild()===t){const o=t.getFirstDescendant(),r=t.getLastDescendant();(r!==null&&e.anchor.key===r.getKey()&&e.anchor.offset===r.getTextContentSize()||o!==null&&e.anchor.key===o.getKey()&&e.anchor.offset===o.getTextContentSize())&&t.insertAfter(a.$createParagraphNode())}}}return!1},ho=e=>{const t=a.$getSelection();if(a.$isRangeSelection(t)&&t.isCollapsed()){const n=t.focus.getNode().getParent(),o=n==null?void 0:n.getParent();return D.removeNodeKeepContent(e,n,o)}return!1};function Co(){const[e]=H.useLexicalComposerContext();return p.useEffect(()=>{if(!e.hasNodes([Se,we,ye]))throw new Error("CollapsiblePlugin: CollapsibleContainerNode, CollapsibleTitleNode, or CollapsibleContentNode not registered on editor");return K.mergeRegister(e.registerNodeTransform(ye,t=>{const n=t.getParent();if(!ce(n)){const o=t.getChildren();for(const r of o)t.insertBefore(r);t.remove()}}),e.registerNodeTransform(we,t=>{const n=t.getParent();if(!ce(n)){t.replace(a.$createParagraphNode().append(...t.getChildren()));return}}),e.registerNodeTransform(Se,t=>{const n=t.getChildren();if(n.length!==2||!Le(n[0])||!Ke(n[1])){for(const o of n)t.insertBefore(o);t.remove()}}),e.registerCommand(a.INSERT_PARAGRAPH_COMMAND,()=>{var n;const t=a.$getSelection();if(a.$isRangeSelection(t)){const o=K.$findMatchingParent(t.anchor.getNode(),r=>Le(r));if(Le(o)){const r=o.getParent();if(r&&ce(r))return r.getOpen()||r.toggleOpen(),(n=o.getNextSibling())==null||n.selectEnd(),!0}}return!1},a.COMMAND_PRIORITY_LOW),e.registerCommand(Jt,()=>(e.update(()=>{const t=ct(),n=a.$createParagraphNode(),o=D.getCurrentElement(),r=lt(!1).append(t.append(n),at().append(a.$createParagraphNode()));o==null||o.replace(r),n.select()}),!0),a.COMMAND_PRIORITY_LOW))},[e]),null}const mt=a.createCommand("INSERT_EMBED_INTEGRATION_COMMAND ");function bo(){const[e]=H.useLexicalComposerContext();return p.useEffect(()=>{if(!e.hasNodes([d.EmbedNode]))throw new Error("EmbedPlugin: EmbedNode not registered on editor");return e.registerCommand(mt,t=>{const n=d.$createEmbedNode(t,"100%","100%","",!0,"unknown"),o=D.getCurrentElement();return o&&o.getParent()&&(o==null||o.replace(n)),!0},a.COMMAND_PRIORITY_EDITOR)},[e]),null}const gt=a.createCommand(),Eo=e=>{const t=a.$getSelection();if(a.$isRangeSelection(t)&&t.isCollapsed()){const n=t.anchor.getNode(),o=K.$findMatchingParent(n,d.$isLayoutContainerNode),r=K.$findMatchingParent(n,d.$isLayoutItemNode),{lexicalNode:l}=D.$getClosestParentNode(n,e,{"layout-item":!0});if(l&&!l.getTextContent()&&o)return D.handleEnterExitContainer(e,o,r)&&d.$isLayoutItemNode(l)}return!0},xo=e=>{const t=a.$getSelection();if(a.$isRangeSelection(t)&&t.isCollapsed()){const n=t.focus.getNode().getParent(),o=n==null?void 0:n.getParent();if((n==null?void 0:n.getTextContent())===`
|
|
@@ -3,8 +3,8 @@ import { useTranslation as l } from "react-i18next";
|
|
|
3
3
|
import { useLexicalComposerContext as h } from "@lexical/react/LexicalComposerContext";
|
|
4
4
|
import { createCommand as d, COMMAND_PRIORITY_LOW as p, $isRootNode as x, $isElementNode as A, $getRoot as E, ParagraphNode as O } from "lexical";
|
|
5
5
|
import { showMessageNotification as g, showErrorNotification as M, FilePicker as D } from "@layers-app/shared";
|
|
6
|
-
import { C as u } from "./layers.
|
|
7
|
-
import { h as T, i as w, V as P, j as y, I as L, k as U, l as z, L as V, m as $, n as R, F as W, o as G } from "./layers.
|
|
6
|
+
import { C as u } from "./layers.7jmq6tBR.js";
|
|
7
|
+
import { h as T, i as w, V as P, j as y, I as L, k as U, l as z, L as V, m as $, n as R, F as W, o as G } from "./layers.Dq3o7sh3.js";
|
|
8
8
|
import "@lexical/code";
|
|
9
9
|
import "@lexical/hashtag";
|
|
10
10
|
import "@lexical/link";
|
|
@@ -12,7 +12,7 @@ import "@lexical/mark";
|
|
|
12
12
|
import "@lexical/overflow";
|
|
13
13
|
import "@lexical/react/LexicalHorizontalRuleNode";
|
|
14
14
|
import "@lexical/rich-text";
|
|
15
|
-
import { i as Z } from "./layers.
|
|
15
|
+
import { i as Z } from "./layers.Dev6Yrwi.js";
|
|
16
16
|
import { jsx as j } from "react/jsx-runtime";
|
|
17
17
|
const v = d(
|
|
18
18
|
"INSERT_MUSIC_COMMAND"
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const Oe=require("@lexical/react/LexicalComposerContext"),n=require("react/jsx-runtime"),l=require("react"),Be=require("react-dom"),Ee=require("react-i18next"),xe=require("@lexical/rich-text"),de=require("@lexical/utils"),u=require("@mantine/core"),$=require("@tabler/icons-react"),c=require("lexical"),Ce=require("./layers.eLiGm-eZ.js"),rt=require("@lexical/code");require("@lexical/hashtag");const Me=require("@lexical/link");require("@lexical/mark");require("@lexical/overflow");require("@lexical/react/LexicalHorizontalRuleNode");const C=require("./layers.CEMW9z_P.js"),ee=require("./layers.C69TrYD7.js"),T=require("./layers.CzNz0Zya.js"),Ne=require("@lexical/selection"),Pe=require("@layers-app/shared"),V=require("./layers.Cwao1pOZ.js"),lt=require("./layers.DNCgFYS7.js"),at=require("@lexical/react/LexicalDecoratorBlockNode"),He=require("@mantine/hooks"),Ke=require("./layers.B10sB-Vy.js"),ct=4,ut=2,dt="draggable-block-menu",ft=16,ze="application/x-lexical-drag-block",De=e=>e?e.match(/(\d*\.?\d+)%/g):[],Ze=e=>e<0?0:e>100?100:e,Je=(e,t,o)=>{let i=0,s=[];e.update(()=>{if(e&&t){const f=e.getElementByKey(t.getKey());if(f){const p=f.style;s=De(p.getPropertyValue("grid-template-columns")).map(m=>m.slice(0,-1)),i=s?s.length:0}}const a=100/(i+1),r=[...s];r.splice(o,0,`${a}%`);let d=a/i;for(let f=0;f<r.length;f++)if(o!==f){const p=Number(r[f])-d;r[f]=`minmax(100px,${Ze(p)}%)`}else r[f]=`minmax(100px,${r[f]})`;t.setTemplateColumns(r.join(" "))})},Re=(e,t,o,i)=>{e.update(()=>{const s=e.getElementByKey(t.getKey());if(!s)return;let a=i;o<i&&(a=i-1);const d=s.style.getPropertyValue("grid-template-columns").match(/minmax\([^)]*\)|\S+/g)||[],f=d.splice(o,1)[0];d.splice(a,0,f),t.setTemplateColumns(d.join(" "))})},Ie=(e,t)=>(e!=null&&e.children?Array.from(e.children):[]).indexOf(t);function mt(e,t,o,i){var f;let s=e.getAttribute("data-direction")==="left",a=e.getAttribute("data-direction")==="right",r=e.getAttribute("data-index"),d=e.getAttribute("data-index-start");if(s||a||r){let p=(f=o.getParent())==null?void 0:f.getParent();if(o instanceof C.LayoutContainerNode&&(p=o),o instanceof C.LayoutDividerNode||o instanceof C.LayoutContainerNode){const m=p==null?void 0:p.getChildren();let N=i instanceof C.LayoutDividerNode;if((m==null?void 0:m.length)>=4&&!N)return!0;t.update(()=>{var _;let g=0;s?g=0:a?g=((_=p==null?void 0:p.getChildren())==null?void 0:_.length)-1:g=Number(r),N?Re(t,p,Number(d),g):Je(t,p,g);let A=null;g!==void 0&&t.update(()=>{if(A=p.getChildren()[g],N)o instanceof C.LayoutContainerNode?A.insertAfter(i.getParent()):A.insertBefore(i.getParent());else if(a)A.insertAfter(C.$createLayoutItemNode().append(i).append(C.$createLayoutDividerNode()));else{const j=i.getParent(),L=j==null?void 0:j.getParent();C.$isLayoutItemNode(j)&&(j==null?void 0:j.getChildrenSize())===2&&C.$isLayoutItemNode(j)&&C.$isLayoutContainerNode(L)&&T.removeNodeKeepContent(t,j,L),A.insertBefore(C.$createLayoutItemNode().append(i).append(C.$createLayoutDividerNode()))}})})}else t.update(()=>{const m=C.$createLayoutContainerNode(ee.GRID_TWO_COL_WITH_GAP);let N;if(C.$isCalloutWrapperNode(o)||ee.$isCollapsibleContainerNode(o)){const g=i.getParent(),A=g==null?void 0:g.getParent();if(C.$isLayoutItemNode(g)&&(g==null?void 0:g.getChildrenSize())===2&&C.$isLayoutContainerNode(A)){const j=A.getParent(),L=j==null?void 0:j.getParent(),F=A.getChildren(),v=F.findIndex(B=>B===g)===0?1:0,P=F[v];if(C.$isLayoutItemNode(P)){const B=P.getChildren()[0];C.$isCalloutWrapperNode(L)&&(L.append(B),A.remove(),N=T.$copyNodeDeep(L))}}else N=T.$copyNodeDeep(o,i)}else N=T.$copyNodeDeep(o);N&&(s?(m.append(C.$createLayoutItemNode().append(i).append(C.$createLayoutDividerNode())),m.append(C.$createLayoutItemNode().append(N).append(C.$createLayoutDividerNode()))):(m.append(C.$createLayoutItemNode().append(N).append(C.$createLayoutDividerNode())),m.append(C.$createLayoutItemNode().append(i).append(C.$createLayoutDividerNode()))),o.insertAfter(m),o.remove(),N.selectStart())});return!0}return!1}function pt(e,t,o="right",i=!1){e.update(()=>{const s=c.$getNearestNodeFromDOMNode(t),a=s==null?void 0:s.getParent();if(a){if(De(a.__templateColumns).length===4)return;let d=Ie(t.parentElement,t);o==="right"&&(d=d+1),Je(e,a,d)}const r=C.$createLayoutItemNode().append(c.$createParagraphNode()).append(C.$createLayoutDividerNode());s&&(o==="right"?i?(s.insertBefore(T.$copyNodeDeep(s)),s.selectStart()):(s.insertAfter(r),r==null||r.selectStart()):(s.insertBefore(r),r.selectStart()))})}const et=(e,t)=>{const o=t==null?void 0:t.getParent();let i=De(o==null?void 0:o.getTemplateColumns());const s=o==null?void 0:o.getChildren();let a=0;if(s&&t){for(let m=0;m<s.length;m++)if(s[m].__key===t.__key){a=m;break}}i.splice(a,1);const r=i.map(m=>parseFloat(m)),d=r.reduce((m,N)=>m+N,0),p=r.map(m=>m/d*100).map(m=>`minmax(50px,${m.toFixed(2)}%)`);o==null||o.setTemplateColumns(p.join(" "))},gt=e=>e.className.includes("editor-image")||e.className.includes("video-container")?e:e.className.includes("editor-excalidraw")?e.firstChild:null,tt=(e,t)=>t!=null&&t.__key&&e!==t.__key?tt(e,t==null?void 0:t.getParent()):e===(t==null?void 0:t.__key),qe=(e,t,o)=>{e.update(()=>{var r,d,f;const i=(r=t==null?void 0:t.getParent())==null?void 0:r.getParent(),s=t==null?void 0:t.getParent(),a=o==="right"?(d=t==null?void 0:t.getParent())==null?void 0:d.getNextSibling():(f=t==null?void 0:t.getParent())==null?void 0:f.getPreviousSibling();if(s&&a&&i instanceof C.LayoutContainerNode){const p=e.getElementByKey(s.getKey()),m=e.getElementByKey(i.getKey()),N=Ie(m,p);s&&i&&a&&(o==="right"&&(Re(e,i,N+1,N),a.insertAfter(s)),o==="left"&&(Re(e,i,N,N+1),a.insertBefore(s)))}})};function ht(e){e&&(e.style.display="none")}function We({blockElement:e,editor:t,isTop:o,isClickedBlockRef:i,setDraggableBlockElem:s}){e&&(i.current=!0,t.update(()=>{const a=c.$getNearestNodeFromDOMNode(e);if(a){const r=c.$createParagraphNode();o?(a.insertBefore(r),setTimeout(()=>{s(t.getElementByKey(r.__key)),t.update(()=>{r.selectStart()})})):(a.insertAfter(r),setTimeout(()=>{s(t.getElementByKey(r.__key)),t.update(()=>{r.selectEnd()})}))}}))}function xt(e){const t=(f,p)=>f?parseFloat(window.getComputedStyle(f)[p]):0,{marginTop:o,marginBottom:i}=window.getComputedStyle(e),s=t(e.previousElementSibling,"marginBottom"),a=t(e.nextElementSibling,"marginTop"),r=Math.max(parseFloat(o),s);return{marginBottom:Math.max(parseFloat(i),a),marginTop:r}}function Ct(e){return!!e.closest(`.${dt}`)}function Ue(e,t,o,i){if(!e){t.style.opacity="0";return}t.style.display="block";let s=null;const a=gt(e);a&&a.style.justifyContent!=="left"&&a.firstChild instanceof HTMLElement?s=a.firstChild.getBoundingClientRect():s=e.getBoundingClientRect();let r=null,d=0,f=!0,p=0;if(s){let F=e.firstChild instanceof HTMLElement&&(e.firstChild.hasAttribute("data-lexical-text")||e.firstChild.tagName==="LI"||e.firstChild.tagName==="A")?e.firstChild:null;if(F&&!F.className.includes("editor-image")&&e.tagName!=="CODE"){const M=window.getComputedStyle(F),v=parseFloat(M.lineHeight),P=parseFloat(M.fontSize);p=Math.ceil(P+(v-P)/2),r=F.getBoundingClientRect()}else if(e.firstChild instanceof HTMLElement&&e.firstChild.tagName==="BR"&&e.tagName!=="CODE"){const M=window.getComputedStyle(e,"::before");p=parseFloat(M.height)||30}else e&&(e.tagName==="HR"||e.matches(":has(audio)")||e.classList.contains("file-container"))?p=e.clientHeight:e.firstChild instanceof HTMLElement&&e.firstChild.tagName==="SUMMARY"?p=e.firstChild.clientHeight:(r=s,f=!1)}const m=o.getBoundingClientRect(),N=(r==null?void 0:r.top)||s.top,g=p||d,A=t.clientHeight,_=g-A;let j=!f||!g?s.top+7-m.top:N+_/2-m.top,L=s.left-m.left-A*2-3;e.tagName==="LI"&&e.getAttribute("role")!=="checkbox"&&(L=L-26,j=j-1),a&&(j=N-m.top+7,(a.style.justifyContent==="center"||a.style.justifyContent==="right")&&(L=L+10)),e.matches(":has(.resizable-container__handle)")&&!e.matches(":has(.hide-padding)")&&(j=N-m.top+27),s.top<0&&(j=j+-s.top),e.className==="dsd__theme__layoutDivider"&&(t.style.display="none",s.top-t.clientHeight<0?e.style.setProperty("--height-column",`${e.clientHeight+s.top-t.clientHeight-7}px`):e.style.setProperty("--height-column",`${e.clientHeight}px`)),t.style.opacity="1",!i&&L>-40&&(t.style.transform=`translate(${L}px, ${j}px)`)}function Ye(e,t){const{transform:o}=t.style;t.style.transform="translateZ(0)",e.setDragImage(t,0,0),setTimeout(()=>{t.style.transform=o})}function yt(e,t){const o=document.createElement("div");o.style.position="absolute",o.style.top="-9999px",o.style.left="-9999px",t.forEach(i=>{const s=i.cloneNode(!0);s.style.position="relative",o.appendChild(s)}),document.body.appendChild(o),e.setDragImage(o,0,0),setTimeout(()=>document.body.removeChild(o),0)}function bt(e,t,o,i,s,a,r){var x;const{top:d,height:f,width:p,left:m}=t.getBoundingClientRect(),{top:N,left:g,width:A}=s==null?void 0:s.getBoundingClientRect(),{marginTop:_,marginBottom:j}=xt(t);let L=d;o>=d?(r.current.isBottom=!0,L+=f+j/2):(r.current.isBottom=!1,L-=_/2);const F=L-N-ut,M=ft-ct,P=a.target.closest(".dsd__theme__layoutDivider");e.setAttribute("data-index",""),e.style.background="deepskyblue";const B=m-g-M;if(i<=m&&!P){if(t.closest(".dsd__theme__layoutItem"))return;e.style.transform=`translate(${B}px, ${d-N}px)`,e.style.width="4px",e.style.height=`${f}px`,e.style.opacity=".4",e.setAttribute("data-direction","left")}else if(i>=A-B&&!P&&!t.closest(".dsd__theme__layoutItem"))t.classList.contains("dsd__theme__layoutContainer")&&!e.getAttribute("data-index-start")&&t&&t.children.length>=4&&(e.style.background="red"),e.style.transform=`translate(${A-B}px, ${d-N}px)`,e.style.width="4px",e.style.height=`${f}px`,e.style.opacity=".4",e.setAttribute("data-direction","right");else if(P){a.preventDefault();const S=(x=P.parentNode)==null?void 0:x.parentNode;(S==null?void 0:S.children.length)===4&&(e.style.background="red");const k=P.parentNode,O=Ie(S,k),R=O?P.getBoundingClientRect().left-g:B+30;e.style.transform=`translate(${R}px, ${d-N}px)`,e.style.width="4px",e.style.height=`${f}px`,e.style.opacity=".4",e.setAttribute("data-index",`${O}`)}else e.style.transform=`translate(${B}px, ${F}px)`,e.style.width=`${p+M}px`,e.style.opacity=".4",e.style.height="4px",e.setAttribute("data-direction","")}function Ge(e){e&&(e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)")}const Tt=({hoveredButton:e,insertNewParagraph:t,currentDraggableBlockRef:o,setHoveredButton:i,isClickedBlockRef:s,setDraggableBlockElem:a,editor:r,t:d})=>n.jsx("div",{className:`icon add-block-menu ${e?"active":""}`,onClick:()=>{t({blockElement:o.current.htmlElement,editor:r,isTop:!1,isClickedBlockRef:s,setDraggableBlockElem:a}),i("both")},onMouseEnter:()=>{i("bottom")},onMouseLeave:()=>{i("both")},children:n.jsx(u.Tooltip,{openDelay:300,label:d("editor.hoverOptions.addNewBlockAbove"),position:"bottom",disabled:s.current||!e,children:n.jsx(u.ActionIcon,{radius:"sm",color:"gray",size:"xs",variant:"subtle","aria-label":"Settings",children:e==="bottom"?n.jsx($.IconPlus,{}):n.jsx($.IconMinus,{})})})}),Mt=({hoveredButton:e,insertNewParagraph:t,currentDraggableBlockRef:o,setHoveredButton:i,isClickedBlockRef:s,setDraggableBlockElem:a,editor:r,t:d})=>n.jsx("div",{className:`icon add-block-menu add-block-menu_top ${e?"active":""}`,onClick:()=>{t({blockElement:o.current.htmlElement,editor:r,isTop:!0,isClickedBlockRef:s,setDraggableBlockElem:a}),i("both")},onMouseEnter:()=>{i("top")},onMouseLeave:()=>{i("both")},children:n.jsx(u.Tooltip,{disabled:s.current||!e,openDelay:300,label:d("editor.hoverOptions.addNewBlockBelow"),position:"top",children:n.jsx(u.ActionIcon,{radius:"sm",color:"gray",size:"xs",variant:"subtle","aria-label":"Settings",children:e==="top"?n.jsx($.IconPlus,{}):n.jsx($.IconMinus,{})})})});function nt(e,t){var a,r;const o=(a=t.exportDOM)==null?void 0:a.call(t,e),i=(o==null?void 0:o.element)??null;if(c.$isElementNode(t)){const d=i??document.createElement("div"),f=((r=t.getChildren)==null?void 0:r.call(t))??[];for(const p of f){const m=nt(e,p);if(m)d.appendChild(m);else{const N=typeof p.getTextContent=="function"?p.getTextContent():"";N&&d.appendChild(document.createTextNode(N))}}return typeof(o==null?void 0:o.after)=="function"&&o.after(d),d}if(i)return typeof(o==null?void 0:o.after)=="function"&&o.after(i),i;const s=typeof t.getTextContent=="function"?t.getTextContent():"";return s?document.createTextNode(s):null}async function Xe(e,t){const o=e.getRootElement(),i=Array.from(o.querySelectorAll(".selected-block"));if(!i.length)return;let s="",a="";e.getEditorState().read(()=>{e.update(()=>{let r=i.map(f=>c.$getNearestNodeFromDOMNode(f)).filter(f=>!!f);s=r.map(f=>typeof f.getTextContent=="function"?f.getTextContent():"").filter(Boolean).join(`
|
|
1
|
+
"use strict";const Oe=require("@lexical/react/LexicalComposerContext"),n=require("react/jsx-runtime"),l=require("react"),Be=require("react-dom"),Ee=require("react-i18next"),xe=require("@lexical/rich-text"),de=require("@lexical/utils"),u=require("@mantine/core"),$=require("@tabler/icons-react"),c=require("lexical"),Ce=require("./layers.CZPeYQ9g.js"),rt=require("@lexical/code");require("@lexical/hashtag");const Me=require("@lexical/link");require("@lexical/mark");require("@lexical/overflow");require("@lexical/react/LexicalHorizontalRuleNode");const C=require("./layers.B90YwJga.js"),ee=require("./layers.CZ_Lt7IL.js"),T=require("./layers.Dgok89qX.js"),Ne=require("@lexical/selection"),Pe=require("@layers-app/shared"),V=require("./layers.C03OvlLb.js"),lt=require("./layers.DNCgFYS7.js"),at=require("@lexical/react/LexicalDecoratorBlockNode"),He=require("@mantine/hooks"),Ke=require("./layers.CJiIq6YQ.js"),ct=4,ut=2,dt="draggable-block-menu",ft=16,ze="application/x-lexical-drag-block",De=e=>e?e.match(/(\d*\.?\d+)%/g):[],Ze=e=>e<0?0:e>100?100:e,Je=(e,t,o)=>{let i=0,s=[];e.update(()=>{if(e&&t){const f=e.getElementByKey(t.getKey());if(f){const p=f.style;s=De(p.getPropertyValue("grid-template-columns")).map(m=>m.slice(0,-1)),i=s?s.length:0}}const a=100/(i+1),r=[...s];r.splice(o,0,`${a}%`);let d=a/i;for(let f=0;f<r.length;f++)if(o!==f){const p=Number(r[f])-d;r[f]=`minmax(100px,${Ze(p)}%)`}else r[f]=`minmax(100px,${r[f]})`;t.setTemplateColumns(r.join(" "))})},Re=(e,t,o,i)=>{e.update(()=>{const s=e.getElementByKey(t.getKey());if(!s)return;let a=i;o<i&&(a=i-1);const d=s.style.getPropertyValue("grid-template-columns").match(/minmax\([^)]*\)|\S+/g)||[],f=d.splice(o,1)[0];d.splice(a,0,f),t.setTemplateColumns(d.join(" "))})},Ie=(e,t)=>(e!=null&&e.children?Array.from(e.children):[]).indexOf(t);function mt(e,t,o,i){var f;let s=e.getAttribute("data-direction")==="left",a=e.getAttribute("data-direction")==="right",r=e.getAttribute("data-index"),d=e.getAttribute("data-index-start");if(s||a||r){let p=(f=o.getParent())==null?void 0:f.getParent();if(o instanceof C.LayoutContainerNode&&(p=o),o instanceof C.LayoutDividerNode||o instanceof C.LayoutContainerNode){const m=p==null?void 0:p.getChildren();let N=i instanceof C.LayoutDividerNode;if((m==null?void 0:m.length)>=4&&!N)return!0;t.update(()=>{var _;let g=0;s?g=0:a?g=((_=p==null?void 0:p.getChildren())==null?void 0:_.length)-1:g=Number(r),N?Re(t,p,Number(d),g):Je(t,p,g);let A=null;g!==void 0&&t.update(()=>{if(A=p.getChildren()[g],N)o instanceof C.LayoutContainerNode?A.insertAfter(i.getParent()):A.insertBefore(i.getParent());else if(a)A.insertAfter(C.$createLayoutItemNode().append(i).append(C.$createLayoutDividerNode()));else{const j=i.getParent(),L=j==null?void 0:j.getParent();C.$isLayoutItemNode(j)&&(j==null?void 0:j.getChildrenSize())===2&&C.$isLayoutItemNode(j)&&C.$isLayoutContainerNode(L)&&T.removeNodeKeepContent(t,j,L),A.insertBefore(C.$createLayoutItemNode().append(i).append(C.$createLayoutDividerNode()))}})})}else t.update(()=>{const m=C.$createLayoutContainerNode(ee.GRID_TWO_COL_WITH_GAP);let N;if(C.$isCalloutWrapperNode(o)||ee.$isCollapsibleContainerNode(o)){const g=i.getParent(),A=g==null?void 0:g.getParent();if(C.$isLayoutItemNode(g)&&(g==null?void 0:g.getChildrenSize())===2&&C.$isLayoutContainerNode(A)){const j=A.getParent(),L=j==null?void 0:j.getParent(),F=A.getChildren(),v=F.findIndex(B=>B===g)===0?1:0,P=F[v];if(C.$isLayoutItemNode(P)){const B=P.getChildren()[0];C.$isCalloutWrapperNode(L)&&(L.append(B),A.remove(),N=T.$copyNodeDeep(L))}}else N=T.$copyNodeDeep(o,i)}else N=T.$copyNodeDeep(o);N&&(s?(m.append(C.$createLayoutItemNode().append(i).append(C.$createLayoutDividerNode())),m.append(C.$createLayoutItemNode().append(N).append(C.$createLayoutDividerNode()))):(m.append(C.$createLayoutItemNode().append(N).append(C.$createLayoutDividerNode())),m.append(C.$createLayoutItemNode().append(i).append(C.$createLayoutDividerNode()))),o.insertAfter(m),o.remove(),N.selectStart())});return!0}return!1}function pt(e,t,o="right",i=!1){e.update(()=>{const s=c.$getNearestNodeFromDOMNode(t),a=s==null?void 0:s.getParent();if(a){if(De(a.__templateColumns).length===4)return;let d=Ie(t.parentElement,t);o==="right"&&(d=d+1),Je(e,a,d)}const r=C.$createLayoutItemNode().append(c.$createParagraphNode()).append(C.$createLayoutDividerNode());s&&(o==="right"?i?(s.insertBefore(T.$copyNodeDeep(s)),s.selectStart()):(s.insertAfter(r),r==null||r.selectStart()):(s.insertBefore(r),r.selectStart()))})}const et=(e,t)=>{const o=t==null?void 0:t.getParent();let i=De(o==null?void 0:o.getTemplateColumns());const s=o==null?void 0:o.getChildren();let a=0;if(s&&t){for(let m=0;m<s.length;m++)if(s[m].__key===t.__key){a=m;break}}i.splice(a,1);const r=i.map(m=>parseFloat(m)),d=r.reduce((m,N)=>m+N,0),p=r.map(m=>m/d*100).map(m=>`minmax(50px,${m.toFixed(2)}%)`);o==null||o.setTemplateColumns(p.join(" "))},gt=e=>e.className.includes("editor-image")||e.className.includes("video-container")?e:e.className.includes("editor-excalidraw")?e.firstChild:null,tt=(e,t)=>t!=null&&t.__key&&e!==t.__key?tt(e,t==null?void 0:t.getParent()):e===(t==null?void 0:t.__key),qe=(e,t,o)=>{e.update(()=>{var r,d,f;const i=(r=t==null?void 0:t.getParent())==null?void 0:r.getParent(),s=t==null?void 0:t.getParent(),a=o==="right"?(d=t==null?void 0:t.getParent())==null?void 0:d.getNextSibling():(f=t==null?void 0:t.getParent())==null?void 0:f.getPreviousSibling();if(s&&a&&i instanceof C.LayoutContainerNode){const p=e.getElementByKey(s.getKey()),m=e.getElementByKey(i.getKey()),N=Ie(m,p);s&&i&&a&&(o==="right"&&(Re(e,i,N+1,N),a.insertAfter(s)),o==="left"&&(Re(e,i,N,N+1),a.insertBefore(s)))}})};function ht(e){e&&(e.style.display="none")}function We({blockElement:e,editor:t,isTop:o,isClickedBlockRef:i,setDraggableBlockElem:s}){e&&(i.current=!0,t.update(()=>{const a=c.$getNearestNodeFromDOMNode(e);if(a){const r=c.$createParagraphNode();o?(a.insertBefore(r),setTimeout(()=>{s(t.getElementByKey(r.__key)),t.update(()=>{r.selectStart()})})):(a.insertAfter(r),setTimeout(()=>{s(t.getElementByKey(r.__key)),t.update(()=>{r.selectEnd()})}))}}))}function xt(e){const t=(f,p)=>f?parseFloat(window.getComputedStyle(f)[p]):0,{marginTop:o,marginBottom:i}=window.getComputedStyle(e),s=t(e.previousElementSibling,"marginBottom"),a=t(e.nextElementSibling,"marginTop"),r=Math.max(parseFloat(o),s);return{marginBottom:Math.max(parseFloat(i),a),marginTop:r}}function Ct(e){return!!e.closest(`.${dt}`)}function Ue(e,t,o,i){if(!e){t.style.opacity="0";return}t.style.display="block";let s=null;const a=gt(e);a&&a.style.justifyContent!=="left"&&a.firstChild instanceof HTMLElement?s=a.firstChild.getBoundingClientRect():s=e.getBoundingClientRect();let r=null,d=0,f=!0,p=0;if(s){let F=e.firstChild instanceof HTMLElement&&(e.firstChild.hasAttribute("data-lexical-text")||e.firstChild.tagName==="LI"||e.firstChild.tagName==="A")?e.firstChild:null;if(F&&!F.className.includes("editor-image")&&e.tagName!=="CODE"){const M=window.getComputedStyle(F),v=parseFloat(M.lineHeight),P=parseFloat(M.fontSize);p=Math.ceil(P+(v-P)/2),r=F.getBoundingClientRect()}else if(e.firstChild instanceof HTMLElement&&e.firstChild.tagName==="BR"&&e.tagName!=="CODE"){const M=window.getComputedStyle(e,"::before");p=parseFloat(M.height)||30}else e&&(e.tagName==="HR"||e.matches(":has(audio)")||e.classList.contains("file-container"))?p=e.clientHeight:e.firstChild instanceof HTMLElement&&e.firstChild.tagName==="SUMMARY"?p=e.firstChild.clientHeight:(r=s,f=!1)}const m=o.getBoundingClientRect(),N=(r==null?void 0:r.top)||s.top,g=p||d,A=t.clientHeight,_=g-A;let j=!f||!g?s.top+7-m.top:N+_/2-m.top,L=s.left-m.left-A*2-3;e.tagName==="LI"&&e.getAttribute("role")!=="checkbox"&&(L=L-26,j=j-1),a&&(j=N-m.top+7,(a.style.justifyContent==="center"||a.style.justifyContent==="right")&&(L=L+10)),e.matches(":has(.resizable-container__handle)")&&!e.matches(":has(.hide-padding)")&&(j=N-m.top+27),s.top<0&&(j=j+-s.top),e.className==="dsd__theme__layoutDivider"&&(t.style.display="none",s.top-t.clientHeight<0?e.style.setProperty("--height-column",`${e.clientHeight+s.top-t.clientHeight-7}px`):e.style.setProperty("--height-column",`${e.clientHeight}px`)),t.style.opacity="1",!i&&L>-40&&(t.style.transform=`translate(${L}px, ${j}px)`)}function Ye(e,t){const{transform:o}=t.style;t.style.transform="translateZ(0)",e.setDragImage(t,0,0),setTimeout(()=>{t.style.transform=o})}function yt(e,t){const o=document.createElement("div");o.style.position="absolute",o.style.top="-9999px",o.style.left="-9999px",t.forEach(i=>{const s=i.cloneNode(!0);s.style.position="relative",o.appendChild(s)}),document.body.appendChild(o),e.setDragImage(o,0,0),setTimeout(()=>document.body.removeChild(o),0)}function bt(e,t,o,i,s,a,r){var x;const{top:d,height:f,width:p,left:m}=t.getBoundingClientRect(),{top:N,left:g,width:A}=s==null?void 0:s.getBoundingClientRect(),{marginTop:_,marginBottom:j}=xt(t);let L=d;o>=d?(r.current.isBottom=!0,L+=f+j/2):(r.current.isBottom=!1,L-=_/2);const F=L-N-ut,M=ft-ct,P=a.target.closest(".dsd__theme__layoutDivider");e.setAttribute("data-index",""),e.style.background="deepskyblue";const B=m-g-M;if(i<=m&&!P){if(t.closest(".dsd__theme__layoutItem"))return;e.style.transform=`translate(${B}px, ${d-N}px)`,e.style.width="4px",e.style.height=`${f}px`,e.style.opacity=".4",e.setAttribute("data-direction","left")}else if(i>=A-B&&!P&&!t.closest(".dsd__theme__layoutItem"))t.classList.contains("dsd__theme__layoutContainer")&&!e.getAttribute("data-index-start")&&t&&t.children.length>=4&&(e.style.background="red"),e.style.transform=`translate(${A-B}px, ${d-N}px)`,e.style.width="4px",e.style.height=`${f}px`,e.style.opacity=".4",e.setAttribute("data-direction","right");else if(P){a.preventDefault();const S=(x=P.parentNode)==null?void 0:x.parentNode;(S==null?void 0:S.children.length)===4&&(e.style.background="red");const k=P.parentNode,O=Ie(S,k),R=O?P.getBoundingClientRect().left-g:B+30;e.style.transform=`translate(${R}px, ${d-N}px)`,e.style.width="4px",e.style.height=`${f}px`,e.style.opacity=".4",e.setAttribute("data-index",`${O}`)}else e.style.transform=`translate(${B}px, ${F}px)`,e.style.width=`${p+M}px`,e.style.opacity=".4",e.style.height="4px",e.setAttribute("data-direction","")}function Ge(e){e&&(e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)")}const Tt=({hoveredButton:e,insertNewParagraph:t,currentDraggableBlockRef:o,setHoveredButton:i,isClickedBlockRef:s,setDraggableBlockElem:a,editor:r,t:d})=>n.jsx("div",{className:`icon add-block-menu ${e?"active":""}`,onClick:()=>{t({blockElement:o.current.htmlElement,editor:r,isTop:!1,isClickedBlockRef:s,setDraggableBlockElem:a}),i("both")},onMouseEnter:()=>{i("bottom")},onMouseLeave:()=>{i("both")},children:n.jsx(u.Tooltip,{openDelay:300,label:d("editor.hoverOptions.addNewBlockAbove"),position:"bottom",disabled:s.current||!e,children:n.jsx(u.ActionIcon,{radius:"sm",color:"gray",size:"xs",variant:"subtle","aria-label":"Settings",children:e==="bottom"?n.jsx($.IconPlus,{}):n.jsx($.IconMinus,{})})})}),Mt=({hoveredButton:e,insertNewParagraph:t,currentDraggableBlockRef:o,setHoveredButton:i,isClickedBlockRef:s,setDraggableBlockElem:a,editor:r,t:d})=>n.jsx("div",{className:`icon add-block-menu add-block-menu_top ${e?"active":""}`,onClick:()=>{t({blockElement:o.current.htmlElement,editor:r,isTop:!0,isClickedBlockRef:s,setDraggableBlockElem:a}),i("both")},onMouseEnter:()=>{i("top")},onMouseLeave:()=>{i("both")},children:n.jsx(u.Tooltip,{disabled:s.current||!e,openDelay:300,label:d("editor.hoverOptions.addNewBlockBelow"),position:"top",children:n.jsx(u.ActionIcon,{radius:"sm",color:"gray",size:"xs",variant:"subtle","aria-label":"Settings",children:e==="top"?n.jsx($.IconPlus,{}):n.jsx($.IconMinus,{})})})});function nt(e,t){var a,r;const o=(a=t.exportDOM)==null?void 0:a.call(t,e),i=(o==null?void 0:o.element)??null;if(c.$isElementNode(t)){const d=i??document.createElement("div"),f=((r=t.getChildren)==null?void 0:r.call(t))??[];for(const p of f){const m=nt(e,p);if(m)d.appendChild(m);else{const N=typeof p.getTextContent=="function"?p.getTextContent():"";N&&d.appendChild(document.createTextNode(N))}}return typeof(o==null?void 0:o.after)=="function"&&o.after(d),d}if(i)return typeof(o==null?void 0:o.after)=="function"&&o.after(i),i;const s=typeof t.getTextContent=="function"?t.getTextContent():"";return s?document.createTextNode(s):null}async function Xe(e,t){const o=e.getRootElement(),i=Array.from(o.querySelectorAll(".selected-block"));if(!i.length)return;let s="",a="";e.getEditorState().read(()=>{e.update(()=>{let r=i.map(f=>c.$getNearestNodeFromDOMNode(f)).filter(f=>!!f);s=r.map(f=>typeof f.getTextContent=="function"?f.getTextContent():"").filter(Boolean).join(`
|
|
2
2
|
`);const d=document.createElement("div");r.forEach(f=>{const p=nt(e,f);t==="cut"&&f.remove(),p&&d.appendChild(p)}),a=d.innerHTML})}),(s||a)&&await Nt(s,a)}async function Nt(e,t){if(navigator.clipboard&&"write"in navigator.clipboard&&window.ClipboardItem){const o=new ClipboardItem({"text/plain":new Blob([e],{type:"text/plain"}),...t?{"text/html":new Blob([t],{type:"text/html"})}:{}});await navigator.clipboard.write([o])}}const Ve=(e,t,o,i)=>{if(o)if(i==="layout"){const s=o.getParent(),a=s.getParent();T.removeNodeKeepContent(e,s,a),t("delete")}else{const s=o==null?void 0:o.getParent();if(s instanceof C.LayoutItemNode&&s.getChildren().length===2){const a=s,r=s.getParent();if(o.__type==="image"){a.append(c.$createParagraphNode());return}T.removeNodeKeepContent(e,a,r)}T.deleteNode(e,o),t("delete")}},Qe=e=>{const t=e._rootElement;return Array.from(t.querySelectorAll(".selected-block"))},Fe=(e,t,o,i=!1)=>{t&&e.update(()=>{const s=e.getElementByKey(t.getParent().getKey());pt(e,s,o,i)})},_t=(e,t,o,i)=>{if(i==="layout")Fe(e,o,"right",!0);else{const s=e._rootElement,a=Array.from(s.querySelectorAll(".selected-block")).reverse();a.length&&(e.update(()=>{const r=c.$getNearestNodeFromDOMNode(a[0]);a.forEach(d=>{let f=c.$getNearestNodeFromDOMNode(d);f&&(r==null||r.insertAfter(T.$copyNodeDeep(f))),ee.$removeSelectedHTMLElement(d)})}),t())}},St=({editor:e,onChange:t,currentEditorNode:o,textBlock:i,t:s,isDisabledAddColumnButton:a,disabledMoveColumnButtons:r})=>{const{fetchUploadMedia:d,excludeNodes:f}=l.useContext(Ce.Context),[p,m]=l.useState("inherit"),[N,g]=l.useState("inherit"),[A,_]=l.useState("inherit"),[j,L]=l.useState("");l.useEffect(()=>{const x=o==null?void 0:o.__type;e.read(()=>{var S;((S=o==null?void 0:o.getParent())==null?void 0:S.__type)==="layout-item"?L("layout"):L(x==="callout-wrapper"?x:"block")})},[o==null?void 0:o.__key]);const F=x=>x.split(";").filter(Boolean).reduce((S,k)=>{const[O,R]=k.split(":").map(U=>U.trim());return O&&R&&(S[O]=R),S},{}),M=x=>Object.entries(x).map(([S,k])=>`${S}: ${k}`).join("; "),v=l.useCallback(x=>{e.update(()=>{const S=Qe(e).map(O=>c.$getNearestNodeFromDOMNode(O)).filter(Boolean),k=O=>{if(typeof O.getStyle=="function"&&typeof O.setStyle=="function"){const R=F(O.getStyle());R.color=x.color,R["background-color"]=x.bgColor,O.setStyle(M(R)),m(x.bgColor),_(x.color)}};S.forEach(O=>{if(O instanceof C.ListNode){O.getChildren().forEach(R=>{const U=R.getFirstChild();U instanceof C.ExtendedTextNode&&k(U)});return}if(O instanceof c.ElementNode){const R=O.getFirstChild();R instanceof C.ExtendedTextNode&&k(R)}})})},[m,_]),P=(x,S)=>{const k=S||j;k==="callout-wrapper"&&o instanceof C.CalloutWrapperNode?e.update(()=>{const O=ee.isCalloutValue(x);o.setType(O?x.meta.type:void 0),o.setBackgroundColor(x.value)}):k==="layout-color"?e.update(()=>{const O=o==null?void 0:o.getParent(),R=x.value===N?"inherit":x.value;O instanceof C.LayoutItemNode&&O.setLayoutBackground(R)}):v({color:A,bgColor:p,[x.mode==="background"?"bgColor":x.mode]:x.value})},B=x=>{const S=Qe(e);S.length?S.forEach(k=>{e.update(()=>{let O=c.$getNearestNodeFromDOMNode(k);O&&Ve(e,t,O,x)})}):e.update(()=>{let k=c.$getNearestNodeFromDOMNode(S[0]);Ve(e,t,k,x)})};return l.useEffect(()=>{setTimeout(()=>{e.read(()=>{if(j==="callout-wrapper"&&o instanceof C.CalloutWrapperNode){m(o.__backgroundColor);return}const x=o==null?void 0:o.getParent();x instanceof C.LayoutItemNode&&g(x.__backgroundColor);const S=c.$getSelection();c.$isRangeSelection(S)&&(_(Ne.$getSelectionStyleValueForProperty(S,"color","inherit")),m(Ne.$getSelectionStyleValueForProperty(S,"background-color","inherit")))})})},[]),n.jsxs(n.Fragment,{children:[n.jsx(u.Menu.Item,{onMouseDown:x=>{x.preventDefault(),Xe(e,"copy"),t("copy")},leftSection:n.jsx($.IconClipboard,{style:{width:u.rem(14),height:u.rem(14)}}),children:s("editor.link.copy")}),n.jsx(u.Menu.Item,{onMouseDown:x=>{x.preventDefault(),Xe(e,"cut"),t("cut")},leftSection:n.jsx($.IconCut,{style:{width:u.rem(14),height:u.rem(14)}}),children:s("editor.contextMenu.cut")}),n.jsx(u.Menu.Item,{onClick:()=>B(""),leftSection:n.jsx($.IconTrash,{style:{width:u.rem(14),height:u.rem(14)}}),children:s("editor.contextMenu.delete")}),n.jsx(u.Menu.Item,{disabled:j==="layout"&&a,onClick:()=>_t(e,t,o,j),leftSection:n.jsx($.IconCopy,{style:{width:u.rem(14),height:u.rem(14)}}),children:s("editor.contextMenu.duplicate")}),i==="text"&&j!=="callout-wrapper"&&n.jsxs(n.Fragment,{children:[n.jsx(u.Menu.Divider,{}),n.jsx(ee.BlockFormatMenu,{disabled:!1,blockType:"paragraph",rootType:"root",editor:e,mode:"editor",fetchUploadMedia:d,excludeNodes:f,onChange:t,menuProps:{trigger:"hover",position:"right-start",offset:{mainAxis:0,alignmentAxis:0}},children:n.jsx("div",{children:n.jsx(V.CustomMenuItem,{label:s("editor.toolbar.turnInto"),icon:n.jsx($.IconArrowsRightLeft,{style:{width:u.rem(14),height:u.rem(14)}})})})})]}),(i==="text"||j=="callout-wrapper")&&n.jsxs(n.Fragment,{children:[n.jsx(u.Menu.Divider,{}),n.jsx(Pe.NewColorPicker,{data:{callout:{label:s("editor.colors.theme"),filled:!0,palette:ee.calloutData.map(x=>({label:s(`editor.colors.callout.${x.name}`),value:u.alpha(x.color,.19),icon:x.icon,meta:{type:x.name,emoji:x.emoji}}))}},modes:j==="callout-wrapper"?["callout","background"]:["color","background"],value:{color:A,background:p,callout:p},onChange:x=>{P(x),t(),T.resetSelection(e)},hideInherit:!0,target:n.jsx("div",{children:n.jsx(V.CustomMenuItem,{label:s(j==="callout-wrapper"?"editor.contextMenu.appearance":"editor.toolbar.color"),icon:n.jsx($.IconPaint,{size:14})})}),menuProps:{trigger:"hover",position:"right-start",offset:{mainAxis:0,alignmentAxis:0}}})]}),j==="layout"&&n.jsxs(n.Fragment,{children:[n.jsx(u.Menu.Divider,{}),n.jsx(Pe.NewColorPicker,{modes:["background"],value:{background:N},onChange:x=>{P(x,"layout-color"),t(),T.resetSelection(e)},hideInherit:!0,target:n.jsx("div",{children:n.jsx(V.CustomMenuItem,{label:s("editor.column.changeColor"),icon:n.jsx($.IconPaint,{size:14})})}),menuProps:{trigger:"hover",position:"right-start",offset:{mainAxis:0,alignmentAxis:0}}}),n.jsx(u.Menu.Item,{disabled:a,onClick:()=>{Fe(e,o,"left")},leftSection:n.jsx($.IconColumnInsertLeft,{style:{width:u.rem(14),height:u.rem(14)}}),children:s("editor.column.addLeft")}),n.jsx(u.Menu.Item,{disabled:a,onClick:()=>{Fe(e,o,"right")},leftSection:n.jsx($.IconColumnInsertRight,{style:{width:u.rem(14),height:u.rem(14)}}),children:s("editor.column.addRight")}),n.jsx(u.Menu.Item,{disabled:r.left,onClick:()=>{qe(e,o,"left"),T.resetSelection(e)},leftSection:n.jsx($.IconColumnInsertRight,{style:{width:u.rem(14),height:u.rem(14)}}),children:s("editor.column.moveLeft")}),n.jsx(u.Menu.Item,{disabled:r.right,onClick:()=>{qe(e,o,"right"),T.resetSelection(e)},leftSection:n.jsx($.IconColumnInsertRight,{style:{width:u.rem(14),height:u.rem(14)}}),children:s("editor.column.moveRight")}),n.jsx(u.Menu.Item,{onClick:()=>B("layout"),leftSection:n.jsx($.IconTrash,{style:{width:u.rem(14),height:u.rem(14)}}),children:s("editor.column.deleteColumn")})]})]})};function It(e){if(!e)return window;let t=e;for(;t;){if(t===document.body||t===document.documentElement)return window;const i=getComputedStyle(t).overflowY;if((i==="auto"||i==="scroll"||i==="overlay")&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return window}function jt(e,t){let o=150;const{clientY:i}=e;if(t===window){const s=window.innerHeight;i<o?window.scrollBy(0,Math.max(-15,(i-o)/15)):i>s-o&&window.scrollBy(0,Math.min(15,(i-(s-o))/15))}else{o=100;const s=t.getBoundingClientRect();i<s.top+o?t.scrollTop-=5:i>s.bottom-o&&(t.scrollTop+=5)}}const $t=lt.lodashExports.throttle((e,t)=>{e.preventDefault(),jt(e,t)},16);let ve=null;function kt(e){return e?e.classList.contains("dsd__theme__table-scrollable-wrapper")?e.firstElementChild:e:null}function vt(e,t,o){const i=l.useRef(null),s=l.useRef(null),a=l.useRef(!1),r=l.useRef(!1),d=l.useRef({htmlElement:null,lexicalNode:null,isBottom:!1}),f=l.useRef(null),[p,m]=l.useState(null),{disable:N}=l.useContext(Ce.Context),[g,A]=l.useState(!1),[_,j]=l.useState({opened:!1}),[L,F]=l.useState(""),[M,v]=l.useState(null),[P,B]=l.useState(!1),[x,S]=l.useState({left:!1,right:!1}),[k,O]=l.useState(null),{t:R}=Ee.useTranslation(),U=ee.useDebounce(y=>{const h=y.target;r.current||T.isHTMLElement(h)&&(Ct(h)||e.read(()=>{var X;const w=h.className.includes("content-editable-wrapper"),G=w?c.$getRoot():c.$getNearestNodeFromDOMNode(h),{htmlElement:W,lexicalNode:D}=T.$getBlockNode(G,e,{root:!0,"layout-container":!0,"layout-item":!0,callout:!0,"collapsible-content":!0},y);if((D==null?void 0:D.__type)==="callout"||(D==null?void 0:D.__type)==="callout-image"||((X=D==null?void 0:D.getParent())==null?void 0:X.__type)==="callout"&&(D==null?void 0:D.getPreviousSibling())===null){m(null);return}if(!(w&&D instanceof C.LayoutDividerNode||w&&!D)&&D!=null&&D.__key){if(D.__type==="layout-container"||D.__type==="layout-item"||D.__type==="collapsible-content"){m(null);return}W&&(d.current.htmlElement=W,d.current.lexicalNode=D),(D==null?void 0:D.__type)==="collapsible-title"&&(d.current.htmlElement=(W==null?void 0:W.parentElement)||W,d.current.lexicalNode=D.getParent()),v(null),m(d.current.htmlElement)}}))},20,50);l.useEffect(()=>()=>{ve=null},[]),l.useEffect(()=>{function y(){r.current||m(null)}function h(G){if(!a.current)return!1;const[W]=xe.eventFiles(G);if(W)return!1;const{target:D,dataTransfer:X}=G,te=(X==null?void 0:X.getData(ze))||"";e.update(()=>{var ge;let b=c.$getNodeByKey(te);if(!b||!(T.isHTMLElement(D)||D.closest(".resizable-container")))return!1;const{htmlElement:H,lexicalNode:ie,isBottom:K}=d.current;let z=ie,pe=null;if(z!=null&&z.__key&&(pe=H),!pe||!z)return!1;if(z===b)return!0;if(s.current&&mt(s.current,e,z,b))return!1;if(b.__type==="layout-divider"){if(b=b.getParent(),ie&&(b!=null&&b.isParentOf(ie)))return!1;et(e,b)}if(b.getParent()instanceof C.LayoutItemNode&&((ge=b.getParent())==null?void 0:ge.getChildren().length)===2){const he=b.getParent(),Te=he.getParent();T.removeNodeKeepContent(e,he,Te)}if(H!=null&&H.classList.contains("selected-block"))return;let be;const re=e._rootElement;K?be=Array.from(re.querySelectorAll(".selected-block")).reverse():be=Array.from(re.querySelectorAll(".selected-block")),be.length?be.forEach(he=>{let Te=c.$getNearestNodeFromDOMNode(he);K?z==null||z.insertAfter(Te):z==null||z.insertBefore(Te)}):K?z.insertAfter(b):z.insertBefore(b),m(null)})}function w(G){const{target:W}=G;T.isHTMLElement(W)&&W.className==="ContentEditable__root"&&Ge(s.current)}return t==null||t.addEventListener("mousemove",U),t==null||t.addEventListener("drop",h),t==null||t.addEventListener("mouseleave",y),t==null||t.addEventListener("dragleave",w),()=>{t==null||t.removeEventListener("mousemove",U),t==null||t.addEventListener("drop",h),t==null||t.removeEventListener("mouseleave",y),t==null||t.removeEventListener("dragleave",w)}},[t,e]),l.useEffect(()=>{if(i.current){if(r.current||_.opened)return;Ue(p,i.current,t,_.opened)}},[t,p,r.current,_.opened]),l.useEffect(()=>{function y(h){var K,z;const{clientY:w,target:G,pageX:W}=h;if(!a.current)return!1;const[D]=xe.eventFiles(h);if(D||!T.isHTMLElement(G))return!1;const X=c.$getNearestNodeFromDOMNode(G)||c.$getRoot(),{htmlElement:te,lexicalNode:b}=T.$getBlockNode(X,e,{root:!0,"layout-container":!0,"layout-item":!0,"callout-wrapper":!0,callout:!0,"collapsible-content":!0,"collapsible-container":!0},h);if(h.preventDefault(),(b==null?void 0:b.__type)==="callout"||(b==null?void 0:b.__type)==="collapsible-content"||tt(f.current,b==null?void 0:b.getParent())||(b==null?void 0:b.__type)==="layout-item"&&X.__type!=="root")return!1;te&&(d.current.htmlElement=te,d.current.lexicalNode=b);let H=null;H=d.current.htmlElement||te,H!=null&&H.closest(".dsd__theme__layoutContainer")&&X.__type==="root"&&b&&((b==null?void 0:b.__type)==="layout-item"&&X.__type==="root"?(H=H==null?void 0:H.parentElement,d.current.htmlElement=H,d.current.lexicalNode=b==null?void 0:b.getParent()):(H=(K=H.parentElement)==null?void 0:K.parentElement,d.current.htmlElement=H,d.current.lexicalNode=(z=b.getParent())==null?void 0:z.getParent()));const ie=s.current;return!H&&ie?(ie.style.background="transparent",!1):H===null||ie===null||H!=null&&H.classList.contains("selected-block")?!1:(bt(ie,H,w,W,t,h,d),!0)}return de.mergeRegister(e.registerCommand(T.ON_CHANGE_COMMAND,h=>h==="hide_menu"?(ht(i.current),setTimeout(()=>{r.current=!0},0),!1):h==="show_menu"?(r.current=!1,!1):(h===!0&&!r.current&&m(null),r.current=!1,!1),c.COMMAND_PRIORITY_LOW),e.registerCommand(T.RIGHT_CLICK_COMMAND,h=>((h==null?void 0:h.target)instanceof HTMLElement&&i.current instanceof HTMLElement&&(Z(h),Ue(h.target,i.current,t,_.opened)),!1),c.COMMAND_PRIORITY_LOW),e.registerCommand(c.DRAGOVER_COMMAND,h=>(ve||(ve=It(h.target)),$t(h,ve),y(h)),c.COMMAND_PRIORITY_LOW),e.registerCommand(c.KEY_ARROW_DOWN_COMMAND,()=>(e.dispatchCommand(T.ON_CHANGE_COMMAND,!0),!1),c.COMMAND_PRIORITY_LOW),e.registerCommand(c.KEY_ARROW_UP_COMMAND,()=>(e.dispatchCommand(T.ON_CHANGE_COMMAND,!0),!1),c.COMMAND_PRIORITY_LOW))},[t,e]);function ae(y){var D;const h=y.dataTransfer;(D=s.current)==null||D.setAttribute("data-index-start","");const w=p||d.current.htmlElement;if(!h||!w)return;const G=e._rootElement;if(w!=null&&w.classList.contains("selected-block")){const X=e._rootElement,te=Array.from(X.querySelectorAll(".selected-block"));yt(y.dataTransfer,te)}else ee.$removeSelectedHTMLElements(G),w.className.includes("_layoutDivider")&&w.parentElement?Ye(h,w.parentElement):Ye(h,w);let W="";e.read(()=>{var te,b;const X=c.$getNearestNodeFromDOMNode(w);if(X&&(W=X.getKey()),X instanceof C.LayoutDividerNode){const H=Ie((te=w.parentElement)==null?void 0:te.parentElement,w.parentElement);(b=s.current)==null||b.setAttribute("data-index-start",H.toString())}}),i.current&&(A(!0),i.current.style.opacity="0"),a.current=!0,f.current=W,h.setData(ze,W)}function Y(){a.current=!1,Ge(s.current),A(!1)}if(N)return n.jsx("div",{});function E(){var w;const y=d.current.htmlElement,h=(w=y==null?void 0:y.parentElement)==null?void 0:w.parentElement;if(h!=null&&h.classList.contains("dsd__theme__layoutContainer")&&(h.children.length===4?B(!0):B(!1),y!=null&&y.parentElement)){const G=Ie(h,y==null?void 0:y.parentElement);G?G===h.children.length-1?S({left:!1,right:!0}):S({left:!1,right:!1}):S({left:!0,right:!1})}}function Z(y){r.current=!0;const h=kt((y==null?void 0:y.target)??d.current.htmlElement);if(!h)return;const w=e._rootElement;E(),h.classList.contains("selected-block")||ee.$removeSelectedHTMLElements(w),e.update(()=>{const W=c.$getSelection(),X=((W==null?void 0:W.getNodes())??[]).filter(K=>!c.$isTextNode(K)&&!C.$isListNode(K)&&K.__parent==="root"),te=X.map(K=>{const z=e.getElementByKey(K.getKey());return K.getType()==="table"?z==null?void 0:z.firstElementChild:z}).filter(K=>K!==null),b=X.length&&te.includes(h)?te:[h];if(b.length===1){const K=c.$getNearestNodeFromDOMNode(h);if(!K)return;K.selectStart(),O(K)}else O(null);b.forEach(K=>{ee.$getSelectedHTMLElements(e,{block:K,isCreateEventListener:!1})});const H=Array.from(document.querySelectorAll(".selected-block")).reduce((K,z)=>{const pe=c.$getNearestNodeFromDOMNode(z);return pe&&K.push(pe),K},[]),ie=H.length>0&&H.every(K=>C.$isCalloutWrapperNode(K)||C.$isTableNode(K)||ee.$isCollapsibleContainerNode(K)?!1:c.$isElementNode(K)||c.$isTextNode(K));F(ie?"text":"block")}),T.blockScroll();const G=Number(y==null?void 0:y.y)+240>window.innerHeight?Number(y==null?void 0:y.y)-200:y==null?void 0:y.y;j({opened:!0,x:(y==null?void 0:y.x)??0,y:G??0}),e.dispatchCommand(T.ON_OPEN_KEBAB_MENU,!0)}const oe=()=>{e.update(()=>{const y=T.getCurrentElement();if(r.current=!1,j(h=>({opened:!1,x:h.x,y:h.y})),(y==null?void 0:y.__key)==="root"){const h=c.$createParagraphNode();y.append(h)}})},ce=o?"hide-add-button":"",me=_.x!==0?{position:"fixed",top:0,left:0,transform:`translate(${_.x}px, ${_.y}px)`}:{},_e=()=>{oe(),T.unblockScroll(),ee.onSelectEnd(e),ee.$removeSelectedHTMLElements(e._rootElement)},je=(y=!1)=>{y?e.update(()=>{const h=c.$getSelection();let w=null;c.$isRangeSelection(h)&&(w=h.anchor.getNode().getParent()),_e(),setTimeout(()=>{e.update(()=>{w==null||w.selectEnd()})},100)}):_e()},ye=l.useCallback(y=>{const h=document.querySelector(".draggable-menu");if(!_&&y.button!==2)return;const w=y.target;if(w.closest(".mantine-Menu-dropdown"))return;!((h==null?void 0:h.contains(w))&&w.closest("div.custom-menu-item"))&&y.button!==2&&_.opened&&(y.stopPropagation(),y.preventDefault())},[e,_]);return l.useEffect(()=>(_.opened?document.addEventListener("mousedown",ye):document.removeEventListener("mousedown",ye),()=>{document.removeEventListener("mousedown",ye)}),[_.opened,ye]),Be.createPortal(n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:`draggable-block-container ${ce} ${p?"visible":""}`,ref:i,onMouseEnter:()=>{var y;_||v("both"),(y=i.current)!=null&&y.style&&(i.current.style.opacity="1")},onMouseLeave:()=>{v(null)},children:[n.jsx(Mt,{hoveredButton:M,insertNewParagraph:We,currentDraggableBlockRef:d,setHoveredButton:v,isClickedBlockRef:r,setDraggableBlockElem:m,editor:e,t:R}),n.jsxs(u.Menu,{onOpen:Z,opened:_.opened,styles:{dropdown:me},position:"left-start",width:320,shadow:"md",withinPortal:!0,onClose:()=>{je()},transitionProps:C.animationMenu,children:[n.jsx(u.Menu.Target,{children:n.jsx("div",{className:"icon draggable-block-menu",draggable:!0,onDragStart:ae,onDragEnd:Y,children:n.jsx(u.Tooltip,{openDelay:300,multiline:!0,disabled:g||r.current,label:n.jsxs(n.Fragment,{children:[n.jsxs("span",{children:[n.jsx("strong",{children:R("editor.hoverOptions.drag")}),","," ",R("editor.hoverOptions.dragAction")]}),n.jsx("br",{}),n.jsxs("span",{children:[n.jsx("strong",{children:R("editor.hoverOptions.click")}),","," ",R("editor.hoverOptions.clickAction")]})]}),position:"bottom-start",children:n.jsx(u.ActionIcon,{radius:"sm",color:"gray",size:"sm",variant:"subtle","aria-label":"Settings",children:n.jsx($.IconGripVertical,{size:20})})})})}),n.jsx(Tt,{hoveredButton:M,insertNewParagraph:We,currentDraggableBlockRef:d,setHoveredButton:v,isClickedBlockRef:r,setDraggableBlockElem:m,editor:e,t:R}),n.jsx(u.Menu.Dropdown,{className:"draggable-menu",children:n.jsx(St,{onChange:()=>{je(!0),T.resetSelection(e)},t:R,textBlock:L,currentEditorNode:k,editor:e,isDisabledAddColumnButton:P,disabledMoveColumnButtons:x})})]})]}),n.jsx("div",{className:"draggable-block-target-line",ref:s})]}),t)}function At({anchorElem:e=document.body,isShowAddButton:t=!1}){const[o]=Oe.useLexicalComposerContext();return vt(o,e,t)}function Ot({editor:e,anchorElem:t,isLink:o,isBold:i,isItalic:s,isUnderline:a,isCode:r,isStrikethrough:d,isSubscript:f,isSuperscript:p,component:m,isText:N}){const g=l.useRef(null),A=l.useRef(!1),_=l.useRef(null),j=l.useCallback(()=>{e.dispatchCommand(T.ON_SHOW_LINK_POPUP,"create")},[e,o]);function L(){var M,v;g.current&&(A.current=!0,T.setFloatingElemPosition(((M=_.current)==null?void 0:M.rect)||null,g==null?void 0:g.current,t,(v=_.current)==null?void 0:v.isLink))}l.useEffect(()=>{const M=T.getNativeSelectedText();if(!N&&!(M!=null&&M.length)){let v=function(S){return S instanceof HTMLElement};const P=g.current,B=window.getSelection();let x=!1;B!=null&&B.anchorNode&&v(B.anchorNode)&&B.anchorNode.className==="toolbar"&&(x=!0),P&&!x&&(_.current={rect:null,floatingElem:P,anchorElem:t,isLink:o},T.setFloatingElemPosition(null,P,t,o),A.current=!1)}},[N,e]),l.useEffect(()=>{if(g!=null&&g.current)return document.addEventListener("mouseup",L),()=>{document.removeEventListener("mouseup",L)}},[g]),l.useEffect(()=>{e.registerCommand(c.KEY_DOWN_COMMAND,M=>{var v;return(M.metaKey||M.ctrlKey)&&M.code==="KeyA"?(M.preventDefault(),T.selectCurrentNode(e),T.getCurrentElement(!0)&&(T.isWholeNodeSelected()&&(g!=null&&g.current)?(T.setFloatingElemPosition(null,g==null?void 0:g.current,t,(v=_.current)==null?void 0:v.isLink),c.$selectAll(),ee.$getSelectedHTMLElements(e)):setTimeout(()=>{L()})),!0):!1},c.COMMAND_PRIORITY_LOW),e.registerCommand(T.ON_OPEN_KEBAB_MENU,()=>(setTimeout(()=>{var M;g!=null&&g.current&&T.setFloatingElemPosition(null,g==null?void 0:g.current,t,(M=_.current)==null?void 0:M.isLink)},100),!1),c.COMMAND_PRIORITY_LOW)},[e]);const F=l.useCallback(()=>{const M=c.$getSelection(),v=g.current,P=window.getSelection();if(v===null)return;const B=e.getRootElement();let x=!1;const S=T.getNativeSelectedText();if(S&&S.length>0&&(x=!0),M!==null&&P!==null&&!P.isCollapsed&&B!==null&&B.contains(P.anchorNode)&&x){const k=T.getDOMRangeRect(P,B);if(_.current={rect:k,floatingElem:v,anchorElem:t,isLink:o},c.$isRangeSelection(M)){const R=T.getSelectedNode(M).getParent(),U=R==null?void 0:R.getFormatType();A.current&&U&&g&&e.registerCommand(T.ON_OPEN_KEBAB_MENU,ae=>(ae||setTimeout(()=>{var Y,E;T.setFloatingElemPosition(((Y=_.current)==null?void 0:Y.rect)||null,v,t,(E=_.current)==null?void 0:E.isLink)},100),!1),c.COMMAND_PRIORITY_LOW)}}else _.current={rect:null,floatingElem:v,anchorElem:t,isLink:o}},[e,t,o]);return l.useEffect(()=>{const M=t.parentElement,v=()=>{e.getEditorState().read(()=>{F()})};return window.addEventListener("resize",v),M&&M.addEventListener("scroll",v),()=>{window.removeEventListener("resize",v),M&&M.removeEventListener("scroll",v)}},[e,F,t]),l.useEffect(()=>(e.getEditorState().read(()=>{F()}),de.mergeRegister(e.registerUpdateListener(({editorState:M})=>{M.read(()=>{F()})}),e.registerCommand(c.SELECTION_CHANGE_COMMAND,()=>(F(),!1),c.COMMAND_PRIORITY_LOW))),[e,F]),n.jsx("div",{ref:g,className:`floating-text-format-popup doc-space-editor-wrapper ${N?"":"floating-text-format-popup-hidden"}`,children:n.jsx("div",{children:e.isEditable()&&(m||n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",onClick:()=>{e.dispatchCommand(c.FORMAT_TEXT_COMMAND,"bold")},className:"popup-item spaced "+(i?"active":""),children:n.jsx(V.Icon,{name:"bold",stroke:i?3:2})}),n.jsx("button",{type:"button",onClick:()=>{e.dispatchCommand(c.FORMAT_TEXT_COMMAND,"italic")},className:"popup-item spaced "+(s?"active":""),children:n.jsx(V.Icon,{name:"italic",stroke:s?3:2})}),n.jsx("button",{type:"button",onClick:()=>{e.dispatchCommand(c.FORMAT_TEXT_COMMAND,"underline")},className:"popup-item spaced "+(a?"active":""),children:n.jsx(V.Icon,{name:"underline",stroke:a?3:2})}),n.jsx("button",{type:"button",onClick:()=>{e.dispatchCommand(c.FORMAT_TEXT_COMMAND,"strikethrough")},className:"popup-item spaced "+(d?"active":""),"data-test-id":"toolbar-strikethrough",children:n.jsx(V.Icon,{name:"strikethrough",stroke:d?3:2})}),n.jsx("button",{type:"button",onClick:()=>{e.dispatchCommand(c.FORMAT_TEXT_COMMAND,"subscript")},className:"popup-item spaced "+(f?"active":""),children:n.jsx(V.Icon,{name:"subscript",stroke:f?3:2})}),n.jsx("button",{type:"button",onClick:()=>{e.dispatchCommand(c.FORMAT_TEXT_COMMAND,"superscript")},className:"popup-item spaced "+(p?"active":""),children:n.jsx(V.Icon,{name:"superscript",stroke:p?3:2})}),n.jsx("button",{type:"button",onClick:()=>{e.dispatchCommand(c.FORMAT_TEXT_COMMAND,"code")},className:"popup-item spaced "+(r?"active":""),children:n.jsx(V.Icon,{name:"code"})}),n.jsx("button",{type:"button",onClick:j,className:"popup-item spaced "+(o?"active":""),children:n.jsx(V.Icon,{name:"link"})})]}))})})}function Dt(e,t,o){const[i,s]=l.useState(!1),[a,r]=l.useState(!1),[d,f]=l.useState(!1),[p,m]=l.useState(!1),[N,g]=l.useState(!1),[A,_]=l.useState(!1),[j,L]=l.useState(!1),[F,M]=l.useState(!1),[v,P]=l.useState(!1),B=T.allEditorSelected(),{disable:x}=l.useContext(Ce.Context),S=l.useCallback(()=>{e.getEditorState().read(()=>{var oe,ce,me;if(e.isComposing())return;const k=c.$getSelection(),O=window.getSelection(),R=e.getRootElement();if(O!==null&&(!c.$isRangeSelection(k)||R===null||!R.contains(O.anchorNode))){s(!1);return}if(!c.$isRangeSelection(k))return;const U=T.getSelectedNode(k);f(k.hasFormat("bold")),m(k.hasFormat("italic")),g(k.hasFormat("underline")),_(k.hasFormat("strikethrough")),L(k.hasFormat("subscript")),M(k.hasFormat("superscript")),P(k.hasFormat("code"));const ae=U.getParent();Me.$isLinkNode(ae)||Me.$isLinkNode(U)?r(!0):r(!1);const Y=rt.$isCodeHighlightNode(k.anchor.getNode()),E=(me=(ce=(oe=e.getElementByKey(U.__key))==null?void 0:oe.parentElement)==null?void 0:ce.parentElement)==null?void 0:me.classList.contains("Collapsible__title");!Y&&k.getTextContent()!==""&&!E?s(C.$isExtendedTextNode(U)||c.$isParagraphNode(U)||xe.$isHeadingNode(U)||xe.$isQuoteNode(U)||C.$isListItemNode(U)):s(!1);const Z=k.getTextContent().replace(/\n/g,"");if(!k.isCollapsed()&&Z===""){s(!1);return}})},[e]);return l.useEffect(()=>(document.addEventListener("selectionchange",S),()=>{document.removeEventListener("selectionchange",S)}),[S]),l.useEffect(()=>de.mergeRegister(e.registerUpdateListener(()=>{S()}),e.registerRootListener(()=>{e.getRootElement()===null&&s(!1)})),[e,S]),x?null:Be.createPortal(n.jsx(Ot,{editor:e,anchorElem:t,isLink:a,isBold:d,isItalic:p,isStrikethrough:A,isSubscript:j,isSuperscript:F,isUnderline:N,isCode:v,component:o,isText:i&&!B}),document.body)}function wt({anchorElem:e=document.body,component:t}){const[o]=Oe.useLexicalComposerContext();return Dt(o,e,t)}const Lt=(e,t,o,i)=>{e.update(()=>{if(c.$isRangeSelection(o)){const s=c.$createTextNode(t);o.insertNodes([s]),i()}})},Pt=(e,t,o,i)=>{e.update(()=>{if(c.$isRangeSelection(o)){const s=c.$createTextNode(t);o.insertNodes([]);const a=s.getParent()??o.focus.getNode().getParent();if(a){const r=o.focus.getNode().getNextSibling();r?r.insertBefore(s):a.append(s),i()}}})},Rt=(e,t="",o,i)=>{e.update(()=>{if(!c.$isRangeSelection(o))return;const a=o.anchor.getNode().getTopLevelElementOrThrow(),r=c.$createParagraphNode();t&&r.append(c.$createTextNode(t)),a.insertAfter(r),i()})},Ft=(e,t)=>{e.update(()=>{const o=c.$getSelection();if(c.$isRangeSelection(o)){const i=o.getTextContent();t(i)}})},Bt=({editor:e,response:t,onSubmit:o,setTypeMenu:i,onClose:s,t:a,selection:r})=>n.jsxs(n.Fragment,{children:[n.jsx(u.Menu.Item,{leftSection:n.jsx($.IconArrowNarrowLeft,{size:14}),onClick:()=>i("main"),children:a("editor.ai.back")}),n.jsx(u.Menu.Item,{onClick:()=>{Lt(e,t,r,s)},leftSection:n.jsx($.IconReplace,{size:14}),children:a("editor.ai.menu.answer.replaceSelection")}),n.jsx(u.Menu.Item,{onClick:()=>{Pt(e,` ${t}`,r,s)},leftSection:n.jsx($.IconTextPlus,{size:14}),children:a("editor.ai.menu.answer.addTextInline")}),n.jsx(u.Menu.Item,{onClick:()=>{Rt(e,t,r,s),s()},leftSection:n.jsx($.IconIndentIncrease,{size:14}),children:a("editor.ai.menu.answer.addBelowParagraph")}),n.jsx(u.Menu.Divider,{}),n.jsx(u.Menu.Label,{children:a("editor.ai.menu.answer.modifyFurther")}),n.jsx(u.Menu.Item,{onClick:()=>{o(`Start with this text and continue. Output this text at the start: "${t}"`,!1)},leftSection:n.jsx($.IconPlayerPlay,{size:14}),children:a("editor.ai.menu.answer.continueWriting")}),n.jsx(u.Menu.Item,{onClick:()=>{o("Regenerate this text with another way: ")},leftSection:n.jsx($.IconReload,{size:14}),children:a("editor.ai.menu.answer.regenerate")}),n.jsx(u.Menu.Item,{onClick:s,leftSection:n.jsx($.IconTrash,{size:14}),children:a("editor.ai.menu.answer.discard")})]}),Et=["arabic","bengali","chinese","dutch","english","french","german","hindi","japanese","korean","nepali","portuguese","spanish"],Ht=["professional","straightforward","friendly","poetic","passiveAggressive","pirate"],Kt=[{title:"modifySelection",options:[{title:"improveWriting",prompt:"Improve the quality of the text",icon:n.jsx($.IconWand,{size:14})},{title:"fixMistakes",prompt:"Fix any typos or general errors in the text",icon:n.jsx($.IconTextSpellcheck,{size:14})},{title:"simplify",prompt:"Shorten the text, simplifying it",icon:n.jsx($.IconSortAscending,{size:14})},{title:"addMoreDetail",prompt:"Lengthen the text, going into more detail",icon:n.jsx($.IconSortDescending,{size:14})}]},{title:"generate",options:[{title:"summarise",prompt:"Summarise the text",icon:n.jsx($.IconNotes,{size:14})},{title:"translate",icon:n.jsx($.IconLanguage,{size:14}),type:"language"},{title:"changeStyle",icon:n.jsx($.IconScript,{size:14}),type:"style"},{title:"explain",prompt:"Explain what the text is about",icon:n.jsx($.IconHelpOctagon,{size:14})}]}],zt=({setTypeMenu:e,onSubmit:t,t:o})=>n.jsxs(n.Fragment,{children:[n.jsx(u.Menu.Item,{leftSection:n.jsx($.IconArrowNarrowLeft,{size:14}),onClick:()=>e("main"),children:o("editor.ai.back")}),Et.map(i=>n.jsx(u.Menu.Item,{onClick:()=>{t(`Translate text into the ${i} language`)},children:o(`editor.ai.menu.languages.${i}`)},i))]}),qt=({setTypeMenu:e,onSubmit:t,t:o})=>n.jsx(n.Fragment,{children:Kt.map(i=>n.jsxs("div",{children:[n.jsx(u.Menu.Label,{children:o(`editor.ai.menu.main.${i.title}`)}),i.options.map(s=>n.jsx(u.Menu.Item,{onClick:()=>{if(s.type){e(s.type);return}t(s.prompt||"")},leftSection:s.icon,children:o(`editor.ai.menu.main.${s.title}`)},s.title))]},i.title))}),Wt=({setTypeMenu:e,onSubmit:t,t:o})=>n.jsxs(n.Fragment,{children:[n.jsx(u.Menu.Item,{leftSection:n.jsx($.IconArrowNarrowLeft,{size:14}),onClick:()=>e("main"),children:o("editor.ai.back")}),Ht.map(i=>n.jsx(u.Menu.Item,{onClick:()=>{t(`Change text into ${i} style`)},children:o(`editor.ai.menu.style.${i}`)},i))]}),Ut=({keyType:e,setTypeMenu:t,editor:o,onSubmit:i,response:s,onClose:a,t:r,selection:d})=>{switch(e){case"main":return n.jsx(qt,{t:r,setTypeMenu:t,onSubmit:i});case"answer":return n.jsx(Bt,{t:r,onSubmit:i,editor:o,response:s,setTypeMenu:t,onClose:a,selection:d});case"language":return n.jsx(zt,{t:r,onSubmit:i,setTypeMenu:t});case"style":return n.jsx(Wt,{t:r,onSubmit:i,setTypeMenu:t});default:return null}};function Yt(e,t=40){const[o,i]=l.useState(""),s=l.useRef(0),a=l.useRef(null),r=l.useRef(null);return l.useEffect(()=>{if(a.current&&clearInterval(a.current),i(""),s.current=0,!!e)return a.current=setInterval(()=>{i(d=>{const f=e[s.current];return s.current+=1,s.current>=e.length&&clearInterval(a.current),d+(f||"")})},t),()=>{a.current&&clearInterval(a.current)}},[e,t]),l.useEffect(()=>{r.current&&(r.current.scrollTop=r.current.scrollHeight)},[o]),{displayedText:o,containerRef:r}}const Gt=()=>{var ae;const[e,t]=l.useState({top:"0px",bottom:"auto"}),[o,i]=l.useState(!1),[s,a]=l.useState(!1),[r]=Oe.useLexicalComposerContext(),[d,f]=l.useState("main"),[p,m]=l.useState(""),[N,g]=l.useState(""),[A,_]=l.useState(""),[j,L]=l.useState(null),[F,M]=l.useState(!1),{fetchPromptResult:v}=l.useContext(Ce.Context),{t:P}=Ee.useTranslation(),[B,x]=He.useResizeObserver(),S=()=>{i(!1),a(!1),_(""),f("main"),setTimeout(()=>{t({top:"0px",bottom:"auto"})},200)},k=He.useClickOutside(()=>{S()});l.useEffect(()=>{o?(Ft(r,g),document.documentElement.style.overflow="hidden",r.update(()=>{const Y=c.$getSelection();Y&&L(Y)})):(f("main"),document.documentElement.style.overflow="auto",_(""))},[o]);const{displayedText:O,containerRef:R}=Yt(A,10),U=(Y,E=!0)=>{const Z=Y+` "${E?N:""}"Only return the modified text. Do not include any explanations, introductions, or formatting.`;M(!0),v&&v(Z,oe=>{_(oe),M(!1),f("answer"),m("")},()=>{M(!1)})};return l.useEffect(()=>{var E,Z,oe;const{bottom:Y}=((E=B.current)==null?void 0:E.getBoundingClientRect())||{bottom:0};if(Y>window.innerHeight){const ce=(((oe=(Z=r._rootElement)==null?void 0:Z.getBoundingClientRect())==null?void 0:oe.bottom)||0)-window.innerHeight;t({...e,top:"auto",bottom:`${ce}px`})}},[x.height,o,B.current]),(ae=r._rootElement)!=null&&ae.parentElement?n.jsxs(n.Fragment,{children:[e.top?Be.createPortal(n.jsx(u.Transition,{mounted:!!o,transition:"scale-x",duration:300,timingFunction:"ease",children:Y=>n.jsx(u.Box,{ref:k,style:{position:"absolute",...e,...Y},className:"ai-editor-menu",children:n.jsxs(u.Menu,{opened:!!s,closeOnItemClick:!1,position:"bottom-start",zIndex:99,transitionProps:{transition:"fade",duration:300},styles:{dropdown:{overflow:"auto"}},offset:8,middlewares:{flip:!0,size:{apply({availableHeight:E,elements:Z}){requestAnimationFrame(()=>{Object.assign(Z.floating.style,{maxHeight:`${E>=425?425:E}px`})})}}},disabled:F,children:[n.jsx(u.Menu.Target,{children:n.jsxs(u.Paper,{withBorder:!0,ref:B,shadow:"lg",radius:"md",p:"0",px:"xs",children:[A&&n.jsxs(n.Fragment,{children:[n.jsxs(u.Group,{gap:3,align:"flex-start",style:{overflowY:"auto"},mah:120,ref:R,children:[n.jsx(u.Box,{style:{flex:1},w:"auto",py:"xs",children:O}),n.jsx(u.Box,{w:"auto",mt:"xs",children:n.jsx(u.CopyButton,{value:A,timeout:2e3,children:({copied:E,copy:Z})=>n.jsx(u.Tooltip,{label:E?"Copied":"Copy",withArrow:!0,position:"right",children:n.jsx(u.ActionIcon,{color:E?"teal":"gray",variant:"subtle",onClick:Z,children:E?n.jsx($.IconCheck,{size:16}):n.jsx($.IconCopy,{size:16})})})})})]}),n.jsx(u.Divider,{my:"0"})]}),n.jsx(u.Box,{children:n.jsx(u.Input,{size:"md",placeholder:P("editor.ai.placeholder"),rightSectionPointerEvents:"all",variant:"unstyled",value:p,onKeyDown:E=>{if(E.key==="Enter"){if(F)return;U(p)}},onChange:E=>{m(E.target.value)},rightSection:n.jsx(n.Fragment,{children:F?n.jsx(u.Loader,{color:"violet",size:"16",mr:"xs"}):n.jsx(u.ActionIcon,{color:"violet",disabled:!p,variant:"subtle",onClick:()=>{U(p)},children:n.jsx($.IconSparkles,{size:16})})})})})]})}),n.jsx(u.Menu.Dropdown,{className:"menu-dropdown-ai",onMouseDown:E=>{E.stopPropagation()},children:n.jsx(Ut,{keyType:d,setTypeMenu:f,editor:r,onSubmit:U,response:A,onClose:S,t:P,selection:j})})]})})}),r._rootElement.parentElement):null,n.jsxs("button",{disabled:!1,className:"toolbar-item spaced alignment","aria-label":"Formatting options for text alignment",type:"button",onClick:()=>{const Y=document.querySelector(".floating-text-format-popup");if(Y.style.opacity="0",Y.style.transform="translate(-10000px, -10000px)",Y!=null&&Y.style){const E=window.getSelection();if((E==null?void 0:E.rangeCount)===0)return null;if(E){const oe=E.getRangeAt(0).getBoundingClientRect(),ce=document.querySelector(".content-editable-wrapper"),me=ce.getBoundingClientRect(),_e=oe.top-me.top+ce.scrollTop+oe.height+"px";t({top:_e,bottom:"auto"}),setTimeout(()=>{i(!0)},0),setTimeout(()=>{a(!0)},100)}}},children:[n.jsx($.IconSparkles,{color:"#7950f2",size:18}),n.jsx($.IconAi,{size:21,color:"#7950f2"})]})]}):null},Xt=({editor:e,isEditable:t,t:o})=>{const{fetchUploadMedia:i,imperativeHandleRef:s}=l.useContext(Ce.Context),[a,r]=l.useState(!1);return i?n.jsx(Ke.ImagePicker,{popoverProps:{opened:a,position:"bottom",onChange:r},onUpload:d=>{var f,p;!i||!d.length||(r(!1),(f=s==null?void 0:s.current)!=null&&f.insertImages&&((p=s.current)==null||p.insertImages(d)))},onChange:d=>{e.dispatchCommand(Ke.INSERT_IMAGE_COMMAND,{altText:"",src:d}),r(!1)},children:n.jsx(u.Tooltip,{label:o("editor.image.add_photo"),children:n.jsx("button",{disabled:!t,type:"button",onClick:()=>r(d=>!d),className:"toolbar-item spaced",children:n.jsx(V.Icon,{name:"photo"})})})}):null},Vt={bullet:"Маркированный список",check:"Чек-лист",code:"Кодовый блок",h1:"Заголовок 1",h2:"Заголовок 2",h3:"Заголовок 3",h4:"Заголовок 4",h5:"Заголовок 5",h6:"Заголовок 6",number:"Нумерованный список",paragraph:"Параграф",quote:"Цитата"};function Ae(){return n.jsx("div",{className:"divider"})}function Qt({mode:e,isFloating:t}){const[o]=Oe.useLexicalComposerContext(),[i,s]=l.useState(o),[a,r]=l.useState("paragraph"),[d,f]=l.useState("root"),[p,m]=l.useState(null),[N,g]=l.useState("#000"),[A,_]=l.useState("#fff"),[j,L]=l.useState("left"),[F,M]=l.useState(!1),[v,P]=l.useState(!1),[B,x]=l.useState(!1),[S,k]=l.useState(!1),[O,R]=l.useState(!1),[U,ae]=l.useState(!1),[Y,E]=l.useState(!1),[Z,oe]=l.useState(!1),[ce,me]=l.useState(!1),[_e,je]=l.useState(!1),[ye]=C.useModal(),[y,h]=l.useState(!1),[w,G]=l.useState(!0),[W,D]=l.useState(!0),[X,te]=l.useState(0),[b,H]=l.useState(()=>o.isEditable()),ie=e||"default",{excludeNodes:K,fetchUploadMedia:z,fetchPromptResult:pe,commentOptions:be}=l.useContext(Ce.Context),{t:re}=Ee.useTranslation(),ge=l.useCallback(()=>{const I=c.$getSelection();if(c.$isRangeSelection(I)){const q=I.anchor.getNode(),se=I.focus.getNode(),ne=c.$isRootNode(q)?null:q.getTopLevelElementOrThrow(),fe=c.$isRootNode(se)?null:se.getTopLevelElementOrThrow();let Q=q.getKey()==="root"?q:de.$findMatchingParent(q,ue=>{const ke=ue.getParent();return ke!==null&&c.$isRootOrShadowRoot(ke)});I.getNodes().length===1?G(!0):G(!1),Q===null&&(Q=q.getTopLevelElementOrThrow());const J=Q.getKey(),$e=i.getElementByKey(J);o.update(()=>{P(I.hasFormat("bold")),x(I.hasFormat("italic")),k(I.hasFormat("underline")),R(I.hasFormat("strikethrough")),ae(I.hasFormat("subscript")),E(I.hasFormat("superscript")),oe(I.hasFormat("code"))});const le=T.getSelectedNode(I),Se=le.getParent();Me.$isLinkNode(Se)||Me.$isLinkNode(le)?M(!0):M(!1),g(Ne.$getSelectionStyleValueForProperty(I,"color","inherit")),_(Ne.$getSelectionStyleValueForProperty(I,"background-color","inherit"));let Le;Me.$isLinkNode(Se)&&(Le=de.$findMatchingParent(le,ue=>c.$isElementNode(ue)&&!ue.isInline())),L(c.$isElementNode(Le)?Le.getFormatType():c.$isElementNode(le)?le.getFormatType():(Se==null?void 0:Se.getFormatType())||"left");const it=de.$findMatchingParent(le,C.$isTableNode);if(C.$isTableNode(it)?f("table"):f("root"),$e!==null&&(ne==null?void 0:ne.getKey())===(fe==null?void 0:fe.getKey()))if(m(J),C.$isListNode(Q)){const ue=de.$getNearestNodeOfType(q,C.ListNode),ke=ue?ue.getListType():Q.getListType();r(ke)}else{const ue=xe.$isHeadingNode(Q)?Q.getTag():Q.getType();ue in Vt&&r(ue)}else r("")}},[i,G]);l.useEffect(()=>o.registerCommand(c.SELECTION_CHANGE_COMMAND,(I,q)=>(ge(),s(q),!1),c.COMMAND_PRIORITY_CRITICAL),[o,ge]),l.useEffect(()=>de.mergeRegister(o.registerEditableListener(I=>{H(I)}),i.registerUpdateListener(({editorState:I})=>{I.read(()=>{ge()})}),i.registerCommand(c.CAN_UNDO_COMMAND,I=>(me(I),!1),c.COMMAND_PRIORITY_CRITICAL),i.registerCommand(c.CAN_REDO_COMMAND,I=>(je(I),!1),c.COMMAND_PRIORITY_CRITICAL)),[ge,i,o]),l.useEffect(()=>de.mergeRegister(i.registerCommand(c.KEY_MODIFIER_COMMAND,I=>{const q=I,{code:se,metaKey:ne}=q;if(se==="KeyK"&&ne){q.preventDefault();let fe;return F?fe=null:fe=T.sanitizeUrl("https://"),i.dispatchCommand(Me.TOGGLE_LINK_COMMAND,fe)}return!1},c.COMMAND_PRIORITY_NORMAL),i.registerCommand(c.CLICK_COMMAND,()=>{const I=c.$getSelection();if(c.$isRangeSelection(I)){const q=I.getNodes(),se=q.length>0&&q.every(ne=>C.$isCalloutWrapperNode(ne)||C.$isTableNode(ne)||ee.$isCollapsibleContainerNode(ne)?!1:c.$isElementNode(ne)||c.$isTextNode(ne));D(!se)}return!1},c.COMMAND_PRIORITY_NORMAL)),[i,F]),l.useCallback((I,q)=>{i.update(()=>{const se=c.$getSelection();se!==null&&Ne.$patchStyleText(se,I)},q?{tag:"historic"}:{})},[i]);const he=l.useCallback(()=>{setTimeout(()=>{i.dispatchCommand(c.FORMAT_TEXT_COMMAND,"")}),i.update(()=>{const I=c.$getSelection();if(c.$isRangeSelection(I)){const q=I.anchor,se=I.focus,ne=I.getNodes(),fe=I.extract();if(q.key===se.key&&q.offset===se.offset)return;ne.forEach((Q,we)=>{if(C.$isExtendedTextNode(Q)){let J=Q;we===0&&q.offset!==0&&(J=J.splitText(q.offset)[1]||J),we===ne.length-1&&(J=J.splitText(se.offset)[0]||J);const $e=fe[0];ne.length===1&&C.$isExtendedTextNode($e)&&(J=$e),J.__style!==""&&J.setStyle(""),J.__format!==0&&J.setFormat(0);const le=de.$getNearestBlockElementAncestorOrThrow(J);le.__format!==0&&le.setFormat(""),le.__indent!==0&&le.setIndent(0),Q=J}else xe.$isHeadingNode(Q)||xe.$isQuoteNode(Q)?Q.replace(c.$createParagraphNode(),!0):at.$isDecoratorBlockNode(Q)&&Q.setFormat("")})}})},[i]),Te=I=>{g(I.color),_(I["background-color"]),i.update(()=>{const q=c.$getSelection();q!==null&&Ne.$patchStyleText(q,I)})},ot=l.useCallback(()=>{o.dispatchCommand(T.ON_SHOW_LINK_POPUP,"create"),setTimeout(()=>{H(!0)},1e3)},[o]),st=()=>{o.dispatchCommand(Ce.INSERT_INLINE_COMMAND,void 0),te(I=>I+1)};return n.jsx("div",{className:"toolbar-wrapper",tabIndex:-1,children:n.jsxs("div",{className:"toolbar",children:[n.jsxs(n.Fragment,{children:[n.jsx(ee.BlockFormatMenu,{disabled:W,blockType:a,rootType:d,editor:o,mode:ie,fetchUploadMedia:z,excludeNodes:K}),n.jsx(Ae,{})]}),e==="editor"&&!0&&pe&&n.jsxs(n.Fragment,{children:[n.jsx(l.Suspense,{fallback:null,children:n.jsx(Gt,{})}),n.jsx(Ae,{})]}),n.jsxs(n.Fragment,{children:[n.jsx(u.Tooltip,{label:re("editor.toolbar.bold"),children:n.jsx("button",{disabled:!b,onClick:()=>{i.dispatchCommand(c.FORMAT_TEXT_COMMAND,"bold")},className:"toolbar-item spaced "+(v?"active":""),type:"button","data-test-id":"toolbar-bold",children:n.jsx(V.Icon,{name:"bold"})})}),n.jsx(u.Tooltip,{label:re("editor.toolbar.italic"),children:n.jsx("button",{disabled:!b,onClick:()=>{i.dispatchCommand(c.FORMAT_TEXT_COMMAND,"italic")},className:"toolbar-item spaced "+(B?"active":""),type:"button","data-test-id":"toolbar-italic",children:n.jsx(V.Icon,{name:"italic"})})}),n.jsx(u.Tooltip,{label:re("editor.toolbar.underline"),children:n.jsx("button",{disabled:!b,"data-test-id":"toolbar-underline",onClick:()=>{i.dispatchCommand(c.FORMAT_TEXT_COMMAND,"underline")},className:"toolbar-item spaced "+(S?"active":""),type:"button",children:n.jsx(V.Icon,{name:"underline"})})}),n.jsx(u.Tooltip,{label:re("editor.toolbar.strike"),children:n.jsx("button",{disabled:!b,className:"toolbar-item spaced "+(O?"active":""),"data-test-id":"toolbar-strikethrough",onClick:()=>{i.dispatchCommand(c.FORMAT_TEXT_COMMAND,"strikethrough")},children:n.jsx(V.Icon,{name:"strikethrough"})})}),n.jsx(u.Tooltip,{label:re("editor.toolbar.code"),children:n.jsx("button",{disabled:!b,onClick:()=>{i.dispatchCommand(c.FORMAT_TEXT_COMMAND,"code")},className:"toolbar-item spaced "+(Z?"active":""),type:"button","data-test-id":"toolbar-code",children:n.jsx(V.Icon,{name:"code"})})}),n.jsx(u.Tooltip,{label:re("editor.toolbar.clear"),children:n.jsx("button",{disabled:!b,className:"toolbar-item",onClick:he,"data-test-id":"toolbar-clear-format",children:n.jsx(V.Icon,{name:"сlear-format"})})}),n.jsx(u.Tooltip,{disabled:!b,label:re("editor.toolbar.link"),children:n.jsx("button",{onClick:ot,className:"toolbar-item spaced "+(F?"active":""),onMouseDown:()=>{H(!1)},type:"button","data-test-id":"toolbar-link",children:n.jsx(V.Icon,{name:"link"})})}),be&&e==="editor"&&n.jsx(u.Tooltip,{label:re("editor.toolbar.comment"),children:n.jsx("button",{onClick:st,className:"toolbar-item spaced "+(F?"active":""),type:"button","data-test-id":"toolbar-comment",children:n.jsx(V.Icon,{name:"message"})})},X),n.jsx(Pe.NewColorPicker,{value:{color:N,background:A},menuProps:{closeOnItemClick:!0},onChange:I=>{Te({color:N,"background-color":A,[I.mode==="color"?"color":"background-color"]:I.value})},disabled:!b,modes:["color","background"]})]}),n.jsx(Ae,{}),n.jsx(V.AlignMenu,{disabled:!b,value:j,editor:o,isRTL:y,setElementFormat:L}),e==="default"&&n.jsxs(n.Fragment,{children:[n.jsx(Ae,{}),n.jsx(Xt,{editor:o,t:re,isEditable:b})]}),ye]})})}exports.DraggableBlockPlugin=At;exports.FloatingTextFormatToolbarPlugin=wt;exports.ToolbarPlugin=Qt;exports.getTemplateColumns=De;exports.maxWidthPercent=Ze;exports.setTemplateColumnsAfterDelete=et;
|
|
@@ -13,21 +13,21 @@ import { CODE_LANGUAGE_FRIENDLY_NAME_MAP as Lr, CodeNode as Br, CODE_LANGUAGE_MA
|
|
|
13
13
|
import { Select as mo, Menu as X, Button as ve, Text as G, ActionIcon as Oe, alpha as vr, Tooltip as we, Group as Z, Image as Xe, Box as nt, Flex as po, Table as ye, Checkbox as ke, Divider as Ur, List as $, Title as Pr, Portal as ho, HoverCard as $t, Popover as ot, Stack as Pt, Input as Mt, Anchor as Kr, Transition as ft } from "@mantine/core";
|
|
14
14
|
import { IconExclamationCircle as jr, IconCheck as gn, IconAlertTriangle as Qr, IconChevronDown as fo, IconMenu2 as Yr, IconCopy as go, IconArrowsDiagonal as bo, IconArrowsDiagonalMinimize2 as Co, IconCircleDashed as Gr, IconPlayerPlayFilled as Jr, IconTriangleFilled as _e, IconCursorText as Hr, IconLink as Wr, IconPlus as $e } from "@tabler/icons-react";
|
|
15
15
|
import { NewColorPicker as Eo, EmojiPicker as qr, IconEntity as Fr } from "@layers-app/shared";
|
|
16
|
-
import { p as tt, q as Et, I as Vr, n as Gt, m as Se, f as Nt, k as Xr, c as _r, r as Ue, s as $r, t as es, u as He, v as yo, C as ts, w as ns, x as xn, y as Jt, z as os, A as rs, B as ss, D as wo, G as So, H as is, J as ls, K as as, N as cs, O as ds, P as en, Q as Ln, L as us, R as As, S as ms, T as Bn, U as yt, W as To, X as ps, Y as hs, Z as fs, _ as gs, a0 as bs, a1 as bn, a2 as No, a3 as Pe, a4 as kt, a5 as rt, a6 as On, a7 as Cs, a8 as Es, a9 as zn, aa as ys, ab as ze, ac as me, ad as Ge, ae as Ht, af as Ke, ag as Wt, ah as ws, ai as qt, aj as Dt, ak as Ss, al as Kt, am as cn, an as Ts, ao as Ns, ap as xt, aq as ks, ar as Is, as as Rs, at as Lt, au as Ms, av as xs, aw as Dn, ax as Ls, ay as Bs, az as Os, aA as zs, aB as Ds, aC as Zs, aD as vs } from "./layers.
|
|
17
|
-
import { I as Y, B as Zn } from "./layers.
|
|
18
|
-
import { o as Us, i as ce, m as Ps, q as Ks, r as js, $ as Cn, I as ko, u as Qs, v as Ft, w as Io, g as vn, x as Ro, y as Un, z as gt, A as tn, B as Ys, t as Pn, C as Gs, D as Js, O as dn, E as Hs } from "./layers.
|
|
16
|
+
import { p as tt, q as Et, I as Vr, n as Gt, m as Se, f as Nt, k as Xr, c as _r, r as Ue, s as $r, t as es, u as He, v as yo, C as ts, w as ns, x as xn, y as Jt, z as os, A as rs, B as ss, D as wo, G as So, H as is, J as ls, K as as, N as cs, O as ds, P as en, Q as Ln, L as us, R as As, S as ms, T as Bn, U as yt, W as To, X as ps, Y as hs, Z as fs, _ as gs, a0 as bs, a1 as bn, a2 as No, a3 as Pe, a4 as kt, a5 as rt, a6 as On, a7 as Cs, a8 as Es, a9 as zn, aa as ys, ab as ze, ac as me, ad as Ge, ae as Ht, af as Ke, ag as Wt, ah as ws, ai as qt, aj as Dt, ak as Ss, al as Kt, am as cn, an as Ts, ao as Ns, ap as xt, aq as ks, ar as Is, as as Rs, at as Lt, au as Ms, av as xs, aw as Dn, ax as Ls, ay as Bs, az as Os, aA as zs, aB as Ds, aC as Zs, aD as vs } from "./layers.Dq3o7sh3.js";
|
|
17
|
+
import { I as Y, B as Zn } from "./layers.CXffIp2y.js";
|
|
18
|
+
import { o as Us, i as ce, m as Ps, q as Ks, r as js, $ as Cn, I as ko, u as Qs, v as Ft, w as Io, g as vn, x as Ro, y as Un, z as gt, A as tn, B as Ys, t as Pn, C as Gs, D as Js, O as dn, E as Hs } from "./layers.Dev6Yrwi.js";
|
|
19
19
|
import { editorStateFromSerializedDocument as Ws, importFile as qs, exportFile as Fs, serializedDocumentFromEditorState as Vs } from "@lexical/file";
|
|
20
20
|
import { CHECK_LIST as Xs, HEADING as _s, QUOTE as $s, MULTILINE_ELEMENT_TRANSFORMERS as ei, TEXT_FORMAT_TRANSFORMERS as ti, TEXT_MATCH_TRANSFORMERS as ni, $convertToMarkdownString as Mo, $convertFromMarkdownString as xo } from "@lexical/markdown";
|
|
21
21
|
import { CONNECTED_COMMAND as oi } from "@lexical/yjs";
|
|
22
|
-
import { I as ri, d as si, e as Kn, C as En, c as ii, f as jn } from "./layers.
|
|
22
|
+
import { I as ri, d as si, e as Kn, C as En, c as ii, f as jn } from "./layers.7jmq6tBR.js";
|
|
23
23
|
import { $getClipboardDataFromSelection as Lo } from "@lexical/clipboard";
|
|
24
24
|
import { $isQuoteNode as li, $createHeadingNode as ai, $createQuoteNode as ci, $isHeadingNode as di } from "@lexical/rich-text";
|
|
25
25
|
import { debounce as st } from "lodash-es";
|
|
26
26
|
import { useBasicTypeaheadTriggerMatch as ui, LexicalTypeaheadMenuPlugin as Bo, MenuOption as Ai } from "@lexical/react/LexicalTypeaheadMenuPlugin";
|
|
27
27
|
import { INSERT_EMBED_COMMAND as mi } from "@lexical/react/LexicalAutoEmbedPlugin";
|
|
28
28
|
import { HorizontalRuleNode as pi, $createHorizontalRuleNode as Oo, $isHorizontalRuleNode as hi, INSERT_HORIZONTAL_RULE_COMMAND as fi } from "@lexical/react/LexicalHorizontalRuleNode";
|
|
29
|
-
import { f as gi, h as bi, j as Ci, k as Ei } from "./layers.
|
|
30
|
-
import { m as Qn, g as yi } from "./layers.
|
|
29
|
+
import { f as gi, h as bi, j as Ci, k as Ei } from "./layers.Ci1-qkbn.js";
|
|
30
|
+
import { m as Qn, g as yi } from "./layers.Duy8YzsH.js";
|
|
31
31
|
import { $createLinkNode as wi, TOGGLE_LINK_COMMAND as Zt, $isLinkNode as nn, $isAutoLinkNode as Yn } from "@lexical/link";
|
|
32
32
|
import { useClickOutside as Si } from "@mantine/hooks";
|
|
33
33
|
import { LinkPlugin as Ti } from "@lexical/react/LexicalLinkPlugin";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { $isElementNode as y, createCommand as h, $getRoot as S, $createParagraphNode as b, $getSelection as g, $isRangeSelection as p, $getNearestNodeFromDOMNode as N, $setSelection as M, $getNodeByKey as G, $createRangeSelection as V, $copyNode as O, ElementNode as x, ParagraphNode as W, INSERT_PARAGRAPH_COMMAND as j, COMMAND_PRIORITY_NORMAL as $, $isParagraphNode as J, DELETE_CHARACTER_COMMAND as Y, REDO_COMMAND as q } from "lexical";
|
|
2
|
-
import { p as k, D as I, f as E, aF as Z, a6 as Q, U as H, u as v, Q as A, C as X, aj as tt, n as et } from "./layers.
|
|
3
|
-
import { s as st } from "./layers.
|
|
2
|
+
import { p as k, D as I, f as E, aF as Z, a6 as Q, U as H, u as v, Q as A, C as X, aj as tt, n as et } from "./layers.Dq3o7sh3.js";
|
|
3
|
+
import { s as st } from "./layers.Duy8YzsH.js";
|
|
4
4
|
import { $getNearestNodeOfType as nt } from "@lexical/utils";
|
|
5
5
|
import { $isAtNodeEnd as D } from "@lexical/selection";
|
|
6
6
|
import "@lexical/code";
|
|
@@ -10,7 +10,7 @@ import "@lexical/mark";
|
|
|
10
10
|
import "@lexical/overflow";
|
|
11
11
|
import "@lexical/react/LexicalHorizontalRuleNode";
|
|
12
12
|
import "@lexical/rich-text";
|
|
13
|
-
import { G as F, H as ot, _ as lt, a0 as rt, a1 as it, a2 as at, a3 as K, a4 as ct, a5 as ft, a6 as ut, a7 as dt, a8 as gt, a9 as ht, aa as pt, ab as mt } from "./layers.
|
|
13
|
+
import { G as F, H as ot, _ as lt, a0 as rt, a1 as it, a2 as at, a3 as K, a4 as ct, a5 as ft, a6 as ut, a7 as dt, a8 as gt, a9 as ht, aa as pt, ab as mt } from "./layers.D6d62qQ_.js";
|
|
14
14
|
function Ct(t, e) {
|
|
15
15
|
if (e.add(t.getKey()), y(t))
|
|
16
16
|
for (const s of t.getChildren())
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const r=require("lexical"),g=require("./layers.CEMW9z_P.js"),x=require("./layers.hgliNTDV.js"),k=require("@lexical/utils"),O=require("@lexical/selection");require("@lexical/code");require("@lexical/hashtag");require("@lexical/link");require("@lexical/mark");require("@lexical/overflow");require("@lexical/react/LexicalHorizontalRuleNode");require("@lexical/rich-text");const f=require("./layers.C69TrYD7.js");function T(e,t){if(t.add(e.getKey()),r.$isElementNode(e))for(const n of e.getChildren())T(n,t)}function I(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation()}const R=r.createCommand(),F=r.createCommand(),K=r.createCommand(),B=r.createCommand(),U=r.createCommand(),q=r.createCommand(),z=r.createCommand(),W=r.createCommand(),G=(()=>{var t;const e=(t=window.navigator)==null?void 0:t.userAgentData;return e!==void 0?e.mobile:window.innerWidth<=800&&window.innerHeight<=600})(),V=e=>typeof e=="string"&&e.includes("%")?parseFloat(e):e;function H(e,t){if(!t||!(t instanceof HTMLElement)){console.error("Invalid DOM element provided.");return}e?t.classList.add("disable-scroll"):t.classList.remove("disable-scroll")}function m(e){const t=r.$getSelection();if(r.$isRangeSelection(t)){const o=t.anchor.getNode();if(o!==null){const s=o.getParent();return e?s:o}}return null}function Y(e){e.update(()=>{const t=r.$getSelection();if(r.$isRangeSelection(t)){const n=t.getNodes();let o=null,s=null;if(n.forEach((l,c)=>{c===0&&(o=l.getParent()),c===n.length-1&&(s=l.getParent())}),o&&s){const l=r.$getSelection();r.$isRangeSelection(l)&&(o.isAttached()&&s.isAttached()?g.$isExtendedTextNode(o)&&g.$isExtendedTextNode(s)?l.setTextNodeRange(o,0,s,s.getTextContentSize()):(l.anchor.set(o.getKey(),0,"element"),l.focus.set(s.getKey(),s.getChildrenSize(),"element")):console.error("Error: One of the nodes is not attached."))}}})}const $=(e,t)=>{e.update(()=>{if(typeof t=="string"){const n=r.$getNodeByKey(t);n&&n.remove();return}t&&t.remove()})};function J(e,t){t.update(()=>{let n=r.$createRangeSelection();e.getParent()&&(n.anchor.set(e.getKey(),0,"element"),n.focus.set(e.getKey(),0,"element"),r.$setSelection(n))})}function j(){const e=r.$getSelection();if(r.$isRangeSelection(e)){const t=e.anchor,n=e.focus,o=n.getNode(),s=g.$isExtendedCodeNode(o)?o.__size:o.getTextContentSize(),l=t.offset===0,c=n.offset===s;if(l&&c)return!0}return!1}function Z(e,t){const n=r.$copyNode(e),o=[[e,n]];let s;for(;(s=o.length)>0;)for(let l=0;l<s;l++){const c=o.shift();if(c!==void 0){const[a,i]=c;if(r.$isElementNode(a)&&r.$isElementNode(i)){const d=a.getChildren();for(const u of d){if(t&&u.is(t))continue;const h=r.$copyNode(u);g.$isExtendedTextNode(u)&&g.$isExtendedTextNode(h)&&(h.setFormat(u.__format),h.setStyle(u.__style)),i.append(h),o.push([u,h])}}}}return n}function v(e,t,n=3){if(!e)return null;let o=e,s=0;for(;o&&s<n;){if(t(o))return o;if(o.__type==="root")break;o=o.getParent(),s++}return null}function E(e,t,n){var s;const o=n||{root:!0};if(e){let l=e.getParent();if(o[l==null?void 0:l.__type]){const c=t.getElementByKey(e.__key),a=v(l,g.$isCalloutNode);if(a&&(a.getFirstChild()===e.getTopLevelElement()||a.getFirstChild()===((s=e.getTopLevelElement())==null?void 0:s.getParent()))){const d=a.getParent(),u=d?t.getElementByKey(d.__key):null;if(u)return{htmlElement:u,lexicalNode:r.$getNearestNodeFromDOMNode(u)}}return{htmlElement:c,lexicalNode:e}}return E(l,t,o)}return{htmlElement:null,lexicalNode:null}}function Q(e,t,n,o){var s;if(e)if((e==null?void 0:e.__type)==="root"||(e==null?void 0:e.__type)==="layout-item"||(e==null?void 0:e.__type)==="callout-wrapper"||(e==null?void 0:e.__type)==="collapsible-content"){const l=(o==null?void 0:o.clientY)||0,{left:c}=((s=t.getElementByKey(e.__key))==null?void 0:s.getBoundingClientRect())||{left:0},{paddingLeft:a}=window.getComputedStyle(o==null?void 0:o.target),i=document.elementFromPoint(c+parseFloat(a)+10,l),d=r.$getNearestNodeFromDOMNode(i||document.body);return d?E(d,t,n):{htmlElement:null,lexicalNode:null}}else return E(e,t,n);return{htmlElement:null,lexicalNode:null}}const X=e=>{e.update(()=>{r.$getSelection()!==null&&r.$setSelection(null)})},ee=()=>{const e=r.$getRoot(),t=e==null?void 0:e.getFirstChild();return e.getChildren().length>1?!1:t&&r.$isElementNode(t)&&t.isEmpty()&&!g.$isExtendedCodeNode(t)},te=e=>{e.update(()=>{const t=r.$getRoot(),n=r.$createParagraphNode(),o=r.$getSelection();r.$isRangeSelection(o)&&(o.format=0,o.setStyle("")),t.append(n).selectEnd()})},ne=(e,t,n)=>{const o=e.target;if(o&&(o instanceof HTMLElement||o instanceof SVGElement)){let s=null;const l=o.closest(t);for(const a of n)if(s=o.closest(a),s)break;return{lexicalDOMNode:l,isOutside:!(l||s)}}else return{lexicalDOMNode:null,isOutside:!0}};async function*L(e){let t=!1;for(;!t;){const n=await e.read(),{value:o}=n;o!==void 0&&(yield o),t=n.done}}async function oe(e){const t=[];for await(const o of L(e))for(let s=0;s<o.length;s+=32768)t.push(String.fromCharCode(...o.subarray(s,s+32768)));return t.join("")}async function se(e){const t=new CompressionStream("gzip"),n=t.writable.getWriter(),[,o]=await Promise.all([n.write(new TextEncoder().encode(JSON.stringify(e))).then(()=>n.close()),oe(t.readable.getReader())]);return`#doc=${btoa(o).replace(/\//g,"_").replace(/\+/g,"-").replace(/=+$/,"")}`}async function le(e){const t=/^#doc=(.*)$/.exec(e);if(!t)return null;const n=new DecompressionStream("gzip"),o=n.writable.getWriter(),s=atob(t[1].replace(/_/g,"/").replace(/-/g,"+")),l=new Uint8Array(s.length);for(let i=0;i<s.length;i++)l[i]=s.charCodeAt(i);const c=o.write(l).then(()=>o.close()),a=[];for await(const i of L(n.readable.pipeThrough(new TextDecoderStream).getReader()))a.push(i);return await c,JSON.parse(a.join(""))}const P=()=>!!document.querySelector(".selected-all-document"),re=(e,t,n)=>{var s,l,c,a,i;const o=r.$getSelection();if(r.$isRangeSelection(o)&&o.isCollapsed()){const d=o.anchor.getNode(),u=d.getKey(),h=d.getParent()===n,C=n instanceof r.ElementNode&&(n.__type==="layout-item"?(l=(s=n.getLastChild())==null?void 0:s.getPreviousSibling())==null?void 0:l.getKey():(c=n.getLastChild())==null?void 0:c.getKey())===u,b=n instanceof r.ElementNode&&((a=n.getFirstChild())==null?void 0:a.getKey())===u;if(n&&d instanceof r.ParagraphNode&&!d.getTextContent()&&h&&!((i=d.getPreviousSibling())!=null&&i.getTextContent())&&C&&!b){const D=e.registerCommand(r.INSERT_PARAGRAPH_COMMAND,()=>(D(),!0),r.COMMAND_PRIORITY_NORMAL);return e.update(()=>{var _;if(n){let p=n.getChildren();const w=n.getLastChild();g.$isLayoutDividerNode(w)&&(p=p.slice(0,-1)),p.length===2?p.slice(-1).forEach(y=>y.remove()):p.slice(-2).forEach(y=>y.remove())}const S=t==null?void 0:t.getNextSibling();if(r.$isParagraphNode(S)&&S.getTextContent()==="")(_=t==null?void 0:t.getNextSibling())==null||_.selectEnd();else{const p=t==null?void 0:t.insertAfter(r.$createParagraphNode());p==null||p.selectStart()}}),!0}}return!1},ie=(e,t,n)=>{var l,c,a;const o=(n==null?void 0:n.getChildren())||[];if((o==null?void 0:o.length)===2){for(const i of o)i.__key!==(t==null?void 0:t.__key)&&(n==null||n.insertBefore(i),(l=i.getFirstChild())==null||l.selectEnd());n.remove()}else for(const i of o)if(i.__key===(t==null?void 0:t.__key)){x.setTemplateColumnsAfterDelete(e,i),$(e,i);const d=i.getPreviousSibling()??i.getNextSibling();(a=(c=d==null?void 0:d.getFirstChild)==null?void 0:c.call(d))==null||a.selectEnd()}const s=e.registerCommand(r.DELETE_CHARACTER_COMMAND,()=>(s(),!0),r.COMMAND_PRIORITY_NORMAL);return!0},ce=(e,t,n)=>{if(!e)return null;let o=null;return n.read(()=>{const s=r.$getNearestNodeFromDOMNode(e);o=s&&k.$getNearestNodeOfType(s,t)}),o};function ae(e){return e instanceof HTMLElement}function N(e){let t=0;e instanceof WheelEvent?t=e.deltaY:e instanceof TouchEvent&&(t=1);let n=e.target;for(;n&&n!==document.body&&n!==document.documentElement;){if(n.scrollHeight>n.clientHeight&&(t<0&&n.scrollTop>0||t>0&&n.scrollTop+n.clientHeight<n.scrollHeight))return;n=n.parentElement}e.preventDefault()}function A(){document.addEventListener("wheel",N,{passive:!1}),document.addEventListener("touchmove",N,{passive:!1})}function M(){document.removeEventListener("wheel",N),document.removeEventListener("touchmove",N)}function de(e){const t=e.anchor,n=e.focus,o=e.anchor.getNode(),s=e.focus.getNode();return o===s?o:e.isBackward()?O.$isAtNodeEnd(n)?o:s:O.$isAtNodeEnd(t)?o:s}const ue=new Set(["http:","https:","mailto:","sms:","tel:"]);function fe(e){try{const t=new URL(e);if(!ue.has(t.protocol))return"about:blank"}catch{return e}return e}function ge(e,t){const n=e.getRangeAt(0);let o;if(e.anchorNode===t){let s=t;for(;s.firstElementChild!=null;)s=s.firstElementChild;o=s.getBoundingClientRect()}else o=n.getBoundingClientRect();return o}const he=()=>{var n;const e=(n=window.getSelection())==null?void 0:n.toString().trim();return e==null?void 0:e.replace(/\s+/g,"")},pe=10,me=5;function Ce(e,t,n,o=!1,s=pe,l=me){const c=n.parentElement,a=document.querySelector(".ai-editor-menu");if(e===null||!c||a){t.style.opacity="0",t.style.transform="translate(-10000px, -10000px)",M();return}const i=t.getBoundingClientRect(),d=c.getBoundingClientRect();let u=e.top-i.height-s;u<0&&(u=10);let h=e.left-l;if(u<d.top&&(u+=i.height+e.height+s*2),h+i.width>d.right&&(h=d.right-i.width-l),e.bottom-e.height>d.bottom){t.style.transform="translate(-1000px, -1000px)";return}if(e.bottom+e.height<d.top){t.style.transform="translate(-1000px, -1000px)";return}let C=u;i.top>=d.bottom&&(C=d.bottom),t.style.transform=`translate(${h}px, ${C}px)`,t.style.opacity="1",A()}const Ee=e=>{const t=r.$getSelection(),n=m(),o=n==null?void 0:n.getParent(),s=o==null?void 0:o.getParent();if(n){if(P())return r.$getRoot().clear(),t.insertParagraph(),!0;if(s instanceof f.CollapsibleContentNode||s instanceof f.CollapsibleTitleNode)return f.handleDeleteCollapsibleCharacter();if(o instanceof g.ExtendCodeNode)return f.handleDeleteCodeCharacter()}return!1},Ne=(e,t)=>{var n,o,s,l,c,a;if(e.dataTransfer){const i=Object.values(e.dataTransfer.files);if(i&&i.length)return e.preventDefault(),e.target instanceof HTMLElement&&((n=t.current)!=null&&n.insertImages)&&((o=r.$getNearestNodeFromDOMNode(e.target))==null||o.selectEnd(),i[0].type.includes("video")&&((s=t.current)!=null&&s.insertVideos)?t.current.insertVideos(i):i[0].type.includes("image")&&((l=t.current)!=null&&l.insertImages)?t.current.insertImages(i):i[0].type.includes("audio")&&((c=t.current)!=null&&c.insertMusics)?t.current.insertMusics(i):(a=t.current)!=null&&a.insertFiles&&(t==null||t.current.insertFiles(i))),!0}return!1},ye=()=>{const e=m(),t=e==null?void 0:e.getParent();return e&&f.$isCollapsibleContentNode(t)?f.$onEscapeDownRightCollapsible():!1},Se=()=>{const e=m(),t=e==null?void 0:e.getParent();return e&&f.$isCollapsibleTitleNode(t)?f.$onEscapeUpLeftCollapsible():!1},_e=e=>{const t=r.$getSelection();if(!r.$isRangeSelection(t)||!t.isCollapsed())return!1;const n=t.anchor.getNode();if(n.getPreviousSibling()===null&&t.anchor.offset===0){const o=n.getParent();if(o){const s=r.$createParagraphNode();return s.append(...o.getChildren()),o.replace(s),e.preventDefault(),!0}}return!1};function Oe(e){if(!e)return null;const n=new DOMParser().parseFromString(e,"text/html").body,o=Array.from(n.children);if(o.length!==1)return null;const s=o[0];return s.tagName!=="IMG"||n.textContent&&n.textContent.trim().length>0?null:s.getAttribute("src")||""||null}const Te=(e,t,n)=>{var l,c;const o=m(),s=o==null?void 0:o.getParent();if(o){if(f.$isCollapsibleTitleNode(s))return f.deleteCollapsibleContainer(e);if(g.$isCalloutNode(s))(c=(l=n.current)==null?void 0:l.onDeleteCallout)==null||c.call(l,t);else{if(g.$isLayoutItemNode(s))return f.deleteLayoutItem(e);if(g.$isListItemNode(s))return _e(t)}}return!1},$e=(e,t)=>{const n=t.ctrlKey||t.metaKey,o=t.shiftKey,s=t.code==="KeyZ";return n&&o&&s?(t.preventDefault(),e.dispatchCommand(r.REDO_COMMAND,void 0),!0):!1},Le=(e,t,n,o,s)=>{var a,i;if(s)return o.preventDefault(),o.key==="Enter"&&o.shiftKey&&t.insertParagraph(),!0;const l=m(),c=l==null?void 0:l.getParent();if(l){if(c instanceof g.LayoutItemNode)return f.handleExitLayout(e);if(c instanceof f.CollapsibleContentNode)return f.handleExitCollapsible(e);if(c instanceof g.CalloutNode)return f.handleExitCallout(e);if(c instanceof g.TableCellNode)return f.handleExitTable(e);if(c instanceof g.ListNode||g.LayoutItemNode)return f.handleEnterCheckList()}return(i=(a=n.current)==null?void 0:a.decoratorEnterAction)==null||i.call(a),!1};function Pe(e,t){var n,o,s,l,c,a,i,d;if("dataTransfer"in e&&((o=(n=e.dataTransfer)==null?void 0:n.files)!=null&&o.length)){const u=Array.from(e.dataTransfer.files),h=u[0];return h.type.includes("video")&&((s=t.current)!=null&&s.insertVideos)?t.current.insertVideos(u):h.type.includes("image")&&((l=t.current)!=null&&l.insertImages)?t.current.insertImages(u):h.type.includes("audio")&&((c=t.current)!=null&&c.insertMusics)?t.current.insertMusics(u):(a=t.current)!=null&&a.insertFiles&&t.current.insertFiles(u),!0}if("clipboardData"in e){const u=(d=(i=e.clipboardData)==null?void 0:i.getData("text/html"))==null?void 0:d.trim();if(Oe(u))return!0}return!1}function Ae(e){if(!e||e.classList.contains("video-container")||e.classList.contains("resizable-container")||e.classList.contains("editor-image"))return null;if(e.closest("ol, ul"))return e;let t=e;for(;t&&!t.classList.contains("ContentEditable__root");)t=t.parentElement;if(t!=null&&t.classList.contains("ContentEditable__root")){let n=e;for(;n&&n.parentElement!==t;)n=n.parentElement;return n}return null}function Me(e,t=!1){e.focus(),e.update(()=>{var o,s;const n=r.$getRoot();t?(n.selectStart(),(o=n.getFirstChild())==null||o.selectEnd()):(n.selectEnd(),(s=n.getLastChild())==null||s.selectEnd())})}exports.$copyNodeDeep=Z;exports.$createNewParagraph=te;exports.$getBlockNode=Q;exports.$getClosestParentNode=E;exports.CREATE_TEMPLATE=q;exports.INSERT_CALLOUT_COMMAND=K;exports.KeyBackSpace=Te;exports.ON_CHANGE_COMMAND=R;exports.ON_OPEN_KEBAB_MENU=F;exports.ON_SCROLL_EDITOR=B;exports.ON_SHOW_LINK_POPUP=U;exports.OPEN_EMOJI_PICKER_COMMAND=W;exports.RIGHT_CLICK_COMMAND=z;exports.addNodeAndChildrenToSelection=T;exports.allEditorSelected=P;exports.blockScroll=A;exports.checkIsEmpty=ee;exports.deleteCharacterCommand=Ee;exports.deleteNode=$;exports.docFromHash=le;exports.docToHash=se;exports.dropCommand=Ne;exports.findTopParentElement=Ae;exports.focusEditor=Me;exports.focusOnNode=J;exports.getCurrentElement=m;exports.getDOMRangeRect=ge;exports.getMouseInfo=ne;exports.getNativeSelectedText=he;exports.getNearestBlockNodeOfType=ce;exports.getSelectedNode=de;exports.handleEnterExitContainer=re;exports.isHTMLElement=ae;exports.isMobile=G;exports.isWholeNodeSelected=j;exports.keyArrowRightDown=ye;exports.keyArrowUpLeft=Se;exports.keyDownCommand=$e;exports.keyEnterListener=Le;exports.parseContainerSize=V;exports.pasteCommand=Pe;exports.removeNodeKeepContent=ie;exports.resetSelection=X;exports.sanitizeUrl=fe;exports.selectCurrentNode=Y;exports.setFloatingElemPosition=Ce;exports.stopEvent=I;exports.toggleLockScroll=H;exports.unblockScroll=M;
|
|
1
|
+
"use strict";const r=require("lexical"),g=require("./layers.B90YwJga.js"),x=require("./layers.Cnm-pECN.js"),k=require("@lexical/utils"),O=require("@lexical/selection");require("@lexical/code");require("@lexical/hashtag");require("@lexical/link");require("@lexical/mark");require("@lexical/overflow");require("@lexical/react/LexicalHorizontalRuleNode");require("@lexical/rich-text");const f=require("./layers.CZ_Lt7IL.js");function T(e,t){if(t.add(e.getKey()),r.$isElementNode(e))for(const n of e.getChildren())T(n,t)}function I(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation()}const R=r.createCommand(),F=r.createCommand(),K=r.createCommand(),B=r.createCommand(),U=r.createCommand(),q=r.createCommand(),z=r.createCommand(),W=r.createCommand(),G=(()=>{var t;const e=(t=window.navigator)==null?void 0:t.userAgentData;return e!==void 0?e.mobile:window.innerWidth<=800&&window.innerHeight<=600})(),V=e=>typeof e=="string"&&e.includes("%")?parseFloat(e):e;function H(e,t){if(!t||!(t instanceof HTMLElement)){console.error("Invalid DOM element provided.");return}e?t.classList.add("disable-scroll"):t.classList.remove("disable-scroll")}function m(e){const t=r.$getSelection();if(r.$isRangeSelection(t)){const o=t.anchor.getNode();if(o!==null){const s=o.getParent();return e?s:o}}return null}function Y(e){e.update(()=>{const t=r.$getSelection();if(r.$isRangeSelection(t)){const n=t.getNodes();let o=null,s=null;if(n.forEach((l,c)=>{c===0&&(o=l.getParent()),c===n.length-1&&(s=l.getParent())}),o&&s){const l=r.$getSelection();r.$isRangeSelection(l)&&(o.isAttached()&&s.isAttached()?g.$isExtendedTextNode(o)&&g.$isExtendedTextNode(s)?l.setTextNodeRange(o,0,s,s.getTextContentSize()):(l.anchor.set(o.getKey(),0,"element"),l.focus.set(s.getKey(),s.getChildrenSize(),"element")):console.error("Error: One of the nodes is not attached."))}}})}const $=(e,t)=>{e.update(()=>{if(typeof t=="string"){const n=r.$getNodeByKey(t);n&&n.remove();return}t&&t.remove()})};function J(e,t){t.update(()=>{let n=r.$createRangeSelection();e.getParent()&&(n.anchor.set(e.getKey(),0,"element"),n.focus.set(e.getKey(),0,"element"),r.$setSelection(n))})}function j(){const e=r.$getSelection();if(r.$isRangeSelection(e)){const t=e.anchor,n=e.focus,o=n.getNode(),s=g.$isExtendedCodeNode(o)?o.__size:o.getTextContentSize(),l=t.offset===0,c=n.offset===s;if(l&&c)return!0}return!1}function Z(e,t){const n=r.$copyNode(e),o=[[e,n]];let s;for(;(s=o.length)>0;)for(let l=0;l<s;l++){const c=o.shift();if(c!==void 0){const[a,i]=c;if(r.$isElementNode(a)&&r.$isElementNode(i)){const d=a.getChildren();for(const u of d){if(t&&u.is(t))continue;const h=r.$copyNode(u);g.$isExtendedTextNode(u)&&g.$isExtendedTextNode(h)&&(h.setFormat(u.__format),h.setStyle(u.__style)),i.append(h),o.push([u,h])}}}}return n}function v(e,t,n=3){if(!e)return null;let o=e,s=0;for(;o&&s<n;){if(t(o))return o;if(o.__type==="root")break;o=o.getParent(),s++}return null}function E(e,t,n){var s;const o=n||{root:!0};if(e){let l=e.getParent();if(o[l==null?void 0:l.__type]){const c=t.getElementByKey(e.__key),a=v(l,g.$isCalloutNode);if(a&&(a.getFirstChild()===e.getTopLevelElement()||a.getFirstChild()===((s=e.getTopLevelElement())==null?void 0:s.getParent()))){const d=a.getParent(),u=d?t.getElementByKey(d.__key):null;if(u)return{htmlElement:u,lexicalNode:r.$getNearestNodeFromDOMNode(u)}}return{htmlElement:c,lexicalNode:e}}return E(l,t,o)}return{htmlElement:null,lexicalNode:null}}function Q(e,t,n,o){var s;if(e)if((e==null?void 0:e.__type)==="root"||(e==null?void 0:e.__type)==="layout-item"||(e==null?void 0:e.__type)==="callout-wrapper"||(e==null?void 0:e.__type)==="collapsible-content"){const l=(o==null?void 0:o.clientY)||0,{left:c}=((s=t.getElementByKey(e.__key))==null?void 0:s.getBoundingClientRect())||{left:0},{paddingLeft:a}=window.getComputedStyle(o==null?void 0:o.target),i=document.elementFromPoint(c+parseFloat(a)+10,l),d=r.$getNearestNodeFromDOMNode(i||document.body);return d?E(d,t,n):{htmlElement:null,lexicalNode:null}}else return E(e,t,n);return{htmlElement:null,lexicalNode:null}}const X=e=>{e.update(()=>{r.$getSelection()!==null&&r.$setSelection(null)})},ee=()=>{const e=r.$getRoot(),t=e==null?void 0:e.getFirstChild();return e.getChildren().length>1?!1:t&&r.$isElementNode(t)&&t.isEmpty()&&!g.$isExtendedCodeNode(t)},te=e=>{e.update(()=>{const t=r.$getRoot(),n=r.$createParagraphNode(),o=r.$getSelection();r.$isRangeSelection(o)&&(o.format=0,o.setStyle("")),t.append(n).selectEnd()})},ne=(e,t,n)=>{const o=e.target;if(o&&(o instanceof HTMLElement||o instanceof SVGElement)){let s=null;const l=o.closest(t);for(const a of n)if(s=o.closest(a),s)break;return{lexicalDOMNode:l,isOutside:!(l||s)}}else return{lexicalDOMNode:null,isOutside:!0}};async function*L(e){let t=!1;for(;!t;){const n=await e.read(),{value:o}=n;o!==void 0&&(yield o),t=n.done}}async function oe(e){const t=[];for await(const o of L(e))for(let s=0;s<o.length;s+=32768)t.push(String.fromCharCode(...o.subarray(s,s+32768)));return t.join("")}async function se(e){const t=new CompressionStream("gzip"),n=t.writable.getWriter(),[,o]=await Promise.all([n.write(new TextEncoder().encode(JSON.stringify(e))).then(()=>n.close()),oe(t.readable.getReader())]);return`#doc=${btoa(o).replace(/\//g,"_").replace(/\+/g,"-").replace(/=+$/,"")}`}async function le(e){const t=/^#doc=(.*)$/.exec(e);if(!t)return null;const n=new DecompressionStream("gzip"),o=n.writable.getWriter(),s=atob(t[1].replace(/_/g,"/").replace(/-/g,"+")),l=new Uint8Array(s.length);for(let i=0;i<s.length;i++)l[i]=s.charCodeAt(i);const c=o.write(l).then(()=>o.close()),a=[];for await(const i of L(n.readable.pipeThrough(new TextDecoderStream).getReader()))a.push(i);return await c,JSON.parse(a.join(""))}const P=()=>!!document.querySelector(".selected-all-document"),re=(e,t,n)=>{var s,l,c,a,i;const o=r.$getSelection();if(r.$isRangeSelection(o)&&o.isCollapsed()){const d=o.anchor.getNode(),u=d.getKey(),h=d.getParent()===n,C=n instanceof r.ElementNode&&(n.__type==="layout-item"?(l=(s=n.getLastChild())==null?void 0:s.getPreviousSibling())==null?void 0:l.getKey():(c=n.getLastChild())==null?void 0:c.getKey())===u,b=n instanceof r.ElementNode&&((a=n.getFirstChild())==null?void 0:a.getKey())===u;if(n&&d instanceof r.ParagraphNode&&!d.getTextContent()&&h&&!((i=d.getPreviousSibling())!=null&&i.getTextContent())&&C&&!b){const D=e.registerCommand(r.INSERT_PARAGRAPH_COMMAND,()=>(D(),!0),r.COMMAND_PRIORITY_NORMAL);return e.update(()=>{var _;if(n){let p=n.getChildren();const w=n.getLastChild();g.$isLayoutDividerNode(w)&&(p=p.slice(0,-1)),p.length===2?p.slice(-1).forEach(y=>y.remove()):p.slice(-2).forEach(y=>y.remove())}const S=t==null?void 0:t.getNextSibling();if(r.$isParagraphNode(S)&&S.getTextContent()==="")(_=t==null?void 0:t.getNextSibling())==null||_.selectEnd();else{const p=t==null?void 0:t.insertAfter(r.$createParagraphNode());p==null||p.selectStart()}}),!0}}return!1},ie=(e,t,n)=>{var l,c,a;const o=(n==null?void 0:n.getChildren())||[];if((o==null?void 0:o.length)===2){for(const i of o)i.__key!==(t==null?void 0:t.__key)&&(n==null||n.insertBefore(i),(l=i.getFirstChild())==null||l.selectEnd());n.remove()}else for(const i of o)if(i.__key===(t==null?void 0:t.__key)){x.setTemplateColumnsAfterDelete(e,i),$(e,i);const d=i.getPreviousSibling()??i.getNextSibling();(a=(c=d==null?void 0:d.getFirstChild)==null?void 0:c.call(d))==null||a.selectEnd()}const s=e.registerCommand(r.DELETE_CHARACTER_COMMAND,()=>(s(),!0),r.COMMAND_PRIORITY_NORMAL);return!0},ce=(e,t,n)=>{if(!e)return null;let o=null;return n.read(()=>{const s=r.$getNearestNodeFromDOMNode(e);o=s&&k.$getNearestNodeOfType(s,t)}),o};function ae(e){return e instanceof HTMLElement}function N(e){let t=0;e instanceof WheelEvent?t=e.deltaY:e instanceof TouchEvent&&(t=1);let n=e.target;for(;n&&n!==document.body&&n!==document.documentElement;){if(n.scrollHeight>n.clientHeight&&(t<0&&n.scrollTop>0||t>0&&n.scrollTop+n.clientHeight<n.scrollHeight))return;n=n.parentElement}e.preventDefault()}function A(){document.addEventListener("wheel",N,{passive:!1}),document.addEventListener("touchmove",N,{passive:!1})}function M(){document.removeEventListener("wheel",N),document.removeEventListener("touchmove",N)}function de(e){const t=e.anchor,n=e.focus,o=e.anchor.getNode(),s=e.focus.getNode();return o===s?o:e.isBackward()?O.$isAtNodeEnd(n)?o:s:O.$isAtNodeEnd(t)?o:s}const ue=new Set(["http:","https:","mailto:","sms:","tel:"]);function fe(e){try{const t=new URL(e);if(!ue.has(t.protocol))return"about:blank"}catch{return e}return e}function ge(e,t){const n=e.getRangeAt(0);let o;if(e.anchorNode===t){let s=t;for(;s.firstElementChild!=null;)s=s.firstElementChild;o=s.getBoundingClientRect()}else o=n.getBoundingClientRect();return o}const he=()=>{var n;const e=(n=window.getSelection())==null?void 0:n.toString().trim();return e==null?void 0:e.replace(/\s+/g,"")},pe=10,me=5;function Ce(e,t,n,o=!1,s=pe,l=me){const c=n.parentElement,a=document.querySelector(".ai-editor-menu");if(e===null||!c||a){t.style.opacity="0",t.style.transform="translate(-10000px, -10000px)",M();return}const i=t.getBoundingClientRect(),d=c.getBoundingClientRect();let u=e.top-i.height-s;u<0&&(u=10);let h=e.left-l;if(u<d.top&&(u+=i.height+e.height+s*2),h+i.width>d.right&&(h=d.right-i.width-l),e.bottom-e.height>d.bottom){t.style.transform="translate(-1000px, -1000px)";return}if(e.bottom+e.height<d.top){t.style.transform="translate(-1000px, -1000px)";return}let C=u;i.top>=d.bottom&&(C=d.bottom),t.style.transform=`translate(${h}px, ${C}px)`,t.style.opacity="1",A()}const Ee=e=>{const t=r.$getSelection(),n=m(),o=n==null?void 0:n.getParent(),s=o==null?void 0:o.getParent();if(n){if(P())return r.$getRoot().clear(),t.insertParagraph(),!0;if(s instanceof f.CollapsibleContentNode||s instanceof f.CollapsibleTitleNode)return f.handleDeleteCollapsibleCharacter();if(o instanceof g.ExtendCodeNode)return f.handleDeleteCodeCharacter()}return!1},Ne=(e,t)=>{var n,o,s,l,c,a;if(e.dataTransfer){const i=Object.values(e.dataTransfer.files);if(i&&i.length)return e.preventDefault(),e.target instanceof HTMLElement&&((n=t.current)!=null&&n.insertImages)&&((o=r.$getNearestNodeFromDOMNode(e.target))==null||o.selectEnd(),i[0].type.includes("video")&&((s=t.current)!=null&&s.insertVideos)?t.current.insertVideos(i):i[0].type.includes("image")&&((l=t.current)!=null&&l.insertImages)?t.current.insertImages(i):i[0].type.includes("audio")&&((c=t.current)!=null&&c.insertMusics)?t.current.insertMusics(i):(a=t.current)!=null&&a.insertFiles&&(t==null||t.current.insertFiles(i))),!0}return!1},ye=()=>{const e=m(),t=e==null?void 0:e.getParent();return e&&f.$isCollapsibleContentNode(t)?f.$onEscapeDownRightCollapsible():!1},Se=()=>{const e=m(),t=e==null?void 0:e.getParent();return e&&f.$isCollapsibleTitleNode(t)?f.$onEscapeUpLeftCollapsible():!1},_e=e=>{const t=r.$getSelection();if(!r.$isRangeSelection(t)||!t.isCollapsed())return!1;const n=t.anchor.getNode();if(n.getPreviousSibling()===null&&t.anchor.offset===0){const o=n.getParent();if(o){const s=r.$createParagraphNode();return s.append(...o.getChildren()),o.replace(s),e.preventDefault(),!0}}return!1};function Oe(e){if(!e)return null;const n=new DOMParser().parseFromString(e,"text/html").body,o=Array.from(n.children);if(o.length!==1)return null;const s=o[0];return s.tagName!=="IMG"||n.textContent&&n.textContent.trim().length>0?null:s.getAttribute("src")||""||null}const Te=(e,t,n)=>{var l,c;const o=m(),s=o==null?void 0:o.getParent();if(o){if(f.$isCollapsibleTitleNode(s))return f.deleteCollapsibleContainer(e);if(g.$isCalloutNode(s))(c=(l=n.current)==null?void 0:l.onDeleteCallout)==null||c.call(l,t);else{if(g.$isLayoutItemNode(s))return f.deleteLayoutItem(e);if(g.$isListItemNode(s))return _e(t)}}return!1},$e=(e,t)=>{const n=t.ctrlKey||t.metaKey,o=t.shiftKey,s=t.code==="KeyZ";return n&&o&&s?(t.preventDefault(),e.dispatchCommand(r.REDO_COMMAND,void 0),!0):!1},Le=(e,t,n,o,s)=>{var a,i;if(s)return o.preventDefault(),o.key==="Enter"&&o.shiftKey&&t.insertParagraph(),!0;const l=m(),c=l==null?void 0:l.getParent();if(l){if(c instanceof g.LayoutItemNode)return f.handleExitLayout(e);if(c instanceof f.CollapsibleContentNode)return f.handleExitCollapsible(e);if(c instanceof g.CalloutNode)return f.handleExitCallout(e);if(c instanceof g.TableCellNode)return f.handleExitTable(e);if(c instanceof g.ListNode||g.LayoutItemNode)return f.handleEnterCheckList()}return(i=(a=n.current)==null?void 0:a.decoratorEnterAction)==null||i.call(a),!1};function Pe(e,t){var n,o,s,l,c,a,i,d;if("dataTransfer"in e&&((o=(n=e.dataTransfer)==null?void 0:n.files)!=null&&o.length)){const u=Array.from(e.dataTransfer.files),h=u[0];return h.type.includes("video")&&((s=t.current)!=null&&s.insertVideos)?t.current.insertVideos(u):h.type.includes("image")&&((l=t.current)!=null&&l.insertImages)?t.current.insertImages(u):h.type.includes("audio")&&((c=t.current)!=null&&c.insertMusics)?t.current.insertMusics(u):(a=t.current)!=null&&a.insertFiles&&t.current.insertFiles(u),!0}if("clipboardData"in e){const u=(d=(i=e.clipboardData)==null?void 0:i.getData("text/html"))==null?void 0:d.trim();if(Oe(u))return!0}return!1}function Ae(e){if(!e||e.classList.contains("video-container")||e.classList.contains("resizable-container")||e.classList.contains("editor-image"))return null;if(e.closest("ol, ul"))return e;let t=e;for(;t&&!t.classList.contains("ContentEditable__root");)t=t.parentElement;if(t!=null&&t.classList.contains("ContentEditable__root")){let n=e;for(;n&&n.parentElement!==t;)n=n.parentElement;return n}return null}function Me(e,t=!1){e.focus(),e.update(()=>{var o,s;const n=r.$getRoot();t?(n.selectStart(),(o=n.getFirstChild())==null||o.selectEnd()):(n.selectEnd(),(s=n.getLastChild())==null||s.selectEnd())})}exports.$copyNodeDeep=Z;exports.$createNewParagraph=te;exports.$getBlockNode=Q;exports.$getClosestParentNode=E;exports.CREATE_TEMPLATE=q;exports.INSERT_CALLOUT_COMMAND=K;exports.KeyBackSpace=Te;exports.ON_CHANGE_COMMAND=R;exports.ON_OPEN_KEBAB_MENU=F;exports.ON_SCROLL_EDITOR=B;exports.ON_SHOW_LINK_POPUP=U;exports.OPEN_EMOJI_PICKER_COMMAND=W;exports.RIGHT_CLICK_COMMAND=z;exports.addNodeAndChildrenToSelection=T;exports.allEditorSelected=P;exports.blockScroll=A;exports.checkIsEmpty=ee;exports.deleteCharacterCommand=Ee;exports.deleteNode=$;exports.docFromHash=le;exports.docToHash=se;exports.dropCommand=Ne;exports.findTopParentElement=Ae;exports.focusEditor=Me;exports.focusOnNode=J;exports.getCurrentElement=m;exports.getDOMRangeRect=ge;exports.getMouseInfo=ne;exports.getNativeSelectedText=he;exports.getNearestBlockNodeOfType=ce;exports.getSelectedNode=de;exports.handleEnterExitContainer=re;exports.isHTMLElement=ae;exports.isMobile=G;exports.isWholeNodeSelected=j;exports.keyArrowRightDown=ye;exports.keyArrowUpLeft=Se;exports.keyDownCommand=$e;exports.keyEnterListener=Le;exports.parseContainerSize=V;exports.pasteCommand=Pe;exports.removeNodeKeepContent=ie;exports.resetSelection=X;exports.sanitizeUrl=fe;exports.selectCurrentNode=Y;exports.setFloatingElemPosition=Ce;exports.stopEvent=I;exports.toggleLockScroll=H;exports.unblockScroll=M;
|
|
@@ -5,9 +5,9 @@ import { $getSelection as G, $isRangeSelection as z, $isRootOrShadowRoot as Dt,
|
|
|
5
5
|
import { copyToClipboard as po, $getClipboardDataFromSelection as wo } from "@lexical/clipboard";
|
|
6
6
|
import { $getNearestNodeOfType as Co, removeClassNamesFromElement as Ft, addClassNamesToElement as te, isHTMLElement as on, mergeRegister as sn, $findMatchingParent as Y, objectKlassEquals as bo } from "@lexical/utils";
|
|
7
7
|
import { debounce as yo } from "lodash-es";
|
|
8
|
-
import { w as So, x as vo, y as No, z as Do, D as To, G as xo, H as Bo } from "./layers.
|
|
9
|
-
import { t as Ge, a as Eo, u as Mo, C as ct, m as Zt, b as Lo, c as Oo } from "./layers.
|
|
10
|
-
import { s as Te, t as ut, j as Oe, l as ko, m as Ro, O as Fo, n as Io } from "./layers.
|
|
8
|
+
import { w as So, x as vo, y as No, z as Do, D as To, G as xo, H as Bo } from "./layers.D6d62qQ_.js";
|
|
9
|
+
import { t as Ge, a as Eo, u as Mo, C as ct, m as Zt, b as Lo, c as Oo } from "./layers.7jmq6tBR.js";
|
|
10
|
+
import { s as Te, t as ut, j as Oe, l as ko, m as Ro, O as Fo, n as Io } from "./layers.Dev6Yrwi.js";
|
|
11
11
|
import { jsx as h, jsxs as X, Fragment as It } from "react/jsx-runtime";
|
|
12
12
|
import Ho, { useRef as ve, useCallback as pe, useState as R, useEffect as K, useContext as dt, forwardRef as Wo, useMemo as be, Suspense as Po, lazy as $n } from "react";
|
|
13
13
|
import { CodeNode as er, $isCodeHighlightNode as tr, CodeHighlightNode as an } from "@lexical/code";
|
|
@@ -21,14 +21,14 @@ import { createPortal as zo } from "react-dom";
|
|
|
21
21
|
import { useTranslation as se } from "react-i18next";
|
|
22
22
|
import { useLexicalComposerContext as Ht } from "@lexical/react/LexicalComposerContext";
|
|
23
23
|
import { ActionIcon as xe, Box as Tt, Text as xt, Anchor as sr, Flex as Je, Image as ir, Popover as Jt, Stack as Go, TextInput as Xo, Center as Zo, Button as Bt, Tooltip as ke, Menu as Ye, LoadingOverlay as ar, Modal as Jo, useMantineTheme as Vo, useMantineColorScheme as Qo } from "@mantine/core";
|
|
24
|
-
import { a as Ve, P as _o, R as Wt, I as Se, M as qo } from "./layers.
|
|
24
|
+
import { a as Ve, P as _o, R as Wt, I as Se, M as qo } from "./layers.CXffIp2y.js";
|
|
25
25
|
import { useDisclosure as $o } from "@mantine/hooks";
|
|
26
26
|
import { EmojiPicker as es, ProjectIcon as ts, FilePicker as cn, ShakaVideoPlayer as ns, showErrorNotification as lr, AttachmentsGalleryModal as rs, BottomDrawerWithoutHeader as os } from "@layers-app/shared";
|
|
27
27
|
import { DecoratorBlockNode as Me } from "@lexical/react/LexicalDecoratorBlockNode";
|
|
28
28
|
import { IconFile as cr, IconExternalLink as ss, IconX as is, IconEdit as as } from "@tabler/icons-react";
|
|
29
29
|
import { renderToString as ls } from "react-dom/server";
|
|
30
30
|
import { BlockWithAlignableContents as Re } from "@lexical/react/LexicalBlockWithAlignableContents";
|
|
31
|
-
import { U as cs, b as us, i as ds, g as hs, c as Et, p as ur, d as As, e as gs, I as fs } from "./layers.
|
|
31
|
+
import { U as cs, b as us, i as ds, g as hs, c as Et, p as ur, d as As, e as gs, I as fs } from "./layers.Ci1-qkbn.js";
|
|
32
32
|
import { useLexicalNodeSelection as dr } from "@lexical/react/useLexicalNodeSelection";
|
|
33
33
|
import { useLexicalEditable as ms } from "@lexical/react/useLexicalEditable";
|
|
34
34
|
import { exportToSvg as ps, Excalidraw as ws } from "@excalidraw/excalidraw";
|
|
@@ -8,23 +8,23 @@ import { mergeRegister as Fe, $findMatchingParent as it, $getNearestNodeOfType a
|
|
|
8
8
|
import { Tooltip as ie, ActionIcon as ze, Menu as $, rem as V, alpha as mn, Transition as gn, Box as We, Paper as hn, Group as bn, CopyButton as yn, Divider as Cn, Input as _n, Loader as Tn } from "@mantine/core";
|
|
9
9
|
import { IconPlus as Vt, IconMinus as Et, IconClipboard as xn, IconCut as kn, IconTrash as ft, IconCopy as Qt, IconArrowsRightLeft as vn, IconPaint as St, IconColumnInsertLeft as In, IconColumnInsertRight as lt, IconGripVertical as wn, IconArrowNarrowLeft as Tt, IconReplace as Sn, IconTextPlus as Mn, IconIndentIncrease as An, IconPlayerPlay as Pn, IconReload as Dn, IconWand as Ln, IconTextSpellcheck as Nn, IconSortAscending as On, IconSortDescending as $n, IconNotes as Rn, IconLanguage as Bn, IconScript as Fn, IconHelpOctagon as zn, IconCheck as Hn, IconSparkles as Mt, IconAi as Kn } from "@tabler/icons-react";
|
|
10
10
|
import { $getNearestNodeFromDOMNode as oe, $createParagraphNode as Pe, $isElementNode as Me, ElementNode as Un, $getSelection as ue, $isRangeSelection as de, COMMAND_PRIORITY_LOW as be, DRAGOVER_COMMAND as Gn, KEY_ARROW_DOWN_COMMAND as Wn, KEY_ARROW_UP_COMMAND as jn, $isTextNode as pt, $getRoot as At, $getNodeByKey as qn, $isParagraphNode as Yn, KEY_DOWN_COMMAND as Vn, $selectAll as En, SELECTION_CHANGE_COMMAND as Xt, FORMAT_TEXT_COMMAND as le, $createTextNode as xt, $isRootNode as Pt, $isRootOrShadowRoot as Qn, COMMAND_PRIORITY_CRITICAL as rt, CAN_UNDO_COMMAND as Xn, CAN_REDO_COMMAND as Jn, KEY_MODIFIER_COMMAND as Zn, COMMAND_PRIORITY_NORMAL as Dt, CLICK_COMMAND as eo } from "lexical";
|
|
11
|
-
import { C as De, g as to } from "./layers.
|
|
11
|
+
import { C as De, g as to } from "./layers.7jmq6tBR.js";
|
|
12
12
|
import { $isCodeHighlightNode as no } from "@lexical/code";
|
|
13
13
|
import "@lexical/hashtag";
|
|
14
14
|
import { $isLinkNode as Re, TOGGLE_LINK_COMMAND as oo } from "@lexical/link";
|
|
15
15
|
import "@lexical/mark";
|
|
16
16
|
import "@lexical/overflow";
|
|
17
17
|
import "@lexical/react/LexicalHorizontalRuleNode";
|
|
18
|
-
import { L as Xe, P as Ee, S as ke, T as ve, U as je, W as Lt, R as so, q as Je, Q as Ze, n as Jt, l as Nt, w as Ot, r as Zt, a3 as Qe, a4 as io, f as mt, u as lo, v as ro } from "./layers.
|
|
19
|
-
import { I as ao, $ as kt, J as co, K as en, O as uo, P as fo, z as po, Q as at, R as tn, U as mo } from "./layers.
|
|
20
|
-
import { w as et, F as Be, n as go, D as $e, O as ct, R as ho, G as bo, H as gt, J as qe, L as $t, M as yo, i as nn, u as Co, A as vt, B as on, N as Rt, P as Oe, Q as _o, S as To, T as xo, z as ko } from "./layers.
|
|
18
|
+
import { L as Xe, P as Ee, S as ke, T as ve, U as je, W as Lt, R as so, q as Je, Q as Ze, n as Jt, l as Nt, w as Ot, r as Zt, a3 as Qe, a4 as io, f as mt, u as lo, v as ro } from "./layers.Dq3o7sh3.js";
|
|
19
|
+
import { I as ao, $ as kt, J as co, K as en, O as uo, P as fo, z as po, Q as at, R as tn, U as mo } from "./layers.D6d62qQ_.js";
|
|
20
|
+
import { w as et, F as Be, n as go, D as $e, O as ct, R as ho, G as bo, H as gt, J as qe, L as $t, M as yo, i as nn, u as Co, A as vt, B as on, N as Rt, P as Oe, Q as _o, S as To, T as xo, z as ko } from "./layers.Dev6Yrwi.js";
|
|
21
21
|
import { $getSelectionStyleValueForProperty as tt, $patchStyleText as Bt } from "@lexical/selection";
|
|
22
22
|
import { NewColorPicker as ht } from "@layers-app/shared";
|
|
23
|
-
import { C as ut, I as X, A as vo } from "./layers.
|
|
23
|
+
import { C as ut, I as X, A as vo } from "./layers.CXffIp2y.js";
|
|
24
24
|
import { l as Io } from "./layers.QjAkD17S.js";
|
|
25
25
|
import { $isDecoratorBlockNode as wo } from "@lexical/react/LexicalDecoratorBlockNode";
|
|
26
26
|
import { useResizeObserver as So, useClickOutside as Mo } from "@mantine/hooks";
|
|
27
|
-
import { I as Ao, f as Po } from "./layers.
|
|
27
|
+
import { I as Ao, f as Po } from "./layers.Ci1-qkbn.js";
|
|
28
28
|
const Do = 4, Lo = 2, No = "draggable-block-menu", Oo = 16, Ft = "application/x-lexical-drag-block", It = (e) => e ? e.match(/(\d*\.?\d+)%/g) : [], $o = (e) => e < 0 ? 0 : e > 100 ? 100 : e, sn = (e, t, n) => {
|
|
29
29
|
let i = 0, s = [];
|
|
30
30
|
e.update(() => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@layers-app/editor",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.6-optimization",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Powerful rich-text editor ",
|
|
7
7
|
"keywords": [
|
|
@@ -29,7 +29,6 @@
|
|
|
29
29
|
"start:specific": "VITE_LAYERS=false vite --mode full ",
|
|
30
30
|
"build": "VITE_LAYERS=true vite build",
|
|
31
31
|
"build:specific": "VITE_LAYERS=false vite build",
|
|
32
|
-
"postinstall": "node -e \"console.log('\\n📦 @layers-app/editor installed!\\n\\n⚠️ Peer dependencies required:\\n npm install lexical @lexical/react @lexical/file @lexical/markdown @layers-app/shared\\n\\n📖 Docs: https://github.com/your-org/editor#readme\\n')\"",
|
|
33
32
|
"lint": "eslint . --ext .ts,.tsx",
|
|
34
33
|
"lint:fix": "eslint . --ext .ts,.tsx --fix",
|
|
35
34
|
"preview": "vite preview",
|