PageSourceSearch

https://metool.online/_assets/js/edit.DRPj-klj.js

js metool.online collected 2026-10-04 19:07:07 UTC 17,061 bytes, 139 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./LatexWasmStudio.CpmT4uJr.js","./entry.q2vg8f26.js","./vue.BHwQAC8Z.js","../css/entry.BlhIgkn4.css","./LatexEditorPanel.BhC8hB-V.js","./file._rkF38iv.js","./latexToHtml.Ch93ETaN.js","./projectFiles.Co11vA9O.js","./LatexPreview.DuaFRfLy.js","./interval.Bq9kqul3.js","../css/LatexPreview.D0U0su4l.css","./codemirror.DehOuXct.js","./composables.Ke7ssj2i.js","./pdfJs.CrCJZM5Y.js","./useLatexEngine.DME6W3ZY.js","../css/LatexWasmStudio.ChQtAHHA.css"])))=>i.map(i=>d[i]);
2/* © 2024-2026 MeTool.online. All rights reserved. Unauthorized copying or redistribution is prohibited. */
3import{d as de,w as b,o as pe,E as F,z,e as h,q as M,y as R,P as X,C as _,v as fe,c as W,B as xe,G as ge,W as we,_ as ye,f as _e,n as he}from"./vue.BHwQAC8Z.js";import{f as ve,r as be,p as Ee}from"./entry.q2vg8f26.js";import{T as Te}from"./ToolPageLayout.BKevcskg.js";import{L as Pe}from"./LatexEditorPanel.BhC8hB-V.js";import{u as $e,M as Ce}from"./useToolMcpRelay.xHT8laQs.js";import{u as Le,s as O,g as Me}from"./useToolGa4.HZ1kdNPy.js";import{u as ke}from"./useLatexProject.DeZ3Q5Qz.js";import{i as De,b as Se}from"./projectFiles.Co11vA9O.js";import{n as V}from"./projectFiles.2RN-axH5.js";import{downloadBlob as Fe}from"./file._rkF38iv.js";import"./AppSiteFooterBar.DaI0tcoG.js";import"./ToolBreadcrumb.W6i9Er2k.js";import"./AppIcon.kB3f-rsX.js";import"./iconLibrary.DB9GK0r4.js";import"./FavoriteStarButton.DO1P1yzW.js";import"./useUserLibrary.GGsQQArI.js";import"./useFeedback.Dr-ufl2w.js";import"./useRelatedTools.DFXR-u5P.js";import"./useToolGroup.D6DXaJBJ.js";import"./useGameTools.Cea25uJs.js";import"./useImageTools.DnXsyVeV.js";import"./useMagicTools.CMgTWyzO.js";import"./useDocTools.M0St8VTC.js";import"./brandSvgs.3qwNwPst.js";
3import"./useMarkdownTools.MAZnT9yn.js";import"./use3DTools.B2gNq-E_.js";import"./useDevTools.Du8khQc-.js";import"./useVideoTools.wfF_hwIl.js";import"./useAISkillTools.DxAcHgjm.js";import"./useLatexTools.CNuf4UvK.js";import"./useHtmlTools.eon9ygLT.js";import"./useCategoryChrome.DfAp-lE4.js";import"./useReadQueryParam.d9oDta5j.js";import"./latexToHtml.Ch93ETaN.js";import"./LatexPreview.DuaFRfLy.js";import"./interval.Bq9kqul3.js";import"./codemirror.DehOuXct.js";import"./composables.Ke7ssj2i.js";import"./McpRobotAvatar.CWn9K7G7.js";import"./McpAiUsageScene.BWFxNkv6.js";import"./NuxtImg.CQcfjr1Q.js";import"./McpConnectFlow.CjN9gpjl.js";import"./AuthLoginPanel.6BO_3-aa.js";import"./TurnstileWidget.CKVAXgA9.js";import"./safeRedirect.ChHJvCig.js";import"./ga4.CSfqKzxe.js";import"./metoolSkill.BWk2OZE5.js";import"./baseUrl.-I_t1oyB.js";const H="metool:latex:engine-mode",qe="metool-latex-engine-";async function Ne(){if(typeof window>"u"||!("caches"in window))return!1;try{const t=await caches.keys();for(const r of t){if(!r.startsWith(qe))continue;const p=(await(await caches.open(r)).keys()).map(a=>a.url),c=p.some(a=>a.includes("/latex/wasm/busytex.wasm")),x=p.some(a=>a.includes("/latex/wasm/texlive-core.data"));if(c&&x)return!0}}catch{}return!1}function Ie(){if(typeof localStorage>"u")return null;try{const t=localStorage.getItem(H);return t==="fast"||t==="wasm"?t:null}catch{return null}}function Y(t){if(!(typeof localStorage>"u"))try{localStorage.setItem(H,t)}catch{}}async function je(){return Ie()??(await Ne()?"wasm":"fast")}const Ae="metool_latex_v1",E="drafts",K="edit",U="metool_latex_edit_content",Be=600;function J(){return new Promise((t,r)=>{const n=indexedDB.open(Ae,1);n.onupgradeneeded=()=>{n.result.createObjectStore(E)},n.onsuccess=()=>t(n.result),n.onerror=()=>r(n.error)})}async function ze(t){const r=await J();await new Promise((n,p)=>{const c=r.transaction(E,"readwrite");c.objectStore(E).put(t,K),c.oncomplete=()=>{r.close(),n()},c.onerror=()=>{r.close(),p(c.error)}})}let k=null,q=null;function Re(t,r){q={files:[...t],entryPath:r,savedAt:Date.now()},k&&clearTimeout(k),k=setTimeout(()=>{k=null;const n=q;q=null,n&&ze(n).catch(()=>{})},Be)}async function Xe(){try{const t=await J(),r=await new Promise((n,p)=>{const c=t.transaction(E,"readonly"),x=c.objectStore(E).get(K);x.onsuccess=()=>n(x.result),x.onerror=()=>p(x.error),c.oncomplete=()=>t.close()});if(r?.files?.length)return r}catch{}return We()}function We(){try{const t=localStorage.getItem(U);return t?.trim()?(localStorage.removeItem(U),{files:[["main.tex",t]],entryPath:"main.tex",savedAt:Date.now()}):null}catch{return null}}const v=180*1024,Oe={tex:"text/x-tex",bib:"text/x-bibtex",cls:"text/x-tex",sty:"text/x-tex",bst:"text/x-bibtex",bbx:"text/x-bibtex",cbx:"text/x-bibtex",def:"text/x-tex",clo:"text/x-tex",ltx:"text/x-tex",txt:"text/plain",md:"text/markdown"},Ye={pdf:"application/pdf",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",svg:"image/svg+xml",bmp:"image/bmp",tif:"image/tiff",tiff:"image/tiff",eps:"application/postscript",ps:"application/postscript",otf:"font/otf",ttf:"font/ttf"},D=new TextEncoder;function Ue(t){return t.slice(t.lastIndexOf(".")+1).toLowerCase()}function N(t,r){const n=Ue(t);return(r?Ye:Oe)[n]??(r?"application/octet-stream":"text/plain")}function G(t){if(typeof t!="string")throw new Error("path must be a non-empty string");const r=V(t);if(!r)throw new Error(`invalid_path: ${t}`);if(!De(r))throw new Error(`unsupported_text_file: ${r}`);return r}function Ge(t,r={}){function n(){const a={};for(const[i,s]of t.files.value)typeof s=="string"&&(a[i]={content:s,mimeType:N(i,!1)});return{revision:t.revision.value,files:a}}function p(){const a=[...t.files.value].map(([i,s])=>{const m=typeof s!="string";return{path:i,mimeType:N(i,m),bytes:typeof s=="string"?D.encode(s).byteLength:s.byteLength,readOnly:m||void 0,entry:i===t.entryPath.value||void 0}});return{revision:t.revision.value,files:a.sort((i,s)=>i.path.localeCompare(s.path))}}function c(a){const i=V(a);if(!i)throw new Error(`invalid_path: ${a}`);const s=t.files.value.get(i);if(s===void 0)throw new Error(`file_not_found: ${i}`);
3if(typeof s!="string")throw new Error(`binary_file_read_only: ${i}; bytes are not sent through MCP`);const m=D.encode(s).byteLength;if(m>v)throw new Error(`file_too_large_for_mcp: ${i} is ${m} bytes; limit is ${v}`);return{path:i,content:s,mimeType:N(i,!1),revision:t.revision.value}}function x(a){if(a.op==="write_file"){const i=G(a.payload.path),s=a.payload.content;if(typeof s!="string")throw new Error("content must be a string");const m=D.encode(s).byteLength;if(m>v)throw new Error(`file_too_large_for_mcp: ${i} is ${m} bytes; limit is ${v}`);const g=t.writeTextFile(i,s);return t.files.value.size>1&&r.onMultiFileWrite?.(),{ok:!0,...g}}if(a.op==="edit_file"){const i=G(a.payload.path),s=a.payload.old_text,m=a.payload.new_text;if(typeof s!="string"||typeof m!="string")throw new Error("old_text and new_text must be strings");const g=t.files.value.get(i);if(g===void 0)throw new Error(`file_not_found: ${i}`);if(typeof g!="string")throw new Error(`binary_file_read_only: ${i}`);if(!g.includes(s))throw new Error("old_text not present in file");const T=g.replace(s,m),l=D.encode(T).byteLength;if(l>v)throw new Error(`file_too_large_for_mcp: ${i} is ${l} bytes; limit is ${v}`);const d=t.writeTextFile(i,T);return t.files.value.size>1&&r.onMultiFileWrite?.(),{ok:!0,...d,patched:!0}}throw new Error(`unknown op: ${a.op}`)}return{getWorkspace:n,listFiles:p,readFile:c,applyCommand:x}}const Ve={key:2,class:"absolute inset-0 z-50 flex flex-col items-center justify-center gap-3 bg-blue-50/90 dark:bg-blue-950/80 border-2 border-dashed border-blue-400 dark:border-blue-600 rounded-xl pointer-events-none"},He={class:"text-sm font-medium text-blue-700 dark:text-blue-300"},Ot=de({__name:"edit",setup(t){const r=we(()=>ye(()=>import("./LatexWasmStudio.CpmT4uJr.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]),import.meta.url)),{t:n,locale:p}=ve(),c=Le("latex","edit");be({title:n("meta.latex.edit.title"),description:n("meta.latex.edit.description"),keywords:n("meta.latex.edit.keywords")});const x=[{question:n("pages.latex.edit.faq1q"),answer:n("pages.latex.edit.faq1a")},{question:n("pages.latex.edit.faq2q"),answer:n("pages.latex.edit.faq2a")},{question:n("pages.latex.edit.faq3q"),answer:n("pages.latex.edit.faq3a")},{question:n("pages.latex.edit.faq4q"),answer:n("pages.latex.edit.faq4a")},{question:n("pages.latex.edit.faq5q"),answer:n("pages.latex.edit.faq5a")}],a=h("fast"),i=new Date().getFullYear(),s=`\\documentclass{article}
4
5\\title{MeTool.online LaTeX 编辑器}
6\\author{metool.online}
7\\date{${i}}
8
9\\begin{document}
10
11\\maketitle
12
13\\begin{abstract}
14\\textbf{MeTool.online} 是一款纯前端在线工具箱(80+ 款工具),所有处理均在浏览器完成,数据零上传。
15本 LaTeX 编辑器基于 latex.js,支持即时预览,可导出 PDF / HTML / PNG。
16\\end{abstract}
17
18\\section{文本格式}
19
20\\textbf{粗体文本},\\textit{斜体文本},\\underline{下划线},\\texttt{等宽代码字体}。
21
22普通段落自动换行,空行开始新段落。连字符:en-dash --,em-dash ---。
23
24\\section{列表}
25
26\\subsection{无序列表}
27
28\\begin{itemize}
29  \\item 图片工具:压缩、裁剪、格式转换
30  \\item Markdown 编辑器:实时预览与导出
31  \\item LaTeX 编辑器:本页面
32  \\item 开发工具:JSON 美化、Base64、正则测试
33\\end{itemize}
34
35\\subsection{有序列表}
36
37\\begin{enumerate}
38  \\item 粘贴或上传 .tex 文件
39  \\item 在右侧预览渲染结果
40  \\item 点击"导出"按钮下载 PDF / HTML / PNG
41\\end{enumerate}
42
43\\section{数学公式}
44
45行内公式:质能方程 $E = mc^2$,欧拉恒等式 $e^{i\\pi} + 1 = 0$。
46
47块级公式——高斯积分:
48$$
49\\int_{-\\infty}^{+\\infty} e^{-x^2}\\,dx = \\sqrt{\\pi}
50$$
51
52求和公式:
53$$
54\\sum_{n=1}^{\\infty} \\frac{1}{n^2} = \\frac{\\pi^2}{6}
55$$
56
57\\section{表格}
58
59\\begin{tabular}{lll}
60\\hline
61\\textbf{城市} & \\textbf{国家} & \\textbf{人口(百万)} \\\\
62\\hline
63东京 & 日本 & 13.96 \\\\
64上海 & 中国 & 24.87 \\\\
65纽约 & 美国 & 8.34 \\\\
66伦敦 & 英国 & 9.54 \\\\
67\\hline
68\\end{tabular}
69
70\\end{document}
71`,m=`\\documentclass{article}
72
73\\title{MeTool.online LaTeX Editor}
74\\author{metool.online}
75\\date{${i}}
76
77\\begin{document}
78
79\\maketitle
80
81\\begin{abstract}
82\\textbf{MeTool.online} is a pure-frontend toolbox with 80+ tools --- everything runs in your browser, zero data upload.
83This LaTeX editor is powered by latex.js with live preview and PDF / HTML / PNG export.
84\\end{abstract}
85
86\\section{Text Formatting}
87
88\\textbf{Bold text}, \\textit{italic text}, \\underline{underline}, \\texttt{monospace code font}.
89
90Blank lines start new paragraphs. Dashes: en-dash --, em-dash ---.
91
92\\section{Lists}
93
94\\subsection{Unordered List}
95
96\\begin{itemize}
97  \\item Image tools: compress, crop, convert
98  \\item Markdown editor: live preview and export
99  \\item LaTeX editor: this page
100  \\item Dev tools: JSON beautify, Base64, regex tester
101\\end{itemize}
102
103\\subsection{Ordered List}
104
105\\begin{enumerate}
106  \\item Paste or upload a .tex file
107  \\item Preview the rendered result on the right
108  \\item Click "Export" to download PDF / HTML / PNG
109\\end{enumerate}
110
111\\section{Math Formulas}
112
113Inline: mass--energy equivalence $E = mc^2$, Euler's identity $e^{i\\pi} + 1 = 0$.
114
115Display --- Gaussian integral:
116$$
117\\int_{-\\infty}^{+\\infty} e^{-x^2}\\,dx = \\sqrt{\\pi}
118$$
119
120Basel problem:
121$$
122\\sum_{n=1}^{\\infty} \\frac{1}{n^2} = \\frac{\\pi^2}{6}
123$$
124
125\\section{Table}
126
127\\begin{tabular}{lll}
128\\hline
129\\textbf{City} & \\textbf{Country} & \\textbf{Population (M)} \\\\
130\\hline
131Tokyo & Japan & 13.96 \\\\
132Shanghai & China & 24.87 \\\\
133New York & USA & 8.34 \\\\
134London & UK & 9.54 \\\\
135\\hline
136\\end{tabular}
137
138\\end{document}
139`,g=e=>e==="zh"?s:m,T=e=>e===s||e===m,l=ke();l.setSingleSource(g(p.value));const d=_e({get:()=>{const e=l.files.value.get(l.entryPath.value);return typeof e=="string"?e:""},set:e=>{const o=l.entryPath.value;o?l.updateFile(o,e):l.setSingleSource(e)}});b(p,(e,o)=>{d.value===g(o)&&(d.value=g(e))});const I=h(!1);b(()=>l.files.value,e=>{e.size&&Re(e,l.entryPath.value)}),b(d,()=>{if(a.value==="fast"&&!I.value&&d.value.trim()&&!T(d.value)){I.value=!0;const e=performance.now();c.toolInputReady({input_method:"text",engine:"latexjs"}),c.toolRunStart({engine:"latexjs"}),c.toolRunSuccess({duration_ms:Math.round(performance.now()-e),engine:"latexjs"})}});const j=h(!0),w=h(null),P=h(!1),S=h(null);b(w,async e=>{const o=S.value;!e||!o||(S.value=null,await e.importDropped(o))}),pe(async()=>{const e=l.revision.value,o=await Xe();o&&l.revision.value===e&&l.importEntries(o.files.map(([f,L])=>({path:f,content:L}))).status==="loaded"&&(l.setEntry(o.entryPath),l.openFile(o.entryPath)),!(!(l.isProjectMode.value||await je()==="wasm")||a.value==="wasm")&&(a.value="wasm",O("latex_engine_upgrade",{tool_category:"latex",tool_id:"edit",reason:l.isProjectMode.value?"restored_project":"cached_default"}))});function $(e,o={}){a.value!=="wasm"&&(j.value=o.autoCompile??!0,a.value="wasm",Y("wasm"),O("latex_engine_upgrade",{tool_category:"latex",tool_id:"edit",reason:e}))}function Z(){a.value="fast",Y("fast")}async function A(e){if(e.length){if($("project_import",{autoCompile:!1}),w.value){await w.value.importDropped(e);return}S.value=e}}async function Q(e){P.value=!1;const o=[...e.dataTransfer?.files??[]];if(o.length){if(!Se(o)){d.value=await o[0].text();return}await A(o)}}function ee(e){}const C=Ge(l,{onMultiFileWrite:()=>$("mcp_multi_file",{autoCompile:!1})});async function te(){return a.value!=="wasm"&&$("mcp_compile",{autoCompile:!1}),await he(),w.value?w.value:await new Promise((e,o)=>{const y=setTimeout(()=>{u(),o(new Error("workspace_not_ready: LaTeX engine UI did not initialize"))},1e4),u=b(w,f=>{f&&(clearTimeout(y),u(),e(f))},{immediate:!0})})}function B(){const e=l.entryPath.value.replace(/^.*\//,"").replace(/\.tex$/i,"")||"metool_latex";return l.isProjectMode.value?{id:"source",label:"LaTeX project source (ZIP)",filename:"metool_latex_edit.zip",mimeType:"application/zip",ready:!0}:{id:"source",label:"LaTeX source (TEX)",filename:`${e}_metool.tex`,mimeType:"text/x-tex",bytes:new TextEncoder().encode(d.value).byteLength,ready:!0}}function oe(){const e=l.entryPath.value.replace(/^.*\//,"").replace(/\.tex$/i,"")||"metool_latex";return[B(),{id:"pdf",label:"Compiled PDF",filename:`${e}_metool.pdf`,mimeType:"application/pdf",ready:w.value?.hasCurrentPdf()??!1}]}async function ne(e){if(!e?.length)throw new Error("need_choice: call list_artifacts and ask which output to save");const o=e.filter(u=>u!=="source"&&u!=="pdf");if(o.length)throw new Error(`unknown artifact ids: ${o.join(", ")}`);
139if(e.includes("pdf")&&!(w.value?.hasCurrentPdf()??!1))throw new Error("artifact_not_ready: call compile_document first");const y=[];for(const u of[...new Set(e)]){if(u==="source"){const f=B();if(l.isProjectMode.value)await l.downloadZip(f.filename),y.push({id:u,filename:f.filename,mimeType:f.mimeType});else{const L=new Blob([d.value],{type:"text/x-tex;charset=utf-8"});Fe(L,f.filename),y.push({id:u,filename:f.filename,mimeType:f.mimeType,bytes:L.size})}continue}y.push({id:u,...w.value.saveCurrentPdf()})}return{delivery:"browser_download_request",files:y}}async function ae(e){return e.op==="compile_document"?(await te()).startCompile():C.applyCommand(e)}const{status:ie,errorMessage:re,connect:se,disconnect:le}=$e({toolKey:"latex/edit",getWorkspace:C.getWorkspace,listFiles:C.listFiles,readFile:C.readFile,applyCommand:ae,listArtifacts:oe,saveArtifacts:ne});function ce(e){c.toolRunStart({engine:"wasm",packs:e.join("+")})}function ue({ms:e,packs:o}){c.toolRunSuccess({duration_ms:Math.round(e),engine:"wasm",packs:o.join("+")})}function me(e){if(e.userRecoverable){c.toolUserRecoverable({engine:"wasm",reason_code:e.reasonCode,reason_msg:e.missingPackages.slice(0,5).join(",")||e.kind});return}c.toolRunError({engine:"wasm",error_code:e.reasonCode,error_msg:Me(`${e.kind}: ${e.missingPackages.join(",")||"n/a"}`)})}return(e,o)=>{const y=Ee;return M(),F(Te,{category:"latex","tool-id":"edit",shortName:e.$t("meta.latex.edit.shortName"),title:e.$t("meta.latex.edit.title"),description:e.$t("pages.latex.edit.heroLead"),compact:!0,faqs:x},{"title-actions":z(()=>[W(Ce,{category:"latex","tool-id":"edit",status:_(ie),"error-code":_(re),onConnect:_(se),onDisconnect:_(le)},null,8,["status","error-code","onConnect","onDisconnect"])]),default:z(()=>[R("div",{class:"relative h-full",onDragover:o[1]||(o[1]=X(u=>P.value=!0,["prevent"])),onDragleave:o[2]||(o[2]=u=>P.value=!1),onDrop:X(Q,["prevent"])},[a.value==="wasm"?(M(),F(_(r),{key:0,ref_key:"studioRef",ref:w,project:_(l),"auto-compile":j.value,onImport:ee,onExit:Z,onCompileStart:ce,onCompileSuccess:ue,onCompileFailure:me},null,8,["project","auto-compile"])):(M(),F(Pe,{key:1,modelValue:d.value,"onUpdate:modelValue":o[0]||(o[0]=u=>d.value=u),"download-name":"metool_latex_edit","can-upgrade":"",onUpgrade:$,onImportProject:A},null,8,["modelValue"])),P.value?(M(),fe("div",Ve,[W(y,{icon:"lucide:folder-down",class:"w-10 h-10 text-blue-500"}),R("p",He,xe(_(n)("pages.latex.edit.dropHint")),1)])):ge("",!0)],32)]),_:1},8,["shortName","title","description"])}}});export{Ot as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.