Add in-app help, formula reference outlines, underline and auto-closing
- Help dialog (?, F1, Datei > Hilfe): user topics, all shortcuts and the formula functions with one search over everything. Topics and shortcuts are plain data in data/help.ts; the function list comes from codeReference.ts so new built-ins appear by themselves. - While a formula is edited, the grid outlines each referenced cell/range in the colour of its position in the text, and the outline can be dragged to move or resize the reference, as in Excel. Point-mode picks (click, drag, arrow keys) are outlined too, so keyboard picking is no longer blind. - Underline as a cell format, plus Mod+Shift+B/I/U toggles that switch on unless every selected cell already has the format. - A formula committed with open parentheses or an open text literal gets the missing closers appended; anything that still doesn't parse is left alone so the usual error shows instead of a guess. - Cells and tables with a fill but no text colour get dark or light text by WCAG contrast instead of the theme colour (no black on black).
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { dateToSerial, timeSerial } from '../../engine';
|
||||
import { formatValue } from '../format';
|
||||
import { formatValue, readableTextOn } from '../format';
|
||||
|
||||
describe('formatValue: date/time', () => {
|
||||
const day = dateToSerial(2026, 9, 2); // a Wednesday
|
||||
@@ -46,3 +46,23 @@ describe('formatValue: date/time', () => {
|
||||
expect(formatValue(day, 'plain', 'dateiso')).toBe('2026-09-02');
|
||||
});
|
||||
});
|
||||
|
||||
describe('readableTextOn', () => {
|
||||
it('light text on dark fills, dark text on light fills', () => {
|
||||
expect(readableTextOn('#000000')).toBe('#f5f5f7');
|
||||
expect(readableTextOn('#000')).toBe('#f5f5f7');
|
||||
expect(readableTextOn('#1b1b1b')).toBe('#f5f5f7');
|
||||
expect(readableTextOn('#0057ff')).toBe('#f5f5f7');
|
||||
expect(readableTextOn('#ffffff')).toBe('#1d1d1f');
|
||||
expect(readableTextOn('#ffd400')).toBe('#1d1d1f');
|
||||
expect(readableTextOn('#FFF')).toBe('#1d1d1f');
|
||||
});
|
||||
|
||||
it('ignores what it cannot read, and mostly transparent fills', () => {
|
||||
expect(readableTextOn(undefined)).toBeNull();
|
||||
expect(readableTextOn('red')).toBeNull();
|
||||
expect(readableTextOn('#12345')).toBeNull();
|
||||
expect(readableTextOn('#00000020')).toBeNull();
|
||||
expect(readableTextOn('#000000cc')).toBe('#f5f5f7');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user