Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(md): normalize triple click, normalize enter and headings (#5312)

Seamusbabf6d94e7de
diff --git a/apps/web/biome.jsonc b/apps/web/biome.jsonc
index da1fa53135..ab523b24f8 100644
--- a/apps/web/biome.jsonc
+++ b/apps/web/biome.jsonc
@@ -1,5 +1,5 @@
{
- "$schema": "https://biomejs.dev/schemas/2.4.12/schema.json",
+ "$schema": "https://biomejs.dev/schemas/2.5.6/schema.json",
"root": true,
"extends": ["../../biome.base.jsonc"],
"vcs": {
diff --git a/apps/web/src/features/entity/tests/buildEntityData.test.ts b/apps/web/src/features/entity/tests/buildEntityData.test.ts
index 15968b45c8..58b4a48641 100644
--- a/apps/web/src/features/entity/tests/buildEntityData.test.ts
+++ b/apps/web/src/features/entity/tests/buildEntityData.test.ts
@@ -196,23 +196,23 @@ describe('buildEntityData', () => {
] satisfies Array<{
status: CallStatus;
attended: boolean;
- }>)('builds a $status call with derived attendance', ({
- status,
- attended,
- }) => {
- expect(
- buildEntityData({
- ...base,
- blockName: 'call',
- channelId: 'c-1',
+ }>)(
+ 'builds a $status call with derived attendance',
+ ({ status, attended }) => {
+ expect(
+ buildEntityData({
+ ...base,
+ blockName: 'call',
+ channelId: 'c-1',
+ status,
+ })
+ ).toMatchObject({
+ type: 'call',
status,
- })
- ).toMatchObject({
- type: 'call',
- status,
- attended,
- });
- });
+ attended,
+ });
+ }
+ );
});
describe('csv alias', () => {
diff --git a/apps/web/src/features/settings/teamMemberPermissions.test.ts b/apps/web/src/features/settings/teamMemberPermissions.test.ts
index 5e9caca40e..9a24e2a31a 100644
--- a/apps/web/src/features/settings/teamMemberPermissions.test.ts
+++ b/apps/web/src/features/settings/teamMemberPermissions.test.ts
@@ -37,34 +37,39 @@ describe('canRemoveTeamMember', function () {
[TeamRole.admin, true],
[TeamRole.member, false],
[undefined, false],
- ])('allows the %s role to remove an ordinary member: %s', function (role, expected) {
- expect(canRemoveTeamMember(ACTING_USER_ID, role, ordinaryMember)).toBe(
- expected
- );
- });
+ ])(
+ 'allows the %s role to remove an ordinary member: %s',
+ function (role, expected) {
+ expect(canRemoveTeamMember(ACTING_USER_ID, role, ordinaryMember)).toBe(
+ expected
+ );
+ }
+ );
- it.each([
- TeamRole.owner,
- TeamRole.admin,
- ])('allows the %s role to remove a peer admin', function (role) {
- expect(canRemoveTeamMember(ACTING_USER_ID, role, peerAdmin)).toBe(true);
- });
+ it.each([TeamRole.owner, TeamRole.admin])(
+ 'allows the %s role to remove a peer admin',
+ function (role) {
+ expect(canRemoveTeamMember(ACTING_USER_ID, role, peerAdmin)).toBe(true);
+ }
+ );
- it.each([
- TeamRole.owner,
- TeamRole.admin,
- ])('prevents the %s role from removing themselves', function (role) {
- const actingMember = teamMember(ACTING_USER_ID, role);
+ it.each([TeamRole.owner, TeamRole.admin])(
+ 'prevents the %s role from removing themselves',
+ function (role) {
+ const actingMember = teamMember(ACTING_USER_ID, role);
- expect(canRemoveTeamMember(ACTING_USER_ID, role, actingMember)).toBe(false);
- });
+ expect(canRemoveTeamMember(ACTING_USER_ID, role, actingMember)).toBe(
+ false
+ );
+ }
+ );
- it.each([
- TeamRole.owner,
- TeamRole.admin,
- ])('prevents the %s role from removing the owner', function (role) {
- expect(canRemoveTeamMember(ACTING_USER_ID, role, owner)).toBe(false);
- });
+ it.each([TeamRole.owner, TeamRole.admin])(
+ 'prevents the %s role from removing the owner',
+ function (role) {
+ expect(canRemoveTeamMember(ACTING_USER_ID, role, owner)).toBe(false);
+ }
+ );
it('prevents removal when the acting user ID is unavailable', function () {
expect(canRemoveTeamMember(undefined, TeamRole.admin, ordinaryMember)).toBe(
diff --git a/apps/web/src/lib/analytics/planProperties.test.ts b/apps/web/src/lib/analytics/planProperties.test.ts
index 5c63dadf00..43eecf6e89 100644
--- a/apps/web/src/lib/analytics/planProperties.test.ts
+++ b/apps/web/src/lib/analytics/planProperties.test.ts
@@ -15,21 +15,19 @@ describe('getPlanAnalyticsProperties', () => {
});
});
- it.each([
- 'inactive',
- 'past_due',
- 'canceled',
- undefined,
- ])('%s does not grant premium access', (status) => {
- expect(getPlanAnalyticsProperties(status)).toEqual({
- person: {
- plan_tier: 'free',
- has_paid_access: false,
- },
- event: {
- plan_tier_at_event: 'free',
- has_paid_access_at_event: false,
- },
- });
- });
+ it.each(['inactive', 'past_due', 'canceled', undefined])(
+ '%s does not grant premium access',
+ (status) => {
+ expect(getPlanAnalyticsProperties(status)).toEqual({
+ person: {
+ plan_tier: 'free',
+ has_paid_access: false,
+ },
+ event: {
+ plan_tier_at_event: 'free',
+ has_paid_access_at_event: false,
+ },
+ });
+ }
+ );
});
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/find-and-replace/searchHighlight.tsx b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/find-and-replace/searchHighlight.tsx
index d67ff1c4ea..e5955b23bc 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/find-and-replace/searchHighlight.tsx
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/find-and-replace/searchHighlight.tsx
@@ -140,13 +140,9 @@ export function SearchHighlight({
return null;
}
-export function FloatingSearchHighlight({
- anchorElem = document.body,
-}: {
- anchorElem?: HTMLElement;
-}) {
+export function FloatingSearchHighlight(props: { anchorElem?: HTMLElement }) {
return (
- <Portal mount={anchorElem}>
+ <Portal mount={props.anchorElem}>
<For each={FindAndReplaceStore.get.styles}>
{(item) => (
<div
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/index.ts b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/index.ts
index 0bed59b6b0..c84401ad59 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/index.ts
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/index.ts
@@ -28,6 +28,7 @@ export * from './media';
export * from './mentions';
export * from './node-accessory';
export * from './node-transform';
+export * from './normalize-triple-click';
export * from './pinned-properties';
export * from './pluginManager';
export * from './popup';
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/normalize-enter/normalizeEnterPlugin.ts b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/normalize-enter/normalizeEnterPlugin.ts
index 97431c622e..e988d805de 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/normalize-enter/normalizeEnterPlugin.ts
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/normalize-enter/normalizeEnterPlugin.ts
@@ -18,6 +18,7 @@ import {
INSERT_PARAGRAPH_COMMAND,
KEY_ENTER_COMMAND,
type LexicalEditor,
+ type LexicalNode,
type RangeSelection,
} from 'lexical';
@@ -46,10 +47,18 @@ function $testSelectionPosition(
}
/**
- * Returns true if the selection is at the start of an empty paragraph or is
- * directly preceded by a line break.
+ * Returns true if the selection is at the start of an element that matches
+ * `isMatchingElement`, or is directly preceded by a line break.
+ *
+ * When `emptyOnly` is true (the default), the element must also be empty for
+ * this to return true. Pass `false` to match the start of the element
+ * regardless of whether it has content (e.g. Enter from the 0th char of a
+ * non-empty heading).
*/
-function $isAtStartOfEmptyParagraph(): boolean {
+function $isAtStartOfElement(
+ isMatchingElement: (node: LexicalNode | null) => boolean,
+ emptyOnly = true
+): boolean {
const selection = $getSelection();
if (!$isRangeSelection(selection) || !selection.isCollapsed()) {
return false;
@@ -72,15 +81,27 @@ function $isAtStartOfEmptyParagraph(): boolean {
return false;
}
- if ($isParagraphNode(parentElement)) {
- return isEmptyOrMatches(parentElement.getTextContent().trim(), /^$/);
+ if (isMatchingElement(parentElement)) {
+ return emptyOnly
+ ? isEmptyOrMatches(parentElement!.getTextContent().trim(), /^$/)
+ : true;
}
if ($isRootNode(parentElement)) {
- return isEmptyOrMatches(node.getTextContent().trim(), /^$/);
+ return emptyOnly
+ ? isEmptyOrMatches(node.getTextContent().trim(), /^$/)
+ : true;
}
return false;
}
+/**
+ * Returns true if the selection is at the start of an empty paragraph or is
+ * directly preceded by a line break.
+ */
+function $isAtStartOfEmptyParagraph(): boolean {
+ return $isAtStartOfElement($isParagraphNode);
+}
+
/**
* Normalize enter at start of block elements.
* QuoteNode - mirrors heading node behavior and notion.
@@ -96,7 +117,7 @@ function $handleEnterAtBlockStart(): boolean {
const rootParent = selectionNode.getTopLevelElement();
if (!rootParent) return false;
- if ($isQuoteNode(rootParent)) {
+ if ($isQuoteNode(rootParent) || $isHeadingNode(rootParent)) {
if (rootParent.getTextContent() === '') {
const paragraph = $createParagraphNode();
rootParent.replace(paragraph);
@@ -156,10 +177,25 @@ function $handleEnterFromHeading(): boolean {
const anchorBlock = selection.anchor.getNode().getTopLevelElement();
const focusBlock = selection.focus.getNode().getTopLevelElement();
+
+ // Return false if the anchor block is a heading with empty text to use default
+ // replace with paragraph behavior.
+ if ($isHeadingNode(anchorBlock) && anchorBlock.getTextContent() === '') {
+ return false;
+ }
+
if (!$isHeadingNode(anchorBlock) || anchorBlock !== focusBlock) {
return false;
}
+ // Enter from the very start of a non-empty heading: insert an empty
+ // paragraph above the heading instead of splitting it into a heading +
+ // paragraph. The heading and its content stay intact below.
+ if ($isAtStartOfElement($isHeadingNode, false)) {
+ anchorBlock.insertBefore($createParagraphNode());
+ return true;
+ }
+
const nextBlock = selection.insertParagraph();
if (!$isElementNode(nextBlock)) {
return false;
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/normalize-triple-click/index.ts b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/normalize-triple-click/index.ts
new file mode 100644
index 0000000000..aefe98958c
--- /dev/null
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/normalize-triple-click/index.ts
@@ -0,0 +1 @@
+export * from './normalizeTripleClickPlugin';
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/normalize-triple-click/normalizeTripleClickPlugin.test.ts b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/normalize-triple-click/normalizeTripleClickPlugin.test.ts
new file mode 100644
index 0000000000..d61e0ae342
--- /dev/null
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/normalize-triple-click/normalizeTripleClickPlugin.test.ts
@@ -0,0 +1,152 @@
+import {
+ $createHeadingNode,
+ $isHeadingNode,
+ HeadingNode,
+ QuoteNode,
+ registerRichText,
+} from '@lexical/rich-text';
+import {
+ $createParagraphNode,
+ $createRangeSelection,
+ $createTextNode,
+ $getRoot,
+ $getSelection,
+ $isParagraphNode,
+ $isRangeSelection,
+ $setSelection,
+ createEditor,
+ type LexicalEditor,
+ ParagraphNode,
+ TextNode,
+} from 'lexical';
+import { describe, expect, test } from 'vitest';
+import {
+ $fixFocusOverselection,
+ normalizeTripleClickPlugin,
+} from './normalizeTripleClickPlugin';
+
+function createTestEditor(): LexicalEditor {
+ const editor = createEditor({
+ namespace: 'normalize-triple-click-plugin-test',
+ nodes: [HeadingNode, ParagraphNode, QuoteNode, TextNode],
+ onError: (error) => {
+ throw error;
+ },
+ });
+
+ const root = document.createElement('div');
+ root.contentEditable = 'true';
+ document.body.appendChild(root);
+ editor.setRootElement(root);
+ registerRichText(editor);
+ normalizeTripleClickPlugin()(editor);
+
+ return editor;
+}
+
+/**
+ * Builds a heading followed by a paragraph and returns the keys of their text
+ * nodes. The nodes are committed in their own update so the DOM is reconciled
+ * before we manipulate the selection (mirroring a real triple-click, where the
+ * blocks already exist in the DOM).
+ */
+function seedHeadingAndParagraph(editor: LexicalEditor): {
+ headingTextKey: string;
+ paragraphTextKey: string;
+} {
+ let headingTextKey = '';
+ let paragraphTextKey = '';
+
+ editor.update(
+ () => {
+ const heading = $createHeadingNode('h1');
+ const headingText = $createTextNode('Header');
+ heading.append(headingText);
+ headingTextKey = headingText.getKey();
+
+ const paragraph = $createParagraphNode();
+ const paragraphText = $createTextNode('Paragraph');
+ paragraph.append(paragraphText);
+ paragraphTextKey = paragraphText.getKey();
+
+ $getRoot().clear().append(heading).append(paragraph);
+ },
+ { discrete: true }
+ );
+
+ return { headingTextKey, paragraphTextKey };
+}
+
+/**
+ * Simulate the browser triple-click over-selection: the selection covers the
+ * whole heading but the focus spills into offset 0 of the next block.
+ */
+function selectOverBlockBoundary(
+ headingTextKey: string,
+ paragraphTextKey: string
+): void {
+ const selection = $createRangeSelection();
+ selection.anchor.set(headingTextKey, 0, 'text');
+ selection.focus.set(paragraphTextKey, 0, 'text');
+ $setSelection(selection);
+}
+
+describe('normalizeTripleClickPlugin', () => {
+ test('pulls an over-selected focus back to the end of the selected block', () => {
+ const editor = createTestEditor();
+ const { headingTextKey, paragraphTextKey } =
+ seedHeadingAndParagraph(editor);
+
+ let focusKey = '';
+ let focusOffset = -1;
+
+ editor.update(
+ () => {
+ selectOverBlockBoundary(headingTextKey, paragraphTextKey);
+
+ $fixFocusOverselection();
+
+ const fixedSelection = $getSelection();
+ if (!$isRangeSelection(fixedSelection)) return;
+ focusKey = fixedSelection.focus.key;
+ focusOffset = fixedSelection.focus.offset;
+ },
+ { discrete: true }
+ );
+
+ // Focus should now land at the end of the heading text, not the start of
+ // the paragraph.
+ expect(focusKey).toBe(headingTextKey);
+ expect(focusOffset).toBe('Header'.length);
+ });
+
+ test('deleting a triple-selected heading does not restyle the paragraph below', () => {
+ const editor = createTestEditor();
+ const { headingTextKey, paragraphTextKey } =
+ seedHeadingAndParagraph(editor);
+
+ editor.update(
+ () => {
+ selectOverBlockBoundary(headingTextKey, paragraphTextKey);
+
+ $fixFocusOverselection();
+
+ const fixedSelection = $getSelection();
+ if (!$isRangeSelection(fixedSelection)) return;
+ fixedSelection.removeText();
+ },
+ { discrete: true }
+ );
+
+ editor.read(() => {
+ const paragraph = $getRoot()
+ .getChildren()
+ .find((node) => node.getTextContent() === 'Paragraph');
+ expect(paragraph).toBeDefined();
+ // The paragraph must remain a paragraph rather than inheriting the
+ // heading style from a block merge.
+ expect($isParagraphNode(paragraph)).toBe(true);
+ expect($isHeadingNode(paragraph)).toBe(false);
+ });
+ });
+});
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/normalize-triple-click/normalizeTripleClickPlugin.ts b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/normalize-triple-click/normalizeTripleClickPlugin.ts
new file mode 100644
index 0000000000..f0fe3cc02c
--- /dev/null
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/normalize-triple-click/normalizeTripleClickPlugin.ts
@@ -0,0 +1,177 @@
+import { mergeRegister } from '@lexical/utils';
+import {
+ $caretRangeFromSelection,
+ $getCaretRange,
+ $getCaretRangeInDirection,
+ $getChildCaret,
+ $getEditor,
+ $getPreviousSelection,
+ $getSelection,
+ $getSiblingCaret,
+ $isChildCaret,
+ $isElementNode,
+ $isLineBreakNode,
+ $isRangeSelection,
+ $isSiblingCaret,
+ $isTextPointCaret,
+ $normalizeCaret,
+ $rewindSiblingCaret,
+ $setSelectionFromCaretRange,
+ $updateDOMSelection,
+ COMMAND_PRIORITY_BEFORE_CRITICAL,
+ getDOMSelection,
+ type LexicalEditor,
+ SELECTION_CHANGE_COMMAND,
+ SKIP_SCROLL_INTO_VIEW_TAG,
+ SKIP_SELECTION_FOCUS_TAG,
+} from 'lexical';
+
+const SKIP_TAGS = new Set([
+ SKIP_SELECTION_FOCUS_TAG,
+ SKIP_SCROLL_INTO_VIEW_TAG,
+]);
+
+// Need a frame or two between the mouse events and the resulting
+// selectionchange for a triple click.
+const TRIPLE_CLICK_THRESHOLD_MS = 100;
+
+/**
+ * Triple-clicking a block causes the browser to expand the selection to cover
+ * the entire block, but it leaves the focus point at offset 0 of the *next*
+ * block. Visually it looks like a single block is selected, but the selection
+ * actually extends one position into the following block.
+ *
+ * Without correcting this, deleting a triple-selected node merges the
+ * heading with the node below it.
+ *
+ * This mirrors `NormalizeTripleClickSelectionExtension` from `@lexical/extension`,
+ * classic `registerRichText` used here does not. It moves the focus back so it
+ * prefers the end of a node over the start of its next sibling, and it does not
+ * skip over a `LineBreakNode`.
+ */
+export function $fixFocusOverselection(): void {
+ const selection = $getSelection();
+ if (!$isRangeSelection(selection) || selection.isCollapsed()) {
+ return;
+ }
+
+ const range = $getCaretRangeInDirection(
+ $caretRangeFromSelection(selection),
+ 'next'
+ );
+ let focusCaret = range.focus;
+
+ // Move it out of the next TextNode if none of it is selected.
+ if (
+ $isTextPointCaret(focusCaret) &&
+ range.anchor.origin !== focusCaret.origin &&
+ focusCaret.offset === 0
+ ) {
+ focusCaret = $rewindSiblingCaret(focusCaret.getSiblingCaret());
+ }
+ // Move it behind a single LineBreakNode.
+ if (
+ $isSiblingCaret(focusCaret) &&
+ range.anchor.origin !== focusCaret.origin &&
+ $isLineBreakNode(focusCaret.origin)
+ ) {
+ focusCaret = $rewindSiblingCaret(focusCaret);
+ }
+ // Move the focus out of the start of any elements.
+ while (
+ $isChildCaret(focusCaret) &&
+ range.anchor.origin !== focusCaret.origin
+ ) {
+ focusCaret = $rewindSiblingCaret(
+ $getSiblingCaret(focusCaret.origin, 'next')
+ );
+ }
+ // Move it inside the containing element.
+ if ($isSiblingCaret(focusCaret) && $isElementNode(focusCaret.origin)) {
+ focusCaret = $normalizeCaret(
+ $getChildCaret(focusCaret.origin, 'previous')
+ ).getFlipped();
+ }
+ focusCaret = $normalizeCaret(focusCaret);
+
+ if (focusCaret.isSamePointCaret(range.focus)) {
+ return;
+ }
+
+ const sel = $setSelectionFromCaretRange(
+ $getCaretRange(range.anchor, focusCaret)
+ );
+ const editor = $getEditor();
+ const rootElement = editor.getRootElement();
+ const domSelection =
+ rootElement && getDOMSelection(rootElement.ownerDocument.defaultView);
+ if (rootElement && domSelection) {
+ // Eagerly fix up the DOM selection to avoid a flash of over-selection.
+ $updateDOMSelection(
+ $getPreviousSelection(),
+ sel,
+ editor,
+ domSelection,
+ SKIP_TAGS,
+ rootElement
+ );
+ }
+}
+
+function registerNormalizeTripleClickPlugin(editor: LexicalEditor) {
+ return editor.registerRootListener((rootElement) => {
+ if (!rootElement) {
+ return;
+ }
+
+ let lastTripleClick = 0;
+ const refreshTripleClick = (event: MouseEvent | null): number => {
+ if (event ? event.detail === 3 : lastTripleClick > 0) {
+ const now = Date.now();
+ lastTripleClick =
+ (event && event.type === 'mousedown') ||
+ now - lastTripleClick <= TRIPLE_CLICK_THRESHOLD_MS
+ ? now
+ : 0;
+ }
+ return lastTripleClick;
+ };
+
+ const events: Array<keyof HTMLElementEventMap> = ['mouseup', 'mousedown'];
+ const listener = (event: Event) => refreshTripleClick(event as MouseEvent);
+
+ return mergeRegister(
+ editor.registerCommand(
+ SELECTION_CHANGE_COMMAND,
+ () => {
+ if (refreshTripleClick(null)) {
+ lastTripleClick = 0;
+ $fixFocusOverselection();
+ }
+ return false;
+ },
+ COMMAND_PRIORITY_BEFORE_CRITICAL
+ ),
+ (() => {
+ for (const eventName of events) {
+ rootElement.addEventListener(eventName, listener, true);
+ }
+ return () => {
+ for (const eventName of events) {
+ rootElement.removeEventListener(eventName, listener, true);
+ }
+ };
+ })()
+ );
+ });
+}
+
+/**
+ * Normalizes browser triple-click over-selection so that selecting a block and
+ * then deleting or reformatting it does not bleed into the following block.
+ */
+export function normalizeTripleClickPlugin() {
+ return (editor: LexicalEditor) => {
+ return registerNormalizeTripleClickPlugin(editor);
+ };
+}
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/pluginManager.ts b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/pluginManager.ts
index 86d336c691..7a765a6cfb 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/pluginManager.ts
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/pluginManager.ts
@@ -20,6 +20,7 @@ import { bindStateAs } from '../utils';
import { checklistPlugin } from './checklist/';
import { customDeletePlugin } from './custom-delete';
import { markdownShortcutsPlugin } from './markdown-shortcuts';
+import { normalizeTripleClickPlugin } from './normalize-triple-click';
export type PluginFunction = (editor: LexicalEditor) => () => void;
@@ -76,6 +77,10 @@ export function createPluginManager(editor: LexicalEditor, type: EditorType) {
richText() {
cleanupFunctions.push(registerRichText(editor));
+ // `registerRichText` (classic API) does not wire up triple-click
+ // selection normalization the way the newer RichTextExtension does, so
+ // register it explicitly here.
+ cleanupFunctions.push(normalizeTripleClickPlugin()(editor));
return pluginManager;
},
diff --git a/apps/web/src/lib/queries/channel/tests/channel-messages.test.ts b/apps/web/src/lib/queries/channel/tests/channel-messages.test.ts
index 4fb7729654..74d7d0fbd6 100644
--- a/apps/web/src/lib/queries/channel/tests/channel-messages.test.ts
+++ b/apps/web/src/lib/queries/channel/tests/channel-messages.test.ts
@@ -40,39 +40,42 @@ afterEach(() => {
});
describe('channelMessagesQueryOptions', () => {
- it.each([
- 'NOT_FOUND',
- 'GONE',
- ] as const)('throws missing load-around messages without retrying them for %s', async (code) => {
- mocks.getChannelMessages.mockResolvedValueOnce(
- resultErr([{ code, message: 'Message unavailable' }])
- );
+ it.each(['NOT_FOUND', 'GONE'] as const)(
+ 'throws missing load-around messages without retrying them for %s',
+ async (code) => {
+ mocks.getChannelMessages.mockResolvedValueOnce(
+ resultErr([{ code, message: 'Message unavailable' }])
+ );
- const options = channelMessagesQueryOptions('channel-1', 'message-missing');
+ const options = channelMessagesQueryOptions(
+ 'channel-1',
+ 'message-missing'
+ );
- let error: unknown;
- try {
- await options.queryFn({ pageParam: null });
- } catch (err) {
- error = err;
- }
+ let error: unknown;
+ try {
+ await options.queryFn({ pageParam: null });
+ } catch (err) {
+ error = err;
+ }
- if (!(error instanceof Error)) {
- throw new Error('Expected queryFn to throw an Error');
- }
+ if (!(error instanceof Error)) {
+ throw new Error('Expected queryFn to throw an Error');
+ }
- expect(error).toBeInstanceOf(ThrownResultError);
- expect(isMissingChannelMessageError(error)).toBe(true);
- expect(options.retry(0, error)).toBe(false);
- expect(mocks.getChannelMessages).toHaveBeenCalledTimes(1);
- expect(mocks.getChannelMessages).toHaveBeenCalledWith({
- channel_id: 'channel-1',
- limit: 50,
- next_cursor: null,
- previous_cursor: null,
- load_around_message_id: 'message-missing',
- });
- });
+ expect(error).toBeInstanceOf(ThrownResultError);
+ expect(isMissingChannelMessageError(error)).toBe(true);
+ expect(options.retry(0, error)).toBe(false);
+ expect(mocks.getChannelMessages).toHaveBeenCalledTimes(1);
+ expect(mocks.getChannelMessages).toHaveBeenCalledWith({
+ channel_id: 'channel-1',
+ limit: 50,
+ next_cursor: null,
+ previous_cursor: null,
+ load_around_message_id: 'message-missing',
+ });
+ }
+ );
it('preserves the default single retry for other errors', () => {
const options = channelMessagesQueryOptions('channel-1', null);
diff --git a/apps/web/src/lib/queries/soup/normalized-cache/operations.test.ts b/apps/web/src/lib/queries/soup/normalized-cache/operations.test.ts
index d423d6d9ee..948bc31509 100644
--- a/apps/web/src/lib/queries/soup/normalized-cache/operations.test.ts
+++ b/apps/web/src/lib/queries/soup/normalized-cache/operations.test.ts
@@ -229,33 +229,32 @@ describe('buildSingleEntityFilter', () => {
filterKey: 'call_filters',
idKey: 'call_ids',
},
- ])('unblocks only $entityType filter with the real entityId', ({
- entityType,
- filterKey,
- idKey,
- }) => {
- const filter = buildSingleEntityFilter(entityType, 'entity-1')!;
- expect(filter).not.toBeNull();
- expect(filter.limit).toBe(1);
-
- // The target filter uses the real entityId
- expect((filter as any)[filterKey][idKey]).toEqual(['entity-1']);
-
- // All other ID-based filters use NIL_ID
- const otherFilters = [
- 'document_filters',
- 'chat_filters',
- 'channel_filters',
- 'channel_thread_filters',
- 'project_filters',
- 'call_filters',
- ].filter((k) => k !== filterKey);
-
- for (const key of otherFilters) {
- const ids = Object.values((filter as any)[key])[0];
- expect(ids).toEqual([NIL_ID]);
+ ])(
+ 'unblocks only $entityType filter with the real entityId',
+ ({ entityType, filterKey, idKey }) => {
+ const filter = buildSingleEntityFilter(entityType, 'entity-1')!;
+ expect(filter).not.toBeNull();
+ expect(filter.limit).toBe(1);
+
+ // The target filter uses the real entityId
+ expect((filter as any)[filterKey][idKey]).toEqual(['entity-1']);
+
+ // All other ID-based filters use NIL_ID
+ const otherFilters = [
+ 'document_filters',
+ 'chat_filters',
+ 'channel_filters',
+ 'channel_thread_filters',
+ 'project_filters',
+ 'call_filters',
+ ].filter((k) => k !== filterKey);
+
+ for (const key of otherFilters) {
+ const ids = Object.values((filter as any)[key])[0];
+ expect(ids).toEqual([NIL_ID]);
+ }
}
- });
+ );
it('project filter defaults include_root to false', () => {
const filter = buildSingleEntityFilter('project', 'entity-1');