Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(calendar): open booking links in event descriptions as links (#9366)
Eric Hayes5b2a219c48fe
diff --git a/apps/web/src/features/calendar/utils/calendar-description.test.ts b/apps/web/src/features/calendar/utils/calendar-description.test.tsindex c3eaf03495..ed9cb29238 100644--- a/apps/web/src/features/calendar/utils/calendar-description.test.ts+++ b/apps/web/src/features/calendar/utils/calendar-description.test.ts@@ -172,6 +172,18 @@ describe('calendarDescriptionToEditorHtml', () => {).toEqual({ blockName: 'task', documentId: DOCUMENT_ID });expect(parseMacroAppLink('not a url')).toBeUndefined();});++ it('leaves app pages that are not entities as ordinary links', () => {+ const href = `https://macro.com/app/booking/${DOCUMENT_ID}#token`;+ expect(parseMacroAppLink(href)).toBeUndefined();+ const html = calendarDescriptionToEditorHtml(+ `<a href="${href}">Manage</a>`+ );+ const anchor = new DOMParser()+ .parseFromString(html, 'text/html')+ .body.querySelector('a');+ expect(anchor?.hasAttribute('data-document-mention')).toBe(false);+ });});describe('exportCalendarDescription', () => {diff --git a/apps/web/src/features/calendar/utils/calendar-description.ts b/apps/web/src/features/calendar/utils/calendar-description.tsindex 80cd612f71..504ccbdeb7 100644--- a/apps/web/src/features/calendar/utils/calendar-description.ts+++ b/apps/web/src/features/calendar/utils/calendar-description.ts@@ -1,3 +1,7 @@+import {+ BlockAliasRegistry,+ BlockRegistry,+} from '@app/lib/constants/block-registry';import { editorIsEmpty } from '@core/component/LexicalMarkdown/utils';import { convertBookingLinkMentionsToLinks } from '@core/component/LexicalMarkdown/utils/convertBookingLinkMentionsToLinks';import { convertDocumentMentionsToLinks } from '@core/component/LexicalMarkdown/utils/convertDocumentMentionsToLinks';@@ -18,7 +22,16 @@ function parseHtml(html: string): Document {const APP_LINK_PATTERN = /^\/app\/([a-z0-9_-]+)\/([A-Za-z0-9_-]+)\/?$/i;-/** Which Macro entity an `/app/<block>/<id>` link opens, if it is one. */+const BLOCK_NAMES: ReadonlySet<string> = new Set([+ ...BlockRegistry,+ ...BlockAliasRegistry,+]);++/**+ * Which Macro entity an `/app/<block>/<id>` link opens, if it is one. App pages+ * with the same shape that are not entities, such as `/app/booking/<id>`,+ * open as ordinary links.+ */export function parseMacroAppLink(href: string): { blockName: string; documentId: string } | undefined {@@ -35,7 +48,7 @@ export function parseMacroAppLink(]);if (!origins.has(url.origin)) return undefined;const match = APP_LINK_PATTERN.exec(url.pathname);- if (!match) return undefined;+ if (!match || !BLOCK_NAMES.has(match[1])) return undefined;return { blockName: match[1], documentId: match[2] };}