@nice2dev/ui 1.0.30 → 1.1.5
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/CHANGELOG.md +848 -0
- package/README.md +30 -31
- package/dist/NiceCalendarScheduler.doc-BEtQkZjV.cjs +9 -0
- package/dist/NiceCalendarScheduler.doc-D__LRgOx.js +33 -0
- package/dist/NiceCodeEditor-BVUwp9yX.js +1134 -0
- package/dist/NiceCodeEditor-cIqUSk3j.cjs +260 -0
- package/dist/NiceColorPicker-C8NZZcXE.js +596 -0
- package/dist/NiceColorPicker-CKVbjicN.cjs +1 -0
- package/dist/NiceConfirmDialog-B57cl_F7.cjs +1 -0
- package/dist/NiceConfirmDialog-DmBX1Iea.js +81 -0
- package/dist/NiceConfirmDialog-N9fBTLYm.js +81 -0
- package/dist/NiceConfirmDialog-oSxVpsCs.cjs +1 -0
- package/dist/NiceDataGrid-3AIf2D3t.cjs +10 -0
- package/dist/NiceDataGrid-CXCUAkRb.js +1736 -0
- package/dist/NiceDocumentViewer-B-uEPZAf.js +672 -0
- package/dist/NiceDocumentViewer-BE0gKBlw.cjs +180 -0
- package/dist/NiceDrawingCanvas.doc-Dv5vB4gY.js +32 -0
- package/dist/NiceDrawingCanvas.doc-Ww9zz17x.cjs +8 -0
- package/dist/NiceErrorBoundary-BD-uqk_q.js +709 -0
- package/dist/NiceErrorBoundary-CIPXaYik.cjs +1 -0
- package/dist/NiceFileManagerViews.doc-CKlnm6cX.cjs +1 -0
- package/dist/NiceFileManagerViews.doc-Cg21DArG.js +25 -0
- package/dist/NiceForm-BNZB31Pg.js +4499 -0
- package/dist/NiceForm-C6F0HvrX.cjs +1 -0
- package/dist/NiceForm-CCyfWgIs.js +4805 -0
- package/dist/NiceForm-CPyAXxBO.cjs +1 -0
- package/dist/NiceGantt-CSFLZD2y.js +328 -0
- package/dist/NiceGantt-_ysNSVYR.cjs +1 -0
- package/dist/NiceHtmlEditor-B8B8AcSC.js +841 -0
- package/dist/NiceHtmlEditor-D8RQcBNp.cjs +10 -0
- package/dist/NiceLoginForm-Bai7aN8V.js +708 -0
- package/dist/NiceLoginForm-BrvIc-wq.cjs +1 -0
- package/dist/NiceMegaMenu.doc-7UyOCd3l.cjs +7 -0
- package/dist/NiceMegaMenu.doc-zeIyVa65.js +31 -0
- package/dist/NiceMention-CWoLD0SE.js +11082 -0
- package/dist/NiceMention-J1lUDLhg.cjs +430 -0
- package/dist/NiceMention.css +1 -0
- package/dist/NiceModal-0UxviEYE.cjs +1 -0
- package/dist/NiceModal-Bj53SKLI.js +95 -0
- package/dist/NiceModal-D-iOonog.js +95 -0
- package/dist/NiceModal-DC0UlQhc.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-4hzDw6it.js +6999 -0
- package/dist/NiceModuleLifecyclePanel-BBOg9g0b.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-Df_1k5qW.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-DtuXRiLR.js +6991 -0
- package/dist/NiceModuleLifecyclePanel.css +1 -1
- package/dist/NicePagination-Bjxy9aEc.js +172 -0
- package/dist/NicePagination-CPn-Q1h_.js +172 -0
- package/dist/NicePagination-CfFfNwrg.cjs +1 -0
- package/dist/NicePagination-EEQ6o1dF.cjs +1 -0
- package/dist/NicePivotGrid-Cmiolup9.cjs +152 -0
- package/dist/NicePivotGrid-DX_iUj2X.js +1167 -0
- package/dist/NiceSavedQueryPanel-BhjFJBvn.cjs +586 -0
- package/dist/NiceSavedQueryPanel-CH5c3rUG.js +6988 -0
- package/dist/NiceSavedQueryPanel-KvyXTnFx.js +5129 -0
- package/dist/NiceSavedQueryPanel-aQrEmmcC.cjs +596 -0
- package/dist/NiceScannerControl-Cd5KXJA9.js +12769 -0
- package/dist/NiceScannerControl-DZsERSw_.cjs +698 -0
- package/dist/NiceScannerControl.css +1 -0
- package/dist/NiceScheduler-DuxPzQQZ.js +1645 -0
- package/dist/NiceScheduler-nW7fMzKL.cjs +5 -0
- package/dist/NiceSelect-BVoqtfYN.cjs +1 -0
- package/dist/NiceSelect-DHowflmX.js +433 -0
- package/dist/NiceWindow-BoDzlGk-.js +1621 -0
- package/dist/NiceWindow-DdD9k4nc.cjs +1 -0
- package/dist/NiceWindow-DgONWxBm.cjs +1 -0
- package/dist/NiceWindow-xnTSHdHv.js +1623 -0
- package/dist/charts-B-sl1V9y.cjs +882 -0
- package/dist/charts-Bs0aDM0X.js +4671 -0
- package/dist/charts-DO2z6Ziu.js +31920 -0
- package/dist/charts-DjjKkw0q.cjs +761 -0
- package/dist/charts.cjs +1 -1
- package/dist/charts.mjs +7 -7
- package/dist/core-BUsZ7_vI.js +27914 -0
- package/dist/core-C2KhqEaU.cjs +1 -0
- package/dist/core-CLfcCDKc.cjs +122 -0
- package/dist/core-K2DIxXLn.js +795 -0
- package/dist/data-branching-D7l_kILW.cjs +1 -0
- package/dist/data-branching-DC6hcBQN.cjs +1 -0
- package/dist/data-branching-DykdTpjJ.js +6255 -0
- package/dist/data-branching-lJ07lDN-.js +6255 -0
- package/dist/data-branching.cjs +1 -1
- package/dist/data-branching.mjs +1 -1
- package/dist/data.cjs +1 -1
- package/dist/data.d.ts +70 -44
- package/dist/data.mjs +17 -16
- package/dist/devops-Bi8MXtko.js +8165 -0
- package/dist/devops-CU0sOVEA.cjs +17 -0
- package/dist/devops-CXyEwQeM.js +8165 -0
- package/dist/devops-On_1wRf9.cjs +17 -0
- package/dist/devops.cjs +1 -1
- package/dist/devops.mjs +1 -1
- package/dist/editors.cjs +1 -1
- package/dist/editors.d.ts +288 -432
- package/dist/editors.mjs +58 -62
- package/dist/feedback.cjs +1 -1
- package/dist/feedback.d.ts +1 -1
- package/dist/feedback.mjs +3 -3
- package/dist/index-BDH1yDSg.js +69235 -0
- package/dist/index-C9njkNOD.cjs +5470 -0
- package/dist/index.cjs +5137 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +556 -929
- package/dist/index.mjs +66371 -1017
- package/dist/lazy.cjs +1 -1
- package/dist/lazy.mjs +24 -24
- package/dist/navigation.cjs +1 -1
- package/dist/navigation.d.ts +31 -213
- package/dist/navigation.mjs +105 -113
- package/dist/no-code-8lO7o6xi.js +7425 -0
- package/dist/no-code-C58g8_fb.cjs +332 -0
- package/dist/no-code-Cj4xJ3w9.js +7425 -0
- package/dist/no-code-K8tOLNew.cjs +332 -0
- package/dist/no-code.cjs +1 -1
- package/dist/no-code.mjs +1 -1
- package/dist/overlays.cjs +1 -1
- package/dist/overlays.d.ts +10 -0
- package/dist/overlays.mjs +36 -36
- package/dist/pickerCommons-B-wOzHFh.cjs +1 -0
- package/dist/pickerCommons-CORo9j2a.js +2119 -0
- package/dist/pickerCommons-COiSUiP2.js +1122 -0
- package/dist/pickerCommons-D3WShRrR.cjs +1 -0
- package/dist/style.css +6 -6
- package/dist/vendor-BPVpdtPp.js +271 -0
- package/dist/vendor-Bo2Q64AF.cjs +1 -0
- package/package.json +17 -17
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),j=require("./charts-B-sl1V9y.cjs"),o=require("react"),h=require("./NiceColorPicker-CKVbjicN.cjs"),Qe=require("./NiceSelect-BVoqtfYN.cjs");function me(c){const t=c.trim().toLowerCase();return t.startsWith("http://")||t.startsWith("https://")||t.startsWith("/")||t.startsWith("./")||t.startsWith("../")?!0:!(t.startsWith("javascript:")||t.startsWith("vbscript:")||t.startsWith("data:text"))}const Ue=[{target:".nice-htmleditor",titleKey:"tutorial.htmlEditor.intro.title",title:"Rich text editor",contentKey:"tutorial.htmlEditor.intro.content",content:"Format text with the toolbar, insert links, images and tables, and switch to HTML or Markdown source when you need it.",placement:"auto"}],Xe=["bold","italic","underline","strikethrough","h1","h2","h3","ul","ol","blockquote","hr","link","unlink","image","table","code","alignLeft","alignCenter","alignRight","fontSize","fontColor","undo","redo","clear","findReplace","emoji","source","fullscreen","markdown"],l=({d:c,viewBox:t="0 0 24 24"})=>n.jsx("svg",{width:"16",height:"16",viewBox:t,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:n.jsx("path",{d:c})}),Je={bold:n.jsx("strong",{style:{fontFamily:"serif"},children:"B"}),italic:n.jsx("em",{style:{fontFamily:"serif"},children:"I"}),underline:n.jsx("span",{style:{textDecoration:"underline"},children:"U"}),strikethrough:n.jsx("span",{style:{textDecoration:"line-through"},children:"S"}),h1:"H1",h2:"H2",h3:"H3",ul:n.jsx(l,{d:"M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01"}),ol:n.jsx(l,{d:"M10 6h11M10 12h11M10 18h11M4 6h1v4M4 10h2M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"}),link:n.jsx(l,{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"}),unlink:n.jsx(l,{d:"M18.84 12.25l1.72-1.71a5 5 0 0 0-7.07-7.07L11 5.78M3 3l18 18M9 15l3-3M14 11l3 3M14 21l-1.72-1.72a5 5 0 0 1-7.07-7.07L7 10.49"}),undo:n.jsx(l,{d:"M3 7v6h6M3 13a9 9 0 1 0 3-7.7L3 13"}),redo:n.jsx(l,{d:"M21 7v6h-6M21 13a9 9 0 1 1-3-7.7L21 13"}),clear:n.jsx(l,{d:"M3 6h18M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),table:n.jsx(l,{d:"M3 3h18v18H3zM3 9h18M3 15h18M9 3v18M15 3v18"}),image:n.jsx(l,{d:"M3 3h18v18H3zM3 16l5-5 4 4 3-3 6 6M9 9a2 2 0 1 1-4 0 2 2 0 0 1 4 0z"}),code:n.jsx(l,{d:"M16 18l6-6-6-6M8 6l-6 6 6 6"}),markdown:"MD",blockquote:n.jsx(l,{d:"M3 21c3-3 3-9 0-12M21 21c-3-3-3-9 0-12M9 7h6v6H9zM15 7h6v6h-6z"}),hr:n.jsx(l,{d:"M5 12h14"}),subscript:"X₂",superscript:"X²",indent:n.jsx(l,{d:"M3 8l4 4-4 4M7 6h14M7 12h14M3 18h18"}),outdent:n.jsx(l,{d:"M7 8l-4 4 4 4M21 6H3M21 12H7M21 18H3"}),alignLeft:n.jsx(l,{d:"M3 6h18M3 12h12M3 18h18"}),alignCenter:n.jsx(l,{d:"M3 6h18M6 12h12M3 18h18"}),alignRight:n.jsx(l,{d:"M3 6h18M9 12h12M3 18h18"}),alignJustify:n.jsx(l,{d:"M3 6h18M3 12h18M3 18h18"}),fullscreen:n.jsx(l,{d:"M3 9V3h6M21 9V3h-6M3 15v6h6M21 15v6h-6"}),removeFormat:n.jsx(l,{d:"M4 7V4h16v3M5 20h6M13 4 8 20"}),print:n.jsx(l,{d:"M6 9V2h12v7M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2M6 14h12v8H6z"}),source:n.jsx(l,{d:"M16 18l6-6-6-6M8 6l-6 6 6 6"}),emoji:n.jsx(l,{d:"M12 22a10 10 0 1 1 0-20 10 10 0 0 1 0 20zM8 14s1.5 2 4 2 4-2 4-2M9 9h.01M15 9h.01"}),findReplace:n.jsx(l,{d:"M11 19a8 8 0 1 1 0-16 8 8 0 0 1 0 16zM21 21l-4.35-4.35"}),fontSize:n.jsx(l,{d:"M4 7V4h16v3M9 20h6M12 4v16"}),fontColor:n.jsx(l,{d:"M4 21h16M5 17l7-12 7 12M8 13h8"})},Ye=[{value:"1",label:"8pt"},{value:"2",label:"10pt"},{value:"3",label:"12pt"},{value:"4",label:"14pt"},{value:"5",label:"18pt"},{value:"6",label:"24pt"},{value:"7",label:"36pt"}],Ge=[{label:"Faces",emojis:["??","??","??","??","??","??","??","??","??","??","??","??"]},{label:"Hands",emojis:["??","??","??","??","??","??","??","??","??","??"]},{label:"Symbols",emojis:["??","?","??","?","?","?","??","??","??","??","??","??"]},{label:"Arrows",emojis:["??","??","??","??","??","??","??","??","??","?"]}];function Ze(c){let t=c;return t=t.replace(/<h1[^>]*>(.*?)<\/h1>/gi,`# $1
|
|
2
|
+
`),t=t.replace(/<h2[^>]*>(.*?)<\/h2>/gi,`## $1
|
|
3
|
+
`),t=t.replace(/<h3[^>]*>(.*?)<\/h3>/gi,`### $1
|
|
4
|
+
`),t=t.replace(/<strong[^>]*>(.*?)<\/strong>/gi,"**$1**"),t=t.replace(/<b[^>]*>(.*?)<\/b>/gi,"**$1**"),t=t.replace(/<em[^>]*>(.*?)<\/em>/gi,"*$1*"),t=t.replace(/<i[^>]*>(.*?)<\/i>/gi,"*$1*"),t=t.replace(/<code[^>]*>(.*?)<\/code>/gi,"`$1`"),t=t.replace(/<pre[^>]*>(.*?)<\/pre>/gis,"```\n$1\n```\n"),t=t.replace(/<br\s*\/?>/gi,`
|
|
5
|
+
`),t=t.replace(/<li[^>]*>(.*?)<\/li>/gi,`- $1
|
|
6
|
+
`),t=t.replace(/<\/?(?:ul|ol|p|div)[^>]*>/gi,`
|
|
7
|
+
`),t=t.replace(/<[^>]+>/g,""),t=t.replace(/\n{3,}/g,`
|
|
8
|
+
|
|
9
|
+
`),t.trim()}function et(c){let t=c;return t=t.replace(/^### (.+)$/gm,"<h3>$1</h3>"),t=t.replace(/^## (.+)$/gm,"<h2>$1</h2>"),t=t.replace(/^# (.+)$/gm,"<h1>$1</h1>"),t=t.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),t=t.replace(/\*(.+?)\*/g,"<em>$1</em>"),t=t.replace(/`([^`]+)`/g,"<code>$1</code>"),t=t.replace(/```\n?([\s\S]*?)\n?```/g,"<pre>$1</pre>"),t=t.replace(/^- (.+)$/gm,"<li>$1</li>"),t=t.replace(/(<li>.*<\/li>)/gs,"<ul>$1</ul>"),t=t.replace(/\n/g,"<br>"),t}const tt=({value:c,onChange:t,placeholder:fe,height:N=200,toolbar:pe=Xe,readOnly:f,onImageUpload:C,mentionTrigger:x,mentionSuggestions:he,onMentionSearch:X,onFileDrop:S,pasteCleanup:J=!0,maxLength:H=0,showWordCount:Y=!1,templates:R,label:G,error:_,helperText:Z,required:xe,disabled:p,size:be="md",id:ee,className:ge,style:Me,accessMode:ve,tutorial:ke})=>{const $=j.Dc(ve,ee),ye=$==="hidden";$==="disabled"&&(p=!0),$==="readOnly"&&(f=!0);const te=j.bc(ee),d=o.useRef(null),ne=o.useRef(null),je=o.useRef(null),[M,D]=o.useState(!1),[I,re]=o.useState(""),[v,O]=o.useState(!1),[E,se]=o.useState(""),[F,L]=o.useState(!1),[Ce,Se]=o.useState(""),[W,B]=o.useState(0),[K,He]=o.useState(!1),[oe,we]=o.useState("var(--nice-text, #000000)"),[ae,Te]=o.useState("var(--nice-warning, #ffff00)"),[ie,A]=o.useState(0),[_e,Le]=o.useState(0),[q,V]=o.useState(!1),[u,ze]=o.useState(""),[w,Ne]=o.useState(""),[P,le]=o.useState(!1),[ce,de]=o.useState(!1),m=o.useCallback((e,r)=>{if(f||p)return;const a=d.current;if(a){if(e==="markdown"){if(!M)re(Ze(c)),D(!0),O(!1);else{const s=et(I);t(s),D(!1)}return}if(e==="source"){v?(t(E),O(!1)):(se(c),O(!0),D(!1));return}if(e==="fullscreen"){He(s=>!s);return}if(e==="emoji"){le(s=>!s);return}if(e==="findReplace"){V(s=>!s);return}if(e==="image"){if(C)ne.current?.click();else{const s=prompt("Image URL:");s&&me(s)&&(a.focus(),document.execCommand("insertImage",!1,s),t(j.lc(a.innerHTML)))}return}switch(a.focus(),e){case"bold":document.execCommand("bold");break;case"italic":document.execCommand("italic");break;case"underline":document.execCommand("underline");break;case"strikethrough":document.execCommand("strikeThrough");break;case"h1":document.execCommand("formatBlock",!1,"h1");break;case"h2":document.execCommand("formatBlock",!1,"h2");break;case"h3":document.execCommand("formatBlock",!1,"h3");break;case"ul":document.execCommand("insertUnorderedList");break;case"ol":document.execCommand("insertOrderedList");break;case"blockquote":document.execCommand("formatBlock",!1,"blockquote");break;case"hr":document.execCommand("insertHorizontalRule");break;case"subscript":document.execCommand("subscript");break;case"superscript":document.execCommand("superscript");break;case"indent":document.execCommand("indent");break;case"outdent":document.execCommand("outdent");break;case"alignLeft":document.execCommand("justifyLeft");break;case"alignCenter":document.execCommand("justifyCenter");break;case"alignRight":document.execCommand("justifyRight");break;case"alignJustify":document.execCommand("justifyFull");break;case"removeFormat":document.execCommand("removeFormat");break;case"print":window.print();return;case"link":{const s=prompt("URL:");s&&me(s)&&document.execCommand("createLink",!1,s);break}case"unlink":document.execCommand("unlink");break;case"undo":document.execCommand("undo");break;case"redo":document.execCommand("redo");break;case"clear":document.execCommand("removeFormat");break;case"fontSize":{r&&document.execCommand("fontSize",!1,r);break}case"fontColor":{r&&document.execCommand("foreColor",!1,r);break}case"bgColor":{r&&document.execCommand("hiliteColor",!1,r);break}case"table":{document.execCommand("insertHTML",!1,'<table class="nice-htmleditor__table"><thead><tr><th>Header 1</th><th>Header 2</th><th>Header 3</th></tr></thead><tbody><tr><td> </td><td> </td><td> </td></tr><tr><td> </td><td> </td><td> </td></tr></tbody></table><p> </p>');break}case"code":{const i=window.getSelection()?.toString()||"";i.includes(`
|
|
10
|
+
`)||i.length>60?document.execCommand("insertHTML",!1,`<pre class="nice-htmleditor__code-block">${i||"// code"}</pre>`):document.execCommand("insertHTML",!1,`<code>${i||"code"}</code>`);break}}t(j.lc(a.innerHTML)),A(a.textContent?.length??0)}},[t,f,p,M,I,c,C,v,E]),Re=o.useCallback(async e=>{const r=e.target.files?.[0];if(!r||!C)return;const a=await C(r),s=d.current;s&&a&&(s.focus(),document.execCommand("insertImage",!1,a),t(s.innerHTML)),e.target.value=""},[C,t]),$e=o.useCallback(()=>{const e=d.current;if(!e)return;const r=e.textContent?.length??0;if(H>0&&r>H&&(e.textContent=(e.textContent??"").slice(0,H)),A(r),Le((e.textContent??"").trim().split(/\s+/).filter(Boolean).length),t(e.innerHTML),x){const a=window.getSelection();if(a&&a.rangeCount>0){const s=a.getRangeAt(0),i=s.startContainer;if(i.nodeType===Node.TEXT_NODE){const b=i.textContent||"",y=s.startOffset,z=b.slice(0,y),g=z.lastIndexOf(x);if(g>=0&&(g===0||/\s/.test(z[g-1]))){const T=z.slice(g+x.length);if(!/\s/.test(T)){L(!0),Se(T),B(0),X?.(T);return}}}}L(!1)}},[t,x,X]),k=he?.filter(e=>e.label.toLowerCase().includes(Ce.toLowerCase())).slice(0,8)??[],Q=o.useCallback(e=>{const r=d.current;if(!r)return;const a=window.getSelection();if(!a||a.rangeCount===0)return;const s=a.getRangeAt(0),i=s.startContainer;if(i.nodeType===Node.TEXT_NODE&&x){const b=i.textContent||"",y=s.startOffset,g=b.slice(0,y).lastIndexOf(x);if(g>=0){const T=b.slice(0,g),qe=b.slice(y),Ve=`<span class="nice-htmleditor__mention" data-mention="${e.key}" contenteditable="false">${x}${e.label}</span> `;i.textContent=T;const U=document.createRange();U.setStartAfter(i),U.collapse(!0);const Pe=U.createContextualFragment(Ve+qe);i.parentNode?.insertBefore(Pe,i.nextSibling),a.collapseToEnd(),t(r.innerHTML)}}L(!1)},[x,t]),De=o.useCallback(e=>{if(F&&k.length>0){e.key==="ArrowDown"?(e.preventDefault(),B(r=>Math.min(r+1,k.length-1))):e.key==="ArrowUp"?(e.preventDefault(),B(r=>Math.max(r-1,0))):e.key==="Enter"?(e.preventDefault(),Q(k[W])):e.key==="Escape"&&L(!1);return}(e.ctrlKey||e.metaKey)&&e.key==="b"?(e.preventDefault(),m("bold")):(e.ctrlKey||e.metaKey)&&e.key==="i"?(e.preventDefault(),m("italic")):(e.ctrlKey||e.metaKey)&&e.key==="u"?(e.preventDefault(),m("underline")):(e.ctrlKey||e.metaKey)&&e.key==="f"?(e.preventDefault(),V(r=>!r)):(e.ctrlKey||e.metaKey)&&e.key==="z"&&!e.shiftKey?(e.preventDefault(),m("undo")):(e.ctrlKey||e.metaKey)&&(e.key==="y"||e.key==="z"&&e.shiftKey)&&(e.preventDefault(),m("redo"))},[F,k,W,Q,m]),Ie=o.useCallback(e=>{if(!J)return;e.preventDefault();const r=e.clipboardData.getData("text/html"),a=e.clipboardData.getData("text/plain");if(r){const i=r.replace(/<style[\s\S]*?<\/style>/gi,"").replace(/<script[\s\S]*?<\/script>/gi,"").replace(/class="[^"]*"/gi,"").replace(/style="[^"]*"/gi,"").replace(/<o:[^>]*>[\s\S]*?<\/o:[^>]*>/gi,"").replace(/<!--[\s\S]*?-->/g,"").replace(/<\/?(?:xml|meta|link|font|span)[^>]*>/gi,"");document.execCommand("insertHTML",!1,i)}else a&&document.execCommand("insertText",!1,a);const s=d.current;s&&(t(s.innerHTML),A(s.textContent?.length??0))},[J,t]),Oe=o.useCallback(async e=>{if(!S)return;e.preventDefault();const r=Array.from(e.dataTransfer.files);if(r.length===0)return;const a=await S(r),s=d.current;if(s){s.focus();for(const i of a)if(/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i.test(i)||i.startsWith("data:image/"))document.execCommand("insertImage",!1,i);else{const y=`<a href="${i}">${i.split("/").pop()??i}</a>`;document.execCommand("insertHTML",!1,y)}t(s.innerHTML)}},[S,t]),Ee=o.useCallback(e=>{S&&e.preventDefault()},[S]),ue=o.useCallback(e=>{const r=d.current;if(!r||!u)return;const a=r.textContent??"",s=u.toLowerCase(),i=a.toLowerCase();(e===1?i.indexOf(s):i.lastIndexOf(s))!==-1&&(r.focus(),window.find?.(u))},[u]),Fe=o.useCallback(()=>{const e=d.current;!e||!u||(e.innerHTML=e.innerHTML.split(u).join(w),t(e.innerHTML))},[u,w,t]),We=o.useCallback(()=>{if(!u)return;const e=c.split(u).join(w);t(e);const r=d.current;r&&(r.innerHTML=e)},[u,w,c,t]),Be=o.useCallback(e=>{const r=d.current;r&&(r.focus(),document.execCommand("insertText",!1,e),t(r.innerHTML),le(!1))},[t]),Ke=o.useCallback(e=>{const r=d.current;r&&(r.focus(),document.execCommand("insertHTML",!1,e),t(r.innerHTML),de(!1))},[t]),Ae=o.useCallback(e=>{const r=p||f;if(e==="fontSize")return n.jsx(Qe.NiceSelect,{size:"sm",value:"",onChange:s=>m("fontSize",String(s)),disabled:r,placeholder:"Size",options:Ye.map(s=>({value:s.value,label:s.label})),style:{minWidth:70,maxWidth:80}},e);if(e==="fontColor")return n.jsx(h.NiceColorPicker,{value:oe,onChange:s=>{we(s),m("fontColor",s)},disabled:r,size:"sm",label:"",title:"Text color"},e);if(e==="bgColor")return n.jsx(h.NiceColorPicker,{value:ae,onChange:s=>{Te(s),m("bgColor",s)},disabled:r,size:"sm",label:"",title:"Highlight color"},e);const a=e==="markdown"&&M||e==="fullscreen"&&K||e==="source"&&v||e==="findReplace"&&q||e==="emoji"&&P;return n.jsx(h.NiceButton,{size:"sm",variant:a?"primary":"ghost",onClick:()=>m(e),title:e,disabled:r,children:Je[e]||e},e)},[p,f,m,M,K,oe,ae,v,q,P]);return ye?null:n.jsxs("div",{className:`nice-field nice-field--${be} ${_?"nice-field--error":""} ${ge||""}`,style:Me,children:[G&&n.jsxs("label",{className:"nice-field__label",htmlFor:te,children:[G,xe&&n.jsx("span",{className:"nice-field__required",children:"*"})]}),n.jsxs("div",{ref:je,className:`nice-htmleditor${K?" nice-htmleditor--fullscreen":""}`,style:{position:"relative"},children:[n.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:n.jsx(j.Ql,{steps:j.Yl(ke,Ue)})}),n.jsxs("div",{className:"nice-htmleditor__toolbar",style:{display:"flex",flexWrap:"wrap",gap:2,alignItems:"center"},children:[pe.map(Ae),R&&R.length>0&&n.jsxs("div",{style:{position:"relative"},children:[n.jsx(h.NiceButton,{size:"sm",variant:ce?"primary":"ghost",onClick:()=>de(e=>!e),title:"Insert template",children:"??"}),ce&&n.jsx("ul",{style:{position:"absolute",top:"100%",right:0,zIndex:200,background:"var(--bg-primary, #fff)",border:"1px solid var(--border-color, #ddd)",borderRadius:6,boxShadow:"0 4px 16px var(--nice-overlay-12, rgba(0, 0, 0, 0.12))",listStyle:"none",margin:0,padding:4,minWidth:160,maxHeight:200,overflow:"auto"},children:R.map((e,r)=>n.jsx("li",{style:{padding:"6px 10px",cursor:"pointer",borderRadius:4},onMouseDown:a=>{a.preventDefault(),Ke(e.html)},children:e.label},r))})]})]}),q&&n.jsxs("div",{className:"nice-htmleditor__find-bar",style:{display:"flex",gap:4,alignItems:"center",padding:"4px 8px",background:"var(--bg-secondary, #f8f9fa)",borderBottom:"1px solid var(--border-color, #ddd)",fontSize:"0.875em"},children:[n.jsx("input",{type:"text",placeholder:"Find...",value:u,onChange:e=>ze(e.target.value),style:{flex:1,maxWidth:180,padding:"2px 6px",border:"1px solid var(--border-color, #ccc)",borderRadius:4,background:"var(--bg-primary, #fff)",color:"var(--text-primary, #1f2937)"}}),n.jsx("input",{type:"text",placeholder:"Replace...",value:w,onChange:e=>Ne(e.target.value),style:{flex:1,maxWidth:180,padding:"2px 6px",border:"1px solid var(--border-color, #ccc)",borderRadius:4,background:"var(--bg-primary, #fff)",color:"var(--text-primary, #1f2937)"}}),n.jsx(h.NiceButton,{size:"sm",variant:"ghost",onClick:()=>ue(1),title:"Find next",children:"?"}),n.jsx(h.NiceButton,{size:"sm",variant:"ghost",onClick:()=>ue(-1),title:"Find previous",children:"?"}),n.jsx(h.NiceButton,{size:"sm",variant:"ghost",onClick:Fe,disabled:p||f,children:"Replace"}),n.jsx(h.NiceButton,{size:"sm",variant:"ghost",onClick:We,disabled:p||f,children:"All"}),n.jsx(h.NiceButton,{size:"sm",variant:"ghost",onClick:()=>V(!1),children:"?"})]}),P&&n.jsx("div",{className:"nice-htmleditor__emoji-picker",style:{padding:8,background:"var(--bg-primary, #fff)",borderBottom:"1px solid var(--border-color, #ddd)",maxHeight:180,overflowY:"auto"},children:Ge.map(e=>n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:"0.7em",fontWeight:600,color:"var(--text-muted, #999)",padding:"4px 0"},children:e.label}),n.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:2},children:e.emojis.map(r=>n.jsx("span",{style:{cursor:"pointer",fontSize:"1.2em",padding:2,borderRadius:4},onClick:()=>Be(r),title:r,children:r},r))})]},e.label))}),n.jsx("input",{ref:ne,type:"file",accept:"image/*",style:{display:"none"},onChange:Re}),v?n.jsx("textarea",{className:"nice-htmleditor__source",value:E,onChange:e=>se(e.target.value),style:{minHeight:N,width:"100%",fontFamily:"monospace",resize:"vertical",whiteSpace:"pre",fontSize:"0.85em",background:"var(--bg-primary, #fff)",color:"var(--text-primary, #1f2937)",border:"none",padding:12,boxSizing:"border-box",outline:"none"},disabled:p||f}):M?n.jsx("textarea",{className:"nice-htmleditor__markdown",value:I,onChange:e=>re(e.target.value),style:{minHeight:N,width:"100%",fontFamily:"monospace",resize:"vertical",background:"var(--bg-primary, #fff)",color:"var(--text-primary, #1f2937)",border:"none",padding:12,boxSizing:"border-box",outline:"none"},disabled:p||f}):n.jsxs("div",{style:{position:"relative"},children:[n.jsx("div",{ref:d,id:te,className:"nice-htmleditor__content",contentEditable:!p&&!f,dangerouslySetInnerHTML:{__html:c},onInput:$e,onKeyDown:De,onPaste:Ie,onDrop:Oe,onDragOver:Ee,style:{minHeight:N},"data-placeholder":fe,role:"textbox","aria-multiline":"true",suppressContentEditableWarning:!0}),F&&k.length>0&&n.jsx("ul",{className:"nice-htmleditor__mention-list",children:k.map((e,r)=>n.jsx("li",{className:`nice-htmleditor__mention-item ${r===W?"nice-htmleditor__mention-item--active":""}`,onMouseDown:a=>{a.preventDefault(),Q(e)},children:e.label},e.key))})]}),n.jsxs("div",{className:"nice-htmleditor__statusbar",style:{display:"flex",gap:12,padding:"2px 8px",fontSize:"0.75em",color:"var(--text-muted, #666)",borderTop:"1px solid var(--border-color, #eee)"},children:[H>0&&n.jsxs("span",{children:[ie," / ",H]}),Y&&n.jsxs("span",{children:[_e," words"]}),Y&&n.jsxs("span",{children:[ie," chars"]}),v&&n.jsx("span",{style:{fontWeight:600},children:"HTML Source"}),M&&n.jsx("span",{style:{fontWeight:600},children:"Markdown"})]})]}),_&&n.jsx("div",{className:"nice-field__error",children:_}),Z&&!_&&n.jsx("div",{className:"nice-field__hint",children:Z})]})};exports.NiceHtmlEditor=tt;
|