@zeke-02/docx-editor-react 0.1.0
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/LICENSE +201 -0
- package/README.md +122 -0
- package/dist/FindReplaceDialog-25PDOTC7.js +1 -0
- package/dist/FindReplaceDialog-6PLDD22H.mjs +1 -0
- package/dist/FootnotePropertiesDialog-JIWAFAKL.js +1 -0
- package/dist/FootnotePropertiesDialog-SZYOYLR3.mjs +1 -0
- package/dist/HyperlinkDialog-G5FFKLWY.js +1 -0
- package/dist/HyperlinkDialog-PSJ6P3E3.mjs +1 -0
- package/dist/ImagePositionDialog-DTGYFFAR.js +1 -0
- package/dist/ImagePositionDialog-FKBG2MSL.mjs +1 -0
- package/dist/ImagePropertiesDialog-SO6RAOT6.js +1 -0
- package/dist/ImagePropertiesDialog-T77XMKJF.mjs +1 -0
- package/dist/KeyboardShortcutsDialog-04AoVwn3.d.mts +415 -0
- package/dist/KeyboardShortcutsDialog-04AoVwn3.d.ts +415 -0
- package/dist/PageSetupDialog-Q7UGLILM.mjs +1 -0
- package/dist/PageSetupDialog-XMG64O3T.js +1 -0
- package/dist/PrintPreview-DEhwRBC_.d.mts +93 -0
- package/dist/PrintPreview-DEhwRBC_.d.ts +93 -0
- package/dist/SplitCellDialog-NPGW4JGQ.mjs +1 -0
- package/dist/SplitCellDialog-RNP37SKZ.js +1 -0
- package/dist/TablePropertiesDialog-3QNCWNEG.mjs +1 -0
- package/dist/TablePropertiesDialog-AQVM7FGA.js +1 -0
- package/dist/chunk-2DBLZSGF.js +1 -0
- package/dist/chunk-3QCOIABL.js +2 -0
- package/dist/chunk-45GFZZ45.mjs +1 -0
- package/dist/chunk-4RTT4L2S.js +1 -0
- package/dist/chunk-7DAI755K.mjs +1 -0
- package/dist/chunk-BJ5RZW6Y.js +1 -0
- package/dist/chunk-BMBP5UFA.mjs +1 -0
- package/dist/chunk-DZHU5RSL.mjs +2 -0
- package/dist/chunk-FZ357PVD.mjs +2 -0
- package/dist/chunk-GM2S2WMT.mjs +1 -0
- package/dist/chunk-GNIO6SOS.js +1 -0
- package/dist/chunk-HAFRR4IT.js +1 -0
- package/dist/chunk-ICVBXT6V.mjs +2 -0
- package/dist/chunk-JGPOALUP.js +1 -0
- package/dist/chunk-JTUSMG6J.js +1 -0
- package/dist/chunk-K5DD2LSK.mjs +1 -0
- package/dist/chunk-NIBCC7WQ.js +1 -0
- package/dist/chunk-PBA4ERQP.js +2 -0
- package/dist/chunk-RK5GPBQ5.mjs +1 -0
- package/dist/chunk-UMM2BQ4N.mjs +1 -0
- package/dist/chunk-UT6DJWGC.js +2 -0
- package/dist/chunk-UZLKRJJK.js +2 -0
- package/dist/chunk-W3QFF3SQ.mjs +2 -0
- package/dist/chunk-XA53EBKC.js +1 -0
- package/dist/chunk-XRZKQOQJ.mjs +1 -0
- package/dist/chunk-ZFZJRL2R.mjs +1 -0
- package/dist/dialogs.d.mts +40 -0
- package/dist/dialogs.d.ts +40 -0
- package/dist/dialogs.js +1 -0
- package/dist/dialogs.mjs +1 -0
- package/dist/hooks.d.mts +513 -0
- package/dist/hooks.d.ts +513 -0
- package/dist/hooks.js +1 -0
- package/dist/hooks.mjs +1 -0
- package/dist/index.d.mts +567 -0
- package/dist/index.d.ts +567 -0
- package/dist/index.js +33 -0
- package/dist/index.mjs +33 -0
- package/dist/plugin-api.d.mts +90 -0
- package/dist/plugin-api.d.ts +90 -0
- package/dist/plugin-api.js +246 -0
- package/dist/plugin-api.mjs +246 -0
- package/dist/styles.css +1 -0
- package/dist/styles.d.mts +13 -0
- package/dist/styles.d.ts +13 -0
- package/dist/styles.js +1 -0
- package/dist/styles.mjs +1 -0
- package/dist/types-DaQbko33.d.mts +106 -0
- package/dist/types-DaQbko33.d.ts +106 -0
- package/dist/ui.d.mts +1565 -0
- package/dist/ui.d.ts +1565 -0
- package/dist/ui.js +111 -0
- package/dist/ui.mjs +111 -0
- package/dist/useFindReplace-C5gZIvkA.d.mts +219 -0
- package/dist/useFindReplace-C5gZIvkA.d.ts +219 -0
- package/package.json +137 -0
package/dist/ui.mjs
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import {h,o,b as b$1,a as a$1}from'./chunk-FZ357PVD.mjs';export{r as AlignmentButtons,q as ColorPicker,E as EditorToolbar,p as FontPicker,c as FontSizePicker,F as HorizontalRuler,s as LineSpacingPicker,e as ListButtons,t as StylePicker,w as TableBorderColorPicker,v as TableBorderPicker,x as TableBorderWidthPicker,y as TableCellFillPicker,z as TableMoreDropdown,i as TextContextMenu,D as Toolbar,A as ToolbarButton,B as ToolbarGroup,C as ToolbarSeparator,u as ZoomControl,f as createDefaultListState,m as getDefaultTextContextMenuItems,I as getMarginInUnits,H as getRulerDimensions,k as getTextActionLabel,l as getTextActionShortcut,n as isTextActionAvailable,J as parseMarginFromUnits,G as positionToMargin,j as useTextContextMenu}from'./chunk-FZ357PVD.mjs';export{l as KeyboardShortcutsDialog,a as PasteSpecialDialog,k as getAllCategories,d as getAllPasteOptions,j as getCategoryLabel,i as getCommonShortcuts,e as getDefaultPasteOption,g as getDefaultShortcuts,c as getPasteOption,h as getShortcutsByCategory,f as isPasteSpecialShortcut,m as useKeyboardShortcutsDialog,b as usePasteSpecial}from'./chunk-W3QFF3SQ.mjs';export{a as formatShortcutKeys}from'./chunk-K5DD2LSK.mjs';import {a as a$2}from'./chunk-GM2S2WMT.mjs';import {b as b$2}from'./chunk-DZHU5RSL.mjs';export{o as TableToolbar,k as addColumn,i as addRow,d as createTableContext,l as deleteColumn,j as deleteRow,f as getCellAt,e as getColumnCount,g as getTableSplitCellDialogConfig,m as mergeCells,n as splitCell,h as splitTableCell}from'./chunk-DZHU5RSL.mjs';export{a as FindReplaceDialog}from'./chunk-45GFZZ45.mjs';import {a}from'./chunk-7DAI755K.mjs';export{b as useFindReplace}from'./chunk-7DAI755K.mjs';export{d as HyperlinkDialog,m as useHyperlinkDialog}from'./chunk-ICVBXT6V.mjs';import {b}from'./chunk-ZFZJRL2R.mjs';import'./chunk-BMBP5UFA.mjs';import Kr,{useRef,useState,useEffect,useCallback,useLayoutEffect,useMemo}from'react';import {DEFAULT_AI_ACTIONS,getActionLabel,getActionDescription}from'@zeke-02/docx-editor-core/types/agentApi';import {jsxs,jsx,Fragment}from'react/jsx-runtime';var Io={askAI:"contextMenu.aiActions.askAi",rewrite:"contextMenu.aiActions.rewrite",expand:"contextMenu.aiActions.expand",summarize:"contextMenu.aiActions.summarize",translate:"contextMenu.aiActions.translate",explain:"contextMenu.aiActions.explain",fixGrammar:"contextMenu.aiActions.fixGrammar",makeFormal:"contextMenu.aiActions.makeFormal",makeCasual:"contextMenu.aiActions.makeCasual",custom:"contextMenu.aiActions.custom"},Po=()=>jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("circle",{cx:"8",cy:"8",r:"7",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M8 4v4M8 10v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),Lo=()=>jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M13 3L3 13M3 3h4v4M13 13h-4v-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Ro=()=>jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M8 3v10M3 8h10",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),Eo=()=>jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M3 4h10M3 8h7M3 12h4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),Do=()=>jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M2 3h6M5 3v6M3 5c0 2 1 4 2 4s2-2 2-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),jsx("path",{d:"M9 7l3 6M15 7l-3 6M10 11h4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),Ao=()=>jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M6 6c0-1.1.9-2 2-2s2 .9 2 2c0 1.5-2 1.5-2 3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),jsx("circle",{cx:"8",cy:"12",r:"0.5",fill:"currentColor"})]}),Mo=()=>jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M4 12l3-8 3 8M5 10h4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M12 6l2 2-2 2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),Oo=()=>jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M6 7h4M6 9h4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),_o=()=>jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("circle",{cx:"8",cy:"8",r:"5",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M6 9c.5.5 1 1 2 1s1.5-.5 2-1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),jsx("circle",{cx:"6",cy:"7",r:"0.5",fill:"currentColor"}),jsx("circle",{cx:"10",cy:"7",r:"0.5",fill:"currentColor"})]}),Bo=()=>jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M12 4L4 12M4 4l8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function No(e){switch(e){case "askAI":return jsx(Po,{});case "rewrite":return jsx(Lo,{});case "expand":return jsx(Ro,{});case "summarize":return jsx(Eo,{});case "translate":return jsx(Do,{});case "explain":return jsx(Ao,{});case "fixGrammar":return jsx(Mo,{});case "makeFormal":return jsx(Oo,{});case "makeCasual":return jsx(_o,{});case "custom":return jsx(Bo,{});default:return null}}var zo=({action:e,onClick:t,isHighlighted:o,onMouseEnter:i})=>{let{t:r}=b(),n=r(Io[e]),s=getActionDescription(e),a=No(e);return jsxs("button",{type:"button",className:`docx-context-menu-item ${o?"docx-context-menu-item-highlighted":""}`,onClick:t,onMouseEnter:i,title:s,role:"menuitem",style:{display:"flex",alignItems:"center",gap:"8px",width:"100%",padding:"8px 12px",border:"none",background:o?"var(--doc-primary-light)":"transparent",cursor:"pointer",fontSize:"13px",color:"var(--doc-text)",textAlign:"left"},children:[jsx("span",{style:{display:"flex",color:"var(--doc-text-muted)"},children:a}),jsx("span",{children:n})]})},Wo=({isOpen:e,onSubmit:t,onClose:o,selectedText:i})=>{let[r,n]=useState(""),s=useRef(null),{t:a}=b();useEffect(()=>{e&&s.current&&s.current.focus();},[e]);let l=p=>{p.preventDefault(),r.trim()&&(t(r.trim()),n(""));},c=p=>{p.key==="Escape"&&o();};return e?jsx("div",{className:"docx-custom-prompt-dialog",style:{position:"absolute",top:"100%",left:0,right:0,padding:"8px",background:"white",borderTop:"1px solid var(--doc-border)"},children:jsxs("form",{onSubmit:l,children:[jsxs("div",{style:{marginBottom:"8px",fontSize:"12px",color:"var(--doc-text-muted)"},children:['Selected: "',i.slice(0,50),i.length>50?"...":"",'"']}),jsx("input",{ref:s,type:"text",value:r,onChange:p=>n(p.target.value),onKeyDown:c,placeholder:a("contextMenu.customPromptPlaceholder"),style:{width:"100%",padding:"8px",border:"1px solid var(--doc-border-light)",borderRadius:"4px",fontSize:"13px"}}),jsxs("div",{style:{marginTop:"8px",display:"flex",gap:"8px",justifyContent:"flex-end"},children:[jsx("button",{type:"button",onClick:o,style:{padding:"6px 12px",border:"1px solid var(--doc-border-light)",borderRadius:"4px",background:"white",cursor:"pointer",fontSize:"12px"},children:a("common.cancel")}),jsx("button",{type:"submit",disabled:!r.trim(),style:{padding:"6px 12px",border:"none",borderRadius:"4px",background:r.trim()?"var(--doc-primary)":"var(--doc-border)",color:r.trim()?"white":"var(--doc-text-placeholder)",cursor:r.trim()?"pointer":"not-allowed",fontSize:"12px"},children:a("common.send")})]})]})}):null},Yo=({isOpen:e,position:t,selectedText:o,selectionContext:i,onAction:r,onClose:n,actions:s=DEFAULT_AI_ACTIONS,showCustomPrompt:a=true,className:l=""})=>{let c=useRef(null),[p,g]=useState(0),[d,m]=useState(false),{t:x}=b(),b$1=a?[...s,"custom"]:s;useEffect(()=>{if(!e)return;let u=h=>{c.current&&!c.current.contains(h.target)&&n();};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[e,n]),useEffect(()=>{if(!e)return;let u=h=>{switch(h.key){case "Escape":d?m(false):n();break;case "ArrowDown":h.preventDefault(),g(P=>(P+1)%b$1.length);break;case "ArrowUp":h.preventDefault(),g(P=>(P-1+b$1.length)%b$1.length);break;case "Enter":h.preventDefault();let I=b$1[p];I==="custom"?m(true):(r(I),n());break}};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[e,p,b$1,r,n,d]),useEffect(()=>{e&&(g(0),m(false));},[e]);let f=useCallback(()=>{let h$1=b$1.length*36+16,I=t.x,P=t.y;return typeof window<"u"&&(I+200>window.innerWidth&&(I=window.innerWidth-200-10),P+h$1>window.innerHeight&&(P=window.innerHeight-h$1-10),I<10&&(I=10),P<10&&(P=10)),{position:"fixed",top:P,left:I,minWidth:200,background:"white",border:"1px solid var(--doc-border-light)",borderRadius:"8px",boxShadow:"0 2px 10px rgba(0, 0, 0, 0.15)",zIndex:h.contextMenu,padding:"4px 0",overflow:"hidden"}},[t,b$1.length]),k=u=>{u==="custom"?m(true):(r(u),n());},T=u=>{r("custom",u),n();};return !e||!o?null:jsxs("div",{ref:c,className:`docx-context-menu ${l}`,style:f(),role:"menu","aria-label":x("contextMenu.ariaLabel"),children:[jsxs("div",{style:{padding:"8px 12px",borderBottom:"1px solid var(--doc-border)",fontSize:"11px",color:"var(--doc-text-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:['"',o.slice(0,30),o.length>30?"...":"",'"']}),jsx("div",{role:"group",children:b$1.map((u,h)=>jsx(zo,{action:u,onClick:()=>k(u),isHighlighted:h===p,onMouseEnter:()=>g(h)},u))}),a&&jsx(Wo,{isOpen:d,onSubmit:T,onClose:()=>m(false),selectedText:o})]})};function Uo(){let[e,t]=useState(false),[o,i]=useState({x:0,y:0}),[r,n]=useState(""),[s,a]=useState(),l=useCallback((p,g,d)=>{p.preventDefault(),i({x:p.clientX,y:p.clientY}),n(g),a(d),t(true);},[]),c=useCallback(()=>{t(false);},[]);return {isOpen:e,position:o,selectedText:r,selectionContext:s,openMenu:l,closeMenu:c}}function Fo(e){return {rewrite:"Ctrl+Shift+R",summarize:"Ctrl+Shift+S",translate:"Ctrl+Shift+T",fixGrammar:"Ctrl+Shift+G"}[e]}function Vo(e,t,o){return !(!t||t.trim().length===0)}function $o(){return [...DEFAULT_AI_ACTIONS]}function Go(){return ["askAI","rewrite","expand","summarize","translate","explain","fixGrammar","makeFormal","makeCasual","custom"]}var Ho=()=>jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M3 8l4 4 6-8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),Ve=()=>jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})}),Ko=()=>jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M2 8a6 6 0 0111.318-2.828M14 8a6 6 0 01-11.318 2.828",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),jsx("path",{d:"M13 2v4h-4M3 14v-4h4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),jo=()=>jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M11 2l3 3-9 9H2v-3l9-9z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Zo=()=>jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{animation:"spin 1s linear infinite"},children:[jsx("circle",{cx:"10",cy:"10",r:"8",stroke:"var(--doc-border)",strokeWidth:"2",fill:"none"}),jsx("path",{d:"M10 2a8 8 0 018 8",stroke:"var(--doc-primary)",strokeWidth:"2",strokeLinecap:"round",fill:"none"}),jsx("style",{children:`
|
|
2
|
+
@keyframes spin {
|
|
3
|
+
from { transform: rotate(0deg); }
|
|
4
|
+
to { transform: rotate(360deg); }
|
|
5
|
+
}
|
|
6
|
+
`})]});function Xo(e,t){let o=[],i=e.split(/(\s+)/),r=t.split(/(\s+)/),n=0,s=0;for(;n<i.length||s<r.length;){if(n>=i.length){o.push({type:"added",text:r.slice(s).join("")});break}if(s>=r.length){o.push({type:"removed",text:i.slice(n).join("")});break}if(i[n]===r[s])o.push({type:"same",text:i[n]}),n++,s++;else {let l=r.indexOf(i[n],s),c=i.indexOf(r[s],n);l===-1&&c===-1?(o.push({type:"removed",text:i[n]}),o.push({type:"added",text:r[s]}),n++,s++):c!==-1&&(l===-1||c-n<=l-s)?(o.push({type:"added",text:r[s]}),s++):(o.push({type:"removed",text:i[n]}),n++);}}let a=[];for(let l of o)a.length>0&&a[a.length-1].type===l.type?a[a.length-1].text+=l.text:a.push(l);return a}var Qo=({original:e,modified:t})=>{let o=Xo(e,t);return jsx("div",{className:"docx-response-diff",style:{lineHeight:1.6,fontSize:"14px"},children:o.map((i,r)=>{let n={};switch(i.type){case "removed":n={textDecoration:"line-through",color:"#d32f2f",backgroundColor:"#ffebee"};break;case "added":n={color:"#2e7d32",backgroundColor:"#e8f5e9"};break;}return jsx("span",{style:n,children:i.text},r)})})},Jo=({originalText:e,response:t,action:o,isLoading:i,error:r,onAccept:n,onReject:s,onRetry:a,allowEdit:l=true,showDiff:c=true,className:p="",position:g})=>{let{t:d}=b(),[m,x]=useState(false),[b$1,f]=useState(""),k=useRef(null),T=useRef(null),u=t?.newText||"";useEffect(()=>{u&&f(u);},[u]),useEffect(()=>{m&&k.current&&(k.current.focus(),k.current.select());},[m]),useEffect(()=>{let R=E=>{E.key==="Escape"?m?(x(false),f(u)):s():E.key==="Enter"&&(E.metaKey||E.ctrlKey)&&(E.preventDefault(),h());};return document.addEventListener("keydown",R),()=>document.removeEventListener("keydown",R)},[m,u,s]);let h=useCallback(()=>{n(m?b$1:u);},[m,b$1,u,n]),I=useCallback(()=>{x(true);},[]),P=useCallback(()=>{x(false),f(u);},[u]),_={position:g?"fixed":"relative",...g&&{left:g.x,top:g.y},width:"400px",maxWidth:"90vw",maxHeight:"80vh",background:"white",border:"1px solid var(--doc-border-light)",borderRadius:"8px",boxShadow:"0 4px 20px rgba(0, 0, 0, 0.15)",zIndex:1e4,overflow:"hidden",display:"flex",flexDirection:"column"};return i?jsx("div",{ref:T,className:`docx-response-preview docx-response-preview-loading ${p}`,style:_,children:jsxs("div",{style:{padding:"24px",display:"flex",flexDirection:"column",alignItems:"center",gap:"16px"},children:[jsx(Zo,{}),jsx("div",{style:{color:"var(--doc-text-muted)",fontSize:"14px"},children:d("responsePreview.loading",{action:getActionLabel(o)})})]})}):r?jsx("div",{ref:T,className:`docx-response-preview docx-response-preview-error ${p}`,style:_,children:jsxs("div",{style:{padding:"16px"},children:[jsx("div",{style:{padding:"12px",background:"var(--doc-error-bg)",borderRadius:"4px",color:"var(--doc-error)",fontSize:"13px",marginBottom:"16px"},children:r}),jsxs("div",{style:{display:"flex",gap:"8px",justifyContent:"flex-end"},children:[a&&jsxs("button",{type:"button",onClick:a,style:{display:"flex",alignItems:"center",gap:"4px",padding:"8px 16px",border:"1px solid var(--doc-border-light)",borderRadius:"4px",background:"white",cursor:"pointer",fontSize:"13px"},children:[jsx(Ko,{}),d("common.retry")]}),jsx("button",{type:"button",onClick:s,style:{padding:"8px 16px",border:"none",borderRadius:"4px",background:"var(--doc-border)",cursor:"pointer",fontSize:"13px"},children:d("common.close")})]})]})}):!t||!u?null:jsxs("div",{ref:T,className:`docx-response-preview ${p}`,style:_,children:[jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid var(--doc-border)",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[jsx("div",{style:{fontWeight:500,fontSize:"14px",color:"var(--doc-text)"},children:d("responsePreview.result",{action:getActionLabel(o)})}),jsx("button",{type:"button",onClick:s,style:{display:"flex",padding:"4px",border:"none",background:"transparent",cursor:"pointer",color:"var(--doc-text-muted)"},title:d("responsePreview.closeEsc"),children:jsx(Ve,{})})]}),jsxs("div",{style:{padding:"16px",overflowY:"auto",flex:1},children:[m?jsxs("div",{children:[jsx("div",{style:{marginBottom:"8px",fontSize:"12px",color:"var(--doc-text-muted)"},children:d("responsePreview.editPrompt")}),jsx("textarea",{ref:k,value:b$1,onChange:R=>f(R.target.value),style:{width:"100%",minHeight:"120px",padding:"12px",border:"1px solid var(--doc-primary)",borderRadius:"4px",fontSize:"14px",lineHeight:1.6,resize:"vertical",fontFamily:"inherit"}})]}):c?jsxs("div",{children:[jsx("div",{style:{marginBottom:"8px",fontSize:"12px",color:"var(--doc-text-muted)"},children:d("responsePreview.changes")}),jsx(Qo,{original:e,modified:u})]}):jsxs("div",{children:[jsx("div",{style:{marginBottom:"8px",fontSize:"12px",color:"var(--doc-text-muted)"},children:d("responsePreview.original")}),jsx("div",{style:{padding:"8px 12px",background:"var(--doc-bg-subtle)",borderRadius:"4px",marginBottom:"16px",textDecoration:"line-through",color:"var(--doc-text-placeholder)",fontSize:"13px"},children:e}),jsx("div",{style:{marginBottom:"8px",fontSize:"12px",color:"var(--doc-text-muted)"},children:d("responsePreview.new")}),jsx("div",{style:{padding:"8px 12px",background:"#e8f5e9",borderRadius:"4px",color:"#2e7d32",fontSize:"13px"},children:u})]}),t.warnings&&t.warnings.length>0&&jsx("div",{style:{marginTop:"16px",padding:"8px 12px",background:"var(--doc-warning-bg)",borderRadius:"4px",fontSize:"12px",color:"var(--doc-warning)"},children:t.warnings.map((R,E)=>jsx("div",{children:R},E))})]}),jsxs("div",{style:{padding:"12px 16px",borderTop:"1px solid var(--doc-border)",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[jsxs("div",{children:[l&&!m&&jsxs("button",{type:"button",onClick:I,style:{display:"flex",alignItems:"center",gap:"4px",padding:"6px 12px",border:"1px solid var(--doc-border-light)",borderRadius:"4px",background:"white",cursor:"pointer",fontSize:"12px",color:"var(--doc-text-muted)"},children:[jsx(jo,{}),d("common.edit")]}),m&&jsx("button",{type:"button",onClick:P,style:{padding:"6px 12px",border:"1px solid var(--doc-border-light)",borderRadius:"4px",background:"white",cursor:"pointer",fontSize:"12px",color:"var(--doc-text-muted)"},children:d("responsePreview.cancelEdit")})]}),jsxs("div",{style:{display:"flex",gap:"8px"},children:[jsxs("button",{type:"button",onClick:s,style:{display:"flex",alignItems:"center",gap:"4px",padding:"8px 16px",border:"1px solid var(--doc-border-light)",borderRadius:"4px",background:"white",cursor:"pointer",fontSize:"13px",color:"var(--doc-text-muted)"},children:[jsx(Ve,{}),d("common.reject")]}),jsxs("button",{type:"button",onClick:h,style:{display:"flex",alignItems:"center",gap:"4px",padding:"8px 16px",border:"none",borderRadius:"4px",background:"var(--doc-primary)",cursor:"pointer",fontSize:"13px",color:"white"},children:[jsx(Ho,{}),d("common.accept")]})]})]})]})};function qo(){let[e,t]=useState({isVisible:false,originalText:"",response:null,action:"rewrite",isLoading:false}),o=useCallback((s,a,l)=>{t({isVisible:true,originalText:s,response:null,action:a,isLoading:true,position:l});},[]),i=useCallback(s=>{t(a=>({...a,response:s,isLoading:false}));},[]),r=useCallback(s=>{t(a=>({...a,error:s,isLoading:false}));},[]),n=useCallback(()=>{t(s=>({...s,isVisible:false}));},[]);return {state:e,showPreview:o,setResponse:i,setError:r,hidePreview:n}}function er(e,t){return {success:true,newText:e,warnings:t}}function tr(e){return {success:false,error:e}}var or={includeHeaders:true,includeFooters:true,includePageNumbers:true,pageRange:null,scale:1,printBackground:true,margins:"default"};function rr({onPrint:e,disabled:t=false,label:o,className:i="",style:r,showIcon:n=true,compact:s=false}){let{t:a}=b(),l=o??a("print.label"),c={display:"flex",alignItems:"center",gap:s?"4px":"6px",padding:s?"4px 8px":"6px 12px",fontSize:s?"13px":"14px",backgroundColor:"white",border:"1px solid var(--doc-border)",borderRadius:"4px",cursor:t?"not-allowed":"pointer",color:t?"var(--doc-text-muted)":"var(--doc-text)",opacity:t?.6:1,transition:"background-color 0.15s, border-color 0.15s",...r};return jsxs("button",{className:`docx-print-button ${i}`.trim(),style:c,onClick:e,disabled:t,"aria-label":l,title:l,children:[n&&jsx(ir,{size:s?14:16}),!s&&jsx("span",{children:l})]})}function nr(){return jsx("style",{children:`
|
|
7
|
+
@media print {
|
|
8
|
+
/* Hide everything except print content */
|
|
9
|
+
body * {
|
|
10
|
+
visibility: hidden;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.docx-print-pages,
|
|
14
|
+
.docx-print-pages * {
|
|
15
|
+
visibility: visible;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.docx-print-pages {
|
|
19
|
+
position: absolute;
|
|
20
|
+
left: 0;
|
|
21
|
+
top: 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/* Remove shadows and margins in print */
|
|
25
|
+
.docx-print-page {
|
|
26
|
+
box-shadow: none !important;
|
|
27
|
+
margin: 0 !important;
|
|
28
|
+
page-break-after: always;
|
|
29
|
+
page-break-inside: avoid;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* Ensure images print */
|
|
33
|
+
img {
|
|
34
|
+
max-width: 100%;
|
|
35
|
+
page-break-inside: avoid;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* Ensure tables don't break badly */
|
|
39
|
+
table {
|
|
40
|
+
page-break-inside: avoid;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
tr {
|
|
44
|
+
page-break-inside: avoid;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/* Keep headings with content */
|
|
48
|
+
h1, h2, h3, h4, h5, h6 {
|
|
49
|
+
page-break-after: avoid;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/* Avoid orphan lines */
|
|
53
|
+
p {
|
|
54
|
+
orphans: 3;
|
|
55
|
+
widows: 3;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@page {
|
|
60
|
+
margin: 0;
|
|
61
|
+
size: auto;
|
|
62
|
+
}
|
|
63
|
+
`})}function ir({size:e=18}){return jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("polyline",{points:"6 9 6 2 18 2 18 9"}),jsx("path",{d:"M6 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-2"}),jsx("rect",{x:"6",y:"14",width:"12",height:"8"})]})}function sr(){window.print();}function ar(e="Document",t){let o=window.open("","_blank");return o?(o.document.write(`
|
|
64
|
+
<!DOCTYPE html>
|
|
65
|
+
<html>
|
|
66
|
+
<head>
|
|
67
|
+
<title>${e}</title>
|
|
68
|
+
<style>
|
|
69
|
+
@media print {
|
|
70
|
+
body {
|
|
71
|
+
margin: 0;
|
|
72
|
+
padding: 0;
|
|
73
|
+
}
|
|
74
|
+
@page {
|
|
75
|
+
margin: 0;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
</style>
|
|
79
|
+
</head>
|
|
80
|
+
<body>
|
|
81
|
+
${t}
|
|
82
|
+
</body>
|
|
83
|
+
</html>
|
|
84
|
+
`),o.document.close(),o):null}function lr(){return {...or}}function cr(e,t){if(!e||!e.trim())return null;let o=e.trim();if(/^\d+$/.test(o)){let r=parseInt(o,10);return r>=1&&r<=t?{start:r,end:r}:null}let i=o.match(/^(\d+)-(\d+)$/);if(i){let r=parseInt(i[1],10),n=parseInt(i[2],10);return r>=1&&n<=t&&r<=n?{start:r,end:n}:null}return null}function dr(e,t){return e?e.start===e.end?`Page ${e.start}`:`Pages ${e.start}-${e.end}`:`All (${t} pages)`}function pr(){return typeof window<"u"&&typeof window.print=="function"}function ur({onAction:e,disabled:t=false,canMerge:o$1=false,canSplit:i=false}){let{t:r}=b(),n=useCallback(p=>{p.preventDefault(),p.stopPropagation();},[]),s=useCallback(()=>{o$1&&e("mergeCells");},[e,o$1]),a=useCallback(()=>{i&&e("splitCell");},[e,i]),l=jsx(o,{content:r("table.mergeCells"),children:jsx(b$1,{variant:"ghost",size:"icon-sm",className:a$1("text-slate-500 hover:text-slate-900 hover:bg-slate-100/80",(t||!o$1)&&"opacity-30 cursor-not-allowed"),onMouseDown:n,onClick:s,disabled:t||!o$1,"aria-label":r("table.mergeCells"),"data-testid":"toolbar-table-merge",children:jsx(b$2,{name:"call_merge",size:20})})}),c=jsx(o,{content:r("table.splitCell"),children:jsx(b$1,{variant:"ghost",size:"icon-sm",className:a$1("text-slate-500 hover:text-slate-900 hover:bg-slate-100/80",(t||!i)&&"opacity-30 cursor-not-allowed"),onMouseDown:n,onClick:a,disabled:t||!i,"aria-label":r("table.splitCell"),"data-testid":"toolbar-table-split",children:jsx(b$2,{name:"call_split",size:20})})});return jsxs(Fragment,{children:[l,c]})}var xr=[{action:"addRowAbove",icon:"keyboard_arrow_up",labelKey:"table.insertRowAbove",testId:"toolbar-table-add-row-above"},{action:"addRowBelow",icon:"keyboard_arrow_down",labelKey:"table.insertRowBelow",testId:"toolbar-table-add-row-below"},{action:"addColumnLeft",icon:"keyboard_arrow_left",labelKey:"table.insertColumnLeft",testId:"toolbar-table-add-col-left"},{action:"addColumnRight",icon:"keyboard_arrow_right",labelKey:"table.insertColumnRight",testId:"toolbar-table-add-col-right"}];function fr({onAction:e,disabled:t=false}){let{t:o$1}=b(),i=useCallback(r=>{r.preventDefault(),r.stopPropagation();},[]);return jsx(Fragment,{children:xr.map(({action:r,icon:n,labelKey:s,testId:a})=>{let l=o$1(s);return jsx(o,{content:l,children:jsx(b$1,{variant:"ghost",size:"icon-sm",className:a$1("text-slate-500 hover:text-slate-900 hover:bg-slate-100/80",t&&"opacity-30 cursor-not-allowed"),onMouseDown:i,onClick:()=>!t&&e(r),disabled:t,"aria-label":l,"data-testid":a,children:jsx(b$2,{name:n,size:20})})},typeof r=="string"?r:r.type)})})}var yr="var(--doc-error)",hr="var(--doc-success)",Sr=({size:e=16})=>jsxs("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M3 2h8l2 2v9a1 1 0 01-1 1H3a1 1 0 01-1-1V3a1 1 0 011-1z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M5 2v4h5V2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M5 14v-4h6v4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),wr=({size:e=16})=>jsxs("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M8 5v4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),jsx("circle",{cx:"8",cy:"11",r:"0.5",fill:"currentColor"})]}),Cr=`
|
|
85
|
+
@keyframes docx-unsaved-pulse {
|
|
86
|
+
0%, 100% { opacity: 1; }
|
|
87
|
+
50% { opacity: 0.6; }
|
|
88
|
+
}
|
|
89
|
+
`,Tr=(e,t,o,i,r,n,s)=>{let a={display:"inline-flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s ease",animation:o&&i?"docx-unsaved-pulse 2s ease-in-out infinite":"none"};switch(t==="absolute-top-right"?(a.position="absolute",a.top="4px",a.right="4px"):t==="absolute-top-left"&&(a.position="absolute",a.top="4px",a.left="4px"),e){case "dot":return {...a,width:`${s}px`,height:`${s}px`,borderRadius:"50%",backgroundColor:o?r:n};case "badge":return {...a,padding:"2px 8px",borderRadius:"10px",fontSize:"11px",fontWeight:500,backgroundColor:o?r:n,color:"white"};case "text":return {...a,fontSize:"12px",color:o?r:n,fontWeight:500};case "icon":return {...a,color:o?r:n};default:return a}},kr=({hasUnsavedChanges:e,variant:t="dot",position:o="inline",showPulse:i=true,label:r,savedLabel:n,showWhenSaved:s=false,unsavedColor:a=yr,savedColor:l=hr,size:c=8,className:p="",style:g,onClick:d,title:m})=>{let{t:x}=b(),b$1=r??x("unsaved.unsaved"),f=n??x("unsaved.saved");if(useEffect(()=>{if(!i||!e)return;let I="docx-unsaved-pulse-keyframes";if(!document.getElementById(I)){let P=document.createElement("style");P.id=I,P.textContent=Cr,document.head.appendChild(P);}},[i,e]),!e&&!s)return null;let T={...Tr(t,o,e,i,a,l,c),...g,cursor:d?"pointer":void 0},u=x(e?"unsaved.unsavedTitle":"unsaved.savedTitle"),h=()=>{switch(t){case "dot":return null;case "badge":return e?b$1:f;case "text":return e?b$1:f;case "icon":return e?jsx(wr,{size:c}):jsx(Sr,{size:c});default:return null}};return jsx("span",{className:`docx-unsaved-indicator docx-unsaved-indicator-${t} ${e?"docx-unsaved":"docx-saved"} ${p}`,style:T,onClick:d,title:m??u,role:d?"button":"status","aria-label":x(e?"unsaved.unsavedAriaLabel":"unsaved.savedAriaLabel"),children:h()})};function Ir(e={}){let{t}=b(),{document:o,warnBeforeLeave:i=true,warningMessage:r=t("errors.unsavedChanges"),enabled:n=true,onChangeStatusChange:s}=e,[a,l]=useState(false),[c,p]=useState(0),[g,d]=useState(null),m=useRef(null),x=useRef(false),b$1=useCallback(u=>{if(!u)return null;try{return JSON.stringify(u.package)}catch{return null}},[]),f=useCallback(()=>{n&&(l(false),p(0),d(o??null),m.current=b$1(o));},[n,o,b$1]),k=useCallback(()=>{n&&(a||(l(true),s?.(true)),p(u=>u+1));},[n,a,s]),T=useCallback(u=>{let h=u!==void 0?u:o;l(false),p(0),d(h??null),m.current=b$1(h),x.current=true;},[o,b$1]);return useEffect(()=>{!n||!o||x.current||T(o);},[n,o,T]),useEffect(()=>{if(!n||!o||!x.current)return;let u=b$1(o),h=m.current;if(u!==h){let I=b$1(g);u!==I?(a||(l(true),s?.(true)),p(P=>P+1)):a&&(l(false),s?.(false)),m.current=u;}},[n,o,g,a,b$1,s]),useEffect(()=>{if(!n||!i||!a)return;let u=h=>(h.preventDefault(),h.returnValue=r,r);return window.addEventListener("beforeunload",u),()=>window.removeEventListener("beforeunload",u)},[n,i,a,r]),{hasUnsavedChanges:a,markAsSaved:f,markAsChanged:k,resetTracking:T,lastSavedDocument:g,changeCount:c}}function Pr(e){return {dot:"Dot",badge:"Badge",text:"Text",icon:"Icon"}[e]}function Lr(){return ["dot","badge","text","icon"]}function Rr(){return ["inline","absolute-top-right","absolute-top-left"]}function Er(){let e=0,t=null,o=false;return {markChanged:()=>{e++,o=true;},markSaved:()=>{o=false,t=new Date;},getState:()=>({changeCount:e,lastSaveTime:t,hasUnsavedChanges:o}),reset:()=>{e=0,t=null,o=false;}}}var Dr={small:{size:16,strokeWidth:2,fontSize:11},medium:{size:32,strokeWidth:3,fontSize:13},large:{size:48,strokeWidth:4,fontSize:14}},Ar="var(--doc-primary)",Mr=300,Or=`
|
|
90
|
+
@keyframes docx-loading-spin {
|
|
91
|
+
0% { transform: rotate(0deg); }
|
|
92
|
+
100% { transform: rotate(360deg); }
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
@keyframes docx-loading-pulse {
|
|
96
|
+
0%, 100% { opacity: 1; transform: scale(1); }
|
|
97
|
+
50% { opacity: 0.5; transform: scale(0.95); }
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
@keyframes docx-loading-dots {
|
|
101
|
+
0%, 80%, 100% { transform: scale(0); opacity: 0.5; }
|
|
102
|
+
40% { transform: scale(1); opacity: 1; }
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
@keyframes docx-loading-bar {
|
|
106
|
+
0% { left: -35%; right: 100%; }
|
|
107
|
+
60% { left: 100%; right: -90%; }
|
|
108
|
+
100% { left: 100%; right: -90%; }
|
|
109
|
+
}
|
|
110
|
+
`,_r=({size:e,strokeWidth:t,color:o})=>{let i=(e-t)/2,r=i*2*Math.PI;return jsxs("svg",{width:e,height:e,viewBox:`0 0 ${e} ${e}`,style:{animation:"docx-loading-spin 1s linear infinite"},children:[jsx("circle",{cx:e/2,cy:e/2,r:i,fill:"none",stroke:o,strokeWidth:t,strokeLinecap:"round",strokeDasharray:`${r*.75} ${r}`,opacity:.25}),jsx("circle",{cx:e/2,cy:e/2,r:i,fill:"none",stroke:o,strokeWidth:t,strokeLinecap:"round",strokeDasharray:`${r*.25} ${r}`,transform:`rotate(-90 ${e/2} ${e/2})`})]})},Br=({size:e,color:t})=>{let o=e/4,i=o/2;return jsx("div",{style:{display:"flex",gap:`${i}px`},children:[0,1,2].map(r=>jsx("div",{style:{width:o,height:o,borderRadius:"50%",backgroundColor:t,animation:`docx-loading-dots 1.4s ease-in-out ${r*.16}s infinite both`}},r))})},Nr=({size:e,color:t})=>jsx("div",{style:{width:e*3,height:e/4,backgroundColor:`${t}20`,borderRadius:e/8,overflow:"hidden",position:"relative"},children:jsx("div",{style:{position:"absolute",top:0,bottom:0,left:0,right:0,backgroundColor:t,borderRadius:e/8,animation:"docx-loading-bar 2.1s cubic-bezier(0.65, 0.815, 0.735, 0.395) infinite"}})}),zr=({size:e,color:t})=>jsx("div",{style:{width:e,height:e,borderRadius:"50%",backgroundColor:t,animation:"docx-loading-pulse 1.5s ease-in-out infinite"}}),Wr=({size:e,color:t,progress:o,showText:i,fontSize:r})=>{let n=Math.max(0,Math.min(100,o));return jsxs("div",{style:{width:e*3,height:e/4,backgroundColor:`${t}20`,borderRadius:e/8,overflow:"hidden",position:"relative"},children:[jsx("div",{style:{position:"absolute",top:0,bottom:0,left:0,width:`${n}%`,backgroundColor:t,borderRadius:e/8,transition:"width 0.3s ease"}}),i&&jsxs("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",fontSize:r,fontWeight:500,color:n>50?"#fff":t},children:[Math.round(n),"%"]})]})},Yr=({isLoading:e,variant:t="spinner",size:o="medium",message:i,overlay:r=false,overlayOpacity:n=.5,progress:s=0,showProgressText:a=true,color:l=Ar,className:c="",style:p})=>{let{t:g}=b(),d=Dr[o];if(useEffect(()=>{let b="docx-loading-keyframes";if(!document.getElementById(b)){let f=document.createElement("style");f.id=b,f.textContent=Or,document.head.appendChild(f);}},[]),!e)return null;let m=()=>{switch(t){case "spinner":return jsx(_r,{size:d.size,strokeWidth:d.strokeWidth,color:l});case "dots":return jsx(Br,{size:d.size,color:l});case "bar":return jsx(Nr,{size:d.size,color:l});case "pulse":return jsx(zr,{size:d.size,color:l});case "progress":return jsx(Wr,{size:d.size,color:l,progress:s,showText:a,fontSize:d.fontSize});default:return null}},x=jsxs("div",{className:`docx-loading-content ${c}`,style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",...p},children:[m(),i&&jsx("div",{style:{fontSize:d.fontSize,color:r?"white":"var(--doc-text-muted)",textAlign:"center"},children:i})]});return r?jsx("div",{className:`docx-loading-overlay ${c}`,style:{position:"fixed",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:`rgba(0, 0, 0, ${n})`,zIndex:1e4,...p},role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":t==="progress"?s:void 0,"aria-busy":"true","aria-label":i||g("loading.label"),children:x}):jsx("div",{className:`docx-loading-inline ${c}`,style:{display:"inline-flex",alignItems:"center",...p},role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":t==="progress"?s:void 0,"aria-busy":"true","aria-label":i||"Loading",children:x})};function Ur(e={}){let{initialLoading:t=false,minDuration:o=Mr,onStart:i,onEnd:r}=e,[n,s]=useState(t),[a,l]=useState(null),[c,p]=useState(0),g=useRef(null),d=useRef(null),m=useCallback(f=>{g.current=Date.now(),s(true),l(f||null),p(0),i?.();},[i]),x=useCallback(()=>{let f=g.current,k=Date.now(),T=f?k-f:0,u=Math.max(0,o-T);u>0?d.current=setTimeout(()=>{s(false),l(null),p(0),g.current=null,r?.();},u):(s(false),l(null),p(0),g.current=null,r?.());},[o,r]),b=useCallback(async(f,k)=>{m(k);try{let T=await f();return x(),T}catch(T){throw x(),T}},[m,x]);return useEffect(()=>()=>{d.current&&clearTimeout(d.current);},[]),{isLoading:n,message:a,progress:c,startLoading:m,stopLoading:x,setProgress:p,setMessage:l,withLoading:b}}function Fr(){let[e,t]=useState(new Map),o=useCallback((a,l)=>{t(c=>{let p=new Map(c);return p.set(a,{id:a,message:l,startTime:Date.now()}),p});},[]),i=useCallback((a,l)=>{t(c=>{let p=c.get(a);if(!p)return c;let g=new Map(c);return g.set(a,{...p,...l}),g});},[]),r=useCallback(a=>{t(l=>{let c=new Map(l);return c.delete(a),c});},[]),n=e.size>0;return {operations:Array.from(e.values()),isAnyLoading:n,startOperation:o,updateOperation:i,endOperation:r,getOperation:a=>e.get(a)}}function Vr(e){return {spinner:"Spinner",dots:"Dots",bar:"Bar",pulse:"Pulse",progress:"Progress"}[e]}function $r(){return ["spinner","dots","bar","pulse","progress"]}function Gr(){return ["small","medium","large"]}function Hr(e){return new Promise(t=>setTimeout(t,e))}var Xe=4,Qe=36,Xr=32,Qr=()=>jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("circle",{cx:"3",cy:"8",r:"1.5",fill:"currentColor"}),jsx("circle",{cx:"8",cy:"8",r:"1.5",fill:"currentColor"}),jsx("circle",{cx:"13",cy:"8",r:"1.5",fill:"currentColor"})]});function Je(e){let{containerRef:t,items:o,itemGap:i=Xe,overflowButtonWidth:r=Qe}=e,[n,s]=useState(o.length),a=useRef(new Map),l=useCallback(()=>{let g=t.current;if(!g){s(o.length);return}let d=g.offsetWidth;if(d===0)return;let m=[...o].sort((f,k)=>f.alwaysVisible&&!k.alwaysVisible?-1:!f.alwaysVisible&&k.alwaysVisible?1:(f.priority||3)-(k.priority||3)),x=0,b=0;for(let f of m){let T=(f.minWidth||a.current.get(f.id)||Xr)+(b>0?i:0),u=b<o.length-1?r+i:0;if(x+T+u<=d)x+=T,b++;else if(f.alwaysVisible)x+=T,b++;else break}s(Math.max(0,b));},[t,o,i,r]);useLayoutEffect(()=>{let g=t.current;if(!g)return;l();let d=new ResizeObserver(()=>{l();});return d.observe(g),()=>{d.disconnect();}},[t,l]),useEffect(()=>{l();},[o,l]);let{visibleItems:c,overflowItems:p}=useMemo(()=>{let g=[...o].sort((d,m)=>d.alwaysVisible&&!m.alwaysVisible?-1:!d.alwaysVisible&&m.alwaysVisible?1:(d.priority||3)-(m.priority||3));return {visibleItems:g.slice(0,n),overflowItems:g.slice(n)}},[o,n]);return {visibleItems:c,overflowItems:p,hasOverflow:p.length>0,recalculate:l}}var Jr=({items:e,isOpen:t,onClose:o,anchorRef:i})=>{let r=useRef(null);return useEffect(()=>{if(!t)return;let n=s=>{r.current&&!r.current.contains(s.target)&&i.current&&!i.current.contains(s.target)&&o();};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[t,o,i]),useEffect(()=>{if(!t)return;let n=s=>{s.key==="Escape"&&o();};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[t,o]),!t||e.length===0?null:jsx("div",{ref:r,className:"docx-responsive-toolbar-overflow-menu",style:{position:"absolute",top:"100%",right:0,marginTop:"4px",backgroundColor:"white",border:"1px solid var(--doc-border)",borderRadius:"8px",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",padding:"8px",zIndex:1e3,display:"flex",flexWrap:"wrap",gap:"4px",maxWidth:"300px"},role:"menu",children:e.map(n=>jsx("div",{className:"docx-responsive-toolbar-overflow-item",role:"menuitem",children:n.content},n.id))})},qr=({items:e,overflowItems:t=[],alwaysShowOverflow:o=false,renderOverflowButton:i,renderOverflowMenu:r,itemGap:n=Xe,padding:s="8px 12px",overflowButtonWidth:a=Qe,className:l="",style:c,height:p=44,backgroundColor:g="var(--doc-toolbar-bg)",borderBottom:d="1px solid var(--doc-border)"})=>{let m=useRef(null),x=useRef(null),[b,f]=useState(false),{visibleItems:k,overflowItems:T,hasOverflow:u}=Je({containerRef:m,items:e,itemGap:n,overflowButtonWidth:a}),h=[...T,...t],I=u||o||t.length>0,P=useCallback(()=>{f(E=>!E);},[]),_=useCallback(()=>{f(false);},[]),R=jsx("button",{ref:x,type:"button",className:"docx-responsive-toolbar-overflow-button",onClick:P,"aria-label":`Show ${h.length} more options`,"aria-expanded":b,"aria-haspopup":"menu",style:{display:"flex",alignItems:"center",justifyContent:"center",width:`${a}px`,height:"32px",border:"none",borderRadius:"4px",backgroundColor:b?"var(--doc-primary-light)":"transparent",color:"var(--doc-text-muted)",cursor:"pointer",transition:"background-color 0.15s ease"},children:jsx(Qr,{})});return jsxs("div",{ref:m,className:`docx-responsive-toolbar ${l}`,style:{display:"flex",alignItems:"center",gap:`${n}px`,height:typeof p=="number"?`${p}px`:p,padding:s,backgroundColor:g,borderBottom:d,position:"relative",...c},children:[k.map(E=>jsxs(Kr.Fragment,{children:[jsx("div",{className:"docx-responsive-toolbar-item","data-item-id":E.id,style:{flexShrink:0},children:E.content}),E.separatorAfter&&jsx("div",{className:"docx-responsive-toolbar-separator",style:{width:"1px",height:"24px",backgroundColor:"var(--doc-border)",margin:"0 4px"}})]},E.id)),I&&jsx("div",{style:{flex:1,minWidth:0}}),I&&jsxs("div",{style:{position:"relative",flexShrink:0},children:[i?i(h.length,b,P):R,r?b&&r(h,_):jsx(Jr,{items:h,isOpen:b,onClose:_,anchorRef:x})]})]})},en=({children:e,gap:t=2,separatorAfter:o=false,className:i="",style:r})=>jsxs(Fragment,{children:[jsx("div",{className:`docx-toolbar-group ${i}`,style:{display:"flex",alignItems:"center",gap:`${t}px`,...r},children:e}),o&&jsx("div",{className:"docx-toolbar-group-separator",style:{width:"1px",height:"24px",backgroundColor:"var(--doc-border)",margin:"0 4px"}})]});function tn(e,t,o){return {id:e,content:t,priority:3,...o}}function on(e){return e.map(t=>({...t,priority:t.priority||3}))}function rn(e){return {undo:1,redo:1,bold:1,italic:1,underline:2,fontFamily:2,fontSize:2,textColor:3,highlightColor:3,alignment:3,lists:4,indent:4,lineSpacing:5,styles:5}[e]||3}var an={position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4},ln={backgroundColor:"white",borderRadius:"8px",boxShadow:"0 4px 20px rgba(0, 0, 0, 0.15)",minWidth:"320px",maxWidth:"400px",width:"100%",margin:"20px"},cn={display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 20px",borderBottom:"1px solid var(--doc-border)"},dn={margin:0,fontSize:"18px",fontWeight:600,color:"var(--doc-text)"},pn={background:"none",border:"none",fontSize:"20px",cursor:"pointer",color:"var(--doc-text-muted)",padding:"4px 8px",lineHeight:1},un={padding:"20px"},gn={display:"flex",flexDirection:"column",alignItems:"center",marginBottom:"16px"},mn={display:"grid",gap:"2px",padding:"4px",backgroundColor:"var(--doc-bg-hover)",borderRadius:"4px",cursor:"pointer"},nt={width:"24px",height:"24px",backgroundColor:"white",border:"1px solid var(--doc-border-dark)",borderRadius:"2px",transition:"background-color 0.1s, border-color 0.1s"},bn={...nt,backgroundColor:"var(--doc-primary)",borderColor:"var(--doc-primary)"},xn={marginTop:"8px",fontSize:"14px",fontWeight:500,color:"var(--doc-text)"},fn={display:"flex",alignItems:"center",gap:"12px",margin:"16px 0",color:"var(--doc-text-muted)",fontSize:"12px"},et={flex:1,height:"1px",backgroundColor:"var(--doc-border)"},tt={display:"flex",alignItems:"center",gap:"12px",marginBottom:"12px"},ot={fontSize:"14px",fontWeight:500,color:"var(--doc-text)",minWidth:"80px"},rt={width:"80px",padding:"8px 12px",border:"1px solid var(--doc-border-input)",borderRadius:"4px",fontSize:"14px",textAlign:"center"},vn={display:"flex",justifyContent:"flex-end",gap:"12px",padding:"16px 20px",borderTop:"1px solid var(--doc-border)"},Ee={padding:"10px 20px",borderRadius:"4px",fontSize:"14px",fontWeight:500,cursor:"pointer",border:"none"},yn={...Ee,backgroundColor:"var(--doc-primary)",color:"white"},hn={...Ee,backgroundColor:"var(--doc-bg-hover)",color:"var(--doc-text)",border:"1px solid var(--doc-border-input)"},Sn={...Ee,backgroundColor:"var(--doc-border-input)",color:"var(--doc-text-muted)",cursor:"not-allowed"};function wn(){return jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("rect",{x:"2",y:"2",width:"16",height:"16",stroke:"currentColor",strokeWidth:"1.5",fill:"none",rx:"1"}),jsx("line",{x1:"2",y1:"7",x2:"18",y2:"7",stroke:"currentColor",strokeWidth:"1.5"}),jsx("line",{x1:"2",y1:"12",x2:"18",y2:"12",stroke:"currentColor",strokeWidth:"1.5"}),jsx("line",{x1:"8",y1:"2",x2:"8",y2:"18",stroke:"currentColor",strokeWidth:"1.5"}),jsx("line",{x1:"13",y1:"2",x2:"13",y2:"18",stroke:"currentColor",strokeWidth:"1.5"})]})}function Cn({isOpen:e,onClose:t,onInsert:o,maxGridRows:i=8,maxGridColumns:r=10,maxRows:n=100,maxColumns:s=20,className:a,style:l}){let{t:c}=b(),[p,g]=useState(0),[d,m]=useState(0),[x,b$1]=useState(3),[f,k]=useState(3),T=useRef(null);useEffect(()=>{e&&(g(0),m(0),b$1(3),k(3));},[e]),useEffect(()=>{e&&T.current?.focus();},[e]);let u=useCallback((C,D)=>{g(C),m(D);},[]),h=useCallback(()=>{p>0&&d>0&&o({rows:p,columns:d});},[p,d,o]),I=useCallback(()=>{let C=Math.min(Math.max(1,x),n),D=Math.min(Math.max(1,f),s);o({rows:C,columns:D});},[x,f,n,s,o]),P=useCallback(C=>{C.key==="Escape"?t():C.key==="Enter"&&!C.shiftKey&&(C.preventDefault(),I());},[t,I]),_=useCallback(C=>{C.target===C.currentTarget&&t();},[t]),R=useCallback(C=>{let D=parseInt(C.target.value,10);isNaN(D)?C.target.value===""&&b$1(1):b$1(Math.min(Math.max(1,D),n));},[n]),E=useCallback(C=>{let D=parseInt(C.target.value,10);isNaN(D)?C.target.value===""&&k(1):k(Math.min(Math.max(1,D),s));},[s]);if(!e)return null;let G=[];for(let C=1;C<=i;C++)for(let D=1;D<=r;D++){let H=C<=p&&D<=d;G.push(jsx("div",{style:H?bn:nt,onMouseEnter:()=>u(C,D),onClick:h,role:"gridcell","aria-selected":H},`${C}-${D}`));}let q=x>=1&&f>=1,v=p>0&&d>0?c("dialogs.insertTable.tableSize",{cols:d,rows:p}):c("dialogs.insertTable.hoverToSelect");return jsx("div",{className:`docx-insert-table-dialog-overlay ${a||""}`,style:{...an,...l},onClick:_,onKeyDown:P,role:"dialog","aria-modal":"true","aria-labelledby":"insert-table-dialog-title",children:jsxs("div",{ref:T,className:"docx-insert-table-dialog",style:ln,tabIndex:-1,children:[jsxs("div",{className:"docx-insert-table-dialog-header",style:cn,children:[jsx("h2",{id:"insert-table-dialog-title",style:dn,children:jsxs("span",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[jsx(wn,{}),c("dialogs.insertTable.title")]})}),jsx("button",{type:"button",className:"docx-insert-table-dialog-close",style:pn,onClick:t,"aria-label":c("common.closeDialog"),children:"\xD7"})]}),jsxs("div",{className:"docx-insert-table-dialog-body",style:un,children:[jsxs("div",{className:"docx-insert-table-grid-container",style:gn,children:[jsx("div",{className:"docx-insert-table-grid",style:{...mn,gridTemplateColumns:`repeat(${r}, 1fr)`},onMouseLeave:()=>{g(0),m(0);},role:"grid","aria-label":"Table size selector",children:G}),jsx("div",{className:"docx-insert-table-grid-label",style:xn,children:v})]}),jsxs("div",{className:"docx-insert-table-separator",style:fn,children:[jsx("div",{style:et}),jsx("span",{children:c("dialogs.insertTable.orSpecifySize")}),jsx("div",{style:et})]}),jsxs("div",{className:"docx-insert-table-inputs",children:[jsxs("div",{style:tt,children:[jsx("label",{htmlFor:"insert-table-rows",style:ot,children:c("dialogs.insertTable.rowsLabel")}),jsx("input",{id:"insert-table-rows",type:"number",min:1,max:n,value:x,onChange:R,style:rt})]}),jsxs("div",{style:tt,children:[jsx("label",{htmlFor:"insert-table-cols",style:ot,children:c("dialogs.insertTable.columnsLabel")}),jsx("input",{id:"insert-table-cols",type:"number",min:1,max:s,value:f,onChange:E,style:rt})]})]})]}),jsxs("div",{className:"docx-insert-table-dialog-footer",style:vn,children:[jsx("button",{type:"button",className:"docx-insert-table-dialog-cancel",style:hn,onClick:t,children:c("common.cancel")}),jsx("button",{type:"button",className:"docx-insert-table-dialog-insert",style:q?yn:Sn,onClick:I,disabled:!q,children:c("dialogs.insertTable.insertButton")})]})]})})}function Tn(){let[e,t]=useState(false),o=useCallback(()=>t(true),[]),i=useCallback(()=>t(false),[]),r=useCallback(()=>t(n=>!n),[]);return {isOpen:e,open:o,close:i,toggle:r}}function kn(e=3,t=3){return {rows:e,columns:t}}function In(e,t=100,o=20){return e.rows>=1&&e.rows<=t&&e.columns>=1&&e.columns<=o}function Pn(e,t=100,o=20){return {rows:Math.min(Math.max(1,e.rows),t),columns:Math.min(Math.max(1,e.columns),o)}}function Ln(e){return `${e.columns} x ${e.rows}`}function Rn(){return [{label:"2 x 2",config:{rows:2,columns:2}},{label:"3 x 3",config:{rows:3,columns:3}},{label:"4 x 4",config:{rows:4,columns:4}},{label:"2 x 4",config:{rows:2,columns:4}},{label:"4 x 2",config:{rows:4,columns:2}},{label:"5 x 5",config:{rows:5,columns:5}}]}var Dn={position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4},An={backgroundColor:"white",borderRadius:"8px",boxShadow:"0 4px 20px rgba(0, 0, 0, 0.15)",minWidth:"450px",maxWidth:"600px",width:"100%",margin:"20px",maxHeight:"90vh",overflow:"auto"},Mn={display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 20px",borderBottom:"1px solid var(--doc-border)"},On={margin:0,fontSize:"18px",fontWeight:600,color:"var(--doc-text)"},_n={background:"none",border:"none",fontSize:"20px",cursor:"pointer",color:"var(--doc-text-muted)",padding:"4px 8px",lineHeight:1},Bn={padding:"20px"},De={border:"2px dashed var(--doc-border-input)",borderRadius:"8px",padding:"40px 20px",textAlign:"center",cursor:"pointer",transition:"border-color 0.2s, background-color 0.2s",marginBottom:"16px"},Nn={...De,borderColor:"var(--doc-primary)",backgroundColor:"var(--doc-primary-light)"},zn={...De,padding:"20px",borderStyle:"solid",borderColor:"var(--doc-primary)"},Wn={display:"flex",justifyContent:"center",alignItems:"center",maxHeight:"250px",overflow:"hidden"},Yn={maxWidth:"100%",maxHeight:"250px",objectFit:"contain",borderRadius:"4px"},Un={fontSize:"48px",color:"var(--doc-text-placeholder)",marginBottom:"12px"},Fn={fontSize:"14px",color:"var(--doc-text-muted)",marginBottom:"8px"},Vn={fontSize:"12px",color:"var(--doc-text-placeholder)"},$n={marginBottom:"16px"},Gn={display:"block",marginBottom:"6px",fontSize:"14px",fontWeight:500,color:"var(--doc-text)"},Hn={width:"100%",padding:"10px 12px",border:"1px solid var(--doc-border-input)",borderRadius:"4px",fontSize:"14px",boxSizing:"border-box"},Kn={display:"flex",alignItems:"center",gap:"12px",marginBottom:"16px"},st={width:"100px",padding:"6px 8px",border:"1px solid var(--doc-border-input)",borderRadius:"4px",fontSize:"14px"},at={display:"inline-flex",alignItems:"center",gap:"6px",fontSize:"14px",color:"var(--doc-text)",fontWeight:500},jn={display:"inline-flex",alignItems:"center",gap:"6px",fontSize:"13px",color:"var(--doc-text-muted)",cursor:"pointer",whiteSpace:"nowrap"},Zn={display:"flex",justifyContent:"flex-end",gap:"12px",padding:"16px 20px",borderTop:"1px solid var(--doc-border)"},Ae={padding:"10px 20px",borderRadius:"4px",fontSize:"14px",fontWeight:500,cursor:"pointer",border:"none"},Xn={...Ae,backgroundColor:"var(--doc-primary)",color:"white"},Qn={...Ae,backgroundColor:"var(--doc-bg-subtle)",color:"var(--doc-text)",border:"1px solid var(--doc-border-input)"},Jn={...Ae,backgroundColor:"var(--doc-border-input)",color:"var(--doc-text-muted)",cursor:"not-allowed"};function qn(){return jsx("span",{style:{color:"var(--doc-text-placeholder)"},children:jsx(b$2,{name:"image",size:48})})}function ei({isOpen:e,onClose:t,onInsert:o,maxWidth:i=800,maxHeight:r=600,accept:n="image/*",className:s,style:a}){let{t:l}=b(),[c,p]=useState(null),[g,d]=useState(false),{width:m,height:x,lockAspect:b$1,setLockAspect:f,handleWidthChange:k,handleHeightChange:T,seed:u}=a$2(),[h,I]=useState(""),[P,_]=useState(null),R=useRef(null),E=useRef(null);useEffect(()=>{e&&(p(null),d(false),u(null,null),I(""),_(null));},[e]);let G=useCallback(w=>{if(!w.type.startsWith("image/")){_(l("dialogs.insertImage.invalidFile"));return}if(w.size>10*1024*1024){_(l("dialogs.insertImage.fileTooLarge"));return}_(null);let K=new FileReader;K.onload=bt=>{let _e=bt.target?.result,me=new Image;me.onload=()=>{let ee=me.width,te=me.height;if(ee>i||te>r){let xt=i/ee,ft=r/te,Be=Math.min(xt,ft);ee=Math.round(ee*Be),te=Math.round(te*Be);}u(ee,te),p({src:_e,width:ee,height:te,fileName:w.name,mimeType:w.type});},me.src=_e;},K.onerror=()=>{_("Failed to read image file");},K.readAsDataURL(w);},[i,r]),q=useCallback(w=>{let K=w.target.files?.[0];K&&G(K);},[G]),v=useCallback(()=>{R.current?.click();},[]),C=useCallback(w=>{w.preventDefault(),d(true);},[]),D=useCallback(w=>{w.preventDefault(),d(false);},[]),H=useCallback(w=>{w.preventDefault(),d(false);let K=w.dataTransfer.files?.[0];K&&G(K);},[G]),we=useCallback(()=>{c&&typeof m=="number"&&typeof x=="number"&&o({...c,width:m,height:x,alt:h||void 0});},[c,m,x,h,o]),pt=useCallback(w=>{w.key==="Escape"?t():w.key==="Enter"&&c&&!w.shiftKey&&(w.preventDefault(),we());},[t,c,we]),ut=useCallback(w=>{w.target===w.currentTarget&&t();},[t]),gt=useCallback(()=>{p(null),u(null,null),I(""),_(null),R.current&&(R.current.value="");},[u]);if(!e)return null;let Oe=c!==null&&typeof m=="number"&&m>0&&typeof x=="number"&&x>0,mt=()=>c?zn:g?Nn:De;return jsx("div",{className:`docx-insert-image-dialog-overlay ${s||""}`,style:{...Dn,...a},onClick:ut,onKeyDown:pt,role:"dialog","aria-modal":"true","aria-labelledby":"insert-image-dialog-title",children:jsxs("div",{ref:E,className:"docx-insert-image-dialog",style:An,tabIndex:-1,children:[jsxs("div",{className:"docx-insert-image-dialog-header",style:Mn,children:[jsx("h2",{id:"insert-image-dialog-title",style:On,children:l("dialogs.insertImage.title")}),jsx("button",{type:"button",className:"docx-insert-image-dialog-close",style:_n,onClick:t,"aria-label":l("common.closeDialog"),children:"\xD7"})]}),jsxs("div",{className:"docx-insert-image-dialog-body",style:Bn,children:[jsx("input",{ref:R,type:"file",accept:n,onChange:q,style:{display:"none"}}),jsx("div",{className:"docx-insert-image-dropzone",style:mt(),onClick:v,onDragOver:C,onDragLeave:D,onDrop:H,role:"button",tabIndex:0,"aria-label":l("dialogs.insertImage.uploadAriaLabel"),children:c?jsx("div",{style:Wn,children:jsx("img",{src:c.src,alt:h||"Preview",style:Yn})}):jsxs(Fragment,{children:[jsx("div",{style:Un,children:jsx(qn,{})}),jsx("div",{style:Fn,children:l("dialogs.insertImage.uploadText")}),jsx("div",{style:Vn,children:l("dialogs.insertImage.uploadSubtext")})]})}),P&&jsx("div",{style:{color:"var(--doc-error)",fontSize:"14px",marginBottom:"16px",textAlign:"center"},children:P}),c&&jsxs(Fragment,{children:[jsxs("div",{style:Kn,children:[jsxs("label",{style:at,children:[l("dialogs.insertImage.widthLabel"),jsx("input",{type:"number",value:m,onChange:w=>k(w.target.value),min:1,max:i,style:st})]}),jsxs("label",{style:at,children:[l("dialogs.insertImage.heightLabel"),jsx("input",{type:"number",value:x,onChange:w=>T(w.target.value),min:1,max:r,style:st})]}),jsxs("label",{style:jn,children:[jsx("input",{type:"checkbox",checked:b$1,onChange:w=>f(w.target.checked)}),l(b$1?"dialogs.insertImage.aspectRatioLocked":"dialogs.insertImage.aspectRatioUnlocked")]})]}),jsxs("div",{style:$n,children:[jsx("label",{htmlFor:"insert-image-alt",style:Gn,children:l("dialogs.insertImage.altTextLabel")}),jsx("input",{id:"insert-image-alt",type:"text",value:h,onChange:w=>I(w.target.value),placeholder:l("dialogs.insertImage.altTextPlaceholder"),style:Hn})]})]})]}),jsxs("div",{className:"docx-insert-image-dialog-footer",style:Zn,children:[(()=>{let w=c!==null;return jsx("button",{type:"button",className:"docx-insert-image-dialog-clear",style:Qn,onClick:w?gt:t,children:l(w?"common.clear":"common.cancel")})})(),jsx("button",{type:"button",className:"docx-insert-image-dialog-insert",style:Oe?Xn:Jn,onClick:we,disabled:!Oe,children:l("dialogs.insertImage.insertButton")})]})]})})}function ti(){let[e,t]=useState(false),o=useCallback(()=>t(true),[]),i=useCallback(()=>t(false),[]),r=useCallback(()=>t(n=>!n),[]);return {isOpen:e,open:o,close:i,toggle:r}}function oi(e){return e.type.startsWith("image/")}function ri(){return [".png",".jpg",".jpeg",".gif",".webp",".bmp",".svg"]}function ni(){return "image/png,image/jpeg,image/gif,image/webp,image/bmp,image/svg+xml"}function ii(e,t,o,i){if(e<=o&&t<=i)return {width:e,height:t};let r=o/e,n=i/t,s=Math.min(r,n);return {width:Math.round(e*s),height:Math.round(t*s)}}function si(e){let t=e.split(","),o=t[0].match(/:(.*?);/)?.[1]||"image/png",i=atob(t[1]),r=new Uint8Array(i.length);for(let n=0;n<i.length;n++)r[n]=i.charCodeAt(n);return new Blob([r],{type:o})}function ai(e){return new Promise((t,o)=>{let i=new Image;i.onload=()=>t({width:i.width,height:i.height}),i.onerror=()=>o(new Error("Failed to load image")),i.src=e;})}function li(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var ui={position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4},gi={backgroundColor:"white",borderRadius:"8px",boxShadow:"0 4px 20px rgba(0, 0, 0, 0.15)",minWidth:"450px",maxWidth:"550px",width:"100%",margin:"20px",maxHeight:"80vh",display:"flex",flexDirection:"column"},mi={display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 20px",borderBottom:"1px solid var(--doc-border)"},bi={margin:0,fontSize:"18px",fontWeight:600,color:"var(--doc-text)"},xi={background:"none",border:"none",fontSize:"20px",cursor:"pointer",color:"var(--doc-text-muted)",padding:"4px 8px",lineHeight:1},fi={padding:"20px",flex:1,overflow:"auto"},vi={width:"100%",padding:"10px 12px",border:"1px solid var(--doc-border-input)",borderRadius:"4px",fontSize:"14px",marginBottom:"16px",boxSizing:"border-box"},yi={display:"flex",flexWrap:"wrap",gap:"4px",marginBottom:"16px"},ct={padding:"6px 12px",border:"1px solid var(--doc-border-input)",borderRadius:"4px",backgroundColor:"white",cursor:"pointer",fontSize:"12px",transition:"all 0.15s"},hi={...ct,backgroundColor:"var(--doc-primary)",borderColor:"var(--doc-primary)",color:"white"},Si={display:"grid",gridTemplateColumns:"repeat(10, 1fr)",gap:"4px",maxHeight:"250px",overflow:"auto"},wi={width:"36px",height:"36px",display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--doc-border)",borderRadius:"4px",backgroundColor:"white",cursor:"pointer",fontSize:"18px",transition:"all 0.15s"},Ci={marginTop:"16px",padding:"12px",backgroundColor:"var(--doc-bg-subtle)",borderRadius:"4px",display:"flex",alignItems:"center",gap:"16px"},Ti={fontSize:"36px",width:"60px",height:"60px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"white",borderRadius:"4px",border:"1px solid var(--doc-border)"},ki={flex:1},Ii={display:"flex",justifyContent:"flex-end",gap:"12px",padding:"16px 20px",borderTop:"1px solid var(--doc-border)"},Me={padding:"10px 20px",borderRadius:"4px",fontSize:"14px",fontWeight:500,cursor:"pointer",border:"none"},Pi={...Me,backgroundColor:"var(--doc-primary)",color:"white"},Li={...Me,backgroundColor:"var(--doc-bg-subtle)",color:"var(--doc-text)",border:"1px solid var(--doc-border-input)"},Ri={...Me,backgroundColor:"var(--doc-border-input)",color:"var(--doc-text-muted)",cursor:"not-allowed"},ae=[{name:"common",label:"Common",symbols:["\xA9","\xAE","\u2122","\u2022","\u2026","\u2014","\u2013","\xB0","\xB1","\xD7","\xF7","\u2260","\u2264","\u2265","\u221E","\u221A","\u2211","\u220F","\u222B","\u03C0","\u20AC","\xA3","\xA5","\xA2","\xA7","\xB6","\u2020","\u2021","\u2030","\u2116"]},{name:"arrows",label:"Arrows",symbols:["\u2190","\u2191","\u2192","\u2193","\u2194","\u2195","\u2196","\u2197","\u2198","\u2199","\u21D0","\u21D1","\u21D2","\u21D3","\u21D4","\u21D5","\u27F5","\u27F6","\u27F7","\u2794","\u279C","\u279E","\u27A1","\u27A2","\u27A3","\u27A4","\u27A5","\u27A6","\u27A7","\u27A8"]},{name:"math",label:"Math",symbols:["+","\u2212","\xD7","\xF7","=","\u2260","<",">","\u2264","\u2265","\xB1","\u2213","\u221E","\u221A","\u221B","\u221C","\u2211","\u220F","\u222B","\u2202","\u2206","\u2207","\u2208","\u2209","\u220B","\u2205","\u2200","\u2203","\u2204","\u2282","\u2283","\u2286","\u2287","\u222A","\u2229","\u2295","\u2297","\u22A5","\u2220","\u221F"]},{name:"greek",label:"Greek",symbols:["\u03B1","\u03B2","\u03B3","\u03B4","\u03B5","\u03B6","\u03B7","\u03B8","\u03B9","\u03BA","\u03BB","\u03BC","\u03BD","\u03BE","\u03BF","\u03C0","\u03C1","\u03C3","\u03C4","\u03C5","\u03C6","\u03C7","\u03C8","\u03C9","\u0391","\u0392","\u0393","\u0394","\u0395","\u0396","\u0397","\u0398","\u0399","\u039A","\u039B","\u039C","\u039D","\u039E","\u039F","\u03A0"]},{name:"shapes",label:"Shapes",symbols:["\u25A0","\u25A1","\u25AA","\u25AB","\u25AC","\u25AD","\u25AE","\u25AF","\u25B0","\u25B1","\u25B2","\u25B3","\u25B4","\u25B5","\u25B6","\u25B7","\u25B8","\u25B9","\u25BA","\u25BB","\u25BC","\u25BD","\u25BE","\u25BF","\u25C0","\u25C1","\u25C2","\u25C3","\u25C4","\u25C5","\u25CF","\u25CB","\u25CE","\u25C9","\u25CC","\u25CD","\u25D0","\u25D1","\u25D2","\u25D3"]},{name:"punctuation",label:"Punctuation",symbols:["\u2013","\u2014","\u2018","\u2019","\u201C","\u201D","\xAB","\xBB","\u2039","\u203A","\u2026","\xB7","\u2022","\u2023","\u2043","\u2010","\u2011","\u2012","\u2015","\u2016","\u2032","\u2033","\u2034","\u2057","\u2035","\u2036","\u2037","\u203B","\u203D","\u2042"]},{name:"currency",label:"Currency",symbols:["$","\xA2","\xA3","\xA4","\xA5","\u20A0","\u20A1","\u20A2","\u20A3","\u20A4","\u20A5","\u20A6","\u20A7","\u20A8","\u20A9","\u20AA","\u20AB","\u20AC","\u20AD","\u20AE","\u20AF","\u20B0","\u20B1","\u20B2","\u20B3","\u20B4","\u20B5","\u20B6","\u20B7","\u20B8"]},{name:"music",label:"Music",symbols:["\u2669","\u266A","\u266B","\u266C","\u266D","\u266E","\u266F","\u{1D11E}","\u{1D122}","\u{1D12A}","\u{1D12B}","\u{1D157}\u{1D165}","\u{1D158}\u{1D165}","\u{1D158}\u{1D165}\u{1D16E}","\u{1D158}\u{1D165}\u{1D16F}","\u{1D158}\u{1D165}\u{1D170}","\u{1D192}","\u{1D193}","\u{1D110}","\u{1D111}"]},{name:"emoji",label:"Emoji",symbols:["\u{1F600}","\u{1F603}","\u{1F604}","\u{1F601}","\u{1F606}","\u{1F605}","\u{1F923}","\u{1F602}","\u{1F642}","\u{1F643}","\u{1F609}","\u{1F60A}","\u{1F607}","\u{1F970}","\u{1F60D}","\u{1F929}","\u{1F618}","\u{1F617}","\u263A","\u{1F61A}","\u2764","\u{1F9E1}","\u{1F49B}","\u{1F49A}","\u{1F499}","\u{1F49C}","\u{1F5A4}","\u{1F90D}","\u{1F494}","\u2763","\u{1F44D}","\u{1F44E}","\u{1F44C}","\u270C","\u{1F91E}","\u{1F91F}","\u{1F918}","\u{1F44B}","\u{1F64F}","\u2705"]}];function dt(){return ae.flatMap(e=>e.symbols)}function Ei({isOpen:e,onClose:t,onInsert:o,recentSymbols:i=[],className:r,style:n}){let{t:s}=b(),[a,l]=useState("common"),[c,p]=useState(null),[g,d]=useState(""),[m,x]=useState(null),b$1=useRef(null);useEffect(()=>{e&&(p(null),d(""),x(null),setTimeout(()=>b$1.current?.focus(),100));},[e]);let f=useMemo(()=>{if(!g.trim())return a==="recent"?i:ae.find(H=>H.name===a)?.symbols||[];let v=g.toLowerCase();return dt().filter(D=>{let H=D.codePointAt(0)?.toString(16).toUpperCase()||"";return D.includes(v)||H.includes(v.toUpperCase())||`U+${H}`.toLowerCase().includes(v)})},[g,a,i]),k=useCallback(v=>{p(v);},[]),T=useCallback(v=>{o(v);},[o]),u=useCallback(()=>{c&&o(c);},[c,o]),h=useCallback(v=>{v.key==="Escape"?t():v.key==="Enter"&&c&&(v.preventDefault(),u());},[t,c,u]),I=useCallback(v=>{v.target===v.currentTarget&&t();},[t]),P=v=>{if(!v)return null;let C=v.codePointAt(0);return {character:v,codePoint:C?`U+${C.toString(16).toUpperCase().padStart(4,"0")}`:"",decimal:C||0}};if(!e)return null;let R=P(m||c),E=c!==null,G={common:s("dialogs.insertSymbol.categories.common"),arrows:s("dialogs.insertSymbol.categories.arrows"),math:s("dialogs.insertSymbol.categories.math"),greek:s("dialogs.insertSymbol.categories.greek"),shapes:s("dialogs.insertSymbol.categories.shapes"),punctuation:s("dialogs.insertSymbol.categories.punctuation"),currency:s("dialogs.insertSymbol.categories.currency"),music:s("dialogs.insertSymbol.categories.music"),emoji:s("dialogs.insertSymbol.categories.emoji")},q=[...i.length>0?[{name:"recent",label:"Recent"}]:[],...ae.map(v=>({name:v.name,label:G[v.name]||v.label}))];return jsx("div",{className:`docx-insert-symbol-dialog-overlay ${r||""}`,style:{...ui,...n},onClick:I,onKeyDown:h,role:"dialog","aria-modal":"true","aria-labelledby":"insert-symbol-dialog-title",children:jsxs("div",{className:"docx-insert-symbol-dialog",style:gi,children:[jsxs("div",{className:"docx-insert-symbol-dialog-header",style:mi,children:[jsx("h2",{id:"insert-symbol-dialog-title",style:bi,children:s("dialogs.insertSymbol.title")}),jsx("button",{type:"button",className:"docx-insert-symbol-dialog-close",style:xi,onClick:t,"aria-label":s("common.closeDialog"),children:"\xD7"})]}),jsxs("div",{className:"docx-insert-symbol-dialog-body",style:fi,children:[jsx("input",{ref:b$1,type:"text",placeholder:s("dialogs.insertSymbol.searchPlaceholder"),value:g,onChange:v=>d(v.target.value),style:vi}),!g&&jsx("div",{className:"docx-insert-symbol-categories",style:yi,children:q.map(v=>jsx("button",{type:"button",onClick:()=>l(v.name),style:a===v.name?hi:ct,children:v.label},v.name))}),jsx("div",{className:"docx-insert-symbol-grid",style:Si,children:f.map((v,C)=>jsx("button",{type:"button",onClick:()=>k(v),onDoubleClick:()=>T(v),onMouseEnter:()=>x(v),onMouseLeave:()=>x(null),style:{...wi,...c===v?{backgroundColor:"var(--doc-primary-light)",borderColor:"var(--doc-primary)"}:{}},title:`${v} - U+${v.codePointAt(0)?.toString(16).toUpperCase()}`,children:v},`${v}-${C}`))}),f.length===0&&jsx("div",{style:{textAlign:"center",padding:"20px",color:"var(--doc-text-muted)"},children:s("dialogs.insertSymbol.noResults",{query:g})}),R&&jsxs("div",{className:"docx-insert-symbol-preview",style:Ci,children:[jsx("div",{style:Ti,children:R.character}),jsxs("div",{style:ki,children:[jsx("div",{style:{fontSize:"14px",fontWeight:500,marginBottom:"4px"},children:R.codePoint}),jsx("div",{style:{fontSize:"12px",color:"var(--doc-text-muted)"},children:s("dialogs.insertSymbol.decimal",{value:R.decimal})})]})]})]}),jsxs("div",{className:"docx-insert-symbol-dialog-footer",style:Ii,children:[jsx("button",{type:"button",className:"docx-insert-symbol-dialog-cancel",style:Li,onClick:t,children:s("common.cancel")}),jsx("button",{type:"button",className:"docx-insert-symbol-dialog-insert",style:E?Pi:Ri,onClick:u,disabled:!E,children:s("common.insert")})]})]})})}function Di(e=20){let[t,o]=useState(false),[i,r]=useState([]),n=useCallback(()=>o(true),[]),s=useCallback(()=>o(false),[]),a=useCallback(()=>o(c=>!c),[]),l=useCallback(c=>{r(p=>{let g=p.filter(d=>d!==c);return [c,...g].slice(0,e)});},[e]);return {isOpen:t,recentSymbols:i,open:n,close:s,toggle:a,addRecent:l}}function Ai(){return ae}function Mi(e){return ae.find(o=>o.name===e)?.symbols||[]}function Oi(e){let t=e.codePointAt(0)||0;return {character:e,codePoint:`U+${t.toString(16).toUpperCase().padStart(4,"0")}`,decimal:t,hex:t.toString(16).toUpperCase()}}function _i(e){if(!e.trim())return [];let t=e.toLowerCase();return dt().filter(o=>{let i=o.codePointAt(0)?.toString(16).toUpperCase()||"";return o.includes(e)||i.includes(t.toUpperCase())||`U+${i}`.toLowerCase().includes(t)})}function Bi(e){let t=e.replace(/^U\+/i,"").replace(/^0x/i,""),o=parseInt(t,16);return isNaN(o)||o<0||o>1114111?null:String.fromCodePoint(o)}var export_createDefaultFindOptions=a.createDefaultFindOptions;var export_createSearchPattern=a.createSearchPattern;var export_escapeRegexString=a.escapeRegexString;var export_findAllMatches=a.findAllMatches;var export_findInDocument=a.findInDocument;var export_findInParagraph=a.findInParagraph;var export_getDefaultHighlightOptions=a.getDefaultHighlightOptions;var export_getMatchCountText=a.getMatchCountText;var export_isEmptySearch=a.isEmptySearch;var export_replaceAllInContent=a.replaceAllInContent;var export_replaceFirstInContent=a.replaceFirstInContent;var export_scrollToMatch=a.scrollToMatch;
|
|
111
|
+
export{Yo as ContextMenu,ei as InsertImageDialog,Ei as InsertSymbolDialog,Cn as InsertTableDialog,Yr as LoadingIndicator,rr as PrintButton,nr as PrintStyles,Jo as ResponsePreview,qr as ResponsiveToolbar,en as ResponsiveToolbarGroup,ae as SYMBOL_CATEGORIES,fr as TableInsertButtons,ur as TableMergeButton,kr as UnsavedIndicator,ii as calculateFitDimensions,Pn as clampTableConfig,Er as createChangeTracker,export_createDefaultFindOptions as createDefaultFindOptions,kn as createDefaultTableConfig,tr as createErrorResponse,er as createMockResponse,export_createSearchPattern as createSearchPattern,tn as createToolbarItem,on as createToolbarItems,si as dataUrlToBlob,Hr as delay,export_escapeRegexString as escapeRegexString,export_findAllMatches as findAllMatches,export_findInDocument as findInDocument,export_findInParagraph as findInParagraph,li as formatFileSize,dr as formatPrintPageRange,Ln as formatTableDimensions,Fo as getActionShortcut,Go as getAllActions,Rr as getAllIndicatorPositions,Lr as getAllIndicatorVariants,Gr as getAllLoadingSizes,$r as getAllLoadingVariants,$o as getDefaultActions,export_getDefaultHighlightOptions as getDefaultHighlightOptions,lr as getDefaultPrintOptions,ni as getImageAcceptString,ai as getImageDimensions,Vr as getLoadingVariantLabel,export_getMatchCountText as getMatchCountText,rn as getRecommendedPriority,ri as getSupportedImageExtensions,Ai as getSymbolCategories,Oi as getSymbolUnicodeInfo,Mi as getSymbolsByCategory,Rn as getTablePresets,Pr as getVariantLabel,Vo as isActionAvailable,export_isEmptySearch as isEmptySearch,pr as isPrintSupported,oi as isValidImageFile,In as isValidTableConfig,ar as openPrintWindow,cr as parsePageRange,export_replaceAllInContent as replaceAllInContent,export_replaceFirstInContent as replaceFirstInContent,export_scrollToMatch as scrollToMatch,_i as searchSymbols,Bi as symbolFromCodePoint,sr as triggerPrint,Uo as useContextMenu,ti as useInsertImageDialog,Di as useInsertSymbolDialog,Tn as useInsertTableDialog,Ur as useLoading,Fr as useLoadingOperations,qo as useResponsePreview,Je as useResponsiveToolbar,Ir as useUnsavedChanges};
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import React__default, { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
import { Table } from '@zeke-02/docx-editor-core/types/document';
|
|
3
|
+
import { FindMatch, FindOptions } from '@zeke-02/docx-editor-core/utils/findReplace';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* TableToolbar Component
|
|
7
|
+
*
|
|
8
|
+
* Provides controls for editing tables:
|
|
9
|
+
* - Add row above/below
|
|
10
|
+
* - Add column left/right
|
|
11
|
+
* - Delete row/column
|
|
12
|
+
* - Merge cells
|
|
13
|
+
* - Split cell
|
|
14
|
+
*
|
|
15
|
+
* Shows when cursor is in a table.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Table editing action types
|
|
20
|
+
*/
|
|
21
|
+
type TableAction = 'addRowAbove' | 'addRowBelow' | 'addColumnLeft' | 'addColumnRight' | 'deleteRow' | 'deleteColumn' | 'mergeCells' | 'splitCell' | 'deleteTable' | 'selectTable' | 'selectRow' | 'selectColumn' | 'borderAll' | 'borderOutside' | 'borderInside' | 'borderNone' | 'borderTop' | 'borderBottom' | 'borderLeft' | 'borderRight' | {
|
|
22
|
+
type: 'cellFillColor';
|
|
23
|
+
color: string | null;
|
|
24
|
+
} | {
|
|
25
|
+
type: 'borderColor';
|
|
26
|
+
color: string;
|
|
27
|
+
} | {
|
|
28
|
+
type: 'borderWidth';
|
|
29
|
+
size: number;
|
|
30
|
+
} | {
|
|
31
|
+
type: 'cellBorder';
|
|
32
|
+
side: 'top' | 'bottom' | 'left' | 'right' | 'all';
|
|
33
|
+
style: string;
|
|
34
|
+
size: number;
|
|
35
|
+
color: string;
|
|
36
|
+
} | {
|
|
37
|
+
type: 'cellVerticalAlign';
|
|
38
|
+
align: 'top' | 'center' | 'bottom';
|
|
39
|
+
} | {
|
|
40
|
+
type: 'cellMargins';
|
|
41
|
+
margins: {
|
|
42
|
+
top?: number;
|
|
43
|
+
bottom?: number;
|
|
44
|
+
left?: number;
|
|
45
|
+
right?: number;
|
|
46
|
+
};
|
|
47
|
+
} | {
|
|
48
|
+
type: 'cellTextDirection';
|
|
49
|
+
direction: string | null;
|
|
50
|
+
} | {
|
|
51
|
+
type: 'toggleNoWrap';
|
|
52
|
+
} | {
|
|
53
|
+
type: 'rowHeight';
|
|
54
|
+
height: number | null;
|
|
55
|
+
rule?: 'auto' | 'atLeast' | 'exact';
|
|
56
|
+
} | {
|
|
57
|
+
type: 'toggleHeaderRow';
|
|
58
|
+
} | {
|
|
59
|
+
type: 'distributeColumns';
|
|
60
|
+
} | {
|
|
61
|
+
type: 'autoFitContents';
|
|
62
|
+
} | {
|
|
63
|
+
type: 'tableProperties';
|
|
64
|
+
props: {
|
|
65
|
+
width?: number | null;
|
|
66
|
+
widthType?: string | null;
|
|
67
|
+
justification?: 'left' | 'center' | 'right' | null;
|
|
68
|
+
};
|
|
69
|
+
} | {
|
|
70
|
+
type: 'openTableProperties';
|
|
71
|
+
} | {
|
|
72
|
+
type: 'applyTableStyle';
|
|
73
|
+
styleId: string;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Selection within a table
|
|
77
|
+
*/
|
|
78
|
+
interface TableSelection {
|
|
79
|
+
/** Index of the table in the document */
|
|
80
|
+
tableIndex: number;
|
|
81
|
+
/** Row index (0-indexed) */
|
|
82
|
+
rowIndex: number;
|
|
83
|
+
/** Column index (0-indexed) */
|
|
84
|
+
columnIndex: number;
|
|
85
|
+
/** Selected cell range for multi-cell selection */
|
|
86
|
+
selectedCells?: {
|
|
87
|
+
startRow: number;
|
|
88
|
+
startCol: number;
|
|
89
|
+
endRow: number;
|
|
90
|
+
endCol: number;
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Context for table operations
|
|
95
|
+
*/
|
|
96
|
+
interface TableContext {
|
|
97
|
+
/** The table being edited */
|
|
98
|
+
table: Table;
|
|
99
|
+
/** Current selection within the table */
|
|
100
|
+
selection: TableSelection;
|
|
101
|
+
/** Whether multiple cells are selected (for merge) */
|
|
102
|
+
hasMultiCellSelection: boolean;
|
|
103
|
+
/** Whether current cell can be split */
|
|
104
|
+
canSplitCell: boolean;
|
|
105
|
+
/** Total number of rows */
|
|
106
|
+
rowCount: number;
|
|
107
|
+
/** Total number of columns */
|
|
108
|
+
columnCount: number;
|
|
109
|
+
}
|
|
110
|
+
interface TableSplitConfig {
|
|
111
|
+
minRows: number;
|
|
112
|
+
minCols: number;
|
|
113
|
+
initialRows: number;
|
|
114
|
+
initialCols: number;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Props for TableToolbar component
|
|
118
|
+
*/
|
|
119
|
+
interface TableToolbarProps {
|
|
120
|
+
/** Current table context (null if cursor not in table) */
|
|
121
|
+
context: TableContext | null;
|
|
122
|
+
/** Callback when a table action is triggered */
|
|
123
|
+
onAction?: (action: TableAction, context: TableContext) => void;
|
|
124
|
+
/** Whether the toolbar is disabled */
|
|
125
|
+
disabled?: boolean;
|
|
126
|
+
/** Additional CSS class name */
|
|
127
|
+
className?: string;
|
|
128
|
+
/** Additional inline styles */
|
|
129
|
+
style?: CSSProperties;
|
|
130
|
+
/** Show labels next to icons */
|
|
131
|
+
showLabels?: boolean;
|
|
132
|
+
/** Compact mode */
|
|
133
|
+
compact?: boolean;
|
|
134
|
+
/** Position of the toolbar */
|
|
135
|
+
position?: 'top' | 'floating';
|
|
136
|
+
/** Custom render for additional buttons */
|
|
137
|
+
children?: ReactNode;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* TableToolbar - Shows table manipulation controls when cursor is in a table
|
|
141
|
+
*/
|
|
142
|
+
declare function TableToolbar({ context, onAction, disabled, className, style, showLabels, compact, position, children, }: TableToolbarProps): React__default.ReactElement | null;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* useFindReplace Hook
|
|
146
|
+
*
|
|
147
|
+
* React hook for managing find/replace dialog state.
|
|
148
|
+
* Extracted from FindReplaceDialog.tsx.
|
|
149
|
+
*/
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Options for the useFindReplace hook
|
|
153
|
+
*/
|
|
154
|
+
interface FindReplaceOptions {
|
|
155
|
+
/** Whether to show replace functionality initially */
|
|
156
|
+
initialReplaceMode?: boolean;
|
|
157
|
+
/** Callback when matches change */
|
|
158
|
+
onMatchesChange?: (matches: FindMatch[]) => void;
|
|
159
|
+
/** Callback when current match changes */
|
|
160
|
+
onCurrentMatchChange?: (match: FindMatch | null, index: number) => void;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* State for the find/replace hook
|
|
164
|
+
*/
|
|
165
|
+
interface FindReplaceState {
|
|
166
|
+
/** Whether the dialog is open */
|
|
167
|
+
isOpen: boolean;
|
|
168
|
+
/** Current search text */
|
|
169
|
+
searchText: string;
|
|
170
|
+
/** Current replace text */
|
|
171
|
+
replaceText: string;
|
|
172
|
+
/** Find options */
|
|
173
|
+
options: FindOptions;
|
|
174
|
+
/** All matches found */
|
|
175
|
+
matches: FindMatch[];
|
|
176
|
+
/** Current match index */
|
|
177
|
+
currentIndex: number;
|
|
178
|
+
/** Whether in replace mode */
|
|
179
|
+
replaceMode: boolean;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Return type for the useFindReplace hook
|
|
183
|
+
*/
|
|
184
|
+
interface UseFindReplaceReturn {
|
|
185
|
+
/** Current state */
|
|
186
|
+
state: FindReplaceState;
|
|
187
|
+
/** Open the find dialog */
|
|
188
|
+
openFind: (selectedText?: string) => void;
|
|
189
|
+
/** Open the replace dialog */
|
|
190
|
+
openReplace: (selectedText?: string) => void;
|
|
191
|
+
/** Close the dialog */
|
|
192
|
+
close: () => void;
|
|
193
|
+
/** Toggle dialog visibility */
|
|
194
|
+
toggle: () => void;
|
|
195
|
+
/** Update search text */
|
|
196
|
+
setSearchText: (text: string) => void;
|
|
197
|
+
/** Update replace text */
|
|
198
|
+
setReplaceText: (text: string) => void;
|
|
199
|
+
/** Update find options */
|
|
200
|
+
setOptions: (options: Partial<FindOptions>) => void;
|
|
201
|
+
/** Set search results */
|
|
202
|
+
setMatches: (matches: FindMatch[], currentIndex?: number) => void;
|
|
203
|
+
/** Go to next match */
|
|
204
|
+
goToNextMatch: () => number;
|
|
205
|
+
/** Go to previous match */
|
|
206
|
+
goToPreviousMatch: () => number;
|
|
207
|
+
/** Go to a specific match by index */
|
|
208
|
+
goToMatch: (index: number) => void;
|
|
209
|
+
/** Get current match */
|
|
210
|
+
getCurrentMatch: () => FindMatch | null;
|
|
211
|
+
/** Check if has matches */
|
|
212
|
+
hasMatches: () => boolean;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Hook for managing find/replace dialog state
|
|
216
|
+
*/
|
|
217
|
+
declare function useFindReplace(hookOptions?: FindReplaceOptions): UseFindReplaceReturn;
|
|
218
|
+
|
|
219
|
+
export { type FindReplaceOptions as F, type TableSelection as T, type UseFindReplaceReturn as U, type TableContext as a, type TableSplitConfig as b, type TableAction as c, type FindReplaceState as d, TableToolbar as e, type TableToolbarProps as f, useFindReplace as u };
|