Files
edentext/tests/unit/mark-order.test.ts
Steffen Becker 819f51587e fix: direct formatting on a run beats its named character style
A character style is a stylesheet rule, direct formatting an inline style on the
run's span. The charStyle mark ranked below TextStyle, so its span sat *inside*
and the rule won over the ancestor's inline style — a 9pt style silently undid a
run's own 10pt. Priority 102 lifts it above TextStyle's 101.

One fixture: 259 → 172 parity issues, lineEnd 49 → 7.
2026-08-10 18:08:13 +00:00

19 lines
911 B
TypeScript

import { describe, it, expect } from 'vitest';
import { getSchema, generateHTML } from '@tiptap/core';
import { extensions } from '../../src/lib/editor/extensions';
// A named character style renders as a stylesheet rule, direct formatting as an inline
// style — so the charStyle span has to sit outside, or the rule beats the ancestor.
describe('mark nesting', () => {
it('puts charStyle outside textStyle', () => {
const schema = getSchema(extensions);
expect(schema.marks.charStyle.rank).toBeLessThan(schema.marks.textStyle.rank);
const html = generateHTML({
type: 'doc',
content: [{ type: 'paragraph', content: [{ type: 'text', text: 'x',
marks: [{ type: 'textStyle', attrs: { fontSize: '10pt' } }, { type: 'charStyle', attrs: { name: 'Code' } }] }] }],
}, extensions);
expect(html.indexOf('data-char-style')).toBeLessThan(html.indexOf('font-size'));
});
});