mirror of
https://github.com/outline/outline.git
synced 2026-01-06 11:09:55 -06:00
21 lines
500 B
TypeScript
21 lines
500 B
TypeScript
import compact from "lodash/compact";
|
|
import uniq from "lodash/uniq";
|
|
import {
|
|
attachmentPublicRegex,
|
|
attachmentRedirectRegex,
|
|
} from "@shared/utils/ProsemirrorHelper";
|
|
|
|
export default function parseAttachmentIds(
|
|
text: string,
|
|
includePublic = false
|
|
): string[] {
|
|
return uniq(
|
|
compact(
|
|
[
|
|
...text.matchAll(attachmentRedirectRegex),
|
|
...(includePublic ? text.matchAll(attachmentPublicRegex) : []),
|
|
].map((match) => match.groups && match.groups.id)
|
|
)
|
|
);
|
|
}
|