mirror of
https://github.com/outline/outline.git
synced 2026-11-29 00:29:36 +03:00
feat: Convert @ prefixed Markdown links to mentions on server writes (#13403)
* checkpoint * feat: Convert @ prefixed links to mentions on server Markdown writes A Markdown link preceded by "@" now becomes a mention when brought in through the documents API, MCP, or an import, so an exported mention survives a round trip instead of degrading to a plain link. The editor rule creates a generic mention carrying the href, and the type of resource it points at is resolved by the plugin that recognizes the URL through a new MentionProvider hook. Mentions of external resources also serialize to their real URL rather than a mention:// URI, so the reference resolves outside of Outline. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix: Escape values interpolated into rendered mention HTML markdown-it leaves markup in a link label intact when html is disabled, so the label and attributes are escaped before being written into the tag. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
1ed8ca2b78
commit
f49b047648
16 files changed
+464
-30
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import { Minute } from "@shared/utils/time";
|
||||
import { PluginManager, Hook } from "@server/utils/PluginManager";
|
||||
import config from "../plugin.json";
|
||||
import { GitLabUtils } from "../shared/GitLabUtils";
|
||||
import { GitLabIssueProvider } from "./GitLabIssueProvider";
|
||||
import router from "./api/gitlab";
|
||||
import { GitLab } from "./gitlab";
|
||||
@@ -20,6 +21,12 @@ PluginManager.add([
|
||||
type: Hook.UnfurlProvider,
|
||||
value: { unfurl: GitLab.unfurl, cacheExpiry: Minute.seconds },
|
||||
},
|
||||
{
|
||||
// Only the public host is recognized here, a self-hosted instance is not
|
||||
// known without the settings of a connected integration.
|
||||
type: Hook.MentionProvider,
|
||||
value: (url: URL) => GitLabUtils.mentionType(url),
|
||||
},
|
||||
{
|
||||
type: Hook.Task,
|
||||
value: GitLabWebhookTask,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import env from "@shared/env";
|
||||
import { integrationSettingsPath } from "@shared/utils/routeHelpers";
|
||||
import { UnfurlResourceType } from "@shared/types";
|
||||
import { MentionType, UnfurlResourceType } from "@shared/types";
|
||||
|
||||
export const GitLabOAuthNonceCookie = "gitlabOAuthNonce";
|
||||
|
||||
@@ -244,6 +244,32 @@ export class GitLabUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the type of mention a GitLab URL represents.
|
||||
*
|
||||
* @param url the URL to evaluate.
|
||||
* @param customUrl optional custom GitLab URL from integration settings.
|
||||
* @returns the mention type, or undefined if this is not a GitLab URL for a
|
||||
* resource that can be mentioned.
|
||||
*/
|
||||
public static mentionType(
|
||||
url: URL,
|
||||
customUrl?: string
|
||||
): MentionType | undefined {
|
||||
const parsed = this.parseUrl(url.toString(), customUrl);
|
||||
|
||||
switch (parsed?.type) {
|
||||
case UnfurlResourceType.PR:
|
||||
return MentionType.PullRequest;
|
||||
case UnfurlResourceType.Issue:
|
||||
return MentionType.Issue;
|
||||
case UnfurlResourceType.Project:
|
||||
return MentionType.Project;
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the first path segment is a known GitLab system path.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user