mirror of
https://github.com/outline/outline.git
synced 2026-01-03 01:29:55 -06:00
26 lines
505 B
TypeScript
26 lines
505 B
TypeScript
import { Node } from "prosemirror-model";
|
|
import { parser } from "@server/editor";
|
|
|
|
export default function parseImages(text: string): string[] {
|
|
const doc = parser.parse(text);
|
|
const images: string[] = [];
|
|
|
|
doc.descendants((node: Node) => {
|
|
if (node.type.name === "image") {
|
|
if (!images.includes(node.attrs.src)) {
|
|
images.push(node.attrs.src);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
if (!node.content.size) {
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
});
|
|
|
|
return images;
|
|
}
|