Skip to content

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

Preserve images in mobile editor fallback

yomafc1d86038410
diff --git a/apps/web/public/mobile-edit.html b/apps/web/public/mobile-edit.html
index 781e1637..2f857cfa 100644
--- a/apps/web/public/mobile-edit.html
+++ b/apps/web/public/mobile-edit.html
@@ -211,11 +211,23 @@
const docToMarkdown = (doc) => {
if (!doc || !Array.isArray(doc.content)) return "";
return doc.content
- .map((node) => inlineText(node && node.content))
+ .map((node) => blockToMarkdown(node))
.filter(Boolean)
.join("\\n\\n");
};
+ const blockToMarkdown = (node) => {
+ if (!node || typeof node !== "object") return "";
+ if (node.type === "image") return imageToMarkdown(node.attrs);
+ if (node.type === "heading") {
+ const level = Math.min(Math.max(Number(node.attrs && node.attrs.level) || 1, 1), 6);
+ const text = inlineText(node.content);
+ return text ? `${"#".repeat(level)} ${text}` : "";
+ }
+ if (node.type === "horizontalRule") return "---";
+ return inlineText(node.content);
+ };
+
const inlineText = (content) => {
if (!Array.isArray(content)) return "";
return content
@@ -223,11 +235,26 @@
if (!node || typeof node !== "object") return "";
if (typeof node.text === "string") return node.text;
if (node.type === "hardBreak") return "\\n";
+ if (node.type === "image") return imageToMarkdown(node.attrs);
return inlineText(node.content);
})
.join("");
};
+ const imageToMarkdown = (attrs) => {
+ const src = stringAttr(attrs, "src");
+ if (!src) return "";
+ const alt = stringAttr(attrs, "alt").replace(/\]/g, "\\]");
+ const title = stringAttr(attrs, "title");
+ const titleSuffix = title ? ` "${title.replace(/"/g, '\\"')}"` : "";
+ return `![${alt}](${src}${titleSuffix})`;
+ };
+
+ const stringAttr = (attrs, key) => {
+ const value = attrs && attrs[key];
+ return typeof value === "string" ? value.trim() : "";
+ };
+
const parseTags = (value) =>
value
.split(/[,,]/)