mirror of
https://github.com/outline/outline.git
synced 2026-11-25 07:04:37 +03:00
* feat: Display links as preview cards Adds a display attribute to mentions so a link can render either inline or as a card with image, title and description from its unfurl. Pasting a URL offers a "Card" option, and selecting a link mention shows a toolbar to switch between the two displays. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016MJXFgeTUqKhSTriUHfG3z * feat: Arrow key selection, full width and Return for link cards Cards fill the document width, hide the blank line below them, are selected by the up and down arrow keys like images, and Return on a selected card adds a paragraph below it. * feat: Display document and collection mentions as cards Document and collection mentions can be switched to a card from the selection toolbar. Document cards show the summary, collection and the first image larger than 100x100. Collection cards show the first line of the description. On public shares the preview image is signed, as the share page already signs the attachments of that document. Card images are hidden until they load and removed if they fail. * feat: Keep mention cards through Markdown The card display is written as the link title, so URLs are not changed. Document and collection cards are written as @ links to their id and parsed back into mentions. * refactor: Move mention cards to their own file Document cards show the collection after the title instead of below it. * fix: Address review feedback on mention cards - Include the share id in the document card unfurl URL for root shares. - Return on a card in a heading adds a paragraph. - URL cards keep their URL in Markdown, and the server does not narrow their type. - Unfurl results apply to the current node, not the node at first render. - Collection card descriptions stop at the first line break. * refactor: Reuse existing helpers for mention cards - Sign the preview image with TextHelper.attachmentsToSignedUrls. - Check document and collection ids with isUUID. - Return lines from getFirstText without changing an input array. * fix: Preserve JSON output for inline mentions * refactor: Centralize mention selection classes --------- Co-authored-by: Claude <noreply@anthropic.com>
174 lines
4.7 KiB
TypeScript
174 lines
4.7 KiB
TypeScript
/** The kinds of resource that a mention can refer to. */
|
|
export enum MentionType {
|
|
User = "user",
|
|
Document = "document",
|
|
Collection = "collection",
|
|
Group = "group",
|
|
Issue = "issue",
|
|
PullRequest = "pull_request",
|
|
Project = "project",
|
|
URL = "url",
|
|
Date = "date",
|
|
}
|
|
|
|
/** How a mention is presented in a document. */
|
|
export enum MentionDisplay {
|
|
/** Rendered inline with surrounding text. */
|
|
Inline = "inline",
|
|
/** Rendered as a preview card with image, title and description. */
|
|
Card = "card",
|
|
}
|
|
|
|
/** The kinds of resource that a link can unfurl to. */
|
|
export enum UnfurlResourceType {
|
|
URL = "url",
|
|
Mention = "mention",
|
|
Group = "group",
|
|
Document = "document",
|
|
Issue = "issue",
|
|
PR = "pull",
|
|
Project = "project",
|
|
}
|
|
|
|
/** The unfurl response shape for each resource type. */
|
|
export type UnfurlResponse = {
|
|
[UnfurlResourceType.URL]: {
|
|
/** The resource type */
|
|
type: UnfurlResourceType.URL;
|
|
/** URL pointing to the resource */
|
|
url: string;
|
|
/** A text title, describing the resource */
|
|
title: string;
|
|
/** A color representing the resource */
|
|
color?: string;
|
|
/** A brief description about the resource */
|
|
description: string;
|
|
/** A URL to a thumbnail image representing the resource */
|
|
thumbnailUrl: string;
|
|
/** A URL to a favicon representing the resource */
|
|
faviconUrl: string;
|
|
};
|
|
[UnfurlResourceType.Mention]: {
|
|
/** The resource type */
|
|
type: UnfurlResourceType.Mention;
|
|
/** Mentioned user's name */
|
|
name: string;
|
|
/** Mentioned user's email */
|
|
email: string | null;
|
|
/** Mentioned user's avatar URL */
|
|
avatarUrl: string | null;
|
|
/** Used to create mentioned user's avatar if no avatar URL provided */
|
|
color: string;
|
|
/** Mentioned user's recent activity */
|
|
lastActive: string;
|
|
};
|
|
[UnfurlResourceType.Group]: {
|
|
/** The resource type */
|
|
type: UnfurlResourceType.Group;
|
|
/** Group name */
|
|
name: string;
|
|
/** Group description */
|
|
description: string | null;
|
|
/** Number of members in the group */
|
|
memberCount: number;
|
|
/** Array of group members (limited to display count) */
|
|
users: Array<{
|
|
id: string;
|
|
name: string;
|
|
avatarUrl: string | null;
|
|
color: string;
|
|
}>;
|
|
};
|
|
[UnfurlResourceType.Document]: {
|
|
/** The resource type */
|
|
type: UnfurlResourceType.Document;
|
|
/** URL pointing to the resource */
|
|
url: string;
|
|
/** Document id */
|
|
id: string;
|
|
/** Document title */
|
|
title: string;
|
|
/** Document summary */
|
|
summary: string;
|
|
/** Source of an image from the document to use as a preview */
|
|
thumbnailUrl?: string;
|
|
/** Viewer's last activity on this document */
|
|
lastActivityByViewer?: string;
|
|
};
|
|
[UnfurlResourceType.Issue]: {
|
|
/** The resource type */
|
|
type: UnfurlResourceType.Issue;
|
|
/** Issue link */
|
|
url: string;
|
|
/** Issue identifier */
|
|
id: string;
|
|
/** Issue title */
|
|
title: string;
|
|
/** Issue description */
|
|
description: string | null;
|
|
/** Issue's author */
|
|
author: { name: string; avatarUrl: string };
|
|
/** Issue's labels */
|
|
labels: Array<{ name: string; color: string }>;
|
|
/** Issue's status */
|
|
state: {
|
|
type?: string;
|
|
name: string;
|
|
color: string;
|
|
completionPercentage?: number;
|
|
};
|
|
/** Issue's creation time */
|
|
createdAt: string;
|
|
};
|
|
[UnfurlResourceType.PR]: {
|
|
/** The resource type */
|
|
type: UnfurlResourceType.PR;
|
|
/** Pull Request link */
|
|
url: string;
|
|
/** Pull Request identifier */
|
|
id: string;
|
|
/** Pull Request title */
|
|
title: string;
|
|
/** Pull Request description */
|
|
description: string | null;
|
|
/** Pull Request author */
|
|
author: { name: string; avatarUrl: string };
|
|
/** Pull Request status */
|
|
state: { name: string; color: string; draft?: boolean };
|
|
/** Pull Request creation time */
|
|
createdAt: string;
|
|
};
|
|
[UnfurlResourceType.Project]: {
|
|
/** The resource type */
|
|
type: UnfurlResourceType.Project;
|
|
/** Project link */
|
|
url: string;
|
|
/** Project identifier */
|
|
id: string;
|
|
/** Project name */
|
|
name: string;
|
|
/** Project color */
|
|
color: string;
|
|
/** Project avatar URL */
|
|
avatarUrl?: string;
|
|
/** Project description */
|
|
description: string | null;
|
|
/** Project lead */
|
|
lead: { name: string; avatarUrl: string } | null;
|
|
/** Project state */
|
|
state: {
|
|
name: string;
|
|
color: string;
|
|
type: string;
|
|
};
|
|
/** Project labels */
|
|
labels: Array<{ name: string; color: string }>;
|
|
/** Project progress (0-1) */
|
|
progress?: number;
|
|
/** Project creation time */
|
|
createdAt: string;
|
|
/** Project target date */
|
|
targetDate: string | null;
|
|
};
|
|
};
|