Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
fix(docs): inherit list marker font size (#7510)
Univerb1dc4c3d58af
diff --git a/packages/core/src/docs/data-model/text-x/build-utils/__tests__/paragraph.spec.ts b/packages/core/src/docs/data-model/text-x/build-utils/__tests__/paragraph.spec.tsindex b46f99497b..d6dce4d9c0 100644--- a/packages/core/src/docs/data-model/text-x/build-utils/__tests__/paragraph.spec.ts+++ b/packages/core/src/docs/data-model/text-x/build-utils/__tests__/paragraph.spec.ts@@ -196,8 +196,8 @@ describe('paragraph build utils', () => {expect(body.paragraphs?.[2].bullet).toMatchObject({listType: PresetListType.ORDER_LIST,nestingLevel: 0,- textStyle: { fs: 20 },});+ expect(body.paragraphs?.[2].bullet?.textStyle).toBeUndefined();const toggled = toggleChecklistParagraph({ paragraphIndex: secondParagraph.startIndex, document: doc });expect(toggleChecklistParagraph({ paragraphIndex: 999, document: doc })).toBe(false);diff --git a/packages/core/src/docs/data-model/text-x/build-utils/paragraph.ts b/packages/core/src/docs/data-model/text-x/build-utils/paragraph.tsindex c650d4dd35..7c7f80507b 100644--- a/packages/core/src/docs/data-model/text-x/build-utils/paragraph.ts+++ b/packages/core/src/docs/data-model/text-x/build-utils/paragraph.ts@@ -102,9 +102,6 @@ export const switchParagraphBullet = (params: ISwitchParagraphBulletParams) => {},bullet: {nestingLevel: bullet?.nestingLevel ?? 0,- textStyle: {- fs: 20,- },listType,listId,},@@ -224,11 +221,9 @@ export const setParagraphBullet = (params: ISetParagraphBulletParams) => {paragraphStyle,bullet: {nestingLevel: bullet?.nestingLevel ?? 0,- textStyle: bullet?.listType === listType- ? bullet.textStyle- : {- fs: 20,- },+ ...(bullet?.listType === listType && bullet.textStyle+ ? { textStyle: bullet.textStyle }+ : {}),listType,listId,},diff --git a/packages/docs-ui/src/commands/commands/__tests__/list.command.spec.ts b/packages/docs-ui/src/commands/commands/__tests__/list.command.spec.tsindex 99126e4322..1eceebaebe 100644--- a/packages/docs-ui/src/commands/commands/__tests__/list.command.spec.ts+++ b/packages/docs-ui/src/commands/commands/__tests__/list.command.spec.ts@@ -134,6 +134,21 @@ describe('list commands', () => {expect(paragraphs[0].bullet?.listId).toBe(paragraphs[1].bullet?.listId);});+ it.each([+ ['ordered', OrderListCommand.id, PresetListType.ORDER_LIST],+ ['unordered', BulletListCommand.id, PresetListType.BULLET_LIST],+ ['task', CheckListCommand.id, PresetListType.CHECK_LIST],+ ])('does not assign an absolute marker font size to %s lists', async (_label, commandId, listType) => {+ setSelections([{ startOffset: 0, endOffset: 4, collapsed: false }]);++ await commandService.executeCommand(commandId);+ await awaitTime(0);++ const bullet = getBody()?.paragraphs?.[0].bullet;+ expect(bullet?.listType).toBe(listType);+ expect(bullet?.textStyle?.fs).toBeUndefined();+ });+it('changes checklist type and nesting level on an existing list', async () => {setSelections([{ startOffset: 0, endOffset: 4, collapsed: false },@@ -177,6 +192,7 @@ describe('list commands', () => {expect(getBody()?.paragraphs?.[0].bullet?.listType).toBe(PresetListType.ORDER_LIST);expect(getBody()?.paragraphs?.[0].bullet?.nestingLevel).toBe(0);+ expect(getBody()?.paragraphs?.[0].bullet?.textStyle?.fs).toBeUndefined();expect(getBody()?.paragraphs?.[0].paragraphStyle?.textStyle).toMatchObject(PRESET_LIST_TYPE[PresetListType.ORDER_LIST].nestingLevel[0].paragraphProperties?.textStyle ?? {});diff --git a/packages/docs-ui/src/commands/commands/list.command.ts b/packages/docs-ui/src/commands/commands/list.command.tsindex eb3f69aab4..54b8df51b2 100644--- a/packages/docs-ui/src/commands/commands/list.command.ts+++ b/packages/docs-ui/src/commands/commands/list.command.ts@@ -466,9 +466,6 @@ export const QuickListCommand: ICommand<IQuickListCommandParams> = {bullet: {...(paragraph.bullet ?? {nestingLevel: 0,- textStyle: {- fs: 20,- },}),listType,listId,diff --git a/packages/engine-render/src/components/docs/layout/model/__tests__/glyph.spec.ts b/packages/engine-render/src/components/docs/layout/model/__tests__/glyph.spec.tsindex b245afddf6..d2ac9e8d42 100644--- a/packages/engine-render/src/components/docs/layout/model/__tests__/glyph.spec.ts+++ b/packages/engine-render/src/components/docs/layout/model/__tests__/glyph.spec.ts@@ -225,7 +225,7 @@ describe('Glyph utils test cases', () => {measureSpy.mockRestore();});- it('centers the custom checkbox shape on the measured marker metrics', () => {+ it('inherits the paragraph font size when centering the custom checkbox shape', () => {const measureSpy = vi.spyOn(FontCache, 'getTextSize').mockReturnValue({width: 16,ba: 18,@@ -247,12 +247,13 @@ describe('Glyph utils test cases', () => {{listId: 'check-list',symbol: '\u2610',- ts: { fs: 20 },+ ts: {},startIndexItem: 1,},10);+ expect(bulletGlyph.ts?.fs).toBe(20);expect(bulletGlyph.width).toBe(30);expect(bulletGlyph.bBox).toMatchObject({width: 24,