Skip to content

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

fix(ios): make note image upload pick, insert, and persist on reopen

tianma-if16c1d836d517
diff --git a/apps/ios/EdgeEver/Editor/TipTapWarmPool.swift b/apps/ios/EdgeEver/Editor/TipTapWarmPool.swift
index dce880a7..a1289632 100644
--- a/apps/ios/EdgeEver/Editor/TipTapWarmPool.swift
+++ b/apps/ios/EdgeEver/Editor/TipTapWarmPool.swift
@@ -156,6 +156,97 @@ final class SharedTipTapRuntime: NSObject, WKScriptMessageHandler, WKNavigationD
)
}
+ /// Seed local blob + disk cache so a newly uploaded image can render without a network round-trip.
+ func seedResource(id: String, data: Data, mimeType: String) async {
+ await ResourceBlobStore.shared.put(id: id, data: data, mimeType: mimeType)
+ _ = try? await resourceCache.dataURL(for: id, data: data, mimeType: mimeType)
+ }
+
+ /// Insert an image at the caret (protected API `src` for persistence), then hydrate display.
+ /// Returns `false` if the editor session is not ready or JS insert failed.
+ @discardableResult
+ func insertImage(src: String, alt: String, displayData: Data? = nil, mimeType: String? = nil) async -> Bool {
+ guard session?.mode == .editor else {
+ NSLog("SharedTipTapRuntime insertImage skipped: mode=\(String(describing: session?.mode)) ready=\(ready)")
+ return false
+ }
+ guard ready else {
+ NSLog("SharedTipTapRuntime insertImage skipped: editor bundle not ready")
+ return false
+ }
+
+ if let displayData, let mimeType, let resourceId = ResourceCache.resourceId(from: src) {
+ await seedResource(id: resourceId, data: displayData, mimeType: mimeType)
+ }
+
+ let srcB64 = Data(src.utf8).base64EncodedString()
+ let altB64 = Data(alt.utf8).base64EncodedString()
+ let uploadId = "up-\(UUID().uuidString)"
+ let idB64 = Data(uploadId.utf8).base64EncodedString()
+ let js = """
+ (function(){
+ function dec(b64){
+ var bin = atob(b64);
+ var bytes = new Uint8Array(bin.length);
+ for (var i = 0; i < bin.length; i++) bytes[i] = bin.charCodeAt(i);
+ return new TextDecoder('utf-8').decode(bytes);
+ }
+ try {
+ if (!window.EdgeEverEditor || !window.EdgeEverEditor.completeImageUpload) return false;
+ var id = dec('\(idB64)');
+ var src = dec('\(srcB64)');
+ var alt = dec('\(altB64)');
+ // Stores protected path in TipTap JSON; native hydrate paints it under file://.
+ window.EdgeEverEditor.completeImageUpload(id, src, alt);
+ return true;
+ } catch (e) {
+ try { window.webkit.messageHandlers.edgeever.postMessage({type:'error', message: String(e)}); } catch (_) {}
+ return false;
+ }
+ })();
+ """
+ let ok: Bool = await withCheckedContinuation { cont in
+ webView.evaluateJavaScript(js) { result, error in
+ if let error { NSLog("SharedTipTapRuntime insertImage error: \(error)") }
+ else { NSLog("SharedTipTapRuntime insertImage ok result=\(String(describing: result))") }
+ cont.resume(returning: (result as? Bool) ?? (error == nil))
+ }
+ }
+ guard ok else { return false }
+ await nativeHydrateDOMImages(generation: contentGeneration)
+ return true
+ }
+
+ /// Read current editor markdown + JSON after a mutation (avoids racing the async bridge onChange).
+ func snapshotContent() async -> (markdown: String, json: String)? {
+ guard ready else { return nil }
+ let js = """
+ (function(){
+ try {
+ if (!window.EdgeEverEditor) return null;
+ var md = '';
+ var json = '';
+ try { md = window.EdgeEverEditor.getMarkdown() || ''; } catch (e) {}
+ try { json = window.EdgeEverEditor.getDocument() || ''; } catch (e) {}
+ return JSON.stringify({ md: md, json: json });
+ } catch (e) { return null; }
+ })();
+ """
+ let raw: Any? = await withCheckedContinuation { cont in
+ webView.evaluateJavaScript(js) { value, _ in
+ cont.resume(returning: value)
+ }
+ }
+ guard let text = raw as? String,
+ let data = text.data(using: .utf8),
+ let obj = try? JSONSerialization.jsonObject(with: data) as? [String: Any]
+ else { return nil }
+ let md = obj["md"] as? String ?? ""
+ let json = obj["json"] as? String ?? ""
+ guard !json.isEmpty || !md.isEmpty else { return nil }
+ return (md, json)
+ }
+
private func scheduleFocusEnd(for generation: UInt64) {
guard focusedGeneration != generation else { return }
focusedGeneration = generation
diff --git a/apps/ios/EdgeEver/Features/Workspace/MemoEditView.swift b/apps/ios/EdgeEver/Features/Workspace/MemoEditView.swift
index f9fbec74..7c4baa23 100644
--- a/apps/ios/EdgeEver/Features/Workspace/MemoEditView.swift
+++ b/apps/ios/EdgeEver/Features/Workspace/MemoEditView.swift
@@ -1,5 +1,7 @@
import PhotosUI
import SwiftUI
+import UIKit
+import UniformTypeIdentifiers
enum MemoEditMode: Equatable {
case create(notebookId: String)
@@ -23,7 +25,6 @@ struct MemoEditView: View {
@State private var memoId: String?
@State private var error: String?
@State private var saveTask: Task<Void, Never>?
- @State private var photoItem: PhotosPickerItem?
@State private var isMaterializing = false
@State private var isDirty = false
@State private var isSaving = false
@@ -36,12 +37,36 @@ struct MemoEditView: View {
/// Snapshot of body when edit opened (or last intentional load). Used to reject empty clobbers.
@State private var baselineMarkdown = ""
@State private var showNotebookPicker = false
+ @State private var showImagePicker = false
+ @State private var showUploadError = false
@State private var resourceTarget: ResourceTarget?
var body: some View {
- VStack(spacing: 0) {
- createHeader
- createMain
+ ZStack {
+ VStack(spacing: 0) {
+ createHeader
+ createMain
+ }
+
+ // Impossible-to-miss upload feedback (status chip alone was too easy to miss).
+ if isUploading {
+ Color.black.opacity(0.28)
+ .ignoresSafeArea()
+ .allowsHitTesting(true)
+ VStack(spacing: 12) {
+ ProgressView()
+ .controlSize(.large)
+ .tint(.white)
+ Text(env.preferences.t("正在上传图片…", en: "Uploading image…"))
+ .font(.system(size: 15, weight: .semibold))
+ .foregroundStyle(.white)
+ }
+ .padding(24)
+ .background(.ultraThinMaterial.opacity(0.9))
+ .background(Color.black.opacity(0.55))
+ .clipShape(RoundedRectangle(cornerRadius: 14, style: .continuous))
+ .accessibilityIdentifier("createMemoUploadOverlay")
+ }
}
.background(Color.white.ignoresSafeArea())
.accessibilityIdentifier(CreateMemoChrome.root)
@@ -70,9 +95,30 @@ struct MemoEditView: View {
.presentationDetents([.height(360), .medium])
.presentationDragIndicator(.hidden)
}
- .onChange(of: photoItem) { _, item in
- guard let item else { return }
- Task { await insertImage(item) }
+ // fullScreenCover avoids nested-sheet bugs when MemoEditView itself is already a fullScreenCover.
+ // PHPicker + NSItemProvider (not SwiftUI PhotosPicker/Transferable) is the reliable path.
+ .fullScreenCover(isPresented: $showImagePicker) {
+ SystemImagePicker { result in
+ showImagePicker = false
+ switch result {
+ case .cancelled:
+ break
+ case .failed(let message):
+ error = message
+ showUploadError = true
+ case .picked(let data, let filename):
+ Task { await insertImageData(data, filename: filename) }
+ }
+ }
+ .ignoresSafeArea()
+ }
+ .alert(
+ env.preferences.t("图片上传失败", en: "Image upload failed"),
+ isPresented: $showUploadError
+ ) {
+ Button(env.preferences.t("好的", en: "OK"), role: .cancel) {}
+ } message: {
+ Text(error ?? env.preferences.t("请重试", en: "Please try again"))
}
.task {
await loadInitial()
@@ -87,8 +133,9 @@ struct MemoEditView: View {
}
.onDisappear {
saveTask?.cancel()
- // Only flush real user edits — never push the empty pre-hydrate state.
- if !isCreate, isDirty, contentHydrated {
+ // Flush real edits. Create mode also flushes after materialize (image upload
+ // already created a server memo — draft-only would orphan the image).
+ if isDirty, contentHydrated, (!isCreate || hasMaterializedServerMemo) {
Task { await flushPending() }
}
}
@@ -213,14 +260,25 @@ struct MemoEditView: View {
.accessibilityLabel(env.preferences.t("笔记标签", en: "Tags"))
.accessibilityIdentifier(CreateMemoChrome.tags)
- PhotosPicker(selection: $photoItem, matching: .images) {
+ Button {
+ // Resign WebView first responder so the picker sheet is not blocked.
+ UIApplication.shared.sendAction(
+ #selector(UIResponder.resignFirstResponder),
+ to: nil,
+ from: nil,
+ for: nil
+ )
+ error = nil
+ showImagePicker = true
+ } label: {
Image(systemName: "photo")
.font(.system(size: 15, weight: .semibold))
- .foregroundStyle(AppTheme.slate)
+ .foregroundStyle(isUploading ? AppTheme.muted : AppTheme.slate)
.frame(width: 36, height: 32)
.contentShape(Rectangle())
}
.buttonStyle(.plain)
+ .disabled(isUploading)
.accessibilityLabel(env.preferences.t("插入图片", en: "Insert image"))
.accessibilityIdentifier(CreateMemoChrome.imageTool)
}
@@ -238,9 +296,21 @@ struct MemoEditView: View {
baseURL: env.session.session.map { URL(string: $0.baseUrl) } ?? nil,
token: env.session.session?.token,
onChange: { md, json in
- guard contentHydrated else { return }
- contentMarkdown = md
- contentJSON = json
+ guard contentHydrated, !isUploading else { return }
+ // @tiptap/markdown sometimes omits image nodes; never let a bridge
+ // payload erase protected image refs we already inserted.
+ var nextMd = md
+ let resourceRefs = Self.protectedResourceRefs(in: contentMarkdown)
+ for ref in resourceRefs where !nextMd.contains(ref) {
+ nextMd += "\n\n![](\(ref))\n"
+ }
+ contentMarkdown = nextMd
+ if !json.isEmpty {
+ contentJSON = json
+ }
+ for ref in resourceRefs where !contentJSON.contains(ref) {
+ ensureImageInContent(imageSrc: ref, alt: "image")
+ }
markDirtyAndScheduleSave()
},
onResourcePress: { target in
@@ -346,13 +416,24 @@ struct MemoEditView: View {
// MARK: - Actions
private func markDirtyAndScheduleSave() {
+ // Avoid autosaving mid-upload (placeholder / incomplete body).
+ guard !isUploading else {
+ isDirty = true
+ return
+ }
isDirty = true
scheduleSave()
}
private func handleBack() async {
+ // After image materialize the server memo already exists — must flush body
+ // before dismiss or the uploaded image is orphaned and disappears on reopen.
if isCreate {
- // Draft retained; close without materialize (Android requestClose)
+ if hasMaterializedServerMemo {
+ await pullEditorSnapshotIfPossible()
+ await persistDraftOrQueue()
+ await env.runSyncCycle()
+ }
dismiss()
} else {
await flushPending()
@@ -361,6 +442,7 @@ struct MemoEditView: View {
}
private func handleDone() async {
+ await pullEditorSnapshotIfPossible()
if isCreate {
await commitCreate()
} else {
@@ -369,6 +451,24 @@ struct MemoEditView: View {
}
}
+ /// True once `materializeForImage` (or edit open) holds a real server memo id.
+ private var hasMaterializedServerMemo: Bool {
+ guard let memoId else { return false }
+ return !memoId.hasPrefix("local:")
+ }
+
+ /// Pull markdown/JSON from TipTap so saves don't race the async change bridge.
+ private func pullEditorSnapshotIfPossible() async {
+ guard let snap = await SharedTipTapRuntime.editor.snapshotContent() else { return }
+ if !snap.json.isEmpty {
+ contentJSON = snap.json
+ }
+ // Prefer snapshot markdown, but keep any image refs we already patched in.
+ if !snap.markdown.isEmpty {
+ contentMarkdown = snap.markdown
+ }
+ }
+
private func loadInitial() async {
guard let scope = env.session.dataScope else { return }
switch mode {
@@ -478,8 +578,10 @@ struct MemoEditView: View {
isDirty = false
}
let now = EdgeEverDate.nowString()
- switch mode {
- case .create:
+
+ // Create mode before materialize: draft only.
+ // Create mode after materialize (image upload) OR edit: mirror + outbox update.
+ if isCreate, !hasMaterializedServerMemo {
try? env.drafts.write(
scope: scope,
draft: MemoDraft(
@@ -493,50 +595,85 @@ struct MemoEditView: View {
updatedAt: now
)
)
- case .edit:
- guard let memoId else { return }
- guard var memo = try? env.mirror.resolveMemo(scope: scope, id: memoId) else { return }
- memo.title = title
- memo.contentMarkdown = contentMarkdown
- memo.contentText = contentMarkdown
- memo.tags = tags
- memo.notebookId = notebookId
- memo.updatedAt = now
- memo.excerpt = String(contentMarkdown.prefix(160))
- if let json = try? JSONValue.parse(contentJSON) {
- memo.contentJson = json
- }
- try? env.mirror.upsertMemo(scope: scope, memo: memo)
+ NSLog(
+ "MemoEditView persist draft-only mdLen=%d hasImg=%d",
+ contentMarkdown.count,
+ contentMarkdown.contains("/api/v1/resources/") ? 1 : 0
+ )
+ return
+ }
- let rev = expectedRevision ?? memo.revision
- let hash = expectedContentHash ?? memo.contentHash
- try? env.outbox.enqueueUpdate(
- scope: scope,
- payload: MemoUpdatePayload(
- memoId: memo.id,
- expectedRevision: rev,
- expectedContentHash: hash,
- title: title,
- contentMarkdown: contentMarkdown,
- notebookId: notebookId,
- tags: tags
+ guard let memoId, !memoId.hasPrefix("local:") else {
+ // Offline local: create still in flight — keep draft.
+ if isCreate {
+ try? env.drafts.write(
+ scope: scope,
+ draft: MemoDraft(
+ draftKey: DraftRepository.newKey,
+ title: title,
+ contentMarkdown: contentMarkdown,
+ contentJson: contentJSON,
+ notebookId: notebookId,
+ tagsText: tagsText,
+ expectedRevision: nil,
+ updatedAt: now
+ )
)
+ }
+ return
+ }
+
+ guard var memo = try? env.mirror.resolveMemo(scope: scope, id: memoId) else {
+ NSLog("MemoEditView persist: mirror miss for \(memoId)")
+ return
+ }
+ memo.title = title.isEmpty ? "无标题笔记" : title
+ memo.contentMarkdown = contentMarkdown
+ memo.contentText = contentMarkdown
+ memo.tags = tags
+ memo.notebookId = notebookId
+ memo.updatedAt = now
+ memo.excerpt = String(contentMarkdown.prefix(160))
+ if let json = try? JSONValue.parse(contentJSON) {
+ memo.contentJson = json
+ }
+ try? env.mirror.upsertMemo(scope: scope, memo: memo)
+
+ let rev = expectedRevision ?? memo.revision
+ let hash = expectedContentHash ?? memo.contentHash
+ try? env.outbox.enqueueUpdate(
+ scope: scope,
+ payload: MemoUpdatePayload(
+ memoId: memo.id,
+ expectedRevision: rev,
+ expectedContentHash: hash,
+ title: memo.title ?? title,
+ contentMarkdown: contentMarkdown,
+ notebookId: notebookId,
+ tags: tags
)
- try? env.drafts.write(
- scope: scope,
- draft: MemoDraft(
- draftKey: DraftRepository.memoKey(memo.id),
- title: title,
- contentMarkdown: contentMarkdown,
- contentJson: contentJSON,
- notebookId: notebookId,
- tagsText: tagsText,
- expectedRevision: rev,
- updatedAt: now
- )
+ )
+ try? env.drafts.write(
+ scope: scope,
+ draft: MemoDraft(
+ draftKey: isCreate ? DraftRepository.newKey : DraftRepository.memoKey(memo.id),
+ title: title,
+ contentMarkdown: contentMarkdown,
+ contentJson: contentJSON,
+ notebookId: notebookId,
+ tagsText: tagsText,
+ expectedRevision: rev,
+ updatedAt: now
)
- Task { await env.runSyncCycle() }
- }
+ )
+ NSLog(
+ "MemoEditView persist update memo=%@ mdLen=%d hasImg=%d jsonHasImg=%d",
+ memo.id,
+ contentMarkdown.count,
+ contentMarkdown.contains("/api/v1/resources/") ? 1 : 0,
+ contentJSON.contains("/api/v1/resources/") ? 1 : 0
+ )
+ Task { await env.runSyncCycle() }
}
private func commitCreate() async {
@@ -625,28 +762,291 @@ struct MemoEditView: View {
return memo.id
}
- private func insertImage(_ item: PhotosPickerItem) async {
+ /// Upload bytes from the system PHPicker and insert into TipTap.
+ private func insertImageData(_ data: Data, filename: String) async {
isUploading = true
+ error = nil
defer { isUploading = false }
do {
- guard let data = try await item.loadTransferable(type: Data.self) else { return }
+ NSLog("MemoEditView insertImageData: start bytes=%d name=%@", data.count, filename)
let compress = env.preferences.useCompression
let prepared = compress
? ImageCompressor.compressIfNeeded(data)
- : (data: data, mimeType: "image/jpeg", filename: "image.jpg")
+ : Self.preparedUpload(from: data, preferredName: filename)
+ NSLog(
+ "MemoEditView insertImageData: prepared bytes=%d mime=%@ file=%@",
+ prepared.data.count,
+ prepared.mimeType,
+ prepared.filename
+ )
let serverId = try await materializeForImage()
+ NSLog("MemoEditView insertImageData: memoId=%@", serverId)
let resource = try await env.session.client.uploadMemoResource(
memoId: serverId,
filename: prepared.filename,
mimeType: prepared.mimeType,
data: prepared.data
)
- contentMarkdown += "\n\n![](\(resource.url))\n"
- markDirtyAndScheduleSave()
- photoItem = nil
+ NSLog("MemoEditView insertImageData: uploaded resourceId=%@ url=%@", resource.id, resource.url)
+ // Prefer protected relative path so hydrate + menus work offline/online.
+ let imageSrc: String = {
+ if resource.url.contains("/api/v1/resources/") {
+ return ResourceCache.normalizeProtectedResourcePath(
+ resource.url,
+ baseURL: env.session.session.flatMap { URL(string: $0.baseUrl) }
+ )
+ }
+ return "/api/v1/resources/\(resource.id)/blob"
+ }()
+ // TipTap is JSON-driven: must insert via JS (markdown-only never re-renders).
+ // Seed blob cache + hydrate so file:// WebView can paint the protected src.
+ let inserted = await SharedTipTapRuntime.editor.insertImage(
+ src: imageSrc,
+ alt: prepared.filename,
+ displayData: prepared.data,
+ mimeType: prepared.mimeType
+ )
+ if !inserted {
+ throw APIError(
+ status: 0,
+ code: nil,
+ message: env.preferences.t(
+ "图片已上传,但插入编辑器失败,请重试。",
+ en: "Upload succeeded but insert into editor failed. Please try again."
+ )
+ )
+ }
+ // Snapshot TipTap state immediately — do not rely on async bridge onChange
+ // (it can arrive after our save, or markdown serializers may drop images).
+ await pullEditorSnapshotIfPossible()
+ ensureImageInContent(imageSrc: imageSrc, alt: prepared.filename)
+ isDirty = true
+ // Persist immediately so leaving the editor cannot orphan the resource.
+ saveTask?.cancel()
+ await persistDraftOrQueue()
+ await env.runSyncCycle()
+ NSLog(
+ "MemoEditView insertImageData: done src=%@ mdHas=%d jsonHas=%d",
+ imageSrc,
+ contentMarkdown.contains(imageSrc) ? 1 : 0,
+ contentJSON.contains(imageSrc) ? 1 : 0
+ )
} catch {
self.error = error.localizedDescription
+ showUploadError = true
+ NSLog("MemoEditView insertImageData failed: \(error)")
+ }
+ }
+
+ private static func protectedResourceRefs(in markdown: String) -> [String] {
+ guard let regex = try? NSRegularExpression(
+ pattern: #"/api/v1/resources/[A-Za-z0-9_-]+(?:/blob)?"#,
+ options: []
+ ) else { return [] }
+ let ns = markdown as NSString
+ let matches = regex.matches(in: markdown, options: [], range: NSRange(location: 0, length: ns.length))
+ var seen = Set<String>()
+ var refs: [String] = []
+ for match in matches {
+ let ref = ns.substring(with: match.range)
+ if seen.insert(ref).inserted {
+ refs.append(ref)
+ }
+ }
+ return refs
+ }
+
+ /// Guarantee markdown + TipTap JSON both reference the uploaded resource path.
+ private func ensureImageInContent(imageSrc: String, alt: String) {
+ if !contentMarkdown.contains(imageSrc) {
+ let block = contentMarkdown.hasSuffix("\n") || contentMarkdown.isEmpty
+ ? "![\(alt)](\(imageSrc))\n"
+ : "\n\n![\(alt)](\(imageSrc))\n"
+ contentMarkdown += block
+ }
+ if contentJSON.contains(imageSrc) { return }
+ // Inject an image node into the JSON doc when serializers/snapshot omitted it.
+ guard let data = contentJSON.data(using: .utf8),
+ var doc = try? JSONSerialization.jsonObject(with: data) as? [String: Any]
+ else {
+ contentJSON = """
+ {"type":"doc","content":[{"type":"paragraph"},{"type":"image","attrs":{"src":"\(imageSrc)","alt":"\(alt.replacingOccurrences(of: "\"", with: ""))"}},{"type":"paragraph"}]}
+ """
+ return
+ }
+ var content = doc["content"] as? [[String: Any]] ?? []
+ content.append([
+ "type": "image",
+ "attrs": [
+ "src": imageSrc,
+ "alt": alt,
+ ] as [String: Any],
+ ])
+ content.append(["type": "paragraph"] as [String: Any])
+ doc["type"] = doc["type"] ?? "doc"
+ doc["content"] = content
+ if let out = try? JSONSerialization.data(withJSONObject: doc),
+ let s = String(data: out, encoding: .utf8)
+ {
+ contentJSON = s
+ }
+ }
+
+ /// When compression is off, still normalize HEIC → JPEG for reliable upload mime.
+ private static func preparedUpload(
+ from data: Data,
+ preferredName: String
+ ) -> (data: Data, mimeType: String, filename: String) {
+ let normalized = ImagePickerData.normalize(data)
+ let mime = TipTapResourceLoader.sniffImageMime(normalized)
+ let resolvedMime = mime == "application/octet-stream" ? "image/jpeg" : mime
+ let ext: String
+ switch resolvedMime {
+ case "image/png": ext = "png"
+ case "image/gif": ext = "gif"
+ case "image/webp": ext = "webp"
+ default: ext = "jpg"
+ }
+ let base = (preferredName as NSString).deletingPathExtension
+ let name = base.isEmpty ? "image.\(ext)" : "\(base).\(ext)"
+ return (normalized, resolvedMime, name)
+ }
+}
+
+// MARK: - System PHPicker (reliable; PhotosPicker+Transferable was a silent no-op)
+
+private enum ImagePickerResult {
+ case cancelled
+ case failed(String)
+ case picked(Data, filename: String)
+}
+
+/// UIKit PHPicker wrapper — loads UIImage/data via NSItemProvider (not Transferable).
+private struct SystemImagePicker: UIViewControllerRepresentable {
+ var onFinish: (ImagePickerResult) -> Void
+
+ func makeUIViewController(context: Context) -> PHPickerViewController {
+ var config = PHPickerConfiguration(photoLibrary: .shared())
+ config.filter = .images
+ config.selectionLimit = 1
+ config.preferredAssetRepresentationMode = .current
+ let picker = PHPickerViewController(configuration: config)
+ picker.delegate = context.coordinator
+ return picker
+ }
+
+ func updateUIViewController(_ uiViewController: PHPickerViewController, context: Context) {}
+
+ func makeCoordinator() -> Coordinator {
+ Coordinator(onFinish: onFinish)
+ }
+
+ final class Coordinator: NSObject, PHPickerViewControllerDelegate {
+ let onFinish: (ImagePickerResult) -> Void
+ private var settled = false
+
+ init(onFinish: @escaping (ImagePickerResult) -> Void) {
+ self.onFinish = onFinish
+ }
+
+ func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) {
+ guard !settled else { return }
+ guard let provider = results.first?.itemProvider else {
+ settled = true
+ DispatchQueue.main.async { self.onFinish(.cancelled) }
+ return
+ }
+ Task {
+ do {
+ let (data, name) = try await Self.loadImage(from: provider)
+ await MainActor.run {
+ guard !self.settled else { return }
+ self.settled = true
+ self.onFinish(.picked(data, filename: name))
+ }
+ } catch {
+ await MainActor.run {
+ guard !self.settled else { return }
+ self.settled = true
+ self.onFinish(.failed(error.localizedDescription))
+ }
+ }
+ }
+ }
+
+ private static func loadImage(from provider: NSItemProvider) async throws -> (Data, String) {
+ // 1) UIImage path — most reliable for Photos library assets.
+ if provider.canLoadObject(ofClass: UIImage.self) {
+ let image = try await withCheckedThrowingContinuation { (cont: CheckedContinuation<UIImage, Error>) in
+ provider.loadObject(ofClass: UIImage.self) { object, error in
+ if let image = object as? UIImage {
+ cont.resume(returning: image)
+ } else {
+ cont.resume(
+ throwing: error
+ ?? APIError(status: 0, code: nil, message: "无法解码图片")
+ )
+ }
+ }
+ }
+ if let data = image.jpegData(compressionQuality: 0.92), !data.isEmpty {
+ return (data, "image.jpg")
+ }
+ }
+
+ // 2) Typed data representations.
+ let typeIds = [
+ UTType.jpeg.identifier,
+ UTType.png.identifier,
+ UTType.heic.identifier,
+ UTType.image.identifier,
+ ]
+ for typeId in typeIds where provider.hasItemConformingToTypeIdentifier(typeId) {
+ if let data = try? await loadData(provider, typeIdentifier: typeId), !data.isEmpty {
+ let normalized = ImagePickerData.normalize(data)
+ let mime = TipTapResourceLoader.sniffImageMime(normalized)
+ let ext = mime == "image/png" ? "png" : "jpg"
+ return (normalized, "image.\(ext)")
+ }
+ }
+
+ throw APIError(status: 0, code: nil, message: "无法读取所选图片,请换一张重试。")
+ }
+
+ private static func loadData(_ provider: NSItemProvider, typeIdentifier: String) async throws -> Data {
+ try await withCheckedThrowingContinuation { cont in
+ provider.loadDataRepresentation(forTypeIdentifier: typeIdentifier) { data, error in
+ if let data {
+ cont.resume(returning: data)
+ } else {
+ cont.resume(
+ throwing: error
+ ?? APIError(status: 0, code: nil, message: "读取图片数据失败")
+ )
+ }
+ }
+ }
+ }
+ }
+}
+
+enum ImagePickerData {
+ /// HEIC / unknown → JPEG so upload mime is valid and ImageCompressor can decode.
+ static func normalize(_ data: Data) -> Data {
+ if data.starts(with: [0xFF, 0xD8, 0xFF]) { return data } // JPEG
+ if data.starts(with: [0x89, 0x50, 0x4E, 0x47]) { return data } // PNG
+ if data.starts(with: [0x47, 0x49, 0x46, 0x38]) { return data } // GIF
+ if data.count >= 12 {
+ let riff = data.prefix(4)
+ let webp = data.dropFirst(8).prefix(4)
+ if riff.elementsEqual([0x52, 0x49, 0x46, 0x46]), webp.elementsEqual([0x57, 0x45, 0x42, 0x50]) {
+ return data
+ }
+ }
+ if let image = UIImage(data: data), let jpeg = image.jpegData(compressionQuality: 0.92) {
+ return jpeg
}
+ return data
}
}
diff --git a/apps/ios/EdgeEver/Resources/EditorBundle/index.html b/apps/ios/EdgeEver/Resources/EditorBundle/index.html
index f9c0ce64..c6ca1181 100644
--- a/apps/ios/EdgeEver/Resources/EditorBundle/index.html
+++ b/apps/ios/EdgeEver/Resources/EditorBundle/index.html
@@ -535,7 +535,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
`});Ju({type:"change",contentMarkdown:a,contentJson:n})}catch(n){Ju({type:"error",message:n instanceof Error?n.message:String(n)})}}function Y0e(t){if(JM.classList.toggle("editor-mode",t),JM.innerHTML="",!t)return;const e=[{id:"bold",label:"B",run:()=>Jr.chain().focus().toggleBold().run()},{id:"bullet",label:"•",run:()=>Jr.chain().focus().toggleBulletList().run()},{id:"quote",label:"❝",run:()=>Jr.chain().focus().toggleBlockquote().run()},{id:"hr",label:"—",run:()=>Jr.chain().focus().setHorizontalRule().run()},{id:"h2",label:"H2",run:()=>Jr.chain().focus().toggleHeading({level:2}).run()},{id:"code",label:"</>",run:()=>Jr.chain().focus().toggleCodeBlock().run()}];for(const r of e){const n=document.createElement("button");n.type="button",n.textContent=r.label,n.dataset.action=r.id,n.addEventListener("click",()=>{r.run(),Cp(Jr)}),JM.appendChild(n)}}async function sZ(t="light"){await bet(ql),al==="viewer"&&await xet(ql,t)}const wet={configure(t){const e=t.mode==="editor"?"editor":"viewer",r=e!==al;al=e,Jr.setEditable(al==="editor"),Y0e(al==="editor"),document.documentElement.dataset.theme=t.theme||"light",t.placeholder&&ql.setAttribute("data-placeholder",t.placeholder),al==="editor"&&r&&requestAnimationFrame(()=>{try{Jr.commands.focus("end")}catch{}})},setMarkdown(t){var e;XT=!0;try{Jr.commands.setContent(t||"",{contentType:"markdown"})}catch{try{const r=(e=Jr.storage.markdown)==null?void 0:e.manager;if(r)Jr.commands.setContent(r.parse(t||""));else throw new Error("no markdown manager")}catch{Jr.commands.setContent({type:"doc",content:[{type:"paragraph",content:t?[{type:"text",text:t}]:[]}]})}}Jr.setEditable(al==="editor"),XT=!1,sZ(document.documentElement.dataset.theme||"light")},setDocumentFromJSON(t){XT=!0;try{const e=JSON.parse(t);Jr.commands.setContent(e)}catch{Jr.commands.setContent({type:"doc",content:[{type:"paragraph"}]})}Jr.setEditable(al==="editor"),XT=!1,sZ(document.documentElement.dataset.theme||"light")},resolveResource(t,e){const r=zA.get(t);r&&(zA.delete(t),r(e))},getMarkdown(){var e,r;return((r=(e=Jr.storage.markdown)==null?void 0:e.getMarkdown)==null?void 0:r.call(e))??Jr.getText({blockSeparator:`
-`})},getDocument(){return JSON.stringify(Jr.getJSON())},focusEnd(){Jr.commands.focus("end")},flush(){Cp(Jr)},exec(t){var r;const e={bold:()=>Jr.chain().focus().toggleBold().run(),bulletList:()=>Jr.chain().focus().toggleBulletList().run(),blockquote:()=>Jr.chain().focus().toggleBlockquote().run(),horizontalRule:()=>Jr.chain().focus().setHorizontalRule().run(),heading2:()=>Jr.chain().focus().toggleHeading({level:2}).run(),codeBlock:()=>Jr.chain().focus().toggleCodeBlock().run()};(r=e[t])==null||r.call(e),Cp(Jr)},beginImageUpload(t,e){Jr.chain().focus().setImage({src:e,alt:t}).run();const r=ql.querySelectorAll("img"),n=r[r.length-1];n&&(n.dataset.uploadId=t),Cp(Jr)},completeImageUpload(t,e,r){const n=ql.querySelector(`img[data-upload-id="${t}"]`);n?(n.setAttribute("src",e),n.dataset.originalSrc=e,r&&n.setAttribute("alt",r),delete n.dataset.uploadId):Jr.chain().focus().setImage({src:e,alt:r}).run(),Cp(Jr)},cancelImageUpload(t){const e=ql.querySelector(`img[data-upload-id="${t}"]`);e==null||e.remove(),Cp(Jr)}};window.EdgeEverEditor=wet;Y0e(!1);Ju({type:"ready",startupMs:Math.round(performance.now()-get)});class _t 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,_t.prototype),this.position=i,i!=null&&a!=null&&(this.length=a-i),this.rawMessage=e}}var Cet=/([A-Z])/g,ket=t=>t.replace(Cet,"-$1").toLowerCase(),Eet={"&":"&amp;",">":"&gt;","<":"&lt;",'"':"&quot;","'":"&#x27;"},Aet=/[&><"']/g,ds=t=>String(t).replace(Aet,e=>Eet[e]),J4=t=>t.type==="ordgroup"||t.type==="color"?t.body.length===1?J4(t.body[0]):t:t.type==="font"?J4(t.body):t,_et=new Set(["mathord","textord","atom"]),Ph=t=>_et.has(J4(t).type),Ret=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"},VA={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 Let(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 Met(t){if(t.default!==void 0)return t.default;var e=Array.isArray(t.type)?t.type[0]:t.type;return Let(e)}function Iet(t,e,r,n){var i=r[e];t[e]=i!==void 0?n.processor?n.processor(i):i:Met(n)}class NV{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(VA)){var n=VA[r];n&&Iet(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 _t("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=Ret(e.url);if(r==null)return!1;e.protocol=r}var n=typeof this.trust=="function"?this.trust(e):this.trust;return!!n}}class td{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 Dc[Net[this.id]]}sub(){return Dc[Det[this.id]]}fracNum(){return Dc[Oet[this.id]]}fracDen(){return Dc[$et[this.id]]}cramp(){return Dc[Pet[this.id]]}text(){return Dc[Bet[this.id]]}isTight(){return this.size>=2}}var DV=0,GA=1,dy=2,hh=3,GC=4,dl=5,Mb=6,$s=7,Dc=[new td(DV,0,!1),new td(GA,0,!0),new td(dy,1,!1),new td(hh,1,!0),new td(GC,2,!1),new td(dl,2,!0),new td(Mb,3,!1),new td($s,3,!0)],Net=[GC,dl,GC,dl,Mb,$s,Mb,$s],Det=[dl,dl,dl,dl,$s,$s,$s,$s],Oet=[dy,hh,GC,dl,Mb,$s,Mb,$s],$et=[hh,hh,dl,dl,$s,$s,$s,$s],Pet=[GA,GA,hh,hh,dl,dl,$s,$s],Bet=[DV,GA,dy,hh,dy,hh,dy,hh],Ir={DISPLAY:Dc[DV],TEXT:Dc[dy],SCRIPT:Dc[GC],SCRIPTSCRIPT:Dc[Mb]},UO=[{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 Fet(t){for(var e=0;e<UO.length;e++)for(var r=UO[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 e3=[];UO.forEach(t=>t.blocks.forEach(e=>e3.push(...e)));function X0e(t){for(var e=0;e<e3.length;e+=2)if(t>=e3[e]&&t<=e3[e+1])return!0;return!1}var ta=t=>t+" "+t,qg=80,zet=function(e,r){return"M95,"+(622+e+r)+`
+`})},getDocument(){return JSON.stringify(Jr.getJSON())},focusEnd(){Jr.commands.focus("end")},flush(){Cp(Jr)},exec(t){var r;const e={bold:()=>Jr.chain().focus().toggleBold().run(),bulletList:()=>Jr.chain().focus().toggleBulletList().run(),blockquote:()=>Jr.chain().focus().toggleBlockquote().run(),horizontalRule:()=>Jr.chain().focus().setHorizontalRule().run(),heading2:()=>Jr.chain().focus().toggleHeading({level:2}).run(),codeBlock:()=>Jr.chain().focus().toggleCodeBlock().run()};(r=e[t])==null||r.call(e),Cp(Jr)},beginImageUpload(t,e){Jr.chain().focus().setImage({src:e,alt:t}).run();const r=ql.querySelectorAll("img"),n=r[r.length-1];n&&(n.dataset.uploadId=t),Cp(Jr)},completeImageUpload(t,e,r){Jr.chain().focus().setImage({src:e,alt:r||t||""}).run();const n=ql.querySelectorAll("img"),i=n[n.length-1];i&&(i.dataset.originalSrc=e,delete i.dataset.uploadId),Cp(Jr)},cancelImageUpload(t){const e=ql.querySelector(`img[data-upload-id="${t}"]`);e==null||e.remove(),Cp(Jr)}};window.EdgeEverEditor=wet;Y0e(!1);Ju({type:"ready",startupMs:Math.round(performance.now()-get)});class _t 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,_t.prototype),this.position=i,i!=null&&a!=null&&(this.length=a-i),this.rawMessage=e}}var Cet=/([A-Z])/g,ket=t=>t.replace(Cet,"-$1").toLowerCase(),Eet={"&":"&amp;",">":"&gt;","<":"&lt;",'"':"&quot;","'":"&#x27;"},Aet=/[&><"']/g,ds=t=>String(t).replace(Aet,e=>Eet[e]),J4=t=>t.type==="ordgroup"||t.type==="color"?t.body.length===1?J4(t.body[0]):t:t.type==="font"?J4(t.body):t,_et=new Set(["mathord","textord","atom"]),Ph=t=>_et.has(J4(t).type),Ret=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"},VA={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 Let(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 Met(t){if(t.default!==void 0)return t.default;var e=Array.isArray(t.type)?t.type[0]:t.type;return Let(e)}function Iet(t,e,r,n){var i=r[e];t[e]=i!==void 0?n.processor?n.processor(i):i:Met(n)}class NV{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(VA)){var n=VA[r];n&&Iet(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 _t("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=Ret(e.url);if(r==null)return!1;e.protocol=r}var n=typeof this.trust=="function"?this.trust(e):this.trust;return!!n}}class td{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 Dc[Net[this.id]]}sub(){return Dc[Det[this.id]]}fracNum(){return Dc[Oet[this.id]]}fracDen(){return Dc[$et[this.id]]}cramp(){return Dc[Pet[this.id]]}text(){return Dc[Bet[this.id]]}isTight(){return this.size>=2}}var DV=0,GA=1,dy=2,hh=3,GC=4,dl=5,Mb=6,$s=7,Dc=[new td(DV,0,!1),new td(GA,0,!0),new td(dy,1,!1),new td(hh,1,!0),new td(GC,2,!1),new td(dl,2,!0),new td(Mb,3,!1),new td($s,3,!0)],Net=[GC,dl,GC,dl,Mb,$s,Mb,$s],Det=[dl,dl,dl,dl,$s,$s,$s,$s],Oet=[dy,hh,GC,dl,Mb,$s,Mb,$s],$et=[hh,hh,dl,dl,$s,$s,$s,$s],Pet=[GA,GA,hh,hh,dl,dl,$s,$s],Bet=[DV,GA,dy,hh,dy,hh,dy,hh],Ir={DISPLAY:Dc[DV],TEXT:Dc[dy],SCRIPT:Dc[GC],SCRIPTSCRIPT:Dc[Mb]},UO=[{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 Fet(t){for(var e=0;e<UO.length;e++)for(var r=UO[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 e3=[];UO.forEach(t=>t.blocks.forEach(e=>e3.push(...e)));function X0e(t){for(var e=0;e<e3.length;e+=2)if(t>=e3[e]&&t<=e3[e+1])return!0;return!1}var ta=t=>t+" "+t,qg=80,zet=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 f9c0ce64..c6ca1181 100644
--- a/apps/ios/EditorBundle/index.html
+++ b/apps/ios/EditorBundle/index.html
@@ -535,7 +535,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
`});Ju({type:"change",contentMarkdown:a,contentJson:n})}catch(n){Ju({type:"error",message:n instanceof Error?n.message:String(n)})}}function Y0e(t){if(JM.classList.toggle("editor-mode",t),JM.innerHTML="",!t)return;const e=[{id:"bold",label:"B",run:()=>Jr.chain().focus().toggleBold().run()},{id:"bullet",label:"•",run:()=>Jr.chain().focus().toggleBulletList().run()},{id:"quote",label:"❝",run:()=>Jr.chain().focus().toggleBlockquote().run()},{id:"hr",label:"—",run:()=>Jr.chain().focus().setHorizontalRule().run()},{id:"h2",label:"H2",run:()=>Jr.chain().focus().toggleHeading({level:2}).run()},{id:"code",label:"</>",run:()=>Jr.chain().focus().toggleCodeBlock().run()}];for(const r of e){const n=document.createElement("button");n.type="button",n.textContent=r.label,n.dataset.action=r.id,n.addEventListener("click",()=>{r.run(),Cp(Jr)}),JM.appendChild(n)}}async function sZ(t="light"){await bet(ql),al==="viewer"&&await xet(ql,t)}const wet={configure(t){const e=t.mode==="editor"?"editor":"viewer",r=e!==al;al=e,Jr.setEditable(al==="editor"),Y0e(al==="editor"),document.documentElement.dataset.theme=t.theme||"light",t.placeholder&&ql.setAttribute("data-placeholder",t.placeholder),al==="editor"&&r&&requestAnimationFrame(()=>{try{Jr.commands.focus("end")}catch{}})},setMarkdown(t){var e;XT=!0;try{Jr.commands.setContent(t||"",{contentType:"markdown"})}catch{try{const r=(e=Jr.storage.markdown)==null?void 0:e.manager;if(r)Jr.commands.setContent(r.parse(t||""));else throw new Error("no markdown manager")}catch{Jr.commands.setContent({type:"doc",content:[{type:"paragraph",content:t?[{type:"text",text:t}]:[]}]})}}Jr.setEditable(al==="editor"),XT=!1,sZ(document.documentElement.dataset.theme||"light")},setDocumentFromJSON(t){XT=!0;try{const e=JSON.parse(t);Jr.commands.setContent(e)}catch{Jr.commands.setContent({type:"doc",content:[{type:"paragraph"}]})}Jr.setEditable(al==="editor"),XT=!1,sZ(document.documentElement.dataset.theme||"light")},resolveResource(t,e){const r=zA.get(t);r&&(zA.delete(t),r(e))},getMarkdown(){var e,r;return((r=(e=Jr.storage.markdown)==null?void 0:e.getMarkdown)==null?void 0:r.call(e))??Jr.getText({blockSeparator:`
-`})},getDocument(){return JSON.stringify(Jr.getJSON())},focusEnd(){Jr.commands.focus("end")},flush(){Cp(Jr)},exec(t){var r;const e={bold:()=>Jr.chain().focus().toggleBold().run(),bulletList:()=>Jr.chain().focus().toggleBulletList().run(),blockquote:()=>Jr.chain().focus().toggleBlockquote().run(),horizontalRule:()=>Jr.chain().focus().setHorizontalRule().run(),heading2:()=>Jr.chain().focus().toggleHeading({level:2}).run(),codeBlock:()=>Jr.chain().focus().toggleCodeBlock().run()};(r=e[t])==null||r.call(e),Cp(Jr)},beginImageUpload(t,e){Jr.chain().focus().setImage({src:e,alt:t}).run();const r=ql.querySelectorAll("img"),n=r[r.length-1];n&&(n.dataset.uploadId=t),Cp(Jr)},completeImageUpload(t,e,r){const n=ql.querySelector(`img[data-upload-id="${t}"]`);n?(n.setAttribute("src",e),n.dataset.originalSrc=e,r&&n.setAttribute("alt",r),delete n.dataset.uploadId):Jr.chain().focus().setImage({src:e,alt:r}).run(),Cp(Jr)},cancelImageUpload(t){const e=ql.querySelector(`img[data-upload-id="${t}"]`);e==null||e.remove(),Cp(Jr)}};window.EdgeEverEditor=wet;Y0e(!1);Ju({type:"ready",startupMs:Math.round(performance.now()-get)});class _t 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,_t.prototype),this.position=i,i!=null&&a!=null&&(this.length=a-i),this.rawMessage=e}}var Cet=/([A-Z])/g,ket=t=>t.replace(Cet,"-$1").toLowerCase(),Eet={"&":"&amp;",">":"&gt;","<":"&lt;",'"':"&quot;","'":"&#x27;"},Aet=/[&><"']/g,ds=t=>String(t).replace(Aet,e=>Eet[e]),J4=t=>t.type==="ordgroup"||t.type==="color"?t.body.length===1?J4(t.body[0]):t:t.type==="font"?J4(t.body):t,_et=new Set(["mathord","textord","atom"]),Ph=t=>_et.has(J4(t).type),Ret=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"},VA={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 Let(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 Met(t){if(t.default!==void 0)return t.default;var e=Array.isArray(t.type)?t.type[0]:t.type;return Let(e)}function Iet(t,e,r,n){var i=r[e];t[e]=i!==void 0?n.processor?n.processor(i):i:Met(n)}class NV{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(VA)){var n=VA[r];n&&Iet(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 _t("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=Ret(e.url);if(r==null)return!1;e.protocol=r}var n=typeof this.trust=="function"?this.trust(e):this.trust;return!!n}}class td{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 Dc[Net[this.id]]}sub(){return Dc[Det[this.id]]}fracNum(){return Dc[Oet[this.id]]}fracDen(){return Dc[$et[this.id]]}cramp(){return Dc[Pet[this.id]]}text(){return Dc[Bet[this.id]]}isTight(){return this.size>=2}}var DV=0,GA=1,dy=2,hh=3,GC=4,dl=5,Mb=6,$s=7,Dc=[new td(DV,0,!1),new td(GA,0,!0),new td(dy,1,!1),new td(hh,1,!0),new td(GC,2,!1),new td(dl,2,!0),new td(Mb,3,!1),new td($s,3,!0)],Net=[GC,dl,GC,dl,Mb,$s,Mb,$s],Det=[dl,dl,dl,dl,$s,$s,$s,$s],Oet=[dy,hh,GC,dl,Mb,$s,Mb,$s],$et=[hh,hh,dl,dl,$s,$s,$s,$s],Pet=[GA,GA,hh,hh,dl,dl,$s,$s],Bet=[DV,GA,dy,hh,dy,hh,dy,hh],Ir={DISPLAY:Dc[DV],TEXT:Dc[dy],SCRIPT:Dc[GC],SCRIPTSCRIPT:Dc[Mb]},UO=[{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 Fet(t){for(var e=0;e<UO.length;e++)for(var r=UO[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 e3=[];UO.forEach(t=>t.blocks.forEach(e=>e3.push(...e)));function X0e(t){for(var e=0;e<e3.length;e+=2)if(t>=e3[e]&&t<=e3[e+1])return!0;return!1}var ta=t=>t+" "+t,qg=80,zet=function(e,r){return"M95,"+(622+e+r)+`
+`})},getDocument(){return JSON.stringify(Jr.getJSON())},focusEnd(){Jr.commands.focus("end")},flush(){Cp(Jr)},exec(t){var r;const e={bold:()=>Jr.chain().focus().toggleBold().run(),bulletList:()=>Jr.chain().focus().toggleBulletList().run(),blockquote:()=>Jr.chain().focus().toggleBlockquote().run(),horizontalRule:()=>Jr.chain().focus().setHorizontalRule().run(),heading2:()=>Jr.chain().focus().toggleHeading({level:2}).run(),codeBlock:()=>Jr.chain().focus().toggleCodeBlock().run()};(r=e[t])==null||r.call(e),Cp(Jr)},beginImageUpload(t,e){Jr.chain().focus().setImage({src:e,alt:t}).run();const r=ql.querySelectorAll("img"),n=r[r.length-1];n&&(n.dataset.uploadId=t),Cp(Jr)},completeImageUpload(t,e,r){Jr.chain().focus().setImage({src:e,alt:r||t||""}).run();const n=ql.querySelectorAll("img"),i=n[n.length-1];i&&(i.dataset.originalSrc=e,delete i.dataset.uploadId),Cp(Jr)},cancelImageUpload(t){const e=ql.querySelector(`img[data-upload-id="${t}"]`);e==null||e.remove(),Cp(Jr)}};window.EdgeEverEditor=wet;Y0e(!1);Ju({type:"ready",startupMs:Math.round(performance.now()-get)});class _t 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,_t.prototype),this.position=i,i!=null&&a!=null&&(this.length=a-i),this.rawMessage=e}}var Cet=/([A-Z])/g,ket=t=>t.replace(Cet,"-$1").toLowerCase(),Eet={"&":"&amp;",">":"&gt;","<":"&lt;",'"':"&quot;","'":"&#x27;"},Aet=/[&><"']/g,ds=t=>String(t).replace(Aet,e=>Eet[e]),J4=t=>t.type==="ordgroup"||t.type==="color"?t.body.length===1?J4(t.body[0]):t:t.type==="font"?J4(t.body):t,_et=new Set(["mathord","textord","atom"]),Ph=t=>_et.has(J4(t).type),Ret=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"},VA={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 Let(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 Met(t){if(t.default!==void 0)return t.default;var e=Array.isArray(t.type)?t.type[0]:t.type;return Let(e)}function Iet(t,e,r,n){var i=r[e];t[e]=i!==void 0?n.processor?n.processor(i):i:Met(n)}class NV{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(VA)){var n=VA[r];n&&Iet(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 _t("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=Ret(e.url);if(r==null)return!1;e.protocol=r}var n=typeof this.trust=="function"?this.trust(e):this.trust;return!!n}}class td{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 Dc[Net[this.id]]}sub(){return Dc[Det[this.id]]}fracNum(){return Dc[Oet[this.id]]}fracDen(){return Dc[$et[this.id]]}cramp(){return Dc[Pet[this.id]]}text(){return Dc[Bet[this.id]]}isTight(){return this.size>=2}}var DV=0,GA=1,dy=2,hh=3,GC=4,dl=5,Mb=6,$s=7,Dc=[new td(DV,0,!1),new td(GA,0,!0),new td(dy,1,!1),new td(hh,1,!0),new td(GC,2,!1),new td(dl,2,!0),new td(Mb,3,!1),new td($s,3,!0)],Net=[GC,dl,GC,dl,Mb,$s,Mb,$s],Det=[dl,dl,dl,dl,$s,$s,$s,$s],Oet=[dy,hh,GC,dl,Mb,$s,Mb,$s],$et=[hh,hh,dl,dl,$s,$s,$s,$s],Pet=[GA,GA,hh,hh,dl,dl,$s,$s],Bet=[DV,GA,dy,hh,dy,hh,dy,hh],Ir={DISPLAY:Dc[DV],TEXT:Dc[dy],SCRIPT:Dc[GC],SCRIPTSCRIPT:Dc[Mb]},UO=[{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 Fet(t){for(var e=0;e<UO.length;e++)for(var r=UO[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 e3=[];UO.forEach(t=>t.blocks.forEach(e=>e3.push(...e)));function X0e(t){for(var e=0;e<e3.length;e+=2)if(t>=e3[e]&&t<=e3[e+1])return!0;return!1}var ta=t=>t+" "+t,qg=80,zet=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 04d76660..d09652f6 100644
--- a/apps/ios/EditorSource/src/main.ts
+++ b/apps/ios/EditorSource/src/main.ts
@@ -524,14 +524,18 @@ const api: EdgeEverEditorAPI = {
},
completeImageUpload(uploadId, imageUrl, alt) {
- const img = editorEl.querySelector(`img[data-upload-id="${uploadId}"]`) as HTMLImageElement | null;
- if (img) {
- img.setAttribute("src", imageUrl);
- img.dataset.originalSrc = imageUrl;
- if (alt) img.setAttribute("alt", alt);
- delete img.dataset.uploadId;
- } else {
- editor.chain().focus().setImage({ src: imageUrl, alt }).run();
+ // Always mutate ProseMirror via setImage — DOM-only attr writes do not persist.
+ // Native hydrate rewrites display src under file:// after emitChange.
+ editor
+ .chain()
+ .focus()
+ .setImage({ src: imageUrl, alt: alt || uploadId || "" })
+ .run();
+ const imgs = editorEl.querySelectorAll("img");
+ const last = imgs[imgs.length - 1] as HTMLImageElement | undefined;
+ if (last) {
+ last.dataset.originalSrc = imageUrl;
+ delete last.dataset.uploadId;
}
emitChange(editor);
},