@sqren/docx-editor-react 1.7.0-fork.0 → 1.7.0-fork.1
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/dist/KeyboardShortcutsDialog-B-h3NAat.d.mts +3 -3
- package/dist/KeyboardShortcutsDialog-B-h3NAat.d.ts +3 -3
- package/dist/WatermarkDialog-KRL7WMIS.mjs +1 -1
- package/dist/WatermarkDialog-XGLAH3TK.js +1 -1
- package/dist/chunk-4Y4JFAPY.mjs +1 -1
- package/dist/chunk-74OM4KEH.js +1 -1
- package/dist/chunk-7VWJSV3T.js +1 -1
- package/dist/chunk-BABMU5KA.mjs +1 -1
- package/dist/chunk-BZO4G5M6.js +1 -1
- package/dist/chunk-GNIO6SOS.js +1 -1
- package/dist/chunk-IVFYCMAM.mjs +1 -1
- package/dist/chunk-L4MDZW2J.js +1 -1
- package/dist/chunk-LNONBJQM.js +1 -1
- package/dist/chunk-OHNO4NRQ.mjs +1 -1
- package/dist/chunk-P5ZOUQIK.mjs +1 -1
- package/dist/chunk-P6METJHI.mjs +1 -1
- package/dist/chunk-WFGAQC2B.mjs +1 -1
- package/dist/chunk-WNWY6WX7.js +1 -1
- package/dist/chunk-YY52FSUR.js +1 -1
- package/dist/chunk-ZFZJRL2R.mjs +1 -1
- package/dist/dialogs.d.mts +7 -7
- package/dist/dialogs.d.ts +7 -7
- package/dist/hooks.d.mts +9 -9
- package/dist/hooks.d.ts +9 -9
- package/dist/hooks.js +1 -1
- package/dist/hooks.mjs +1 -1
- package/dist/index.d.mts +27 -27
- package/dist/index.d.ts +27 -27
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/plugin-api.d.mts +8 -8
- package/dist/plugin-api.d.ts +8 -8
- package/dist/plugin-api.js +1 -1
- package/dist/plugin-api.mjs +1 -1
- package/dist/styles.d.mts +2 -2
- package/dist/styles.d.ts +2 -2
- package/dist/types-D35gNE-_.d.mts +1 -1
- package/dist/types-D35gNE-_.d.ts +1 -1
- package/dist/ui.d.mts +12 -12
- package/dist/ui.d.ts +12 -12
- package/dist/ui.js +1 -1
- package/dist/ui.mjs +1 -1
- package/dist/useFindReplace-Bc2ubEeV.d.mts +2 -2
- package/dist/useFindReplace-Bc2ubEeV.d.ts +2 -2
- package/package.json +4 -4
package/dist/ui.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var chunk7VWJSV3T_js=require('./chunk-7VWJSV3T.js'),chunk74OM4KEH_js=require('./chunk-74OM4KEH.js'),chunkPSBO3UDN_js=require('./chunk-PSBO3UDN.js'),chunkNIBCC7WQ_js=require('./chunk-NIBCC7WQ.js'),chunkWNWY6WX7_js=require('./chunk-WNWY6WX7.js'),chunkGWXEFL3H_js=require('./chunk-GWXEFL3H.js'),chunkL4MDZW2J_js=require('./chunk-L4MDZW2J.js'),chunkQD7BVJV3_js=require('./chunk-QD7BVJV3.js'),chunkGNIO6SOS_js=require('./chunk-GNIO6SOS.js');require('./chunk-BJ5RZW6Y.js');var Kr=require('react'),agentApi=require('@eigenpal/docx-editor-core/types/agentApi'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var Kr__default=/*#__PURE__*/_interopDefault(Kr);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=()=>jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("circle",{cx:"8",cy:"8",r:"7",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M8 4v4M8 10v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),Lo=()=>jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M13 3L3 13M3 3h4v4M13 13h-4v-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Ro=()=>jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M8 3v10M3 8h10",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),Eo=()=>jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M3 4h10M3 8h7M3 12h4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),Do=()=>jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("path",{d:"M2 3h6M5 3v6M3 5c0 2 1 4 2 4s2-2 2-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),jsxRuntime.jsx("path",{d:"M9 7l3 6M15 7l-3 6M10 11h4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),Ao=()=>jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.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"}),jsxRuntime.jsx("circle",{cx:"8",cy:"12",r:"0.5",fill:"currentColor"})]}),Mo=()=>jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("path",{d:"M4 12l3-8 3 8M5 10h4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx("path",{d:"M12 6l2 2-2 2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),Oo=()=>jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M6 7h4M6 9h4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),_o=()=>jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("circle",{cx:"8",cy:"8",r:"5",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M6 9c.5.5 1 1 2 1s1.5-.5 2-1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),jsxRuntime.jsx("circle",{cx:"6",cy:"7",r:"0.5",fill:"currentColor"}),jsxRuntime.jsx("circle",{cx:"10",cy:"7",r:"0.5",fill:"currentColor"})]}),Bo=()=>jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M12 4L4 12M4 4l8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function No(e){switch(e){case "askAI":return jsxRuntime.jsx(Po,{});case "rewrite":return jsxRuntime.jsx(Lo,{});case "expand":return jsxRuntime.jsx(Ro,{});case "summarize":return jsxRuntime.jsx(Eo,{});case "translate":return jsxRuntime.jsx(Do,{});case "explain":return jsxRuntime.jsx(Ao,{});case "fixGrammar":return jsxRuntime.jsx(Mo,{});case "makeFormal":return jsxRuntime.jsx(Oo,{});case "makeCasual":return jsxRuntime.jsx(_o,{});case "custom":return jsxRuntime.jsx(Bo,{});default:return null}}var zo=({action:e,onClick:t,isHighlighted:o,onMouseEnter:i})=>{let{t:r}=chunkGNIO6SOS_js.b(),n=r(Io[e]),a=agentApi.getActionDescription(e),s=No(e);return jsxRuntime.jsxs("button",{type:"button",className:`docx-context-menu-item ${o?"docx-context-menu-item-highlighted":""}`,onClick:t,onMouseEnter:i,title:a,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:[jsxRuntime.jsx("span",{style:{display:"flex",color:"var(--doc-text-muted)"},children:s}),jsxRuntime.jsx("span",{children:n})]})},Wo=({isOpen:e,onSubmit:t,onClose:o,selectedText:i})=>{let[r,n]=Kr.useState(""),a=Kr.useRef(null),{t:s}=chunkGNIO6SOS_js.b();Kr.useEffect(()=>{e&&a.current&&a.current.focus();},[e]);let l=p=>{p.preventDefault(),r.trim()&&(t(r.trim()),n(""));},c=p=>{p.key==="Escape"&&o();};return e?jsxRuntime.jsx("div",{className:"docx-custom-prompt-dialog",style:{position:"absolute",top:"100%",left:0,right:0,padding:"8px",background:"var(--doc-surface)",borderTop:"1px solid var(--doc-border)"},children:jsxRuntime.jsxs("form",{onSubmit:l,children:[jsxRuntime.jsxs("div",{style:{marginBottom:"8px",fontSize:"12px",color:"var(--doc-text-muted)"},children:['Selected: "',i.slice(0,50),i.length>50?"...":"",'"']}),jsxRuntime.jsx("input",{ref:a,type:"text",value:r,onChange:p=>n(p.target.value),onKeyDown:c,placeholder:s("contextMenu.customPromptPlaceholder"),style:{width:"100%",padding:"8px",border:"1px solid var(--doc-border-light)",borderRadius:"4px",fontSize:"13px"}}),jsxRuntime.jsxs("div",{style:{marginTop:"8px",display:"flex",gap:"8px",justifyContent:"flex-end"},children:[jsxRuntime.jsx("button",{type:"button",onClick:o,style:{padding:"6px 12px",border:"1px solid var(--doc-border-light)",borderRadius:"4px",background:"var(--doc-surface)",cursor:"pointer",fontSize:"12px"},children:s("common.cancel")}),jsxRuntime.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:s("common.send")})]})]})}):null},Yo=({isOpen:e,position:t,selectedText:o,selectionContext:i,onAction:r,onClose:n,actions:a=agentApi.DEFAULT_AI_ACTIONS,showCustomPrompt:s=true,className:l=""})=>{let c=Kr.useRef(null),[p,g]=Kr.useState(0),[d,m]=Kr.useState(false),{t:x}=chunkGNIO6SOS_js.b(),b=s?[...a,"custom"]:a;Kr.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]),Kr.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.length);break;case "ArrowUp":h.preventDefault(),g(P=>(P-1+b.length)%b.length);break;case "Enter":h.preventDefault();let I=b[p];I==="custom"?m(true):(r(I),n());break}};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[e,p,b,r,n,d]),Kr.useEffect(()=>{e&&(g(0),m(false));},[e]);let f=Kr.useCallback(()=>{let h=b.length*36+16,I=t.x,P=t.y;return typeof window<"u"&&(I+200>window.innerWidth&&(I=window.innerWidth-200-10),P+h>window.innerHeight&&(P=window.innerHeight-h-10),I<10&&(I=10),P<10&&(P=10)),{position:"fixed",top:P,left:I,minWidth:200,background:"var(--doc-surface)",border:"1px solid var(--doc-border-light)",borderRadius:"8px",boxShadow:"0 2px 10px var(--doc-shadow)",zIndex:chunk7VWJSV3T_js.h.contextMenu,padding:"4px 0",overflow:"hidden"}},[t,b.length]),k=u=>{u==="custom"?m(true):(r(u),n());},T=u=>{r("custom",u),n();};return !e||!o?null:jsxRuntime.jsxs("div",{ref:c,className:`docx-context-menu ${l}`,style:f(),role:"menu","aria-label":x("contextMenu.ariaLabel"),children:[jsxRuntime.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?"...":"",'"']}),jsxRuntime.jsx("div",{role:"group",children:b.map((u,h)=>jsxRuntime.jsx(zo,{action:u,onClick:()=>k(u),isHighlighted:h===p,onMouseEnter:()=>g(h)},u))}),s&&jsxRuntime.jsx(Wo,{isOpen:d,onSubmit:T,onClose:()=>m(false),selectedText:o})]})};function Uo(){let[e,t]=Kr.useState(false),[o,i]=Kr.useState({x:0,y:0}),[r,n]=Kr.useState(""),[a,s]=Kr.useState(),l=Kr.useCallback((p,g,d)=>{p.preventDefault(),i({x:p.clientX,y:p.clientY}),n(g),s(d),t(true);},[]),c=Kr.useCallback(()=>{t(false);},[]);return {isOpen:e,position:o,selectedText:r,selectionContext:a,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 [...agentApi.DEFAULT_AI_ACTIONS]}function Go(){return ["askAI","rewrite","expand","summarize","translate","explain","fixGrammar","makeFormal","makeCasual","custom"]}var Ho=()=>jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M3 8l4 4 6-8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),Ve=()=>jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})}),Ko=()=>jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.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"}),jsxRuntime.jsx("path",{d:"M13 2v4h-4M3 14v-4h4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),jo=()=>jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M11 2l3 3-9 9H2v-3l9-9z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Zo=()=>jsxRuntime.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:[jsxRuntime.jsx("circle",{cx:"10",cy:"10",r:"8",stroke:"var(--doc-border)",strokeWidth:"2",fill:"none"}),jsxRuntime.jsx("path",{d:"M10 2a8 8 0 018 8",stroke:"var(--doc-primary)",strokeWidth:"2",strokeLinecap:"round",fill:"none"}),jsxRuntime.jsx("style",{children:`
|
|
1
|
+
'use strict';var chunk7VWJSV3T_js=require('./chunk-7VWJSV3T.js'),chunk74OM4KEH_js=require('./chunk-74OM4KEH.js'),chunkPSBO3UDN_js=require('./chunk-PSBO3UDN.js'),chunkNIBCC7WQ_js=require('./chunk-NIBCC7WQ.js'),chunkWNWY6WX7_js=require('./chunk-WNWY6WX7.js'),chunkGWXEFL3H_js=require('./chunk-GWXEFL3H.js'),chunkL4MDZW2J_js=require('./chunk-L4MDZW2J.js'),chunkQD7BVJV3_js=require('./chunk-QD7BVJV3.js'),chunkGNIO6SOS_js=require('./chunk-GNIO6SOS.js');require('./chunk-BJ5RZW6Y.js');var Kr=require('react'),agentApi=require('@sqren/docx-editor-core/types/agentApi'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var Kr__default=/*#__PURE__*/_interopDefault(Kr);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=()=>jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("circle",{cx:"8",cy:"8",r:"7",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M8 4v4M8 10v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),Lo=()=>jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M13 3L3 13M3 3h4v4M13 13h-4v-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Ro=()=>jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M8 3v10M3 8h10",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),Eo=()=>jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M3 4h10M3 8h7M3 12h4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),Do=()=>jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("path",{d:"M2 3h6M5 3v6M3 5c0 2 1 4 2 4s2-2 2-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),jsxRuntime.jsx("path",{d:"M9 7l3 6M15 7l-3 6M10 11h4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),Ao=()=>jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.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"}),jsxRuntime.jsx("circle",{cx:"8",cy:"12",r:"0.5",fill:"currentColor"})]}),Mo=()=>jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("path",{d:"M4 12l3-8 3 8M5 10h4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx("path",{d:"M12 6l2 2-2 2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),Oo=()=>jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M6 7h4M6 9h4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),_o=()=>jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("circle",{cx:"8",cy:"8",r:"5",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M6 9c.5.5 1 1 2 1s1.5-.5 2-1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),jsxRuntime.jsx("circle",{cx:"6",cy:"7",r:"0.5",fill:"currentColor"}),jsxRuntime.jsx("circle",{cx:"10",cy:"7",r:"0.5",fill:"currentColor"})]}),Bo=()=>jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M12 4L4 12M4 4l8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function No(e){switch(e){case "askAI":return jsxRuntime.jsx(Po,{});case "rewrite":return jsxRuntime.jsx(Lo,{});case "expand":return jsxRuntime.jsx(Ro,{});case "summarize":return jsxRuntime.jsx(Eo,{});case "translate":return jsxRuntime.jsx(Do,{});case "explain":return jsxRuntime.jsx(Ao,{});case "fixGrammar":return jsxRuntime.jsx(Mo,{});case "makeFormal":return jsxRuntime.jsx(Oo,{});case "makeCasual":return jsxRuntime.jsx(_o,{});case "custom":return jsxRuntime.jsx(Bo,{});default:return null}}var zo=({action:e,onClick:t,isHighlighted:o,onMouseEnter:i})=>{let{t:r}=chunkGNIO6SOS_js.b(),n=r(Io[e]),a=agentApi.getActionDescription(e),s=No(e);return jsxRuntime.jsxs("button",{type:"button",className:`docx-context-menu-item ${o?"docx-context-menu-item-highlighted":""}`,onClick:t,onMouseEnter:i,title:a,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:[jsxRuntime.jsx("span",{style:{display:"flex",color:"var(--doc-text-muted)"},children:s}),jsxRuntime.jsx("span",{children:n})]})},Wo=({isOpen:e,onSubmit:t,onClose:o,selectedText:i})=>{let[r,n]=Kr.useState(""),a=Kr.useRef(null),{t:s}=chunkGNIO6SOS_js.b();Kr.useEffect(()=>{e&&a.current&&a.current.focus();},[e]);let l=p=>{p.preventDefault(),r.trim()&&(t(r.trim()),n(""));},c=p=>{p.key==="Escape"&&o();};return e?jsxRuntime.jsx("div",{className:"docx-custom-prompt-dialog",style:{position:"absolute",top:"100%",left:0,right:0,padding:"8px",background:"var(--doc-surface)",borderTop:"1px solid var(--doc-border)"},children:jsxRuntime.jsxs("form",{onSubmit:l,children:[jsxRuntime.jsxs("div",{style:{marginBottom:"8px",fontSize:"12px",color:"var(--doc-text-muted)"},children:['Selected: "',i.slice(0,50),i.length>50?"...":"",'"']}),jsxRuntime.jsx("input",{ref:a,type:"text",value:r,onChange:p=>n(p.target.value),onKeyDown:c,placeholder:s("contextMenu.customPromptPlaceholder"),style:{width:"100%",padding:"8px",border:"1px solid var(--doc-border-light)",borderRadius:"4px",fontSize:"13px"}}),jsxRuntime.jsxs("div",{style:{marginTop:"8px",display:"flex",gap:"8px",justifyContent:"flex-end"},children:[jsxRuntime.jsx("button",{type:"button",onClick:o,style:{padding:"6px 12px",border:"1px solid var(--doc-border-light)",borderRadius:"4px",background:"var(--doc-surface)",cursor:"pointer",fontSize:"12px"},children:s("common.cancel")}),jsxRuntime.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:s("common.send")})]})]})}):null},Yo=({isOpen:e,position:t,selectedText:o,selectionContext:i,onAction:r,onClose:n,actions:a=agentApi.DEFAULT_AI_ACTIONS,showCustomPrompt:s=true,className:l=""})=>{let c=Kr.useRef(null),[p,g]=Kr.useState(0),[d,m]=Kr.useState(false),{t:x}=chunkGNIO6SOS_js.b(),b=s?[...a,"custom"]:a;Kr.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]),Kr.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.length);break;case "ArrowUp":h.preventDefault(),g(P=>(P-1+b.length)%b.length);break;case "Enter":h.preventDefault();let I=b[p];I==="custom"?m(true):(r(I),n());break}};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[e,p,b,r,n,d]),Kr.useEffect(()=>{e&&(g(0),m(false));},[e]);let f=Kr.useCallback(()=>{let h=b.length*36+16,I=t.x,P=t.y;return typeof window<"u"&&(I+200>window.innerWidth&&(I=window.innerWidth-200-10),P+h>window.innerHeight&&(P=window.innerHeight-h-10),I<10&&(I=10),P<10&&(P=10)),{position:"fixed",top:P,left:I,minWidth:200,background:"var(--doc-surface)",border:"1px solid var(--doc-border-light)",borderRadius:"8px",boxShadow:"0 2px 10px var(--doc-shadow)",zIndex:chunk7VWJSV3T_js.h.contextMenu,padding:"4px 0",overflow:"hidden"}},[t,b.length]),k=u=>{u==="custom"?m(true):(r(u),n());},T=u=>{r("custom",u),n();};return !e||!o?null:jsxRuntime.jsxs("div",{ref:c,className:`docx-context-menu ${l}`,style:f(),role:"menu","aria-label":x("contextMenu.ariaLabel"),children:[jsxRuntime.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?"...":"",'"']}),jsxRuntime.jsx("div",{role:"group",children:b.map((u,h)=>jsxRuntime.jsx(zo,{action:u,onClick:()=>k(u),isHighlighted:h===p,onMouseEnter:()=>g(h)},u))}),s&&jsxRuntime.jsx(Wo,{isOpen:d,onSubmit:T,onClose:()=>m(false),selectedText:o})]})};function Uo(){let[e,t]=Kr.useState(false),[o,i]=Kr.useState({x:0,y:0}),[r,n]=Kr.useState(""),[a,s]=Kr.useState(),l=Kr.useCallback((p,g,d)=>{p.preventDefault(),i({x:p.clientX,y:p.clientY}),n(g),s(d),t(true);},[]),c=Kr.useCallback(()=>{t(false);},[]);return {isOpen:e,position:o,selectedText:r,selectionContext:a,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 [...agentApi.DEFAULT_AI_ACTIONS]}function Go(){return ["askAI","rewrite","expand","summarize","translate","explain","fixGrammar","makeFormal","makeCasual","custom"]}var Ho=()=>jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M3 8l4 4 6-8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),Ve=()=>jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})}),Ko=()=>jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.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"}),jsxRuntime.jsx("path",{d:"M13 2v4h-4M3 14v-4h4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),jo=()=>jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M11 2l3 3-9 9H2v-3l9-9z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Zo=()=>jsxRuntime.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:[jsxRuntime.jsx("circle",{cx:"10",cy:"10",r:"8",stroke:"var(--doc-border)",strokeWidth:"2",fill:"none"}),jsxRuntime.jsx("path",{d:"M10 2a8 8 0 018 8",stroke:"var(--doc-primary)",strokeWidth:"2",strokeLinecap:"round",fill:"none"}),jsxRuntime.jsx("style",{children:`
|
|
2
2
|
@keyframes spin {
|
|
3
3
|
from { transform: rotate(0deg); }
|
|
4
4
|
to { transform: rotate(360deg); }
|
package/dist/ui.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {h,o,b as b$1,a as a$1}from'./chunk-P6METJHI.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-P6METJHI.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-4Y4JFAPY.mjs';export{a as formatShortcutKeys}from'./chunk-O6M2HAIZ.mjs';import {a as a$2}from'./chunk-GM2S2WMT.mjs';import {b as b$2}from'./chunk-BABMU5KA.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-BABMU5KA.mjs';export{a as FindReplaceDialog}from'./chunk-OCA7BO3G.mjs';import {a}from'./chunk-OHNO4NRQ.mjs';export{b as useFindReplace}from'./chunk-OHNO4NRQ.mjs';export{d as HyperlinkDialog,m as useHyperlinkDialog}from'./chunk-J72K2BOS.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'@eigenpal/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]),a=getActionDescription(e),s=No(e);return jsxs("button",{type:"button",className:`docx-context-menu-item ${o?"docx-context-menu-item-highlighted":""}`,onClick:t,onMouseEnter:i,title:a,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:s}),jsx("span",{children:n})]})},Wo=({isOpen:e,onSubmit:t,onClose:o,selectedText:i})=>{let[r,n]=useState(""),a=useRef(null),{t:s}=b();useEffect(()=>{e&&a.current&&a.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:"var(--doc-surface)",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:a,type:"text",value:r,onChange:p=>n(p.target.value),onKeyDown:c,placeholder:s("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:"var(--doc-surface)",cursor:"pointer",fontSize:"12px"},children:s("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:s("common.send")})]})]})}):null},Yo=({isOpen:e,position:t,selectedText:o,selectionContext:i,onAction:r,onClose:n,actions:a=DEFAULT_AI_ACTIONS,showCustomPrompt:s=true,className:l=""})=>{let c=useRef(null),[p,g]=useState(0),[d,m]=useState(false),{t:x}=b(),b$1=s?[...a,"custom"]:a;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:"var(--doc-surface)",border:"1px solid var(--doc-border-light)",borderRadius:"8px",boxShadow:"0 2px 10px var(--doc-shadow)",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))}),s&&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(""),[a,s]=useState(),l=useCallback((p,g,d)=>{p.preventDefault(),i({x:p.clientX,y:p.clientY}),n(g),s(d),t(true);},[]),c=useCallback(()=>{t(false);},[]);return {isOpen:e,position:o,selectedText:r,selectionContext:a,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:`
|
|
1
|
+
import {h,o,b as b$1,a as a$1}from'./chunk-P6METJHI.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-P6METJHI.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-4Y4JFAPY.mjs';export{a as formatShortcutKeys}from'./chunk-O6M2HAIZ.mjs';import {a as a$2}from'./chunk-GM2S2WMT.mjs';import {b as b$2}from'./chunk-BABMU5KA.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-BABMU5KA.mjs';export{a as FindReplaceDialog}from'./chunk-OCA7BO3G.mjs';import {a}from'./chunk-OHNO4NRQ.mjs';export{b as useFindReplace}from'./chunk-OHNO4NRQ.mjs';export{d as HyperlinkDialog,m as useHyperlinkDialog}from'./chunk-J72K2BOS.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'@sqren/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]),a=getActionDescription(e),s=No(e);return jsxs("button",{type:"button",className:`docx-context-menu-item ${o?"docx-context-menu-item-highlighted":""}`,onClick:t,onMouseEnter:i,title:a,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:s}),jsx("span",{children:n})]})},Wo=({isOpen:e,onSubmit:t,onClose:o,selectedText:i})=>{let[r,n]=useState(""),a=useRef(null),{t:s}=b();useEffect(()=>{e&&a.current&&a.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:"var(--doc-surface)",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:a,type:"text",value:r,onChange:p=>n(p.target.value),onKeyDown:c,placeholder:s("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:"var(--doc-surface)",cursor:"pointer",fontSize:"12px"},children:s("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:s("common.send")})]})]})}):null},Yo=({isOpen:e,position:t,selectedText:o,selectionContext:i,onAction:r,onClose:n,actions:a=DEFAULT_AI_ACTIONS,showCustomPrompt:s=true,className:l=""})=>{let c=useRef(null),[p,g]=useState(0),[d,m]=useState(false),{t:x}=b(),b$1=s?[...a,"custom"]:a;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:"var(--doc-surface)",border:"1px solid var(--doc-border-light)",borderRadius:"8px",boxShadow:"0 2px 10px var(--doc-shadow)",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))}),s&&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(""),[a,s]=useState(),l=useCallback((p,g,d)=>{p.preventDefault(),i({x:p.clientX,y:p.clientY}),n(g),s(d),t(true);},[]),c=useCallback(()=>{t(false);},[]);return {isOpen:e,position:o,selectedText:r,selectionContext:a,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
2
|
@keyframes spin {
|
|
3
3
|
from { transform: rotate(0deg); }
|
|
4
4
|
to { transform: rotate(360deg); }
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React__default, { CSSProperties, ReactNode } from 'react';
|
|
2
|
-
import { Table } from '@
|
|
3
|
-
import { FindMatch, FindOptions } from '@
|
|
2
|
+
import { Table } from '@sqren/docx-editor-core/types/document';
|
|
3
|
+
import { FindMatch, FindOptions } from '@sqren/docx-editor-core/utils/findReplace';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* TableToolbar Component
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React__default, { CSSProperties, ReactNode } from 'react';
|
|
2
|
-
import { Table } from '@
|
|
3
|
-
import { FindMatch, FindOptions } from '@
|
|
2
|
+
import { Table } from '@sqren/docx-editor-core/types/document';
|
|
3
|
+
import { FindMatch, FindOptions } from '@sqren/docx-editor-core/utils/findReplace';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* TableToolbar Component
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sqren/docx-editor-react",
|
|
3
|
-
"version": "1.7.0-fork.
|
|
3
|
+
"version": "1.7.0-fork.1",
|
|
4
4
|
"description": "React DOCX editor adapter for @eigenpal/docx-editor-core.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -92,9 +92,9 @@
|
|
|
92
92
|
}
|
|
93
93
|
},
|
|
94
94
|
"dependencies": {
|
|
95
|
-
"@
|
|
96
|
-
"@
|
|
97
|
-
"@
|
|
95
|
+
"@sqren/docx-editor-agents": "1.7.0-fork.1",
|
|
96
|
+
"@sqren/docx-editor-core": "1.7.0-fork.1",
|
|
97
|
+
"@sqren/docx-editor-i18n": "1.7.0-fork.1",
|
|
98
98
|
"@radix-ui/react-select": "^2.2.6",
|
|
99
99
|
"clsx": "^2.1.0",
|
|
100
100
|
"sonner": "^2.0.7"
|