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
import { encodeCellMention } from '@macro-inc/spreadsheet/cell-mentions';
import { expect, it } from 'vitest';
import {
cellTextSelection,
readCellText,
setCellTextCursor,
writeCellText,
} from './cell-mention-dom';
it('edits mention tokens atomically and maps selection offsets to the canonical cell input', () => {
const root = document.createElement('div');
root.contentEditable = 'true';
document.body.append(root);
const token = encodeCellMention({
type: 'user',
userId: 'macro|[email protected]',
email: '[email protected]',
displayName: 'Alice',
});
const value = `Owner ${token} next`;
writeCellText(root, value);
expect(root.textContent).toBe('Owner @Alice next');
expect(root.querySelector('span')?.contentEditable).toBe('false');
setCellTextCursor(root, 6 + token.length);
expect(cellTextSelection(root)).toEqual({
start: 6 + token.length,
end: 6 + token.length,
});
expect(readCellText(root)).toBe(value);
writeCellText(root, '**literal** <script>unsafe</script>');
expect(root.querySelector('script')).toBeNull();
expect(root.textContent).toBe('**literal** <script>unsafe</script>');
root.remove();
});
it('labels date pills relative to today while keeping the stored instant', () => {
const root = document.createElement('div');
document.body.append(root);
const tomorrow = new Date();
tomorrow.setHours(0, 0, 0, 0);
tomorrow.setDate(tomorrow.getDate() + 1);
const token = encodeCellMention({
type: 'date',
date: tomorrow.toISOString(),
displayFormat: 'Next week',
});
writeCellText(root, `Due ${token}`);
expect(root.textContent).toBe('Due Tomorrow');
expect(root.querySelector('span')?.contentEditable).toBe('false');
expect(readCellText(root)).toBe(`Due ${token}`);
root.remove();
});