Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions devtools/visual-testing/packages/test-helpers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@
},
"devDependencies": {
"eslint_d": "^14.3.0"
},
"dependencies": {
"@superdoc-testing/harness": "workspace:*"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { defineStory } from '@superdoc-testing/helpers';

const WAIT_MS = 300;
const START_DOC = 'other/sd-1778-apply-font.docx';
const FONT_NAME = 'Courier New';

export default defineStory({
name: 'apply-font',
description: 'Select all content and apply the Courier New font.',
tickets: ['SD-1778'],
startDocument: START_DOC,
layout: true,
toolbar: 'full',
waitForFonts: true,

async run(_, helpers): Promise<void> {
const { selectAll, focus, executeCommand, waitForStable, milestone } = helpers;
await waitForStable(WAIT_MS);
await focus();

await selectAll();

await waitForStable(WAIT_MS);
await executeCommand('setFontFamily', FONT_NAME);
await waitForStable(WAIT_MS);
await milestone('font-applied', `Applied ${FONT_NAME} to document.`);
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ const makeSchema = () =>
instruction: { default: null },
},
},
bookmarkStart: {
inline: true,
group: 'inline',
content: 'inline*',
},
text: { group: 'inline' },
},
marks: {
Expand Down Expand Up @@ -210,6 +215,25 @@ describe('calculateInlineRunPropertiesPlugin', () => {
expect(paragraph.attrs.paragraphProperties).toEqual({ runProperties: { bold: true } });
});

it('treats the first run inside inline wrappers as the paragraph first run', () => {
const schema = makeSchema();
const doc = schema.node('doc', null, [
schema.node('paragraph', null, [
schema.node('bookmarkStart', null, [schema.node('run', null, schema.text('Wrapped'))]),
]),
]);
const state = createState(schema, doc);
const [wrappedRunPos] = runPositions(state.doc);
const from = wrappedRunPos + 1;
const to = wrappedRunPos + 3;

const tr = state.tr.addMark(from, to, schema.marks.bold.create());
const { state: nextState } = state.applyTransaction(tr);

const paragraph = nextState.doc.firstChild;
expect(paragraph.attrs.paragraphProperties).toEqual({ runProperties: { bold: true } });
});

it('does not update paragraph runProperties when a non-first run changes', () => {
const schema = makeSchema();
const doc = schema.node('doc', null, [
Expand Down