@nice2dev/ui 1.1.6 → 1.1.7
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 +52 -0
- package/README.md +50 -29
- package/css/legacy-bg-text-aliases.css +65 -61
- package/dist/NiceCodeEditor-Bc81wiaN.js +1134 -0
- package/dist/NiceCodeEditor-D6f8KdHN.js +1134 -0
- package/dist/NiceCodeEditor-DE3saxyt.cjs +260 -0
- package/dist/NiceCodeEditor-DZM16My5.cjs +260 -0
- package/dist/NiceCodeEditor-HqmcJjmZ.js +1179 -0
- package/dist/NiceColorPicker-6EqXaDj0.cjs +1 -0
- package/dist/NiceColorPicker-BiEWqWnd.js +596 -0
- package/dist/NiceColorPicker-Cuc6YXqz.cjs +1 -0
- package/dist/NiceColorPicker-DMATcNWG.js +596 -0
- package/dist/NiceColorPicker-R3O1nemp.js +596 -0
- package/dist/NiceConfirmDialog-B0e10fRL.cjs +1 -0
- package/dist/NiceConfirmDialog-BBDgEMHv.js +81 -0
- package/dist/NiceConfirmDialog-C7kdr8jJ.js +81 -0
- package/dist/NiceConfirmDialog-DMHqPfFM.js +81 -0
- package/dist/NiceConfirmDialog-ZJpQLQQS.cjs +1 -0
- package/dist/NiceDataGrid-BzUw4dSu.cjs +10 -0
- package/dist/NiceDataGrid-CPKcVOVz.js +1743 -0
- package/dist/NiceDataGrid-DJr33WMy.cjs +10 -0
- package/dist/NiceDataGrid-D_4gZ1Hu.js +1736 -0
- package/dist/NiceDataGrid-DlUAaXhD.js +1736 -0
- package/dist/NiceDocumentViewer-8ghRVtfO.js +672 -0
- package/dist/NiceDocumentViewer-ChWtA_Ry.cjs +180 -0
- package/dist/NiceDocumentViewer-DwLUV7Tc.js +672 -0
- package/dist/NiceDocumentViewer-goMzF1w3.cjs +180 -0
- package/dist/NiceDocumentViewer-gt1mxzP8.js +672 -0
- package/dist/NiceForm-CHEAHxDw.js +4805 -0
- package/dist/NiceForm-CJUp1CL0.cjs +1 -0
- package/dist/NiceForm-Cp_RH3Yj.js +4805 -0
- package/dist/NiceForm-a6tGr6ss.js +4819 -0
- package/dist/NiceForm-jU89oe2S.cjs +1 -0
- package/dist/NiceGantt-BnQwyTfG.cjs +1 -0
- package/dist/NiceGantt-D8coFAvK.js +328 -0
- package/dist/NiceGantt-DOZfT6r5.js +328 -0
- package/dist/NiceGantt-DQzH1V-R.js +328 -0
- package/dist/NiceGantt-jQ8ZpXko.cjs +1 -0
- package/dist/NiceHtmlEditor-B1nlXJNW.cjs +10 -0
- package/dist/NiceHtmlEditor-Bv3VqJPG.js +862 -0
- package/dist/NiceHtmlEditor-CKsGj-Ei.cjs +10 -0
- package/dist/NiceHtmlEditor-CloMgyzg.js +841 -0
- package/dist/NiceHtmlEditor-DUAHmkWI.js +841 -0
- package/dist/NiceLoginForm-Ce_QLnLf.js +736 -0
- package/dist/NiceLoginForm-DLpNTQlR.cjs +1 -0
- package/dist/NiceLoginForm-Dg0286Cc.js +736 -0
- package/dist/NiceLoginForm-X05Vadeg.js +708 -0
- package/dist/NiceLoginForm-f_dBCnUi.cjs +1 -0
- package/dist/NiceMention-BByI4nFG.js +11120 -0
- package/dist/NiceMention-C2TPiMph.cjs +430 -0
- package/dist/NiceMention-C67vT6m0.js +11145 -0
- package/dist/NiceMention-D1cdy63w.cjs +430 -0
- package/dist/NiceMention-QIuggb9Y.js +11122 -0
- package/dist/NiceMention.css +1 -1
- package/dist/NiceModal-CHaan9al.js +95 -0
- package/dist/NiceModal-Czq6OEAT.js +95 -0
- package/dist/NiceModal-D-HFwawr.js +95 -0
- package/dist/NiceModal-DOy2XTzc.cjs +1 -0
- package/dist/NiceModal-DkawKzEE.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-1CsP8Zst.js +6997 -0
- package/dist/NiceModuleLifecyclePanel-Bkx4Yg-3.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-C5oYtczk.js +6999 -0
- package/dist/NiceModuleLifecyclePanel-DCcy2yYi.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-DqdgW-0s.js +7004 -0
- package/dist/NiceModuleLifecyclePanel.css +1 -1
- package/dist/NicePagination-7od5KUa3.cjs +1 -0
- package/dist/NicePagination-DMrkR8hH.cjs +1 -0
- package/dist/NicePagination-DQmZpsSQ.js +179 -0
- package/dist/NicePagination-DipQRjPq.js +172 -0
- package/dist/NicePagination-KhlVXYaT.js +172 -0
- package/dist/NicePivotGrid-B-KthuqL.cjs +152 -0
- package/dist/NicePivotGrid-CLCTHkKO.cjs +152 -0
- package/dist/NicePivotGrid-DV54FCsH.js +1174 -0
- package/dist/NicePivotGrid-DoWLUPUs.js +1167 -0
- package/dist/NicePivotGrid-etwpfccz.js +1167 -0
- package/dist/NiceSavedQueryPanel-BABkTNc5.js +5129 -0
- package/dist/NiceSavedQueryPanel-Cfeig83P.cjs +586 -0
- package/dist/NiceSavedQueryPanel-DTWRLseb.cjs +586 -0
- package/dist/NiceSavedQueryPanel-Dy154sxE.js +5129 -0
- package/dist/NiceSavedQueryPanel-v7AffOOe.js +5129 -0
- package/dist/NiceSavedQueryPanel.css +1 -1
- package/dist/NiceScheduler-BEgB7ZgF.cjs +5 -0
- package/dist/NiceScheduler-C9JprsEI.cjs +5 -0
- package/dist/NiceScheduler-DSP-PPh0.js +1645 -0
- package/dist/NiceScheduler-DuPnaA3t.js +1652 -0
- package/dist/NiceScheduler-Oa89YZx9.js +1645 -0
- package/dist/NiceSelect-A336yeLZ.js +433 -0
- package/dist/NiceSelect-B5hTbqi2.js +433 -0
- package/dist/NiceSelect-BYSgDYzq.cjs +1 -0
- package/dist/NiceSelect-Dudf2T5T.js +433 -0
- package/dist/NiceSelect-DwBAIrX7.cjs +1 -0
- package/dist/NiceWindow-B6zjBTl9.cjs +1 -0
- package/dist/NiceWindow-BKQEx7Vf.js +1623 -0
- package/dist/NiceWindow-BnTH7Gy0.js +1623 -0
- package/dist/NiceWindow-CZN9NVZw.cjs +1 -0
- package/dist/NiceWindow-lxtPR7yZ.js +1623 -0
- package/dist/NiceWindow.css +1 -1
- package/dist/charts-B8_V3_nq.cjs +882 -0
- package/dist/charts-BZgyyybE.js +31933 -0
- package/dist/charts-FuDk5-r6.js +31958 -0
- package/dist/charts-INj3yFo5.js +31946 -0
- package/dist/charts-NolNXKUL.cjs +882 -0
- package/dist/charts.cjs +1 -1
- package/dist/charts.css +1 -1
- package/dist/charts.mjs +1 -1
- package/dist/core-A_A6c7an.js +795 -0
- package/dist/core-B2iH2J_X.js +795 -0
- package/dist/core-BmspZEfD.js +795 -0
- package/dist/core-DAfLOet6.cjs +1 -0
- package/dist/core-ZG3bgnBR.cjs +1 -0
- package/dist/data-branching-B3TOqXAO.cjs +1 -0
- package/dist/data-branching-BUGiICDZ.js +6275 -0
- package/dist/data-branching-DMXmcocj.js +6275 -0
- package/dist/data-branching-YE8P9M5P.js +6275 -0
- package/dist/data-branching-t6uhAwIm.cjs +1 -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 +7 -2
- package/dist/data.mjs +3 -3
- package/dist/devops-BhV3OmF7.js +8285 -0
- package/dist/devops-BqUxnbRi.cjs +17 -0
- package/dist/devops-Bx-Qwj9w.cjs +17 -0
- package/dist/devops-DYZatW45.js +8251 -0
- package/dist/devops-R98k2zpd.js +8251 -0
- package/dist/devops.cjs +1 -1
- package/dist/devops.d.ts +29 -16
- package/dist/devops.mjs +1 -1
- package/dist/editors.cjs +1 -1
- package/dist/editors.d.ts +35 -20
- package/dist/editors.mjs +7 -7
- package/dist/feedback.cjs +1 -1
- package/dist/feedback.mjs +3 -3
- package/dist/index.cjs +445 -445
- package/dist/index.css +1 -1
- package/dist/index.d.ts +190 -111
- package/dist/index.mjs +16635 -16351
- package/dist/lazy.cjs +1 -1
- package/dist/lazy.d.ts +31 -18
- package/dist/lazy.mjs +24 -24
- package/dist/navigation.cjs +1 -1
- package/dist/navigation.d.ts +17 -14
- package/dist/navigation.mjs +130 -130
- package/dist/no-code-BPaAS4wW.cjs +332 -0
- package/dist/no-code-CBwUVL1i.js +7447 -0
- package/dist/no-code-CjktkQ50.js +7447 -0
- package/dist/no-code-DW2NrRba.js +7447 -0
- package/dist/no-code-DmFxrZ5T.cjs +332 -0
- package/dist/no-code.cjs +1 -1
- package/dist/no-code.d.ts +2 -2
- package/dist/no-code.mjs +1 -1
- package/dist/overlays.cjs +1 -1
- package/dist/overlays.d.ts +4 -4
- package/dist/overlays.mjs +2 -2
- package/dist/pickerCommons-C4XWRUvH.cjs +1 -0
- package/dist/pickerCommons-C_BpYs_m.cjs +1 -0
- package/dist/pickerCommons-DAOXH_u5.js +1122 -0
- package/dist/pickerCommons-Dn4wnDco.js +1122 -0
- package/dist/pickerCommons-DskswPS5.js +1122 -0
- package/dist/pickerCommons.css +1 -1
- package/dist/style.css +7 -7
- package/package.json +3 -3
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),j=require("./charts-B8_V3_nq.cjs"),i=require("react"),h=require("./NiceColorPicker-6EqXaDj0.cjs"),Qe=require("./NiceSelect-DwBAIrX7.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=i.useRef(null),ne=i.useRef(null),je=i.useRef(null),[M,D]=i.useState(!1),[I,re]=i.useState(""),[v,O]=i.useState(!1),[E,se]=i.useState(""),[F,L]=i.useState(!1),[Ce,Se]=i.useState(""),[W,B]=i.useState(0),[K,He]=i.useState(!1),[ie,we]=i.useState("var(--nice-text, #000000)"),[oe,Te]=i.useState("var(--nice-warning, #ffff00)"),[ae,A]=i.useState(0),[_e,Le]=i.useState(0),[q,V]=i.useState(!1),[u,ze]=i.useState(""),[w,Ne]=i.useState(""),[P,le]=i.useState(!1),[ce,de]=i.useState(!1),m=i.useCallback((e,r)=>{if(f||p)return;const o=d.current;if(o){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)&&(o.focus(),document.execCommand("insertImage",!1,s),t(j.lc(o.innerHTML)))}return}switch(o.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 a=window.getSelection()?.toString()||"";a.includes(`
|
|
10
|
+
`)||a.length>60?document.execCommand("insertHTML",!1,`<pre class="nice-htmleditor__code-block">${a||"// code"}</pre>`):document.execCommand("insertHTML",!1,`<code>${a||"code"}</code>`);break}}t(j.lc(o.innerHTML)),A(o.textContent?.length??0)}},[t,f,p,M,I,c,C,v,E]),Re=i.useCallback(async e=>{const r=e.target.files?.[0];if(!r||!C)return;const o=await C(r),s=d.current;s&&o&&(s.focus(),document.execCommand("insertImage",!1,o),t(s.innerHTML)),e.target.value=""},[C,t]),$e=i.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 o=window.getSelection();if(o&&o.rangeCount>0){const s=o.getRangeAt(0),a=s.startContainer;if(a.nodeType===Node.TEXT_NODE){const b=a.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=i.useCallback(e=>{const r=d.current;if(!r)return;const o=window.getSelection();if(!o||o.rangeCount===0)return;const s=o.getRangeAt(0),a=s.startContainer;if(a.nodeType===Node.TEXT_NODE&&x){const b=a.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> `;a.textContent=T;const U=document.createRange();U.setStartAfter(a),U.collapse(!0);const Pe=U.createContextualFragment(Ve+qe);a.parentNode?.insertBefore(Pe,a.nextSibling),o.collapseToEnd(),t(r.innerHTML)}}L(!1)},[x,t]),De=i.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=i.useCallback(e=>{if(!J)return;e.preventDefault();const r=e.clipboardData.getData("text/html"),o=e.clipboardData.getData("text/plain");if(r){const a=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,a)}else o&&document.execCommand("insertText",!1,o);const s=d.current;s&&(t(s.innerHTML),A(s.textContent?.length??0))},[J,t]),Oe=i.useCallback(async e=>{if(!S)return;e.preventDefault();const r=Array.from(e.dataTransfer.files);if(r.length===0)return;const o=await S(r),s=d.current;if(s){s.focus();for(const a of o)if(/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i.test(a)||a.startsWith("data:image/"))document.execCommand("insertImage",!1,a);else{const y=`<a href="${a}">${a.split("/").pop()??a}</a>`;document.execCommand("insertHTML",!1,y)}t(s.innerHTML)}},[S,t]),Ee=i.useCallback(e=>{S&&e.preventDefault()},[S]),ue=i.useCallback(e=>{const r=d.current;if(!r||!u)return;const o=r.textContent??"",s=u.toLowerCase(),a=o.toLowerCase();(e===1?a.indexOf(s):a.lastIndexOf(s))!==-1&&(r.focus(),window.find?.(u))},[u]),Fe=i.useCallback(()=>{const e=d.current;!e||!u||(e.innerHTML=e.innerHTML.split(u).join(w),t(e.innerHTML))},[u,w,t]),We=i.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=i.useCallback(e=>{const r=d.current;r&&(r.focus(),document.execCommand("insertText",!1,e),t(r.innerHTML),le(!1))},[t]),Ke=i.useCallback(e=>{const r=d.current;r&&(r.focus(),document.execCommand("insertHTML",!1,e),t(r.innerHTML),de(!1))},[t]),Ae=i.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:ie,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:oe,onChange:s=>{Te(s),m("bgColor",s)},disabled:r,size:"sm",label:"",title:"Highlight color"},e);const o=e==="markdown"&&M||e==="fullscreen"&&K||e==="source"&&v||e==="findReplace"&&q||e==="emoji"&&P;return n.jsx(h.NiceButton,{size:"sm",variant:o?"primary":"ghost",onClick:()=>m(e),title:e,disabled:r,children:Je[e]||e},e)},[p,f,m,M,K,ie,oe,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(--nice-bg-primary, #fff)",border:"1px solid var(--nice-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:o=>{o.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(--nice-bg-secondary, #f8f9fa)",borderBottom:"1px solid var(--nice-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(--nice-border-color, #ccc)",borderRadius:4,background:"var(--nice-bg-primary, #fff)",color:"var(--nice-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(--nice-border-color, #ccc)",borderRadius:4,background:"var(--nice-bg-primary, #fff)",color:"var(--nice-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(--nice-bg-primary, #fff)",borderBottom:"1px solid var(--nice-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(--nice-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(--nice-bg-primary, #fff)",color:"var(--nice-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(--nice-bg-primary, #fff)",color:"var(--nice-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:o=>{o.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(--nice-text-muted, #666)",borderTop:"1px solid var(--nice-border-color, #eee)"},children:[H>0&&n.jsxs("span",{children:[ae," / ",H]}),Y&&n.jsxs("span",{children:[_e," words"]}),Y&&n.jsxs("span",{children:[ae," 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;
|