Open platform to collect and prioritize feedback
Added support for URL based images.
Matt Robertsed0314eb2ce9
diff --git a/public/components/common/form/CustomImage.ts b/public/components/common/form/CustomImage.tsindex d15532411..99916f0b5 100644--- a/public/components/common/form/CustomImage.ts+++ b/public/components/common/form/CustomImage.ts@@ -1,6 +1,7 @@import { ImageUpload } from "@fider/models"import Image from "@tiptap/extension-image"import * as MarkdownIt from "markdown-it"+import { defaultMarkdownSerializer } from "prosemirror-markdown"export interface CustomImageOptions {HTMLAttributes?: Record<string, any>@@ -59,6 +60,11 @@ export const CustomImage = Image.extend<CustomImageOptions>({images: {},markdown: {serialize: (state: any, node: any) => {+ if (!node.attrs.bkey && !node.attrs.id) {+ // Call the default image serializer+ return defaultMarkdownSerializer.nodes.image(state, node, node.parent, node.index)+ }+// When serializing to markdown, we use a special syntax: // Use bkey if available, otherwise fall back to idconst imageId = node.attrs.bkey || node.attrs.id || ""diff --git a/public/services/markdown.ts b/public/services/markdown.tsindex 92c186a1c..69dd87cd5 100644--- a/public/services/markdown.ts+++ b/public/services/markdown.ts@@ -40,13 +40,14 @@ const link = (href: string, title: string, text: string) => {}const fullRenderer = new marked.Renderer()+const originalImage = fullRenderer.image.bind(fullRenderer)fullRenderer.image = (href, title, alt) => {// Check if this is our special fider-image syntaxif (href && href.startsWith("fider-image:")) {const bkey = href.substring("fider-image:".length)return `<img src="/static/images/${bkey}" alt="${alt || ""}" class="fider-inline-image" data-bkey="${bkey}" />`}- return "" // Ignore other images+ return originalImage(href, title, alt)}fullRenderer.link = linkfullRenderer.text = (text: string) => {