@alwith/module-editor 0.1.0-rc.13 → 0.1.0-rc.14
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 +6 -0
- package/dist/chunk-0m07f1rf.js +2 -0
- package/dist/chunk-68dtjjm4.js +2 -0
- package/dist/chunk-6nvrc7p7.js +9 -0
- package/dist/chunk-7zewhyx6.js +2 -0
- package/dist/chunk-83qapya5.js +3 -0
- package/dist/chunk-9mb4nnsc.js +2 -0
- package/dist/chunk-b1xr49tw.js +2 -0
- package/dist/chunk-b5q2ys0a.js +2 -0
- package/dist/chunk-bh9vgt8q.js +2 -0
- package/dist/chunk-czgs93zj.js +3 -0
- package/dist/chunk-dr1ebnb1.js +2 -0
- package/dist/chunk-e5hxq2gn.js +2 -0
- package/dist/chunk-gq1eh0tx.js +2 -0
- package/dist/chunk-jdjcp0ak.js +4 -0
- package/dist/chunk-nn5x2ear.js +2 -0
- package/dist/chunk-qanrx7j1.js +2 -0
- package/dist/chunk-qt0cfrrv.js +2 -0
- package/dist/chunk-s6jrc7pq.js +2 -0
- package/dist/chunk-sq7vxhx3.js +2 -0
- package/dist/chunk-yhtn3t0e.js +2 -0
- package/dist/core.js +1 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +1 -1
- package/dist/monaco.d.ts +2 -2
- package/dist/monaco.js +1 -1
- package/dist/new-tab.d.ts +2 -2
- package/dist/new-tab.js +1 -1
- package/dist/preview-source-mode-toggle.js +1 -1
- package/dist/previews/excel-data.js +1 -3
- package/dist/previews/excel-navigation.js +1 -1
- package/dist/previews/excel.d.ts +1 -1
- package/dist/previews/excel.js +2 -1
- package/dist/previews/html-resources.d.ts +1 -1
- package/dist/previews/html-resources.js +1 -2
- package/dist/previews/html-session.d.ts +1 -1
- package/dist/previews/html-session.js +1 -1
- package/dist/previews/html.d.ts +1 -1
- package/dist/previews/html.js +2 -1
- package/dist/previews/index.d.ts +3 -3
- package/dist/previews/index.js +2 -1
- package/dist/previews/markdown-outline.d.ts +1 -1
- package/dist/previews/markdown-outline.js +2 -1
- package/dist/previews/markdown-readonly.d.ts +1 -1
- package/dist/previews/markdown-readonly.js +2 -2
- package/dist/previews/markdown.d.ts +1 -1
- package/dist/previews/markdown.js +2 -1
- package/dist/previews/media-types.js +1 -1
- package/dist/previews/media.d.ts +1 -1
- package/dist/previews/media.js +2 -1
- package/dist/previews/pdf-controls.js +1 -1
- package/dist/previews/pdf.d.ts +1 -1
- package/dist/previews/pdf.js +2 -1
- package/dist/previews/shared.d.ts +1 -1
- package/dist/previews/shared.js +2 -1
- package/dist/previews/tiff.d.ts +1 -1
- package/dist/previews/tiff.js +2 -1
- package/dist/previews/word.d.ts +1 -1
- package/dist/previews/word.js +2 -1
- package/dist/quick-start-assets.js +1 -1
- package/dist/quick-start-data.js +1 -1
- package/dist/quick-start-icons.js +1 -1
- package/dist/workspace-assets.js +1 -1
- package/dist/workspace-tabs.d.ts +2 -2
- package/dist/workspace-tabs.js +1 -1
- package/dist/workspace.d.ts +1 -1
- package/dist/workspace.js +1 -1
- package/package.json +21 -21
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import"../chunk-czgs93zj.js";import{j}from"../chunk-9mb4nnsc.js";import{z}from"../chunk-7zewhyx6.js";import{D,N}from"../chunk-0m07f1rf.js";import{r}from"../chunk-83qapya5.js";j(import.meta.url,["pc0wr96w","czgs93zj","9mb4nnsc","7zewhyx6","0m07f1rf","83qapya5","rpk588j2","x6e3x53v","g5mn8gma","ft3hwgj5","pm5mxznh","ewq910t8","b5q2ys0a","6nvrc7p7","gq1eh0tx","dr1ebnb1","qt0cfrrv","qanrx7j1","nn5x2ear","68dtjjm4","b1xr49tw","sq7vxhx3","e5hxq2gn","s6jrc7pq","yhtn3t0e","jdjcp0ak","bh9vgt8q"],[["./markdown.js",1,2,3,4,5],["../chunk-czgs93zj.js"],["../chunk-9mb4nnsc.js"],["../chunk-7zewhyx6.js",2],["../chunk-0m07f1rf.js",2],["../chunk-83qapya5.js",2,3,4],["./tiff.js",12,13,14,15,16,17,18,19,20,21,1,2,4],["./html.js",1,22,2,4],["./word.js",1,2,4],["./pdf.js",1,2,23,4],["./media.js",1,2,24,4],["./excel.js",25,26,1,2,4],["../chunk-b5q2ys0a.js"],["../chunk-6nvrc7p7.js"],["../chunk-gq1eh0tx.js"],["../chunk-dr1ebnb1.js"],["../chunk-qt0cfrrv.js"],["../chunk-qanrx7j1.js"],["../chunk-nn5x2ear.js"],["../chunk-68dtjjm4.js",16,17,18],["../chunk-b1xr49tw.js"],["../chunk-sq7vxhx3.js",12],["../chunk-e5hxq2gn.js",1],["../chunk-s6jrc7pq.js"],["../chunk-yhtn3t0e.js"],["../chunk-jdjcp0ak.js"],["../chunk-bh9vgt8q.js"]],0);
|
|
2
|
+
import{defaultValueCtx as tt,Editor as et,EditorStatus as rt,editorViewCtx as nt,editorViewOptionsCtx as ot,rootCtx as it,serializerCtx as ct}from"@milkdown/core";import{history as at}from"@milkdown/plugin-history";import{math as ut}from"@milkdown/plugin-math";import{commonmark as st,imageSchema as lt}from"@milkdown/preset-commonmark";import{gfm as dt}from"@milkdown/preset-gfm";import{Plugin as mt}from"@milkdown/prose/state";import{$prose as ft,getMarkdown as C,replaceAll as p}from"@milkdown/utils";import{useCallback as wt,useEffect as L,useEffectEvent as A,useMemo as I,useRef as E,useState as T}from"react";import"katex/dist/katex.min.css";import"@milkdown/prose/view/style/prosemirror.css";import"@milkdown/prose/tables/style/tables.css";import{jsxDEV as b}from"react/jsx-dev-runtime";function ht(t){let[k,f]=T(null),e=wt(()=>f(t.document.id),[t.document.id]),y=I(()=>t.document.text.replace(/^\s*<!--\s*plate-metadata:[\s\S]*?-->\s*/i,"").replace(/\s*<!--\s*plate-metadata:[\s\S]*?-->\s*$/i,""),[t.document.text]),R=I(()=>({...t.document,text:y}),[t.document,y]);if(I(()=>new TextEncoder().encode(y).byteLength,[y])>=1048576&&k!==t.document.id)return b(r,{...t,document:R,onSwitchToEditor:e},void 0,!1,void 0,this);return b(yt,{...t,document:R},void 0,!1,void 0,this)}function yt(t){let k=E(null),f=E(null),e=E(t);e.current=t;let[y,R]=T(()=>({id:t.document.id,host:t.host,integration:t.host.createMarkdownIntegration?.(t.document,t.context)})),i=y.integration;if(y.id!==t.document.id||y.host!==t.host)i=t.host.createMarkdownIntegration?.(t.document,t.context),R({id:t.document.id,host:t.host,integration:i});let w=E(t.document.text),O=E(!1),s=E(null),[V,K]=T(0),[G,P]=T(null),[J,q]=T(!1);L(()=>{if(!k.current)throw Error("Markdown container is missing");let c=k.current;w.current=e.current.document.text,q(!1),P(null);let h=!1,M=new Set,v=(n)=>{if(!h)P(N(n)),e.current.context.onError(n)},x=null,F=new MutationObserver(()=>{if(x)clearTimeout(x);x=setTimeout(()=>{x=null,K((n)=>n+1)},800)});F.observe(c,{childList:!0,subtree:!0,characterData:!0});let m=et.make().config((n)=>{n.update(lt.key,(u)=>(l)=>{let o=u(l);return{...o,parseMarkdown:{...o.parseMarkdown,runner:(g,a,S)=>o.parseMarkdown.runner(g,{...a,alt:a.alt??"",title:a.title??""},S)}}}),n.set(it,c),n.set(tt,e.current.document.text),n.update(ot,(u)=>({...u,attributes:(l)=>({...typeof u.attributes==="function"?u.attributes(l):u.attributes,"aria-label":e.current.document.path}),editable:()=>!e.current.context.readOnly&&(i?.editable()??!0),nodeViews:{...u.nodeViews,image:(l)=>{let o=window.document.createElement("img"),g=0,a=null,S=(d,Y,Z)=>{let _=++g;if(a)URL.revokeObjectURL(a),M.delete(a),a=null;if(o.removeAttribute("src"),o.alt=Y,o.title=Z,!d)return;if(/^data:image\//i.test(d)){o.src=d;return}if(/^https:\/\//i.test(d)&&e.current.host.allowRemoteResources){o.referrerPolicy="no-referrer",o.src=d;return}if(/^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(d)){v(Error(`Remote Markdown image is blocked: ${d}`));return}e.current.host.resolveResource(e.current.document.path,d).then((U)=>{if(h||_!==g)return;if(!U.mimeType.startsWith("image/"))throw Error("Markdown resource is not an image");a=URL.createObjectURL(new Blob([new Uint8Array(U.bytes).buffer],{type:U.mimeType})),M.add(a),o.src=a}).catch(v)};return S(String(l.attrs.src||""),String(l.attrs.alt||""),String(l.attrs.title||"")),{dom:o,update:(d)=>{if(d.type!==l.type)return!1;return S(String(d.attrs.src||""),String(d.attrs.alt||""),String(d.attrs.title||"")),!0},destroy:()=>{if(g++,a)URL.revokeObjectURL(a),M.delete(a)}}}}}))}).use(st).use(dt).use(ut).use(at).use(ft((n)=>new mt({view:()=>({update:(u,l)=>{if(h||O.current||f.current!==m||e.current.context.readOnly||i?.editable()===!1||u.state.doc.eq(l.doc))return;try{let o=n.get(ct)(u.state.doc);if(o===w.current)return;if(w.current=o,e.current.context.onChange(i?.serialize(o)??o),s.current)clearTimeout(s.current);let g=e.current.host.autoSaveDelay;if(g!==void 0)s.current=setTimeout(()=>{if(s.current=null,!h&&!e.current.context.readOnly&&(i?.editable()??!0))try{e.current.context.onSave()}catch(a){v(a)}},g)}catch(o){v(o)}}})})));i?.configure(m),m.create().then(async()=>{if(h){m.destroy().catch(e.current.context.onError);return}if(e.current.document.text!==w.current)w.current=e.current.document.text,m.action(p(w.current)),w.current=m.action(C());if(w.current=m.action(C()),f.current=m,i?.applyExternal(m,e.current.document),await i?.ready(m),h)return;K((n)=>n+1),q(!0)}).catch(v);let H=(n)=>{if((n.metaKey||n.ctrlKey)&&n.key.toLowerCase()==="s"){if(n.preventDefault(),n.stopPropagation(),s.current)clearTimeout(s.current),s.current=null;if(!e.current.context.readOnly&&(i?.editable()??!0))try{e.current.context.onSave()}catch(u){v(u)}}},W=(n)=>{let u=n.target.closest("a");if(!u)return;n.preventDefault();let l=u.getAttribute("href");if(l)e.current.host.openLink?.(l).catch(v)};return c.addEventListener("keydown",H),c.addEventListener("click",W),()=>{if(h=!0,s.current)clearTimeout(s.current),s.current=null;if(f.current=null,i?.dispose(),F.disconnect(),x)clearTimeout(x);c.removeEventListener("keydown",H),c.removeEventListener("click",W);for(let n of M)URL.revokeObjectURL(n);if(m.status===rt.Created)m.destroy().catch(e.current.context.onError)}},[t.document.id,i]);let Q=A(()=>t.document),X=A((c)=>t.context.onError(c));L(()=>{let c=Q();if(!f.current||c.text===w.current)return;if(s.current)clearTimeout(s.current),s.current=null;O.current=!0;try{if(!i?.applyExternal(f.current,c))f.current.action(p(c.text));w.current=f.current.action(C())}catch(h){P(N(h)),X(h)}finally{O.current=!1}},[t.document.text,i]),L(()=>{f.current?.action((c)=>c.get(nt).setProps({editable:()=>!t.context.readOnly&&(i?.editable()??!0)}))},[t.context.readOnly,J,i]);let B=A((c)=>t.context.setToolbarActions?.(c));return L(()=>(B(b(z,{host:t.host,container:k.current,revision:V},void 0,!1,void 0,this)),()=>B(null)),[t.context.setToolbarActions,t.host,V]),b("div",{className:"alwith-preview-markdown alwith-markdown-view",children:[b(D,{error:G},void 0,!1,void 0,this),i?.render(),b("div",{className:"alwith-markdown-scroll",ref:k},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}export{ht as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{i}from"../chunk-yhtn3t0e.js";export{i as mediaMimeType};
|
package/dist/previews/media.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { type PreviewProps } from "./index
|
|
1
|
+
import { type PreviewProps } from "./index";
|
|
2
2
|
export default function Media({ document, context, host }: PreviewProps): import("react").JSX.Element;
|
package/dist/previews/media.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import"../chunk-czgs93zj.js";import{j,M}from"../chunk-9mb4nnsc.js";import{i}from"../chunk-yhtn3t0e.js";import{C,D}from"../chunk-0m07f1rf.js";j(import.meta.url,["pm5mxznh","czgs93zj","9mb4nnsc","yhtn3t0e","0m07f1rf","rpk588j2","x6e3x53v","g5mn8gma","ft3hwgj5","pc0wr96w","ewq910t8","b5q2ys0a","6nvrc7p7","gq1eh0tx","dr1ebnb1","qt0cfrrv","qanrx7j1","nn5x2ear","68dtjjm4","b1xr49tw","sq7vxhx3","e5hxq2gn","s6jrc7pq","7zewhyx6","83qapya5","jdjcp0ak","bh9vgt8q"],[["./media.js",1,2,3,4],["../chunk-czgs93zj.js"],["../chunk-9mb4nnsc.js"],["../chunk-yhtn3t0e.js"],["../chunk-0m07f1rf.js",2],["./tiff.js",11,12,13,14,15,16,17,18,19,20,1,2,4],["./html.js",1,21,2,4],["./word.js",1,2,4],["./pdf.js",1,2,22,4],["./markdown.js",1,2,23,4,24],["./excel.js",25,26,1,2,4],["../chunk-b5q2ys0a.js"],["../chunk-6nvrc7p7.js"],["../chunk-gq1eh0tx.js"],["../chunk-dr1ebnb1.js"],["../chunk-qt0cfrrv.js"],["../chunk-qanrx7j1.js"],["../chunk-nn5x2ear.js"],["../chunk-68dtjjm4.js",15,16,17],["../chunk-b1xr49tw.js"],["../chunk-sq7vxhx3.js",11],["../chunk-e5hxq2gn.js",1],["../chunk-s6jrc7pq.js"],["../chunk-7zewhyx6.js",2],["../chunk-83qapya5.js",2,23,4],["../chunk-jdjcp0ak.js"],["../chunk-bh9vgt8q.js"]],0);
|
|
2
|
+
import g from"audiomotion-analyzer";import{useEffect as h,useRef as l,useState as k}from"react";import A from"react-player";import{jsxDEV as e,Fragment as N}from"react/jsx-dev-runtime";function P({document:u,context:s,host:c}){let d=i(u.path),a=d.startsWith("audio/"),r=C(u.bytes,d),[y,m]=k(null),n=l(null),p=l(null),w=l(s);w.current=s,h(()=>{m(null)},[r]),h(()=>{if(!a||!r)return;let o=n.current,t=p.current;if(!o||!t)return;let v=null;try{v=new g(t,{source:o,height:140,mode:3,gradient:"classic",showBgColor:!1,showScaleX:!1,showScaleY:!1,showPeaks:!1,roundBars:!0,reflexRatio:0,lumiBars:!1,overlay:!0,smoothing:0.7})}catch(E){w.current.onError(E)}return()=>{o.pause(),v?.destroy(),o.removeAttribute("src"),o.load()}},[a,r]);let f=(o)=>{let t=o instanceof Error?o:Error(n.current?.error?.message||M(c,"mediaUnsupported"));m(t.message),s.onError(t)};return e("div",{className:`alwith-preview-media-desktop ${a?"alwith-preview-audio":"alwith-preview-video"}`,children:e("div",{className:"alwith-preview-media-content",children:[e(D,{error:y},void 0,!1,void 0,this),!r&&e("div",{className:"alwith-preview-status",role:"status",children:[e("span",{className:"alwith-preview-spinner"},void 0,!1,void 0,this),M(c,"loading")]},void 0,!0,void 0,this),r&&(a?e(N,{children:[e("div",{ref:p,className:"alwith-preview-audio-spectrum","aria-hidden":"true"},void 0,!1,void 0,this),e("audio",{ref:n,controls:!0,src:r,preload:"metadata",onError:()=>f(),children:e("track",{kind:"captions"},void 0,!1,void 0,this)},r,!1,void 0,this)]},void 0,!0,void 0,this):e(A,{src:r,controls:!0,width:"100%",height:"100%",preload:"metadata",playsInline:!0,style:{maxHeight:"100%"},onError:f},r,!1,void 0,this))]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}export{P as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{I}from"../chunk-s6jrc7pq.js";export{I as nextPdfZoom};
|
package/dist/previews/pdf.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { type PreviewProps } from "./index
|
|
1
|
+
import { type PreviewProps } from "./index";
|
|
2
2
|
export default function Pdf({ document: file, context, host }: PreviewProps): import("react").JSX.Element;
|
package/dist/previews/pdf.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import"../chunk-czgs93zj.js";import{j,M}from"../chunk-9mb4nnsc.js";import{I}from"../chunk-s6jrc7pq.js";import{D,N}from"../chunk-0m07f1rf.js";j(import.meta.url,["ft3hwgj5","czgs93zj","9mb4nnsc","s6jrc7pq","0m07f1rf","rpk588j2","x6e3x53v","g5mn8gma","pm5mxznh","pc0wr96w","ewq910t8","b5q2ys0a","6nvrc7p7","gq1eh0tx","dr1ebnb1","qt0cfrrv","qanrx7j1","nn5x2ear","68dtjjm4","b1xr49tw","sq7vxhx3","e5hxq2gn","yhtn3t0e","7zewhyx6","83qapya5","jdjcp0ak","bh9vgt8q"],[["./pdf.js",1,2,3,4],["../chunk-czgs93zj.js"],["../chunk-9mb4nnsc.js"],["../chunk-s6jrc7pq.js"],["../chunk-0m07f1rf.js",2],["./tiff.js",11,12,13,14,15,16,17,18,19,20,1,2,4],["./html.js",1,21,2,4],["./word.js",1,2,4],["./media.js",1,2,22,4],["./markdown.js",1,2,23,4,24],["./excel.js",25,26,1,2,4],["../chunk-b5q2ys0a.js"],["../chunk-6nvrc7p7.js"],["../chunk-gq1eh0tx.js"],["../chunk-dr1ebnb1.js"],["../chunk-qt0cfrrv.js"],["../chunk-qanrx7j1.js"],["../chunk-nn5x2ear.js"],["../chunk-68dtjjm4.js",15,16,17],["../chunk-b1xr49tw.js"],["../chunk-sq7vxhx3.js",11],["../chunk-e5hxq2gn.js",1],["../chunk-yhtn3t0e.js"],["../chunk-7zewhyx6.js",2],["../chunk-83qapya5.js",2,23,4],["../chunk-jdjcp0ak.js"],["../chunk-bh9vgt8q.js"]],0);
|
|
2
|
+
import{getDocument as U,GlobalWorkerOptions as Y,RenderingCancelledException as Z}from"pdfjs-dist";import{useEffect as x,useRef as E,useState as H}from"react";import{jsxDEV as g}from"react/jsx-dev-runtime";function _({document:S,context:C,host:h}){let y=E(null),[V,z]=H(null),[O,P]=H(!0),[T,b]=H(1),p=E(T);p.current=T;let v=E({context:C,host:h});v.current={context:C,host:h};let L=E(null);return x(()=>{let l=y.current;if(!l)throw Error("PDF container is missing");Y.workerSrc=h.pdfWorkerSrc,z(null),P(!0),b(1),l.replaceChildren();let o=!1,d=null,t=null,s=new Map,m=new Set,w=new Set,u=new Map,f=new Map,F=U({data:new Uint8Array(S.bytes)}),R=(e)=>{if(!o&&!(e instanceof Z))z(N(e)),v.current.context.onError(e)},k=(e)=>{let r=f.get(e);if(!r)throw Error("PDF page size is missing");e.style.width=`${r.width*p.current}px`,e.style.height=`${r.height*p.current}px`,e.style.minWidth=`${Math.min(720,r.width*p.current)}px`},A=(e)=>{u.set(e,(u.get(e)??0)+1),s.get(e)?.cancel(),s.delete(e),m.delete(e);for(let r of e.querySelectorAll("canvas"))r.width=0,r.height=0,r.remove()},q=async(e)=>{if(!d||m.has(e)||e.querySelector("canvas"))return;let r=(u.get(e)??0)+1;u.set(e,r),m.add(e);let n=null;try{let a=await d.getPage(Number(e.dataset.page));if(o||!w.has(e)||u.get(e)!==r)return;let i=a.getViewport({scale:1});f.set(e,{width:i.width,height:i.height}),k(e);let c=a.getViewport({scale:2*Math.min(window.devicePixelRatio||1,2)});if(c.width*c.height>25000000)throw Error("PDF page exceeds the canvas preview limit");n=document.createElement("canvas"),n.width=Math.ceil(c.width),n.height=Math.ceil(c.height);let K=n.getContext("2d");if(!K)throw Error("PDF canvas context is unavailable");let W=a.render({canvas:n,canvasContext:K,viewport:c});if(s.set(e,W),await W.promise,!o&&w.has(e)&&u.get(e)===r)e.append(n)}finally{if(n&&!n.parentElement)n.width=0,n.height=0;if(u.get(e)===r)s.delete(e),m.delete(e)}};return F.promise.then(async(e)=>{if(d=e,o)return;let r=await d.getPage(1);if(o)return;let n=r.getViewport({scale:1});t=new IntersectionObserver((a)=>{for(let i of a){let c=i.target;if(i.isIntersecting)w.add(c),q(c).catch(R);else w.delete(c),A(c)}},{root:l,rootMargin:"200% 0px"});for(let a=1;a<=d.numPages;a++){let i=document.createElement("div");i.className="alwith-preview-pdf-page",i.dataset.page=String(a),i.setAttribute("aria-label",`${M(v.current.host,"page")} ${a}`),f.set(i,{width:n.width,height:n.height}),k(i),l.append(i),t.observe(i)}L.current=()=>{for(let a of f.keys())k(a)},P(!1)}).catch((e)=>{if(R(e),!o)P(!1)}),()=>{o=!0,L.current=null,t?.disconnect();for(let e of f.keys())A(e);l.replaceChildren(),F.destroy().catch(v.current.context.onError)}},[S.bytes,h.pdfWorkerSrc]),x(()=>{L.current?.()},[T]),x(()=>{let l=y.current;if(!l)throw Error("PDF container is missing");let o=(t)=>{if(!t.ctrlKey&&!t.metaKey)return;let s=t.target;if(s&&(["INPUT","TEXTAREA","SELECT"].includes(s.tagName)||s.isContentEditable))return;if(I(p.current,t.key)===null)return;t.preventDefault(),b((w)=>I(w,t.key))},d=(t)=>{if(!t.ctrlKey&&!t.metaKey)return;if(t.preventDefault(),t.deltaY!==0)b((s)=>I(s,t.deltaY<0?"+":"-"))};return window.addEventListener("keydown",o),l.addEventListener("wheel",d,{passive:!1}),()=>{window.removeEventListener("keydown",o),l.removeEventListener("wheel",d)}},[]),g("div",{className:"alwith-preview-pdf alwith-preview-pdf-desktop",children:[g(D,{error:V},void 0,!1,void 0,this),O&&g("div",{className:"alwith-preview-pdf-loading",role:"status","aria-label":M(h,"loading"),children:g("span",{className:"alwith-preview-spinner"},void 0,!1,void 0,this)},void 0,!1,void 0,this),g("div",{className:"alwith-preview-pdf-scroll",ref:y},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}export{_ as default};
|
package/dist/previews/shared.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{C,D,k,N}from"../chunk-0m07f1rf.js";import{j}from"../chunk-9mb4nnsc.js";import"../chunk-czgs93zj.js";j(import.meta.url,["a29k789h","0m07f1rf","9mb4nnsc","czgs93zj","rpk588j2","x6e3x53v","g5mn8gma","ft3hwgj5","pm5mxznh","pc0wr96w","ewq910t8","b5q2ys0a","6nvrc7p7","gq1eh0tx","dr1ebnb1","qt0cfrrv","qanrx7j1","nn5x2ear","68dtjjm4","b1xr49tw","sq7vxhx3","e5hxq2gn","s6jrc7pq","yhtn3t0e","7zewhyx6","83qapya5","jdjcp0ak","bh9vgt8q"],[["./shared.js",1,2,3],["../chunk-0m07f1rf.js",2],["../chunk-9mb4nnsc.js"],["../chunk-czgs93zj.js"],["./tiff.js",11,12,13,14,15,16,17,18,19,20,3,2,1],["./html.js",3,21,2,1],["./word.js",3,2,1],["./pdf.js",3,2,22,1],["./media.js",3,2,23,1],["./markdown.js",3,2,24,1,25],["./excel.js",26,27,3,2,1],["../chunk-b5q2ys0a.js"],["../chunk-6nvrc7p7.js"],["../chunk-gq1eh0tx.js"],["../chunk-dr1ebnb1.js"],["../chunk-qt0cfrrv.js"],["../chunk-qanrx7j1.js"],["../chunk-nn5x2ear.js"],["../chunk-68dtjjm4.js",15,16,17],["../chunk-b1xr49tw.js"],["../chunk-sq7vxhx3.js",11],["../chunk-e5hxq2gn.js",3],["../chunk-s6jrc7pq.js"],["../chunk-yhtn3t0e.js"],["../chunk-7zewhyx6.js",2],["../chunk-83qapya5.js",2,24,1],["../chunk-jdjcp0ak.js"],["../chunk-bh9vgt8q.js"]],0);
|
|
2
|
+
export{D as ErrorMessage,k as ExternalButton,N as errorText,C as useObjectUrl};
|
package/dist/previews/tiff.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { type PreviewProps } from "./index
|
|
1
|
+
import { type PreviewProps } from "./index";
|
|
2
2
|
export default function Tiff({ document, context, host }: PreviewProps): import("react").JSX.Element;
|
package/dist/previews/tiff.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import"../chunk-b5q2ys0a.js";import"../chunk-6nvrc7p7.js";import"../chunk-gq1eh0tx.js";import"../chunk-dr1ebnb1.js";import"../chunk-qt0cfrrv.js";import"../chunk-qanrx7j1.js";import"../chunk-nn5x2ear.js";import"../chunk-68dtjjm4.js";import"../chunk-b1xr49tw.js";import{A}from"../chunk-sq7vxhx3.js";import"../chunk-czgs93zj.js";import{j,M}from"../chunk-9mb4nnsc.js";import{D,N}from"../chunk-0m07f1rf.js";j(import.meta.url,["rpk588j2","b5q2ys0a","6nvrc7p7","gq1eh0tx","dr1ebnb1","qt0cfrrv","qanrx7j1","nn5x2ear","68dtjjm4","b1xr49tw","sq7vxhx3","czgs93zj","9mb4nnsc","0m07f1rf","x6e3x53v","g5mn8gma","ft3hwgj5","pm5mxznh","pc0wr96w","ewq910t8","e5hxq2gn","s6jrc7pq","yhtn3t0e","7zewhyx6","83qapya5","jdjcp0ak","bh9vgt8q"],[["./tiff.js",1,2,3,4,5,6,7,8,9,10,11,12,13],["../chunk-b5q2ys0a.js"],["../chunk-6nvrc7p7.js"],["../chunk-gq1eh0tx.js"],["../chunk-dr1ebnb1.js"],["../chunk-qt0cfrrv.js"],["../chunk-qanrx7j1.js"],["../chunk-nn5x2ear.js"],["../chunk-68dtjjm4.js",5,6,7],["../chunk-b1xr49tw.js"],["../chunk-sq7vxhx3.js",1],["../chunk-czgs93zj.js"],["../chunk-9mb4nnsc.js"],["../chunk-0m07f1rf.js",12],["./html.js",11,20,12,13],["./word.js",11,12,13],["./pdf.js",11,12,21,13],["./media.js",11,12,22,13],["./markdown.js",11,12,23,13,24],["./excel.js",25,26,11,12,13],["../chunk-e5hxq2gn.js",11],["../chunk-s6jrc7pq.js"],["../chunk-yhtn3t0e.js"],["../chunk-7zewhyx6.js",12],["../chunk-83qapya5.js",12,23,13],["../chunk-jdjcp0ak.js"],["../chunk-bh9vgt8q.js"]],0);
|
|
2
|
+
import{useEffect as T,useEffectEvent as B,useMemo as k,useState as h}from"react";import*as l from"utif";import{jsxDEV as i}from"react/jsx-dev-runtime";function C({document:n,context:f,host:p}){let[g,u]=h(0),[m,y]=h(null),[U,c]=h(null),t=k(()=>{try{return{pages:l.decode(new Uint8Array(n.bytes).buffer),error:null}}catch(e){return{pages:[],error:e}}},[n.bytes]);T(()=>{u(0)},[n.bytes]);let w=B((e)=>f.onError(e));return T(()=>{let e=!1;y(null),c(null);try{if(t.error!==null)throw t.error instanceof Error?t.error:Error(N(t.error));let r=t.pages[g];if(!r)throw Error("TIFF contains no image pages");let o={...r},{t256:d,t257:b}=o,v=Array.isArray(d)?Number(d[0]):0,E=Array.isArray(b)?Number(b[0]):0;if(!v||!E||v*E>25000000)throw Error("TIFF image dimensions exceed the preview limit");l.decodeImage(new Uint8Array(n.bytes).buffer,o);let P=l.toRGBA8(o),s=window.document.createElement("canvas");s.width=o.width,s.height=o.height;let F=s.getContext("2d");if(!F)throw Error("TIFF canvas context is unavailable");F.putImageData(new ImageData(new Uint8ClampedArray(P),o.width,o.height),0,0),s.toBlob((I)=>{if(s.width=0,s.height=0,!I){if(!e){let a=Error("Unable to encode TIFF preview");c(a.message),w(a)}return}I.arrayBuffer().then((a)=>{if(!e)y(new Uint8Array(a))}).catch((a)=>{if(!e)c(N(a)),w(a)})},"image/png")}catch(r){c(N(r)),w(r)}return()=>{e=!0}},[n.bytes,t,g]),i("div",{className:"alwith-preview-excel",children:[i(D,{error:U},void 0,!1,void 0,this),t.pages.length>1&&i("label",{className:"alwith-preview-sheets",children:[M(p,"page"),i("select",{value:g,onChange:(e)=>u(Number(e.target.value)),children:t.pages.map((e,r)=>i("option",{value:r,children:r+1},r,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),m&&i(A,{document:{...n,bytes:m},labels:p.imageLabels,onError:f.onError},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}export{C as default};
|
package/dist/previews/word.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { type PreviewProps } from "./index
|
|
1
|
+
import { type PreviewProps } from "./index";
|
|
2
2
|
export default function Word(props: PreviewProps): import("react").JSX.Element;
|
package/dist/previews/word.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import"../chunk-czgs93zj.js";import{j,M}from"../chunk-9mb4nnsc.js";import{D,k,N}from"../chunk-0m07f1rf.js";j(import.meta.url,["g5mn8gma","czgs93zj","9mb4nnsc","0m07f1rf","rpk588j2","x6e3x53v","ft3hwgj5","pm5mxznh","pc0wr96w","ewq910t8","b5q2ys0a","6nvrc7p7","gq1eh0tx","dr1ebnb1","qt0cfrrv","qanrx7j1","nn5x2ear","68dtjjm4","b1xr49tw","sq7vxhx3","e5hxq2gn","s6jrc7pq","yhtn3t0e","7zewhyx6","83qapya5","jdjcp0ak","bh9vgt8q"],[["./word.js",1,2,3],["../chunk-czgs93zj.js"],["../chunk-9mb4nnsc.js"],["../chunk-0m07f1rf.js",2],["./tiff.js",10,11,12,13,14,15,16,17,18,19,1,2,3],["./html.js",1,20,2,3],["./pdf.js",1,2,21,3],["./media.js",1,2,22,3],["./markdown.js",1,2,23,3,24],["./excel.js",25,26,1,2,3],["../chunk-b5q2ys0a.js"],["../chunk-6nvrc7p7.js"],["../chunk-gq1eh0tx.js"],["../chunk-dr1ebnb1.js"],["../chunk-qt0cfrrv.js"],["../chunk-qanrx7j1.js"],["../chunk-nn5x2ear.js"],["../chunk-68dtjjm4.js",14,15,16],["../chunk-b1xr49tw.js"],["../chunk-sq7vxhx3.js",10],["../chunk-e5hxq2gn.js",1],["../chunk-s6jrc7pq.js"],["../chunk-yhtn3t0e.js"],["../chunk-7zewhyx6.js",2],["../chunk-83qapya5.js",2,23,3],["../chunk-jdjcp0ak.js"],["../chunk-bh9vgt8q.js"]],0);
|
|
2
|
+
import{renderAsync as m}from"docx-preview";import{useEffect as y,useEffectEvent as h,useState as a}from"react";import{jsxDEV as o,Fragment as w}from"react/jsx-dev-runtime";function v(e){let[c,s]=a(null),[d,u]=a(null),l=/\.(doc|dot)$/i.test(e.document.path)||[208,207,17,224,161,177,26,225].every((t,r)=>e.document.bytes[r]===t),f=h((t)=>e.context.onError(t));return y(()=>{if(l)return;let t=!1,r=window.document.createElement("div"),i=window.document.createElement("div");return u(null),s(null),m(new Uint8Array(e.document.bytes).buffer,r,i,{ignoreFonts:!0,useBase64URL:!0,renderAltChunks:!1}).then(()=>{if(t)return;for(let n of r.querySelectorAll("script,iframe,object,embed"))n.remove();for(let n of r.querySelectorAll("[href]"))n.removeAttribute("href");s(`<!doctype html><html><head><meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data:; style-src 'unsafe-inline'; form-action 'none'; base-uri 'none'">${i.innerHTML}</head><body>${r.innerHTML}</body></html>`)}).catch((n)=>{if(!t)u(N(n)),f(n)}).finally(()=>{r.replaceChildren(),i.replaceChildren()}),()=>{t=!0}},[e.document.bytes,l]),o("div",{className:"alwith-preview-html alwith-preview-word",children:l?o("div",{className:"alwith-preview-status",children:[M(e.host,"legacyWord"),o(k,{...e},void 0,!1,void 0,this)]},void 0,!0,void 0,this):o(w,{children:[o(D,{error:d},void 0,!1,void 0,this),c&&o("iframe",{title:e.document.path.split("/").at(-1),sandbox:"",referrerPolicy:"no-referrer",srcDoc:c},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}export{v as default};
|