@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,260 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),w=require("./charts-B8_V3_nq.cjs"),i=require("react"),Ce=[{target:".nice-code-editor-wrap",titleKey:"tutorial.codeEditor.intro.title",title:"Code editor",contentKey:"tutorial.codeEditor.intro.content",content:"Edit code with syntax highlighting, IntelliSense and the toolbar. Ctrl+S saves; the status bar shows the cursor position and any problems.",placement:"auto"}];let D=null,q=null;const Ne="0.45.0",Q=`https://cdn.jsdelivr.net/npm/monaco-editor@${Ne}/min/vs`,se=15e3;function de(){const m=window;if(m.MonacoEnvironment?.getWorkerUrl)return;const a=`self.MonacoEnvironment={baseUrl:'${Q}/'};importScripts('${Q}/base/worker/workerMain.js');`,p=URL.createObjectURL(new Blob([a],{type:"text/javascript"}));m.MonacoEnvironment={getWorkerUrl:()=>p}}function F(m){if(m!=="auto")return m;if(typeof document>"u")return"vs";const a=document.documentElement.dataset.theme;return a==="dark"?"vs-dark":a==="light"?"vs":window.matchMedia?.("(prefers-color-scheme: dark)").matches?"vs-dark":"vs"}function me(){return q?Promise.resolve(q):D||(D=new Promise((m,a)=>{if(window.monaco){de(),q=window.monaco,m(q);return}let p=!1;const l=window.setTimeout(()=>{p||(p=!0,D=null,a(new Error(`Monaco editor failed to load within ${se}ms`)))},se),k=document.createElement("script");k.src=`${Q}/loader.min.js`,k.async=!0,k.onload=()=>{const b=window.require;b.config({paths:{vs:Q}}),de(),b(["vs/editor/editor.main"],_=>{p||(p=!0,window.clearTimeout(l),q=_,m(_))})},k.onerror=()=>{p||(p=!0,window.clearTimeout(l),D=null,a(new Error("Failed to load Monaco Editor loader script")))},document.head.appendChild(k)}),D)}const je=i.forwardRef(function(a,p){const{value:l,onChange:k,language:b="plaintext",theme:_="auto",options:o={},height:W=400,width:P="100%",markers:C=[],decorations:O=[],completionProvider:T,onMount:E,onCursorPositionChange:S,onSelectionChange:I,onSave:N,loading:M,disabled:j=!1,showToolbar:z=!1,showStatusBar:A=!1,editorSize:V="standard",className:$,"data-testid":v,lsp:s,extraLibs:u,tutorial:f}=a,x=i.useRef(null),c=i.useRef(null),y=i.useRef(null),G=i.useRef([]),L=i.useRef(null),[U,B]=i.useState(!0),[Z,pe]=i.useState(null),[oe,fe]=i.useState({lineNumber:1,column:1}),[re,ge]=i.useState(""),[J,he]=i.useState(o.wordWrap==="on"),X=i.useMemo(()=>({automaticLayout:!0,readOnly:j||o.readOnly,minimap:{enabled:o.minimap??!0},lineNumbers:o.lineNumbers??"on",wordWrap:o.wordWrap??"off",tabSize:o.tabSize??2,insertSpaces:o.insertSpaces??!0,fontSize:o.fontSize??14,fontFamily:o.fontFamily??"'Fira Code', 'Consolas', 'Monaco', monospace",fontLigatures:o.fontLigatures??!0,cursorStyle:o.cursorStyle??"line",cursorBlinking:o.cursorBlinking??"blink",autoClosingBrackets:o.autoClosingBrackets??"languageDefined",autoClosingQuotes:o.autoClosingQuotes??"languageDefined",formatOnPaste:o.formatOnPaste??!1,formatOnType:o.formatOnType??!1,renderWhitespace:o.renderWhitespace??"selection",renderControlCharacters:o.renderControlCharacters??!1,scrollBeyondLastLine:o.scrollBeyondLastLine??!0,smoothScrolling:o.smoothScrolling??!0,folding:o.folding??!0,showFoldingControls:o.showFoldingControls??"mouseover","bracketPairColorization.enabled":o.bracketPairColorization??!0,guides:o.guides??{bracketPairs:!0,indentation:!0,highlightActiveIndentation:!0},stickyScroll:{enabled:o.stickyScroll??!1},quickSuggestions:o.quickSuggestions??!0,suggestOnTriggerCharacters:o.suggestOnTriggerCharacters??!0,acceptSuggestionOnEnter:o.acceptSuggestionOnEnter??"on",inlayHints:{enabled:o.inlayHints?"on":"off"}}),[o,j]);i.useEffect(()=>{if(!x.current)return;let e=!0;return me().then(async r=>{if(!e||!x.current)return;y.current=r;const n=r.editor.create(x.current,{value:l,language:b,theme:F(_),...X});if(c.current=n,B(!1),n.onDidChangeModelContent(()=>{const d=n.getValue();k?.(d)}),n.onDidChangeCursorPosition(d=>{fe({lineNumber:d.position.lineNumber,column:d.position.column}),S?.({lineNumber:d.position.lineNumber,column:d.position.column})}),n.onDidChangeCursorSelection(d=>{const h=d.selection,g=n.getModel()?.getValueInRange(h)??"";ge(g),I?.({startLineNumber:h.startLineNumber,startColumn:h.startColumn,endLineNumber:h.endLineNumber,endColumn:h.endColumn})}),n.addCommand(r.KeyMod.CtrlCmd|r.KeyCode.KeyS,()=>{N?.(n.getValue())}),s&&typeof window<"u")try{await Y("https://cdn.jsdelivr.net/npm/vscode-ws-jsonrpc@1.0.2/lib/browser/index.min.js"),await Y("https://cdn.jsdelivr.net/npm/monaco-languageclient@0.15.0/lib/monaco-languageclient.min.js");const d=window,h=d.ReconnectingWebSocket,{MonacoLanguageClient:g,CloseAction:H,ErrorAction:K,createConnection:ie}=d.monacoLanguageClient||{};if(g&&ie){const ve=s.url,xe=s.language,ce=new h(ve),ye=new d.VSCodeWebSocketMessageReader(ce),we=new d.VSCodeWebSocketMessageWriter(ce),_e=ie(ye,we),ae=new g({name:"LSP Client",clientOptions:{documentSelector:[xe],initializationOptions:s.initOptions,errorHandler:{error:()=>K.Continue,closed:()=>H.Restart}},connectionProvider:{get:()=>Promise.resolve(_e)}});ae.start(),c.current.__lspClient=ae}}catch(d){console.warn("LSP bridge failed to load:",d)}E?.(n,r)}).catch(r=>{e&&(pe(r.message??"Failed to load editor"),B(!1))}),()=>{if(e=!1,c.current?.dispose(),L.current?.dispose(),c.current&&c.current.__lspClient)try{c.current.__lspClient.stop()}catch{}}},[s]),i.useEffect(()=>{const e=c.current;if(e&&l!==e.getValue()){const r=e.getPosition();e.setValue(l),r&&e.setPosition(r)}},[l]),i.useEffect(()=>{const e=c.current,r=y.current;if(e&&r){const n=e.getModel();n&&r.editor.setModelLanguage(n,b)}},[b]),i.useEffect(()=>{const e=y.current;if(!e||U||!u||u.length===0||b!=="javascript"&&b!=="typescript")return;const r=e.languages?.typescript;if(!r)return;const n=[];try{u.forEach((d,h)=>{const g=d.filePath??`inmemory://model/nice-extralib-${h}.d.ts`,H=r.typescriptDefaults?.addExtraLib(d.content,g);H&&n.push(H);const K=r.javascriptDefaults?.addExtraLib(d.content,g);K&&n.push(K)})}catch(d){console.warn("Failed to register extraLibs:",d)}return()=>{n.forEach(d=>{try{d.dispose()}catch{}})}},[u,b,U]),i.useEffect(()=>{const e=y.current;if(!e||(e.editor.setTheme(F(_)),_!=="auto"||typeof document>"u"))return;const r=()=>{y.current?.editor.setTheme(F("auto"))},n=new MutationObserver(r);n.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const d=window.matchMedia?.("(prefers-color-scheme: dark)");return d?.addEventListener?.("change",r),()=>{n.disconnect(),d?.removeEventListener?.("change",r)}},[_]),i.useEffect(()=>{const e=c.current;e&&e.updateOptions(X)},[X]),i.useEffect(()=>{const e=c.current,r=y.current;if(e&&r){const n=e.getModel();if(n){const d=C.map(h=>({startLineNumber:h.startLineNumber,startColumn:h.startColumn,endLineNumber:h.endLineNumber,endColumn:h.endColumn,message:h.message,severity:h.severity}));r.editor.setModelMarkers(n,"owner",d)}}},[C]),i.useEffect(()=>{const e=c.current;if(e&&O.length>0){const r=O.map(n=>({range:{startLineNumber:n.range.startLineNumber,startColumn:n.range.startColumn,endLineNumber:n.range.endLineNumber,endColumn:n.range.endColumn},options:{className:n.className,glyphMarginClassName:n.glyphMarginClassName,hoverMessage:n.hoverMessage?{value:n.hoverMessage}:void 0,isWholeLine:n.isWholeLine}}));G.current=e.deltaDecorations(G.current,r)}},[O]),i.useEffect(()=>{const e=y.current;if(!e||!T)return;L.current?.dispose();const r={text:0,method:1,function:2,constructor:3,field:4,variable:5,class:6,interface:7,module:8,property:9,keyword:13,snippet:14,color:15,file:16,reference:17,folder:18};return L.current=e.languages.registerCompletionItemProvider(b,{provideCompletionItems:async(n,d)=>({suggestions:(await T(n,d)).map(g=>({label:g.label,kind:r[g.kind]??0,insertText:g.insertText,insertTextRules:g.insertTextRules==="insertAsSnippet"?4:void 0,documentation:g.documentation,detail:g.detail,range:{startLineNumber:d.lineNumber,startColumn:d.column,endLineNumber:d.lineNumber,endColumn:d.column}}))})}),()=>{L.current?.dispose()}},[b,T]),i.useImperativeHandle(p,()=>({getEditor:()=>c.current,getMonaco:()=>y.current,focus:()=>c.current?.focus(),getValue:()=>c.current?.getValue()??"",setValue:e=>c.current?.setValue(e),getSelection:()=>{const e=c.current;if(!e)return"";const r=e.getSelection();return r?e.getModel()?.getValueInRange(r)??"":""},insertText:e=>{const r=c.current;if(!r)return;const n=r.getSelection();n&&r.executeEdits("",[{range:n,text:e}])},formatDocument:()=>{c.current?.getAction("editor.action.formatDocument")?.run()},goToLine:(e,r=1)=>{const n=c.current;n&&(n.setPosition({lineNumber:e,column:r}),n.revealLineInCenter(e),n.focus())},findReplace:()=>{c.current?.getAction("editor.action.startFindReplaceAction")?.run()},undo:()=>{c.current?.trigger("keyboard","undo",null)},redo:()=>{c.current?.trigger("keyboard","redo",null)},getCursorPosition:()=>{const e=c.current?.getPosition();return{lineNumber:e?.lineNumber??1,column:e?.column??1}},setMarkers:e=>{const r=c.current,n=y.current;if(r&&n){const d=r.getModel();if(d){const h=e.map(g=>({startLineNumber:g.startLineNumber,startColumn:g.startColumn,endLineNumber:g.endLineNumber,endColumn:g.endColumn,message:g.message,severity:g.severity}));n.editor.setModelMarkers(d,"owner",h)}}}}),[]);const R=i.useMemo(()=>({format:()=>c.current?.getAction("editor.action.formatDocument")?.run(),undo:()=>c.current?.trigger("keyboard","undo",null),redo:()=>c.current?.trigger("keyboard","redo",null),find:()=>c.current?.getAction("editor.action.startFindReplaceAction")?.run(),toggleWordWrap:()=>{const e=!J;he(e),c.current?.updateOptions({wordWrap:e?"on":"off"})},toggleMinimap:()=>{const e=c.current?.getOption?.(y.current?.editor?.EditorOption?.minimap);c.current?.updateOptions({minimap:{enabled:!e?.enabled}})},foldAll:()=>c.current?.getAction("editor.foldAll")?.run(),unfoldAll:()=>c.current?.getAction("editor.unfoldAll")?.run()}),[J]),be=l.split(`
|
|
2
|
+
`).length,ke=l.length;return t.jsxs("div",{className:`nice-code-editor-wrap nice-editor--${V} ${$??""}`,style:{height:W,width:P,display:"flex",flexDirection:"column",position:"relative"},"data-testid":v,children:[t.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:t.jsx(w.Ql,{steps:w.Yl(f,Ce)})}),Z&&t.jsxs("div",{className:"nice-code-editor__error",style:{position:"absolute",inset:0,zIndex:2,background:"var(--nice-bg-primary, #fff)"},children:[t.jsxs("span",{children:[t.jsx(w.oa,{name:"warning",size:16})," ",Z]}),t.jsx("textarea",{value:l,onChange:e=>k?.(e.target.value),readOnly:j||o.readOnly,style:{width:"100%",height:"100%",fontFamily:"monospace"}})]}),U&&!Z&&t.jsx("div",{className:"nice-code-editor__loader-overlay",style:{position:"absolute",inset:0,zIndex:2,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--nice-bg-primary, #fff)"},children:M??t.jsx("div",{className:"nice-code-editor__loader",children:"Loading editor..."})}),z&&t.jsxs("div",{className:"nice-code-editor__toolbar",children:[t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:R.undo,title:"Undo (Ctrl+Z)","aria-label":"Undo",children:t.jsx(w.oa,{name:"reply",size:16})}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:R.redo,title:"Redo (Ctrl+Y)","aria-label":"Redo",children:t.jsx(w.oa,{name:"forward",size:16})}),t.jsx("span",{className:"nice-code-editor__toolbar-sep"}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:R.format,title:"Format (Shift+Alt+F)","aria-label":"Format",children:t.jsx(w.oa,{name:"type",size:16})}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:R.find,title:"Find & Replace (Ctrl+H)","aria-label":"Find & Replace",children:t.jsx(w.oa,{name:"search",size:16})}),t.jsx("span",{className:"nice-code-editor__toolbar-sep"}),t.jsx("button",{className:`nice-code-editor__toolbar-btn${J?" nice-code-editor__toolbar-btn--active":""}`,onClick:R.toggleWordWrap,title:"Toggle Word Wrap","aria-label":"Toggle Word Wrap",children:t.jsx(w.oa,{name:"align-left",size:16})}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:R.toggleMinimap,title:"Toggle Minimap","aria-label":"Toggle Minimap",children:t.jsx(w.oa,{name:"columns",size:16})}),t.jsx("span",{className:"nice-code-editor__toolbar-sep"}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:R.foldAll,title:"Fold All","aria-label":"Fold All",children:t.jsx(w.oa,{name:"collapse",size:16})}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:R.unfoldAll,title:"Unfold All","aria-label":"Unfold All",children:t.jsx(w.oa,{name:"expand",size:16})})]}),t.jsx("div",{ref:x,className:"nice-code-editor",style:{flex:1,minHeight:0}}),A&&t.jsxs("div",{className:"nice-code-editor__statusbar",children:[t.jsxs("span",{children:["Ln ",oe.lineNumber,", Col ",oe.column]}),re.length>0&&t.jsxs("span",{children:["(",re.length," selected)"]}),t.jsx("span",{className:"nice-code-editor__statusbar-spacer"}),t.jsxs("span",{children:[be," lines · ",ke," chars"]}),t.jsx("span",{className:"nice-code-editor__statusbar-lang",children:b}),C.length>0&&t.jsxs("span",{className:"nice-code-editor__statusbar-markers",children:[t.jsx(w.oa,{name:"warning",size:14})," ",C.length]})]})]})});function Se(m){const{original:a,modified:p,language:l="plaintext",theme:k="auto",height:b=400,width:_="100%",inline:o=!1,renderSideBySide:W=!0,originalEditable:P=!1,modifiedEditable:C=!1,onOriginalChange:O,onModifiedChange:T,loading:E,className:S,"data-testid":I}=m,N=i.useRef(null),M=i.useRef(null),j=i.useRef(null),[z,A]=i.useState(!0),[V,$]=i.useState(null);return i.useEffect(()=>{if(!N.current)return;let v=!0;return me().then(s=>{if(!v||!N.current)return;j.current=s;const u=s.editor.createModel(a,l),f=s.editor.createModel(p,l),x=s.editor.createDiffEditor(N.current,{automaticLayout:!0,theme:F(k),renderSideBySide:!o&&W,originalEditable:P,readOnly:!C});x.setModel({original:u,modified:f}),M.current=x,A(!1),P&&u.onDidChangeContent(()=>{O?.(u.getValue())}),C&&f.onDidChangeContent(()=>{T?.(f.getValue())})}).catch(s=>{v&&($(s.message??"Failed to load diff editor"),A(!1))}),()=>{v=!1,M.current?.dispose()}},[]),i.useEffect(()=>{const v=M.current;if(!v)return;const s=v.getModel();s&&(s.original.getValue()!==a&&s.original.setValue(a),s.modified.getValue()!==p&&s.modified.setValue(p))},[a,p]),i.useEffect(()=>{const v=j.current;if(!v||(v.editor.setTheme(F(k)),k!=="auto"||typeof document>"u"))return;const s=()=>{j.current?.editor.setTheme(F("auto"))},u=new MutationObserver(s);u.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const f=window.matchMedia?.("(prefers-color-scheme: dark)");return f?.addEventListener?.("change",s),()=>{u.disconnect(),f?.removeEventListener?.("change",s)}},[k,z]),V?t.jsx("div",{className:`nice-code-diff-editor nice-code-diff-editor--error ${S??""}`,style:{height:b,width:_},"data-testid":I,children:t.jsx("div",{className:"nice-code-editor__error",children:t.jsxs("span",{children:[t.jsx(w.oa,{name:"warning",size:16})," ",V]})})}):t.jsxs("div",{className:`nice-code-diff-editor ${S??""}`,style:{height:b,width:_,position:"relative"},"data-testid":I,children:[t.jsx("div",{ref:N,style:{position:"absolute",inset:0}}),z&&t.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--nice-bg-primary, #fff)",zIndex:2},children:E??t.jsx("div",{className:"nice-code-editor__loader",children:"Loading diff editor..."})})]})}const Ee="1.29.0",le=`https://cdn.jsdelivr.net/npm/prismjs@${Ee}`;let ee=null;const ne={javascript:"javascript",typescript:"typescript",json:"json",html:"markup",css:"css",scss:"scss",less:"less",markdown:"markdown",xml:"markup",yaml:"yaml",sql:"sql",python:"python",csharp:"csharp",java:"java",cpp:"cpp",c:"c",go:"go",rust:"rust",php:"php",ruby:"ruby",shell:"bash",powershell:"powershell",plaintext:"plain"};function Y(m){return new Promise((a,p)=>{if(document.querySelector(`script[data-prism-src="${m}"]`)){a();return}const l=document.createElement("script");l.src=m,l.async=!0,l.dataset.prismSrc=m,l.onload=()=>a(),l.onerror=()=>p(new Error(`Failed to load ${m}`)),document.head.appendChild(l)})}function Me(m){if(typeof window>"u")return Promise.resolve(null);const a=window,p=ne[m]??"plain",l=async()=>{if(p!=="plain"&&!a.Prism?.languages?.[p])try{await Y(`${le}/components/prism-${p}.min.js`)}catch{}};return a.Prism?.languages?l().then(()=>a.Prism):(ee||(ee=(async()=>(window.Prism={manual:!0},await Y(`${le}/prism.min.js`),window.Prism))()),ee.then(async()=>(await l(),window.Prism)))}function te(m){return m.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function Le(m){const{value:a,onChange:p,language:l="plaintext",height:k=300,width:b="100%",readOnly:_=!1,tabSize:o=2,lineNumbers:W=!0,placeholder:P,theme:C="auto",className:O,"data-testid":T}=m,E=i.useRef(null),S=i.useRef(null),[I,N]=i.useState(()=>te(a)),[M,j]=i.useState("light");i.useEffect(()=>{const s=()=>{if(C!=="auto")return C;if(typeof document>"u")return"light";const c=document.documentElement.dataset.theme;return c==="dark"?"dark":c==="light"?"light":window.matchMedia?.("(prefers-color-scheme: dark)").matches?"dark":"light"};if(j(s()),C!=="auto"||typeof document>"u")return;const u=()=>j(s()),f=new MutationObserver(u);f.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const x=window.matchMedia?.("(prefers-color-scheme: dark)");return x?.addEventListener?.("change",u),()=>{f.disconnect(),x?.removeEventListener?.("change",u)}},[C]),i.useEffect(()=>{let s=!0;return Me(l).then(u=>{if(!s)return;const f=ne[l]??"plain";if(u?.languages?.[f])try{const x=u.highlight(a,u.languages[f],f);N(x);return}catch{}N(te(a))}).catch(()=>{s&&N(te(a))}),()=>{s=!1}},[a,l]);const z=i.useCallback(()=>{!S.current||!E.current||(S.current.scrollTop=E.current.scrollTop,S.current.scrollLeft=E.current.scrollLeft)},[]),A=i.useCallback(s=>{if(s.key==="Tab"){s.preventDefault();const u=s.currentTarget,f=u.selectionStart,x=u.selectionEnd,c=" ".repeat(o);if(s.shiftKey){const L=a.substring(0,f).lastIndexOf(`
|
|
3
|
+
`)+1;if((a.substring(L,f).match(/^(\s*)/)?.[1]??"").length>=o){const B=a.substring(0,L)+a.substring(L+o);p?.(B),setTimeout(()=>{u.selectionStart=u.selectionEnd=f-o},0)}}else{const y=a.substring(0,f)+c+a.substring(x);p?.(y),setTimeout(()=>{u.selectionStart=u.selectionEnd=f+o},0)}}},[a,p,o]),$=a.split(`
|
|
4
|
+
`).length,v=ne[l]??"plain";return t.jsxs("div",{className:`nice-simple-code-editor nice-simple-code-editor--${M} ${O??""}`,style:{height:k,width:b},"data-testid":T,"data-language":l,"data-theme":M,children:[W&&t.jsx("div",{className:"nice-simple-code-editor__line-numbers",children:Array.from({length:$},(s,u)=>t.jsx("div",{className:"nice-simple-code-editor__line-number",children:u+1},u))}),t.jsxs("div",{className:"nice-simple-code-editor__editor-area",children:[t.jsx("pre",{ref:S,"aria-hidden":"true",className:`nice-simple-code-editor__highlight language-${v}`,children:t.jsx("code",{className:`language-${v}`,dangerouslySetInnerHTML:{__html:I+(a.endsWith(`
|
|
5
|
+
`)?`
|
|
6
|
+
`:"")}})}),t.jsx("textarea",{ref:E,className:"nice-simple-code-editor__textarea",value:a,onChange:s=>p?.(s.target.value),onKeyDown:A,onScroll:z,readOnly:_,placeholder:P,spellCheck:!1,autoCapitalize:"off",autoCorrect:"off"})]})]})}const ue="nice-code-editor-styles";if(typeof document<"u"&&!document.getElementById(ue)){const m=document.createElement("style");m.id=ue,m.textContent=`
|
|
7
|
+
.nice-code-editor,
|
|
8
|
+
.nice-code-diff-editor {
|
|
9
|
+
border: 1px solid var(--nice-border, #e0e0e0);
|
|
10
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
11
|
+
overflow: hidden;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.nice-code-editor--loading,
|
|
15
|
+
.nice-code-editor--error,
|
|
16
|
+
.nice-code-diff-editor--loading {
|
|
17
|
+
display: flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
justify-content: center;
|
|
20
|
+
background: var(--nice-bg-muted, #f5f5f5);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.nice-code-editor__loader {
|
|
24
|
+
color: var(--nice-text-secondary, #666);
|
|
25
|
+
font-size: 14px;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.nice-code-editor__error {
|
|
29
|
+
display: flex;
|
|
30
|
+
flex-direction: column;
|
|
31
|
+
width: 100%;
|
|
32
|
+
height: 100%;
|
|
33
|
+
padding: var(--nice-space-2, 8px);
|
|
34
|
+
gap: var(--nice-space-2, 8px);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.nice-code-editor__error span {
|
|
38
|
+
color: var(--nice-error, #d32f2f);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/* Simple code editor */
|
|
42
|
+
.nice-simple-code-editor {
|
|
43
|
+
display: flex;
|
|
44
|
+
border: 1px solid var(--nice-border-color, var(--nice-border, #e0e0e0));
|
|
45
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
46
|
+
overflow: hidden;
|
|
47
|
+
font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
|
|
48
|
+
font-size: 14px;
|
|
49
|
+
line-height: 1.5;
|
|
50
|
+
background: var(--nice-bg-primary, var(--nice-bg-surface, #fff));
|
|
51
|
+
color: var(--nice-text-primary, var(--nice-text-primary, #333));
|
|
52
|
+
}
|
|
53
|
+
.nice-simple-code-editor--dark {
|
|
54
|
+
background: var(--nice-bg, #1e1e1e);
|
|
55
|
+
color: var(--nice-text, #d4d4d4);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.nice-simple-code-editor__line-numbers {
|
|
59
|
+
padding: var(--nice-space-2, 8px) 0;
|
|
60
|
+
background: var(--nice-bg-secondary, var(--nice-bg-muted, #f5f5f5));
|
|
61
|
+
border-right: 1px solid var(--nice-border-color, var(--nice-border, #e0e0e0));
|
|
62
|
+
user-select: none;
|
|
63
|
+
text-align: right;
|
|
64
|
+
color: var(--nice-text-secondary, var(--nice-text-secondary, #999));
|
|
65
|
+
overflow: hidden;
|
|
66
|
+
}
|
|
67
|
+
.nice-simple-code-editor--dark .nice-simple-code-editor__line-numbers {
|
|
68
|
+
background: var(--nice-bg-secondary, #252526);
|
|
69
|
+
border-right-color: var(--nice-border, #3c3c3c);
|
|
70
|
+
color: var(--nice-text-muted, #858585);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.nice-simple-code-editor__line-number {
|
|
74
|
+
padding: 0 var(--nice-space-3, 12px);
|
|
75
|
+
min-width: 40px;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.nice-simple-code-editor__editor-area {
|
|
79
|
+
position: relative;
|
|
80
|
+
flex: 1;
|
|
81
|
+
overflow: hidden;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.nice-simple-code-editor__highlight,
|
|
85
|
+
.nice-simple-code-editor__textarea {
|
|
86
|
+
position: absolute;
|
|
87
|
+
inset: 0;
|
|
88
|
+
margin: 0;
|
|
89
|
+
padding: var(--nice-space-2, 8px) var(--nice-space-3, 12px);
|
|
90
|
+
border: 0;
|
|
91
|
+
font: inherit;
|
|
92
|
+
line-height: inherit;
|
|
93
|
+
white-space: pre;
|
|
94
|
+
overflow: auto;
|
|
95
|
+
tab-size: 2;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.nice-simple-code-editor__highlight {
|
|
99
|
+
pointer-events: none;
|
|
100
|
+
background: transparent;
|
|
101
|
+
color: inherit;
|
|
102
|
+
}
|
|
103
|
+
.nice-simple-code-editor__highlight code {
|
|
104
|
+
font: inherit;
|
|
105
|
+
background: transparent;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.nice-simple-code-editor__textarea {
|
|
109
|
+
background: transparent;
|
|
110
|
+
color: transparent;
|
|
111
|
+
caret-color: var(--nice-text-primary, var(--nice-text-primary, #333));
|
|
112
|
+
resize: none;
|
|
113
|
+
outline: none;
|
|
114
|
+
-webkit-text-fill-color: transparent;
|
|
115
|
+
}
|
|
116
|
+
.nice-simple-code-editor--dark .nice-simple-code-editor__textarea {
|
|
117
|
+
caret-color: var(--nice-text, #d4d4d4);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.nice-simple-code-editor__textarea::placeholder {
|
|
121
|
+
color: var(--nice-text-secondary, var(--nice-text-secondary, #999));
|
|
122
|
+
-webkit-text-fill-color: var(--nice-text-secondary, var(--nice-text-secondary, #999));
|
|
123
|
+
}
|
|
124
|
+
.nice-simple-code-editor--dark .nice-simple-code-editor__textarea::placeholder {
|
|
125
|
+
color: var(--nice-text-muted, #858585);
|
|
126
|
+
-webkit-text-fill-color: var(--nice-text-muted, #858585);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/* Prism token colors — light */
|
|
130
|
+
.nice-simple-code-editor .token.comment,
|
|
131
|
+
.nice-simple-code-editor .token.prolog,
|
|
132
|
+
.nice-simple-code-editor .token.doctype,
|
|
133
|
+
.nice-simple-code-editor .token.cdata { color: #6a737d; font-style: italic; }
|
|
134
|
+
.nice-simple-code-editor .token.punctuation { color: #586069; }
|
|
135
|
+
.nice-simple-code-editor .token.property,
|
|
136
|
+
.nice-simple-code-editor .token.tag,
|
|
137
|
+
.nice-simple-code-editor .token.boolean,
|
|
138
|
+
.nice-simple-code-editor .token.number,
|
|
139
|
+
.nice-simple-code-editor .token.constant,
|
|
140
|
+
.nice-simple-code-editor .token.symbol,
|
|
141
|
+
.nice-simple-code-editor .token.deleted { color: #005cc5; }
|
|
142
|
+
.nice-simple-code-editor .token.selector,
|
|
143
|
+
.nice-simple-code-editor .token.attr-name,
|
|
144
|
+
.nice-simple-code-editor .token.string,
|
|
145
|
+
.nice-simple-code-editor .token.char,
|
|
146
|
+
.nice-simple-code-editor .token.builtin,
|
|
147
|
+
.nice-simple-code-editor .token.inserted { color: #032f62; }
|
|
148
|
+
.nice-simple-code-editor .token.operator,
|
|
149
|
+
.nice-simple-code-editor .token.entity,
|
|
150
|
+
.nice-simple-code-editor .token.url,
|
|
151
|
+
.nice-simple-code-editor .token.variable { color: var(--nice-danger, #d73a49); }
|
|
152
|
+
.nice-simple-code-editor .token.atrule,
|
|
153
|
+
.nice-simple-code-editor .token.attr-value,
|
|
154
|
+
.nice-simple-code-editor .token.keyword { color: var(--nice-danger, #d73a49); font-weight: 600; }
|
|
155
|
+
.nice-simple-code-editor .token.function,
|
|
156
|
+
.nice-simple-code-editor .token.class-name { color: #6f42c1; }
|
|
157
|
+
.nice-simple-code-editor .token.regex,
|
|
158
|
+
.nice-simple-code-editor .token.important { color: #e36209; }
|
|
159
|
+
|
|
160
|
+
/* Prism token colors — dark */
|
|
161
|
+
.nice-simple-code-editor--dark .token.comment,
|
|
162
|
+
.nice-simple-code-editor--dark .token.prolog,
|
|
163
|
+
.nice-simple-code-editor--dark .token.doctype,
|
|
164
|
+
.nice-simple-code-editor--dark .token.cdata { color: var(--nice-success, #6a9955); font-style: italic; }
|
|
165
|
+
.nice-simple-code-editor--dark .token.punctuation { color: var(--nice-text, #d4d4d4); }
|
|
166
|
+
.nice-simple-code-editor--dark .token.property,
|
|
167
|
+
.nice-simple-code-editor--dark .token.tag,
|
|
168
|
+
.nice-simple-code-editor--dark .token.boolean,
|
|
169
|
+
.nice-simple-code-editor--dark .token.number,
|
|
170
|
+
.nice-simple-code-editor--dark .token.constant,
|
|
171
|
+
.nice-simple-code-editor--dark .token.symbol,
|
|
172
|
+
.nice-simple-code-editor--dark .token.deleted { color: var(--nice-success-light, #b5cea8); }
|
|
173
|
+
.nice-simple-code-editor--dark .token.selector,
|
|
174
|
+
.nice-simple-code-editor--dark .token.attr-name,
|
|
175
|
+
.nice-simple-code-editor--dark .token.string,
|
|
176
|
+
.nice-simple-code-editor--dark .token.char,
|
|
177
|
+
.nice-simple-code-editor--dark .token.builtin,
|
|
178
|
+
.nice-simple-code-editor--dark .token.inserted { color: var(--nice-warning, #ce9178); }
|
|
179
|
+
.nice-simple-code-editor--dark .token.operator,
|
|
180
|
+
.nice-simple-code-editor--dark .token.entity,
|
|
181
|
+
.nice-simple-code-editor--dark .token.url,
|
|
182
|
+
.nice-simple-code-editor--dark .token.variable { color: var(--nice-primary, #569cd6); }
|
|
183
|
+
.nice-simple-code-editor--dark .token.atrule,
|
|
184
|
+
.nice-simple-code-editor--dark .token.attr-value,
|
|
185
|
+
.nice-simple-code-editor--dark .token.keyword { color: #c586c0; font-weight: 600; }
|
|
186
|
+
.nice-simple-code-editor--dark .token.function,
|
|
187
|
+
.nice-simple-code-editor--dark .token.class-name { color: #dcdcaa; }
|
|
188
|
+
.nice-simple-code-editor--dark .token.regex,
|
|
189
|
+
.nice-simple-code-editor--dark .token.important { color: #d7ba7d; }
|
|
190
|
+
|
|
191
|
+
/* Toolbar */
|
|
192
|
+
.nice-code-editor-wrap {
|
|
193
|
+
border: 1px solid var(--nice-border, #e0e0e0);
|
|
194
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
195
|
+
overflow: hidden;
|
|
196
|
+
}
|
|
197
|
+
.nice-code-editor-wrap .nice-code-editor {
|
|
198
|
+
border: none;
|
|
199
|
+
border-radius: 0;
|
|
200
|
+
}
|
|
201
|
+
.nice-code-editor__toolbar {
|
|
202
|
+
display: flex;
|
|
203
|
+
align-items: center;
|
|
204
|
+
gap: var(--nice-space-0-5, 2px);
|
|
205
|
+
padding: var(--nice-space-0-75, 3px) var(--nice-space-1-5, 6px);
|
|
206
|
+
background: var(--nice-bg-muted, #f5f5f5);
|
|
207
|
+
border-bottom: 1px solid var(--nice-border, #e0e0e0);
|
|
208
|
+
}
|
|
209
|
+
.nice-code-editor__toolbar-btn {
|
|
210
|
+
display: inline-flex;
|
|
211
|
+
align-items: center;
|
|
212
|
+
justify-content: center;
|
|
213
|
+
width: 26px;
|
|
214
|
+
height: 26px;
|
|
215
|
+
border: none;
|
|
216
|
+
border-radius: var(--nice-radius-sm, 3px);
|
|
217
|
+
background: transparent;
|
|
218
|
+
color: var(--nice-text-secondary, #666);
|
|
219
|
+
cursor: pointer;
|
|
220
|
+
font-size: 14px;
|
|
221
|
+
transition: background 0.15s, color 0.15s;
|
|
222
|
+
}
|
|
223
|
+
.nice-code-editor__toolbar-btn:hover {
|
|
224
|
+
background: var(--nice-hover, #e0e0e0);
|
|
225
|
+
color: var(--nice-text-primary, #333);
|
|
226
|
+
}
|
|
227
|
+
.nice-code-editor__toolbar-btn--active {
|
|
228
|
+
background: var(--nice-accent, #1976d2);
|
|
229
|
+
color: var(--nice-bg, #FFF);
|
|
230
|
+
}
|
|
231
|
+
.nice-code-editor__toolbar-sep {
|
|
232
|
+
width: 1px;
|
|
233
|
+
height: 18px;
|
|
234
|
+
background: var(--nice-border, #e0e0e0);
|
|
235
|
+
margin: 0 var(--nice-space-1, 4px);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/* Status bar */
|
|
239
|
+
.nice-code-editor__statusbar {
|
|
240
|
+
display: flex;
|
|
241
|
+
align-items: center;
|
|
242
|
+
gap: var(--nice-space-3, 12px);
|
|
243
|
+
padding: var(--nice-space-0-5, 2px) var(--nice-space-2-5, 10px);
|
|
244
|
+
background: var(--nice-bg-muted, #f5f5f5);
|
|
245
|
+
border-top: 1px solid var(--nice-border, #e0e0e0);
|
|
246
|
+
font-size: 12px;
|
|
247
|
+
color: var(--nice-text-secondary, #666);
|
|
248
|
+
user-select: none;
|
|
249
|
+
}
|
|
250
|
+
.nice-code-editor__statusbar-spacer { flex: 1; }
|
|
251
|
+
.nice-code-editor__statusbar-lang {
|
|
252
|
+
text-transform: uppercase;
|
|
253
|
+
font-weight: 600;
|
|
254
|
+
font-size: 11px;
|
|
255
|
+
}
|
|
256
|
+
.nice-code-editor__statusbar-markers {
|
|
257
|
+
color: var(--nice-warning, #f39c12);
|
|
258
|
+
font-weight: 600;
|
|
259
|
+
}
|
|
260
|
+
`,document.head.appendChild(m)}exports.NiceCodeDiffEditor=Se;exports.NiceCodeEditor=je;exports.NiceSimpleCodeEditor=Le;
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),C=require("./charts-NolNXKUL.cjs"),r=require("react"),Re=[{target:".nice-code-editor-wrap",titleKey:"tutorial.codeEditor.intro.title",title:"Code editor",contentKey:"tutorial.codeEditor.intro.content",content:"Edit code with syntax highlighting, IntelliSense and the toolbar. Ctrl+S saves; the status bar shows the cursor position and any problems.",placement:"auto"}];let Q=null,J=null;const Oe="0.45.0",te=`https://cdn.jsdelivr.net/npm/monaco-editor@${Oe}/min/vs`,ge=15e3;function he(){const d=window;if(d.MonacoEnvironment?.getWorkerUrl)return;const u=`self.MonacoEnvironment={baseUrl:'${te}/'};importScripts('${te}/base/worker/workerMain.js');`,m=URL.createObjectURL(new Blob([u],{type:"text/javascript"}));d.MonacoEnvironment={getWorkerUrl:()=>m}}function Y(d){if(d!=="auto")return d;if(typeof document>"u")return"vs";const u=document.documentElement.dataset.theme;return u==="dark"?"vs-dark":u==="light"?"vs":window.matchMedia?.("(prefers-color-scheme: dark)").matches?"vs-dark":"vs"}function ve(){return J?Promise.resolve(J):Q||(Q=new Promise((d,u)=>{if(window.monaco){he(),J=window.monaco,d(J);return}let m=!1;const v=window.setTimeout(()=>{m||(m=!0,Q=null,u(new Error(`Monaco editor failed to load within ${ge}ms`)))},ge),w=document.createElement("script");w.src=`${te}/loader.min.js`,w.async=!0,w.onload=()=>{const R=window.require;R.config({paths:{vs:te}}),he(),R(["vs/editor/editor.main"],f=>{m||(m=!0,window.clearTimeout(v),J=f,d(f))})},w.onerror=()=>{m||(m=!0,window.clearTimeout(v),Q=null,u(new Error("Failed to load Monaco Editor loader script")))},document.head.appendChild(w)}),Q)}const Te=r.forwardRef(function(u,m){const{value:v,defaultValue:w,onChange:R,language:f="plaintext",theme:O="auto",options:o={},height:G=400,width:Z="100%",markers:_=[],decorations:V=[],completionProvider:F,onMount:g,onCursorPositionChange:z,onSelectionChange:T,onSave:P,loading:I,disabled:E=!1,showToolbar:W=!1,showStatusBar:M=!1,editorSize:U="standard",className:B,"data-testid":$,lsp:N,extraLibs:j,tutorial:p}=u,[s,h,S]=C.Vu({value:v,defaultValue:w,fallbackValue:"",onChange:R,componentName:"NiceCodeEditor"}),L=r.useRef(h);L.current=h;const q=r.useRef(s);q.current=s;const x=r.useRef(!1),b=r.useRef(null),a=r.useRef(null),y=r.useRef(null),H=r.useRef([]),A=r.useRef(null),[K,de]=r.useState(!0),[re,xe]=r.useState(null),[le,ye]=r.useState({lineNumber:1,column:1}),[ue,Ce]=r.useState(""),[oe,we]=r.useState(o.wordWrap==="on"),ie=r.useMemo(()=>({automaticLayout:!0,readOnly:E||o.readOnly,minimap:{enabled:o.minimap??!0},lineNumbers:o.lineNumbers??"on",wordWrap:o.wordWrap??"off",tabSize:o.tabSize??2,insertSpaces:o.insertSpaces??!0,fontSize:o.fontSize??14,fontFamily:o.fontFamily??"'Fira Code', 'Consolas', 'Monaco', monospace",fontLigatures:o.fontLigatures??!0,cursorStyle:o.cursorStyle??"line",cursorBlinking:o.cursorBlinking??"blink",autoClosingBrackets:o.autoClosingBrackets??"languageDefined",autoClosingQuotes:o.autoClosingQuotes??"languageDefined",formatOnPaste:o.formatOnPaste??!1,formatOnType:o.formatOnType??!1,renderWhitespace:o.renderWhitespace??"selection",renderControlCharacters:o.renderControlCharacters??!1,scrollBeyondLastLine:o.scrollBeyondLastLine??!0,smoothScrolling:o.smoothScrolling??!0,folding:o.folding??!0,showFoldingControls:o.showFoldingControls??"mouseover","bracketPairColorization.enabled":o.bracketPairColorization??!0,guides:o.guides??{bracketPairs:!0,indentation:!0,highlightActiveIndentation:!0},stickyScroll:{enabled:o.stickyScroll??!1},quickSuggestions:o.quickSuggestions??!0,suggestOnTriggerCharacters:o.suggestOnTriggerCharacters??!0,acceptSuggestionOnEnter:o.acceptSuggestionOnEnter??"on",inlayHints:{enabled:o.inlayHints?"on":"off"}}),[o,E]);r.useEffect(()=>{if(!b.current)return;let e=!0;return ve().then(async i=>{if(!e||!b.current)return;y.current=i;const n=i.editor.create(b.current,{value:q.current,language:f,theme:Y(O),...ie});if(a.current=n,de(!1),n.onDidChangeModelContent(()=>{x.current||L.current(n.getValue())}),n.onDidChangeCursorPosition(c=>{ye({lineNumber:c.position.lineNumber,column:c.position.column}),z?.({lineNumber:c.position.lineNumber,column:c.position.column})}),n.onDidChangeCursorSelection(c=>{const k=c.selection,l=n.getModel()?.getValueInRange(k)??"";Ce(l),T?.({startLineNumber:k.startLineNumber,startColumn:k.startColumn,endLineNumber:k.endLineNumber,endColumn:k.endColumn})}),n.addCommand(i.KeyMod.CtrlCmd|i.KeyCode.KeyS,()=>{P?.(n.getValue())}),N&&typeof window<"u")try{await ne("https://cdn.jsdelivr.net/npm/vscode-ws-jsonrpc@1.0.2/lib/browser/index.min.js"),await ne("https://cdn.jsdelivr.net/npm/monaco-languageclient@0.15.0/lib/monaco-languageclient.min.js");const c=window,k=c.ReconnectingWebSocket,{MonacoLanguageClient:l,CloseAction:X,ErrorAction:ee,createConnection:me}=c.monacoLanguageClient||{};if(l&&me){const je=N.url,Se=N.language,pe=new k(je),Ee=new c.VSCodeWebSocketMessageReader(pe),Me=new c.VSCodeWebSocketMessageWriter(pe),Le=me(Ee,Me),fe=new l({name:"LSP Client",clientOptions:{documentSelector:[Se],initializationOptions:N.initOptions,errorHandler:{error:()=>ee.Continue,closed:()=>X.Restart}},connectionProvider:{get:()=>Promise.resolve(Le)}});fe.start(),a.current.__lspClient=fe}}catch(c){console.warn("LSP bridge failed to load:",c)}g?.(n,i)}).catch(i=>{e&&(xe(i.message??"Failed to load editor"),de(!1))}),()=>{if(e=!1,a.current?.dispose(),A.current?.dispose(),a.current&&a.current.__lspClient)try{a.current.__lspClient.stop()}catch{}}},[N]),r.useEffect(()=>{const e=a.current;if(!S||!e||s===e.getValue())return;const i=e.getPosition();x.current=!0;try{e.setValue(s)}finally{x.current=!1}i&&e.setPosition(i)},[s,S]),r.useEffect(()=>{const e=a.current,i=y.current;if(e&&i){const n=e.getModel();n&&i.editor.setModelLanguage(n,f)}},[f]),r.useEffect(()=>{const e=y.current;if(!e||K||!j||j.length===0||f!=="javascript"&&f!=="typescript")return;const i=e.languages?.typescript;if(!i)return;const n=[];try{j.forEach((c,k)=>{const l=c.filePath??`inmemory://model/nice-extralib-${k}.d.ts`,X=i.typescriptDefaults?.addExtraLib(c.content,l);X&&n.push(X);const ee=i.javascriptDefaults?.addExtraLib(c.content,l);ee&&n.push(ee)})}catch(c){console.warn("Failed to register extraLibs:",c)}return()=>{n.forEach(c=>{try{c.dispose()}catch{}})}},[j,f,K]),r.useEffect(()=>{const e=y.current;if(!e||(e.editor.setTheme(Y(O)),O!=="auto"||typeof document>"u"))return;const i=()=>{y.current?.editor.setTheme(Y("auto"))},n=new MutationObserver(i);n.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const c=window.matchMedia?.("(prefers-color-scheme: dark)");return c?.addEventListener?.("change",i),()=>{n.disconnect(),c?.removeEventListener?.("change",i)}},[O]),r.useEffect(()=>{const e=a.current;e&&e.updateOptions(ie)},[ie]),r.useEffect(()=>{const e=a.current,i=y.current;if(e&&i){const n=e.getModel();if(n){const c=_.map(k=>({startLineNumber:k.startLineNumber,startColumn:k.startColumn,endLineNumber:k.endLineNumber,endColumn:k.endColumn,message:k.message,severity:k.severity}));i.editor.setModelMarkers(n,"owner",c)}}},[_]),r.useEffect(()=>{const e=a.current;if(e&&V.length>0){const i=V.map(n=>({range:{startLineNumber:n.range.startLineNumber,startColumn:n.range.startColumn,endLineNumber:n.range.endLineNumber,endColumn:n.range.endColumn},options:{className:n.className,glyphMarginClassName:n.glyphMarginClassName,hoverMessage:n.hoverMessage?{value:n.hoverMessage}:void 0,isWholeLine:n.isWholeLine}}));H.current=e.deltaDecorations(H.current,i)}},[V]),r.useEffect(()=>{const e=y.current;if(!e||!F)return;A.current?.dispose();const i={text:0,method:1,function:2,constructor:3,field:4,variable:5,class:6,interface:7,module:8,property:9,keyword:13,snippet:14,color:15,file:16,reference:17,folder:18};return A.current=e.languages.registerCompletionItemProvider(f,{provideCompletionItems:async(n,c)=>({suggestions:(await F(n,c)).map(l=>({label:l.label,kind:i[l.kind]??0,insertText:l.insertText,insertTextRules:l.insertTextRules==="insertAsSnippet"?4:void 0,documentation:l.documentation,detail:l.detail,range:{startLineNumber:c.lineNumber,startColumn:c.column,endLineNumber:c.lineNumber,endColumn:c.column}}))})}),()=>{A.current?.dispose()}},[f,F]),r.useImperativeHandle(m,()=>({getEditor:()=>a.current,getMonaco:()=>y.current,focus:()=>a.current?.focus(),getValue:()=>a.current?.getValue()??"",setValue:e=>a.current?.setValue(e),getSelection:()=>{const e=a.current;if(!e)return"";const i=e.getSelection();return i?e.getModel()?.getValueInRange(i)??"":""},insertText:e=>{const i=a.current;if(!i)return;const n=i.getSelection();n&&i.executeEdits("",[{range:n,text:e}])},formatDocument:()=>{a.current?.getAction("editor.action.formatDocument")?.run()},goToLine:(e,i=1)=>{const n=a.current;n&&(n.setPosition({lineNumber:e,column:i}),n.revealLineInCenter(e),n.focus())},findReplace:()=>{a.current?.getAction("editor.action.startFindReplaceAction")?.run()},undo:()=>{a.current?.trigger("keyboard","undo",null)},redo:()=>{a.current?.trigger("keyboard","redo",null)},getCursorPosition:()=>{const e=a.current?.getPosition();return{lineNumber:e?.lineNumber??1,column:e?.column??1}},setMarkers:e=>{const i=a.current,n=y.current;if(i&&n){const c=i.getModel();if(c){const k=e.map(l=>({startLineNumber:l.startLineNumber,startColumn:l.startColumn,endLineNumber:l.endLineNumber,endColumn:l.endColumn,message:l.message,severity:l.severity}));n.editor.setModelMarkers(c,"owner",k)}}}}),[]);const D=r.useMemo(()=>({format:()=>a.current?.getAction("editor.action.formatDocument")?.run(),undo:()=>a.current?.trigger("keyboard","undo",null),redo:()=>a.current?.trigger("keyboard","redo",null),find:()=>a.current?.getAction("editor.action.startFindReplaceAction")?.run(),toggleWordWrap:()=>{const e=!oe;we(e),a.current?.updateOptions({wordWrap:e?"on":"off"})},toggleMinimap:()=>{const e=a.current?.getOption?.(y.current?.editor?.EditorOption?.minimap);a.current?.updateOptions({minimap:{enabled:!e?.enabled}})},foldAll:()=>a.current?.getAction("editor.foldAll")?.run(),unfoldAll:()=>a.current?.getAction("editor.unfoldAll")?.run()}),[oe]),_e=s.split(`
|
|
2
|
+
`).length,Ne=s.length;return t.jsxs("div",{className:`nice-code-editor-wrap nice-editor--${U} ${B??""}`,style:{height:G,width:Z,display:"flex",flexDirection:"column",position:"relative"},"data-testid":$,children:[t.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:t.jsx(C.Ql,{steps:C.Yl(p,Re)})}),re&&t.jsxs("div",{className:"nice-code-editor__error",style:{position:"absolute",inset:0,zIndex:2,background:"var(--nice-bg-primary, #fff)"},children:[t.jsxs("span",{children:[t.jsx(C.oa,{name:"warning",size:16})," ",re]}),t.jsx("textarea",{value:s,onChange:e=>h(e.target.value),readOnly:E||o.readOnly,style:{width:"100%",height:"100%",fontFamily:"monospace"}})]}),K&&!re&&t.jsx("div",{className:"nice-code-editor__loader-overlay",style:{position:"absolute",inset:0,zIndex:2,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--nice-bg-primary, #fff)"},children:I??t.jsx("div",{className:"nice-code-editor__loader",children:"Loading editor..."})}),W&&t.jsxs("div",{className:"nice-code-editor__toolbar",children:[t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:D.undo,title:"Undo (Ctrl+Z)","aria-label":"Undo",children:t.jsx(C.oa,{name:"reply",size:16})}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:D.redo,title:"Redo (Ctrl+Y)","aria-label":"Redo",children:t.jsx(C.oa,{name:"forward",size:16})}),t.jsx("span",{className:"nice-code-editor__toolbar-sep"}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:D.format,title:"Format (Shift+Alt+F)","aria-label":"Format",children:t.jsx(C.oa,{name:"type",size:16})}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:D.find,title:"Find & Replace (Ctrl+H)","aria-label":"Find & Replace",children:t.jsx(C.oa,{name:"search",size:16})}),t.jsx("span",{className:"nice-code-editor__toolbar-sep"}),t.jsx("button",{className:`nice-code-editor__toolbar-btn${oe?" nice-code-editor__toolbar-btn--active":""}`,onClick:D.toggleWordWrap,title:"Toggle Word Wrap","aria-label":"Toggle Word Wrap",children:t.jsx(C.oa,{name:"align-left",size:16})}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:D.toggleMinimap,title:"Toggle Minimap","aria-label":"Toggle Minimap",children:t.jsx(C.oa,{name:"columns",size:16})}),t.jsx("span",{className:"nice-code-editor__toolbar-sep"}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:D.foldAll,title:"Fold All","aria-label":"Fold All",children:t.jsx(C.oa,{name:"collapse",size:16})}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:D.unfoldAll,title:"Unfold All","aria-label":"Unfold All",children:t.jsx(C.oa,{name:"expand",size:16})})]}),t.jsx("div",{ref:b,className:"nice-code-editor",style:{flex:1,minHeight:0}}),M&&t.jsxs("div",{className:"nice-code-editor__statusbar",children:[t.jsxs("span",{children:["Ln ",le.lineNumber,", Col ",le.column]}),ue.length>0&&t.jsxs("span",{children:["(",ue.length," selected)"]}),t.jsx("span",{className:"nice-code-editor__statusbar-spacer"}),t.jsxs("span",{children:[_e," lines · ",Ne," chars"]}),t.jsx("span",{className:"nice-code-editor__statusbar-lang",children:f}),_.length>0&&t.jsxs("span",{className:"nice-code-editor__statusbar-markers",children:[t.jsx(C.oa,{name:"warning",size:14})," ",_.length]})]})]})});function Pe(d){const{original:u,defaultOriginal:m,modified:v,defaultModified:w,language:R="plaintext",theme:f="auto",height:O=400,width:o="100%",inline:G=!1,renderSideBySide:Z=!0,originalEditable:_=!1,modifiedEditable:V=!1,onOriginalChange:F,onModifiedChange:g,loading:z,className:T,"data-testid":P}=d,[I,E,W]=C.Vu({value:u,defaultValue:m,fallbackValue:"",onChange:F,componentName:"NiceCodeDiffEditor.original"}),[M,U,B]=C.Vu({value:v,defaultValue:w,fallbackValue:"",onChange:g,componentName:"NiceCodeDiffEditor.modified"}),$=r.useRef({currentOriginal:I,currentModified:M,setOriginal:E,setModified:U});$.current={currentOriginal:I,currentModified:M,setOriginal:E,setModified:U};const N=r.useRef(!1),j=r.useRef(null),p=r.useRef(null),s=r.useRef(null),[h,S]=r.useState(!0),[L,q]=r.useState(null);return r.useEffect(()=>{if(!j.current)return;let x=!0;return ve().then(b=>{if(!x||!j.current)return;s.current=b;const{currentOriginal:a,currentModified:y}=$.current,H=b.editor.createModel(a,R),A=b.editor.createModel(y,R),K=b.editor.createDiffEditor(j.current,{automaticLayout:!0,theme:Y(f),renderSideBySide:!G&&Z,originalEditable:_,readOnly:!V});K.setModel({original:H,modified:A}),p.current=K,S(!1),_&&H.onDidChangeContent(()=>{N.current||$.current.setOriginal(H.getValue())}),V&&A.onDidChangeContent(()=>{N.current||$.current.setModified(A.getValue())})}).catch(b=>{x&&(q(b.message??"Failed to load diff editor"),S(!1))}),()=>{x=!1,p.current?.dispose()}},[]),r.useEffect(()=>{const x=p.current?.getModel();if(x){N.current=!0;try{W&&x.original.getValue()!==I&&x.original.setValue(I),B&&x.modified.getValue()!==M&&x.modified.setValue(M)}finally{N.current=!1}}},[I,M,W,B]),r.useEffect(()=>{const x=s.current;if(!x||(x.editor.setTheme(Y(f)),f!=="auto"||typeof document>"u"))return;const b=()=>{s.current?.editor.setTheme(Y("auto"))},a=new MutationObserver(b);a.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const y=window.matchMedia?.("(prefers-color-scheme: dark)");return y?.addEventListener?.("change",b),()=>{a.disconnect(),y?.removeEventListener?.("change",b)}},[f,h]),L?t.jsx("div",{className:`nice-code-diff-editor nice-code-diff-editor--error ${T??""}`,style:{height:O,width:o},"data-testid":P,children:t.jsx("div",{className:"nice-code-editor__error",children:t.jsxs("span",{children:[t.jsx(C.oa,{name:"warning",size:16})," ",L]})})}):t.jsxs("div",{className:`nice-code-diff-editor ${T??""}`,style:{height:O,width:o,position:"relative"},"data-testid":P,children:[t.jsx("div",{ref:j,style:{position:"absolute",inset:0}}),h&&t.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--nice-bg-primary, #fff)",zIndex:2},children:z??t.jsx("div",{className:"nice-code-editor__loader",children:"Loading diff editor..."})})]})}const Ie="1.29.0",be=`https://cdn.jsdelivr.net/npm/prismjs@${Ie}`;let ae=null;const se={javascript:"javascript",typescript:"typescript",json:"json",html:"markup",css:"css",scss:"scss",less:"less",markdown:"markdown",xml:"markup",yaml:"yaml",sql:"sql",python:"python",csharp:"csharp",java:"java",cpp:"cpp",c:"c",go:"go",rust:"rust",php:"php",ruby:"ruby",shell:"bash",powershell:"powershell",plaintext:"plain"};function ne(d){return new Promise((u,m)=>{if(document.querySelector(`script[data-prism-src="${d}"]`)){u();return}const v=document.createElement("script");v.src=d,v.async=!0,v.dataset.prismSrc=d,v.onload=()=>u(),v.onerror=()=>m(new Error(`Failed to load ${d}`)),document.head.appendChild(v)})}function Ve(d){if(typeof window>"u")return Promise.resolve(null);const u=window,m=se[d]??"plain",v=async()=>{if(m!=="plain"&&!u.Prism?.languages?.[m])try{await ne(`${be}/components/prism-${m}.min.js`)}catch{}};return u.Prism?.languages?v().then(()=>u.Prism):(ae||(ae=(async()=>(window.Prism={manual:!0},await ne(`${be}/prism.min.js`),window.Prism))()),ae.then(async()=>(await v(),window.Prism)))}function ce(d){return d.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function ze(d){const{value:u,defaultValue:m,onChange:v,language:w="plaintext",height:R=300,width:f="100%",readOnly:O=!1,tabSize:o=2,lineNumbers:G=!0,placeholder:Z,theme:_="auto",className:V,"data-testid":F}=d,[g,z]=C.Vu({value:u,defaultValue:m,fallbackValue:"",onChange:v,componentName:"NiceSimpleCodeEditor"}),T=r.useRef(null),P=r.useRef(null),[I,E]=r.useState(()=>ce(g)),[W,M]=r.useState("light");r.useEffect(()=>{const p=()=>{if(_!=="auto")return _;if(typeof document>"u")return"light";const L=document.documentElement.dataset.theme;return L==="dark"?"dark":L==="light"?"light":window.matchMedia?.("(prefers-color-scheme: dark)").matches?"dark":"light"};if(M(p()),_!=="auto"||typeof document>"u")return;const s=()=>M(p()),h=new MutationObserver(s);h.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const S=window.matchMedia?.("(prefers-color-scheme: dark)");return S?.addEventListener?.("change",s),()=>{h.disconnect(),S?.removeEventListener?.("change",s)}},[_]),r.useEffect(()=>{let p=!0;return Ve(w).then(s=>{if(!p)return;const h=se[w]??"plain";if(s?.languages?.[h])try{const S=s.highlight(g,s.languages[h],h);E(S);return}catch{}E(ce(g))}).catch(()=>{p&&E(ce(g))}),()=>{p=!1}},[g,w]);const U=r.useCallback(()=>{!P.current||!T.current||(P.current.scrollTop=T.current.scrollTop,P.current.scrollLeft=T.current.scrollLeft)},[]),B=r.useCallback(p=>{if(p.key==="Tab"){p.preventDefault();const s=p.currentTarget,h=s.selectionStart,S=s.selectionEnd,L=" ".repeat(o);if(p.shiftKey){const b=g.substring(0,h).lastIndexOf(`
|
|
3
|
+
`)+1;if((g.substring(b,h).match(/^(\s*)/)?.[1]??"").length>=o){const y=g.substring(0,b)+g.substring(b+o);z(y),setTimeout(()=>{s.selectionStart=s.selectionEnd=h-o},0)}}else{const q=g.substring(0,h)+L+g.substring(S);z(q),setTimeout(()=>{s.selectionStart=s.selectionEnd=h+o},0)}}},[g,z,o]),N=g.split(`
|
|
4
|
+
`).length,j=se[w]??"plain";return t.jsxs("div",{className:`nice-simple-code-editor nice-simple-code-editor--${W} ${V??""}`,style:{height:R,width:f},"data-testid":F,"data-language":w,"data-theme":W,children:[G&&t.jsx("div",{className:"nice-simple-code-editor__line-numbers",children:Array.from({length:N},(p,s)=>t.jsx("div",{className:"nice-simple-code-editor__line-number",children:s+1},s))}),t.jsxs("div",{className:"nice-simple-code-editor__editor-area",children:[t.jsx("pre",{ref:P,"aria-hidden":"true",className:`nice-simple-code-editor__highlight language-${j}`,children:t.jsx("code",{className:`language-${j}`,dangerouslySetInnerHTML:{__html:I+(g.endsWith(`
|
|
5
|
+
`)?`
|
|
6
|
+
`:"")}})}),t.jsx("textarea",{ref:T,className:"nice-simple-code-editor__textarea",value:g,onChange:p=>z(p.target.value),onKeyDown:B,onScroll:U,readOnly:O,placeholder:Z,spellCheck:!1,autoCapitalize:"off",autoCorrect:"off"})]})]})}const ke="nice-code-editor-styles";if(typeof document<"u"&&!document.getElementById(ke)){const d=document.createElement("style");d.id=ke,d.textContent=`
|
|
7
|
+
.nice-code-editor,
|
|
8
|
+
.nice-code-diff-editor {
|
|
9
|
+
border: 1px solid var(--nice-border, #e0e0e0);
|
|
10
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
11
|
+
overflow: hidden;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.nice-code-editor--loading,
|
|
15
|
+
.nice-code-editor--error,
|
|
16
|
+
.nice-code-diff-editor--loading {
|
|
17
|
+
display: flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
justify-content: center;
|
|
20
|
+
background: var(--nice-bg-muted, #f5f5f5);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.nice-code-editor__loader {
|
|
24
|
+
color: var(--nice-text-secondary, #666);
|
|
25
|
+
font-size: 14px;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.nice-code-editor__error {
|
|
29
|
+
display: flex;
|
|
30
|
+
flex-direction: column;
|
|
31
|
+
width: 100%;
|
|
32
|
+
height: 100%;
|
|
33
|
+
padding: var(--nice-space-2, 8px);
|
|
34
|
+
gap: var(--nice-space-2, 8px);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.nice-code-editor__error span {
|
|
38
|
+
color: var(--nice-error, #d32f2f);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/* Simple code editor */
|
|
42
|
+
.nice-simple-code-editor {
|
|
43
|
+
display: flex;
|
|
44
|
+
border: 1px solid var(--nice-border-color, var(--nice-border, #e0e0e0));
|
|
45
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
46
|
+
overflow: hidden;
|
|
47
|
+
font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
|
|
48
|
+
font-size: 14px;
|
|
49
|
+
line-height: 1.5;
|
|
50
|
+
background: var(--nice-bg-primary, var(--nice-bg-surface, #fff));
|
|
51
|
+
color: var(--nice-text-primary, var(--nice-text-primary, #333));
|
|
52
|
+
}
|
|
53
|
+
.nice-simple-code-editor--dark {
|
|
54
|
+
background: var(--nice-bg, #1e1e1e);
|
|
55
|
+
color: var(--nice-text, #d4d4d4);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.nice-simple-code-editor__line-numbers {
|
|
59
|
+
padding: var(--nice-space-2, 8px) 0;
|
|
60
|
+
background: var(--nice-bg-secondary, var(--nice-bg-muted, #f5f5f5));
|
|
61
|
+
border-right: 1px solid var(--nice-border-color, var(--nice-border, #e0e0e0));
|
|
62
|
+
user-select: none;
|
|
63
|
+
text-align: right;
|
|
64
|
+
color: var(--nice-text-secondary, var(--nice-text-secondary, #999));
|
|
65
|
+
overflow: hidden;
|
|
66
|
+
}
|
|
67
|
+
.nice-simple-code-editor--dark .nice-simple-code-editor__line-numbers {
|
|
68
|
+
background: var(--nice-bg-secondary, #252526);
|
|
69
|
+
border-right-color: var(--nice-border, #3c3c3c);
|
|
70
|
+
color: var(--nice-text-muted, #858585);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.nice-simple-code-editor__line-number {
|
|
74
|
+
padding: 0 var(--nice-space-3, 12px);
|
|
75
|
+
min-width: 40px;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.nice-simple-code-editor__editor-area {
|
|
79
|
+
position: relative;
|
|
80
|
+
flex: 1;
|
|
81
|
+
overflow: hidden;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.nice-simple-code-editor__highlight,
|
|
85
|
+
.nice-simple-code-editor__textarea {
|
|
86
|
+
position: absolute;
|
|
87
|
+
inset: 0;
|
|
88
|
+
margin: 0;
|
|
89
|
+
padding: var(--nice-space-2, 8px) var(--nice-space-3, 12px);
|
|
90
|
+
border: 0;
|
|
91
|
+
font: inherit;
|
|
92
|
+
line-height: inherit;
|
|
93
|
+
white-space: pre;
|
|
94
|
+
overflow: auto;
|
|
95
|
+
tab-size: 2;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.nice-simple-code-editor__highlight {
|
|
99
|
+
pointer-events: none;
|
|
100
|
+
background: transparent;
|
|
101
|
+
color: inherit;
|
|
102
|
+
}
|
|
103
|
+
.nice-simple-code-editor__highlight code {
|
|
104
|
+
font: inherit;
|
|
105
|
+
background: transparent;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.nice-simple-code-editor__textarea {
|
|
109
|
+
background: transparent;
|
|
110
|
+
color: transparent;
|
|
111
|
+
caret-color: var(--nice-text-primary, var(--nice-text-primary, #333));
|
|
112
|
+
resize: none;
|
|
113
|
+
outline: none;
|
|
114
|
+
-webkit-text-fill-color: transparent;
|
|
115
|
+
}
|
|
116
|
+
.nice-simple-code-editor--dark .nice-simple-code-editor__textarea {
|
|
117
|
+
caret-color: var(--nice-text, #d4d4d4);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.nice-simple-code-editor__textarea::placeholder {
|
|
121
|
+
color: var(--nice-text-secondary, var(--nice-text-secondary, #999));
|
|
122
|
+
-webkit-text-fill-color: var(--nice-text-secondary, var(--nice-text-secondary, #999));
|
|
123
|
+
}
|
|
124
|
+
.nice-simple-code-editor--dark .nice-simple-code-editor__textarea::placeholder {
|
|
125
|
+
color: var(--nice-text-muted, #858585);
|
|
126
|
+
-webkit-text-fill-color: var(--nice-text-muted, #858585);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/* Prism token colors — light */
|
|
130
|
+
.nice-simple-code-editor .token.comment,
|
|
131
|
+
.nice-simple-code-editor .token.prolog,
|
|
132
|
+
.nice-simple-code-editor .token.doctype,
|
|
133
|
+
.nice-simple-code-editor .token.cdata { color: #6a737d; font-style: italic; }
|
|
134
|
+
.nice-simple-code-editor .token.punctuation { color: #586069; }
|
|
135
|
+
.nice-simple-code-editor .token.property,
|
|
136
|
+
.nice-simple-code-editor .token.tag,
|
|
137
|
+
.nice-simple-code-editor .token.boolean,
|
|
138
|
+
.nice-simple-code-editor .token.number,
|
|
139
|
+
.nice-simple-code-editor .token.constant,
|
|
140
|
+
.nice-simple-code-editor .token.symbol,
|
|
141
|
+
.nice-simple-code-editor .token.deleted { color: #005cc5; }
|
|
142
|
+
.nice-simple-code-editor .token.selector,
|
|
143
|
+
.nice-simple-code-editor .token.attr-name,
|
|
144
|
+
.nice-simple-code-editor .token.string,
|
|
145
|
+
.nice-simple-code-editor .token.char,
|
|
146
|
+
.nice-simple-code-editor .token.builtin,
|
|
147
|
+
.nice-simple-code-editor .token.inserted { color: #032f62; }
|
|
148
|
+
.nice-simple-code-editor .token.operator,
|
|
149
|
+
.nice-simple-code-editor .token.entity,
|
|
150
|
+
.nice-simple-code-editor .token.url,
|
|
151
|
+
.nice-simple-code-editor .token.variable { color: var(--nice-danger, #d73a49); }
|
|
152
|
+
.nice-simple-code-editor .token.atrule,
|
|
153
|
+
.nice-simple-code-editor .token.attr-value,
|
|
154
|
+
.nice-simple-code-editor .token.keyword { color: var(--nice-danger, #d73a49); font-weight: 600; }
|
|
155
|
+
.nice-simple-code-editor .token.function,
|
|
156
|
+
.nice-simple-code-editor .token.class-name { color: #6f42c1; }
|
|
157
|
+
.nice-simple-code-editor .token.regex,
|
|
158
|
+
.nice-simple-code-editor .token.important { color: #e36209; }
|
|
159
|
+
|
|
160
|
+
/* Prism token colors — dark */
|
|
161
|
+
.nice-simple-code-editor--dark .token.comment,
|
|
162
|
+
.nice-simple-code-editor--dark .token.prolog,
|
|
163
|
+
.nice-simple-code-editor--dark .token.doctype,
|
|
164
|
+
.nice-simple-code-editor--dark .token.cdata { color: var(--nice-success, #6a9955); font-style: italic; }
|
|
165
|
+
.nice-simple-code-editor--dark .token.punctuation { color: var(--nice-text, #d4d4d4); }
|
|
166
|
+
.nice-simple-code-editor--dark .token.property,
|
|
167
|
+
.nice-simple-code-editor--dark .token.tag,
|
|
168
|
+
.nice-simple-code-editor--dark .token.boolean,
|
|
169
|
+
.nice-simple-code-editor--dark .token.number,
|
|
170
|
+
.nice-simple-code-editor--dark .token.constant,
|
|
171
|
+
.nice-simple-code-editor--dark .token.symbol,
|
|
172
|
+
.nice-simple-code-editor--dark .token.deleted { color: var(--nice-success-light, #b5cea8); }
|
|
173
|
+
.nice-simple-code-editor--dark .token.selector,
|
|
174
|
+
.nice-simple-code-editor--dark .token.attr-name,
|
|
175
|
+
.nice-simple-code-editor--dark .token.string,
|
|
176
|
+
.nice-simple-code-editor--dark .token.char,
|
|
177
|
+
.nice-simple-code-editor--dark .token.builtin,
|
|
178
|
+
.nice-simple-code-editor--dark .token.inserted { color: var(--nice-warning, #ce9178); }
|
|
179
|
+
.nice-simple-code-editor--dark .token.operator,
|
|
180
|
+
.nice-simple-code-editor--dark .token.entity,
|
|
181
|
+
.nice-simple-code-editor--dark .token.url,
|
|
182
|
+
.nice-simple-code-editor--dark .token.variable { color: var(--nice-primary, #569cd6); }
|
|
183
|
+
.nice-simple-code-editor--dark .token.atrule,
|
|
184
|
+
.nice-simple-code-editor--dark .token.attr-value,
|
|
185
|
+
.nice-simple-code-editor--dark .token.keyword { color: #c586c0; font-weight: 600; }
|
|
186
|
+
.nice-simple-code-editor--dark .token.function,
|
|
187
|
+
.nice-simple-code-editor--dark .token.class-name { color: #dcdcaa; }
|
|
188
|
+
.nice-simple-code-editor--dark .token.regex,
|
|
189
|
+
.nice-simple-code-editor--dark .token.important { color: #d7ba7d; }
|
|
190
|
+
|
|
191
|
+
/* Toolbar */
|
|
192
|
+
.nice-code-editor-wrap {
|
|
193
|
+
border: 1px solid var(--nice-border, #e0e0e0);
|
|
194
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
195
|
+
overflow: hidden;
|
|
196
|
+
}
|
|
197
|
+
.nice-code-editor-wrap .nice-code-editor {
|
|
198
|
+
border: none;
|
|
199
|
+
border-radius: 0;
|
|
200
|
+
}
|
|
201
|
+
.nice-code-editor__toolbar {
|
|
202
|
+
display: flex;
|
|
203
|
+
align-items: center;
|
|
204
|
+
gap: var(--nice-space-0-5, 2px);
|
|
205
|
+
padding: var(--nice-space-0-75, 3px) var(--nice-space-1-5, 6px);
|
|
206
|
+
background: var(--nice-bg-muted, #f5f5f5);
|
|
207
|
+
border-bottom: 1px solid var(--nice-border, #e0e0e0);
|
|
208
|
+
}
|
|
209
|
+
.nice-code-editor__toolbar-btn {
|
|
210
|
+
display: inline-flex;
|
|
211
|
+
align-items: center;
|
|
212
|
+
justify-content: center;
|
|
213
|
+
width: 26px;
|
|
214
|
+
height: 26px;
|
|
215
|
+
border: none;
|
|
216
|
+
border-radius: var(--nice-radius-sm, 3px);
|
|
217
|
+
background: transparent;
|
|
218
|
+
color: var(--nice-text-secondary, #666);
|
|
219
|
+
cursor: pointer;
|
|
220
|
+
font-size: 14px;
|
|
221
|
+
transition: background 0.15s, color 0.15s;
|
|
222
|
+
}
|
|
223
|
+
.nice-code-editor__toolbar-btn:hover {
|
|
224
|
+
background: var(--nice-hover, #e0e0e0);
|
|
225
|
+
color: var(--nice-text-primary, #333);
|
|
226
|
+
}
|
|
227
|
+
.nice-code-editor__toolbar-btn--active {
|
|
228
|
+
background: var(--nice-accent, #1976d2);
|
|
229
|
+
color: var(--nice-bg, #FFF);
|
|
230
|
+
}
|
|
231
|
+
.nice-code-editor__toolbar-sep {
|
|
232
|
+
width: 1px;
|
|
233
|
+
height: 18px;
|
|
234
|
+
background: var(--nice-border, #e0e0e0);
|
|
235
|
+
margin: 0 var(--nice-space-1, 4px);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/* Status bar */
|
|
239
|
+
.nice-code-editor__statusbar {
|
|
240
|
+
display: flex;
|
|
241
|
+
align-items: center;
|
|
242
|
+
gap: var(--nice-space-3, 12px);
|
|
243
|
+
padding: var(--nice-space-0-5, 2px) var(--nice-space-2-5, 10px);
|
|
244
|
+
background: var(--nice-bg-muted, #f5f5f5);
|
|
245
|
+
border-top: 1px solid var(--nice-border, #e0e0e0);
|
|
246
|
+
font-size: 12px;
|
|
247
|
+
color: var(--nice-text-secondary, #666);
|
|
248
|
+
user-select: none;
|
|
249
|
+
}
|
|
250
|
+
.nice-code-editor__statusbar-spacer { flex: 1; }
|
|
251
|
+
.nice-code-editor__statusbar-lang {
|
|
252
|
+
text-transform: uppercase;
|
|
253
|
+
font-weight: 600;
|
|
254
|
+
font-size: 11px;
|
|
255
|
+
}
|
|
256
|
+
.nice-code-editor__statusbar-markers {
|
|
257
|
+
color: var(--nice-warning, #f39c12);
|
|
258
|
+
font-weight: 600;
|
|
259
|
+
}
|
|
260
|
+
`,document.head.appendChild(d)}exports.NiceCodeDiffEditor=Pe;exports.NiceCodeEditor=Te;exports.NiceSimpleCodeEditor=ze;
|