Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
Render collaborator caret labels above tables on main (PRD-9444) (#6518)
Andrew Mikofalvydc5fcc3640e3
diff --git a/.changeset/prd-9444-caret-labels-in-tables.md b/.changeset/prd-9444-caret-labels-in-tables.mdnew file mode 100644index 000000000..7e185fbf8--- /dev/null+++ b/.changeset/prd-9444-caret-labels-in-tables.md@@ -0,0 +1,5 @@+---+"@inkeep/open-knowledge-app": patch+---++Collaborator name labels now show in full above the caret, including in a table's first row, under a frozen header row, and on the first line of a paragraph or heading.diff --git a/packages/app/src/editor/TiptapEditor.tsx b/packages/app/src/editor/TiptapEditor.tsxindex 8f7a6be8a..3a43c1253 100644--- a/packages/app/src/editor/TiptapEditor.tsx+++ b/packages/app/src/editor/TiptapEditor.tsx@@ -60,6 +60,7 @@ import { getAwarenessHeartbeat } from './awareness-heartbeat-runtime';import { buildAwarenessUser } from './awareness-user';import { bindingStalenessGuardPlugin, type WedgeDetail } from './binding-staleness-guard';import { BubbleMenuBar } from './bubble-menu/BubbleMenuBar';+import { attachCaretLabel, caretLabelLayerPlugin } from './caret-label-layer';import {createClipboardHtmlSerializer,createClipboardTextSerializer,@@ -118,7 +119,7 @@ function renderCursor(user: Record<string, string>): HTMLElement {label.style.backgroundColor = user.color;label.style.color = deriveIconColor(user.color);label.textContent = user.name;- cursor.append(label);+ attachCaretLabel(cursor, label);return cursor;}@@ -281,6 +282,7 @@ export function buildExtensionList(args: BuildEditorOptionsArgs): AnyExtension[]yCursorPlugin(awareness, {cursorBuilder: renderCursor,}),+ caretLabelLayerPlugin(),];},}),diff --git a/packages/app/src/editor/caret-label-layer.dom.test.ts b/packages/app/src/editor/caret-label-layer.dom.test.tsnew file mode 100644index 000000000..dd575e0a5--- /dev/null+++ b/packages/app/src/editor/caret-label-layer.dom.test.ts@@ -0,0 +1,165 @@+import { Schema } from '@tiptap/pm/model';+import { EditorState, Plugin, PluginKey } from '@tiptap/pm/state';+import { Decoration, DecorationSet, EditorView } from '@tiptap/pm/view';+import { afterEach, describe, expect, test, vi } from 'vitest';+import { attachCaretLabel, caretLabelLayerPlugin } from './caret-label-layer.ts';++const schema = new Schema({+ nodes: {+ doc: { content: 'paragraph+' },+ paragraph: { content: 'text*', toDOM: () => ['p', 0] },+ text: {},+ },+});++const remoteCaretKey = new PluginKey<number | null>('remoteCaret');++function remoteCaret(name: string): HTMLElement {+ const caret = document.createElement('span');+ caret.className = 'collaboration-cursor__caret';+ const label = document.createElement('div');+ label.className = 'collaboration-cursor__label';+ label.textContent = name;+ attachCaretLabel(caret, label);+ return caret;+}++function remoteCaretPlugin(): Plugin<number | null> {+ return new Plugin<number | null>({+ key: remoteCaretKey,+ state: {+ init: () => 1,+ apply: (tr, value) => {+ const next = tr.getMeta(remoteCaretKey) as number | null | undefined;+ return next === undefined ? value : next;+ },+ },+ props: {+ decorations(state) {+ const pos = remoteCaretKey.getState(state);+ if (pos == null) return DecorationSet.empty;+ return DecorationSet.create(state.doc, [+ Decoration.widget(pos, () => remoteCaret('Omar'), { key: `caret-${pos}` }),+ ]);+ },+ },+ });+}++function mountEditor(): { view: EditorView; host: HTMLElement } {+ const host = document.createElement('div');+ document.body.append(host);+ const doc = schema.node('doc', null, [+ schema.node('paragraph', null, [schema.text('Action Owner Admin')]),+ ]);+ const view = new EditorView(host, {+ state: EditorState.create({ doc, plugins: [remoteCaretPlugin(), caretLabelLayerPlugin()] }),+ });+ return { view, host };+}++function moveRemoteCaret(view: EditorView, pos: number | null): void {+ view.dispatch(view.state.tr.setMeta(remoteCaretKey, pos));+}++function stubResizeObserver(): (target: Element) => void {+ const observers: { callback: ResizeObserverCallback; targets: Set<Element> }[] = [];+ vi.stubGlobal(+ 'ResizeObserver',+ class {+ private readonly entry: { callback: ResizeObserverCallback; targets: Set<Element> };+ constructor(callback: ResizeObserverCallback) {+ this.entry = { callback, targets: new Set() };+ observers.push(this.entry);+ }+ observe(target: Element) {+ this.entry.targets.add(target);+ }+ unobserve(target: Element) {+ this.entry.targets.delete(target);+ }+ disconnect() {+ this.entry.targets.clear();+ }+ },+ );+ return (target) => {+ for (const { callback, targets } of observers) {+ if (targets.has(target)) callback([], {} as ResizeObserver);+ }+ };+}++function labels(): HTMLElement[] {+ return Array.from(document.querySelectorAll<HTMLElement>('.collaboration-cursor__label'));+}++describe('caret label layer', () => {+ afterEach(() => {+ vi.unstubAllGlobals();+ document.body.replaceChildren();+ });++ test('renders the label beside the document, never inside it', () => {+ const { view, host } = mountEditor();++ const [label] = labels();+ expect(label?.textContent).toBe('Omar');+ expect(view.dom.contains(label ?? null)).toBe(false);+ expect(label?.parentElement?.parentElement).toBe(host);+ expect(view.dom.querySelectorAll('.collaboration-cursor__caret')).toHaveLength(1);+ view.destroy();+ });++ test('keeps one label per live caret and drops it when the caret leaves', () => {+ const { view } = mountEditor();++ moveRemoteCaret(view, 7);+ expect(labels()).toHaveLength(1);++ moveRemoteCaret(view, null);+ expect(labels()).toHaveLength(0);+ view.destroy();+ });++ test('follows the document when it moves to a new parent, never entering the document', () => {+ const { view, host } = mountEditor();+ const nextHost = document.createElement('div');+ document.body.append(nextHost);++ nextHost.append(view.dom);+ moveRemoteCaret(view, 7);++ const layer = nextHost.querySelector('.collaboration-cursor__label-layer');+ expect(layer?.parentElement).toBe(nextHost);+ expect(host.querySelector('.collaboration-cursor__label-layer')).toBeNull();+ expect(view.dom.querySelector('.collaboration-cursor__label-layer')).toBeNull();+ expect(labels()).toHaveLength(1);+ view.destroy();+ });++ test('follows the document when it is re-attached without a transaction', () => {+ const resize = stubResizeObserver();+ const { view, host } = mountEditor();+ const nextHost = document.createElement('div');+ document.body.append(nextHost);++ nextHost.append(view.dom);+ resize(view.dom);++ expect(nextHost.querySelector('.collaboration-cursor__label-layer')?.parentElement).toBe(+ nextHost,+ );+ expect(host.querySelector('.collaboration-cursor__label-layer')).toBeNull();+ expect(labels()).toHaveLength(1);+ view.destroy();+ });++ test('removes the layer and its labels when the editor is destroyed', () => {+ const { view, host } = mountEditor();++ view.destroy();+ expect(labels()).toHaveLength(0);+ expect(host.querySelector('.collaboration-cursor__label-layer')).toBeNull();+ });+});diff --git a/packages/app/src/editor/caret-label-layer.ts b/packages/app/src/editor/caret-label-layer.tsnew file mode 100644index 000000000..b05bf37fc--- /dev/null+++ b/packages/app/src/editor/caret-label-layer.ts@@ -0,0 +1,120 @@+import { autoUpdate, computePosition, hide, offset, platform } from '@floating-ui/dom';+import { Plugin, PluginKey } from '@tiptap/pm/state';+import type { EditorView } from '@tiptap/pm/view';++const CARET_SELECTOR = '.collaboration-cursor__caret';+const LAYER_CLASS = 'collaboration-cursor__label-layer';++const caretLabels = new WeakMap<HTMLElement, HTMLElement>();++export function attachCaretLabel(caret: HTMLElement, label: HTMLElement): void {+ caretLabels.set(caret, label);+}++interface MountedLabel {+ label: HTMLElement;+ update: () => void;+ stop: () => void;+}++const physicalPlatform = { ...platform, isRTL: () => false };++function setLabelPlacement(label: HTMLElement, position: { x: number; y: number } | null): void {+ label.style.left = `${position?.x ?? 0}px`;+ label.style.top = `${position?.y ?? 0}px`;+ label.style.visibility = position ? '' : 'hidden';+}++function positionLabel(caret: HTMLElement, label: HTMLElement): void {+ void computePosition(caret, label, {+ strategy: 'absolute',+ platform: physicalPlatform,+ placement: 'top-start',+ middleware: [offset({ mainAxis: 2, crossAxis: -1 }), hide()],+ })+ .then(({ x, y, middlewareData }) => {+ setLabelPlacement(label, middlewareData.hide?.referenceHidden ? null : { x, y });+ })+ .catch((error: unknown) => {+ setLabelPlacement(label, null);+ console.warn('[caret-label-layer] computePosition failed; label hidden', error);+ });+}++function mountLabel(layer: HTMLElement, caret: HTMLElement, label: HTMLElement): MountedLabel {+ layer.append(label);+ const update = () => positionLabel(caret, label);+ const stopAutoUpdate = autoUpdate(caret, label, update);+ return {+ label,+ update,+ stop: () => {+ stopAutoUpdate();+ label.remove();+ },+ };+}++class CaretLabelLayerView {+ private readonly view: EditorView;+ private readonly layer: HTMLDivElement;+ private readonly mounted = new Map<HTMLElement, MountedLabel>();+ private readonly attachObserver: ResizeObserver | null;++ constructor(view: EditorView) {+ this.view = view;+ this.layer = document.createElement('div');+ this.layer.className = LAYER_CLASS;+ this.layer.setAttribute('aria-hidden', 'true');+ this.attachObserver =+ typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(() => this.reconcile());+ this.attachObserver?.observe(view.dom);+ this.reconcile();+ }++ update(): void {+ this.reconcile();+ }++ destroy(): void {+ this.attachObserver?.disconnect();+ for (const entry of this.mounted.values()) entry.stop();+ this.mounted.clear();+ this.layer.remove();+ }++ private placeLayerBesideDocument(): void {+ const parent = this.view.dom.parentElement;+ if (parent && this.layer.parentElement !== parent) parent.append(this.layer);+ }++ private reconcile(): void {+ this.placeLayerBesideDocument();+ const live = new Set<HTMLElement>();+ for (const caret of this.view.dom.querySelectorAll<HTMLElement>(CARET_SELECTOR)) {+ const label = caretLabels.get(caret);+ if (!label) continue;+ live.add(caret);+ const existing = this.mounted.get(caret);+ if (existing) {+ existing.update();+ continue;+ }+ this.mounted.set(caret, mountLabel(this.layer, caret, label));+ }+ for (const [caret, entry] of this.mounted) {+ if (live.has(caret)) continue;+ entry.stop();+ this.mounted.delete(caret);+ }+ }+}++const caretLabelLayerKey = new PluginKey('caretLabelLayer');++export function caretLabelLayerPlugin(): Plugin {+ return new Plugin({+ key: caretLabelLayerKey,+ view: (view) => new CaretLabelLayerView(view),+ });+}diff --git a/packages/app/src/globals.css b/packages/app/src/globals.cssindex c7ec3c32f..d9b7d95e0 100644--- a/packages/app/src/globals.css+++ b/packages/app/src/globals.css@@ -1055,10 +1055,17 @@ body[style*="pointer-events: none"] .corner-card-column .floating-card-surface {pointer-events: none;}+.collaboration-cursor__label-layer {+ position: absolute;+ inset: 0;+ pointer-events: none;+ z-index: 6;+}+.collaboration-cursor__label {position: absolute;- top: calc(-100% - 0.2em);- left: -1px;+ top: 0;+ left: 0;padding: 1.5px 6px;border-radius: 5px 5px 5px 0;font-family: var(--font-mono);diff --git a/packages/app/tests/stress/remote-caret-label-table.e2e.ts b/packages/app/tests/stress/remote-caret-label-table.e2e.tsnew file mode 100644index 000000000..48d89341d--- /dev/null+++ b/packages/app/tests/stress/remote-caret-label-table.e2e.ts@@ -0,0 +1,327 @@+import { randomUUID } from 'node:crypto';+import type { Page } from '@playwright/test';+import { expect, placeCaretAtEndOfText, test, waitForActiveProviderSynced } from './_helpers';++const ROLES_TABLE_MARKDOWN = `# Permissions++Who can do what in each workspace role.++## Workspace roles++| Action | Owner | Admin | Member |+|--------|-------|-------|--------|+| Invite people | yes | yes | no |+| Remove people | owner-only | admin-only | never |+| Create projects | yes | yes | sometimes |++Trailing paragraph after the table.++${Array.from({ length: 40 }, (_, i) => `Filler paragraph ${i + 1} so the document scrolls.`).join('\n\n')}+`;++interface LabelHit {+ labels: number;+ width: number;+ height: number;+ hitIsLabel: boolean;+ hitDescription: string;+ gapAboveCaret: number;+ offsetFromCaretLeft: number;+}++async function hitTestRemoteLabel(page: Page): Promise<LabelHit> {+ return page.evaluate(() => {+ const labels = Array.from(document.querySelectorAll('.collaboration-cursor__label')).filter(+ (label): label is HTMLElement =>+ label instanceof HTMLElement && label.getClientRects().length > 0,+ );+ const label = labels[0];+ const caret = document.querySelector('.ProseMirror .collaboration-cursor__caret');+ if (!label || !caret) {+ return {+ labels: labels.length,+ width: 0,+ height: 0,+ hitIsLabel: false,+ hitDescription: 'no label',+ gapAboveCaret: Number.NaN,+ offsetFromCaretLeft: Number.NaN,+ };+ }+ const rect = label.getBoundingClientRect();+ const caretRect = caret.getBoundingClientRect();+ const previous = label.style.pointerEvents;+ label.style.pointerEvents = 'auto';+ const hit = document.elementFromPoint(rect.left + rect.width / 2, rect.top + rect.height / 2);+ label.style.pointerEvents = previous;+ const hitDescription = hit+ ? `${hit.tagName.toLowerCase()}.${Array.from(hit.classList).join('.')}`+ : 'nothing';+ return {+ labels: labels.length,+ width: rect.width,+ height: rect.height,+ hitIsLabel: hit !== null && label.contains(hit),+ hitDescription,+ gapAboveCaret: caretRect.top - rect.bottom,+ offsetFromCaretLeft: caretRect.left - rect.left,+ };+ });+}++async function expectRemoteLabelOnTop(page: Page, cellText: string): Promise<void> {+ await expect+ .poll(async () => (await hitTestRemoteLabel(page)).labels, {+ message: `one rendered label for the remote caret after "${cellText}"`,+ })+ .toBe(1);+ await expect+ .poll(+ async () => {+ const hit = await hitTestRemoteLabel(page);+ return hit.hitIsLabel ? 'label' : hit.hitDescription;+ },+ { message: `the label for the caret after "${cellText}" is painted on top, unclipped` },+ )+ .toBe('label');+ await expect+ .poll(+ async () => {+ const hit = await hitTestRemoteLabel(page);+ return [Math.round(hit.gapAboveCaret), Math.round(hit.offsetFromCaretLeft)];+ },+ { message: `the label sits just above the caret after "${cellText}", flush with its line` },+ )+ .toEqual([2, 1]);+ const hit = await hitTestRemoteLabel(page);+ expect(hit.width).toBeGreaterThan(10);+ expect(hit.height).toBeGreaterThan(10);+}++async function labelCoveredByToolbar(page: Page): Promise<string> {+ return page.evaluate(() => {+ const label = Array.from(+ document.querySelectorAll<HTMLElement>('.collaboration-cursor__label'),+ ).find((element) => element.getClientRects().length > 0);+ const bar = Array.from(+ document.querySelectorAll<HTMLElement>('[data-testid="editor-toolbar"] > .bg-background'),+ ).find((element) => element.getClientRects().length > 0);+ if (!label || !bar) return `missing label=${Boolean(label)} toolbar=${Boolean(bar)}`;+ const rect = label.getBoundingClientRect();+ const x = rect.left + rect.width / 2;+ const y = rect.top + rect.height / 2;+ const barRect = bar.getBoundingClientRect();+ if (y < barRect.top || y > barRect.bottom) return `label centre ${y} outside toolbar band`;+ const previousLabel = label.style.pointerEvents;+ const previousBar = bar.style.pointerEvents;+ label.style.pointerEvents = 'auto';+ bar.style.pointerEvents = 'auto';+ const hit = document.elementFromPoint(x, y);+ label.style.pointerEvents = previousLabel;+ bar.style.pointerEvents = previousBar;+ if (hit !== null && label.contains(hit)) return 'label';+ if (hit !== null && bar.contains(hit)) return 'toolbar';+ return hit ? `${hit.tagName.toLowerCase()}.${Array.from(hit.classList).join('.')}` : 'nothing';+ });+}++async function placeCaretAtStartOfText(page: Page, text: string): Promise<void> {+ const end = (await placeCaretAtEndOfText(page, text)).pmCaret;+ await page.evaluate((start) => {+ window.__activeEditor?.chain().focus().setTextSelection({ from: start, to: start }).run();+ }, end - text.length);+}++async function remoteCaretLinePixels(page: Page): Promise<number> {+ const caret = await page.evaluate(() => {+ const element = document.querySelector<HTMLElement>(+ '.ProseMirror .collaboration-cursor__caret',+ );+ if (!element) return null;+ const rect = element.getBoundingClientRect();+ return {+ x: rect.left,+ y: rect.top,+ height: rect.height,+ color: getComputedStyle(element).borderLeftColor,+ };+ });+ if (!caret || caret.height < 4) return 0;+ const shot = await page.screenshot({+ clip: {+ x: Math.floor(caret.x) - 2,+ y: Math.floor(caret.y),+ width: 5,+ height: Math.floor(caret.height),+ },+ });+ return page.evaluate(+ async ({ png, color }) => {+ const image = new Image();+ image.src = `data:image/png;base64,${png}`;+ await image.decode();+ const canvas = document.createElement('canvas');+ canvas.width = image.width;+ canvas.height = image.height;+ const context = canvas.getContext('2d');+ if (!context) return 0;+ context.drawImage(image, 0, 0);+ const [r, g, b] = (color.match(/\d+/g) ?? []).map(Number);+ const { data } = context.getImageData(0, 0, canvas.width, canvas.height);+ let rows = 0;+ for (let y = 0; y < canvas.height; y++) {+ for (let x = 0; x < canvas.width; x++) {+ const i = (y * canvas.width + x) * 4;+ const close =+ Math.abs((data[i] ?? 0) - (r ?? 0)) < 40 &&+ Math.abs((data[i + 1] ?? 0) - (g ?? 0)) < 40 &&+ Math.abs((data[i + 2] ?? 0) - (b ?? 0)) < 40;+ if (close) {+ rows++;+ break;+ }+ }+ }+ return rows / canvas.height;+ },+ { png: shot.toString('base64'), color: caret.color },+ );+}++test('a remote caret and its label paint on top, unclipped, in table cells and on block edges', async ({+ page,+ api,+}) => {+ const docName = `test-remote-caret-label-table-${randomUUID().slice(0, 8)}`;+ await api.seedDocs([{ name: docName, markdown: ROLES_TABLE_MARKDOWN }]);++ const remoteTab = await page.context().newPage();+ await Promise.all([page.goto(`/#/${docName}`), remoteTab.goto(`/#/${docName}`)]);+ await Promise.all([waitForActiveProviderSynced(page), waitForActiveProviderSynced(remoteTab)]);+ await expect(page.locator('.ProseMirror table th').first()).toHaveText('Action');+ await expect.poll(() => remoteTab.evaluate(() => Boolean(window.__activeEditor))).toBe(true);++ await placeCaretAtEndOfText(remoteTab, 'Action');+ await expect(page.locator('.ProseMirror th .collaboration-cursor__caret')).toHaveCount(1);+ await expectRemoteLabelOnTop(page, 'Action');++ await placeCaretAtEndOfText(remoteTab, 'Invite people');+ await expect(page.locator('.ProseMirror td .collaboration-cursor__caret')).toHaveCount(1);+ await expectRemoteLabelOnTop(page, 'Invite people');++ await placeCaretAtEndOfText(remoteTab, 'owner-only');+ await expect(page.locator('.ProseMirror td .collaboration-cursor__caret')).toHaveCount(1);+ await expectRemoteLabelOnTop(page, 'owner-only');++ await placeCaretAtEndOfText(remoteTab, 'Who can do what');+ await expect(page.locator('.ProseMirror p .collaboration-cursor__caret')).toHaveCount(1);+ await expectRemoteLabelOnTop(page, 'Who can do what');++ await placeCaretAtStartOfText(remoteTab, 'Trailing paragraph');+ await expect(page.locator('.ProseMirror p .collaboration-cursor__caret')).toHaveCount(1);+ await expect+ .poll(() => remoteCaretLinePixels(page), {+ message: 'a remote caret at the start of a paragraph paints its line along its height',+ })+ .toBeGreaterThan(0.8);+ await expectRemoteLabelOnTop(page, 'the start of "Trailing paragraph"');++ await page.evaluate(() => {+ const caret = document.querySelector('.ProseMirror .collaboration-cursor__caret');+ const scroller = caret?.closest<HTMLElement>('[data-testid="editor-scroll-container"]');+ if (!caret || !scroller) throw new Error('caret or editor scroll container missing');+ scroller.scrollTop +=+ caret.getBoundingClientRect().top - scroller.getBoundingClientRect().top - 30;+ });+ await expect+ .poll(() => labelCoveredByToolbar(page), {+ message: 'a label whose caret sits under the editor toolbar stays beneath the toolbar',+ })+ .toBe('toolbar');+ await page.evaluate(() => {+ document.querySelector<HTMLElement>('[data-testid="editor-scroll-container"]')?.scrollTo(0, 0);+ });++ await page.evaluate(() => {+ document.documentElement.dir = 'rtl';+ });+ await placeCaretAtEndOfText(remoteTab, 'Invite people');+ await expect(page.locator('.ProseMirror td .collaboration-cursor__caret')).toHaveCount(1);+ await expectRemoteLabelOnTop(page, 'Invite people, in a right-to-left interface');++ await remoteTab.close();+});++const WIDE_TABLE_MARKDOWN = `# Quarterly metrics++| Metric | Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sep | Oct | Nov | Dec | Far right column |+|--------|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|------------------|+| Revenue | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | rightmost-value |++Paragraph after the wide table.+`;++test('a label whose caret is scrolled out of a wide table does not widen the document', async ({+ page,+ api,+}) => {+ const docName = `test-remote-caret-label-wide-${randomUUID().slice(0, 8)}`;+ await api.seedDocs([{ name: docName, markdown: WIDE_TABLE_MARKDOWN }]);++ const remoteTab = await page.context().newPage();+ await Promise.all([page.goto(`/#/${docName}`), remoteTab.goto(`/#/${docName}`)]);+ await Promise.all([waitForActiveProviderSynced(page), waitForActiveProviderSynced(remoteTab)]);+ await expect.poll(() => remoteTab.evaluate(() => Boolean(window.__activeEditor))).toBe(true);+ await expect.poll(() => page.evaluate(() => Boolean(window.__activeEditor))).toBe(true);++ const overflow = () =>+ page.evaluate(() => {+ const wrapper = Array.from(+ document.querySelectorAll<HTMLElement>('.ProseMirror .tableWrapper'),+ ).find((element) => element.getClientRects().length > 0);+ const scroller = wrapper?.closest<HTMLElement>('[data-testid="editor-scroll-container"]');+ if (!wrapper || !scroller)+ throw new Error('table wrapper or editor scroll container missing');+ return {+ tableScrolls: wrapper.scrollWidth > wrapper.clientWidth,+ documentExtraWidth: scroller.scrollWidth - scroller.clientWidth,+ };+ });+ await page.evaluate(() => {+ const editor = window.__activeEditor;+ if (!editor) throw new Error('no active editor');+ const { state } = editor;+ const tr = state.tr;+ state.doc.descendants((node, pos) => {+ const role = node.type.spec.tableRole;+ if (role === 'cell' || role === 'header_cell') {+ tr.setNodeMarkup(pos, undefined, { ...node.attrs, colwidth: [160] });+ }+ });+ editor.view.dispatch(tr);+ });+ await expect+ .poll(async () => (await overflow()).tableScrolls, {+ message: 'the table overflows its wrapper',+ })+ .toBe(true);+ const baseline = (await overflow()).documentExtraWidth;++ await placeCaretAtEndOfText(remoteTab, 'rightmost-value');+ await expect(page.locator('.ProseMirror td .collaboration-cursor__caret')).toHaveCount(1);+ await expect+ .poll(+ () =>+ page.evaluate(+ () =>+ document.querySelector<HTMLElement>('.collaboration-cursor__label')?.style.visibility,+ ),+ { message: 'the label of a caret scrolled out of the table is hidden' },+ )+ .toBe('hidden');+ expect((await overflow()).documentExtraWidth, 'the hidden label adds no horizontal scroll').toBe(+ baseline,+ );++ await remoteTab.close();+});