efficient-shell 7.21.1 → 7.22.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/README.md +47 -0
- package/dist/{Browser-XPRHVZJS.js → Browser-CHVGSLN7.js} +15 -15
- package/dist/Calculator-RKOELZ6W.js +29 -0
- package/dist/ConfirmDialog-JSVEON35.js +1 -0
- package/dist/{CurrencyConverter-MELIA5ZN.js → CurrencyConverter-PLQ664ZV.js} +9 -9
- package/dist/{Documents-BC5M2PBJ.js → Documents-CKQCMALX.js} +15 -15
- package/dist/{Files-AOQNEOZ7.js → Files-XSUFZ7ZR.js} +79 -79
- package/dist/{Notepad-DWVT66EF.js → Notepad-3EGD2WCN.js} +11 -11
- package/dist/PdfViewer-VIX2NDCO.js +1 -0
- package/dist/PomodoroTimer-N7L7HBYO.js +91 -0
- package/dist/{Preview-7LYC662F.js → Preview-RRXQS5BI.js} +29 -29
- package/dist/Sidebar-77VZQLKP.js +44 -0
- package/dist/{Spreadsheet-PDA4JIJ6.js → Spreadsheet-X677FCIY.js} +12 -12
- package/dist/{Stock-44LXLO2A.js → Stock-UOPST3LH.js} +7 -7
- package/dist/{Weather-TCGDUHYK.js → Weather-HXZK2AYT.js} +17 -17
- package/dist/{WorldClock-GIRESICQ.js → WorldClock-MCDW7P6Q.js} +4 -4
- package/dist/apps/index.js +1 -1
- package/dist/bin/ui-check.js +1 -1
- package/dist/brand.css +1 -1
- package/dist/chunk-4EIZZYLK.js +1 -0
- package/dist/{chunk-2GJNH4XW.js → chunk-4M7DEG4E.js} +50 -50
- package/dist/chunk-5VNBEMZQ.js +1 -0
- package/dist/{chunk-RBKIYZ7H.js → chunk-6J7HKGHL.js} +1 -1
- package/dist/{chunk-ITCBLL72.js → chunk-AKEMYW3H.js} +2 -2
- package/dist/{chunk-Z2TTHY7G.js → chunk-ARB5MUWA.js} +1 -1
- package/dist/{chunk-BVYOUFSW.js → chunk-AV5XPUKR.js} +9 -9
- package/dist/{chunk-ZGUQLVY4.js → chunk-B427NVDP.js} +28 -12
- package/dist/{chunk-RN3NG35J.js → chunk-BZD3UC4R.js} +1 -1
- package/dist/{chunk-BQ7GR7H6.js → chunk-E7WPTZE3.js} +11 -11
- package/dist/{chunk-RUHUTZN4.js → chunk-EA7QO447.js} +1 -1
- package/dist/{chunk-JQRIAZDP.js → chunk-FM6TPY42.js} +30 -30
- package/dist/{chunk-SCJT2XXU.js → chunk-FS27CODA.js} +1 -1
- package/dist/{chunk-IQDY2YFN.js → chunk-GNW45MGV.js} +10 -10
- package/dist/{chunk-G3WYQP4R.js → chunk-J65OSKCY.js} +523 -518
- package/dist/chunk-K7PQXJO7.js +1 -0
- package/dist/{chunk-GNCH3JEH.js → chunk-MBHQQFSZ.js} +7 -7
- package/dist/{chunk-2QC3VXCS.js → chunk-MRE4Y2YJ.js} +1 -1
- package/dist/{chunk-7HLTPMQV.js → chunk-MZHH3MC7.js} +1 -1
- package/dist/{chunk-M4TRVJTO.js → chunk-N2OO2ZYF.js} +1 -1
- package/dist/{chunk-B4PGVDB6.js → chunk-OALCYDHN.js} +1 -1
- package/dist/{chunk-XM2IIPJO.js → chunk-OFHMRWST.js} +1 -1
- package/dist/{chunk-FTJ2G343.js → chunk-ONDFYXHG.js} +13 -13
- package/dist/{chunk-VOFDPOB6.js → chunk-RVPQRXC4.js} +1 -1
- package/dist/{chunk-IJ7RXIWX.js → chunk-SZTKBF3D.js} +8 -8
- package/dist/{chunk-KBOYLXAT.js → chunk-TTUVL25O.js} +1 -1
- package/dist/{chunk-76VCH7N6.js → chunk-XFE43ZU5.js} +19 -19
- package/dist/{chunk-XN7CAWSZ.js → chunk-Y6UUDJNU.js} +2 -2
- package/dist/{chunk-JUISSKJW.js → chunk-Y7T3OW2A.js} +1 -1
- package/dist/{chunk-ZRU5F2XT.js → chunk-ZMQ3GBEX.js} +4 -4
- package/dist/{chunk-GIWC2ZTG.js → chunk-ZU47TGM3.js} +2 -2
- package/dist/file-intake/index.js +1 -1
- package/dist/i18n/index.d.ts +1 -1
- package/dist/icons/efficient-looks.js +189 -177
- package/dist/icons/efficient.d.ts +16 -1
- package/dist/icons/efficient.js +92 -86
- package/dist/icons/index.d.ts +1 -1
- package/dist/icons/index.js +1 -1
- package/dist/{index-DbNqOkOy.d.ts → index-CMwbvwiY.d.ts} +73 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +113 -113
- package/dist/locales/zh-Hans.d.ts +1 -1
- package/dist/locales/zh-Hans.js +1 -1
- package/dist/map/index.js +8 -8
- package/dist/markdown/index.js +1 -1
- package/dist/page-tabs/index.js +5 -5
- package/dist/pdf/index.js +1 -1
- package/dist/{strings-BQtq9300.d.ts → strings-BfHOx-Bl.d.ts} +26 -0
- package/dist/telemetry/index.js +1 -1
- package/dist/themes.css +20 -20
- package/dist/ui/index.d.ts +2 -2
- package/dist/ui/index.js +1 -1
- package/dist/ui.css +122 -7
- package/package.json +1 -1
- package/dist/Calculator-BLKI5RDH.js +0 -29
- package/dist/ConfirmDialog-AVFQGXKL.js +0 -1
- package/dist/PdfViewer-PHABUM7K.js +0 -1
- package/dist/PomodoroTimer-RHJHTLSU.js +0 -91
- package/dist/Sidebar-PYURV2S2.js +0 -44
- package/dist/chunk-IDJPDSA3.js +0 -1
- package/dist/chunk-JTNKC4CR.js +0 -1
- package/dist/chunk-QRCDQPJA.js +0 -1
package/README.md
CHANGED
|
@@ -447,6 +447,53 @@ chooses; on a link Enter follows it, and so does Space. Escape closes the menu
|
|
|
447
447
|
and gives focus back to the trigger, and so does Tab. A click elsewhere closes
|
|
448
448
|
it and leaves focus where you clicked.
|
|
449
449
|
|
|
450
|
+
### The text toolbar
|
|
451
|
+
|
|
452
|
+
`TextToolbar` is the one text toolbar of every rich text box: over a text box
|
|
453
|
+
in a settings panel, or floating above words typed on an editor's canvas (in a
|
|
454
|
+
`FloatingBar`). It was folded in from `efficient-easel`, and draws Lewis's
|
|
455
|
+
final design of 2026-10-06:
|
|
456
|
+
|
|
457
|
+
Row 1, the words: B · I · U · S · Color · Link · Superscript · Subscript · (the host's)
|
|
458
|
+
Row 2, the paragraph: Left · Center · Right · Justify · Bulleted · Numbered · Aa · AA · aa
|
|
459
|
+
|
|
460
|
+
```tsx
|
|
461
|
+
import { TextToolbar } from 'efficient-shell/ui';
|
|
462
|
+
|
|
463
|
+
<TextToolbar
|
|
464
|
+
offered={new Set(['bold', 'italic', 'link', 'bullet'])}
|
|
465
|
+
pressed={{ bold: true }}
|
|
466
|
+
onMark={applyMark}
|
|
467
|
+
alignment={{ value: align, allow: ['left', 'center', 'right'], onChange: setAlign }}
|
|
468
|
+
list={{ pressed: null, onList: setList }}
|
|
469
|
+
letterCase={{ value: textCase, onChange: setCase }}
|
|
470
|
+
windows={linkOpen ? <LinkWindow … /> : null}
|
|
471
|
+
/>
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
**What it draws is what the host offers.** A tool not offered is not drawn,
|
|
475
|
+
a row with nothing in it is not drawn, and with neither row there is no
|
|
476
|
+
toolbar (`textToolbarRows` says which, so a host leaves no empty frame). Two
|
|
477
|
+
rows on one 9-column grid, flush to the box at both ends; ONE row when the
|
|
478
|
+
word tools, a gap and the paragraph tools fit nine cells; and when they do not
|
|
479
|
+
but the word tools leave room, one grid that flows nine cells a line. The
|
|
480
|
+
host's own control takes row 1's 9th cell (`last`); with none, row 1 is eight
|
|
481
|
+
buttons spread over the row. A narrow box (under 268px) draws the buttons a
|
|
482
|
+
size down; it never wraps.
|
|
483
|
+
|
|
484
|
+
**Presses keep the caret.** Every button prevents its mousedown, so a press
|
|
485
|
+
never takes the selection out of the words it acts on. Each button is an
|
|
486
|
+
`IconButton` with its name as its accessible name and its `Tooltip`; the names
|
|
487
|
+
are the shell's words (`textToolbar`). The alignment and the letter case are
|
|
488
|
+
radiogroups with one Tab stop and arrow keys; pressing the lit case again
|
|
489
|
+
takes the case off. `color.run` fills the A with the colour the words wear.
|
|
490
|
+
|
|
491
|
+
**The wrapper is public.** `.rosh-tb-wrap` is the size container. Its direct
|
|
492
|
+
children carry `--rosh-tb-size`, `--rosh-tb-steps`, `--rosh-tb-color-col` and
|
|
493
|
+
`--rosh-tb-link-col`, so a host's colour and link windows, drawn inside it
|
|
494
|
+
through `windows`, can point at their buttons. Being a size container, it
|
|
495
|
+
takes its width from where it is put: in a shrink-to-fit place, give it one.
|
|
496
|
+
|
|
450
497
|
### Popovers
|
|
451
498
|
|
|
452
499
|
`Popover` is a button and the panel it opens, right under it, for anything
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import{peekBrowserStartUrl as e,claimBrowserStartUrl as t}from"./chunk-LWLCNQY7.js";import{AboutApp as o}from"./chunk-
|
|
1
|
+
import{peekBrowserStartUrl as e,claimBrowserStartUrl as t}from"./chunk-LWLCNQY7.js";import{AboutApp as o}from"./chunk-BZD3UC4R.js";import{WindowTitle as r}from"./chunk-4M7DEG4E.js";import"./chunk-DSSLOQDW.js";import"./chunk-FS27CODA.js";import"./chunk-ZMQ3GBEX.js";import"./chunk-5A7MWTXX.js";import"./chunk-SZTKBF3D.js";import{confirm as a}from"./chunk-XFE43ZU5.js";import"./chunk-GNW45MGV.js";import"./chunk-UVBK6YSR.js";import"./chunk-K7PQXJO7.js";import"./chunk-7IQ3B77H.js";import"./chunk-FIEA5CGB.js";import"./chunk-D65T4H6J.js";import"./chunk-5VNBEMZQ.js";import"./chunk-KNUR2UEG.js";import"./chunk-4EIZZYLK.js";import"./chunk-C3QOHMR6.js";import{Icon as n}from"./chunk-B427NVDP.js";import{useRef as s,useEffect as l,useState as i}from"react";import{jsxs as c,jsx as m,Fragment as d}from"react/jsx-runtime";var u="react-os-shell:browser-bookmarks",h="react-os-shell:browser-homepage",p="https://en.wikipedia.org/wiki/Main_Page",g=[{label:"Wikipedia",url:"https://en.wikipedia.org/wiki/Main_Page"},{label:"DevDocs",url:"https://devdocs.io"},{label:"Example",url:"https://example.com"}],b=new Set(["ac ad ae af ag ai al am ao aq ar as at au aw ax az ba bb bd be bf bg bh bi","bj bm bn bo br bs bt bw by bz ca cc cd cf cg ch ci ck cl cm cn co cr cu cv","cw cx cy cz de dj dk dm do dz ec ee eg er es et eu fi fj fk fm fo fr ga gd","ge gf gg gh gi gl gm gn gp gq gr gs gt gu gw gy hk hm hn hr ht hu id ie il","im in io iq ir is it je jm jo jp ke kg kh ki km kn kp kr kw ky kz la lb lc","li lk lr ls lt lu lv ly ma mc md me mg mh mk ml mm mn mo mp mq mr ms mt mu","mv mw mx my mz na nc ne nf ng ni nl no np nr nu nz om pa pe pf pg ph pk pl","pm pn pr ps pt pw py qa re ro rs ru rw sa sb sc sd se sg sh si sk sl sm sn","so sr ss st su sv sx sy sz tc td tf tg th tj tk tl tm tn to tr tt tv tw tz","ua ug uk us uy uz va vc ve vg vi vn vu wf ws ye yt za zm zw","com net org edu gov mil int info biz name pro app dev xyz online site tech","store shop cloud design digital agency studio media news blog live life","world today email systems solutions services software page link space host","press wiki team group works careers finance capital energy academy"].join(" ").split(" "));function f(e){let t=e.trim();return t?/^[a-z][a-z0-9+.-]*:\/\//i.test(t)?t:function(e){const t=/^([\w-]+\.)+([a-z]{2,})(\/.*)?$/i.exec(e);return null!==t&&b.has(t[2].toLowerCase())}(t)?"https://"+t:"https://duckduckgo.com/?q="+encodeURIComponent(t):""}var k=["duckduckgo.com","developer.mozilla.org","google.com","gmail.com","youtube.com","facebook.com","instagram.com","whatsapp.com","twitter.com","x.com","github.com","gitlab.com","linkedin.com","reddit.com","pinterest.com","amazon.com","amazon.ca","amazon.co.uk","apple.com","icloud.com","microsoft.com","outlook.com","live.com","office.com","netflix.com","spotify.com","paypal.com","stripe.com","chat.openai.com","chatgpt.com","claude.ai"];function x(){if("undefined"==typeof window)return g;try{const e=localStorage.getItem(u);if(!e)return g;const t=JSON.parse(e);if(Array.isArray(t)&&t.every(e=>"string"==typeof e?.url))return t}catch{}return g}function w(){return"undefined"==typeof window?p:localStorage.getItem(h)||p}function y(){const d=s(void 0);void 0===d.current&&(d.current=e()),l(()=>{null!=d.current&&t(d.current)},[]);const p=d.current?f(d.current.url):"",[g,b]=i(w),[k,y]=i(p||g),[j,C]=i(k),[z,S]=i([k]),[E,W]=i(0),[R,D]=i(0),[L,B]=i(x),[U,H]=i(!1),[M,O]=i(null),G=s(null),I=s(null);l(()=>{try{localStorage.setItem(u,JSON.stringify(L))}catch{}},[L]);const T=e=>{const t=f(e);t&&(y(t),C(t),S(e=>{const o=e.slice(0,E+1);return o.push(t),o}),W(e=>e+1),H(!1))},F=()=>{"undefined"!=typeof window&&window.open(k,"_blank","noopener,noreferrer")},K=()=>{const e=M?.trim();e?(B(t=>[...t,{label:e,url:k}]),O(null)):O(null)};l(()=>{if(null===M)return;G.current?.focus(),G.current?.select();const e=e=>{const t=e.target;t?.closest("[data-bookmark-popover]")||O(null)},t=setTimeout(()=>document.addEventListener("mousedown",e),0);return()=>{clearTimeout(t),document.removeEventListener("mousedown",e)}},[null!==M]);const P=e=>{B(t=>t.filter((t,o)=>o!==e))},Q=E>0,X=E<z.length-1,Z=L.some(e=>e.url===k),q="p-2 rounded hover:bg-gray-200 transition-colors text-gray-600 disabled:opacity-30";/* @__PURE__ */
|
|
2
2
|
return c("div",{className:"relative flex flex-col h-full bg-white",children:[
|
|
3
3
|
/* @__PURE__ */m(r,{title:`Browser - ${v(k)}`}),
|
|
4
4
|
/* @__PURE__ */m(o,{app:"browser"}),
|
|
5
5
|
/* @__PURE__ */c("div",{className:"flex items-center gap-1 px-2 py-2 border-b border-gray-200 bg-gray-50 shrink-0",children:[
|
|
6
|
-
/* @__PURE__ */m("button",{onClick:()=>{if(
|
|
7
|
-
/* @__PURE__ */m("button",{onClick:()=>{if(
|
|
8
|
-
/* @__PURE__ */m("button",{onClick:()=>
|
|
9
|
-
/* @__PURE__ */m("button",{onClick:()=>
|
|
10
|
-
/* @__PURE__ */m("form",{onSubmit:e=>{e.preventDefault(),
|
|
6
|
+
/* @__PURE__ */m("button",{onClick:()=>{if(E>0){const e=E-1;W(e),y(z[e]),C(z[e]),H(!1)}},disabled:!Q,className:q,title:"Back",children:/* @__PURE__ */m(n,{name:"chevron-left",className:"h-4 w-4",strokeWidth:2})}),
|
|
7
|
+
/* @__PURE__ */m("button",{onClick:()=>{if(E<z.length-1){const e=E+1;W(e),y(z[e]),C(z[e]),H(!1)}},disabled:!X,className:q,title:"Forward",children:/* @__PURE__ */m(n,{name:"chevron-right",className:"h-4 w-4",strokeWidth:2})}),
|
|
8
|
+
/* @__PURE__ */m("button",{onClick:()=>D(e=>e+1),className:q,title:"Refresh",children:/* @__PURE__ */m(n,{name:"refresh",className:"h-4 w-4",strokeWidth:1.8})}),
|
|
9
|
+
/* @__PURE__ */m("button",{onClick:()=>T(g),className:q,title:"Home",children:/* @__PURE__ */m(n,{name:"home",className:"h-4 w-4",strokeWidth:1.8})}),
|
|
10
|
+
/* @__PURE__ */m("form",{onSubmit:e=>{e.preventDefault(),T(j)},className:"flex-1 flex items-center mx-1",children:/* @__PURE__ */c("div",{className:"flex items-center w-full bg-white border border-gray-300 rounded focus-within:border-blue-400 focus-within:ring-1 focus-within:ring-blue-200",children:[
|
|
11
11
|
/* @__PURE__ */m("span",{className:"px-2 text-gray-400 text-xs",children:k.startsWith("https://")?"🔒":"⚠️"}),
|
|
12
|
-
/* @__PURE__ */m("input",{type:"text",value:
|
|
13
|
-
/* @__PURE__ */m("button",{"data-bookmark-popover":!0,onClick:()=>
|
|
14
|
-
/* @__PURE__ */m("button",{onClick:
|
|
15
|
-
/* @__PURE__ */m("button",{onClick:()=>
|
|
12
|
+
/* @__PURE__ */m("input",{type:"text",value:j,onChange:e=>C(e.target.value),onFocus:e=>e.target.select(),className:"flex-1 px-1 py-1 text-sm bg-transparent outline-none font-mono",spellCheck:!1,placeholder:"Enter URL or search…"}),k!==j&&/* @__PURE__ */m("button",{type:"button",onClick:()=>C(k),className:"px-2 text-2xs text-gray-400 hover:text-gray-700",title:"Reset to current URL",children:"×"})]})}),
|
|
13
|
+
/* @__PURE__ */m("button",{"data-bookmark-popover":!0,onClick:()=>Z?P(L.findIndex(e=>e.url===k)):void O(v(k)),className:q+" "+(Z?"text-yellow-500":""),title:Z?"Remove bookmark":"Add bookmark",children:/* @__PURE__ */m(n,{name:"star",className:"h-4 w-4",fill:Z?"currentColor":"none",strokeWidth:1.5})}),
|
|
14
|
+
/* @__PURE__ */m("button",{onClick:F,className:q,title:"Open in new tab",children:/* @__PURE__ */m(n,{name:"external",className:"h-4 w-4",strokeWidth:1.5})}),
|
|
15
|
+
/* @__PURE__ */m("button",{onClick:()=>H(e=>!e),className:q,title:"Embedding help",children:/* @__PURE__ */m(n,{name:"help",className:"h-4 w-4",strokeWidth:1.5})})]}),null!==M&&/* @__PURE__ */c("div",{"data-bookmark-popover":!0,className:"absolute right-3 top-12 z-30 w-72 bg-white border border-gray-200 rounded-md shadow-lg p-3",children:[
|
|
16
16
|
/* @__PURE__ */m("div",{className:"text-2xs font-semibold uppercase tracking-wide text-gray-500 mb-1",children:"Bookmark this page"}),
|
|
17
17
|
/* @__PURE__ */m("div",{className:"text-2xs text-gray-400 truncate mb-2 font-mono",title:k,children:k}),
|
|
18
|
-
/* @__PURE__ */m("input",{ref:
|
|
18
|
+
/* @__PURE__ */m("input",{ref:G,type:"text",value:M,onChange:e=>O(e.target.value),onKeyDown:e=>{"Enter"===e.key?K():"Escape"===e.key&&O(null)},placeholder:"Name",className:"w-full text-sm px-2 h-8 border border-gray-300 rounded focus:outline-none focus:border-blue-400 focus:ring-1 focus:ring-blue-200"}),
|
|
19
19
|
/* @__PURE__ */c("div",{className:"flex justify-end gap-1 mt-2",children:[
|
|
20
|
-
/* @__PURE__ */m("button",{onClick:()=>
|
|
21
|
-
/* @__PURE__ */m("button",{onClick:
|
|
22
|
-
/* @__PURE__ */c("div",{className:"flex items-center gap-0.5 px-2 py-1 border-b border-gray-200 bg-white shrink-0 overflow-x-auto",children:[0===
|
|
20
|
+
/* @__PURE__ */m("button",{onClick:()=>O(null),className:"px-2 py-1 text-xs text-gray-600 hover:bg-gray-100 rounded",children:"Cancel"}),
|
|
21
|
+
/* @__PURE__ */m("button",{onClick:K,disabled:!M.trim(),className:"px-2 py-1 text-xs bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-40",children:"Save"})]})]}),
|
|
22
|
+
/* @__PURE__ */c("div",{className:"flex items-center gap-0.5 px-2 py-1 border-b border-gray-200 bg-white shrink-0 overflow-x-auto",children:[0===L.length&&/* @__PURE__ */m("span",{className:"text-2xs text-gray-400 italic px-2",children:"No bookmarks yet — star the address bar to add one."}),L.map((e,t)=>/* @__PURE__ */c("button",{onClick:()=>T(e.url),onContextMenu:async o=>{o.preventDefault();await a({title:"Remove bookmark",message:`"${e.label}" will be removed from your bookmarks.`,confirmLabel:"Remove",variant:"danger"})&&P(t)},className:"flex items-center gap-2 px-2 py-0.5 rounded text-xs text-gray-700 hover:bg-gray-100 whitespace-nowrap",title:`${e.url}\n(right-click to remove)`,children:[
|
|
23
23
|
/* @__PURE__ */m("img",{src:`https://icons.duckduckgo.com/ip3/${new URL(e.url).hostname}.ico`,alt:"",className:"h-3.5 w-3.5",onError:e=>{e.target.style.visibility="hidden"}}),e.label]},t)),
|
|
24
24
|
/* @__PURE__ */m("div",{className:"flex-1"}),
|
|
25
25
|
/* @__PURE__ */m("button",{onClick:()=>{b(k);try{localStorage.setItem(h,k)}catch{}},className:"px-2 py-0.5 text-2xs text-gray-500 hover:text-gray-800",title:"Set current page as homepage",children:"Set as home"})]}),
|
|
26
|
-
/* @__PURE__ */m("div",{className:"flex-1 relative min-h-0 bg-gray-50",children:/* @__PURE__ */m(N,{url:k,iframeKey:
|
|
26
|
+
/* @__PURE__ */m("div",{className:"flex-1 relative min-h-0 bg-gray-50",children:/* @__PURE__ */m(N,{url:k,iframeKey:R,iframeRef:I,openExternal:F,showHelp:U,dismissHelp:()=>H(!1)})})]})}function v(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function N({url:e,iframeKey:t,iframeRef:o,openExternal:r,showHelp:a,dismissHelp:s}){const[u,h]=i(!1);l(()=>{h(!1)},[e]);return function(e){try{const t=new URL(e).hostname.toLowerCase();return k.some(e=>t===e||t.endsWith("."+e))}catch{return!1}}(e)&&!u?/* @__PURE__ */m("div",{className:"absolute inset-0 flex items-center justify-center bg-white p-8",children:/* @__PURE__ */c("div",{className:"max-w-md text-center",children:[
|
|
27
27
|
/* @__PURE__ */m(n,{name:"no-symbol",className:"h-14 w-14 mx-auto text-gray-300 mb-3",strokeWidth:1.2}),
|
|
28
28
|
/* @__PURE__ */c("h3",{className:"text-base font-semibold text-gray-800 mb-1",children:[v(e)," can't be embedded"]}),
|
|
29
29
|
/* @__PURE__ */c("p",{className:"text-sm text-gray-500 mb-4",children:["This site sends an ",
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import{loadAppearance as e,WidgetSettingsModal as t}from"./chunk-Y7T3OW2A.js";import{useWidgetSettings as n}from"./chunk-4M7DEG4E.js";import"./chunk-DSSLOQDW.js";import"./chunk-FS27CODA.js";import"./chunk-ZMQ3GBEX.js";import"./chunk-5A7MWTXX.js";import"./chunk-SZTKBF3D.js";import"./chunk-XFE43ZU5.js";import"./chunk-GNW45MGV.js";import"./chunk-UVBK6YSR.js";import"./chunk-K7PQXJO7.js";import"./chunk-7IQ3B77H.js";import"./chunk-FIEA5CGB.js";import"./chunk-D65T4H6J.js";import"./chunk-KNUR2UEG.js";import"./chunk-4EIZZYLK.js";import"./chunk-C3QOHMR6.js";import{Icon as r}from"./chunk-B427NVDP.js";import{useState as l,useRef as c,useCallback as i,useEffect as a}from"react";import{jsxs as o,Fragment as s,jsx as u}from"react/jsx-runtime";var d="calc_appearance";function h(){const[h,m]=l("0"),[b,k]=l(null),[p,g]=l(null),[y,N]=l(!1),[x,f]=l(""),[v,C]=l([]),[$,j]=l(!1),[E,w]=l(()=>e(d)),[S,T]=l(!1),[B,D]=l(E),F=c(null);n(i(()=>{D({...E}),T(!0)},[E]));const W=i(e=>{f(""),m(t=>y||"0"===t?(N(!1),"."===e?"0.":e):"."===e&&t.includes(".")?t:t+e)},[y]),A=i(()=>{m("0"),k(null),g(null),N(!1)},[]),O=i((e,t,n)=>{switch(n){case"+":return e+t;case"-":return e-t;case"×":return e*t;case"÷":return 0===t?0:e/t;default:return t}},[]),G=i(e=>{const t=parseFloat(h);if(null!==b&&p&&!y){const e=O(b,t,p);m(String(e)),k(e),C(n=>[`${b} ${p} ${t} = ${e}`,...n].slice(0,20))}else k(t);g(e),N(!0)},[h,b,p,y,O]),M=i(()=>{if(null===b||!p)return;const e=parseFloat(h),t=O(b,e,p),n=`${b} ${p} ${e} =`;C(e=>[`${n} ${t}`,...e].slice(0,20)),f(n),m(String(t)),k(null),g(null),N(!0)},[h,b,p,O]),X=i(()=>{m(e=>String(parseFloat(e)/100))},[]),I=i(()=>{m(e=>e.startsWith("-")?e.slice(1):"0"===e?e:"-"+e)},[]);a(()=>{const e=e=>{const t=e.target.tagName;"INPUT"!==t&&"TEXTAREA"!==t&&"SELECT"!==t&&(e.key>="0"&&e.key<="9"?W(e.key):"."===e.key?W("."):"+"===e.key?G("+"):"-"===e.key?G("-"):"*"===e.key?G("×"):"/"===e.key?(e.preventDefault(),G("÷")):"Enter"===e.key||"="===e.key?("Enter"===e.key&&e.target instanceof Node&&F.current?.contains(e.target)&&e.preventDefault(),M()):"Escape"===e.key?A():"Backspace"===e.key?m(e=>e.length>1?e.slice(0,-1):"0"):"%"===e.key&&X())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[W,G,M,A,X]);const K="flex items-center justify-center rounded-lg text-sm font-medium transition-colors",L=`${K} bg-white border border-gray-200 text-gray-900 hover:bg-gray-50 active:bg-gray-100`,Q=`${K} bg-blue-50 border border-blue-200 text-blue-700 hover:bg-blue-100 active:bg-blue-200`,U=`${K} bg-gray-100 border border-gray-200 text-gray-600 hover:bg-gray-200 active:bg-gray-300`,Z=`${K} bg-blue-600 text-white hover:bg-blue-700 active:bg-blue-800`;/* @__PURE__ */
|
|
2
|
+
return o(s,{children:[
|
|
3
|
+
/* @__PURE__ */o("div",{ref:F,className:"flex flex-col h-full",style:{opacity:E.activeOpacity/100,backdropFilter:E.activeBlur>0?`blur(${E.activeBlur}px)`:void 0},children:[
|
|
4
|
+
/* @__PURE__ */o("div",{className:"bg-slate-200 rounded-t-lg px-4 py-2 group/display relative flex flex-col justify-end min-h-[120px] border-b border-slate-300",children:[
|
|
5
|
+
/* @__PURE__ */u("div",{className:"flex flex-col justify-end flex-1 overflow-hidden",children:v.slice(0,3).reverse().map((e,t)=>/* @__PURE__ */u("div",{className:"text-2xs text-slate-400 text-right font-mono truncate",children:e},t))}),(x||p&&null!==b)&&/* @__PURE__ */u("div",{className:"text-base text-slate-600 text-right font-mono",children:x||`${b} ${p} ${y?"":h}`}),
|
|
6
|
+
/* @__PURE__ */o("div",{className:"flex items-center gap-2",children:[
|
|
7
|
+
/* @__PURE__ */u("button",{onClick:()=>{navigator.clipboard.writeText(h),j(!0),setTimeout(()=>j(!1),1200)},title:"Copy result",className:"shrink-0 text-slate-300 hover:text-slate-500 transition-colors opacity-0 group-hover/display:opacity-100",children:/* @__PURE__ */u(r,$?{name:"check",className:"h-5 w-5 text-green-500",strokeWidth:2}:{name:"copy",className:"h-5 w-5",strokeWidth:2})}),
|
|
8
|
+
/* @__PURE__ */u("div",{className:"text-right text-4xl font-mono font-bold text-slate-800 truncate flex-1",children:(e=>{const t=parseFloat(e);return isNaN(t)||e.endsWith(".")||e.endsWith(".0")||Math.abs(t)<1e15&&e.length<16?e:t.toExponential(6)})(h)})]})]}),
|
|
9
|
+
/* @__PURE__ */o("div",{className:"grid grid-cols-4 grid-rows-5 gap-2 flex-1 min-h-0 p-2",children:[
|
|
10
|
+
/* @__PURE__ */u("button",{onClick:A,className:U,children:"AC"}),
|
|
11
|
+
/* @__PURE__ */u("button",{onClick:I,className:U,children:"+/−"}),
|
|
12
|
+
/* @__PURE__ */u("button",{onClick:X,className:U,children:"%"}),
|
|
13
|
+
/* @__PURE__ */u("button",{onClick:()=>G("÷"),className:`${Q} ${"÷"===p?"ring-2 ring-blue-400":""}`,children:"÷"}),
|
|
14
|
+
/* @__PURE__ */u("button",{onClick:()=>W("7"),className:L,children:"7"}),
|
|
15
|
+
/* @__PURE__ */u("button",{onClick:()=>W("8"),className:L,children:"8"}),
|
|
16
|
+
/* @__PURE__ */u("button",{onClick:()=>W("9"),className:L,children:"9"}),
|
|
17
|
+
/* @__PURE__ */u("button",{onClick:()=>G("×"),className:`${Q} ${"×"===p?"ring-2 ring-blue-400":""}`,children:"×"}),
|
|
18
|
+
/* @__PURE__ */u("button",{onClick:()=>W("4"),className:L,children:"4"}),
|
|
19
|
+
/* @__PURE__ */u("button",{onClick:()=>W("5"),className:L,children:"5"}),
|
|
20
|
+
/* @__PURE__ */u("button",{onClick:()=>W("6"),className:L,children:"6"}),
|
|
21
|
+
/* @__PURE__ */u("button",{onClick:()=>G("-"),className:`${Q} ${"-"===p?"ring-2 ring-blue-400":""}`,children:"−"}),
|
|
22
|
+
/* @__PURE__ */u("button",{onClick:()=>W("1"),className:L,children:"1"}),
|
|
23
|
+
/* @__PURE__ */u("button",{onClick:()=>W("2"),className:L,children:"2"}),
|
|
24
|
+
/* @__PURE__ */u("button",{onClick:()=>W("3"),className:L,children:"3"}),
|
|
25
|
+
/* @__PURE__ */u("button",{onClick:()=>G("+"),className:`${Q} ${"+"===p?"ring-2 ring-blue-400":""}`,children:"+"}),
|
|
26
|
+
/* @__PURE__ */u("button",{onClick:()=>W("0"),className:`${L} col-span-2`,children:"0"}),
|
|
27
|
+
/* @__PURE__ */u("button",{onClick:()=>W("."),className:L,children:"."}),
|
|
28
|
+
/* @__PURE__ */u("button",{onClick:M,className:Z,children:"="})]})]}),
|
|
29
|
+
/* @__PURE__ */u(t,{open:S,onClose:()=>T(!1),title:"Calculator Settings",appearance:B,onAppearanceChange:D,onSave:()=>{w(B),localStorage.setItem(d,JSON.stringify(B)),T(!1)}})]})}export{h as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{ConfirmProvider,confirm,confirmDestructive,prompt,useConfirm}from"./chunk-XFE43ZU5.js";import"./chunk-UVBK6YSR.js";import"./chunk-K7PQXJO7.js";import"./chunk-FIEA5CGB.js";import"./chunk-4EIZZYLK.js";import"./chunk-C3QOHMR6.js";import"./chunk-B427NVDP.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{loadAppearance as e,WidgetSettingsModal as t}from"./chunk-
|
|
1
|
+
import{loadAppearance as e,WidgetSettingsModal as t}from"./chunk-Y7T3OW2A.js";import{useWidgetSettings as r}from"./chunk-4M7DEG4E.js";import"./chunk-DSSLOQDW.js";import"./chunk-FS27CODA.js";import"./chunk-ZMQ3GBEX.js";import"./chunk-5A7MWTXX.js";import"./chunk-SZTKBF3D.js";import"./chunk-XFE43ZU5.js";import"./chunk-GNW45MGV.js";import"./chunk-UVBK6YSR.js";import"./chunk-K7PQXJO7.js";import"./chunk-7IQ3B77H.js";import"./chunk-FIEA5CGB.js";import"./chunk-D65T4H6J.js";import"./chunk-KNUR2UEG.js";import"./chunk-4EIZZYLK.js";import"./chunk-C3QOHMR6.js";import"./chunk-B427NVDP.js";import{useState as n,useCallback as a,useEffect as s}from"react";import{jsxs as c,Fragment as o,jsx as i}from"react/jsx-runtime";var l=["USD","CNY","AUD","GBP","EUR","JPY","CAD","THB","NZD","SGD","HKD","CHF","KRW","INR","MXN","BRL"],m=[["USD","CNY"],["USD","AUD"],["GBP","USD"],["USD","JPY"]],u="currency_pairs",p="currency_appearance",d="currency_rates_cache";function h(e){try{const t=JSON.parse(localStorage.getItem(d)||"{}")[e];if(t&&Date.now()-t.timestamp<36e5)return t.rates}catch{}return null}function g(e,t){try{const r=JSON.parse(localStorage.getItem(d)||"{}");r[e]={rates:t,timestamp:Date.now()},localStorage.setItem(d,JSON.stringify(r))}catch{}}function x(){try{const e=JSON.parse(localStorage.getItem(u)||"");if(Array.isArray(e)&&e.length)return e.slice(0,4)}catch{}return m}var y={USD:"🇺🇸",CNY:"🇨🇳",AUD:"🇦🇺",GBP:"🇬🇧",JPY:"🇯🇵",CAD:"🇨🇦",EUR:"🇪🇺",THB:"🇹🇭",NZD:"🇳🇿",SGD:"🇸🇬",HKD:"🇭🇰",CHF:"🇨🇭",KRW:"🇰🇷",INR:"🇮🇳",MXN:"🇲🇽",BRL:"🇧🇷"};function f(){const[m,d]=n(x),[f,N]=n(()=>e(p)),[b,S]=n({}),[v,D]=n(!1),[k,j]=n(!1),[C,B]=n([]),[U,A]=n(f),[O,I]=n("USD"),[J,G]=n("CNY");r(a(()=>{B([...m]),A({...f}),j(!0)},[m,f])),s(()=>{const e=[...new Set(m.map(([e])=>e))];let t=!0;return async function(){D(!0);const r={};for(const t of e){const e=h(t);if(e)r[t]=e;else try{const e=await fetch(`https://open.er-api.com/v6/latest/${t}`),n=await e.json();n.rates&&(r[t]=n.rates,g(t,n.rates))}catch{}}t&&(S(r),D(!1))}(),()=>{t=!1}},[m]);/* @__PURE__ */
|
|
2
2
|
return c(o,{children:[
|
|
3
|
-
/* @__PURE__ */i("div",{style:{backgroundColor:`rgb(var(--taskbar-bg-rgb, 243 244 246) / ${
|
|
3
|
+
/* @__PURE__ */i("div",{style:{backgroundColor:`rgb(var(--taskbar-bg-rgb, 243 244 246) / ${f.activeOpacity/100})`,backdropFilter:f.activeBlur>0?`blur(${f.activeBlur}px)`:void 0},children:/* @__PURE__ */c("div",{className:"px-4 py-3 space-y-1",children:[v&&/* @__PURE__ */i("div",{className:"text-xs text-gray-400 text-center py-4",children:"Loading rates..."}),m.map(([e,t],r)=>{const n=b[e]?.[t];/* @__PURE__ */
|
|
4
4
|
return c("button",{onClick:()=>{const e=m.map((e,t)=>t===r?[e[1],e[0]]:e);d(e),localStorage.setItem(u,JSON.stringify(e))},className:"flex items-center justify-between px-2 py-2 border-b border-gray-200 last:border-0 w-full hover:bg-gray-100 rounded transition-colors cursor-pointer",children:[
|
|
5
5
|
/* @__PURE__ */c("div",{className:"flex items-center gap-2",children:[
|
|
6
6
|
/* @__PURE__ */i("span",{className:"text-base",children:y[e]||""}),
|
|
@@ -9,13 +9,13 @@ return c("button",{onClick:()=>{const e=m.map((e,t)=>t===r?[e[1],e[0]]:e);d(e),l
|
|
|
9
9
|
/* @__PURE__ */i("span",{className:"text-base",children:y[t]||""}),
|
|
10
10
|
/* @__PURE__ */i("span",{className:"text-sm font-semibold text-gray-700",children:t})]}),
|
|
11
11
|
/* @__PURE__ */i("div",{className:"text-base font-mono font-semibold text-gray-900 tabular-nums",children:null!=n?n.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:4}):"—"})]},`${e}-${t}-${r}`)})]})}),
|
|
12
|
-
/* @__PURE__ */i(t,{open:
|
|
12
|
+
/* @__PURE__ */i(t,{open:k,onClose:()=>j(!1),title:"Currency Settings",appearance:U,onAppearanceChange:A,onSave:()=>{if(0===C.length)return;const e=C.slice(0,4);d(e),N(U),localStorage.setItem(u,JSON.stringify(e)),localStorage.setItem(p,JSON.stringify(U)),j(!1)},children:/* @__PURE__ */c("div",{children:[
|
|
13
13
|
/* @__PURE__ */c("h3",{className:"text-sm font-semibold text-gray-700 mb-2",children:["Currency Pairs ",
|
|
14
|
-
/* @__PURE__ */c("span",{className:"text-2xs font-normal text-gray-400",children:["(",
|
|
15
|
-
/* @__PURE__ */i("div",{className:"space-y-1 mb-2",children:
|
|
14
|
+
/* @__PURE__ */c("span",{className:"text-2xs font-normal text-gray-400",children:["(",C.length,"/",4,")"]})]}),
|
|
15
|
+
/* @__PURE__ */i("div",{className:"space-y-1 mb-2",children:C.map(([e,t],r)=>/* @__PURE__ */c("div",{className:"flex items-center justify-between py-1 px-2 bg-gray-50 rounded",children:[
|
|
16
16
|
/* @__PURE__ */c("span",{className:"text-sm",children:[y[e]||""," ",e," → ",y[t]||""," ",t]}),
|
|
17
|
-
/* @__PURE__ */i("button",{onClick:()=>
|
|
18
|
-
/* @__PURE__ */i("select",{value:
|
|
17
|
+
/* @__PURE__ */i("button",{onClick:()=>B(e=>e.filter((e,t)=>t!==r)),className:"text-red-400 hover:text-red-600",children:"×"})]},r))}),C.length<4?/* @__PURE__ */c("div",{className:"flex items-center gap-2",children:[
|
|
18
|
+
/* @__PURE__ */i("select",{value:O,onChange:e=>I(e.target.value),className:"bg-gray-50 border border-gray-200 rounded px-2 py-1 text-sm focus:outline-none focus:ring-1 focus:ring-blue-500",children:l.map(e=>/* @__PURE__ */i("option",{children:e},e))}),
|
|
19
19
|
/* @__PURE__ */i("span",{className:"text-gray-400",children:"→"}),
|
|
20
|
-
/* @__PURE__ */i("select",{value:
|
|
21
|
-
/* @__PURE__ */i("button",{onClick:()=>{
|
|
20
|
+
/* @__PURE__ */i("select",{value:J,onChange:e=>G(e.target.value),className:"bg-gray-50 border border-gray-200 rounded px-2 py-1 text-sm focus:outline-none focus:ring-1 focus:ring-blue-500",children:l.map(e=>/* @__PURE__ */i("option",{children:e},e))}),
|
|
21
|
+
/* @__PURE__ */i("button",{onClick:()=>{O!==J&&C.length<4&&B(e=>[...e,[O,J]])},className:"text-sm font-medium text-blue-600 hover:text-blue-800 px-2",children:"+ Add"})]}):/* @__PURE__ */c("p",{className:"text-2xs text-gray-400 italic",children:["Max ",4," pairs — remove one to add another."]})]})})]})}export{f as default};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import{escapeHtml as e}from"./chunk-BR22X7E5.js";import{AboutApp as t}from"./chunk-
|
|
1
|
+
import{escapeHtml as e}from"./chunk-BR22X7E5.js";import{AboutApp as t}from"./chunk-BZD3UC4R.js";import{WindowTitle as n}from"./chunk-4M7DEG4E.js";import"./chunk-DSSLOQDW.js";import"./chunk-FS27CODA.js";import{toast_default as r}from"./chunk-EA7QO447.js";import"./chunk-ZMQ3GBEX.js";import"./chunk-5A7MWTXX.js";import"./chunk-SZTKBF3D.js";import"./chunk-XFE43ZU5.js";import{PopupMenu as o,PopupMenuLabel as l,PopupMenuItem as a,PopupMenuDivider as i}from"./chunk-GNW45MGV.js";import"./chunk-UVBK6YSR.js";import"./chunk-K7PQXJO7.js";import"./chunk-7IQ3B77H.js";import"./chunk-FIEA5CGB.js";import"./chunk-D65T4H6J.js";import"./chunk-5VNBEMZQ.js";import"./chunk-KNUR2UEG.js";import"./chunk-4EIZZYLK.js";import"./chunk-C3QOHMR6.js";import{Icon as s}from"./chunk-B427NVDP.js";import{useState as c,useRef as d}from"react";import{jsxs as m,jsx as h}from"react/jsx-runtime";var u=/* @__PURE__ */new Set(["txt","md","markdown","csv","tsv","log","json","xml","html","htm","css","js","jsx","ts","tsx","py","rb","go","rs","java","c","h","cpp","hpp","sh","bash","yml","yaml","toml","ini","conf","env","sql"]),p=/* @__PURE__ */new Set(["docx"]),g={filename:"Untitled",kind:"docx",content:"",ext:"docx"};function x(){const[x,f]=c(g),[y,v]=c(!1),[b,k]=c(!1),[w,N]=c(!1),[j,C]=c(null),D=d(null),M=d(null),L=d(null),U=(e,t)=>{L.current?.focus(),document.execCommand(e,!1,t),N(!0)},B=e=>{for(const t of e){if(!t.type.startsWith("image/"))continue;const e=new FileReader;e.onload=()=>{L.current?.focus(),document.execCommand("insertImage",!1,String(e.result)),N(!0)},e.readAsDataURL(t)}},R=e=>{j&&(j.el.removeAttribute("width"),j.el.removeAttribute("height"),j.el.style.width=e??"",j.el.style.height=e?"auto":"",N(!0),C(null))},O=async t=>{const n=(t.name.split(".").pop()||"").toLowerCase();v(!0);try{if(u.has(n)||!p.has(n)&&t.type.startsWith("text/")){const r=await t.text(),o=e(r).replace(/\n/g,"<br>");f({filename:t.name,kind:"text",content:o,ext:n}),N(!1)}else if(p.has(n))try{const e=await(import(
|
|
2
2
|
/* @vite-ignore */
|
|
3
|
-
"mammoth")),r=await t.arrayBuffer(),o=await e.convertToHtml({arrayBuffer:r});f({filename:t.name,kind:"docx",content:o.value||"<p><em>(empty document)</em></p>",ext:n}),N(!1)}catch(e){r.error('Install the optional "mammoth" peer dep to read .docx files.')}else"doc"===n?r.error(".doc is the legacy Word binary format — convert to .docx first."):r.error(`Unsupported file type: .${n||"unknown"}`)}finally{v(!1)}},
|
|
4
|
-
return m("div",{className:"relative flex flex-col h-full",onDragOver:e=>{e.preventDefault(),b||k(!0)},onDragLeave:e=>{e.currentTarget===e.target&&k(!1)},onDrop:e=>{e.preventDefault(),k(!1);const t=Array.from(e.dataTransfer.files??[]);0!==t.length&&(t.every(e=>e.type.startsWith("image/"))?
|
|
5
|
-
/* @__PURE__ */h(n,{title:`${
|
|
3
|
+
"mammoth")),r=await t.arrayBuffer(),o=await e.convertToHtml({arrayBuffer:r});f({filename:t.name,kind:"docx",content:o.value||"<p><em>(empty document)</em></p>",ext:n}),N(!1)}catch(e){r.error('Install the optional "mammoth" peer dep to read .docx files.')}else"doc"===n?r.error(".doc is the legacy Word binary format — convert to .docx first."):r.error(`Unsupported file type: .${n||"unknown"}`)}finally{v(!1)}},S=x?.filename?(W=x.filename).length>24?`${W.slice(0,23)}…`:W:"Untitled";var W;/* @__PURE__ */
|
|
4
|
+
return m("div",{className:"relative flex flex-col h-full",onDragOver:e=>{e.preventDefault(),b||k(!0)},onDragLeave:e=>{e.currentTarget===e.target&&k(!1)},onDrop:e=>{e.preventDefault(),k(!1);const t=Array.from(e.dataTransfer.files??[]);0!==t.length&&(t.every(e=>e.type.startsWith("image/"))?B(t):O(t[0]))},children:[
|
|
5
|
+
/* @__PURE__ */h(n,{title:`${S}${w?" •":""} - Documents`}),
|
|
6
6
|
/* @__PURE__ */h(t,{app:"documents"}),
|
|
7
7
|
/* @__PURE__ */m("div",{className:"flex items-center flex-wrap gap-x-2 gap-y-1 px-3 py-2 border-b border-gray-200 bg-gray-50 shrink-0",children:[
|
|
8
|
-
/* @__PURE__ */h("input",{ref:D,type:"file",accept:".txt,.md,.csv,.tsv,.log,.json,.xml,.html,.htm,.css,.js,.jsx,.ts,.tsx,.py,.rb,.go,.rs,.java,.c,.h,.cpp,.hpp,.sh,.bash,.yml,.yaml,.toml,.ini,.conf,.env,.sql,.docx,text/*",onChange:e=>{const t=e.target.files?.[0];t&&
|
|
8
|
+
/* @__PURE__ */h("input",{ref:D,type:"file",accept:".txt,.md,.csv,.tsv,.log,.json,.xml,.html,.htm,.css,.js,.jsx,.ts,.tsx,.py,.rb,.go,.rs,.java,.c,.h,.cpp,.hpp,.sh,.bash,.yml,.yaml,.toml,.ini,.conf,.env,.sql,.docx,text/*",onChange:e=>{const t=e.target.files?.[0];t&&O(t),D.current&&(D.current.value="")},className:"hidden"}),
|
|
9
9
|
/* @__PURE__ */m("button",{onClick:()=>D.current?.click(),className:"text-xs text-gray-700 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors flex items-center gap-1",children:[
|
|
10
10
|
/* @__PURE__ */h(s,{name:"folder-open",className:"h-3.5 w-3.5",strokeWidth:1.5}),"Open"]}),
|
|
11
|
-
/* @__PURE__ */h("button",{onClick:()=>{if(!x)return;const t=
|
|
11
|
+
/* @__PURE__ */h("button",{onClick:()=>{if(!x)return;const t=L.current?.innerHTML??"";if("text"===x.kind){if(/<(b|strong|i|em|u|font|span style|ul|ol|img)|style="[^"]*text-align/i.test(t)){const n=new Blob([`<!doctype html><meta charset="utf-8"><title>${e(x.filename)}</title><body style="font-family:ui-monospace,monospace;white-space:pre-wrap">${t}`],{type:"text/html"}),r=URL.createObjectURL(n),o=document.createElement("a");o.href=r,o.download=`${x.filename.replace(/\.[^.]+$/,"")}.html`,o.click(),URL.revokeObjectURL(r)}else{const e=L.current?.innerText??"",t=new Blob([e],{type:"text/plain"}),n=URL.createObjectURL(t),r=document.createElement("a");r.href=n,r.download=x.filename,r.click(),URL.revokeObjectURL(n)}}else{const n=new Blob([`<!doctype html><meta charset="utf-8"><title>${e(x.filename)}</title>${t}`],{type:"text/html"}),r=URL.createObjectURL(n),o=document.createElement("a");o.href=r,o.download=`${x.filename.replace(/\.docx$/i,"")}.html`,o.click(),URL.revokeObjectURL(r)}},className:"text-xs text-gray-700 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors",children:"Save"}),
|
|
12
12
|
/* @__PURE__ */h("span",{className:"text-2xs text-gray-400 ml-1",children:"TXT · DOCX · Code"}),
|
|
13
13
|
/* @__PURE__ */h("div",{className:"h-4 w-px bg-gray-300 mx-1"}),
|
|
14
14
|
/* @__PURE__ */m("span",{className:"text-xs font-medium text-gray-700 truncate max-w-[200px]",title:x.filename,children:[x.filename,w?" •":""]}),
|
|
@@ -38,15 +38,15 @@ return m("div",{className:"relative flex flex-col h-full",onDragOver:e=>{e.preve
|
|
|
38
38
|
/* @__PURE__ */h("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>U("justifyRight"),className:"px-2 py-1 rounded text-gray-700 hover:bg-gray-200 transition-colors",title:"Align right",children:/* @__PURE__ */h("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */h("path",{strokeLinecap:"round",d:"M3.75 6h16.5M10.5 12h9.75M6 18h14.25"})})}),
|
|
39
39
|
/* @__PURE__ */h("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>U("justifyFull"),className:"px-2 py-1 rounded text-gray-700 hover:bg-gray-200 transition-colors",title:"Justify",children:/* @__PURE__ */h("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */h("path",{strokeLinecap:"round",d:"M3.75 6h16.5M3.75 12h16.5M3.75 18h16.5"})})})]}),
|
|
40
40
|
/* @__PURE__ */h("div",{className:"h-4 w-px bg-gray-300 mx-1"}),
|
|
41
|
-
/* @__PURE__ */h("input",{ref:
|
|
42
|
-
/* @__PURE__ */m("button",{onClick:()=>
|
|
41
|
+
/* @__PURE__ */h("input",{ref:M,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:e=>{e.target.files?.length&&B(Array.from(e.target.files)),M.current&&(M.current.value="")}}),
|
|
42
|
+
/* @__PURE__ */m("button",{onClick:()=>M.current?.click(),className:"px-2 py-1 text-xs rounded text-gray-700 hover:bg-gray-200 transition-colors flex items-center gap-1",title:"Insert image (or paste / drop one)",children:[
|
|
43
43
|
/* @__PURE__ */h(s,{name:"image",className:"h-3.5 w-3.5",strokeWidth:1.5}),"Image"]})]}),
|
|
44
|
-
/* @__PURE__ */h("div",{className:"flex-1 min-h-0 overflow-hidden",children:/* @__PURE__ */h("div",y?{className:"flex items-center justify-center h-full text-sm text-gray-400",children:"Loading…"}:{className:"h-full overflow-auto "+("docx"===x.kind?"bg-gray-100 px-6 py-8":"bg-white"),children:/* @__PURE__ */h("div",{ref:
|
|
44
|
+
/* @__PURE__ */h("div",{className:"flex-1 min-h-0 overflow-hidden",children:/* @__PURE__ */h("div",y?{className:"flex items-center justify-center h-full text-sm text-gray-400",children:"Loading…"}:{className:"h-full overflow-auto "+("docx"===x.kind?"bg-gray-100 px-6 py-8":"bg-white"),children:/* @__PURE__ */h("div",{ref:L,contentEditable:!0,suppressContentEditableWarning:!0,spellCheck:!1,onInput:()=>N(!0),onPaste:e=>{const t=Array.from(e.clipboardData?.items??[]).filter(e=>"file"===e.kind&&e.type.startsWith("image/")).map(e=>e.getAsFile()).filter(e=>!!e);t.length&&(e.preventDefault(),B(t))},onClick:e=>{const t=e.target;"IMG"===t.tagName&&(e.preventDefault(),C({x:e.clientX,y:e.clientY,el:t}))},dangerouslySetInnerHTML:{__html:x.content},className:"docx"===x.kind?"docs-editor mx-auto w-[8.5in] min-h-[11in] bg-white p-[1in] shadow text-sm leading-relaxed text-gray-800 outline-none focus:ring-2 focus:ring-blue-400/40":"docs-editor block w-full min-h-full p-4 font-mono text-sm leading-relaxed text-gray-800 bg-white outline-none whitespace-pre-wrap"})})}),b&&/* @__PURE__ */h("div",{className:"absolute inset-0 bg-blue-500/15 border-4 border-dashed border-blue-500 pointer-events-none flex items-center justify-center z-20",children:/* @__PURE__ */h("div",{className:"px-4 py-2 rounded-md bg-blue-600 text-white text-sm font-medium shadow-lg",children:"Drop a document to open · images insert into the page"})}),j&&/* @__PURE__ */m(o,{minWidth:150,style:{left:j.x,top:j.y},onClose:()=>C(null),children:[
|
|
45
45
|
/* @__PURE__ */h(l,{children:"Image width"}),
|
|
46
|
-
/* @__PURE__ */h(a,{onClick:()=>
|
|
47
|
-
/* @__PURE__ */h(a,{onClick:()=>
|
|
48
|
-
/* @__PURE__ */h(a,{onClick:()=>
|
|
49
|
-
/* @__PURE__ */h(a,{onClick:()=>
|
|
50
|
-
/* @__PURE__ */h(a,{onClick:()=>
|
|
46
|
+
/* @__PURE__ */h(a,{onClick:()=>R("25%"),children:"25%"}),
|
|
47
|
+
/* @__PURE__ */h(a,{onClick:()=>R("50%"),children:"50%"}),
|
|
48
|
+
/* @__PURE__ */h(a,{onClick:()=>R("75%"),children:"75%"}),
|
|
49
|
+
/* @__PURE__ */h(a,{onClick:()=>R("100%"),children:"100%"}),
|
|
50
|
+
/* @__PURE__ */h(a,{onClick:()=>R(null),children:"Original size"}),
|
|
51
51
|
/* @__PURE__ */h(i,{}),
|
|
52
|
-
/* @__PURE__ */h(a,{danger:!0,onClick:()=>{
|
|
52
|
+
/* @__PURE__ */h(a,{danger:!0,onClick:()=>{j?.el.remove(),N(!0),C(null)},children:"Remove image"})]})]})}export{x as default};
|