Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

feat: align mobile note image sharing

tianma-if47b8f86c1d11
diff --git a/apps/ios/EdgeEver/Features/Workspace/MemoDetailView.swift b/apps/ios/EdgeEver/Features/Workspace/MemoDetailView.swift
index 15a4f06b..e43ec139 100644
--- a/apps/ios/EdgeEver/Features/Workspace/MemoDetailView.swift
+++ b/apps/ios/EdgeEver/Features/Workspace/MemoDetailView.swift
@@ -15,6 +15,8 @@ struct MemoDetailView: View {
@State private var showRevisions = false
@State private var memoSharePayload: MemoSharePayload?
@State private var imageExportSharePayload: MemoImageExportSharePayload?
+ @State private var imageExportPreviewPayload: MemoImageExportPreviewPayload?
+ @State private var imageExportDocumentPayload: MemoImageExportDocumentPayload?
@State private var imageExportMessage: MemoImageExportMessage?
@State private var imageExporting = false
@State private var imageExportBuffer = MemoImageExportBuffer()
@@ -22,11 +24,14 @@ struct MemoDetailView: View {
@State private var imageShareFormat = "png"
@State private var imageShareTheme = "slate"
@State private var imageShareFontStyle = "serif"
+ @State private var imageShareFontSize = "lg"
+ @State private var imageShareCardWidth = "standard"
@State private var imageShareTitle = true
@State private var imageShareNotebook = false
@State private var imageShareTags = false
@State private var imageShareUpdatedAt = true
@State private var imageShareBranding = true
+ @State private var imageExportIntent: MemoImageExportIntent = .share
@State private var error: String?
@State private var conflictItem: OutboxItem?
@State private var outboxStatus: OutboxStatus?
@@ -129,6 +134,49 @@ struct MemoDetailView: View {
imageExportSharePayload = nil
}
}
+ .sheet(item: $imageExportDocumentPayload) { payload in
+ MemoImageDocumentExportView(fileURL: payload.url) { result in
+ if case let .failure(exportError) = result {
+ imageExportMessage = MemoImageExportMessage(
+ title: env.preferences.t("保存失败", en: "Save failed"),
+ message: exportError.localizedDescription
+ )
+ }
+ imageExportDocumentPayload = nil
+ }
+ }
+ .sheet(item: $imageExportPreviewPayload) { payload in
+ MemoImageExportPreviewView(
+ payload: payload,
+ isEnglish: env.preferences.isEnglish,
+ onCopy: {
+ guard let image = UIImage(contentsOfFile: payload.url.path) else {
+ imageExportMessage = MemoImageExportMessage(
+ title: env.preferences.t("复制失败", en: "Copy failed"),
+ message: env.preferences.t("无法读取生成的图片。", en: "The generated image could not be read.")
+ )
+ return
+ }
+ UIPasteboard.general.image = image
+ imageExportMessage = MemoImageExportMessage(
+ title: env.preferences.t("复制成功", en: "Copied"),
+ message: env.preferences.t("图片已复制到剪贴板。", en: "The image is on your clipboard.")
+ )
+ },
+ onSave: {
+ imageExportPreviewPayload = nil
+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) {
+ imageExportDocumentPayload = MemoImageExportDocumentPayload(url: payload.url)
+ }
+ },
+ onShare: {
+ imageExportPreviewPayload = nil
+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) {
+ imageExportSharePayload = MemoImageExportSharePayload(url: payload.url)
+ }
+ }
+ )
+ }
.sheet(isPresented: $imageShareOptionsOpen) {
NavigationStack {
Form {
@@ -153,6 +201,22 @@ struct MemoDetailView: View {
}
.pickerStyle(.segmented)
}
+ Section(env.preferences.t("字号大小", en: "Font size")) {
+ Picker(env.preferences.t("字号大小", en: "Font size"), selection: $imageShareFontSize) {
+ Text(env.preferences.t("紧凑", en: "Compact")).tag("sm")
+ Text(env.preferences.t("标准", en: "Standard")).tag("md")
+ Text(env.preferences.t("舒适", en: "Comfortable")).tag("lg")
+ }
+ .pickerStyle(.segmented)
+ }
+ Section(env.preferences.t("卡片宽度", en: "Card width")) {
+ Picker(env.preferences.t("卡片宽度", en: "Card width"), selection: $imageShareCardWidth) {
+ Text(env.preferences.t("紧凑", en: "Compact")).tag("compact")
+ Text(env.preferences.t("标准", en: "Standard")).tag("standard")
+ Text(env.preferences.t("宽屏", en: "Wide")).tag("wide")
+ }
+ .pickerStyle(.segmented)
+ }
Section(env.preferences.t("显示内容", en: "Content elements")) {
Toggle(env.preferences.t("笔记标题", en: "Note title"), isOn: $imageShareTitle)
Toggle(env.preferences.t("笔记本", en: "Notebook"), isOn: $imageShareNotebook)
@@ -175,7 +239,7 @@ struct MemoDetailView: View {
Button(env.preferences.t("取消", en: "Cancel")) { imageShareOptionsOpen = false }
}
ToolbarItem(placement: .confirmationAction) {
- Button(env.preferences.t("生成并分享", en: "Generate & Share")) {
+ Button(env.preferences.t("生成预览", en: "Generate Preview")) {
guard let memo else { return }
imageShareOptionsOpen = false
exportMemoImage(
@@ -183,11 +247,14 @@ struct MemoDetailView: View {
format: imageShareFormat,
theme: imageShareTheme,
fontStyle: imageShareFontStyle,
+ fontSize: imageShareFontSize,
+ cardWidth: imageShareCardWidth,
showTitle: imageShareTitle,
showNotebook: imageShareNotebook,
showTags: imageShareTags,
showUpdatedAt: imageShareUpdatedAt,
- showBranding: imageShareBranding
+ showBranding: imageShareBranding,
+ intent: .preview
)
}
.disabled(imageExporting || !bodyReady || memo == nil)
@@ -943,15 +1010,19 @@ struct MemoDetailView: View {
format: String,
theme: String = "slate",
fontStyle: String = "serif",
+ fontSize: String = "lg",
+ cardWidth: String = "standard",
showTitle: Bool = true,
showNotebook: Bool = false,
showTags: Bool = false,
showUpdatedAt: Bool = true,
- showBranding: Bool = true
+ showBranding: Bool = true,
+ intent: MemoImageExportIntent = .share
) {
guard !imageExporting, bodyReady else { return }
let requestId = UUID().uuidString
imageExportBuffer.start(requestId: requestId)
+ imageExportIntent = intent
imageExporting = true
let title = memo.title?.trimmingCharacters(in: .whitespacesAndNewlines)
SharedTipTapRuntime.viewer.exportNoteImage(request: [
@@ -961,9 +1032,11 @@ struct MemoDetailView: View {
"fallbackTitle": env.preferences.t("无标题笔记", en: "Untitled note"),
"notebook": showNotebook ? notebookName(for: memo) : "",
"tags": showTags ? memo.tags : [],
- "updatedAt": showUpdatedAt ? memo.updatedAt : "",
+ "updatedAt": showUpdatedAt ? formattedImageExportDate(memo.updatedAt) : "",
"theme": theme,
"fontStyle": fontStyle,
+ "fontSize": fontSize,
+ "cardWidth": cardWidth,
"showTitle": showTitle,
"showNotebook": showNotebook,
"showTags": showTags,
@@ -972,6 +1045,16 @@ struct MemoDetailView: View {
])
}
+ private func formattedImageExportDate(_ rawValue: String) -> String {
+ let parsers = [ISO8601DateFormatter.edgeEver, ISO8601DateFormatter.edgeEverFallback]
+ guard let date = parsers.lazy.compactMap({ $0.date(from: rawValue) }).first else { return rawValue }
+ let formatter = DateFormatter()
+ formatter.locale = env.preferences.isEnglish ? Locale(identifier: "en_US") : Locale(identifier: "zh_CN")
+ formatter.dateStyle = .medium
+ formatter.timeStyle = .short
+ return formatter.string(from: date)
+ }
+
private func handleImageExportEvent(_ event: [String: Any]) {
switch imageExportBuffer.accept(event) {
case .none:
@@ -982,7 +1065,7 @@ struct MemoDetailView: View {
title: env.preferences.t("导出失败", en: "Export failed"),
message: message
)
- case let .complete(data, filename):
+ case let .complete(data, filename, metadata):
imageExporting = false
do {
let directory = FileManager.default.temporaryDirectory.appendingPathComponent("EdgeEverNoteExports", isDirectory: true)
@@ -990,7 +1073,17 @@ struct MemoDetailView: View {
let safeFilename = (filename as NSString).lastPathComponent
let url = directory.appendingPathComponent(safeFilename)
try data.write(to: url, options: .atomic)
- imageExportSharePayload = MemoImageExportSharePayload(url: url)
+ if imageExportIntent == .preview {
+ imageExportPreviewPayload = MemoImageExportPreviewPayload(
+ url: url,
+ width: metadata.width,
+ height: metadata.height,
+ totalImages: metadata.totalImages,
+ failedImages: metadata.failedImages
+ )
+ } else {
+ imageExportSharePayload = MemoImageExportSharePayload(url: url)
+ }
} catch {
imageExportMessage = MemoImageExportMessage(
title: env.preferences.t("导出失败", en: "Export failed"),
@@ -1012,16 +1105,154 @@ private struct MemoImageExportSharePayload: Identifiable {
let url: URL
}
+private struct MemoImageExportPreviewPayload: Identifiable {
+ let id = UUID()
+ let url: URL
+ let width: Int
+ let height: Int
+ let totalImages: Int
+ let failedImages: Int
+}
+
+private struct MemoImageExportDocumentPayload: Identifiable {
+ let id = UUID()
+ let url: URL
+}
+
+private enum MemoImageExportIntent {
+ case preview
+ case share
+}
+
private struct MemoImageExportMessage: Identifiable {
let id = UUID()
let title: String
let message: String
}
+private struct MemoImageExportPreviewView: View {
+ @Environment(\.dismiss) private var dismiss
+ let payload: MemoImageExportPreviewPayload
+ let isEnglish: Bool
+ let onCopy: () -> Void
+ let onSave: () -> Void
+ let onShare: () -> Void
+
+ var body: some View {
+ NavigationStack {
+ VStack(spacing: 0) {
+ ScrollView {
+ VStack(spacing: 12) {
+ if let image = UIImage(contentsOfFile: payload.url.path) {
+ Image(uiImage: image)
+ .resizable()
+ .scaledToFit()
+ .clipShape(RoundedRectangle(cornerRadius: 14))
+ .shadow(color: .black.opacity(0.16), radius: 12, y: 5)
+ } else {
+ ContentUnavailableView(
+ isEnglish ? "Preview unavailable" : "无法预览",
+ systemImage: "photo.badge.exclamationmark"
+ )
+ }
+ if payload.failedImages > 0 {
+ warning(
+ isEnglish
+ ? "\(payload.failedImages) of \(payload.totalImages) note image(s) could not be included."
+ : "笔记中的 \(payload.totalImages) 张图片有 \(payload.failedImages) 张未能包含。"
+ )
+ }
+ if payload.height > 12_000 {
+ warning(
+ isEnglish
+ ? "This is a long image. Some social apps may reduce its quality; keep the saved original."
+ : "图片较长,部分社交平台可能会压缩画质;建议保留保存的原图。"
+ )
+ }
+ }
+ .padding(16)
+ }
+ Divider()
+ HStack(spacing: 8) {
+ previewButton(isEnglish ? "Copy" : "复制图片", systemImage: "doc.on.doc", action: onCopy)
+ previewButton(isEnglish ? "Save" : "保存图片", systemImage: "square.and.arrow.down", action: onSave)
+ Button(action: onShare) {
+ Label(isEnglish ? "Share" : "系统分享", systemImage: "square.and.arrow.up")
+ .frame(maxWidth: .infinity, minHeight: 44)
+ }
+ .buttonStyle(.borderedProminent)
+ .tint(Color(red: 22 / 255, green: 160 / 255, blue: 110 / 255))
+ }
+ .font(.system(size: 13, weight: .semibold))
+ .padding(12)
+ }
+ .background(Color(.systemGroupedBackground))
+ .navigationTitle(isEnglish ? "Image Preview" : "图片预览")
+ .navigationBarTitleDisplayMode(.inline)
+ .toolbar {
+ ToolbarItem(placement: .cancellationAction) {
+ Button(isEnglish ? "Close" : "关闭") { dismiss() }
+ }
+ }
+ }
+ }
+
+ private func warning(_ text: String) -> some View {
+ Text(text)
+ .font(.system(size: 13))
+ .foregroundStyle(Color.orange)
+ .frame(maxWidth: .infinity, alignment: .leading)
+ .padding(10)
+ .background(Color.orange.opacity(0.1), in: RoundedRectangle(cornerRadius: 8))
+ }
+
+ private func previewButton(_ title: String, systemImage: String, action: @escaping () -> Void) -> some View {
+ Button(action: action) {
+ Label(title, systemImage: systemImage)
+ .frame(maxWidth: .infinity, minHeight: 44)
+ }
+ .buttonStyle(.bordered)
+ }
+}
+
+private struct MemoImageDocumentExportView: UIViewControllerRepresentable {
+ let fileURL: URL
+ let onFinish: (Result<Bool, Error>) -> Void
+
+ func makeCoordinator() -> Coordinator { Coordinator(onFinish: onFinish) }
+
+ func makeUIViewController(context: Context) -> UIDocumentPickerViewController {
+ let picker = UIDocumentPickerViewController(forExporting: [fileURL], asCopy: true)
+ picker.delegate = context.coordinator
+ picker.shouldShowFileExtensions = true
+ return picker
+ }
+
+ func updateUIViewController(_ uiViewController: UIDocumentPickerViewController, context: Context) {}
+
+ final class Coordinator: NSObject, UIDocumentPickerDelegate {
+ let onFinish: (Result<Bool, Error>) -> Void
+ init(onFinish: @escaping (Result<Bool, Error>) -> Void) { self.onFinish = onFinish }
+ func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
+ onFinish(.success(!urls.isEmpty))
+ }
+ func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) {
+ onFinish(.success(false))
+ }
+ }
+}
+
private final class MemoImageExportBuffer {
+ struct Metadata {
+ let width: Int
+ let height: Int
+ let totalImages: Int
+ let failedImages: Int
+ }
+
enum Result {
case none
- case complete(Data, filename: String)
+ case complete(Data, filename: String, metadata: Metadata)
case failure(String)
}
@@ -1055,7 +1286,13 @@ private final class MemoImageExportBuffer {
let filename = event["filename"] as? String,
let data = Data(base64Encoded: chunks.joined())
else { return .failure("Image export returned invalid data") }
- return .complete(data, filename: filename)
+ let metadata = Metadata(
+ width: (event["width"] as? NSNumber)?.intValue ?? 0,
+ height: (event["height"] as? NSNumber)?.intValue ?? 0,
+ totalImages: (event["totalImages"] as? NSNumber)?.intValue ?? 0,
+ failedImages: (event["failedImages"] as? NSNumber)?.intValue ?? 0
+ )
+ return .complete(data, filename: filename, metadata: metadata)
}
}
diff --git a/apps/ios/EdgeEver/Resources/EditorBundle/index.html b/apps/ios/EdgeEver/Resources/EditorBundle/index.html
index faab5462..87c07e65 100644
--- a/apps/ios/EdgeEver/Resources/EditorBundle/index.html
+++ b/apps/ios/EdgeEver/Resources/EditorBundle/index.html
@@ -1240,7 +1240,7 @@ l0,-`+(r+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
`)},II="edgeever-inline-sentinel",tut=(t,e,r)=>{var i;const n=(i=t.storage.markdown)==null?void 0:i.manager;return n!=null&&n.serialize?n.serialize(B_({type:"doc",content:[{type:"paragraph",content:e}]})).replaceAll(P_,"\\$"):r},rut=t=>{const e=t.state.selection;if(e.empty||e.from>=e.to)return null;const r=[];if(t.state.doc.nodesBetween(e.from,e.to,(i,a)=>{if(!i.isTextblock)return!0;const s=a+1,o=s+i.content.size,l=Math.max(e.from,s),u=Math.min(e.to,o);return u>l&&r.push({node:i,contentFrom:s,contentTo:o,from:l,to:u}),!1}),r.length===1){const i=r[0],a=i.node.cut(i.from-i.contentFrom,i.to-i.contentFrom).toJSON(),s=t.state.doc.textBetween(i.from,i.to,`
`),o=tut(t,a.content??[],s).trim();return o?{from:i.from,to:i.to,isInline:!0,markdown:o,text:s}:null}const n=eut(t,e.from,e.to).trim();return n?{from:e.from,to:e.to,isInline:!1,markdown:n,text:t.state.doc.textBetween(e.from,e.to,`
-`)}:null},nut=(t,e,r)=>{var f,p,g;const n=(f=t.storage.markdown)==null?void 0:f.manager,i=e.trim(),a=((p=n==null?void 0:n.parse)==null?void 0:p.call(n,i).content)??[{type:"text",text:i}];if(!r)return a;const s=i.replace(/\s*\n+\s*/g," "),o=(g=n==null?void 0:n.parse)==null?void 0:g.call(n,`${II}${s}`).content,l=(o==null?void 0:o.length)===1?o[0]:null,u=(l==null?void 0:l.type)==="paragraph"?l.content??[]:[],h=u[0];if((h==null?void 0:h.type)!=="text"||typeof h.text!="string"||!h.text.startsWith(II))return[{type:"text",text:s}];const d=h.text.slice(II.length);return[...d?[{...h,text:d}]:[],...u.slice(1)]};function Hh(t){try{const e=JSON.stringify(t.getJSON()),r=F2e(t);Ss({type:"change",contentMarkdown:r,contentJson:e})}catch(e){Ss({type:"error",message:e instanceof Error?e.message:String(e)})}}function iut(t,e){const r=e.trim().toLocaleLowerCase();if(r.length===0)return[];const n=[];let i=null;t.state.doc.descendants((l,u)=>{if(!(!l.isText||!l.text)){i!==null&&u>i&&n.push({char:"\0",pos:-1});for(let h=0;h<l.text.length;h+=1)n.push({char:l.text[h]??"",pos:u+h});i=u+l.text.length}});const a=n.map(l=>l.char).join("").toLocaleLowerCase(),s=[];let o=a.indexOf(r);for(;o!==-1;){const l=n[o],u=n[o+r.length-1];l&&u&&l.pos>=0&&u.pos>=0&&s.push({from:l.pos,to:u.pos+1}),o=a.indexOf(r,o+r.length)}return s}const kte=()=>Tr.isActive("taskItem")?"taskItem":"listItem";function z2e(t){var r;if(YS.classList.toggle("editor-mode",t),YS.innerHTML="",!t)return;const e=[{id:"image",label:"▧+",run:()=>Ss({type:"pickImage"})},{id:"bold",label:"B",run:()=>Tr.chain().focus().toggleBold().run()},{id:"bullet",label:"•",run:()=>Tr.chain().focus().toggleBulletList().run()},{id:"task",label:"☑",run:()=>Tr.chain().focus().toggleTaskList().run()},{id:"indent",label:"⇥",run:()=>Tr.chain().focus().sinkListItem(kte()).run()},{id:"outdent",label:"⇤",run:()=>Tr.chain().focus().liftListItem(kte()).run()},{id:"quote",label:"❝",run:()=>Tr.chain().focus().toggleBlockquote().run()},{id:"hr",label:"—",run:()=>Tr.chain().focus().setHorizontalRule().run()}];for(const n of e){const i=document.createElement("button");i.type="button",i.textContent=n.label,i.dataset.action=n.id;const a={image:["插入图片","Insert image"],bold:["粗体","Bold"],bullet:["项目符号列表","Bullet list"],task:["任务清单","Task list"],indent:["增加列表缩进","Increase list indent"],outdent:["减少列表缩进","Decrease list indent"],quote:["引用","Block quote"],hr:["分隔线","Horizontal rule"]};i.setAttribute("aria-label",((r=a[n.id])==null?void 0:r[O2e==="en-US"?1:0])??n.id),i.addEventListener("click",()=>{n.run(),n.id!=="image"&&Hh(Tr),W8()}),YS.appendChild(i)}W8()}function W8(){const t={bold:Tr.isActive("bold"),bullet:Tr.isActive("bulletList"),task:Tr.isActive("taskList"),quote:Tr.isActive("blockquote")};YS.querySelectorAll("button[data-action]").forEach(e=>{e.classList.toggle("is-active",t[e.dataset.action??""]??!1)})}async function DI(t="light"){Zl.querySelectorAll("[data-placeholder]").forEach(e=>{e.dataset.placeholder=PP}),await jct(Zl),xs==="viewer"&&await Kct(Zl,t)}async function aut(t){var p;if(!t.requestId||t.format!=="png"&&t.format!=="jpeg")return;const e=Not(t.background,t.theme),r=t.fontStyle??"serif",n=t.fontSize??"lg",i=t.cardWidth??"standard",a=Rve[i]||680,s=e4[e]||e4.slate,o=Tr.view.dom.cloneNode(!0);o.removeAttribute("contenteditable"),o.querySelectorAll("button, [contenteditable='true']").forEach(g=>{g.removeAttribute("contenteditable"),g instanceof HTMLButtonElement&&g.remove()});const l=o.innerHTML,u=document.createElement("div");u.style.cssText=`position:fixed;left:-100000px;top:0;width:${a}px;pointer-events:none;`;const h=document.createElement("style");h.textContent=Pot({theme:e,fontStyle:r,fontSize:n,cardWidth:i});const d=$ot({title:t.title||t.fallbackTitle,notebook:t.notebook,tags:t.tags,updatedAt:t.updatedAt,bodyHtml:l,theme:e,fontStyle:r,showTitle:t.showTitle??!0,showNotebook:t.showNotebook??!1,showTags:t.showTags??!1,showUpdatedAt:t.showUpdatedAt??!0,showBranding:t.branding??!0});u.appendChild(h),u.insertAdjacentHTML("beforeend",d);const f=u.lastElementChild;f.style.width=`${a}px`,f.style.maxWidth="none",f.style.margin="0",document.body.appendChild(u);try{await((p=document.fonts)==null?void 0:p.ready),await Promise.all(Array.from(f.querySelectorAll("img")).map(async E=>{if(!E.complete)try{await E.decode()}catch{}}));const g=Math.max(1,Math.ceil(f.getBoundingClientRect().height)),m=Dot[e]||s.canvasBg,y=await Mot(f,{backgroundColor:m,cacheBust:!1,height:g,pixelRatio:2,skipFonts:!0,width:a}),v=await new Promise((E,A)=>{y.toBlob(M=>M?E(M):A(new Error("Image renderer returned an empty file")),t.format==="jpeg"?"image/jpeg":"image/png",t.format==="jpeg"?.92:1)}),x=t.format==="jpeg"?"jpg":"png",b=Oot(t.title,t.fallbackTitle),w=await Yct(v),k=`${b}.${x}`,S=t.format==="jpeg"?"image/jpeg":"image/png",C=Xct(w);for(let E=0;E<C.length;E+=xte)Ss({type:"imageExportChunk",requestId:t.requestId,chunk:C.slice(E,E+xte)}),await new Promise(A=>setTimeout(A,0));Ss({type:"imageExportComplete",requestId:t.requestId,filename:k,mimeType:S})}catch(g){Ss({type:"imageExportError",requestId:t.requestId,message:g instanceof Error?g.message:"Image export failed"})}finally{u.remove()}}const sut={exportImage(t){aut(t)},configure(t){const e=t.mode==="editor"?"editor":"viewer",r=e!==xs;xs=e,O2e=t.locale==="en-US"?"en-US":"zh-CN",Tr.setEditable(xs==="editor"),z2e(xs==="editor"),document.documentElement.dataset.theme=t.theme||"light",document.body.classList.toggle("viewer-mode",xs==="viewer"),document.body.classList.toggle("editor-mode",xs==="editor"),t.placeholder&&(PP=t.placeholder,Zl.querySelectorAll("[data-placeholder]").forEach(n=>{n.dataset.placeholder=PP})),xs==="editor"&&r&&requestAnimationFrame(()=>{try{Tr.commands.focus("end")}catch{}}),DI(t.theme||"light")},setMarkdown(t){var e;C3=!0;try{Tr.commands.setContent(t||"",{contentType:"markdown"})}catch{try{const r=(e=Tr.storage.markdown)==null?void 0:e.manager;if(r)Tr.commands.setContent(r.parse(t||""));else throw new Error("no markdown manager")}catch{Tr.commands.setContent({type:"doc",content:[{type:"paragraph",content:t?[{type:"text",text:t}]:[]}]})}}Tr.setEditable(xs==="editor"),C3=!1,DI(document.documentElement.dataset.theme||"light")},setDocumentFromJSON(t){C3=!0;try{const e=JSON.parse(t);Tr.commands.setContent(e)}catch{Tr.commands.setContent({type:"doc",content:[{type:"paragraph"}]})}Tr.setEditable(xs==="editor"),C3=!1,DI(document.documentElement.dataset.theme||"light")},resolveResource(t,e){const r=G8.get(t);r&&(G8.delete(t),r(e))},getMarkdown(){return F2e(Tr)},getDocument(){return JSON.stringify(Tr.getJSON())},captureSelection(){const t=rut(Tr);return t?(P5={from:t.from,to:t.to,isInline:t.isInline,documentFingerprint:JSON.stringify(Tr.getJSON())},JSON.stringify({from:t.from,to:t.to,markdown:t.markdown,text:t.text})):(P5=null,null)},applySelectionDraft(t,e){var s,o;const r=P5;if(!r||!t.trim())return!1;if(JSON.stringify(Tr.getJSON())!==r.documentFingerprint)return P5=null,!1;const n=Tr.state.doc.content.size,i=Math.min(Math.max(r.from,0),n),a=Math.min(Math.max(r.to,i),n);try{const l=(s=Tr.storage.markdown)==null?void 0:s.manager,u=(o=l==null?void 0:l.parse)==null?void 0:o.call(l,t),h=e==="replace"?nut(Tr,t,r.isInline):(u==null?void 0:u.content)??t,d=e==="append"?{from:a,to:a}:{from:i,to:a};return Tr.chain().focus().insertContentAt(d,h).run(),P5=null,Hh(Tr),!0}catch{return!1}},undo(){if(!Tr.can().undo())return!1;const t=Tr.commands.undo();return t&&Hh(Tr),t},focusEnd(){var t;try{Tr.commands.focus("end")}catch{}try{const e=(t=Tr.view)==null?void 0:t.dom;e&&typeof e.focus=="function"&&e.focus({preventScroll:!0})}catch{}},flush(){Hh(Tr)},exec(t){var r;const e={bold:()=>Tr.chain().focus().toggleBold().run(),bulletList:()=>Tr.chain().focus().toggleBulletList().run(),taskList:()=>Tr.chain().focus().toggleTaskList().run(),blockquote:()=>Tr.chain().focus().toggleBlockquote().run(),horizontalRule:()=>Tr.chain().focus().setHorizontalRule().run(),heading2:()=>Tr.chain().focus().toggleHeading({level:2}).run(),codeBlock:()=>Tr.chain().focus().toggleCodeBlock().run()};(r=e[t])==null||r.call(e),Hh(Tr)},beginImageUpload(t,e){Tr.chain().focus().setImage({src:e,alt:t}).run();const r=Zl.querySelectorAll("img"),n=r[r.length-1];n&&(n.dataset.uploadId=t),Hh(Tr)},completeImageUpload(t,e,r){Tr.chain().focus().setImage({src:e,alt:r||t||""}).run();const n=Zl.querySelectorAll("img"),i=n[n.length-1];i&&(i.dataset.originalSrc=e,delete i.dataset.uploadId),Hh(Tr)},cancelImageUpload(t){const e=Zl.querySelector(`img[data-upload-id="${t}"]`);e==null||e.remove(),Hh(Tr)},search(t,e){const r=iut(Tr,t),n=r.length>0?Math.min(Math.max(Number.isFinite(e)?e:0,0),r.length-1):0,i=r[n];if(i){Tr.commands.setTextSelection({from:i.from,to:i.to});try{const a=Tr.view.domAtPos(i.from).node,s=a instanceof Element?a:a.parentElement;s==null||s.scrollIntoView({block:"center",behavior:"smooth"})}catch{}}Ss({type:"searchResult",count:r.length,index:n})}};window.EdgeEverEditor=sut;z2e(!1);Ss({type:"ready",startupMs:Math.round(performance.now()-Wct)});class Bt extends Error{constructor(e,r){var n="KaTeX parse error: "+e,i,a,s=r&&r.loc;if(s&&s.start<=s.end){var o=s.lexer.input;i=s.start,a=s.end,i===o.length?n+=" at end of input: ":n+=" at position "+(i+1)+": ";var l=o.slice(i,a).replace(/[^]/g,"$&̲"),u;i>15?u="…"+o.slice(i-15,i):u=o.slice(0,i);var h;a+15<o.length?h=o.slice(a,a+15)+"…":h=o.slice(a),n+=u+l+h}super(n),this.name="ParseError",this.position=void 0,this.length=void 0,this.rawMessage=void 0,Object.setPrototypeOf(this,Bt.prototype),this.position=i,i!=null&&a!=null&&(this.length=a-i),this.rawMessage=e}}var out=/([A-Z])/g,lut=t=>t.replace(out,"-$1").toLowerCase(),cut={"&":"&amp;",">":"&gt;","<":"&lt;",'"':"&quot;","'":"&#x27;"},uut=/[&><"']/g,Gs=t=>String(t).replace(uut,e=>cut[e]),XS=t=>t.type==="ordgroup"||t.type==="color"?t.body.length===1?XS(t.body[0]):t:t.type==="font"?XS(t.body):t,hut=new Set(["mathord","textord","atom"]),Gd=t=>hut.has(XS(t).type),dut=t=>{var e=/^[\x00-\x20]*([^\\/#?]*?)(:|&#0*58|&#x0*3a|&colon)/i.exec(t);return e?e[2]!==":"||!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(e[1])?null:e[1].toLowerCase():"_relative"},U8={displayMode:{type:"boolean",description:"Render math in display mode, which puts the math in display style (so \\int and \\sum are large, for example), and centers the math on the page on its own line.",cli:"-d, --display-mode"},output:{type:{enum:["htmlAndMathml","html","mathml"]},description:"Determines the markup language of the output.",cli:"-F, --format <type>"},leqno:{type:"boolean",description:"Render display math in leqno style (left-justified tags)."},fleqn:{type:"boolean",description:"Render display math flush left."},throwOnError:{type:"boolean",default:!0,cli:"-t, --no-throw-on-error",cliDescription:"Render errors (in the color given by --error-color) instead of throwing a ParseError exception when encountering an error."},errorColor:{type:"string",default:"#cc0000",cli:"-c, --error-color <color>",cliDescription:"A color string given in the format 'rgb' or 'rrggbb' (no #). This option determines the color of errors rendered by the -t option.",cliProcessor:t=>"#"+t},macros:{type:"object",cli:"-m, --macro <def>",cliDescription:"Define custom macro of the form '\\foo:expansion' (use multiple -m arguments for multiple macros).",cliDefault:[],cliProcessor:(t,e)=>(e.push(t),e)},minRuleThickness:{type:"number",description:"Specifies a minimum thickness, in ems, for fraction lines, `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, `\\hdashline`, `\\underline`, `\\overline`, and the borders of `\\fbox`, `\\boxed`, and `\\fcolorbox`.",processor:t=>Math.max(0,t),cli:"--min-rule-thickness <size>",cliProcessor:parseFloat},colorIsTextColor:{type:"boolean",description:"Makes \\color behave like LaTeX's 2-argument \\textcolor, instead of LaTeX's one-argument \\color mode change.",cli:"-b, --color-is-text-color"},strict:{type:[{enum:["warn","ignore","error"]},"boolean","function"],description:"Turn on strict / LaTeX faithfulness mode, which throws an error if the input uses features that are not supported by LaTeX.",cli:"-S, --strict",cliDefault:!1},trust:{type:["boolean","function"],description:"Trust the input, enabling all HTML features such as \\url.",cli:"-T, --trust"},maxSize:{type:"number",default:1/0,description:"If non-zero, all user-specified sizes, e.g. in \\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, elements and spaces can be arbitrarily large",processor:t=>Math.max(0,t),cli:"-s, --max-size <n>",cliProcessor:parseInt},maxExpand:{type:"number",default:1e3,description:"Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to Infinity, the macro expander will try to fully expand as in LaTeX.",processor:t=>Math.max(0,t),cli:"-e, --max-expand <n>",cliProcessor:t=>t==="Infinity"?1/0:parseInt(t)},globalGroup:{type:"boolean",cli:!1}};function fut(t){if(typeof t!="string")return t.enum[0];switch(t){case"boolean":return!1;case"string":return"";case"number":return 0;case"object":return{};default:throw new Error("Unexpected schema type; settings must declare an explicit default.")}}function put(t){if(t.default!==void 0)return t.default;var e=Array.isArray(t.type)?t.type[0]:t.type;return fut(e)}function gut(t,e,r,n){var i=r[e];t[e]=i!==void 0?n.processor?n.processor(i):i:put(n)}class Zq{constructor(e){e===void 0&&(e={}),this.displayMode=void 0,this.output=void 0,this.leqno=void 0,this.fleqn=void 0,this.throwOnError=void 0,this.errorColor=void 0,this.macros=void 0,this.minRuleThickness=void 0,this.colorIsTextColor=void 0,this.strict=void 0,this.trust=void 0,this.maxSize=void 0,this.maxExpand=void 0,this.globalGroup=void 0,e=e||{};for(var r of Object.keys(U8)){var n=U8[r];n&&gut(this,r,e,n)}}reportNonstrict(e,r,n){var i=this.strict;if(typeof i=="function"&&(i=i(e,r,n)),!(!i||i==="ignore")){if(i===!0||i==="error")throw new Bt("LaTeX-incompatible input and strict mode is set to 'error': "+(r+" ["+e+"]"),n);i==="warn"?typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+(r+" ["+e+"]")):typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to "+("unrecognized '"+i+"': "+r+" ["+e+"]"))}}useStrictBehavior(e,r,n){var i=this.strict;if(typeof i=="function")try{i=i(e,r,n)}catch{i="error"}return!i||i==="ignore"?!1:i===!0||i==="error"?!0:i==="warn"?(typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+(r+" ["+e+"]")),!1):(typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to "+("unrecognized '"+i+"': "+r+" ["+e+"]")),!1)}isTrusted(e){if("url"in e&&e.url&&!e.protocol){var r=dut(e.url);if(r==null)return!1;e.protocol=r}var n=typeof this.trust=="function"?this.trust(e):this.trust;return!!n}}class hf{constructor(e,r,n){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=e,this.size=r,this.cramped=n}sup(){return Au[mut[this.id]]}sub(){return Au[yut[this.id]]}fracNum(){return Au[vut[this.id]]}fracDen(){return Au[but[this.id]]}cramp(){return Au[xut[this.id]]}text(){return Au[Tut[this.id]]}isTight(){return this.size>=2}}var Jq=0,Y8=1,Oy=2,fd=3,xw=4,Jl=5,r4=6,mo=7,Au=[new hf(Jq,0,!1),new hf(Y8,0,!0),new hf(Oy,1,!1),new hf(fd,1,!0),new hf(xw,2,!1),new hf(Jl,2,!0),new hf(r4,3,!1),new hf(mo,3,!0)],mut=[xw,Jl,xw,Jl,r4,mo,r4,mo],yut=[Jl,Jl,Jl,Jl,mo,mo,mo,mo],vut=[Oy,fd,xw,Jl,r4,mo,r4,mo],but=[fd,fd,Jl,Jl,mo,mo,mo,mo],xut=[Y8,Y8,fd,fd,Jl,Jl,mo,mo],Tut=[Jq,Y8,Oy,fd,Oy,fd,Oy,fd],Qr={DISPLAY:Au[Jq],TEXT:Au[Oy],SCRIPT:Au[xw],SCRIPTSCRIPT:Au[r4]},BP=[{name:"latin",blocks:[[256,591],[768,879]]},{name:"cyrillic",blocks:[[1024,1279]]},{name:"armenian",blocks:[[1328,1423]]},{name:"brahmic",blocks:[[2304,4255]]},{name:"georgian",blocks:[[4256,4351]]},{name:"cjk",blocks:[[12288,12543],[19968,40879],[65280,65376]]},{name:"hangul",blocks:[[44032,55215]]}];function wut(t){for(var e=0;e<BP.length;e++)for(var r=BP[e],n=0;n<r.blocks.length;n++){var i=r.blocks[n];if(t>=i[0]&&t<=i[1])return r.name}return null}var jS=[];BP.forEach(t=>t.blocks.forEach(e=>jS.push(...e)));function H2e(t){for(var e=0;e<jS.length;e+=2)if(t>=jS[e]&&t<=jS[e+1])return!0;return!1}var La=t=>t+" "+t,f1=80,kut=function(e,r){return"M95,"+(622+e+r)+`
+`)}:null},nut=(t,e,r)=>{var f,p,g;const n=(f=t.storage.markdown)==null?void 0:f.manager,i=e.trim(),a=((p=n==null?void 0:n.parse)==null?void 0:p.call(n,i).content)??[{type:"text",text:i}];if(!r)return a;const s=i.replace(/\s*\n+\s*/g," "),o=(g=n==null?void 0:n.parse)==null?void 0:g.call(n,`${II}${s}`).content,l=(o==null?void 0:o.length)===1?o[0]:null,u=(l==null?void 0:l.type)==="paragraph"?l.content??[]:[],h=u[0];if((h==null?void 0:h.type)!=="text"||typeof h.text!="string"||!h.text.startsWith(II))return[{type:"text",text:s}];const d=h.text.slice(II.length);return[...d?[{...h,text:d}]:[],...u.slice(1)]};function Hh(t){try{const e=JSON.stringify(t.getJSON()),r=F2e(t);Ss({type:"change",contentMarkdown:r,contentJson:e})}catch(e){Ss({type:"error",message:e instanceof Error?e.message:String(e)})}}function iut(t,e){const r=e.trim().toLocaleLowerCase();if(r.length===0)return[];const n=[];let i=null;t.state.doc.descendants((l,u)=>{if(!(!l.isText||!l.text)){i!==null&&u>i&&n.push({char:"\0",pos:-1});for(let h=0;h<l.text.length;h+=1)n.push({char:l.text[h]??"",pos:u+h});i=u+l.text.length}});const a=n.map(l=>l.char).join("").toLocaleLowerCase(),s=[];let o=a.indexOf(r);for(;o!==-1;){const l=n[o],u=n[o+r.length-1];l&&u&&l.pos>=0&&u.pos>=0&&s.push({from:l.pos,to:u.pos+1}),o=a.indexOf(r,o+r.length)}return s}const kte=()=>Tr.isActive("taskItem")?"taskItem":"listItem";function z2e(t){var r;if(YS.classList.toggle("editor-mode",t),YS.innerHTML="",!t)return;const e=[{id:"image",label:"▧+",run:()=>Ss({type:"pickImage"})},{id:"bold",label:"B",run:()=>Tr.chain().focus().toggleBold().run()},{id:"bullet",label:"•",run:()=>Tr.chain().focus().toggleBulletList().run()},{id:"task",label:"☑",run:()=>Tr.chain().focus().toggleTaskList().run()},{id:"indent",label:"⇥",run:()=>Tr.chain().focus().sinkListItem(kte()).run()},{id:"outdent",label:"⇤",run:()=>Tr.chain().focus().liftListItem(kte()).run()},{id:"quote",label:"❝",run:()=>Tr.chain().focus().toggleBlockquote().run()},{id:"hr",label:"—",run:()=>Tr.chain().focus().setHorizontalRule().run()}];for(const n of e){const i=document.createElement("button");i.type="button",i.textContent=n.label,i.dataset.action=n.id;const a={image:["插入图片","Insert image"],bold:["粗体","Bold"],bullet:["项目符号列表","Bullet list"],task:["任务清单","Task list"],indent:["增加列表缩进","Increase list indent"],outdent:["减少列表缩进","Decrease list indent"],quote:["引用","Block quote"],hr:["分隔线","Horizontal rule"]};i.setAttribute("aria-label",((r=a[n.id])==null?void 0:r[O2e==="en-US"?1:0])??n.id),i.addEventListener("click",()=>{n.run(),n.id!=="image"&&Hh(Tr),W8()}),YS.appendChild(i)}W8()}function W8(){const t={bold:Tr.isActive("bold"),bullet:Tr.isActive("bulletList"),task:Tr.isActive("taskList"),quote:Tr.isActive("blockquote")};YS.querySelectorAll("button[data-action]").forEach(e=>{e.classList.toggle("is-active",t[e.dataset.action??""]??!1)})}async function DI(t="light"){Zl.querySelectorAll("[data-placeholder]").forEach(e=>{e.dataset.placeholder=PP}),await jct(Zl),xs==="viewer"&&await Kct(Zl,t)}async function aut(t){var p;if(!t.requestId||t.format!=="png"&&t.format!=="jpeg")return;const e=Not(t.background,t.theme),r=t.fontStyle??"serif",n=t.fontSize??"lg",i=t.cardWidth??"standard",a=Rve[i]||680,s=e4[e]||e4.slate,o=Tr.view.dom.cloneNode(!0);o.removeAttribute("contenteditable"),o.querySelectorAll("button, [contenteditable='true']").forEach(g=>{g.removeAttribute("contenteditable"),g instanceof HTMLButtonElement&&g.remove()});const l=o.innerHTML,u=document.createElement("div");u.style.cssText=`position:fixed;left:-100000px;top:0;width:${a}px;pointer-events:none;`;const h=document.createElement("style");h.textContent=Pot({theme:e,fontStyle:r,fontSize:n,cardWidth:i});const d=$ot({title:t.title||t.fallbackTitle,notebook:t.notebook,tags:t.tags,updatedAt:t.updatedAt,bodyHtml:l,theme:e,fontStyle:r,showTitle:t.showTitle??!0,showNotebook:t.showNotebook??!1,showTags:t.showTags??!1,showUpdatedAt:t.showUpdatedAt??!0,showBranding:t.branding??!0});u.appendChild(h),u.insertAdjacentHTML("beforeend",d);const f=u.lastElementChild;f.style.width=`${a}px`,f.style.maxWidth="none",f.style.margin="0",document.body.appendChild(u);try{await((p=document.fonts)==null?void 0:p.ready),await Promise.all(Array.from(f.querySelectorAll("img")).map(async M=>{if(!M.complete)try{await M.decode()}catch{}}));const g=Array.from(f.querySelectorAll(".edgeever-card-body img")),m=g.filter(M=>!M.complete||M.naturalWidth===0).length,y=Math.max(1,Math.ceil(f.getBoundingClientRect().height)),v=Dot[e]||s.canvasBg,x=await Mot(f,{backgroundColor:v,cacheBust:!1,height:y,pixelRatio:2,skipFonts:!0,width:a}),b=await new Promise((M,L)=>{x.toBlob(P=>P?M(P):L(new Error("Image renderer returned an empty file")),t.format==="jpeg"?"image/jpeg":"image/png",t.format==="jpeg"?.92:1)}),w=t.format==="jpeg"?"jpg":"png",k=Oot(t.title,t.fallbackTitle),S=await Yct(b),C=`${k}.${w}`,E=t.format==="jpeg"?"image/jpeg":"image/png",A=Xct(S);for(let M=0;M<A.length;M+=xte)Ss({type:"imageExportChunk",requestId:t.requestId,chunk:A.slice(M,M+xte)}),await new Promise(L=>setTimeout(L,0));Ss({type:"imageExportComplete",requestId:t.requestId,filename:C,mimeType:E,width:x.width,height:x.height,totalImages:g.length,failedImages:m})}catch(g){Ss({type:"imageExportError",requestId:t.requestId,message:g instanceof Error?g.message:"Image export failed"})}finally{u.remove()}}const sut={exportImage(t){aut(t)},configure(t){const e=t.mode==="editor"?"editor":"viewer",r=e!==xs;xs=e,O2e=t.locale==="en-US"?"en-US":"zh-CN",Tr.setEditable(xs==="editor"),z2e(xs==="editor"),document.documentElement.dataset.theme=t.theme||"light",document.body.classList.toggle("viewer-mode",xs==="viewer"),document.body.classList.toggle("editor-mode",xs==="editor"),t.placeholder&&(PP=t.placeholder,Zl.querySelectorAll("[data-placeholder]").forEach(n=>{n.dataset.placeholder=PP})),xs==="editor"&&r&&requestAnimationFrame(()=>{try{Tr.commands.focus("end")}catch{}}),DI(t.theme||"light")},setMarkdown(t){var e;C3=!0;try{Tr.commands.setContent(t||"",{contentType:"markdown"})}catch{try{const r=(e=Tr.storage.markdown)==null?void 0:e.manager;if(r)Tr.commands.setContent(r.parse(t||""));else throw new Error("no markdown manager")}catch{Tr.commands.setContent({type:"doc",content:[{type:"paragraph",content:t?[{type:"text",text:t}]:[]}]})}}Tr.setEditable(xs==="editor"),C3=!1,DI(document.documentElement.dataset.theme||"light")},setDocumentFromJSON(t){C3=!0;try{const e=JSON.parse(t);Tr.commands.setContent(e)}catch{Tr.commands.setContent({type:"doc",content:[{type:"paragraph"}]})}Tr.setEditable(xs==="editor"),C3=!1,DI(document.documentElement.dataset.theme||"light")},resolveResource(t,e){const r=G8.get(t);r&&(G8.delete(t),r(e))},getMarkdown(){return F2e(Tr)},getDocument(){return JSON.stringify(Tr.getJSON())},captureSelection(){const t=rut(Tr);return t?(P5={from:t.from,to:t.to,isInline:t.isInline,documentFingerprint:JSON.stringify(Tr.getJSON())},JSON.stringify({from:t.from,to:t.to,markdown:t.markdown,text:t.text})):(P5=null,null)},applySelectionDraft(t,e){var s,o;const r=P5;if(!r||!t.trim())return!1;if(JSON.stringify(Tr.getJSON())!==r.documentFingerprint)return P5=null,!1;const n=Tr.state.doc.content.size,i=Math.min(Math.max(r.from,0),n),a=Math.min(Math.max(r.to,i),n);try{const l=(s=Tr.storage.markdown)==null?void 0:s.manager,u=(o=l==null?void 0:l.parse)==null?void 0:o.call(l,t),h=e==="replace"?nut(Tr,t,r.isInline):(u==null?void 0:u.content)??t,d=e==="append"?{from:a,to:a}:{from:i,to:a};return Tr.chain().focus().insertContentAt(d,h).run(),P5=null,Hh(Tr),!0}catch{return!1}},undo(){if(!Tr.can().undo())return!1;const t=Tr.commands.undo();return t&&Hh(Tr),t},focusEnd(){var t;try{Tr.commands.focus("end")}catch{}try{const e=(t=Tr.view)==null?void 0:t.dom;e&&typeof e.focus=="function"&&e.focus({preventScroll:!0})}catch{}},flush(){Hh(Tr)},exec(t){var r;const e={bold:()=>Tr.chain().focus().toggleBold().run(),bulletList:()=>Tr.chain().focus().toggleBulletList().run(),taskList:()=>Tr.chain().focus().toggleTaskList().run(),blockquote:()=>Tr.chain().focus().toggleBlockquote().run(),horizontalRule:()=>Tr.chain().focus().setHorizontalRule().run(),heading2:()=>Tr.chain().focus().toggleHeading({level:2}).run(),codeBlock:()=>Tr.chain().focus().toggleCodeBlock().run()};(r=e[t])==null||r.call(e),Hh(Tr)},beginImageUpload(t,e){Tr.chain().focus().setImage({src:e,alt:t}).run();const r=Zl.querySelectorAll("img"),n=r[r.length-1];n&&(n.dataset.uploadId=t),Hh(Tr)},completeImageUpload(t,e,r){Tr.chain().focus().setImage({src:e,alt:r||t||""}).run();const n=Zl.querySelectorAll("img"),i=n[n.length-1];i&&(i.dataset.originalSrc=e,delete i.dataset.uploadId),Hh(Tr)},cancelImageUpload(t){const e=Zl.querySelector(`img[data-upload-id="${t}"]`);e==null||e.remove(),Hh(Tr)},search(t,e){const r=iut(Tr,t),n=r.length>0?Math.min(Math.max(Number.isFinite(e)?e:0,0),r.length-1):0,i=r[n];if(i){Tr.commands.setTextSelection({from:i.from,to:i.to});try{const a=Tr.view.domAtPos(i.from).node,s=a instanceof Element?a:a.parentElement;s==null||s.scrollIntoView({block:"center",behavior:"smooth"})}catch{}}Ss({type:"searchResult",count:r.length,index:n})}};window.EdgeEverEditor=sut;z2e(!1);Ss({type:"ready",startupMs:Math.round(performance.now()-Wct)});class Bt extends Error{constructor(e,r){var n="KaTeX parse error: "+e,i,a,s=r&&r.loc;if(s&&s.start<=s.end){var o=s.lexer.input;i=s.start,a=s.end,i===o.length?n+=" at end of input: ":n+=" at position "+(i+1)+": ";var l=o.slice(i,a).replace(/[^]/g,"$&̲"),u;i>15?u="…"+o.slice(i-15,i):u=o.slice(0,i);var h;a+15<o.length?h=o.slice(a,a+15)+"…":h=o.slice(a),n+=u+l+h}super(n),this.name="ParseError",this.position=void 0,this.length=void 0,this.rawMessage=void 0,Object.setPrototypeOf(this,Bt.prototype),this.position=i,i!=null&&a!=null&&(this.length=a-i),this.rawMessage=e}}var out=/([A-Z])/g,lut=t=>t.replace(out,"-$1").toLowerCase(),cut={"&":"&amp;",">":"&gt;","<":"&lt;",'"':"&quot;","'":"&#x27;"},uut=/[&><"']/g,Gs=t=>String(t).replace(uut,e=>cut[e]),XS=t=>t.type==="ordgroup"||t.type==="color"?t.body.length===1?XS(t.body[0]):t:t.type==="font"?XS(t.body):t,hut=new Set(["mathord","textord","atom"]),Gd=t=>hut.has(XS(t).type),dut=t=>{var e=/^[\x00-\x20]*([^\\/#?]*?)(:|&#0*58|&#x0*3a|&colon)/i.exec(t);return e?e[2]!==":"||!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(e[1])?null:e[1].toLowerCase():"_relative"},U8={displayMode:{type:"boolean",description:"Render math in display mode, which puts the math in display style (so \\int and \\sum are large, for example), and centers the math on the page on its own line.",cli:"-d, --display-mode"},output:{type:{enum:["htmlAndMathml","html","mathml"]},description:"Determines the markup language of the output.",cli:"-F, --format <type>"},leqno:{type:"boolean",description:"Render display math in leqno style (left-justified tags)."},fleqn:{type:"boolean",description:"Render display math flush left."},throwOnError:{type:"boolean",default:!0,cli:"-t, --no-throw-on-error",cliDescription:"Render errors (in the color given by --error-color) instead of throwing a ParseError exception when encountering an error."},errorColor:{type:"string",default:"#cc0000",cli:"-c, --error-color <color>",cliDescription:"A color string given in the format 'rgb' or 'rrggbb' (no #). This option determines the color of errors rendered by the -t option.",cliProcessor:t=>"#"+t},macros:{type:"object",cli:"-m, --macro <def>",cliDescription:"Define custom macro of the form '\\foo:expansion' (use multiple -m arguments for multiple macros).",cliDefault:[],cliProcessor:(t,e)=>(e.push(t),e)},minRuleThickness:{type:"number",description:"Specifies a minimum thickness, in ems, for fraction lines, `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, `\\hdashline`, `\\underline`, `\\overline`, and the borders of `\\fbox`, `\\boxed`, and `\\fcolorbox`.",processor:t=>Math.max(0,t),cli:"--min-rule-thickness <size>",cliProcessor:parseFloat},colorIsTextColor:{type:"boolean",description:"Makes \\color behave like LaTeX's 2-argument \\textcolor, instead of LaTeX's one-argument \\color mode change.",cli:"-b, --color-is-text-color"},strict:{type:[{enum:["warn","ignore","error"]},"boolean","function"],description:"Turn on strict / LaTeX faithfulness mode, which throws an error if the input uses features that are not supported by LaTeX.",cli:"-S, --strict",cliDefault:!1},trust:{type:["boolean","function"],description:"Trust the input, enabling all HTML features such as \\url.",cli:"-T, --trust"},maxSize:{type:"number",default:1/0,description:"If non-zero, all user-specified sizes, e.g. in \\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, elements and spaces can be arbitrarily large",processor:t=>Math.max(0,t),cli:"-s, --max-size <n>",cliProcessor:parseInt},maxExpand:{type:"number",default:1e3,description:"Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to Infinity, the macro expander will try to fully expand as in LaTeX.",processor:t=>Math.max(0,t),cli:"-e, --max-expand <n>",cliProcessor:t=>t==="Infinity"?1/0:parseInt(t)},globalGroup:{type:"boolean",cli:!1}};function fut(t){if(typeof t!="string")return t.enum[0];switch(t){case"boolean":return!1;case"string":return"";case"number":return 0;case"object":return{};default:throw new Error("Unexpected schema type; settings must declare an explicit default.")}}function put(t){if(t.default!==void 0)return t.default;var e=Array.isArray(t.type)?t.type[0]:t.type;return fut(e)}function gut(t,e,r,n){var i=r[e];t[e]=i!==void 0?n.processor?n.processor(i):i:put(n)}class Zq{constructor(e){e===void 0&&(e={}),this.displayMode=void 0,this.output=void 0,this.leqno=void 0,this.fleqn=void 0,this.throwOnError=void 0,this.errorColor=void 0,this.macros=void 0,this.minRuleThickness=void 0,this.colorIsTextColor=void 0,this.strict=void 0,this.trust=void 0,this.maxSize=void 0,this.maxExpand=void 0,this.globalGroup=void 0,e=e||{};for(var r of Object.keys(U8)){var n=U8[r];n&&gut(this,r,e,n)}}reportNonstrict(e,r,n){var i=this.strict;if(typeof i=="function"&&(i=i(e,r,n)),!(!i||i==="ignore")){if(i===!0||i==="error")throw new Bt("LaTeX-incompatible input and strict mode is set to 'error': "+(r+" ["+e+"]"),n);i==="warn"?typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+(r+" ["+e+"]")):typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to "+("unrecognized '"+i+"': "+r+" ["+e+"]"))}}useStrictBehavior(e,r,n){var i=this.strict;if(typeof i=="function")try{i=i(e,r,n)}catch{i="error"}return!i||i==="ignore"?!1:i===!0||i==="error"?!0:i==="warn"?(typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+(r+" ["+e+"]")),!1):(typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to "+("unrecognized '"+i+"': "+r+" ["+e+"]")),!1)}isTrusted(e){if("url"in e&&e.url&&!e.protocol){var r=dut(e.url);if(r==null)return!1;e.protocol=r}var n=typeof this.trust=="function"?this.trust(e):this.trust;return!!n}}class hf{constructor(e,r,n){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=e,this.size=r,this.cramped=n}sup(){return Au[mut[this.id]]}sub(){return Au[yut[this.id]]}fracNum(){return Au[vut[this.id]]}fracDen(){return Au[but[this.id]]}cramp(){return Au[xut[this.id]]}text(){return Au[Tut[this.id]]}isTight(){return this.size>=2}}var Jq=0,Y8=1,Oy=2,fd=3,xw=4,Jl=5,r4=6,mo=7,Au=[new hf(Jq,0,!1),new hf(Y8,0,!0),new hf(Oy,1,!1),new hf(fd,1,!0),new hf(xw,2,!1),new hf(Jl,2,!0),new hf(r4,3,!1),new hf(mo,3,!0)],mut=[xw,Jl,xw,Jl,r4,mo,r4,mo],yut=[Jl,Jl,Jl,Jl,mo,mo,mo,mo],vut=[Oy,fd,xw,Jl,r4,mo,r4,mo],but=[fd,fd,Jl,Jl,mo,mo,mo,mo],xut=[Y8,Y8,fd,fd,Jl,Jl,mo,mo],Tut=[Jq,Y8,Oy,fd,Oy,fd,Oy,fd],Qr={DISPLAY:Au[Jq],TEXT:Au[Oy],SCRIPT:Au[xw],SCRIPTSCRIPT:Au[r4]},BP=[{name:"latin",blocks:[[256,591],[768,879]]},{name:"cyrillic",blocks:[[1024,1279]]},{name:"armenian",blocks:[[1328,1423]]},{name:"brahmic",blocks:[[2304,4255]]},{name:"georgian",blocks:[[4256,4351]]},{name:"cjk",blocks:[[12288,12543],[19968,40879],[65280,65376]]},{name:"hangul",blocks:[[44032,55215]]}];function wut(t){for(var e=0;e<BP.length;e++)for(var r=BP[e],n=0;n<r.blocks.length;n++){var i=r.blocks[n];if(t>=i[0]&&t<=i[1])return r.name}return null}var jS=[];BP.forEach(t=>t.blocks.forEach(e=>jS.push(...e)));function H2e(t){for(var e=0;e<jS.length;e+=2)if(t>=jS[e]&&t<=jS[e+1])return!0;return!1}var La=t=>t+" "+t,f1=80,kut=function(e,r){return"M95,"+(622+e+r)+`
c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
diff --git a/apps/ios/EditorBundle/index.html b/apps/ios/EditorBundle/index.html
index faab5462..87c07e65 100644
--- a/apps/ios/EditorBundle/index.html
+++ b/apps/ios/EditorBundle/index.html
@@ -1240,7 +1240,7 @@ l0,-`+(r+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
`)},II="edgeever-inline-sentinel",tut=(t,e,r)=>{var i;const n=(i=t.storage.markdown)==null?void 0:i.manager;return n!=null&&n.serialize?n.serialize(B_({type:"doc",content:[{type:"paragraph",content:e}]})).replaceAll(P_,"\\$"):r},rut=t=>{const e=t.state.selection;if(e.empty||e.from>=e.to)return null;const r=[];if(t.state.doc.nodesBetween(e.from,e.to,(i,a)=>{if(!i.isTextblock)return!0;const s=a+1,o=s+i.content.size,l=Math.max(e.from,s),u=Math.min(e.to,o);return u>l&&r.push({node:i,contentFrom:s,contentTo:o,from:l,to:u}),!1}),r.length===1){const i=r[0],a=i.node.cut(i.from-i.contentFrom,i.to-i.contentFrom).toJSON(),s=t.state.doc.textBetween(i.from,i.to,`
`),o=tut(t,a.content??[],s).trim();return o?{from:i.from,to:i.to,isInline:!0,markdown:o,text:s}:null}const n=eut(t,e.from,e.to).trim();return n?{from:e.from,to:e.to,isInline:!1,markdown:n,text:t.state.doc.textBetween(e.from,e.to,`
-`)}:null},nut=(t,e,r)=>{var f,p,g;const n=(f=t.storage.markdown)==null?void 0:f.manager,i=e.trim(),a=((p=n==null?void 0:n.parse)==null?void 0:p.call(n,i).content)??[{type:"text",text:i}];if(!r)return a;const s=i.replace(/\s*\n+\s*/g," "),o=(g=n==null?void 0:n.parse)==null?void 0:g.call(n,`${II}${s}`).content,l=(o==null?void 0:o.length)===1?o[0]:null,u=(l==null?void 0:l.type)==="paragraph"?l.content??[]:[],h=u[0];if((h==null?void 0:h.type)!=="text"||typeof h.text!="string"||!h.text.startsWith(II))return[{type:"text",text:s}];const d=h.text.slice(II.length);return[...d?[{...h,text:d}]:[],...u.slice(1)]};function Hh(t){try{const e=JSON.stringify(t.getJSON()),r=F2e(t);Ss({type:"change",contentMarkdown:r,contentJson:e})}catch(e){Ss({type:"error",message:e instanceof Error?e.message:String(e)})}}function iut(t,e){const r=e.trim().toLocaleLowerCase();if(r.length===0)return[];const n=[];let i=null;t.state.doc.descendants((l,u)=>{if(!(!l.isText||!l.text)){i!==null&&u>i&&n.push({char:"\0",pos:-1});for(let h=0;h<l.text.length;h+=1)n.push({char:l.text[h]??"",pos:u+h});i=u+l.text.length}});const a=n.map(l=>l.char).join("").toLocaleLowerCase(),s=[];let o=a.indexOf(r);for(;o!==-1;){const l=n[o],u=n[o+r.length-1];l&&u&&l.pos>=0&&u.pos>=0&&s.push({from:l.pos,to:u.pos+1}),o=a.indexOf(r,o+r.length)}return s}const kte=()=>Tr.isActive("taskItem")?"taskItem":"listItem";function z2e(t){var r;if(YS.classList.toggle("editor-mode",t),YS.innerHTML="",!t)return;const e=[{id:"image",label:"▧+",run:()=>Ss({type:"pickImage"})},{id:"bold",label:"B",run:()=>Tr.chain().focus().toggleBold().run()},{id:"bullet",label:"•",run:()=>Tr.chain().focus().toggleBulletList().run()},{id:"task",label:"☑",run:()=>Tr.chain().focus().toggleTaskList().run()},{id:"indent",label:"⇥",run:()=>Tr.chain().focus().sinkListItem(kte()).run()},{id:"outdent",label:"⇤",run:()=>Tr.chain().focus().liftListItem(kte()).run()},{id:"quote",label:"❝",run:()=>Tr.chain().focus().toggleBlockquote().run()},{id:"hr",label:"—",run:()=>Tr.chain().focus().setHorizontalRule().run()}];for(const n of e){const i=document.createElement("button");i.type="button",i.textContent=n.label,i.dataset.action=n.id;const a={image:["插入图片","Insert image"],bold:["粗体","Bold"],bullet:["项目符号列表","Bullet list"],task:["任务清单","Task list"],indent:["增加列表缩进","Increase list indent"],outdent:["减少列表缩进","Decrease list indent"],quote:["引用","Block quote"],hr:["分隔线","Horizontal rule"]};i.setAttribute("aria-label",((r=a[n.id])==null?void 0:r[O2e==="en-US"?1:0])??n.id),i.addEventListener("click",()=>{n.run(),n.id!=="image"&&Hh(Tr),W8()}),YS.appendChild(i)}W8()}function W8(){const t={bold:Tr.isActive("bold"),bullet:Tr.isActive("bulletList"),task:Tr.isActive("taskList"),quote:Tr.isActive("blockquote")};YS.querySelectorAll("button[data-action]").forEach(e=>{e.classList.toggle("is-active",t[e.dataset.action??""]??!1)})}async function DI(t="light"){Zl.querySelectorAll("[data-placeholder]").forEach(e=>{e.dataset.placeholder=PP}),await jct(Zl),xs==="viewer"&&await Kct(Zl,t)}async function aut(t){var p;if(!t.requestId||t.format!=="png"&&t.format!=="jpeg")return;const e=Not(t.background,t.theme),r=t.fontStyle??"serif",n=t.fontSize??"lg",i=t.cardWidth??"standard",a=Rve[i]||680,s=e4[e]||e4.slate,o=Tr.view.dom.cloneNode(!0);o.removeAttribute("contenteditable"),o.querySelectorAll("button, [contenteditable='true']").forEach(g=>{g.removeAttribute("contenteditable"),g instanceof HTMLButtonElement&&g.remove()});const l=o.innerHTML,u=document.createElement("div");u.style.cssText=`position:fixed;left:-100000px;top:0;width:${a}px;pointer-events:none;`;const h=document.createElement("style");h.textContent=Pot({theme:e,fontStyle:r,fontSize:n,cardWidth:i});const d=$ot({title:t.title||t.fallbackTitle,notebook:t.notebook,tags:t.tags,updatedAt:t.updatedAt,bodyHtml:l,theme:e,fontStyle:r,showTitle:t.showTitle??!0,showNotebook:t.showNotebook??!1,showTags:t.showTags??!1,showUpdatedAt:t.showUpdatedAt??!0,showBranding:t.branding??!0});u.appendChild(h),u.insertAdjacentHTML("beforeend",d);const f=u.lastElementChild;f.style.width=`${a}px`,f.style.maxWidth="none",f.style.margin="0",document.body.appendChild(u);try{await((p=document.fonts)==null?void 0:p.ready),await Promise.all(Array.from(f.querySelectorAll("img")).map(async E=>{if(!E.complete)try{await E.decode()}catch{}}));const g=Math.max(1,Math.ceil(f.getBoundingClientRect().height)),m=Dot[e]||s.canvasBg,y=await Mot(f,{backgroundColor:m,cacheBust:!1,height:g,pixelRatio:2,skipFonts:!0,width:a}),v=await new Promise((E,A)=>{y.toBlob(M=>M?E(M):A(new Error("Image renderer returned an empty file")),t.format==="jpeg"?"image/jpeg":"image/png",t.format==="jpeg"?.92:1)}),x=t.format==="jpeg"?"jpg":"png",b=Oot(t.title,t.fallbackTitle),w=await Yct(v),k=`${b}.${x}`,S=t.format==="jpeg"?"image/jpeg":"image/png",C=Xct(w);for(let E=0;E<C.length;E+=xte)Ss({type:"imageExportChunk",requestId:t.requestId,chunk:C.slice(E,E+xte)}),await new Promise(A=>setTimeout(A,0));Ss({type:"imageExportComplete",requestId:t.requestId,filename:k,mimeType:S})}catch(g){Ss({type:"imageExportError",requestId:t.requestId,message:g instanceof Error?g.message:"Image export failed"})}finally{u.remove()}}const sut={exportImage(t){aut(t)},configure(t){const e=t.mode==="editor"?"editor":"viewer",r=e!==xs;xs=e,O2e=t.locale==="en-US"?"en-US":"zh-CN",Tr.setEditable(xs==="editor"),z2e(xs==="editor"),document.documentElement.dataset.theme=t.theme||"light",document.body.classList.toggle("viewer-mode",xs==="viewer"),document.body.classList.toggle("editor-mode",xs==="editor"),t.placeholder&&(PP=t.placeholder,Zl.querySelectorAll("[data-placeholder]").forEach(n=>{n.dataset.placeholder=PP})),xs==="editor"&&r&&requestAnimationFrame(()=>{try{Tr.commands.focus("end")}catch{}}),DI(t.theme||"light")},setMarkdown(t){var e;C3=!0;try{Tr.commands.setContent(t||"",{contentType:"markdown"})}catch{try{const r=(e=Tr.storage.markdown)==null?void 0:e.manager;if(r)Tr.commands.setContent(r.parse(t||""));else throw new Error("no markdown manager")}catch{Tr.commands.setContent({type:"doc",content:[{type:"paragraph",content:t?[{type:"text",text:t}]:[]}]})}}Tr.setEditable(xs==="editor"),C3=!1,DI(document.documentElement.dataset.theme||"light")},setDocumentFromJSON(t){C3=!0;try{const e=JSON.parse(t);Tr.commands.setContent(e)}catch{Tr.commands.setContent({type:"doc",content:[{type:"paragraph"}]})}Tr.setEditable(xs==="editor"),C3=!1,DI(document.documentElement.dataset.theme||"light")},resolveResource(t,e){const r=G8.get(t);r&&(G8.delete(t),r(e))},getMarkdown(){return F2e(Tr)},getDocument(){return JSON.stringify(Tr.getJSON())},captureSelection(){const t=rut(Tr);return t?(P5={from:t.from,to:t.to,isInline:t.isInline,documentFingerprint:JSON.stringify(Tr.getJSON())},JSON.stringify({from:t.from,to:t.to,markdown:t.markdown,text:t.text})):(P5=null,null)},applySelectionDraft(t,e){var s,o;const r=P5;if(!r||!t.trim())return!1;if(JSON.stringify(Tr.getJSON())!==r.documentFingerprint)return P5=null,!1;const n=Tr.state.doc.content.size,i=Math.min(Math.max(r.from,0),n),a=Math.min(Math.max(r.to,i),n);try{const l=(s=Tr.storage.markdown)==null?void 0:s.manager,u=(o=l==null?void 0:l.parse)==null?void 0:o.call(l,t),h=e==="replace"?nut(Tr,t,r.isInline):(u==null?void 0:u.content)??t,d=e==="append"?{from:a,to:a}:{from:i,to:a};return Tr.chain().focus().insertContentAt(d,h).run(),P5=null,Hh(Tr),!0}catch{return!1}},undo(){if(!Tr.can().undo())return!1;const t=Tr.commands.undo();return t&&Hh(Tr),t},focusEnd(){var t;try{Tr.commands.focus("end")}catch{}try{const e=(t=Tr.view)==null?void 0:t.dom;e&&typeof e.focus=="function"&&e.focus({preventScroll:!0})}catch{}},flush(){Hh(Tr)},exec(t){var r;const e={bold:()=>Tr.chain().focus().toggleBold().run(),bulletList:()=>Tr.chain().focus().toggleBulletList().run(),taskList:()=>Tr.chain().focus().toggleTaskList().run(),blockquote:()=>Tr.chain().focus().toggleBlockquote().run(),horizontalRule:()=>Tr.chain().focus().setHorizontalRule().run(),heading2:()=>Tr.chain().focus().toggleHeading({level:2}).run(),codeBlock:()=>Tr.chain().focus().toggleCodeBlock().run()};(r=e[t])==null||r.call(e),Hh(Tr)},beginImageUpload(t,e){Tr.chain().focus().setImage({src:e,alt:t}).run();const r=Zl.querySelectorAll("img"),n=r[r.length-1];n&&(n.dataset.uploadId=t),Hh(Tr)},completeImageUpload(t,e,r){Tr.chain().focus().setImage({src:e,alt:r||t||""}).run();const n=Zl.querySelectorAll("img"),i=n[n.length-1];i&&(i.dataset.originalSrc=e,delete i.dataset.uploadId),Hh(Tr)},cancelImageUpload(t){const e=Zl.querySelector(`img[data-upload-id="${t}"]`);e==null||e.remove(),Hh(Tr)},search(t,e){const r=iut(Tr,t),n=r.length>0?Math.min(Math.max(Number.isFinite(e)?e:0,0),r.length-1):0,i=r[n];if(i){Tr.commands.setTextSelection({from:i.from,to:i.to});try{const a=Tr.view.domAtPos(i.from).node,s=a instanceof Element?a:a.parentElement;s==null||s.scrollIntoView({block:"center",behavior:"smooth"})}catch{}}Ss({type:"searchResult",count:r.length,index:n})}};window.EdgeEverEditor=sut;z2e(!1);Ss({type:"ready",startupMs:Math.round(performance.now()-Wct)});class Bt extends Error{constructor(e,r){var n="KaTeX parse error: "+e,i,a,s=r&&r.loc;if(s&&s.start<=s.end){var o=s.lexer.input;i=s.start,a=s.end,i===o.length?n+=" at end of input: ":n+=" at position "+(i+1)+": ";var l=o.slice(i,a).replace(/[^]/g,"$&̲"),u;i>15?u="…"+o.slice(i-15,i):u=o.slice(0,i);var h;a+15<o.length?h=o.slice(a,a+15)+"…":h=o.slice(a),n+=u+l+h}super(n),this.name="ParseError",this.position=void 0,this.length=void 0,this.rawMessage=void 0,Object.setPrototypeOf(this,Bt.prototype),this.position=i,i!=null&&a!=null&&(this.length=a-i),this.rawMessage=e}}var out=/([A-Z])/g,lut=t=>t.replace(out,"-$1").toLowerCase(),cut={"&":"&amp;",">":"&gt;","<":"&lt;",'"':"&quot;","'":"&#x27;"},uut=/[&><"']/g,Gs=t=>String(t).replace(uut,e=>cut[e]),XS=t=>t.type==="ordgroup"||t.type==="color"?t.body.length===1?XS(t.body[0]):t:t.type==="font"?XS(t.body):t,hut=new Set(["mathord","textord","atom"]),Gd=t=>hut.has(XS(t).type),dut=t=>{var e=/^[\x00-\x20]*([^\\/#?]*?)(:|&#0*58|&#x0*3a|&colon)/i.exec(t);return e?e[2]!==":"||!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(e[1])?null:e[1].toLowerCase():"_relative"},U8={displayMode:{type:"boolean",description:"Render math in display mode, which puts the math in display style (so \\int and \\sum are large, for example), and centers the math on the page on its own line.",cli:"-d, --display-mode"},output:{type:{enum:["htmlAndMathml","html","mathml"]},description:"Determines the markup language of the output.",cli:"-F, --format <type>"},leqno:{type:"boolean",description:"Render display math in leqno style (left-justified tags)."},fleqn:{type:"boolean",description:"Render display math flush left."},throwOnError:{type:"boolean",default:!0,cli:"-t, --no-throw-on-error",cliDescription:"Render errors (in the color given by --error-color) instead of throwing a ParseError exception when encountering an error."},errorColor:{type:"string",default:"#cc0000",cli:"-c, --error-color <color>",cliDescription:"A color string given in the format 'rgb' or 'rrggbb' (no #). This option determines the color of errors rendered by the -t option.",cliProcessor:t=>"#"+t},macros:{type:"object",cli:"-m, --macro <def>",cliDescription:"Define custom macro of the form '\\foo:expansion' (use multiple -m arguments for multiple macros).",cliDefault:[],cliProcessor:(t,e)=>(e.push(t),e)},minRuleThickness:{type:"number",description:"Specifies a minimum thickness, in ems, for fraction lines, `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, `\\hdashline`, `\\underline`, `\\overline`, and the borders of `\\fbox`, `\\boxed`, and `\\fcolorbox`.",processor:t=>Math.max(0,t),cli:"--min-rule-thickness <size>",cliProcessor:parseFloat},colorIsTextColor:{type:"boolean",description:"Makes \\color behave like LaTeX's 2-argument \\textcolor, instead of LaTeX's one-argument \\color mode change.",cli:"-b, --color-is-text-color"},strict:{type:[{enum:["warn","ignore","error"]},"boolean","function"],description:"Turn on strict / LaTeX faithfulness mode, which throws an error if the input uses features that are not supported by LaTeX.",cli:"-S, --strict",cliDefault:!1},trust:{type:["boolean","function"],description:"Trust the input, enabling all HTML features such as \\url.",cli:"-T, --trust"},maxSize:{type:"number",default:1/0,description:"If non-zero, all user-specified sizes, e.g. in \\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, elements and spaces can be arbitrarily large",processor:t=>Math.max(0,t),cli:"-s, --max-size <n>",cliProcessor:parseInt},maxExpand:{type:"number",default:1e3,description:"Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to Infinity, the macro expander will try to fully expand as in LaTeX.",processor:t=>Math.max(0,t),cli:"-e, --max-expand <n>",cliProcessor:t=>t==="Infinity"?1/0:parseInt(t)},globalGroup:{type:"boolean",cli:!1}};function fut(t){if(typeof t!="string")return t.enum[0];switch(t){case"boolean":return!1;case"string":return"";case"number":return 0;case"object":return{};default:throw new Error("Unexpected schema type; settings must declare an explicit default.")}}function put(t){if(t.default!==void 0)return t.default;var e=Array.isArray(t.type)?t.type[0]:t.type;return fut(e)}function gut(t,e,r,n){var i=r[e];t[e]=i!==void 0?n.processor?n.processor(i):i:put(n)}class Zq{constructor(e){e===void 0&&(e={}),this.displayMode=void 0,this.output=void 0,this.leqno=void 0,this.fleqn=void 0,this.throwOnError=void 0,this.errorColor=void 0,this.macros=void 0,this.minRuleThickness=void 0,this.colorIsTextColor=void 0,this.strict=void 0,this.trust=void 0,this.maxSize=void 0,this.maxExpand=void 0,this.globalGroup=void 0,e=e||{};for(var r of Object.keys(U8)){var n=U8[r];n&&gut(this,r,e,n)}}reportNonstrict(e,r,n){var i=this.strict;if(typeof i=="function"&&(i=i(e,r,n)),!(!i||i==="ignore")){if(i===!0||i==="error")throw new Bt("LaTeX-incompatible input and strict mode is set to 'error': "+(r+" ["+e+"]"),n);i==="warn"?typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+(r+" ["+e+"]")):typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to "+("unrecognized '"+i+"': "+r+" ["+e+"]"))}}useStrictBehavior(e,r,n){var i=this.strict;if(typeof i=="function")try{i=i(e,r,n)}catch{i="error"}return!i||i==="ignore"?!1:i===!0||i==="error"?!0:i==="warn"?(typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+(r+" ["+e+"]")),!1):(typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to "+("unrecognized '"+i+"': "+r+" ["+e+"]")),!1)}isTrusted(e){if("url"in e&&e.url&&!e.protocol){var r=dut(e.url);if(r==null)return!1;e.protocol=r}var n=typeof this.trust=="function"?this.trust(e):this.trust;return!!n}}class hf{constructor(e,r,n){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=e,this.size=r,this.cramped=n}sup(){return Au[mut[this.id]]}sub(){return Au[yut[this.id]]}fracNum(){return Au[vut[this.id]]}fracDen(){return Au[but[this.id]]}cramp(){return Au[xut[this.id]]}text(){return Au[Tut[this.id]]}isTight(){return this.size>=2}}var Jq=0,Y8=1,Oy=2,fd=3,xw=4,Jl=5,r4=6,mo=7,Au=[new hf(Jq,0,!1),new hf(Y8,0,!0),new hf(Oy,1,!1),new hf(fd,1,!0),new hf(xw,2,!1),new hf(Jl,2,!0),new hf(r4,3,!1),new hf(mo,3,!0)],mut=[xw,Jl,xw,Jl,r4,mo,r4,mo],yut=[Jl,Jl,Jl,Jl,mo,mo,mo,mo],vut=[Oy,fd,xw,Jl,r4,mo,r4,mo],but=[fd,fd,Jl,Jl,mo,mo,mo,mo],xut=[Y8,Y8,fd,fd,Jl,Jl,mo,mo],Tut=[Jq,Y8,Oy,fd,Oy,fd,Oy,fd],Qr={DISPLAY:Au[Jq],TEXT:Au[Oy],SCRIPT:Au[xw],SCRIPTSCRIPT:Au[r4]},BP=[{name:"latin",blocks:[[256,591],[768,879]]},{name:"cyrillic",blocks:[[1024,1279]]},{name:"armenian",blocks:[[1328,1423]]},{name:"brahmic",blocks:[[2304,4255]]},{name:"georgian",blocks:[[4256,4351]]},{name:"cjk",blocks:[[12288,12543],[19968,40879],[65280,65376]]},{name:"hangul",blocks:[[44032,55215]]}];function wut(t){for(var e=0;e<BP.length;e++)for(var r=BP[e],n=0;n<r.blocks.length;n++){var i=r.blocks[n];if(t>=i[0]&&t<=i[1])return r.name}return null}var jS=[];BP.forEach(t=>t.blocks.forEach(e=>jS.push(...e)));function H2e(t){for(var e=0;e<jS.length;e+=2)if(t>=jS[e]&&t<=jS[e+1])return!0;return!1}var La=t=>t+" "+t,f1=80,kut=function(e,r){return"M95,"+(622+e+r)+`
+`)}:null},nut=(t,e,r)=>{var f,p,g;const n=(f=t.storage.markdown)==null?void 0:f.manager,i=e.trim(),a=((p=n==null?void 0:n.parse)==null?void 0:p.call(n,i).content)??[{type:"text",text:i}];if(!r)return a;const s=i.replace(/\s*\n+\s*/g," "),o=(g=n==null?void 0:n.parse)==null?void 0:g.call(n,`${II}${s}`).content,l=(o==null?void 0:o.length)===1?o[0]:null,u=(l==null?void 0:l.type)==="paragraph"?l.content??[]:[],h=u[0];if((h==null?void 0:h.type)!=="text"||typeof h.text!="string"||!h.text.startsWith(II))return[{type:"text",text:s}];const d=h.text.slice(II.length);return[...d?[{...h,text:d}]:[],...u.slice(1)]};function Hh(t){try{const e=JSON.stringify(t.getJSON()),r=F2e(t);Ss({type:"change",contentMarkdown:r,contentJson:e})}catch(e){Ss({type:"error",message:e instanceof Error?e.message:String(e)})}}function iut(t,e){const r=e.trim().toLocaleLowerCase();if(r.length===0)return[];const n=[];let i=null;t.state.doc.descendants((l,u)=>{if(!(!l.isText||!l.text)){i!==null&&u>i&&n.push({char:"\0",pos:-1});for(let h=0;h<l.text.length;h+=1)n.push({char:l.text[h]??"",pos:u+h});i=u+l.text.length}});const a=n.map(l=>l.char).join("").toLocaleLowerCase(),s=[];let o=a.indexOf(r);for(;o!==-1;){const l=n[o],u=n[o+r.length-1];l&&u&&l.pos>=0&&u.pos>=0&&s.push({from:l.pos,to:u.pos+1}),o=a.indexOf(r,o+r.length)}return s}const kte=()=>Tr.isActive("taskItem")?"taskItem":"listItem";function z2e(t){var r;if(YS.classList.toggle("editor-mode",t),YS.innerHTML="",!t)return;const e=[{id:"image",label:"▧+",run:()=>Ss({type:"pickImage"})},{id:"bold",label:"B",run:()=>Tr.chain().focus().toggleBold().run()},{id:"bullet",label:"•",run:()=>Tr.chain().focus().toggleBulletList().run()},{id:"task",label:"☑",run:()=>Tr.chain().focus().toggleTaskList().run()},{id:"indent",label:"⇥",run:()=>Tr.chain().focus().sinkListItem(kte()).run()},{id:"outdent",label:"⇤",run:()=>Tr.chain().focus().liftListItem(kte()).run()},{id:"quote",label:"❝",run:()=>Tr.chain().focus().toggleBlockquote().run()},{id:"hr",label:"—",run:()=>Tr.chain().focus().setHorizontalRule().run()}];for(const n of e){const i=document.createElement("button");i.type="button",i.textContent=n.label,i.dataset.action=n.id;const a={image:["插入图片","Insert image"],bold:["粗体","Bold"],bullet:["项目符号列表","Bullet list"],task:["任务清单","Task list"],indent:["增加列表缩进","Increase list indent"],outdent:["减少列表缩进","Decrease list indent"],quote:["引用","Block quote"],hr:["分隔线","Horizontal rule"]};i.setAttribute("aria-label",((r=a[n.id])==null?void 0:r[O2e==="en-US"?1:0])??n.id),i.addEventListener("click",()=>{n.run(),n.id!=="image"&&Hh(Tr),W8()}),YS.appendChild(i)}W8()}function W8(){const t={bold:Tr.isActive("bold"),bullet:Tr.isActive("bulletList"),task:Tr.isActive("taskList"),quote:Tr.isActive("blockquote")};YS.querySelectorAll("button[data-action]").forEach(e=>{e.classList.toggle("is-active",t[e.dataset.action??""]??!1)})}async function DI(t="light"){Zl.querySelectorAll("[data-placeholder]").forEach(e=>{e.dataset.placeholder=PP}),await jct(Zl),xs==="viewer"&&await Kct(Zl,t)}async function aut(t){var p;if(!t.requestId||t.format!=="png"&&t.format!=="jpeg")return;const e=Not(t.background,t.theme),r=t.fontStyle??"serif",n=t.fontSize??"lg",i=t.cardWidth??"standard",a=Rve[i]||680,s=e4[e]||e4.slate,o=Tr.view.dom.cloneNode(!0);o.removeAttribute("contenteditable"),o.querySelectorAll("button, [contenteditable='true']").forEach(g=>{g.removeAttribute("contenteditable"),g instanceof HTMLButtonElement&&g.remove()});const l=o.innerHTML,u=document.createElement("div");u.style.cssText=`position:fixed;left:-100000px;top:0;width:${a}px;pointer-events:none;`;const h=document.createElement("style");h.textContent=Pot({theme:e,fontStyle:r,fontSize:n,cardWidth:i});const d=$ot({title:t.title||t.fallbackTitle,notebook:t.notebook,tags:t.tags,updatedAt:t.updatedAt,bodyHtml:l,theme:e,fontStyle:r,showTitle:t.showTitle??!0,showNotebook:t.showNotebook??!1,showTags:t.showTags??!1,showUpdatedAt:t.showUpdatedAt??!0,showBranding:t.branding??!0});u.appendChild(h),u.insertAdjacentHTML("beforeend",d);const f=u.lastElementChild;f.style.width=`${a}px`,f.style.maxWidth="none",f.style.margin="0",document.body.appendChild(u);try{await((p=document.fonts)==null?void 0:p.ready),await Promise.all(Array.from(f.querySelectorAll("img")).map(async M=>{if(!M.complete)try{await M.decode()}catch{}}));const g=Array.from(f.querySelectorAll(".edgeever-card-body img")),m=g.filter(M=>!M.complete||M.naturalWidth===0).length,y=Math.max(1,Math.ceil(f.getBoundingClientRect().height)),v=Dot[e]||s.canvasBg,x=await Mot(f,{backgroundColor:v,cacheBust:!1,height:y,pixelRatio:2,skipFonts:!0,width:a}),b=await new Promise((M,L)=>{x.toBlob(P=>P?M(P):L(new Error("Image renderer returned an empty file")),t.format==="jpeg"?"image/jpeg":"image/png",t.format==="jpeg"?.92:1)}),w=t.format==="jpeg"?"jpg":"png",k=Oot(t.title,t.fallbackTitle),S=await Yct(b),C=`${k}.${w}`,E=t.format==="jpeg"?"image/jpeg":"image/png",A=Xct(S);for(let M=0;M<A.length;M+=xte)Ss({type:"imageExportChunk",requestId:t.requestId,chunk:A.slice(M,M+xte)}),await new Promise(L=>setTimeout(L,0));Ss({type:"imageExportComplete",requestId:t.requestId,filename:C,mimeType:E,width:x.width,height:x.height,totalImages:g.length,failedImages:m})}catch(g){Ss({type:"imageExportError",requestId:t.requestId,message:g instanceof Error?g.message:"Image export failed"})}finally{u.remove()}}const sut={exportImage(t){aut(t)},configure(t){const e=t.mode==="editor"?"editor":"viewer",r=e!==xs;xs=e,O2e=t.locale==="en-US"?"en-US":"zh-CN",Tr.setEditable(xs==="editor"),z2e(xs==="editor"),document.documentElement.dataset.theme=t.theme||"light",document.body.classList.toggle("viewer-mode",xs==="viewer"),document.body.classList.toggle("editor-mode",xs==="editor"),t.placeholder&&(PP=t.placeholder,Zl.querySelectorAll("[data-placeholder]").forEach(n=>{n.dataset.placeholder=PP})),xs==="editor"&&r&&requestAnimationFrame(()=>{try{Tr.commands.focus("end")}catch{}}),DI(t.theme||"light")},setMarkdown(t){var e;C3=!0;try{Tr.commands.setContent(t||"",{contentType:"markdown"})}catch{try{const r=(e=Tr.storage.markdown)==null?void 0:e.manager;if(r)Tr.commands.setContent(r.parse(t||""));else throw new Error("no markdown manager")}catch{Tr.commands.setContent({type:"doc",content:[{type:"paragraph",content:t?[{type:"text",text:t}]:[]}]})}}Tr.setEditable(xs==="editor"),C3=!1,DI(document.documentElement.dataset.theme||"light")},setDocumentFromJSON(t){C3=!0;try{const e=JSON.parse(t);Tr.commands.setContent(e)}catch{Tr.commands.setContent({type:"doc",content:[{type:"paragraph"}]})}Tr.setEditable(xs==="editor"),C3=!1,DI(document.documentElement.dataset.theme||"light")},resolveResource(t,e){const r=G8.get(t);r&&(G8.delete(t),r(e))},getMarkdown(){return F2e(Tr)},getDocument(){return JSON.stringify(Tr.getJSON())},captureSelection(){const t=rut(Tr);return t?(P5={from:t.from,to:t.to,isInline:t.isInline,documentFingerprint:JSON.stringify(Tr.getJSON())},JSON.stringify({from:t.from,to:t.to,markdown:t.markdown,text:t.text})):(P5=null,null)},applySelectionDraft(t,e){var s,o;const r=P5;if(!r||!t.trim())return!1;if(JSON.stringify(Tr.getJSON())!==r.documentFingerprint)return P5=null,!1;const n=Tr.state.doc.content.size,i=Math.min(Math.max(r.from,0),n),a=Math.min(Math.max(r.to,i),n);try{const l=(s=Tr.storage.markdown)==null?void 0:s.manager,u=(o=l==null?void 0:l.parse)==null?void 0:o.call(l,t),h=e==="replace"?nut(Tr,t,r.isInline):(u==null?void 0:u.content)??t,d=e==="append"?{from:a,to:a}:{from:i,to:a};return Tr.chain().focus().insertContentAt(d,h).run(),P5=null,Hh(Tr),!0}catch{return!1}},undo(){if(!Tr.can().undo())return!1;const t=Tr.commands.undo();return t&&Hh(Tr),t},focusEnd(){var t;try{Tr.commands.focus("end")}catch{}try{const e=(t=Tr.view)==null?void 0:t.dom;e&&typeof e.focus=="function"&&e.focus({preventScroll:!0})}catch{}},flush(){Hh(Tr)},exec(t){var r;const e={bold:()=>Tr.chain().focus().toggleBold().run(),bulletList:()=>Tr.chain().focus().toggleBulletList().run(),taskList:()=>Tr.chain().focus().toggleTaskList().run(),blockquote:()=>Tr.chain().focus().toggleBlockquote().run(),horizontalRule:()=>Tr.chain().focus().setHorizontalRule().run(),heading2:()=>Tr.chain().focus().toggleHeading({level:2}).run(),codeBlock:()=>Tr.chain().focus().toggleCodeBlock().run()};(r=e[t])==null||r.call(e),Hh(Tr)},beginImageUpload(t,e){Tr.chain().focus().setImage({src:e,alt:t}).run();const r=Zl.querySelectorAll("img"),n=r[r.length-1];n&&(n.dataset.uploadId=t),Hh(Tr)},completeImageUpload(t,e,r){Tr.chain().focus().setImage({src:e,alt:r||t||""}).run();const n=Zl.querySelectorAll("img"),i=n[n.length-1];i&&(i.dataset.originalSrc=e,delete i.dataset.uploadId),Hh(Tr)},cancelImageUpload(t){const e=Zl.querySelector(`img[data-upload-id="${t}"]`);e==null||e.remove(),Hh(Tr)},search(t,e){const r=iut(Tr,t),n=r.length>0?Math.min(Math.max(Number.isFinite(e)?e:0,0),r.length-1):0,i=r[n];if(i){Tr.commands.setTextSelection({from:i.from,to:i.to});try{const a=Tr.view.domAtPos(i.from).node,s=a instanceof Element?a:a.parentElement;s==null||s.scrollIntoView({block:"center",behavior:"smooth"})}catch{}}Ss({type:"searchResult",count:r.length,index:n})}};window.EdgeEverEditor=sut;z2e(!1);Ss({type:"ready",startupMs:Math.round(performance.now()-Wct)});class Bt extends Error{constructor(e,r){var n="KaTeX parse error: "+e,i,a,s=r&&r.loc;if(s&&s.start<=s.end){var o=s.lexer.input;i=s.start,a=s.end,i===o.length?n+=" at end of input: ":n+=" at position "+(i+1)+": ";var l=o.slice(i,a).replace(/[^]/g,"$&̲"),u;i>15?u="…"+o.slice(i-15,i):u=o.slice(0,i);var h;a+15<o.length?h=o.slice(a,a+15)+"…":h=o.slice(a),n+=u+l+h}super(n),this.name="ParseError",this.position=void 0,this.length=void 0,this.rawMessage=void 0,Object.setPrototypeOf(this,Bt.prototype),this.position=i,i!=null&&a!=null&&(this.length=a-i),this.rawMessage=e}}var out=/([A-Z])/g,lut=t=>t.replace(out,"-$1").toLowerCase(),cut={"&":"&amp;",">":"&gt;","<":"&lt;",'"':"&quot;","'":"&#x27;"},uut=/[&><"']/g,Gs=t=>String(t).replace(uut,e=>cut[e]),XS=t=>t.type==="ordgroup"||t.type==="color"?t.body.length===1?XS(t.body[0]):t:t.type==="font"?XS(t.body):t,hut=new Set(["mathord","textord","atom"]),Gd=t=>hut.has(XS(t).type),dut=t=>{var e=/^[\x00-\x20]*([^\\/#?]*?)(:|&#0*58|&#x0*3a|&colon)/i.exec(t);return e?e[2]!==":"||!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(e[1])?null:e[1].toLowerCase():"_relative"},U8={displayMode:{type:"boolean",description:"Render math in display mode, which puts the math in display style (so \\int and \\sum are large, for example), and centers the math on the page on its own line.",cli:"-d, --display-mode"},output:{type:{enum:["htmlAndMathml","html","mathml"]},description:"Determines the markup language of the output.",cli:"-F, --format <type>"},leqno:{type:"boolean",description:"Render display math in leqno style (left-justified tags)."},fleqn:{type:"boolean",description:"Render display math flush left."},throwOnError:{type:"boolean",default:!0,cli:"-t, --no-throw-on-error",cliDescription:"Render errors (in the color given by --error-color) instead of throwing a ParseError exception when encountering an error."},errorColor:{type:"string",default:"#cc0000",cli:"-c, --error-color <color>",cliDescription:"A color string given in the format 'rgb' or 'rrggbb' (no #). This option determines the color of errors rendered by the -t option.",cliProcessor:t=>"#"+t},macros:{type:"object",cli:"-m, --macro <def>",cliDescription:"Define custom macro of the form '\\foo:expansion' (use multiple -m arguments for multiple macros).",cliDefault:[],cliProcessor:(t,e)=>(e.push(t),e)},minRuleThickness:{type:"number",description:"Specifies a minimum thickness, in ems, for fraction lines, `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, `\\hdashline`, `\\underline`, `\\overline`, and the borders of `\\fbox`, `\\boxed`, and `\\fcolorbox`.",processor:t=>Math.max(0,t),cli:"--min-rule-thickness <size>",cliProcessor:parseFloat},colorIsTextColor:{type:"boolean",description:"Makes \\color behave like LaTeX's 2-argument \\textcolor, instead of LaTeX's one-argument \\color mode change.",cli:"-b, --color-is-text-color"},strict:{type:[{enum:["warn","ignore","error"]},"boolean","function"],description:"Turn on strict / LaTeX faithfulness mode, which throws an error if the input uses features that are not supported by LaTeX.",cli:"-S, --strict",cliDefault:!1},trust:{type:["boolean","function"],description:"Trust the input, enabling all HTML features such as \\url.",cli:"-T, --trust"},maxSize:{type:"number",default:1/0,description:"If non-zero, all user-specified sizes, e.g. in \\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, elements and spaces can be arbitrarily large",processor:t=>Math.max(0,t),cli:"-s, --max-size <n>",cliProcessor:parseInt},maxExpand:{type:"number",default:1e3,description:"Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to Infinity, the macro expander will try to fully expand as in LaTeX.",processor:t=>Math.max(0,t),cli:"-e, --max-expand <n>",cliProcessor:t=>t==="Infinity"?1/0:parseInt(t)},globalGroup:{type:"boolean",cli:!1}};function fut(t){if(typeof t!="string")return t.enum[0];switch(t){case"boolean":return!1;case"string":return"";case"number":return 0;case"object":return{};default:throw new Error("Unexpected schema type; settings must declare an explicit default.")}}function put(t){if(t.default!==void 0)return t.default;var e=Array.isArray(t.type)?t.type[0]:t.type;return fut(e)}function gut(t,e,r,n){var i=r[e];t[e]=i!==void 0?n.processor?n.processor(i):i:put(n)}class Zq{constructor(e){e===void 0&&(e={}),this.displayMode=void 0,this.output=void 0,this.leqno=void 0,this.fleqn=void 0,this.throwOnError=void 0,this.errorColor=void 0,this.macros=void 0,this.minRuleThickness=void 0,this.colorIsTextColor=void 0,this.strict=void 0,this.trust=void 0,this.maxSize=void 0,this.maxExpand=void 0,this.globalGroup=void 0,e=e||{};for(var r of Object.keys(U8)){var n=U8[r];n&&gut(this,r,e,n)}}reportNonstrict(e,r,n){var i=this.strict;if(typeof i=="function"&&(i=i(e,r,n)),!(!i||i==="ignore")){if(i===!0||i==="error")throw new Bt("LaTeX-incompatible input and strict mode is set to 'error': "+(r+" ["+e+"]"),n);i==="warn"?typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+(r+" ["+e+"]")):typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to "+("unrecognized '"+i+"': "+r+" ["+e+"]"))}}useStrictBehavior(e,r,n){var i=this.strict;if(typeof i=="function")try{i=i(e,r,n)}catch{i="error"}return!i||i==="ignore"?!1:i===!0||i==="error"?!0:i==="warn"?(typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+(r+" ["+e+"]")),!1):(typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to "+("unrecognized '"+i+"': "+r+" ["+e+"]")),!1)}isTrusted(e){if("url"in e&&e.url&&!e.protocol){var r=dut(e.url);if(r==null)return!1;e.protocol=r}var n=typeof this.trust=="function"?this.trust(e):this.trust;return!!n}}class hf{constructor(e,r,n){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=e,this.size=r,this.cramped=n}sup(){return Au[mut[this.id]]}sub(){return Au[yut[this.id]]}fracNum(){return Au[vut[this.id]]}fracDen(){return Au[but[this.id]]}cramp(){return Au[xut[this.id]]}text(){return Au[Tut[this.id]]}isTight(){return this.size>=2}}var Jq=0,Y8=1,Oy=2,fd=3,xw=4,Jl=5,r4=6,mo=7,Au=[new hf(Jq,0,!1),new hf(Y8,0,!0),new hf(Oy,1,!1),new hf(fd,1,!0),new hf(xw,2,!1),new hf(Jl,2,!0),new hf(r4,3,!1),new hf(mo,3,!0)],mut=[xw,Jl,xw,Jl,r4,mo,r4,mo],yut=[Jl,Jl,Jl,Jl,mo,mo,mo,mo],vut=[Oy,fd,xw,Jl,r4,mo,r4,mo],but=[fd,fd,Jl,Jl,mo,mo,mo,mo],xut=[Y8,Y8,fd,fd,Jl,Jl,mo,mo],Tut=[Jq,Y8,Oy,fd,Oy,fd,Oy,fd],Qr={DISPLAY:Au[Jq],TEXT:Au[Oy],SCRIPT:Au[xw],SCRIPTSCRIPT:Au[r4]},BP=[{name:"latin",blocks:[[256,591],[768,879]]},{name:"cyrillic",blocks:[[1024,1279]]},{name:"armenian",blocks:[[1328,1423]]},{name:"brahmic",blocks:[[2304,4255]]},{name:"georgian",blocks:[[4256,4351]]},{name:"cjk",blocks:[[12288,12543],[19968,40879],[65280,65376]]},{name:"hangul",blocks:[[44032,55215]]}];function wut(t){for(var e=0;e<BP.length;e++)for(var r=BP[e],n=0;n<r.blocks.length;n++){var i=r.blocks[n];if(t>=i[0]&&t<=i[1])return r.name}return null}var jS=[];BP.forEach(t=>t.blocks.forEach(e=>jS.push(...e)));function H2e(t){for(var e=0;e<jS.length;e+=2)if(t>=jS[e]&&t<=jS[e+1])return!0;return!1}var La=t=>t+" "+t,f1=80,kut=function(e,r){return"M95,"+(622+e+r)+`
c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
diff --git a/apps/ios/EditorSource/src/main.ts b/apps/ios/EditorSource/src/main.ts
index 04484277..57c21884 100644
--- a/apps/ios/EditorSource/src/main.ts
+++ b/apps/ios/EditorSource/src/main.ts
@@ -83,7 +83,16 @@ type BridgeMessage =
| { type: "pickImage" }
| { type: "searchResult"; count: number; index: number }
| { type: "imageExportChunk"; requestId: string; chunk: string }
- | { type: "imageExportComplete"; requestId: string; filename: string; mimeType: string }
+ | {
+ type: "imageExportComplete";
+ requestId: string;
+ filename: string;
+ mimeType: string;
+ width: number;
+ height: number;
+ totalImages: number;
+ failedImages: number;
+ }
| { type: "imageExportError"; requestId: string; message: string }
| { type: "activeFlags"; flags: number }
| { type: "log"; message: string }
@@ -1161,6 +1170,10 @@ async function exportNoteImage(request: ImageExportRequest) {
if (image.complete) return;
try { await image.decode(); } catch { /* Export the readable remainder. */ }
}));
+ const exportedImages = Array.from(
+ documentRoot.querySelectorAll<HTMLImageElement>(".edgeever-card-body img"),
+ );
+ const failedImages = exportedImages.filter((image) => !image.complete || image.naturalWidth === 0).length;
const totalHeight = Math.max(1, Math.ceil(documentRoot.getBoundingClientRect().height));
const backgroundColor = NOTE_IMAGE_BACKGROUND_COLORS[resolvedTheme] || themeCfg.canvasBg;
@@ -1190,7 +1203,16 @@ async function exportNoteImage(request: ImageExportRequest) {
post({ type: "imageExportChunk", requestId: request.requestId, chunk: base64.slice(offset, offset + IMAGE_EXPORT_CHUNK_SIZE) });
await new Promise((resolve) => setTimeout(resolve, 0));
}
- post({ type: "imageExportComplete", requestId: request.requestId, filename, mimeType });
+ post({
+ type: "imageExportComplete",
+ requestId: request.requestId,
+ filename,
+ mimeType,
+ width: canvas.width,
+ height: canvas.height,
+ totalImages: exportedImages.length,
+ failedImages,
+ });
} catch (error) {
post({ type: "imageExportError", requestId: request.requestId, message: error instanceof Error ? error.message : "Image export failed" });
} finally {
diff --git a/apps/ios/Tests/EdgeEverTests/EditorBundleTests.swift b/apps/ios/Tests/EdgeEverTests/EditorBundleTests.swift
index e2494009..526efc09 100644
--- a/apps/ios/Tests/EdgeEverTests/EditorBundleTests.swift
+++ b/apps/ios/Tests/EdgeEverTests/EditorBundleTests.swift
@@ -44,6 +44,10 @@ final class EditorBundleTests: XCTestCase {
html.contains("imageExportComplete") && html.contains("imageExportChunk"),
"large image exports must cross the native bridge in bounded chunks"
)
+ XCTAssertTrue(
+ html.contains("failedImages") && html.contains("totalImages"),
+ "image export completion must report note-image failures for preview feedback"
+ )
}
/// Caret must not be forced to document end on every content set / keystroke path.
diff --git a/apps/mobile/src/components/LocalTiptapEditor.tsx b/apps/mobile/src/components/LocalTiptapEditor.tsx
index 614e6b77..04ee0b1c 100644
--- a/apps/mobile/src/components/LocalTiptapEditor.tsx
+++ b/apps/mobile/src/components/LocalTiptapEditor.tsx
@@ -1151,6 +1151,10 @@ function LocalTiptapEditorImpl(props: LocalTiptapEditorProps) {
if (image.complete) return;
try { await image.decode(); } catch { /* Export the readable remainder. */ }
}));
+ const exportedImages = Array.from(
+ documentRoot.querySelectorAll<HTMLImageElement>(".edgeever-card-body img"),
+ );
+ const failedImages = exportedImages.filter((image) => !image.complete || image.naturalWidth === 0).length;
const totalHeight = Math.max(1, Math.ceil(documentRoot.getBoundingClientRect().height));
const backgroundColor = NOTE_IMAGE_BACKGROUND_COLORS[resolvedTheme] || themeCfg.canvasBg;
@@ -1180,7 +1184,15 @@ function LocalTiptapEditorImpl(props: LocalTiptapEditorProps) {
for (let offset = 0; offset < base64.length; offset += IMAGE_EXPORT_CHUNK_SIZE) {
await notify({ type: "chunk", chunk: base64.slice(offset, offset + IMAGE_EXPORT_CHUNK_SIZE) });
}
- await notify({ type: "complete", filename, mimeType });
+ await notify({
+ type: "complete",
+ filename,
+ mimeType,
+ width: canvas.width,
+ height: canvas.height,
+ totalImages: exportedImages.length,
+ failedImages,
+ });
} catch (error) {
await notify({ type: "error", message: error instanceof Error ? error.message : "Image export failed" });
} finally {
diff --git a/apps/mobile/src/screens/WorkspaceMemoDetail.tsx b/apps/mobile/src/screens/WorkspaceMemoDetail.tsx
index 5bb00481..b5a0456a 100644
--- a/apps/mobile/src/screens/WorkspaceMemoDetail.tsx
+++ b/apps/mobile/src/screens/WorkspaceMemoDetail.tsx
@@ -7,7 +7,7 @@ import {
type NoteImageCardWidth,
} from "@edgeever/shared/note-image-card";
import * as Clipboard from "expo-clipboard";
-import { Image as RNImage, Platform, StyleSheet, Text as RNText, View, type ImageStyle, type StyleProp, type TextStyle } from "react-native";
+import { Image as RNImage, Platform, ScrollView, StyleSheet, Text as RNText, View, type ImageStyle, type StyleProp, type TextStyle } from "react-native";
import { Modal } from "react-native";
import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context";
import { SvgXml } from "react-native-svg";
@@ -45,9 +45,29 @@ const RESOURCE_DATA_URL_CACHE_LIMIT = 32;
type MobileImageExportEvent =
| { type: "chunk"; requestId: string; chunk: string }
- | { type: "complete"; requestId: string; filename: string; mimeType: string }
+ | {
+ type: "complete";
+ requestId: string;
+ filename: string;
+ mimeType: string;
+ width?: number;
+ height?: number;
+ totalImages?: number;
+ failedImages?: number;
+ }
| { type: "error"; requestId: string; message?: string };
+type MobilePreparedNoteImage = {
+ base64: string;
+ failedImages: number;
+ filename: string;
+ height: number;
+ mimeType: string;
+ totalImages: number;
+ uri: string;
+ width: number;
+};
+
const decodeBase64Chunks = (chunks: string[]) => {
const parts = chunks.map((chunk) => {
const binary = atob(chunk);
@@ -453,12 +473,16 @@ export const MemoDetailModal = ({
const [imageShareFormat, setImageShareFormat] = useState<"jpeg" | "png">("png");
const [imageShareTheme, setImageShareTheme] = useState<NoteImageTheme>("slate");
const [imageShareFontStyle, setImageShareFontStyle] = useState<NoteImageFontStyle>("serif");
+ const [imageShareFontSize, setImageShareFontSize] = useState<NoteImageFontSize>("lg");
+ const [imageShareCardWidth, setImageShareCardWidth] = useState<NoteImageCardWidth>("standard");
const [imageShareTitle, setImageShareTitle] = useState(true);
const [imageShareNotebook, setImageShareNotebook] = useState(false);
const [imageShareTags, setImageShareTags] = useState(false);
const [imageShareUpdatedAt, setImageShareUpdatedAt] = useState(true);
const [imageShareBranding, setImageShareBranding] = useState(true);
+ const [preparedNoteImage, setPreparedNoteImage] = useState<MobilePreparedNoteImage | null>(null);
const viewerRef = useRef<LocalTiptapEditorRef>(null);
+ const imageExportIntentRef = useRef<"preview" | "share">("share");
const imageExportRequestRef = useRef<string | null>(null);
const imageExportChunksRef = useRef<string[]>([]);
const resourceDataUrlCacheRef = useRef(new Map<string, Promise<string | null>>());
@@ -673,13 +697,28 @@ export const MemoDetailModal = ({
const file = new File(directory, event.filename);
if (file.exists) file.delete();
file.create({ overwrite: true, intermediates: true });
+ const base64 = imageExportChunksRef.current.join("");
file.write(decodeBase64Chunks(imageExportChunksRef.current));
- const Sharing = await import("expo-sharing");
- if (!(await Sharing.isAvailableAsync())) throw new Error(resolvedLocale === "en-US" ? "Sharing is unavailable on this device." : "当前设备无法打开系统分享面板。");
- await Sharing.shareAsync(file.uri, {
- dialogTitle: event.filename,
+ const prepared: MobilePreparedNoteImage = {
+ base64,
+ failedImages: event.failedImages ?? 0,
+ filename: event.filename,
+ height: event.height ?? 0,
mimeType: event.mimeType,
- });
+ totalImages: event.totalImages ?? 0,
+ uri: file.uri,
+ width: event.width ?? 0,
+ };
+ if (imageExportIntentRef.current === "preview") {
+ setPreparedNoteImage(prepared);
+ } else {
+ const Sharing = await import("expo-sharing");
+ if (!(await Sharing.isAvailableAsync())) throw new Error(resolvedLocale === "en-US" ? "Sharing is unavailable on this device." : "当前设备无法打开系统分享面板。");
+ await Sharing.shareAsync(file.uri, {
+ dialogTitle: event.filename,
+ mimeType: event.mimeType,
+ });
+ }
} catch (error) {
Alert.alert(
resolvedLocale === "en-US" ? "Image export failed" : "导出笔记图片失败",
@@ -704,12 +743,14 @@ export const MemoDetailModal = ({
showTags?: boolean;
showUpdatedAt?: boolean;
showBranding?: boolean;
+ intent?: "preview" | "share";
} = {},
) => {
if (!memo || !viewerReady || isExportingImage) return;
const requestId = `${Date.now()}-${Math.random().toString(36).slice(2)}`;
imageExportRequestRef.current = requestId;
imageExportChunksRef.current = [];
+ imageExportIntentRef.current = options.intent ?? "share";
setIsExportingImage(true);
safeDomCall(() => viewerRef.current?.exportImage(JSON.stringify({
requestId,
@@ -731,6 +772,50 @@ export const MemoDetailModal = ({
})));
}, [isExportingImage, memo, notebookName, resolvedLocale, viewerReady]);
+ const sharePreparedNoteImage = useCallback(async (prepared: MobilePreparedNoteImage) => {
+ try {
+ const Sharing = await import("expo-sharing");
+ if (!(await Sharing.isAvailableAsync())) throw new Error(resolvedLocale === "en-US" ? "Sharing is unavailable on this device." : "当前设备无法打开系统分享面板。");
+ await Sharing.shareAsync(prepared.uri, { dialogTitle: prepared.filename, mimeType: prepared.mimeType });
+ } catch (shareError) {
+ Alert.alert(
+ resolvedLocale === "en-US" ? "Share failed" : "分享失败",
+ shareError instanceof Error ? shareError.message : (resolvedLocale === "en-US" ? "Try again later." : "请稍后重试。")
+ );
+ }
+ }, [resolvedLocale]);
+
+ const copyPreparedNoteImage = useCallback(async (prepared: MobilePreparedNoteImage) => {
+ try {
+ await Clipboard.setImageAsync(prepared.base64);
+ Alert.alert(resolvedLocale === "en-US" ? "Copied" : "复制成功", resolvedLocale === "en-US" ? "The image is on your clipboard." : "图片已复制到剪贴板。");
+ } catch {
+ Alert.alert(resolvedLocale === "en-US" ? "Copy failed" : "复制失败", resolvedLocale === "en-US" ? "Try saving the image instead." : "请尝试保存图片。" );
+ }
+ }, [resolvedLocale]);
+
+ const savePreparedNoteImage = useCallback(async (prepared: MobilePreparedNoteImage) => {
+ try {
+ const FileSystem = await import("expo-file-system/legacy");
+ const permission = await FileSystem.StorageAccessFramework.requestDirectoryPermissionsAsync();
+ if (!permission.granted) return;
+ const destination = await FileSystem.StorageAccessFramework.createFileAsync(
+ permission.directoryUri,
+ prepared.filename,
+ prepared.mimeType
+ );
+ await FileSystem.StorageAccessFramework.writeAsStringAsync(destination, prepared.base64, {
+ encoding: FileSystem.EncodingType.Base64,
+ });
+ Alert.alert(resolvedLocale === "en-US" ? "Saved" : "保存成功", prepared.filename);
+ } catch (saveError) {
+ Alert.alert(
+ resolvedLocale === "en-US" ? "Save failed" : "保存失败",
+ saveError instanceof Error ? saveError.message : (resolvedLocale === "en-US" ? "Try again later." : "请稍后重试。")
+ );
+ }
+ }, [resolvedLocale]);
+
return (
<Modal animationType="slide" onRequestClose={onClose} presentationStyle="fullScreen" visible={visible}>
<SafeAreaView style={styles.modalSafeArea}>
@@ -1007,36 +1092,40 @@ export const MemoDetailModal = ({
<Pressable onPress={() => setActionsOpen(false)} style={styles.actionSheetBackdrop}>
<Pressable style={styles.actionSheet}>
<View style={styles.actionSheetHandle} />
- <Text style={styles.actionSheetTitle}>笔记操作</Text>
+ <Text style={styles.actionSheetTitle}>{resolvedLocale === "en-US" ? "Note actions" : "笔记操作"}</Text>
{!memo.isDeleted ? (
<DetailActionSheetItem
icon={<Sparkles color="#16A06E" size={18} />}
- label="AI 笔记助手"
+ label={resolvedLocale === "en-US" ? "AI note assistant" : "AI 笔记助手"}
onPress={() => closeActionsAndRun(() => setAiAssistantOpen(true))}
/>
) : null}
<DetailActionSheetItem
disabled={!canCopyMemoId}
icon={<Copy color="#0f172a" size={18} />}
- label={canCopyMemoId ? "复制笔记 ID" : "同步后可复制笔记 ID"}
+ label={canCopyMemoId
+ ? (resolvedLocale === "en-US" ? "Copy note ID" : "复制笔记 ID")
+ : (resolvedLocale === "en-US" ? "Copy note ID after sync" : "同步后可复制笔记 ID")}
onPress={() => closeActionsAndRun(() => void copyMemoId())}
/>
<DetailActionSheetItem
disabled={isExportingImage || !viewerReady}
icon={isExportingImage ? <ActivityIndicator color="#16A06E" size="small" /> : <Share2 color="#0f172a" size={18} />}
- label={isExportingImage ? "正在生成分享图片" : "分享为图片"}
+ label={isExportingImage
+ ? (resolvedLocale === "en-US" ? "Generating share image" : "正在生成分享图片")
+ : (resolvedLocale === "en-US" ? "Share as image" : "分享为图片")}
onPress={() => closeActionsAndRun(() => setImageShareOptionsOpen(true))}
/>
<DetailActionSheetItem
disabled={isExportingImage || !viewerReady}
icon={<Download color="#0f172a" size={18} />}
- label="高级导出 PNG"
+ label={resolvedLocale === "en-US" ? "Advanced export PNG" : "高级导出 PNG"}
onPress={() => closeActionsAndRun(() => exportMemoImage("png"))}
/>
<DetailActionSheetItem
disabled={isExportingImage || !viewerReady}
icon={<Download color="#0f172a" size={18} />}
- label="高级导出 JPEG"
+ label={resolvedLocale === "en-US" ? "Advanced export JPEG" : "高级导出 JPEG"}
onPress={() => closeActionsAndRun(() => exportMemoImage("jpeg"))}
/>
{memo.isDeleted ? (
@@ -1059,6 +1148,7 @@ export const MemoDetailModal = ({
<Pressable style={[styles.actionSheet, imageShareStyles.sheetContainer]}>
<View style={styles.actionSheetHandle} />
<Text style={styles.actionSheetTitle}>{resolvedLocale === "en-US" ? "Share as image" : "分享为图片"}</Text>
+ <ScrollView contentContainerStyle={imageShareStyles.optionsContent} showsVerticalScrollIndicator={false} style={imageShareStyles.optionsScroll}>
<Text style={styles.actionSheetSectionTitle}>{resolvedLocale === "en-US" ? "Theme" : "主题风格"}</Text>
<View style={imageShareStyles.themeGrid}>
@@ -1085,6 +1175,32 @@ export const MemoDetailModal = ({
})}
</View>
+ <Text style={styles.actionSheetSectionTitle}>{resolvedLocale === "en-US" ? "Font size" : "字号大小"}</Text>
+ <View style={imageShareStyles.choiceRow}>
+ {([
+ ["sm", resolvedLocale === "en-US" ? "Compact" : "紧凑"],
+ ["md", resolvedLocale === "en-US" ? "Standard" : "标准"],
+ ["lg", resolvedLocale === "en-US" ? "Comfortable" : "舒适"],
+ ] as const).map(([value, label]) => (
+ <Pressable key={value} accessibilityRole="button" onPress={() => setImageShareFontSize(value)} style={[imageShareStyles.choice, imageShareFontSize === value && imageShareStyles.choiceActive]}>
+ <Text style={[imageShareStyles.choiceText, imageShareFontSize === value && imageShareStyles.choiceTextActive]}>{label}</Text>
+ </Pressable>
+ ))}
+ </View>
+
+ <Text style={styles.actionSheetSectionTitle}>{resolvedLocale === "en-US" ? "Card width" : "卡片宽度"}</Text>
+ <View style={imageShareStyles.choiceRow}>
+ {([
+ ["compact", resolvedLocale === "en-US" ? "Compact" : "紧凑"],
+ ["standard", resolvedLocale === "en-US" ? "Standard" : "标准"],
+ ["wide", resolvedLocale === "en-US" ? "Wide" : "宽屏"],
+ ] as const).map(([value, label]) => (
+ <Pressable key={value} accessibilityRole="button" onPress={() => setImageShareCardWidth(value)} style={[imageShareStyles.choice, imageShareCardWidth === value && imageShareStyles.choiceActive]}>
+ <Text style={[imageShareStyles.choiceText, imageShareCardWidth === value && imageShareStyles.choiceTextActive]}>{label}</Text>
+ </Pressable>
+ ))}
+ </View>
+
<Text style={styles.actionSheetSectionTitle}>{resolvedLocale === "en-US" ? "Typography" : "字体风格"}</Text>
<View style={imageShareStyles.choiceRow}>
{MOBILE_FONT_OPTIONS.map((item) => {
@@ -1141,23 +1257,81 @@ export const MemoDetailModal = ({
exportMemoImage(imageShareFormat, {
theme: imageShareTheme,
fontStyle: imageShareFontStyle,
+ fontSize: imageShareFontSize,
+ cardWidth: imageShareCardWidth,
showTitle: imageShareTitle,
showNotebook: imageShareNotebook,
showTags: imageShareTags,
showUpdatedAt: imageShareUpdatedAt,
showBranding: imageShareBranding,
+ intent: "preview",
});
}}
style={[imageShareStyles.shareButton, isExportingImage && styles.buttonDisabled]}
>
<Share2 color="#ffffff" size={18} />
<Text style={imageShareStyles.shareButtonText}>
- {resolvedLocale === "en-US" ? "Generate & Share" : "生成并分享"}
+ {resolvedLocale === "en-US" ? "Generate preview" : "生成预览"}
</Text>
</Pressable>
+ </ScrollView>
</Pressable>
</Pressable>
</Modal>
+ <Modal animationType="slide" onRequestClose={() => setPreparedNoteImage(null)} presentationStyle="fullScreen" visible={Boolean(preparedNoteImage)}>
+ <SafeAreaView style={imageShareStyles.previewSafeArea}>
+ <View style={imageShareStyles.previewHeader}>
+ <Text style={imageShareStyles.previewTitle}>{resolvedLocale === "en-US" ? "Image preview" : "图片预览"}</Text>
+ <Pressable accessibilityLabel={resolvedLocale === "en-US" ? "Close preview" : "关闭预览"} accessibilityRole="button" onPress={() => setPreparedNoteImage(null)} style={imageShareStyles.previewCloseButton}>
+ <X color="#0f172a" size={22} />
+ </Pressable>
+ </View>
+ {preparedNoteImage ? (
+ <>
+ <ScrollView contentContainerStyle={imageShareStyles.previewScrollContent} style={imageShareStyles.previewScroll}>
+ <RNImage
+ resizeMode="contain"
+ source={{ uri: preparedNoteImage.uri }}
+ style={[
+ imageShareStyles.previewImage,
+ preparedNoteImage.width > 0 && preparedNoteImage.height > 0
+ ? { aspectRatio: preparedNoteImage.width / preparedNoteImage.height }
+ : null,
+ ]}
+ />
+ {preparedNoteImage.failedImages > 0 ? (
+ <Text style={imageShareStyles.previewWarning}>
+ {resolvedLocale === "en-US"
+ ? `${preparedNoteImage.failedImages} of ${preparedNoteImage.totalImages} note image(s) could not be included.`
+ : `笔记中的 ${preparedNoteImage.totalImages} 张图片有 ${preparedNoteImage.failedImages} 张未能包含。`}
+ </Text>
+ ) : null}
+ {preparedNoteImage.height > 12_000 ? (
+ <Text style={imageShareStyles.previewWarning}>
+ {resolvedLocale === "en-US"
+ ? "This is a long image. Some social apps may reduce its quality; keep the saved original."
+ : "图片较长,部分社交平台可能会压缩画质;建议保留保存的原图。"}
+ </Text>
+ ) : null}
+ </ScrollView>
+ <View style={imageShareStyles.previewActions}>
+ <Pressable accessibilityRole="button" onPress={() => void copyPreparedNoteImage(preparedNoteImage)} style={imageShareStyles.previewSecondaryButton}>
+ <Copy color="#0f172a" size={18} />
+ <Text style={imageShareStyles.previewSecondaryButtonText}>{resolvedLocale === "en-US" ? "Copy" : "复制图片"}</Text>
+ </Pressable>
+ <Pressable accessibilityRole="button" onPress={() => void savePreparedNoteImage(preparedNoteImage)} style={imageShareStyles.previewSecondaryButton}>
+ <Download color="#0f172a" size={18} />
+ <Text style={imageShareStyles.previewSecondaryButtonText}>{resolvedLocale === "en-US" ? "Save" : "保存图片"}</Text>
+ </Pressable>
+ <Pressable accessibilityRole="button" onPress={() => void sharePreparedNoteImage(preparedNoteImage)} style={imageShareStyles.previewPrimaryButton}>
+ <Share2 color="#ffffff" size={18} />
+ <Text style={imageShareStyles.previewPrimaryButtonText}>{resolvedLocale === "en-US" ? "Share" : "系统分享"}</Text>
+ </Pressable>
+ </View>
+ </>
+ ) : null}
+ </SafeAreaView>
+ </Modal>
{memo && !memo.isDeleted ? (
<MobileAiAssistantModal
memo={memo}
@@ -1229,6 +1403,12 @@ const imageShareStyles = StyleSheet.create({
maxHeight: "85%",
paddingBottom: 24,
},
+ optionsContent: {
+ paddingBottom: 4,
+ },
+ optionsScroll: {
+ flexShrink: 1,
+ },
themeGrid: {
flexDirection: "row",
flexWrap: "wrap",
@@ -1339,6 +1519,92 @@ const imageShareStyles = StyleSheet.create({
fontSize: 15,
fontWeight: "800",
},
+ previewSafeArea: {
+ backgroundColor: "#f1f5f9",
+ flex: 1,
+ },
+ previewHeader: {
+ alignItems: "center",
+ backgroundColor: "#ffffff",
+ borderBottomColor: "#e2e8f0",
+ borderBottomWidth: 1,
+ flexDirection: "row",
+ justifyContent: "space-between",
+ minHeight: 52,
+ paddingHorizontal: 16,
+ },
+ previewTitle: {
+ color: "#0f172a",
+ fontSize: 17,
+ fontWeight: "800",
+ },
+ previewCloseButton: {
+ alignItems: "center",
+ height: 40,
+ justifyContent: "center",
+ width: 40,
+ },
+ previewScroll: {
+ flex: 1,
+ },
+ previewScrollContent: {
+ padding: 16,
+ },
+ previewImage: {
+ alignSelf: "stretch",
+ backgroundColor: "#ffffff",
+ borderRadius: 12,
+ minHeight: 240,
+ width: "100%",
+ },
+ previewWarning: {
+ backgroundColor: "#fffbeb",
+ borderRadius: 8,
+ color: "#a16207",
+ fontSize: 13,
+ lineHeight: 20,
+ marginTop: 12,
+ padding: 10,
+ },
+ previewActions: {
+ backgroundColor: "#ffffff",
+ borderTopColor: "#e2e8f0",
+ borderTopWidth: 1,
+ flexDirection: "row",
+ gap: 8,
+ padding: 12,
+ },
+ previewSecondaryButton: {
+ alignItems: "center",
+ borderColor: "#cbd5e1",
+ borderRadius: 9,
+ borderWidth: 1,
+ flex: 1,
+ flexDirection: "row",
+ gap: 6,
+ justifyContent: "center",
+ minHeight: 44,
+ },
+ previewSecondaryButtonText: {
+ color: "#0f172a",
+ fontSize: 13,
+ fontWeight: "700",
+ },
+ previewPrimaryButton: {
+ alignItems: "center",
+ backgroundColor: "#16A06E",
+ borderRadius: 9,
+ flex: 1,
+ flexDirection: "row",
+ gap: 6,
+ justifyContent: "center",
+ minHeight: 44,
+ },
+ previewPrimaryButtonText: {
+ color: "#ffffff",
+ fontSize: 13,
+ fontWeight: "800",
+ },
});
const detailLayoutStyles = StyleSheet.create({