Skip to content

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.

feat(docs): complete traditional document sections (#7324)

Univer70286a3cbd93
diff --git a/packages/core/src/types/interfaces/i-document-data.ts b/packages/core/src/types/interfaces/i-document-data.ts
index a946186fec..95ee126681 100644
--- a/packages/core/src/types/interfaces/i-document-data.ts
+++ b/packages/core/src/types/interfaces/i-document-data.ts
@@ -331,10 +331,14 @@ export enum BulletAlignment {
// }
export interface IMargin {
- marginTop?: number; // marginTop
- marginBottom?: number; // marginBottom
- marginRight?: number; // marginRight
- marginLeft?: number; // marginLeft
+ /** Top page margin in 96-DPI layout pixels. */
+ marginTop?: number;
+ /** Bottom page margin in 96-DPI layout pixels. */
+ marginBottom?: number;
+ /** Right page margin in 96-DPI layout pixels. */
+ marginRight?: number;
+ /** Left page margin in 96-DPI layout pixels. */
+ marginLeft?: number;
}
export interface ITableOfContent {}
@@ -413,6 +417,11 @@ export enum CustomRangeType {
DELTED = 9999,
}
+export enum DocxBreakType {
+ COLUMN = 'column',
+ TEXT_WRAPPING = 'textWrapping',
+}
+
/**
* Custom Block
*/
@@ -468,15 +477,16 @@ export enum DocumentFlavor {
*/
export interface IDocStyleBase extends IMargin {
pageNumberStart?: number; // pageNumberStart
- pageSize?: ISize; // pageSize
+ /** Page size in 96-DPI layout pixels. */
+ pageSize?: ISize;
pageOrient?: PageOrientType;
documentFlavor?: DocumentFlavor; // DocumentFlavor: TRADITIONAL, MODERN
- /** Distance from the page edge to the header, in points (pt). */
+ /** Distance from the page edge to the header, in 96-DPI layout pixels. */
marginHeader?: number;
- /** Distance from the page edge to the footer, in points (pt). */
+ /** Distance from the page edge to the footer, in 96-DPI layout pixels. */
marginFooter?: number;
renderConfig?: IDocumentRenderConfig;
@@ -572,9 +582,10 @@ export interface ISectionBreak extends IDocStyleBase, ISectionBreakBase, IHeader
export enum SectionType {
SECTION_TYPE_UNSPECIFIED, // The section type is unspecified.
CONTINUOUS, // The section starts immediately after the last paragraph of the previous section.
+ NEXT_COLUMN, // The section starts in the next column, or on the next page when no column remains.
NEXT_PAGE, // The section starts on the next page.
- EVEN_PAGE, // The section starts on the next page.
- ODD_PAGE, // The section starts on the next page.
+ EVEN_PAGE, // The section starts on the next even-numbered page.
+ ODD_PAGE, // The section starts on the next odd-numbered page.
}
/**
@@ -599,9 +610,9 @@ export enum TextDirectionType {
* Properties of section column
*/
export interface ISectionColumnProperties {
- /** Column width in points (pt). */
+ /** Column width in 96-DPI layout pixels. */
width: number;
- /** Trailing space after the column in points (pt). */
+ /** Trailing space after the column in 96-DPI layout pixels. */
paddingEnd: number;
}
diff --git a/packages/docs-drawing-ui/src/locale/ru-RU.ts b/packages/docs-drawing-ui/src/locale/ru-RU.ts
index 4968549f80..37f95e300e 100644
--- a/packages/docs-drawing-ui/src/locale/ru-RU.ts
+++ b/packages/docs-drawing-ui/src/locale/ru-RU.ts
@@ -24,9 +24,9 @@ const locale: typeof enUS = {
},
shape: {
insert: {
- title: 'Insert Shape',
- rectangle: 'Insert Rectangle',
- ellipse: 'Insert Ellipse',
+ title: 'Вставить фигуру',
+ rectangle: 'Вставить прямоугольник',
+ ellipse: 'Вставить эллипс',
},
},
panel: {
@@ -40,39 +40,39 @@ const locale: typeof enUS = {
reset: 'Сбросить размер',
},
'image-text-wrap': {
- title: 'Text Wrapping',
- wrappingStyle: 'Wrapping Style',
- square: 'Square',
- topAndBottom: 'Top and Bottom',
- inline: 'In line with text',
- behindText: 'Behind text',
- inFrontText: 'In front of text',
- wrapText: 'Wrap text',
- bothSide: 'Both sides',
- leftOnly: 'Left only',
- rightOnly: 'Right only',
- distanceFromText: 'Distance from text',
- top: 'Top(px)',
- left: 'Left(px)',
- bottom: 'Bottom(px)',
- right: 'Right(px)',
+ title: 'Обтекание текстом',
+ wrappingStyle: 'Стиль обтекания',
+ square: 'Квадрат',
+ topAndBottom: 'Сверху и снизу',
+ inline: 'В тексте',
+ behindText: 'За текстом',
+ inFrontText: 'Перед текстом',
+ wrapText: 'Обтекание текстом',
+ bothSide: 'С обеих сторон',
+ leftOnly: 'Только слева',
+ rightOnly: 'Только справа',
+ distanceFromText: 'Расстояние от текста',
+ top: 'Сверху (px)',
+ left: 'Слева (px)',
+ bottom: 'Снизу (px)',
+ right: 'Справа (px)',
},
'image-position': {
- title: 'Position',
- horizontal: 'Horizontal',
- vertical: 'Vertical',
- absolutePosition: 'Absolute Position(px)',
- relativePosition: 'Relative Position',
- toTheRightOf: 'to the right of',
- relativeTo: 'relative to',
- bellow: 'bellow',
- options: 'Options',
- moveObjectWithText: 'Move object with text',
- column: 'Column',
- margin: 'Margin',
- page: 'Page',
- line: 'Line',
- paragraph: 'Paragraph',
+ title: 'Положение',
+ horizontal: 'По горизонтали',
+ vertical: 'По вертикали',
+ absolutePosition: 'Абсолютное положение (px)',
+ relativePosition: 'Относительное положение',
+ toTheRightOf: 'справа от',
+ relativeTo: 'относительно',
+ bellow: 'снизу',
+ options: 'Параметры',
+ moveObjectWithText: 'Перемещать объект с текстом',
+ column: 'Колонка',
+ margin: 'Поле',
+ page: 'Страница',
+ line: 'Строка',
+ paragraph: 'Абзац',
},
'update-status': {
exceedMaxSize: 'Размер изображения превышает лимит, лимит составляет {0}М',
diff --git a/packages/docs-drawing-ui/src/locale/vi-VN.ts b/packages/docs-drawing-ui/src/locale/vi-VN.ts
index 32220d1443..1311318e0f 100644
--- a/packages/docs-drawing-ui/src/locale/vi-VN.ts
+++ b/packages/docs-drawing-ui/src/locale/vi-VN.ts
@@ -24,9 +24,9 @@ const locale: typeof enUS = {
},
shape: {
insert: {
- title: 'Insert Shape',
- rectangle: 'Insert Rectangle',
- ellipse: 'Insert Ellipse',
+ title: 'Chèn hình',
+ rectangle: 'Chèn hình chữ nhật',
+ ellipse: 'Chèn hình elip',
},
},
panel: {
@@ -40,39 +40,39 @@ const locale: typeof enUS = {
reset: 'Đặt lại kích thước',
},
'image-text-wrap': {
- title: 'Text Wrapping',
- wrappingStyle: 'Wrapping Style',
- square: 'Square',
- topAndBottom: 'Top and Bottom',
- inline: 'In line with text',
- behindText: 'Behind text',
- inFrontText: 'In front of text',
- wrapText: 'Wrap text',
- bothSide: 'Both sides',
- leftOnly: 'Left only',
- rightOnly: 'Right only',
- distanceFromText: 'Distance from text',
- top: 'Top(px)',
- left: 'Left(px)',
- bottom: 'Bottom(px)',
- right: 'Right(px)',
+ title: 'Bọc văn bản',
+ wrappingStyle: 'Kiểu bọc văn bản',
+ square: 'Hình vuông',
+ topAndBottom: 'Trên và dưới',
+ inline: 'Cùng dòng với văn bản',
+ behindText: 'Phía sau văn bản',
+ inFrontText: 'Phía trước văn bản',
+ wrapText: 'Bọc văn bản',
+ bothSide: 'Cả hai bên',
+ leftOnly: 'Chỉ bên trái',
+ rightOnly: 'Chỉ bên phải',
+ distanceFromText: 'Khoảng cách với văn bản',
+ top: 'Trên (px)',
+ left: 'Trái (px)',
+ bottom: 'Dưới (px)',
+ right: 'Phải (px)',
},
'image-position': {
- title: 'Position',
- horizontal: 'Horizontal',
- vertical: 'Vertical',
- absolutePosition: 'Absolute Position(px)',
- relativePosition: 'Relative Position',
- toTheRightOf: 'to the right of',
- relativeTo: 'relative to',
- bellow: 'bellow',
- options: 'Options',
- moveObjectWithText: 'Move object with text',
- column: 'Column',
- margin: 'Margin',
- page: 'Page',
- line: 'Line',
- paragraph: 'Paragraph',
+ title: 'Vị trí',
+ horizontal: 'Ngang',
+ vertical: 'Dọc',
+ absolutePosition: 'Vị trí tuyệt đối (px)',
+ relativePosition: 'Vị trí tương đối',
+ toTheRightOf: 'ở bên phải',
+ relativeTo: 'tương đối với',
+ bellow: 'bên dưới',
+ options: 'Tùy chọn',
+ moveObjectWithText: 'Di chuyển đối tượng cùng văn bản',
+ column: 'Cột',
+ margin: 'Lề',
+ page: 'Trang',
+ line: 'Dòng',
+ paragraph: 'Đoạn văn',
},
'update-status': {
exceedMaxSize: 'Kích thước hình ảnh vượt quá giới hạn, giới hạn là {0}M',
@@ -82,11 +82,11 @@ const locale: typeof enUS = {
},
shortcut: {
'drawing-view': 'Chế độ xem bản vẽ',
- 'drawing-move-down': 'Move Drawing down',
- 'drawing-move-up': 'Move Drawing up',
- 'drawing-move-left': 'Move Drawing left',
- 'drawing-move-right': 'Move Drawing right',
- 'drawing-delete': 'Delete Drawing',
+ 'drawing-move-down': 'Di chuyển bản vẽ xuống',
+ 'drawing-move-up': 'Di chuyển bản vẽ lên',
+ 'drawing-move-left': 'Di chuyển bản vẽ sang trái',
+ 'drawing-move-right': 'Di chuyển bản vẽ sang phải',
+ 'drawing-delete': 'Xóa bản vẽ',
},
},
};
diff --git a/packages/docs-drawing-ui/src/locale/zh-HK.ts b/packages/docs-drawing-ui/src/locale/zh-HK.ts
index 2d08a12aca..ebacfc4acb 100644
--- a/packages/docs-drawing-ui/src/locale/zh-HK.ts
+++ b/packages/docs-drawing-ui/src/locale/zh-HK.ts
@@ -24,9 +24,9 @@ const locale: typeof enUS = {
},
shape: {
insert: {
- title: 'Insert Shape',
- rectangle: 'Insert Rectangle',
- ellipse: 'Insert Ellipse',
+ title: '插入圖形',
+ rectangle: '插入矩形',
+ ellipse: '插入橢圓形',
},
},
panel: {
diff --git a/packages/docs-drawing-ui/src/locale/zh-TW.ts b/packages/docs-drawing-ui/src/locale/zh-TW.ts
index 2d08a12aca..ebacfc4acb 100644
--- a/packages/docs-drawing-ui/src/locale/zh-TW.ts
+++ b/packages/docs-drawing-ui/src/locale/zh-TW.ts
@@ -24,9 +24,9 @@ const locale: typeof enUS = {
},
shape: {
insert: {
- title: 'Insert Shape',
- rectangle: 'Insert Rectangle',
- ellipse: 'Insert Ellipse',
+ title: '插入圖形',
+ rectangle: '插入矩形',
+ ellipse: '插入橢圓形',
},
},
panel: {
diff --git a/packages/docs-hyper-link-ui/src/locale/fr-FR.ts b/packages/docs-hyper-link-ui/src/locale/fr-FR.ts
index 002af30400..50d59880c3 100644
--- a/packages/docs-hyper-link-ui/src/locale/fr-FR.ts
+++ b/packages/docs-hyper-link-ui/src/locale/fr-FR.ts
@@ -22,20 +22,20 @@ const locale: typeof enUS = {
confirm: 'Confirmer',
cancel: 'Annuler',
title: 'Lien',
- address: 'Link',
+ address: 'Lien',
placeholder: 'Veuillez entrer un lien',
addressError: 'L\'url est illégal!',
- label: 'Label',
+ label: 'Libellé',
labelError: 'Veuillez entrer le label du lien',
},
info: {
- copy: 'Copy',
- edit: 'Edit',
- cancel: 'Cancel link',
- coped: 'Link copied to clipboard',
+ copy: 'Copier',
+ edit: 'Modifier',
+ cancel: 'Supprimer le lien',
+ coped: 'Lien copié dans le presse-papiers',
},
menu: {
- tooltip: 'Add link',
+ tooltip: 'Ajouter un lien',
},
},
};
diff --git a/packages/docs-ui/src/commands/operations/__tests__/insert-break.operation.spec.ts b/packages/docs-ui/src/commands/operations/__tests__/insert-break.operation.spec.ts
new file mode 100644
index 0000000000..14f8b8ddce
--- /dev/null
+++ b/packages/docs-ui/src/commands/operations/__tests__/insert-break.operation.spec.ts
@@ -0,0 +1,161 @@
+/**
+ * Copyright 2023-present DreamNum Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import type { DocumentDataModel, IDocumentBody, IDocumentData, Injector, Univer } from '@univerjs/core';
+import {
+ DataStreamTreeTokenType,
+ DocumentFlavor,
+ ICommandService,
+ IUndoRedoService,
+ RedoCommand,
+ SectionType,
+ UndoCommand,
+} from '@univerjs/core';
+import {
+ DocSelectionManagerService,
+ InsertDocumentColumnBreakCommand,
+ InsertDocumentSectionBreakCommand,
+ RichTextEditingMutation,
+} from '@univerjs/docs';
+import { afterEach, beforeEach, describe, expect, it } from 'vitest';
+import {
+ InsertContinuousSectionBreakMenuFactory,
+ InsertEvenPageSectionBreakMenuFactory,
+ InsertNextColumnSectionBreakMenuFactory,
+ InsertNextPageSectionBreakMenuFactory,
+ InsertOddPageSectionBreakMenuFactory,
+} from '../../../menu/menu';
+import { createCommandTestBed } from '../../commands/__tests__/create-command-test-bed';
+import { InsertDocumentColumnBreakOperation, InsertDocumentSectionBreakOperation } from '../insert-break.operation';
+
+function createTraditionalDocument(): IDocumentData {
+ return {
+ id: 'test-doc',
+ body: {
+ dataStream: 'One\r\nTwo\r\n',
+ paragraphs: [
+ { paragraphId: 'paragraph-one', startIndex: 3 },
+ { paragraphId: 'paragraph-two', startIndex: 8 },
+ ],
+ sectionBreaks: [
+ { sectionId: 'section_one', startIndex: 4 },
+ { sectionId: 'section_two', startIndex: 9 },
+ ],
+ },
+ documentStyle: {
+ documentFlavor: DocumentFlavor.TRADITIONAL,
+ pageSize: { width: 794, height: 1123 },
+ marginTop: 96,
+ marginBottom: 96,
+ marginLeft: 96,
+ marginRight: 96,
+ },
+ };
+}
+
+describe('document break operations', () => {
+ let univer: Univer;
+ let injector: Injector;
+ let get: Injector['get'];
+ let commandService: ICommandService;
+ let documentDataModel: DocumentDataModel;
+
+ beforeEach(() => {
+ const testBed = createCommandTestBed(createTraditionalDocument());
+ univer = testBed.univer;
+ injector = testBed.injector;
+ get = testBed.get;
+ documentDataModel = testBed.doc;
+ commandService = get(ICommandService);
+ get(IUndoRedoService);
+ commandService.registerCommand(RichTextEditingMutation);
+ commandService.registerCommand(InsertDocumentColumnBreakCommand);
+ commandService.registerCommand(InsertDocumentSectionBreakCommand);
+ commandService.registerCommand(InsertDocumentColumnBreakOperation);
+ commandService.registerCommand(InsertDocumentSectionBreakOperation);
+
+ const selectionManager = get(DocSelectionManagerService);
+ selectionManager.__TEST_ONLY_setCurrentSelection({
+ unitId: 'test-doc',
+ subUnitId: 'test-doc',
+ });
+ selectionManager.__TEST_ONLY_add([{
+ startOffset: 5,
+ endOffset: 5,
+ collapsed: true,
+ isActive: true,
+ segmentId: '',
+ }]);
+ });
+
+ afterEach(() => univer.dispose());
+
+ it('inserts a column break at the active caret', () => {
+ expect(commandService.syncExecuteCommand(InsertDocumentColumnBreakOperation.id)).toBe(true);
+
+ const body = getDocumentBody();
+ expect(body.dataStream[5]).toBe(DataStreamTreeTokenType.COLUMN_BREAK);
+ expect(body.customRanges).toContainEqual(expect.objectContaining({
+ startIndex: 5,
+ endIndex: 5,
+ properties: { docxBreakType: 'column' },
+ }));
+ });
+
+ it('inserts and configures a section in one undo and redo step', () => {
+ const initialSections = structuredClone(getDocumentBody().sectionBreaks);
+ expect(commandService.syncExecuteCommand(InsertDocumentSectionBreakOperation.id, {
+ sectionType: SectionType.NEXT_COLUMN,
+ })).toBe(true);
+ expect(getDocumentBody().sectionBreaks).toEqual([
+ expect.objectContaining({ sectionId: initialSections?.[0].sectionId, startIndex: 4 }),
+ expect.objectContaining({ startIndex: 5 }),
+ expect.objectContaining({ sectionId: initialSections?.[1].sectionId, startIndex: 10, sectionType: SectionType.NEXT_COLUMN }),
+ ]);
+
+ expect(commandService.syncExecuteCommand(UndoCommand.id)).toBe(true);
+ expect(getDocumentBody().sectionBreaks).toEqual(initialSections);
+ expect(commandService.syncExecuteCommand(RedoCommand.id)).toBe(true);
+ expect(getDocumentBody().sectionBreaks).toEqual([
+ expect.objectContaining({ sectionId: initialSections?.[0].sectionId, startIndex: 4 }),
+ expect.objectContaining({ startIndex: 5 }),
+ expect.objectContaining({ sectionId: initialSections?.[1].sectionId, startIndex: 10, sectionType: SectionType.NEXT_COLUMN }),
+ ]);
+ });
+
+ it('routes all five Section Break menu items through the shared operation', () => {
+ const items = [
+ { item: InsertContinuousSectionBreakMenuFactory(injector), sectionType: SectionType.CONTINUOUS },
+ { item: InsertNextColumnSectionBreakMenuFactory(injector), sectionType: SectionType.NEXT_COLUMN },
+ { item: InsertNextPageSectionBreakMenuFactory(injector), sectionType: SectionType.NEXT_PAGE },
+ { item: InsertEvenPageSectionBreakMenuFactory(injector), sectionType: SectionType.EVEN_PAGE },
+ { item: InsertOddPageSectionBreakMenuFactory(injector), sectionType: SectionType.ODD_PAGE },
+ ];
+
+ for (const { item, sectionType } of items) {
+ expect(item.commandId).toBe(InsertDocumentSectionBreakOperation.id);
+ expect(item.params).toEqual({ sectionType });
+ }
+ });
+
+ function getDocumentBody(): IDocumentBody {
+ const body = documentDataModel.getBody();
+ if (!body) {
+ throw new Error('Expected the test document to have a body.');
+ }
+ return body;
+ }
+});
diff --git a/packages/docs-ui/src/commands/operations/insert-break.operation.ts b/packages/docs-ui/src/commands/operations/insert-break.operation.ts
new file mode 100644
index 0000000000..9ce27f46f8
--- /dev/null
+++ b/packages/docs-ui/src/commands/operations/insert-break.operation.ts
@@ -0,0 +1,88 @@
+/**
+ * Copyright 2023-present DreamNum Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import type { DocumentDataModel, ICommand, SectionType } from '@univerjs/core';
+import {
+ CommandType,
+ createSectionId,
+ DocumentFlavor,
+ ICommandService,
+ IUniverInstanceService,
+ UniverInstanceType,
+} from '@univerjs/core';
+import {
+ DocSelectionManagerService,
+ InsertDocumentColumnBreakCommand,
+ InsertDocumentSectionBreakCommand,
+} from '@univerjs/docs';
+
+export interface IInsertDocumentSectionBreakOperationParams {
+ sectionType: SectionType;
+}
+
+function getCollapsedBodyOffset(selectionManager: DocSelectionManagerService): number | null {
+ const range = selectionManager.getActiveTextRange();
+ if (!range?.collapsed || range.segmentId || !Number.isInteger(range.startOffset)) {
+ return null;
+ }
+ return range.startOffset;
+}
+
+export const InsertDocumentColumnBreakOperation: ICommand = {
+ id: 'docs.operation.insert-column-break',
+ type: CommandType.OPERATION,
+ handler: (accessor) => {
+ const instanceService = accessor.get(IUniverInstanceService);
+ const selectionManager = accessor.get(DocSelectionManagerService);
+ const commandService = accessor.get(ICommandService);
+ const document = instanceService.getCurrentUnitOfType<DocumentDataModel>(UniverInstanceType.UNIVER_DOC);
+ const offset = getCollapsedBodyOffset(selectionManager);
+ if (!document || document.getDocumentStyle().documentFlavor !== DocumentFlavor.TRADITIONAL || offset == null) {
+ return false;
+ }
+ return commandService.syncExecuteCommand(InsertDocumentColumnBreakCommand.id, {
+ unitId: document.getUnitId(),
+ offset,
+ });
+ },
+};
+
+export const InsertDocumentSectionBreakOperation: ICommand<IInsertDocumentSectionBreakOperationParams> = {
+ id: 'docs.operation.insert-section-break',
+ type: CommandType.OPERATION,
+ handler: (accessor, params) => {
+ if (!params) {
+ return false;
+ }
+ const instanceService = accessor.get(IUniverInstanceService);
+ const selectionManager = accessor.get(DocSelectionManagerService);
+ const commandService = accessor.get(ICommandService);
+ const document = instanceService.getCurrentUnitOfType<DocumentDataModel>(UniverInstanceType.UNIVER_DOC);
+ const offset = getCollapsedBodyOffset(selectionManager);
+ const body = document?.getBody();
+ if (!document || !body || document.getDocumentStyle().documentFlavor !== DocumentFlavor.TRADITIONAL || offset == null) {
+ return false;
+ }
+
+ const sectionId = createSectionId(new Set(body.sectionBreaks?.map((section) => section.sectionId)));
+ return commandService.syncExecuteCommand(InsertDocumentSectionBreakCommand.id, {
+ unitId: document.getUnitId(),
+ offset,
+ sectionId,
+ nextSectionType: params.sectionType,
+ });
+ },
+};
diff --git a/packages/docs-ui/src/controllers/components.controller.ts b/packages/docs-ui/src/controllers/components.controller.ts
index 770cc128c8..f5b56dae69 100644
--- a/packages/docs-ui/src/controllers/components.controller.ts
+++ b/packages/docs-ui/src/controllers/components.controller.ts
@@ -19,6 +19,7 @@ import {
AddImageIcon,
AlignTextBothIcon,
BoldIcon,
+ ColumnIcon,
CopyDoubleIcon,
CutIcon,
DeleteColumnDoubleIcon,
@@ -142,6 +143,7 @@ export class ComponentsController extends Disposable {
AddImageIcon,
BoldIcon,
CopyDoubleIcon,
+ ColumnIcon,
CutIcon,
DeleteColumnDoubleIcon,
DeleteIcon,
diff --git a/packages/docs-ui/src/controllers/doc-section-setting.controller.ts b/packages/docs-ui/src/controllers/doc-section-setting.controller.ts
index 5e8c9fd572..aef475f8d3 100644
--- a/packages/docs-ui/src/controllers/doc-section-setting.controller.ts
+++ b/packages/docs-ui/src/controllers/doc-section-setting.controller.ts
@@ -15,13 +15,17 @@
*/
import { Disposable, Inject } from '@univerjs/core';
+import { DocSelectionManagerService } from '@univerjs/docs';
import { ISidebarService } from '@univerjs/ui';
import { DOC_SECTION_SETTING_COMPONENT } from '../views/section-setting/component-name';
export class DocSectionSettingController extends Disposable {
private readonly _panelId = 'DocSectionSetting';
- constructor(@Inject(ISidebarService) private readonly _sidebarService: ISidebarService) {
+ constructor(
+ @Inject(ISidebarService) private readonly _sidebarService: ISidebarService,
+ @Inject(DocSelectionManagerService) private readonly _selectionManager: DocSelectionManagerService
+ ) {
super();
}
@@ -37,4 +41,15 @@ export class DocSectionSettingController extends Disposable {
closePanel(): void {
this._sidebarService.close(this._panelId);
}
+
+ navigateToSectionEnd(unitId: string, sectionStart: number, sectionEnd: number): void {
+ const params = { unitId, subUnitId: unitId };
+ const cursorOffset = Math.max(sectionStart, sectionEnd - 1);
+ this._selectionManager.replaceDocRanges(
+ [{ startOffset: cursorOffset, endOffset: cursorOffset }],
+ params,
+ true,
+ { shouldFocus: false }
+ );
+ }
}
diff --git a/packages/docs-ui/src/locale/ar-SA.ts b/packages/docs-ui/src/locale/ar-SA.ts
index 6a24c29673..1999d8862b 100644
--- a/packages/docs-ui/src/locale/ar-SA.ts
+++ b/packages/docs-ui/src/locale/ar-SA.ts
@@ -53,16 +53,23 @@ const locale: typeof enUS = {
horizontalLine: 'خط أفقي',
headerFooter: 'رأس وتذييل',
pageSetup: 'إعداد الصفحة',
+ breaks: 'فواصل',
+ columnBreak: 'فاصل عمود',
+ sectionBreakNextPage: 'فاصل مقطعي (الصفحة التالية)',
+ sectionBreakContinuous: 'فاصل مقطعي (مستمر)',
+ sectionBreakNextColumn: 'فاصل مقطعي (العمود التالي)',
+ sectionBreakEvenPage: 'فاصل مقطعي (صفحة زوجية)',
+ sectionBreakOddPage: 'فاصل مقطعي (صفحة فردية)',
heading: {
- tooltip: 'Heading',
- normal: 'Normal text',
- leading1: 'Heading 1',
- leading2: 'Heading 2',
- leading3: 'Heading 3',
- leading4: 'Heading 4',
- leading5: 'Heading 5',
- title: 'Title',
- subTitle: 'Subtitle',
+ tooltip: 'عنوان',
+ normal: 'نص عادي',
+ leading1: 'عنوان 1',
+ leading2: 'عنوان 2',
+ leading3: 'عنوان 3',
+ leading4: 'عنوان 4',
+ leading5: 'عنوان 5',
+ title: 'العنوان',
+ subTitle: 'العنوان الفرعي',
},
},
table: {
@@ -77,7 +84,7 @@ const locale: typeof enUS = {
deleteTable: 'حذف الجدول',
},
headerFooter: {
- linkToPrevious: 'Link to previous',
+ linkToPrevious: 'ارتباط بالسابق',
header: 'رأس',
footer: 'تذييل',
panel: 'إعدادات الرأس والتذييل',
@@ -104,11 +111,11 @@ const locale: typeof enUS = {
menu: {
paragraphSetting: 'إعدادات الفقرة',
- sectionSetting: 'Section Settings',
+ sectionSetting: 'إعدادات المقطع',
},
slider: {
paragraphSetting: 'إعدادات الفقرة',
- sectionSetting: 'Section Settings',
+ sectionSetting: 'إعدادات المقطع',
},
paragraphSetting: {
alignment: 'محاذاة',
@@ -122,23 +129,29 @@ const locale: typeof enUS = {
after: 'بعد',
lineSpace: 'تباعد الأسطر',
multiSpace: 'تباعد متعدد',
- atLeast: 'At Least (px)',
- exactly: 'Exactly (px)',
+ atLeast: 'على الأقل (بكسل)',
+ exactly: 'بالضبط (بكسل)',
fixedValue: 'قيمة ثابتة (بكسل)',
},
sectionSetting: {
- selectedSections: '{0} sections selected',
- columnCount: 'Column count',
- columnGap: 'Column gap',
- columnSeparator: 'Separator',
- none: 'None',
- betweenColumns: 'Between columns',
- sectionStart: 'Section start',
- unspecified: 'Unspecified',
- continuous: 'Continuous',
- nextPage: 'Next page',
- evenPage: 'Even page',
- oddPage: 'Odd page',
+ selectedSections: 'تم تحديد {0} من المقاطع',
+ multipleValues: 'قيم متعددة',
+ columnCount: 'عدد الأعمدة',
+ columnGap: 'تباعد الأعمدة',
+ columnSeparator: 'الفاصل',
+ none: 'بلا',
+ betweenColumns: 'بين الأعمدة',
+ sectionStart: 'بداية المقطع',
+ unspecified: 'غير محدد',
+ continuous: 'مستمر',
+ nextColumn: 'العمود التالي',
+ nextPage: 'الصفحة التالية',
+ evenPage: 'صفحة زوجية',
+ oddPage: 'صفحة فردية',
+ pageSetup: 'إعداد الصفحة',
+ pageWidth: 'عرض الصفحة',
+ pageHeight: 'ارتفاع الصفحة',
+ pageNumberStart: 'رقم صفحة البداية',
},
},
rightClick: {
diff --git a/packages/docs-ui/src/locale/ca-ES.ts b/packages/docs-ui/src/locale/ca-ES.ts
index 3bf29aff8d..a4548267db 100644
--- a/packages/docs-ui/src/locale/ca-ES.ts
+++ b/packages/docs-ui/src/locale/ca-ES.ts
@@ -53,16 +53,23 @@ const locale: typeof enUS = {
horizontalLine: 'Línia horitzontal',
headerFooter: 'Capçalera i peu de pàgina',
pageSetup: 'Configuració de pàgina',
+ breaks: 'Salts',
+ columnBreak: 'Salt de columna',
+ sectionBreakNextPage: 'Salt de secció (Pàgina següent)',
+ sectionBreakContinuous: 'Salt de secció (Continu)',
+ sectionBreakNextColumn: 'Salt de secció (Columna següent)',
+ sectionBreakEvenPage: 'Salt de secció (Pàgina parella)',
+ sectionBreakOddPage: 'Salt de secció (Pàgina senar)',
heading: {
- tooltip: 'Heading',
- normal: 'Normal text',
- leading1: 'Heading 1',
- leading2: 'Heading 2',
- leading3: 'Heading 3',
- leading4: 'Heading 4',
- leading5: 'Heading 5',
- title: 'Title',
- subTitle: 'Subtitle',
+ tooltip: 'Encapçalament',
+ normal: 'Text normal',
+ leading1: 'Encapçalament 1',
+ leading2: 'Encapçalament 2',
+ leading3: 'Encapçalament 3',
+ leading4: 'Encapçalament 4',
+ leading5: 'Encapçalament 5',
+ title: 'Títol',
+ subTitle: 'Subtítol',
},
},
table: {
@@ -77,7 +84,7 @@ const locale: typeof enUS = {
deleteTable: 'Elimina taula',
},
headerFooter: {
- linkToPrevious: 'Link to previous',
+ linkToPrevious: 'Enllaça amb l\'anterior',
header: 'Capçalera',
footer: 'Peu de pàgina',
panel: 'Configuració de capçalera i peu de pàgina',
@@ -104,11 +111,11 @@ const locale: typeof enUS = {
menu: {
paragraphSetting: 'Configuració de paràgraf',
- sectionSetting: 'Section Settings',
+ sectionSetting: 'Configuració de secció',
},
slider: {
paragraphSetting: 'Configuració de paràgraf',
- sectionSetting: 'Section Settings',
+ sectionSetting: 'Configuració de secció',
},
paragraphSetting: {
alignment: 'Alineació',
@@ -122,23 +129,29 @@ const locale: typeof enUS = {
after: 'Després',
lineSpace: 'Espai entre línies',
multiSpace: 'Espai múltiple',
- atLeast: 'At Least (px)',
- exactly: 'Exactly (px)',
+ atLeast: 'Com a mínim (px)',
+ exactly: 'Exactament (px)',
fixedValue: 'Valor fix (px)',
},
sectionSetting: {
- selectedSections: '{0} sections selected',
- columnCount: 'Column count',
- columnGap: 'Column gap',
- columnSeparator: 'Separator',
- none: 'None',
- betweenColumns: 'Between columns',
- sectionStart: 'Section start',
- unspecified: 'Unspecified',
- continuous: 'Continuous',
- nextPage: 'Next page',
- evenPage: 'Even page',
- oddPage: 'Odd page',
+ selectedSections: '{0} seccions seleccionades',
+ multipleValues: 'Diversos valors',
+ columnCount: 'Nombre de columnes',
+ columnGap: 'Espai entre columnes',
+ columnSeparator: 'Separador',
+ none: 'Cap',
+ betweenColumns: 'Entre columnes',
+ sectionStart: 'Inici de secció',
+ unspecified: 'Sense especificar',
+ continuous: 'Continu',
+ nextColumn: 'Columna següent',
+ nextPage: 'Pàgina següent',
+ evenPage: 'Pàgina parella',
+ oddPage: 'Pàgina senar',
+ pageSetup: 'Configuració de pàgina',
+ pageWidth: 'Amplada de pàgina',
+ pageHeight: 'Alçada de pàgina',
+ pageNumberStart: 'Número de pàgina inicial',
},
},
rightClick: {
diff --git a/packages/docs-ui/src/locale/de-DE.ts b/packages/docs-ui/src/locale/de-DE.ts
index b0d0f6b677..9ba938a905 100644
--- a/packages/docs-ui/src/locale/de-DE.ts
+++ b/packages/docs-ui/src/locale/de-DE.ts
@@ -53,16 +53,23 @@ const locale: typeof enUS = {
horizontalLine: 'Horizontale Linie',
headerFooter: 'Kopf- und Fußzeile',
pageSetup: 'Seite einrichten',
+ breaks: 'Umbrüche',
+ columnBreak: 'Spaltenumbruch',
+ sectionBreakNextPage: 'Abschnittsumbruch (Nächste Seite)',
+ sectionBreakContinuous: 'Abschnittsumbruch (Fortlaufend)',
+ sectionBreakNextColumn: 'Abschnittsumbruch (Nächste Spalte)',
+ sectionBreakEvenPage: 'Abschnittsumbruch (Gerade Seite)',
+ sectionBreakOddPage: 'Abschnittsumbruch (Ungerade Seite)',
heading: {
- tooltip: 'Heading',
- normal: 'Normal text',
- leading1: 'Heading 1',
- leading2: 'Heading 2',
- leading3: 'Heading 3',
- leading4: 'Heading 4',
- leading5: 'Heading 5',
- title: 'Title',
- subTitle: 'Subtitle',
+ tooltip: 'Überschrift',
+ normal: 'Normaler Text',
+ leading1: 'Überschrift 1',
+ leading2: 'Überschrift 2',
+ leading3: 'Überschrift 3',
+ leading4: 'Überschrift 4',
+ leading5: 'Überschrift 5',
+ title: 'Titel',
+ subTitle: 'Untertitel',
},
},
table: {
@@ -77,7 +84,7 @@ const locale: typeof enUS = {
deleteTable: 'Tabelle löschen',
},
headerFooter: {
- linkToPrevious: 'Link to previous',
+ linkToPrevious: 'Mit vorheriger verknüpfen',
header: 'Kopfzeile',
footer: 'Fußzeile',
panel: 'Kopf- und Fußzeileneinstellungen',
@@ -104,11 +111,11 @@ const locale: typeof enUS = {
menu: {
paragraphSetting: 'Absatzeinstellungen',
- sectionSetting: 'Section Settings',
+ sectionSetting: 'Abschnittseinstellungen',
},
slider: {
paragraphSetting: 'Absatzeinstellungen',
- sectionSetting: 'Section Settings',
+ sectionSetting: 'Abschnittseinstellungen',
},
paragraphSetting: {
alignment: 'Ausrichtung',
@@ -122,23 +129,29 @@ const locale: typeof enUS = {
after: 'Nach',
lineSpace: 'Zeilenabstand',
multiSpace: 'Mehrfacher Abstand',
- atLeast: 'At Least (px)',
- exactly: 'Exactly (px)',
+ atLeast: 'Mindestens (px)',
+ exactly: 'Genau (px)',
fixedValue: 'Fester Wert (px)',
},
sectionSetting: {
- selectedSections: '{0} sections selected',
- columnCount: 'Column count',
- columnGap: 'Column gap',
- columnSeparator: 'Separator',
- none: 'None',
- betweenColumns: 'Between columns',
- sectionStart: 'Section start',
- unspecified: 'Unspecified',
- continuous: 'Continuous',
- nextPage: 'Next page',
- evenPage: 'Even page',
- oddPage: 'Odd page',
+ selectedSections: '{0} Abschnitte ausgewählt',
+ multipleValues: 'Mehrere Werte',
+ columnCount: 'Spaltenanzahl',
+ columnGap: 'Spaltenabstand',
+ columnSeparator: 'Trennlinie',
+ none: 'Keine',
+ betweenColumns: 'Zwischen Spalten',
+ sectionStart: 'Abschnittsbeginn',
+ unspecified: 'Nicht angegeben',
+ continuous: 'Fortlaufend',
+ nextColumn: 'Nächste Spalte',
+ nextPage: 'Nächste Seite',
+ evenPage: 'Gerade Seite',
+ oddPage: 'Ungerade Seite',
+ pageSetup: 'Seiteneinrichtung',
+ pageWidth: 'Seitenbreite',
+ pageHeight: 'Seitenhöhe',
+ pageNumberStart: 'Erste Seitenzahl',
},
},
rightClick: {
diff --git a/packages/docs-ui/src/locale/en-US.ts b/packages/docs-ui/src/locale/en-US.ts
index 2b12e70055..7c8f254c38 100644
--- a/packages/docs-ui/src/locale/en-US.ts
+++ b/packages/docs-ui/src/locale/en-US.ts
@@ -51,6 +51,13 @@ const locale = {
horizontalLine: 'Horizontal line',
headerFooter: 'Header & Footer',
pageSetup: 'Page Setup',
+ breaks: 'Breaks',
+ columnBreak: 'Column Break',
+ sectionBreakNextPage: 'Section Break (Next Page)',
+ sectionBreakContinuous: 'Section Break (Continuous)',
+ sectionBreakNextColumn: 'Section Break (Next Column)',
+ sectionBreakEvenPage: 'Section Break (Even Page)',
+ sectionBreakOddPage: 'Section Break (Odd Page)',
heading: {
tooltip: 'Heading',
normal: 'Normal text',
@@ -126,6 +133,7 @@ const locale = {
},
sectionSetting: {
selectedSections: '{0} sections selected',
+ multipleValues: 'Multiple values',
columnCount: 'Column count',
columnGap: 'Column gap',
columnSeparator: 'Separator',
@@ -134,9 +142,14 @@ const locale = {
sectionStart: 'Section start',
unspecified: 'Unspecified',
continuous: 'Continuous',
+ nextColumn: 'Next column',
nextPage: 'Next page',
evenPage: 'Even page',
oddPage: 'Odd page',
+ pageSetup: 'Page setup',
+ pageWidth: 'Page width',
+ pageHeight: 'Page height',
+ pageNumberStart: 'Page number start',
},
},
rightClick: {
diff --git a/packages/docs-ui/src/locale/es-ES.ts b/packages/docs-ui/src/locale/es-ES.ts
index 472c33c15f..9b07cdd133 100644
--- a/packages/docs-ui/src/locale/es-ES.ts
+++ b/packages/docs-ui/src/locale/es-ES.ts
@@ -53,16 +53,23 @@ const locale: typeof enUS = {
horizontalLine: 'Línea horizontal',
headerFooter: 'Encabezado y pie de página',
pageSetup: 'Configuración de página',
+ breaks: 'Saltos',
+ columnBreak: 'Salto de columna',
+ sectionBreakNextPage: 'Salto de sección (Página siguiente)',
+ sectionBreakContinuous: 'Salto de sección (Continuo)',
+ sectionBreakNextColumn: 'Salto de sección (Columna siguiente)',
+ sectionBreakEvenPage: 'Salto de sección (Página par)',
+ sectionBreakOddPage: 'Salto de sección (Página impar)',
heading: {
- tooltip: 'Heading',
- normal: 'Normal text',
- leading1: 'Heading 1',
- leading2: 'Heading 2',
- leading3: 'Heading 3',
- leading4: 'Heading 4',
- leading5: 'Heading 5',
- title: 'Title',
- subTitle: 'Subtitle',
+ tooltip: 'Encabezado',
+ normal: 'Texto normal',
+ leading1: 'Encabezado 1',
+ leading2: 'Encabezado 2',
+ leading3: 'Encabezado 3',
+ leading4: 'Encabezado 4',
+ leading5: 'Encabezado 5',
+ title: 'Título',
+ subTitle: 'Subtítulo',
},
},
table: {
@@ -77,7 +84,7 @@ const locale: typeof enUS = {
deleteTable: 'Eliminar tabla',
},
headerFooter: {
- linkToPrevious: 'Link to previous',
+ linkToPrevious: 'Vincular al anterior',
header: 'Encabezado',
footer: 'Pie de página',
panel: 'Configuración de encabezado y pie de página',
@@ -104,11 +111,11 @@ const locale: typeof enUS = {
menu: {
paragraphSetting: 'Configuración de párrafo',
- sectionSetting: 'Section Settings',
+ sectionSetting: 'Configuración de sección',
},
slider: {
paragraphSetting: 'Configuración de párrafo',
- sectionSetting: 'Section Settings',
+ sectionSetting: 'Configuración de sección',
},
paragraphSetting: {
alignment: 'Alineación',
@@ -122,23 +129,29 @@ const locale: typeof enUS = {
after: 'Después',
lineSpace: 'Espacio entre líneas',
multiSpace: 'Espacio múltiple',
- atLeast: 'At Least (px)',
- exactly: 'Exactly (px)',
+ atLeast: 'Como mínimo (px)',
+ exactly: 'Exactamente (px)',
fixedValue: 'Valor fijo (px)',
},
sectionSetting: {
- selectedSections: '{0} sections selected',
- columnCount: 'Column count',
- columnGap: 'Column gap',
- columnSeparator: 'Separator',
- none: 'None',
- betweenColumns: 'Between columns',
- sectionStart: 'Section start',
- unspecified: 'Unspecified',
- continuous: 'Continuous',
- nextPage: 'Next page',
- evenPage: 'Even page',
- oddPage: 'Odd page',
+ selectedSections: '{0} secciones seleccionadas',
+ multipleValues: 'Varios valores',
+ columnCount: 'Número de columnas',
+ columnGap: 'Espacio entre columnas',
+ columnSeparator: 'Separador',
+ none: 'Ninguno',
+ betweenColumns: 'Entre columnas',
+ sectionStart: 'Inicio de sección',
+ unspecified: 'Sin especificar',
+ continuous: 'Continuo',
+ nextColumn: 'Columna siguiente',
+ nextPage: 'Página siguiente',
+ evenPage: 'Página par',
+ oddPage: 'Página impar',
+ pageSetup: 'Configurar página',
+ pageWidth: 'Ancho de página',
+ pageHeight: 'Alto de página',
+ pageNumberStart: 'Número de página inicial',
},
},
rightClick: {
diff --git a/packages/docs-ui/src/locale/fa-IR.ts b/packages/docs-ui/src/locale/fa-IR.ts
index 5789147750..b5e4673904 100644
--- a/packages/docs-ui/src/locale/fa-IR.ts
+++ b/packages/docs-ui/src/locale/fa-IR.ts
@@ -45,24 +45,31 @@ const locale: typeof enUS = {
order: 'لیست شماره‌دار',
unorder: 'لیست بدون شماره',
checklist: 'لیست وظیفه',
- documentFlavor: 'Modern Mode',
+ documentFlavor: 'حالت مدرن',
alignLeft: 'تراز چپ',
alignCenter: 'تراز وسط',
alignRight: 'تراز راست',
alignJustify: 'توجیه',
- horizontalLine: 'Horizontal line',
+ horizontalLine: 'خط افقی',
headerFooter: 'هدر و فوتر',
pageSetup: 'تنظیمات صفحه',
+ breaks: 'شکست‌ها',
+ columnBreak: 'شکست ستون',
+ sectionBreakNextPage: 'شکست بخش (صفحه بعد)',
+ sectionBreakContinuous: 'شکست بخش (پیوسته)',
+ sectionBreakNextColumn: 'شکست بخش (ستون بعد)',
+ sectionBreakEvenPage: 'شکست بخش (صفحه زوج)',
+ sectionBreakOddPage: 'شکست بخش (صفحه فرد)',
heading: {
- tooltip: 'Heading',
- normal: 'Normal text',
- leading1: 'Heading 1',
- leading2: 'Heading 2',
- leading3: 'Heading 3',
- leading4: 'Heading 4',
- leading5: 'Heading 5',
- title: 'Title',
- subTitle: 'Subtitle',
+ tooltip: 'عنوان',
+ normal: 'متن عادی',
+ leading1: 'عنوان 1',
+ leading2: 'عنوان 2',
+ leading3: 'عنوان 3',
+ leading4: 'عنوان 4',
+ leading5: 'عنوان 5',
+ title: 'عنوان',
+ subTitle: 'زیرعنوان',
},
},
table: {
@@ -77,7 +84,7 @@ const locale: typeof enUS = {
deleteTable: 'حذف جدول',
},
headerFooter: {
- linkToPrevious: 'Link to previous',
+ linkToPrevious: 'پیوند به قبلی',
header: 'هدر',
footer: 'فوتر',
panel: 'تنظیمات هدر و فوتر',
@@ -104,11 +111,11 @@ const locale: typeof enUS = {
menu: {
paragraphSetting: 'تنظیمات پاراگراف',
- sectionSetting: 'Section Settings',
+ sectionSetting: 'تنظیمات بخش',
},
slider: {
paragraphSetting: 'تنظیمات پاراگراف',
- sectionSetting: 'Section Settings',
+ sectionSetting: 'تنظیمات بخش',
},
paragraphSetting: {
alignment: 'تراز',
@@ -122,23 +129,29 @@ const locale: typeof enUS = {
after: 'بعد',
lineSpace: 'فاصله خط',
multiSpace: 'فاصله چندگانه',
- atLeast: 'At Least (px)',
- exactly: 'Exactly (px)',
+ atLeast: 'حداقل (پیکسل)',
+ exactly: 'دقیقاً (پیکسل)',
fixedValue: 'مقدار ثابت(px)',
},
sectionSetting: {
- selectedSections: '{0} sections selected',
- columnCount: 'Column count',
- columnGap: 'Column gap',
- columnSeparator: 'Separator',
- none: 'None',
- betweenColumns: 'Between columns',
- sectionStart: 'Section start',
- unspecified: 'Unspecified',
- continuous: 'Continuous',
- nextPage: 'Next page',
- evenPage: 'Even page',
- oddPage: 'Odd page',
+ selectedSections: '{0} بخش انتخاب شده',
+ multipleValues: 'چند مقدار',
+ columnCount: 'تعداد ستون‌ها',
+ columnGap: 'فاصله ستون‌ها',
+ columnSeparator: 'جداکننده',
+ none: 'هیچ‌کدام',
+ betweenColumns: 'بین ستون‌ها',
+ sectionStart: 'شروع بخش',
+ unspecified: 'نامشخص',
+ continuous: 'پیوسته',
+ nextColumn: 'ستون بعد',
+ nextPage: 'صفحه بعد',
+ evenPage: 'صفحه زوج',
+ oddPage: 'صفحه فرد',
+ pageSetup: 'تنظیم صفحه',
+ pageWidth: 'عرض صفحه',
+ pageHeight: 'ارتفاع صفحه',
+ pageNumberStart: 'شماره شروع صفحه',
},
},
rightClick: {
diff --git a/packages/docs-ui/src/locale/fr-FR.ts b/packages/docs-ui/src/locale/fr-FR.ts
index 2a4331b5ed..efe9f47932 100644
--- a/packages/docs-ui/src/locale/fr-FR.ts
+++ b/packages/docs-ui/src/locale/fr-FR.ts
@@ -45,24 +45,31 @@ const locale: typeof enUS = {
order: 'Liste ordonnée',
unorder: 'Liste non ordonnée',
checklist: 'Liste de tâches',
- documentFlavor: 'Modern Mode',
+ documentFlavor: 'Mode moderne',
alignLeft: 'Aligner à gauche',
alignCenter: 'Aligner au centre',
alignRight: 'Aligner à droite',
alignJustify: 'Justifier',
- horizontalLine: 'Horizontal line',
+ horizontalLine: 'Ligne horizontale',
headerFooter: 'En-tête et pied de page',
pageSetup: 'Paramètres de page',
+ breaks: 'Sauts',
+ columnBreak: 'Saut de colonne',
+ sectionBreakNextPage: 'Saut de section (Page suivante)',
+ sectionBreakContinuous: 'Saut de section (Continu)',
+ sectionBreakNextColumn: 'Saut de section (Colonne suivante)',
+ sectionBreakEvenPage: 'Saut de section (Page paire)',
+ sectionBreakOddPage: 'Saut de section (Page impaire)',
heading: {
- tooltip: 'Heading',
- normal: 'Normal text',
- leading1: 'Heading 1',
- leading2: 'Heading 2',
- leading3: 'Heading 3',
- leading4: 'Heading 4',
- leading5: 'Heading 5',
- title: 'Title',
- subTitle: 'Subtitle',
+ tooltip: 'Titre',
+ normal: 'Texte normal',
+ leading1: 'Titre 1',
+ leading2: 'Titre 2',
+ leading3: 'Titre 3',
+ leading4: 'Titre 4',
+ leading5: 'Titre 5',
+ title: 'Titre',
+ subTitle: 'Sous-titre',
},
},
table: {
@@ -77,7 +84,7 @@ const locale: typeof enUS = {
deleteTable: 'Supprimer le tableau',
},
headerFooter: {
- linkToPrevious: 'Link to previous',
+ linkToPrevious: 'Lier au précédent',
header: 'En-tête',
footer: 'Pied de page',
panel: 'En-tête et pied de page',
@@ -104,15 +111,15 @@ const locale: typeof enUS = {
menu: {
paragraphSetting: 'Paramètres de paragraphe',
- sectionSetting: 'Section Settings',
+ sectionSetting: 'Paramètres de section',
},
slider: {
paragraphSetting: 'Paramètres de paragraphe',
- sectionSetting: 'Section Settings',
+ sectionSetting: 'Paramètres de section',
},
paragraphSetting: {
alignment: 'Alignement',
- indentation: 'Indentation',
+ indentation: 'Retrait',
left: 'Gauche',
right: 'Droite',
firstLine: 'Première ligne',
@@ -122,23 +129,29 @@ const locale: typeof enUS = {
after: 'Après',
lineSpace: 'Espacement de ligne',
multiSpace: 'Espacement multiple',
- atLeast: 'At Least (px)',
- exactly: 'Exactly (px)',
+ atLeast: 'Au moins (px)',
+ exactly: 'Exactement (px)',
fixedValue: 'Valeur fixe(px)',
},
sectionSetting: {
- selectedSections: '{0} sections selected',
- columnCount: 'Column count',
- columnGap: 'Column gap',
- columnSeparator: 'Separator',
- none: 'None',
- betweenColumns: 'Between columns',
- sectionStart: 'Section start',
- unspecified: 'Unspecified',
- continuous: 'Continuous',
- nextPage: 'Next page',
- evenPage: 'Even page',
- oddPage: 'Odd page',
+ selectedSections: '{0} sections sélectionnées',
+ multipleValues: 'Plusieurs valeurs',
+ columnCount: 'Nombre de colonnes',
+ columnGap: 'Espacement des colonnes',
+ columnSeparator: 'Séparateur',
+ none: 'Aucun',
+ betweenColumns: 'Entre les colonnes',
+ sectionStart: 'Début de section',
+ unspecified: 'Non spécifié',
+ continuous: 'Continu',
+ nextColumn: 'Colonne suivante',
+ nextPage: 'Page suivante',
+ evenPage: 'Page paire',
+ oddPage: 'Page impaire',
+ pageSetup: 'Mise en page',
+ pageWidth: 'Largeur de page',
+ pageHeight: 'Hauteur de page',
+ pageNumberStart: 'Numéro de page initial',
},
},
rightClick: {
diff --git a/packages/docs-ui/src/locale/id-ID.ts b/packages/docs-ui/src/locale/id-ID.ts
index ed5c67f3a1..b123c53b23 100644
--- a/packages/docs-ui/src/locale/id-ID.ts
+++ b/packages/docs-ui/src/locale/id-ID.ts
@@ -53,16 +53,23 @@ const locale: typeof enUS = {
horizontalLine: 'Garis horizontal',
headerFooter: 'Header & Footer',
pageSetup: 'Pengaturan Halaman',
+ breaks: 'Pemisah',
+ columnBreak: 'Pemisah kolom',
+ sectionBreakNextPage: 'Pemisah bagian (Halaman berikutnya)',
+ sectionBreakContinuous: 'Pemisah bagian (Berkelanjutan)',
+ sectionBreakNextColumn: 'Pemisah bagian (Kolom berikutnya)',
+ sectionBreakEvenPage: 'Pemisah bagian (Halaman genap)',
+ sectionBreakOddPage: 'Pemisah bagian (Halaman ganjil)',
heading: {
- tooltip: 'Heading',
- normal: 'Normal text',
- leading1: 'Heading 1',
- leading2: 'Heading 2',
- leading3: 'Heading 3',
- leading4: 'Heading 4',
- leading5: 'Heading 5',
- title: 'Title',
- subTitle: 'Subtitle',
+ tooltip: 'Judul',
+ normal: 'Teks normal',
+ leading1: 'Judul 1',
+ leading2: 'Judul 2',
+ leading3: 'Judul 3',
+ leading4: 'Judul 4',
+ leading5: 'Judul 5',
+ title: 'Judul',
+ subTitle: 'Subjudul',
},
},
table: {
@@ -77,7 +84,7 @@ const locale: typeof enUS = {
deleteTable: 'Hapus tabel',
},
headerFooter: {
- linkToPrevious: 'Link to previous',
+ linkToPrevious: 'Tautkan ke sebelumnya',
header: 'Header',
footer: 'Footer',
panel: 'Pengaturan Header & Footer',
@@ -104,11 +111,11 @@ const locale: typeof enUS = {
menu: {
paragraphSetting: 'Pengaturan Paragraf',
- sectionSetting: 'Section Settings',
+ sectionSetting: 'Pengaturan bagian',
},
slider: {
paragraphSetting: 'Pengaturan Paragraf',
- sectionSetting: 'Section Settings',
+ sectionSetting: 'Pengaturan bagian',
},
paragraphSetting: {
alignment: 'Perataan',
@@ -122,23 +129,29 @@ const locale: typeof enUS = {
after: 'Sesudah',
lineSpace: 'Spasi Baris',
multiSpace: 'Spasi Ganda',
- atLeast: 'At Least (px)',
- exactly: 'Exactly (px)',
+ atLeast: 'Setidaknya (px)',
+ exactly: 'Tepat (px)',
fixedValue: 'Nilai Tetap(px)',
},
sectionSetting: {
- selectedSections: '{0} sections selected',
- columnCount: 'Column count',
- columnGap: 'Column gap',
- columnSeparator: 'Separator',
- none: 'None',
- betweenColumns: 'Between columns',
- sectionStart: 'Section start',
- unspecified: 'Unspecified',
- continuous: 'Continuous',
- nextPage: 'Next page',
- evenPage: 'Even page',
- oddPage: 'Odd page',
+ selectedSections: '{0} bagian dipilih',
+ multipleValues: 'Beberapa nilai',
+ columnCount: 'Jumlah kolom',
+ columnGap: 'Jarak kolom',
+ columnSeparator: 'Pemisah',
+ none: 'Tidak ada',
+ betweenColumns: 'Di antara kolom',
+ sectionStart: 'Awal bagian',
+ unspecified: 'Tidak ditentukan',
+ continuous: 'Berkelanjutan',
+ nextColumn: 'Kolom berikutnya',
+ nextPage: 'Halaman berikutnya',
+ evenPage: 'Halaman genap',
+ oddPage: 'Halaman ganjil',
+ pageSetup: 'Pengaturan halaman',
+ pageWidth: 'Lebar halaman',
+ pageHeight: 'Tinggi halaman',
+ pageNumberStart: 'Nomor halaman awal',
},
},
rightClick: {
diff --git a/packages/docs-ui/src/locale/it-IT.ts b/packages/docs-ui/src/locale/it-IT.ts
index 63451cd703..20bd069af3 100644
--- a/packages/docs-ui/src/locale/it-IT.ts
+++ b/packages/docs-ui/src/locale/it-IT.ts
@@ -53,16 +53,23 @@ const locale: typeof enUS = {
horizontalLine: 'Linea orizzontale',
headerFooter: 'Intestazione e Piè di Pagina',
pageSetup: 'Impostazione Pagina',
+ breaks: 'Interruzioni',
+ columnBreak: 'Interruzione di colonna',
+ sectionBreakNextPage: 'Interruzione di sezione (Pagina successiva)',
+ sectionBreakContinuous: 'Interruzione di sezione (Continua)',
+ sectionBreakNextColumn: 'Interruzione di sezione (Colonna successiva)',
+ sectionBreakEvenPage: 'Interruzione di sezione (Pagina pari)',
+ sectionBreakOddPage: 'Interruzione di sezione (Pagina dispari)',
heading: {
- tooltip: 'Heading',
- normal: 'Normal text',
- leading1: 'Heading 1',
- leading2: 'Heading 2',
- leading3: 'Heading 3',
- leading4: 'Heading 4',
- leading5: 'Heading 5',
- title: 'Title',
- subTitle: 'Subtitle',
+ tooltip: 'Titolo',
+ normal: 'Testo normale',
+ leading1: 'Titolo 1',
+ leading2: 'Titolo 2',
+ leading3: 'Titolo 3',
+ leading4: 'Titolo 4',
+ leading5: 'Titolo 5',
+ title: 'Titolo',
+ subTitle: 'Sottotitolo',
},
},
table: {
@@ -77,7 +84,7 @@ const locale: typeof enUS = {
deleteTable: 'Elimina tabella',
},
headerFooter: {
- linkToPrevious: 'Link to previous',
+ linkToPrevious: 'Collega al precedente',
header: 'Intestazione',
footer: 'Piè di pagina',
panel: 'Impostazioni Intestazione e Piè di Pagina',
@@ -104,11 +111,11 @@ const locale: typeof enUS = {
menu: {
paragraphSetting: 'Impostazioni Paragrafo',
- sectionSetting: 'Section Settings',
+ sectionSetting: 'Impostazioni sezione',
},
slider: {
paragraphSetting: 'Impostazioni Paragrafo',
- sectionSetting: 'Section Settings',
+ sectionSetting: 'Impostazioni sezione',
},
paragraphSetting: {
alignment: 'Allineamento',
@@ -122,23 +129,29 @@ const locale: typeof enUS = {
after: 'Dopo',
lineSpace: 'Interlinea',
multiSpace: 'Spaziatura multipla',
- atLeast: 'At Least (px)',
- exactly: 'Exactly (px)',
+ atLeast: 'Almeno (px)',
+ exactly: 'Esattamente (px)',
fixedValue: 'Valore fisso (px)',
},
sectionSetting: {
- selectedSections: '{0} sections selected',
- columnCount: 'Column count',
- columnGap: 'Column gap',
- columnSeparator: 'Separator',
- none: 'None',
- betweenColumns: 'Between columns',
- sectionStart: 'Section start',
- unspecified: 'Unspecified',
- continuous: 'Continuous',
- nextPage: 'Next page',
- evenPage: 'Even page',
- oddPage: 'Odd page',
+ selectedSections: '{0} sezioni selezionate',
+ multipleValues: 'Più valori',
+ columnCount: 'Numero di colonne',
+ columnGap: 'Spaziatura colonne',
+ columnSeparator: 'Separatore',
+ none: 'Nessuno',
+ betweenColumns: 'Tra le colonne',
+ sectionStart: 'Inizio sezione',
+ unspecified: 'Non specificato',
+ continuous: 'Continua',
+ nextColumn: 'Colonna successiva',
+ nextPage: 'Pagina successiva',
+ evenPage: 'Pagina pari',
+ oddPage: 'Pagina dispari',
+ pageSetup: 'Imposta pagina',
+ pageWidth: 'Larghezza pagina',
+ pageHeight: 'Altezza pagina',
+ pageNumberStart: 'Numero di pagina iniziale',
},
},
rightClick: {
diff --git a/packages/docs-ui/src/locale/ja-JP.ts b/packages/docs-ui/src/locale/ja-JP.ts
index 9b20bd9c84..58ef23caca 100644
--- a/packages/docs-ui/src/locale/ja-JP.ts
+++ b/packages/docs-ui/src/locale/ja-JP.ts
@@ -53,16 +53,23 @@ const locale: typeof enUS = {
horizontalLine: '横線の挿入',
headerFooter: 'ヘッダーとフッター',
pageSetup: 'ページ設定',
+ breaks: '区切り',
+ columnBreak: '段区切り',
+ sectionBreakNextPage: 'セクション区切り(次のページ)',
+ sectionBreakContinuous: 'セクション区切り(現在の位置)',
+ sectionBreakNextColumn: 'セクション区切り(次の段)',
+ sectionBreakEvenPage: 'セクション区切り(偶数ページ)',
+ sectionBreakOddPage: 'セクション区切り(奇数ページ)',
heading: {
- tooltip: 'Heading',
- normal: 'Normal text',
- leading1: 'Heading 1',
- leading2: 'Heading 2',
- leading3: 'Heading 3',
- leading4: 'Heading 4',
- leading5: 'Heading 5',
- title: 'Title',
- subTitle: 'Subtitle',
+ tooltip: '見出し',
+ normal: '標準テキスト',
+ leading1: '見出し 1',
+ leading2: '見出し 2',
+ leading3: '見出し 3',
+ leading4: '見出し 4',
+ leading5: '見出し 5',
+ title: 'タイトル',
+ subTitle: 'サブタイトル',
},
},
table: {
@@ -77,7 +84,7 @@ const locale: typeof enUS = {
deleteTable: '表を削除',
},
headerFooter: {
- linkToPrevious: 'Link to previous',
+ linkToPrevious: '前と同じ',
header: 'ヘッダー',
footer: 'フッター',
panel: 'ヘッダーとフッターの設定',
@@ -104,11 +111,11 @@ const locale: typeof enUS = {
menu: {
paragraphSetting: '段落設定',
- sectionSetting: 'Section Settings',
+ sectionSetting: 'セクション設定',
},
slider: {
paragraphSetting: '段落設定',
- sectionSetting: 'Section Settings',
+ sectionSetting: 'セクション設定',
},
paragraphSetting: {
alignment: '配置',
@@ -122,23 +129,29 @@ const locale: typeof enUS = {
after: '後の間隔',
lineSpace: '行間',
multiSpace: '複数行間',
- atLeast: 'At Least (px)',
- exactly: 'Exactly (px)',
+ atLeast: '最小値 (px)',
+ exactly: '固定値 (px)',
fixedValue: '固定値(px)',
},
sectionSetting: {
- selectedSections: '{0} sections selected',
- columnCount: 'Column count',
- columnGap: 'Column gap',
- columnSeparator: 'Separator',
- none: 'None',
- betweenColumns: 'Between columns',
- sectionStart: 'Section start',
- unspecified: 'Unspecified',
- continuous: 'Continuous',
- nextPage: 'Next page',
- evenPage: 'Even page',
- oddPage: 'Odd page',
+ selectedSections: '{0} 個のセクションを選択中',
+ multipleValues: '複数の値',
+ columnCount: '段数',
+ columnGap: '段の間隔',
+ columnSeparator: '境界線',
+ none: 'なし',
+ betweenColumns: '段の間',
+ sectionStart: 'セクションの開始位置',
+ unspecified: '指定なし',
+ continuous: '現在の位置',
+ nextColumn: '次の段',
+ nextPage: '次のページ',
+ evenPage: '偶数ページ',
+ oddPage: '奇数ページ',
+ pageSetup: 'ページ設定',
+ pageWidth: 'ページ幅',
+ pageHeight: 'ページの高さ',
+ pageNumberStart: '開始ページ番号',
},
},
rightClick: {
diff --git a/packages/docs-ui/src/locale/ko-KR.ts b/packages/docs-ui/src/locale/ko-KR.ts
index 8b5dbc52bd..ba50f76a5d 100644
--- a/packages/docs-ui/src/locale/ko-KR.ts
+++ b/packages/docs-ui/src/locale/ko-KR.ts
@@ -53,16 +53,23 @@ const locale: typeof enUS = {
horizontalLine: '가로줄 삽입',
headerFooter: '머리글 및 바닥글',
pageSetup: '페이지 설정',
+ breaks: '나누기',
+ columnBreak: '단 나누기',
+ sectionBreakNextPage: '구역 나누기(다음 페이지)',
+ sectionBreakContinuous: '구역 나누기(이어짐)',
+ sectionBreakNextColumn: '구역 나누기(다음 단)',
+ sectionBreakEvenPage: '구역 나누기(짝수 페이지)',
+ sectionBreakOddPage: '구역 나누기(홀수 페이지)',
heading: {
- tooltip: 'Heading',
- normal: 'Normal text',
- leading1: 'Heading 1',
- leading2: 'Heading 2',
- leading3: 'Heading 3',
- leading4: 'Heading 4',
- leading5: 'Heading 5',
- title: 'Title',
- subTitle: 'Subtitle',
+ tooltip: '제목',
+ normal: '일반 텍스트',
+ leading1: '제목 1',
+ leading2: '제목 2',
+ leading3: '제목 3',
+ leading4: '제목 4',
+ leading5: '제목 5',
+ title: '제목',
+ subTitle: '부제목',
},
},
table: {
@@ -77,7 +84,7 @@ const locale: typeof enUS = {
deleteTable: '표 삭제',
},
headerFooter: {
- linkToPrevious: 'Link to previous',
+ linkToPrevious: '이전 항목에 연결',
header: '머리글',
footer: '바닥글',
panel: '머리글 및 바닥글 설정',
@@ -104,11 +111,11 @@ const locale: typeof enUS = {
menu: {
paragraphSetting: '문단 설정',
- sectionSetting: 'Section Settings',
+ sectionSetting: '구역 설정',
},
slider: {
paragraphSetting: '문단 설정',
- sectionSetting: 'Section Settings',
+ sectionSetting: '구역 설정',
},
paragraphSetting: {
alignment: '정렬',
@@ -122,23 +129,29 @@ const locale: typeof enUS = {
after: '아래 간격',
lineSpace: '줄 간격',
multiSpace: '복수 줄 간격',
- atLeast: 'At Least (px)',
- exactly: 'Exactly (px)',
+ atLeast: '최소 (px)',
+ exactly: '고정값 (px)',
fixedValue: '고정 값(px)',
},
sectionSetting: {
- selectedSections: '{0} sections selected',
- columnCount: 'Column count',
- columnGap: 'Column gap',
- columnSeparator: 'Separator',
- none: 'None',
- betweenColumns: 'Between columns',
- sectionStart: 'Section start',
- unspecified: 'Unspecified',
- continuous: 'Continuous',
- nextPage: 'Next page',
- evenPage: 'Even page',
- oddPage: 'Odd page',
+ selectedSections: '{0}개 구역 선택됨',
+ multipleValues: '여러 값',
+ columnCount: '단 수',
+ columnGap: '단 간격',
+ columnSeparator: '구분선',
+ none: '없음',
+ betweenColumns: '단 사이',
+ sectionStart: '구역 시작',
+ unspecified: '지정 안 함',
+ continuous: '이어서',
+ nextColumn: '다음 단',
+ nextPage: '다음 페이지',
+ evenPage: '짝수 페이지',
+ oddPage: '홀수 페이지',
+ pageSetup: '페이지 설정',
+ pageWidth: '페이지 너비',
+ pageHeight: '페이지 높이',
+ pageNumberStart: '시작 페이지 번호',
},
},
rightClick: {
diff --git a/packages/docs-ui/src/locale/pl-PL.ts b/packages/docs-ui/src/locale/pl-PL.ts
index c1fdb58c72..1bd91a27ca 100644
--- a/packages/docs-ui/src/locale/pl-PL.ts
+++ b/packages/docs-ui/src/locale/pl-PL.ts
@@ -53,16 +53,23 @@ const locale: typeof enUS = {
horizontalLine: 'Linia pozioma',
headerFooter: 'Nagłówek i stopka',
pageSetup: 'Ustawienia strony',
+ breaks: 'Podziały',
+ columnBreak: 'Podział kolumny',
+ sectionBreakNextPage: 'Podział sekcji (Następna strona)',
+ sectionBreakContinuous: 'Podział sekcji (Ciągły)',
+ sectionBreakNextColumn: 'Podział sekcji (Następna kolumna)',
+ sectionBreakEvenPage: 'Podział sekcji (Strona parzysta)',
+ sectionBreakOddPage: 'Podział sekcji (Strona nieparzysta)',
heading: {
- tooltip: 'Heading',
- normal: 'Normal text',
- leading1: 'Heading 1',
- leading2: 'Heading 2',
- leading3: 'Heading 3',
- leading4: 'Heading 4',
- leading5: 'Heading 5',
- title: 'Title',
- subTitle: 'Subtitle',
+ tooltip: 'Nagłówek',
+ normal: 'Tekst normalny',
+ leading1: 'Nagłówek 1',
+ leading2: 'Nagłówek 2',
+ leading3: 'Nagłówek 3',
+ leading4: 'Nagłówek 4',
+ leading5: 'Nagłówek 5',
+ title: 'Tytuł',
+ subTitle: 'Podtytuł',
},
},
table: {
@@ -77,7 +84,7 @@ const locale: typeof enUS = {
deleteTable: 'Usuń tabelę',
},
headerFooter: {
- linkToPrevious: 'Link to previous',
+ linkToPrevious: 'Połącz z poprzednim',
header: 'Nagłówek',
footer: 'Stopka',
panel: 'Ustawienia nagłówka i stopki',
@@ -104,11 +111,11 @@ const locale: typeof enUS = {
menu: {
paragraphSetting: 'Ustawienia akapitu',
- sectionSetting: 'Section Settings',
+ sectionSetting: 'Ustawienia sekcji',
},
slider: {
paragraphSetting: 'Ustawienia akapitu',
- sectionSetting: 'Section Settings',
+ sectionSetting: 'Ustawienia sekcji',
},
paragraphSetting: {
alignment: 'Wyrównanie',
@@ -122,23 +129,29 @@ const locale: typeof enUS = {
after: 'Po',
lineSpace: 'Odstęp między wierszami',
multiSpace: 'Wielokrotny odstęp',
- atLeast: 'At Least (px)',
- exactly: 'Exactly (px)',
+ atLeast: 'Co najmniej (px)',
+ exactly: 'Dokładnie (px)',
fixedValue: 'Wartość stała (px)',
},
sectionSetting: {
- selectedSections: '{0} sections selected',
- columnCount: 'Column count',
- columnGap: 'Column gap',
+ selectedSections: 'Wybrano sekcje: {0}',
+ multipleValues: 'Wiele wartości',
+ columnCount: 'Liczba kolumn',
+ columnGap: 'Odstęp między kolumnami',
columnSeparator: 'Separator',
- none: 'None',
- betweenColumns: 'Between columns',
- sectionStart: 'Section start',
- unspecified: 'Unspecified',
- continuous: 'Continuous',
- nextPage: 'Next page',
- evenPage: 'Even page',
- oddPage: 'Odd page',
+ none: 'Brak',
+ betweenColumns: 'Między kolumnami',
+ sectionStart: 'Początek sekcji',
+ unspecified: 'Nie określono',
+ continuous: 'Ciągły',
+ nextColumn: 'Następna kolumna',
+ nextPage: 'Następna strona',
+ evenPage: 'Strona parzysta',
+ oddPage: 'Strona nieparzysta',
+ pageSetup: 'Ustawienia strony',
+ pageWidth: 'Szerokość strony',
+ pageHeight: 'Wysokość strony',
+ pageNumberStart: 'Początkowy numer strony',
},
},
rightClick: {
diff --git a/packages/docs-ui/src/locale/pt-BR.ts b/packages/docs-ui/src/locale/pt-BR.ts
index b9a5fe39b7..a8765fc062 100644
--- a/packages/docs-ui/src/locale/pt-BR.ts
+++ b/packages/docs-ui/src/locale/pt-BR.ts
@@ -53,16 +53,23 @@ const locale: typeof enUS = {
horizontalLine: 'Linha horizontal',
headerFooter: 'Cabeçalho e rodapé',
pageSetup: 'Configurar página',
+ breaks: 'Quebras',
+ columnBreak: 'Quebra de coluna',
+ sectionBreakNextPage: 'Quebra de seção (Próxima página)',
+ sectionBreakContinuous: 'Quebra de seção (Contínua)',
+ sectionBreakNextColumn: 'Quebra de seção (Próxima coluna)',
+ sectionBreakEvenPage: 'Quebra de seção (Página par)',
+ sectionBreakOddPage: 'Quebra de seção (Página ímpar)',
heading: {
- tooltip: 'Heading',
- normal: 'Normal text',
- leading1: 'Heading 1',
- leading2: 'Heading 2',
- leading3: 'Heading 3',
- leading4: 'Heading 4',
- leading5: 'Heading 5',
- title: 'Title',
- subTitle: 'Subtitle',
+ tooltip: 'Título',
+ normal: 'Texto normal',
+ leading1: 'Título 1',
+ leading2: 'Título 2',
+ leading3: 'Título 3',
+ leading4: 'Título 4',
+ leading5: 'Título 5',
+ title: 'Título',
+ subTitle: 'Subtítulo',
},
},
table: {
@@ -77,7 +84,7 @@ const locale: typeof enUS = {
deleteTable: 'Excluir tabela',
},
headerFooter: {
- linkToPrevious: 'Link to previous',
+ linkToPrevious: 'Vincular ao anterior',
header: 'Cabeçalho',
footer: 'Rodapé',
panel: 'Configurações de cabeçalho e rodapé',
@@ -104,11 +111,11 @@ const locale: typeof enUS = {
menu: {
paragraphSetting: 'Configurações de parágrafo',
- sectionSetting: 'Section Settings',
+ sectionSetting: 'Configurações da seção',
},
slider: {
paragraphSetting: 'Configurações de parágrafo',
- sectionSetting: 'Section Settings',
+ sectionSetting: 'Configurações da seção',
},
paragraphSetting: {
alignment: 'Alinhamento',
@@ -122,23 +129,29 @@ const locale: typeof enUS = {
after: 'Depois',
lineSpace: 'Espaçamento entre linhas',
multiSpace: 'Espaçamento múltiplo',
- atLeast: 'At Least (px)',
- exactly: 'Exactly (px)',
+ atLeast: 'Pelo menos (px)',
+ exactly: 'Exatamente (px)',
fixedValue: 'Valor fixo (px)',
},
sectionSetting: {
- selectedSections: '{0} sections selected',
- columnCount: 'Column count',
- columnGap: 'Column gap',
- columnSeparator: 'Separator',
- none: 'None',
- betweenColumns: 'Between columns',
- sectionStart: 'Section start',
- unspecified: 'Unspecified',
- continuous: 'Continuous',
- nextPage: 'Next page',
- evenPage: 'Even page',
- oddPage: 'Odd page',
+ selectedSections: '{0} seções selecionadas',
+ multipleValues: 'Vários valores',
+ columnCount: 'Número de colunas',
+ columnGap: 'Espaçamento entre colunas',
+ columnSeparator: 'Separador',
+ none: 'Nenhum',
+ betweenColumns: 'Entre colunas',
+ sectionStart: 'Início da seção',
+ unspecified: 'Não especificado',
+ continuous: 'Contínuo',
+ nextColumn: 'Próxima coluna',
+ nextPage: 'Próxima página',
+ evenPage: 'Página par',
+ oddPage: 'Página ímpar',
+ pageSetup: 'Configurar página',
+ pageWidth: 'Largura da página',
+ pageHeight: 'Altura da página',
+ pageNumberStart: 'Número de página inicial',
},
},
rightClick: {
diff --git a/packages/docs-ui/src/locale/ru-RU.ts b/packages/docs-ui/src/locale/ru-RU.ts
index 083458057f..80021362b3 100644
--- a/packages/docs-ui/src/locale/ru-RU.ts
+++ b/packages/docs-ui/src/locale/ru-RU.ts
@@ -53,16 +53,23 @@ const locale: typeof enUS = {
horizontalLine: 'Горизонтальная линия',
headerFooter: 'Верхние и нижние колонтитулы',
pageSetup: 'Настройки страницы',
+ breaks: 'Разрывы',
+ columnBreak: 'Разрыв колонки',
+ sectionBreakNextPage: 'Разрыв раздела (Со следующей страницы)',
+ sectionBreakContinuous: 'Разрыв раздела (Непрерывный)',
+ sectionBreakNextColumn: 'Разрыв раздела (Со следующей колонки)',
+ sectionBreakEvenPage: 'Разрыв раздела (С чётной страницы)',
+ sectionBreakOddPage: 'Разрыв раздела (С нечётной страницы)',
heading: {
- tooltip: 'Heading',
- normal: 'Normal text',
- leading1: 'Heading 1',
- leading2: 'Heading 2',
- leading3: 'Heading 3',
- leading4: 'Heading 4',
- leading5: 'Heading 5',
- title: 'Title',
- subTitle: 'Subtitle',
+ tooltip: 'Заголовок',
+ normal: 'Обычный текст',
+ leading1: 'Заголовок 1',
+ leading2: 'Заголовок 2',
+ leading3: 'Заголовок 3',
+ leading4: 'Заголовок 4',
+ leading5: 'Заголовок 5',
+ title: 'Название',
+ subTitle: 'Подзаголовок',
},
},
table: {
@@ -77,7 +84,7 @@ const locale: typeof enUS = {
deleteTable: 'Удалить таблицу',
},
headerFooter: {
- linkToPrevious: 'Link to previous',
+ linkToPrevious: 'Связать с предыдущим',
header: 'Верхний колонтитул',
footer: 'Нижний колонтитул',
panel: 'Настройки верхнего и нижнего колонтитулов',
@@ -104,11 +111,11 @@ const locale: typeof enUS = {
menu: {
paragraphSetting: 'Настройка абзаца',
- sectionSetting: 'Section Settings',
+ sectionSetting: 'Параметры раздела',
},
slider: {
paragraphSetting: 'Настройка абзаца',
- sectionSetting: 'Section Settings',
+ sectionSetting: 'Параметры раздела',
},
paragraphSetting: {
alignment: 'Выравнивание',
@@ -122,23 +129,29 @@ const locale: typeof enUS = {
after: 'После',
lineSpace: 'Высота строки',
multiSpace: 'Двойной отступ',
- atLeast: 'At Least (px)',
- exactly: 'Exactly (px)',
+ atLeast: 'Не менее (px)',
+ exactly: 'Точно (px)',
fixedValue: 'Фиксированное значение (px)',
},
sectionSetting: {
- selectedSections: '{0} sections selected',
- columnCount: 'Column count',
- columnGap: 'Column gap',
- columnSeparator: 'Separator',
- none: 'None',
- betweenColumns: 'Between columns',
- sectionStart: 'Section start',
- unspecified: 'Unspecified',
- continuous: 'Continuous',
- nextPage: 'Next page',
- evenPage: 'Even page',
- oddPage: 'Odd page',
+ selectedSections: 'Выбрано разделов: {0}',
+ multipleValues: 'Несколько значений',
+ columnCount: 'Количество колонок',
+ columnGap: 'Интервал между колонками',
+ columnSeparator: 'Разделитель',
+ none: 'Нет',
+ betweenColumns: 'Между колонками',
+ sectionStart: 'Начало раздела',
+ unspecified: 'Не указано',
+ continuous: 'Непрерывный',
+ nextColumn: 'Следующая колонка',
+ nextPage: 'Следующая страница',
+ evenPage: 'Чётная страница',
+ oddPage: 'Нечётная страница',
+ pageSetup: 'Параметры страницы',
+ pageWidth: 'Ширина страницы',
+ pageHeight: 'Высота страницы',
+ pageNumberStart: 'Начальный номер страницы',
},
},
rightClick: {
diff --git a/packages/docs-ui/src/locale/sk-SK.ts b/packages/docs-ui/src/locale/sk-SK.ts
index c34cc4a3d8..1a953484dd 100644
--- a/packages/docs-ui/src/locale/sk-SK.ts
+++ b/packages/docs-ui/src/locale/sk-SK.ts
@@ -53,16 +53,23 @@ const locale: typeof enUS = {
horizontalLine: 'Vodorovná čiara',
headerFooter: 'Hlavička a päta',
pageSetup: 'Nastavenie stránky',
+ breaks: 'Zlomy',
+ columnBreak: 'Zlom stĺpca',
+ sectionBreakNextPage: 'Zlom sekcie (Nasledujúca strana)',
+ sectionBreakContinuous: 'Zlom sekcie (Priebežný)',
+ sectionBreakNextColumn: 'Zlom sekcie (Nasledujúci stĺpec)',
+ sectionBreakEvenPage: 'Zlom sekcie (Párna strana)',
+ sectionBreakOddPage: 'Zlom sekcie (Nepárna strana)',
heading: {
- tooltip: 'Heading',
- normal: 'Normal text',
- leading1: 'Heading 1',
- leading2: 'Heading 2',
- leading3: 'Heading 3',
- leading4: 'Heading 4',
- leading5: 'Heading 5',
- title: 'Title',
- subTitle: 'Subtitle',
+ tooltip: 'Nadpis',
+ normal: 'Normálny text',
+ leading1: 'Nadpis 1',
+ leading2: 'Nadpis 2',
+ leading3: 'Nadpis 3',
+ leading4: 'Nadpis 4',
+ leading5: 'Nadpis 5',
+ title: 'Názov',
+ subTitle: 'Podnadpis',
},
},
table: {
@@ -77,7 +84,7 @@ const locale: typeof enUS = {
deleteTable: 'Odstrániť tabuľku',
},
headerFooter: {
- linkToPrevious: 'Link to previous',
+ linkToPrevious: 'Prepojiť s predchádzajúcim',
header: 'Hlavička',
footer: 'Päta',
panel: 'Nastavenia hlavičky a päty',
@@ -104,11 +111,11 @@ const locale: typeof enUS = {
menu: {
paragraphSetting: 'Nastavenia odseku',
- sectionSetting: 'Section Settings',
+ sectionSetting: 'Nastavenia sekcie',
},
slider: {
paragraphSetting: 'Nastavenia odseku',
- sectionSetting: 'Section Settings',
+ sectionSetting: 'Nastavenia sekcie',
},
paragraphSetting: {
alignment: 'Zarovnanie',
@@ -122,23 +129,29 @@ const locale: typeof enUS = {
after: 'Za',
lineSpace: 'Riadkovanie',
multiSpace: 'Viacnásobné',
- atLeast: 'At Least (px)',
- exactly: 'Exactly (px)',
+ atLeast: 'Najmenej (px)',
+ exactly: 'Presne (px)',
fixedValue: 'Pevná hodnota (px)',
},
sectionSetting: {
- selectedSections: '{0} sections selected',
- columnCount: 'Column count',
- columnGap: 'Column gap',
- columnSeparator: 'Separator',
- none: 'None',
- betweenColumns: 'Between columns',
- sectionStart: 'Section start',
- unspecified: 'Unspecified',
- continuous: 'Continuous',
- nextPage: 'Next page',
- evenPage: 'Even page',
- oddPage: 'Odd page',
+ selectedSections: 'Vybraté sekcie: {0}',
+ multipleValues: 'Viaceré hodnoty',
+ columnCount: 'Počet stĺpcov',
+ columnGap: 'Medzera medzi stĺpcami',
+ columnSeparator: 'Oddeľovač',
+ none: 'Žiadny',
+ betweenColumns: 'Medzi stĺpcami',
+ sectionStart: 'Začiatok sekcie',
+ unspecified: 'Neurčené',
+ continuous: 'Priebežne',
+ nextColumn: 'Nasledujúci stĺpec',
+ nextPage: 'Nasledujúca strana',
+ evenPage: 'Párna strana',
+ oddPage: 'Nepárna strana',
+ pageSetup: 'Nastavenie strany',
+ pageWidth: 'Šírka strany',
+ pageHeight: 'Výška strany',
+ pageNumberStart: 'Počiatočné číslo strany',
},
},
rightClick: {
diff --git a/packages/docs-ui/src/locale/vi-VN.ts b/packages/docs-ui/src/locale/vi-VN.ts
index bd9aa7f4eb..9b08f9d09c 100644
--- a/packages/docs-ui/src/locale/vi-VN.ts
+++ b/packages/docs-ui/src/locale/vi-VN.ts
@@ -36,33 +36,40 @@ const locale: typeof enUS = {
main: 'Màu nền văn bản',
},
table: {
- main: 'Table',
- insert: 'Insert Table',
- colCount: 'Column count',
- rowCount: 'Row count',
+ main: 'Bảng',
+ insert: 'Chèn bảng',
+ colCount: 'Số cột',
+ rowCount: 'Số hàng',
},
resetColor: 'Đặt lại màu',
order: 'Danh sách có thứ tự',
unorder: 'Danh sách không thứ tự',
- checklist: 'Task list',
- documentFlavor: 'Modern Mode',
+ checklist: 'Danh sách công việc',
+ documentFlavor: 'Chế độ hiện đại',
alignLeft: 'Căn trái',
alignCenter: 'Căn giữa',
alignRight: 'Căn phải',
alignJustify: 'Căn đều hai bên',
- horizontalLine: 'Horizontal line',
+ horizontalLine: 'Đường ngang',
headerFooter: 'Đầu trang và chân trang',
pageSetup: 'Cài đặt trang',
+ breaks: 'Ngắt',
+ columnBreak: 'Ngắt cột',
+ sectionBreakNextPage: 'Ngắt phần (Trang tiếp theo)',
+ sectionBreakContinuous: 'Ngắt phần (Liên tục)',
+ sectionBreakNextColumn: 'Ngắt phần (Cột tiếp theo)',
+ sectionBreakEvenPage: 'Ngắt phần (Trang chẵn)',
+ sectionBreakOddPage: 'Ngắt phần (Trang lẻ)',
heading: {
- tooltip: 'Heading',
- normal: 'Normal text',
- leading1: 'Heading 1',
- leading2: 'Heading 2',
- leading3: 'Heading 3',
- leading4: 'Heading 4',
- leading5: 'Heading 5',
- title: 'Title',
- subTitle: 'Subtitle',
+ tooltip: 'Tiêu đề',
+ normal: 'Văn bản thường',
+ leading1: 'Tiêu đề 1',
+ leading2: 'Tiêu đề 2',
+ leading3: 'Tiêu đề 3',
+ leading4: 'Tiêu đề 4',
+ leading5: 'Tiêu đề 5',
+ title: 'Tiêu đề',
+ subTitle: 'Tiêu đề phụ',
},
},
table: {
@@ -77,7 +84,7 @@ const locale: typeof enUS = {
deleteTable: 'Xóa bảng',
},
headerFooter: {
- linkToPrevious: 'Link to previous',
+ linkToPrevious: 'Liên kết với phần trước',
header: 'Đầu trang',
footer: 'Chân trang',
panel: 'Cài đặt đầu trang và chân trang',
@@ -103,42 +110,48 @@ const locale: typeof enUS = {
},
menu: {
- paragraphSetting: 'Paragraph Setting',
- sectionSetting: 'Section Settings',
+ paragraphSetting: 'Cài đặt đoạn văn',
+ sectionSetting: 'Cài đặt phần',
},
slider: {
- paragraphSetting: 'Paragraph Setting',
- sectionSetting: 'Section Settings',
+ paragraphSetting: 'Cài đặt đoạn văn',
+ sectionSetting: 'Cài đặt phần',
},
paragraphSetting: {
- alignment: 'Alignment',
- indentation: 'Indentation',
- left: 'Left',
- right: 'Right',
- firstLine: 'First Line',
- hanging: 'Hanging',
- spacing: 'Spacing',
- before: 'Before',
- after: 'After',
- lineSpace: 'Line Space',
- multiSpace: 'Multi Space',
- atLeast: 'At Least (px)',
- exactly: 'Exactly (px)',
- fixedValue: 'Fixed Value(px)',
+ alignment: 'Căn chỉnh',
+ indentation: 'Thụt lề',
+ left: 'Trái',
+ right: 'Phải',
+ firstLine: 'Dòng đầu',
+ hanging: 'Treo',
+ spacing: 'Khoảng cách',
+ before: 'Trước',
+ after: 'Sau',
+ lineSpace: 'Giãn dòng',
+ multiSpace: 'Nhiều dòng',
+ atLeast: 'Tối thiểu (px)',
+ exactly: 'Chính xác (px)',
+ fixedValue: 'Giá trị cố định (px)',
},
sectionSetting: {
- selectedSections: '{0} sections selected',
- columnCount: 'Column count',
- columnGap: 'Column gap',
- columnSeparator: 'Separator',
- none: 'None',
- betweenColumns: 'Between columns',
- sectionStart: 'Section start',
- unspecified: 'Unspecified',
- continuous: 'Continuous',
- nextPage: 'Next page',
- evenPage: 'Even page',
- oddPage: 'Odd page',
+ selectedSections: 'Đã chọn {0} phần',
+ multipleValues: 'Nhiều giá trị',
+ columnCount: 'Số cột',
+ columnGap: 'Khoảng cách cột',
+ columnSeparator: 'Đường phân cách',
+ none: 'Không có',
+ betweenColumns: 'Giữa các cột',
+ sectionStart: 'Bắt đầu phần',
+ unspecified: 'Không xác định',
+ continuous: 'Liên tục',
+ nextColumn: 'Cột tiếp theo',
+ nextPage: 'Trang tiếp theo',
+ evenPage: 'Trang chẵn',
+ oddPage: 'Trang lẻ',
+ pageSetup: 'Thiết lập trang',
+ pageWidth: 'Chiều rộng trang',
+ pageHeight: 'Chiều cao trang',
+ pageNumberStart: 'Số trang bắt đầu',
},
},
rightClick: {
diff --git a/packages/docs-ui/src/locale/zh-CN.ts b/packages/docs-ui/src/locale/zh-CN.ts
index b0e605bc0f..1fb8ebe194 100644
--- a/packages/docs-ui/src/locale/zh-CN.ts
+++ b/packages/docs-ui/src/locale/zh-CN.ts
@@ -53,6 +53,13 @@ const locale: typeof enUS = {
horizontalLine: '水平分割线',
headerFooter: '页眉页脚',
pageSetup: '页面设置',
+ breaks: '分隔符',
+ columnBreak: '分栏符',
+ sectionBreakNextPage: '分节符(下一页)',
+ sectionBreakContinuous: '分节符(连续)',
+ sectionBreakNextColumn: '分节符(下一栏)',
+ sectionBreakEvenPage: '分节符(偶数页)',
+ sectionBreakOddPage: '分节符(奇数页)',
heading: {
tooltip: '标题',
normal: '普通文本',
@@ -128,6 +135,7 @@ const locale: typeof enUS = {
},
sectionSetting: {
selectedSections: '已选择 {0} 个节',
+ multipleValues: '多个值',
columnCount: '栏数',
columnGap: '栏间距',
columnSeparator: '分隔线',
@@ -136,9 +144,14 @@ const locale: typeof enUS = {
sectionStart: '节起始位置',
unspecified: '未指定',
continuous: '连续',
+ nextColumn: '下一栏',
nextPage: '下一页',
evenPage: '偶数页',
oddPage: '奇数页',
+ pageSetup: '页面设置',
+ pageWidth: '页面宽度',
+ pageHeight: '页面高度',
+ pageNumberStart: '起始页码',
},
},
rightClick: {
diff --git a/packages/docs-ui/src/locale/zh-HK.ts b/packages/docs-ui/src/locale/zh-HK.ts
index fe9e1f456d..56832f8a55 100644
--- a/packages/docs-ui/src/locale/zh-HK.ts
+++ b/packages/docs-ui/src/locale/zh-HK.ts
@@ -36,10 +36,10 @@ const locale: typeof enUS = {
main: '文字背景色',
},
table: {
- main: 'Table',
- insert: 'Insert Table',
- colCount: 'Column count',
- rowCount: 'Row count',
+ main: '表格',
+ insert: '插入表格',
+ colCount: '欄數',
+ rowCount: '列數',
},
resetColor: '重置顏色',
order: '有序列表',
@@ -50,31 +50,38 @@ const locale: typeof enUS = {
alignCenter: '居中對齊',
alignRight: '右對齊',
alignJustify: '兩端對齊',
- horizontalLine: 'Horizontal line',
+ horizontalLine: '水平線',
headerFooter: '頁眉頁腳',
pageSetup: '頁面設置',
+ breaks: '分隔符',
+ columnBreak: '分欄符',
+ sectionBreakNextPage: '分節符(下一頁)',
+ sectionBreakContinuous: '分節符(連續)',
+ sectionBreakNextColumn: '分節符(下一欄)',
+ sectionBreakEvenPage: '分節符(偶數頁)',
+ sectionBreakOddPage: '分節符(奇數頁)',
heading: {
- tooltip: 'Heading',
- normal: 'Normal text',
- leading1: 'Heading 1',
- leading2: 'Heading 2',
- leading3: 'Heading 3',
- leading4: 'Heading 4',
- leading5: 'Heading 5',
- title: 'Title',
- subTitle: 'Subtitle',
+ tooltip: '標題',
+ normal: '一般文字',
+ leading1: '標題 1',
+ leading2: '標題 2',
+ leading3: '標題 3',
+ leading4: '標題 4',
+ leading5: '標題 5',
+ title: '標題',
+ subTitle: '副標題',
},
},
table: {
- insert: 'Insert',
- insertRowAbove: 'Insert row above',
- insertRowBelow: 'Insert row below',
- insertColumnLeft: 'Insert column left',
- insertColumnRight: 'Insert column right',
- delete: 'Table delete',
- deleteRows: 'Delete row',
- deleteColumns: 'Delete column',
- deleteTable: 'Delete table',
+ insert: '插入',
+ insertRowAbove: '在上方插入列',
+ insertRowBelow: '在下方插入列',
+ insertColumnLeft: '在左側插入欄',
+ insertColumnRight: '在右側插入欄',
+ delete: '刪除表格',
+ deleteRows: '刪除列',
+ deleteColumns: '刪除欄',
+ deleteTable: '刪除表格',
},
headerFooter: {
linkToPrevious: '連結到上一節',
@@ -103,42 +110,48 @@ const locale: typeof enUS = {
},
menu: {
- paragraphSetting: 'Paragraph Setting',
- sectionSetting: 'Section Settings',
+ paragraphSetting: '段落設定',
+ sectionSetting: '節設定',
},
slider: {
- paragraphSetting: 'Paragraph Setting',
- sectionSetting: 'Section Settings',
+ paragraphSetting: '段落設定',
+ sectionSetting: '節設定',
},
paragraphSetting: {
- alignment: 'Alignment',
- indentation: 'Indentation',
- left: 'Left',
- right: 'Right',
- firstLine: 'First Line',
- hanging: 'Hanging',
- spacing: 'Spacing',
- before: 'Before',
- after: 'After',
- lineSpace: 'Line Space',
- multiSpace: 'Multi Space',
- atLeast: 'At Least (px)',
- exactly: 'Exactly (px)',
- fixedValue: 'Fixed Value(px)',
+ alignment: '對齊',
+ indentation: '縮排',
+ left: '左',
+ right: '右',
+ firstLine: '首行',
+ hanging: '凸排',
+ spacing: '間距',
+ before: '段前',
+ after: '段後',
+ lineSpace: '行距',
+ multiSpace: '多倍行距',
+ atLeast: '最小值 (px)',
+ exactly: '固定值 (px)',
+ fixedValue: '固定值 (px)',
},
sectionSetting: {
- selectedSections: '{0} sections selected',
- columnCount: 'Column count',
- columnGap: 'Column gap',
- columnSeparator: 'Separator',
- none: 'None',
- betweenColumns: 'Between columns',
- sectionStart: 'Section start',
- unspecified: 'Unspecified',
- continuous: 'Continuous',
- nextPage: 'Next page',
- evenPage: 'Even page',
- oddPage: 'Odd page',
+ selectedSections: '已選取 {0} 個節',
+ multipleValues: '多個值',
+ columnCount: '欄數',
+ columnGap: '欄間距',
+ columnSeparator: '分隔線',
+ none: '無',
+ betweenColumns: '欄之間',
+ sectionStart: '節起始位置',
+ unspecified: '未指定',
+ continuous: '接續本頁',
+ nextColumn: '下一欄',
+ nextPage: '下一頁',
+ evenPage: '偶數頁',
+ oddPage: '奇數頁',
+ pageSetup: '頁面設定',
+ pageWidth: '頁面寬度',
+ pageHeight: '頁面高度',
+ pageNumberStart: '起始頁碼',
},
},
rightClick: {
diff --git a/packages/docs-ui/src/locale/zh-TW.ts b/packages/docs-ui/src/locale/zh-TW.ts
index 7e27637737..58b3ced74b 100644
--- a/packages/docs-ui/src/locale/zh-TW.ts
+++ b/packages/docs-ui/src/locale/zh-TW.ts
@@ -36,10 +36,10 @@ const locale: typeof enUS = {
main: '文字背景色',
},
table: {
- main: 'Table',
- insert: 'Insert Table',
- colCount: 'Column count',
- rowCount: 'Row count',
+ main: '表格',
+ insert: '插入表格',
+ colCount: '欄數',
+ rowCount: '列數',
},
resetColor: '重置顏色',
order: '有序列表',
@@ -50,9 +50,16 @@ const locale: typeof enUS = {
alignCenter: '居中對齊',
alignRight: '右對齊',
alignJustify: '兩端對齊',
- horizontalLine: 'Horizontal line',
+ horizontalLine: '水平線',
headerFooter: '頁眉頁腳',
pageSetup: '頁面設置',
+ breaks: '分隔符',
+ columnBreak: '分欄符',
+ sectionBreakNextPage: '分節符(下一頁)',
+ sectionBreakContinuous: '分節符(連續)',
+ sectionBreakNextColumn: '分節符(下一欄)',
+ sectionBreakEvenPage: '分節符(偶數頁)',
+ sectionBreakOddPage: '分節符(奇數頁)',
heading: {
tooltip: '標題',
normal: '普通文字',
@@ -103,42 +110,48 @@ const locale: typeof enUS = {
},
menu: {
- paragraphSetting: 'Paragraph Setting',
- sectionSetting: 'Section Settings',
+ paragraphSetting: '段落設定',
+ sectionSetting: '節設定',
},
slider: {
- paragraphSetting: 'Paragraph Setting',
- sectionSetting: 'Section Settings',
+ paragraphSetting: '段落設定',
+ sectionSetting: '節設定',
},
paragraphSetting: {
- alignment: 'Alignment',
- indentation: 'Indentation',
- left: 'Left',
- right: 'Right',
- firstLine: 'First Line',
- hanging: 'Hanging',
- spacing: 'Spacing',
- before: 'Before',
- after: 'After',
- lineSpace: 'Line Space',
- multiSpace: 'Multi Space',
- atLeast: 'At Least (px)',
- exactly: 'Exactly (px)',
- fixedValue: 'Fixed Value(px)',
+ alignment: '對齊方式',
+ indentation: '縮排',
+ left: '左',
+ right: '右',
+ firstLine: '第一行',
+ hanging: '凸排',
+ spacing: '間距',
+ before: '段前',
+ after: '段後',
+ lineSpace: '行距',
+ multiSpace: '多倍行距',
+ atLeast: '至少 (px)',
+ exactly: '固定值 (px)',
+ fixedValue: '固定值 (px)',
},
sectionSetting: {
- selectedSections: '{0} sections selected',
- columnCount: 'Column count',
- columnGap: 'Column gap',
- columnSeparator: 'Separator',
- none: 'None',
- betweenColumns: 'Between columns',
- sectionStart: 'Section start',
- unspecified: 'Unspecified',
- continuous: 'Continuous',
- nextPage: 'Next page',
- evenPage: 'Even page',
- oddPage: 'Odd page',
+ selectedSections: '已選取 {0} 個節',
+ multipleValues: '多個值',
+ columnCount: '欄數',
+ columnGap: '欄間距',
+ columnSeparator: '分隔線',
+ none: '無',
+ betweenColumns: '欄之間',
+ sectionStart: '節起始位置',
+ unspecified: '未指定',
+ continuous: '接續本頁',
+ nextColumn: '下一欄',
+ nextPage: '下一頁',
+ evenPage: '偶數頁',
+ oddPage: '奇數頁',
+ pageSetup: '頁面設定',
+ pageWidth: '頁面寬度',
+ pageHeight: '頁面高度',
+ pageNumberStart: '起始頁碼',
},
},
rightClick: {
diff --git a/packages/docs-ui/src/menu/menu.ts b/packages/docs-ui/src/menu/menu.ts
index 394905ffcc..06f1ecddb6 100644
--- a/packages/docs-ui/src/menu/menu.ts
+++ b/packages/docs-ui/src/menu/menu.ts
@@ -31,6 +31,7 @@ import {
NAMED_STYLE_MAP,
NamedStyleType,
PresetListType,
+ SectionType,
ThemeService,
Tools,
UniverInstanceType,
@@ -88,6 +89,7 @@ import { SetParagraphNamedStyleCommand } from '../commands/commands/set-heading.
// import { SwitchDocModeCommand } from '../commands/commands/switch-doc-mode.command';
import { CreateDocTableCommand } from '../commands/commands/table/doc-table-create.command';
import { DocCreateTableOperation } from '../commands/operations/doc-create-table.operation';
+import { InsertDocumentColumnBreakOperation, InsertDocumentSectionBreakOperation } from '../commands/operations/insert-break.operation';
import { DocOpenPageSettingCommand } from '../commands/operations/open-page-setting.operation';
import { getCommandSkeleton } from '../commands/util';
import { IDocEmbedRuntimeFocusCoordinator } from '../services/doc-embed-integration.service';
@@ -209,7 +211,7 @@ export function disableMenuWhenHeaderFooterEditing(accessor: IAccessor): Observa
});
}
-function getHeaderFooterMenuHiddenObservable(
+function getTraditionalDocMenuHiddenObservable(
accessor: IAccessor
): Observable<boolean> {
const univerInstanceService = accessor.get(IUniverInstanceService);
@@ -1038,12 +1040,79 @@ export function HeaderFooterMenuItemFactory(accessor: IAccessor): IMenuButtonIte
type: MenuItemType.BUTTON,
icon: 'HeaderFooterIcon',
tooltip: 'docs-ui.toolbar.headerFooter',
- hidden$: combineLatest(getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC), getHeaderFooterMenuHiddenObservable(accessor), (one, two) => {
+ hidden$: combineLatest(getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC), getTraditionalDocMenuHiddenObservable(accessor), (one, two) => {
return one || two;
}),
};
}
+export const DOC_BREAKS_MENU_ID = 'doc.menu.breaks';
+export const DOC_SECTION_BREAK_NEXT_PAGE_MENU_ID = 'doc.menu.section-break.next-page';
+export const DOC_SECTION_BREAK_CONTINUOUS_MENU_ID = 'doc.menu.section-break.continuous';
+export const DOC_SECTION_BREAK_NEXT_COLUMN_MENU_ID = 'doc.menu.section-break.next-column';
+export const DOC_SECTION_BREAK_EVEN_PAGE_MENU_ID = 'doc.menu.section-break.even-page';
+export const DOC_SECTION_BREAK_ODD_PAGE_MENU_ID = 'doc.menu.section-break.odd-page';
+
+export function BreaksMenuFactory(accessor: IAccessor): IMenuItem<LocaleKey> {
+ return {
+ id: DOC_BREAKS_MENU_ID,
+ type: MenuItemType.SUBITEMS,
+ icon: 'ColumnIcon',
+ tooltip: 'docs-ui.toolbar.breaks',
+ disabled$: disableMenuWhenNoDocRange(accessor),
+ hidden$: combineLatest(
+ getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC),
+ getTraditionalDocMenuHiddenObservable(accessor),
+ (hidden, unsupported) => hidden || unsupported
+ ),
+ };
+}
+
+export function InsertColumnBreakMenuFactory(accessor: IAccessor): IMenuButtonItem<LocaleKey> {
+ return {
+ id: InsertDocumentColumnBreakOperation.id,
+ type: MenuItemType.BUTTON,
+ title: 'docs-ui.toolbar.columnBreak',
+ disabled$: disableMenuWhenNoDocRange(accessor),
+ };
+}
+
+function createSectionBreakMenuItem(
+ accessor: IAccessor,
+ id: string,
+ title: LocaleKey,
+ sectionType: SectionType
+): IMenuButtonItem<LocaleKey> {
+ return {
+ id,
+ commandId: InsertDocumentSectionBreakOperation.id,
+ params: { sectionType },
+ type: MenuItemType.BUTTON,
+ title,
+ disabled$: disableMenuWhenNoDocRange(accessor),
+ };
+}
+
+export function InsertNextPageSectionBreakMenuFactory(accessor: IAccessor): IMenuButtonItem<LocaleKey> {
+ return createSectionBreakMenuItem(accessor, DOC_SECTION_BREAK_NEXT_PAGE_MENU_ID, 'docs-ui.toolbar.sectionBreakNextPage', SectionType.NEXT_PAGE);
+}
+
+export function InsertContinuousSectionBreakMenuFactory(accessor: IAccessor): IMenuButtonItem<LocaleKey> {
+ return createSectionBreakMenuItem(accessor, DOC_SECTION_BREAK_CONTINUOUS_MENU_ID, 'docs-ui.toolbar.sectionBreakContinuous', SectionType.CONTINUOUS);
+}
+
+export function InsertNextColumnSectionBreakMenuFactory(accessor: IAccessor): IMenuButtonItem<LocaleKey> {
+ return createSectionBreakMenuItem(accessor, DOC_SECTION_BREAK_NEXT_COLUMN_MENU_ID, 'docs-ui.toolbar.sectionBreakNextColumn', SectionType.NEXT_COLUMN);
+}
+
+export function InsertEvenPageSectionBreakMenuFactory(accessor: IAccessor): IMenuButtonItem<LocaleKey> {
+ return createSectionBreakMenuItem(accessor, DOC_SECTION_BREAK_EVEN_PAGE_MENU_ID, 'docs-ui.toolbar.sectionBreakEvenPage', SectionType.EVEN_PAGE);
+}
+
+export function InsertOddPageSectionBreakMenuFactory(accessor: IAccessor): IMenuButtonItem<LocaleKey> {
+ return createSectionBreakMenuItem(accessor, DOC_SECTION_BREAK_ODD_PAGE_MENU_ID, 'docs-ui.toolbar.sectionBreakOddPage', SectionType.ODD_PAGE);
+}
+
export const TableIcon = 'GridIcon';
export const TABLE_MENU_ID = 'doc.menu.table';
diff --git a/packages/docs-ui/src/menu/schema.ts b/packages/docs-ui/src/menu/schema.ts
index b3f539969b..e617297a06 100644
--- a/packages/docs-ui/src/menu/schema.ts
+++ b/packages/docs-ui/src/menu/schema.ts
@@ -77,6 +77,7 @@ import {
import { DocCreateTableOperation } from '../commands/operations/doc-create-table.operation';
import { DocParagraphSettingPanelOperation } from '../commands/operations/doc-paragraph-setting-panel.operation';
import { DocSectionSettingPanelOperation } from '../commands/operations/doc-section-setting-panel.operation';
+import { InsertDocumentColumnBreakOperation } from '../commands/operations/insert-break.operation';
import { DocOpenPageSettingCommand } from '../commands/operations/open-page-setting.operation';
import {
CopyMenuFactory,
@@ -105,10 +106,17 @@ import {
AlignRightMenuItemFactory,
BackgroundColorSelectorMenuItemFactory,
BoldMenuItemFactory,
+ BreaksMenuFactory,
BulletListMenuItemFactory,
CheckListMenuItemFactory,
+ DOC_BREAKS_MENU_ID,
DOC_INSERT_EMOJI_MENU_ID,
DOC_INSERT_SYMBOL_MENU_ID,
+ DOC_SECTION_BREAK_CONTINUOUS_MENU_ID,
+ DOC_SECTION_BREAK_EVEN_PAGE_MENU_ID,
+ DOC_SECTION_BREAK_NEXT_COLUMN_MENU_ID,
+ DOC_SECTION_BREAK_NEXT_PAGE_MENU_ID,
+ DOC_SECTION_BREAK_ODD_PAGE_MENU_ID,
// DocSwitchModeMenuItemFactory,
EmojiPickerMenuItemFactory,
FLOAT_TEXT_STYLE_MENU_ID,
@@ -119,7 +127,13 @@ import {
HeaderFooterMenuItemFactory,
HeadingSelectorMenuItemFactory,
HorizontalLineFactory,
+ InsertColumnBreakMenuFactory,
+ InsertContinuousSectionBreakMenuFactory,
InsertDefaultTableMenuFactory,
+ InsertEvenPageSectionBreakMenuFactory,
+ InsertNextColumnSectionBreakMenuFactory,
+ InsertNextPageSectionBreakMenuFactory,
+ InsertOddPageSectionBreakMenuFactory,
InsertTableMenuFactory,
ItalicMenuItemFactory,
OrderListMenuItemFactory,
@@ -324,14 +338,43 @@ export const menuSchema: MenuSchemaType = {
gridLayout: { row: 1, column: 2, rowSpan: 2, showLabel: true },
menuItemFactory: HorizontalLineFactory,
},
- [DOC_INSERT_EMOJI_MENU_ID]: {
+ [DOC_BREAKS_MENU_ID]: {
order: 4,
- gridLayout: { row: 1, column: 3 },
+ gridLayout: { row: 1, column: 3, rowSpan: 2, showLabel: true },
+ menuItemFactory: BreaksMenuFactory,
+ [InsertDocumentColumnBreakOperation.id]: {
+ order: 0,
+ menuItemFactory: InsertColumnBreakMenuFactory,
+ },
+ [DOC_SECTION_BREAK_NEXT_PAGE_MENU_ID]: {
+ order: 1,
+ menuItemFactory: InsertNextPageSectionBreakMenuFactory,
+ },
+ [DOC_SECTION_BREAK_CONTINUOUS_MENU_ID]: {
+ order: 2,
+ menuItemFactory: InsertContinuousSectionBreakMenuFactory,
+ },
+ [DOC_SECTION_BREAK_NEXT_COLUMN_MENU_ID]: {
+ order: 3,
+ menuItemFactory: InsertNextColumnSectionBreakMenuFactory,
+ },
+ [DOC_SECTION_BREAK_EVEN_PAGE_MENU_ID]: {
+ order: 4,
+ menuItemFactory: InsertEvenPageSectionBreakMenuFactory,
+ },
+ [DOC_SECTION_BREAK_ODD_PAGE_MENU_ID]: {
+ order: 5,
+ menuItemFactory: InsertOddPageSectionBreakMenuFactory,
+ },
+ },
+ [DOC_INSERT_EMOJI_MENU_ID]: {
+ order: 5,
+ gridLayout: { row: 1, column: 4 },
menuItemFactory: EmojiPickerMenuItemFactory,
},
[DOC_INSERT_SYMBOL_MENU_ID]: {
- order: 5,
- gridLayout: { row: 2, column: 3 },
+ order: 6,
+ gridLayout: { row: 2, column: 4 },
menuItemFactory: SymbolPickerMenuItemFactory,
},
},
diff --git a/packages/docs-ui/src/plugin.ts b/packages/docs-ui/src/plugin.ts
index 1a109acc3e..51bd352c98 100644
--- a/packages/docs-ui/src/plugin.ts
+++ b/packages/docs-ui/src/plugin.ts
@@ -143,6 +143,7 @@ import { DocTableTabCommand } from './commands/commands/table/doc-table-tab.comm
import { MoveCursorOperation, MoveSelectionOperation } from './commands/operations/doc-cursor.operation';
import { DocParagraphSettingPanelOperation } from './commands/operations/doc-paragraph-setting-panel.operation';
import { DocSectionSettingPanelOperation } from './commands/operations/doc-section-setting-panel.operation';
+import { InsertDocumentColumnBreakOperation, InsertDocumentSectionBreakOperation } from './commands/operations/insert-break.operation';
import { DocOpenPageSettingCommand } from './commands/operations/open-page-setting.operation';
import { SetDocZoomRatioOperation } from './commands/operations/set-doc-zoom-ratio.operation';
import { defaultPluginConfig, DOCS_UI_PLUGIN_CONFIG_KEY } from './config/config';
@@ -356,6 +357,8 @@ export class UniverDocsUIPlugin extends Plugin {
DocSelectAllCommand,
DocParagraphSettingPanelOperation,
DocSectionSettingPanelOperation,
+ InsertDocumentColumnBreakOperation,
+ InsertDocumentSectionBreakOperation,
MoveCursorOperation,
MoveSelectionOperation,
ReplaceTextRunsCommand,
diff --git a/packages/docs-ui/src/views/section-setting/Setting.tsx b/packages/docs-ui/src/views/section-setting/Setting.tsx
index 0b169ba0ab..d647cc280b 100644
--- a/packages/docs-ui/src/views/section-setting/Setting.tsx
+++ b/packages/docs-ui/src/views/section-setting/Setting.tsx
@@ -16,14 +16,14 @@
import type { ReactNode } from 'react';
import type { LocaleKey } from '../../locale/types';
-import { ColumnSeparatorType, LocaleService, SectionType } from '@univerjs/core';
+import { ColumnSeparatorType, LocaleService, PageOrientType, SectionType } from '@univerjs/core';
import { InputNumber, Select } from '@univerjs/design';
import { useDependency, useObservable } from '@univerjs/ui';
-import { useEffect, useMemo } from 'react';
+import { useEffect } from 'react';
import { DocSectionSettingController } from '../../controllers/doc-section-setting.controller';
import { useSectionSetting } from './use-section-setting';
-function SettingRow(props: { label: ReactNode; children: ReactNode }) {
+function SettingRow(props: { label: ReactNode; unit?: string; children: ReactNode }) {
return (
<div className="univer-grid univer-min-h-8 univer-items-center univer-gap-3" style={{ gridTemplateColumns: 'minmax(0, 1fr) minmax(140px, 160px)' }}>
<div
@@ -33,6 +33,7 @@ function SettingRow(props: { label: ReactNode; children: ReactNode }) {
"
>
{props.label}
+ {props.unit}
</div>
<div className="univer-w-full univer-min-w-0">{props.children}</div>
</div>
@@ -43,21 +44,7 @@ export function SectionSetting() {
const localeService = useDependency(LocaleService);
const controller = useDependency(DocSectionSettingController);
const setting = useSectionSetting();
- const locale = useObservable(localeService.currentLocale$);
- const labels = useMemo(() => ({
- selectedSections: localeService.t<LocaleKey>('docs-ui.doc.sectionSetting.selectedSections', String(setting.selectedCount)),
- columnCount: localeService.t<LocaleKey>('docs-ui.doc.sectionSetting.columnCount'),
- columnGap: `${localeService.t<LocaleKey>('docs-ui.doc.sectionSetting.columnGap')}(px)`,
- columnSeparator: localeService.t<LocaleKey>('docs-ui.doc.sectionSetting.columnSeparator'),
- none: localeService.t<LocaleKey>('docs-ui.doc.sectionSetting.none'),
- betweenColumns: localeService.t<LocaleKey>('docs-ui.doc.sectionSetting.betweenColumns'),
- sectionStart: localeService.t<LocaleKey>('docs-ui.doc.sectionSetting.sectionStart'),
- unspecified: localeService.t<LocaleKey>('docs-ui.doc.sectionSetting.unspecified'),
- continuous: localeService.t<LocaleKey>('docs-ui.doc.sectionSetting.continuous'),
- nextPage: localeService.t<LocaleKey>('docs-ui.doc.sectionSetting.nextPage'),
- evenPage: localeService.t<LocaleKey>('docs-ui.doc.sectionSetting.evenPage'),
- oddPage: localeService.t<LocaleKey>('docs-ui.doc.sectionSetting.oddPage'),
- }), [locale, localeService, setting.selectedCount]);
+ useObservable(localeService.currentLocale$);
useEffect(() => {
if (!setting.valid) {
@@ -78,41 +65,189 @@ export function SectionSetting() {
dark:!univer-text-gray-300
"
>
- {labels.selectedSections}
+ {localeService.t<LocaleKey>('docs-ui.doc.sectionSetting.selectedSections', `${setting.selectedCount}`)}
</div>
)}
<div className="univer-grid univer-gap-3">
- <SettingRow label={labels.columnCount}>
- <InputNumber className="univer-w-full" min={1} max={12} step={1} precision={0} value={setting.columnCount} onChange={(value) => value != null && setting.setColumnCount(value)} />
+ <SettingRow label={localeService.t<LocaleKey>('docs-ui.doc.slider.sectionSetting')}>
+ <Select
+ className="univer-w-full"
+ value={setting.selectedSectionId ?? ''}
+ options={[
+ ...(setting.selectedSectionId == null
+ ? [{
+ label: localeService.t<LocaleKey>('docs-ui.doc.sectionSetting.multipleValues'),
+ value: '',
+ disabled: true,
+ }]
+ : []),
+ ...setting.sectionOptions,
+ ]}
+ onChange={setting.selectSection}
+ />
</SettingRow>
- <SettingRow label={labels.columnGap}>
- <InputNumber className="univer-w-full" min={0} max={1000} step={1} precision={1} value={setting.columnGap} onChange={(value) => value != null && setting.setColumnGap(value)} />
+ <SettingRow label={localeService.t<LocaleKey>('docs-ui.doc.sectionSetting.columnCount')}>
+ <InputNumber
+ aria-label={localeService.t<LocaleKey>('docs-ui.doc.sectionSetting.columnCount')}
+ className="univer-w-full"
+ min={1}
+ max={12}
+ step={1}
+ precision={0}
+ value={setting.columnCount}
+ onChange={(value) => value != null && setting.setColumnCount(value)}
+ />
+ </SettingRow>
+ <SettingRow label={localeService.t<LocaleKey>('docs-ui.doc.sectionSetting.columnGap')} unit=" (px)">
+ <InputNumber
+ aria-label={localeService.t<LocaleKey>('docs-ui.doc.sectionSetting.columnGap')}
+ className="univer-w-full"
+ min={0}
+ max={1000}
+ step={1}
+ precision={1}
+ value={setting.columnGap}
+ onChange={(value) => value != null && setting.setColumnGap(value)}
+ />
</SettingRow>
- <SettingRow label={labels.columnSeparator}>
+ <SettingRow label={localeService.t<LocaleKey>('docs-ui.doc.sectionSetting.columnSeparator')}>
<Select
className="univer-w-full"
- value={setting.separatorType == null ? '' : String(setting.separatorType)}
+ value={setting.separatorType == null ? '' : `${setting.separatorType}`}
options={[
- { label: labels.none, value: String(ColumnSeparatorType.NONE) },
- { label: labels.betweenColumns, value: String(ColumnSeparatorType.BETWEEN_EACH_COLUMN) },
+ ...(setting.separatorType == null
+ ? [{
+ label: localeService.t<LocaleKey>('docs-ui.doc.sectionSetting.multipleValues'),
+ value: '',
+ disabled: true,
+ }]
+ : []),
+ { label: localeService.t<LocaleKey>('docs-ui.doc.sectionSetting.none'), value: `${ColumnSeparatorType.NONE}` },
+ { label: localeService.t<LocaleKey>('docs-ui.doc.sectionSetting.betweenColumns'), value: `${ColumnSeparatorType.BETWEEN_EACH_COLUMN}` },
]}
onChange={(value) => setting.setSeparatorType(Number(value))}
/>
</SettingRow>
- <SettingRow label={labels.sectionStart}>
+ <SettingRow label={localeService.t<LocaleKey>('docs-ui.doc.sectionSetting.sectionStart')}>
<Select
className="univer-w-full"
- value={setting.sectionType == null ? '' : String(setting.sectionType)}
+ value={setting.sectionType == null ? '' : `${setting.sectionType}`}
options={[
- { label: labels.unspecified, value: String(SectionType.SECTION_TYPE_UNSPECIFIED) },
- { label: labels.continuous, value: String(SectionType.CONTINUOUS) },
- { label: labels.nextPage, value: String(SectionType.NEXT_PAGE) },
- { label: labels.evenPage, value: String(SectionType.EVEN_PAGE) },
- { label: labels.oddPage, value: String(SectionType.ODD_PAGE) },
+ ...(setting.sectionType == null
+ ? [{
+ label: localeService.t<LocaleKey>('docs-ui.doc.sectionSetting.multipleValues'),
+ value: '',
+ disabled: true,
+ }]
+ : []),
+ { label: localeService.t<LocaleKey>('docs-ui.doc.sectionSetting.unspecified'), value: `${SectionType.SECTION_TYPE_UNSPECIFIED}` },
+ { label: localeService.t<LocaleKey>('docs-ui.doc.sectionSetting.continuous'), value: `${SectionType.CONTINUOUS}` },
+ { label: localeService.t<LocaleKey>('docs-ui.doc.sectionSetting.nextColumn'), value: `${SectionType.NEXT_COLUMN}` },
+ { label: localeService.t<LocaleKey>('docs-ui.doc.sectionSetting.nextPage'), value: `${SectionType.NEXT_PAGE}` },
+ { label: localeService.t<LocaleKey>('docs-ui.doc.sectionSetting.evenPage'), value: `${SectionType.EVEN_PAGE}` },
+ { label: localeService.t<LocaleKey>('docs-ui.doc.sectionSetting.oddPage'), value: `${SectionType.ODD_PAGE}` },
]}
onChange={(value) => setting.setSectionType(Number(value))}
/>
</SettingRow>
+ <div className="univer-pt-2 univer-text-sm univer-font-medium">
+ {localeService.t<LocaleKey>('docs-ui.doc.sectionSetting.pageSetup')}
+ </div>
+ <SettingRow label={localeService.t<LocaleKey>('docs-ui.doc.sectionSetting.pageWidth')} unit=" (px)">
+ <InputNumber
+ aria-label={localeService.t<LocaleKey>('docs-ui.doc.sectionSetting.pageWidth')}
+ className="univer-w-full"
+ min={1}
+ step={1}
+ precision={1}
+ value={setting.pageWidth}
+ onChange={(value) => value != null && setting.setPageWidth(value)}
+ />
+ </SettingRow>
+ <SettingRow label={localeService.t<LocaleKey>('docs-ui.doc.sectionSetting.pageHeight')} unit=" (px)">
+ <InputNumber
+ aria-label={localeService.t<LocaleKey>('docs-ui.doc.sectionSetting.pageHeight')}
+ className="univer-w-full"
+ min={1}
+ step={1}
+ precision={1}
+ value={setting.pageHeight}
+ onChange={(value) => value != null && setting.setPageHeight(value)}
+ />
+ </SettingRow>
+ <SettingRow label={localeService.t<LocaleKey>('docs-ui.page-settings.orientation')}>
+ <Select
+ className="univer-w-full"
+ value={setting.pageOrient == null ? '' : `${setting.pageOrient}`}
+ options={[
+ ...(setting.pageOrient == null
+ ? [{
+ label: localeService.t<LocaleKey>('docs-ui.doc.sectionSetting.multipleValues'),
+ value: '',
+ disabled: true,
+ }]
+ : []),
+ { label: localeService.t<LocaleKey>('docs-ui.page-settings.portrait'), value: `${PageOrientType.PORTRAIT}` },
+ { label: localeService.t<LocaleKey>('docs-ui.page-settings.landscape'), value: `${PageOrientType.LANDSCAPE}` },
+ ]}
+ onChange={(value) => setting.setPageOrient(Number(value))}
+ />
+ </SettingRow>
+ <SettingRow label={localeService.t<LocaleKey>('docs-ui.page-settings.top')} unit=" (px)">
+ <InputNumber
+ aria-label={localeService.t<LocaleKey>('docs-ui.page-settings.top')}
+ className="univer-w-full"
+ min={0}
+ step={1}
+ precision={1}
+ value={setting.marginTop}
+ onChange={(value) => value != null && setting.setMarginTop(value)}
+ />
+ </SettingRow>
+ <SettingRow label={localeService.t<LocaleKey>('docs-ui.page-settings.bottom')} unit=" (px)">
+ <InputNumber
+ aria-label={localeService.t<LocaleKey>('docs-ui.page-settings.bottom')}
+ className="univer-w-full"
+ min={0}
+ step={1}
+ precision={1}
+ value={setting.marginBottom}
+ onChange={(value) => value != null && setting.setMarginBottom(value)}
+ />
+ </SettingRow>
+ <SettingRow label={localeService.t<LocaleKey>('docs-ui.page-settings.left')} unit=" (px)">
+ <InputNumber
+ aria-label={localeService.t<LocaleKey>('docs-ui.page-settings.left')}
+ className="univer-w-full"
+ min={0}
+ step={1}
+ precision={1}
+ value={setting.marginLeft}
+ onChange={(value) => value != null && setting.setMarginLeft(value)}
+ />
+ </SettingRow>
+ <SettingRow label={localeService.t<LocaleKey>('docs-ui.page-settings.right')} unit=" (px)">
+ <InputNumber
+ aria-label={localeService.t<LocaleKey>('docs-ui.page-settings.right')}
+ className="univer-w-full"
+ min={0}
+ step={1}
+ precision={1}
+ value={setting.marginRight}
+ onChange={(value) => value != null && setting.setMarginRight(value)}
+ />
+ </SettingRow>
+ <SettingRow label={localeService.t<LocaleKey>('docs-ui.doc.sectionSetting.pageNumberStart')}>
+ <InputNumber
+ aria-label={localeService.t<LocaleKey>('docs-ui.doc.sectionSetting.pageNumberStart')}
+ className="univer-w-full"
+ min={1}
+ step={1}
+ precision={0}
+ value={setting.pageNumberStart}
+ onChange={(value) => value != null && setting.setPageNumberStart(value)}
+ />
+ </SettingRow>
</div>
</div>
);
diff --git a/packages/docs-ui/src/views/section-setting/__tests__/use-section-setting.spec.ts b/packages/docs-ui/src/views/section-setting/__tests__/use-section-setting.spec.ts
index ce53cf2357..3ebbe05a67 100644
--- a/packages/docs-ui/src/views/section-setting/__tests__/use-section-setting.spec.ts
+++ b/packages/docs-ui/src/views/section-setting/__tests__/use-section-setting.spec.ts
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-import { ColumnSeparatorType, DataStreamTreeTokenType, DocumentDataModel, SectionType } from '@univerjs/core';
+import { ColumnSeparatorType, DataStreamTreeTokenType, DocumentDataModel, PageOrientType, SectionType } from '@univerjs/core';
import { describe, expect, it } from 'vitest';
-import { createSectionColumnUpdates, getSectionSettingValues, getSelectedSections } from '../use-section-setting';
+import { createSectionColumnUpdates, createSectionOrientationUpdates, getSectionSettingValues, getSelectedSections } from '../use-section-setting';
describe('section setting selection', () => {
it('maps ranges to top-level sections by their stable ids', () => {
@@ -68,11 +68,19 @@ describe('section setting selection', () => {
},
];
- expect(getSectionSettingValues(sections)).toEqual({
+ expect(getSectionSettingValues(sections, {})).toEqual({
columnCount: undefined,
columnGap: undefined,
separatorType: undefined,
sectionType: undefined,
+ pageWidth: undefined,
+ pageHeight: undefined,
+ pageOrient: undefined,
+ marginTop: 0,
+ marginBottom: 0,
+ marginLeft: 0,
+ marginRight: 0,
+ pageNumberStart: 1,
});
});
@@ -103,4 +111,19 @@ describe('section setting selection', () => {
expect(updates[0].config.columnProperties?.[0].paddingEnd).toBe(24);
expect(updates[1].config.columnProperties?.[0].paddingEnd).toBe(24);
});
+
+ it('swaps page dimensions when changing a section orientation', () => {
+ expect(createSectionOrientationUpdates([{
+ sectionId: 'section_1',
+ startIndex: 2,
+ pageSize: { width: 600, height: 800 },
+ pageOrient: PageOrientType.PORTRAIT,
+ }], {}, PageOrientType.LANDSCAPE)).toEqual([{
+ sectionId: 'section_1',
+ config: {
+ pageOrient: PageOrientType.LANDSCAPE,
+ pageSize: { width: 800, height: 600 },
+ },
+ }]);
+ });
});
diff --git a/packages/docs-ui/src/views/section-setting/use-section-setting.ts b/packages/docs-ui/src/views/section-setting/use-section-setting.ts
index bc729706dd..d4a0b2313d 100644
--- a/packages/docs-ui/src/views/section-setting/use-section-setting.ts
+++ b/packages/docs-ui/src/views/section-setting/use-section-setting.ts
@@ -21,6 +21,7 @@ import {
DocumentFlavor,
ICommandService,
IUniverInstanceService,
+ PageOrientType,
SectionType,
UniverInstanceType,
} from '@univerjs/core';
@@ -33,6 +34,7 @@ import {
import { useDependency, useObservable } from '@univerjs/ui';
import { useMemo } from 'react';
import { combineLatest, map, startWith } from 'rxjs';
+import { DocSectionSettingController } from '../../controllers/doc-section-setting.controller';
const DEFAULT_SECTION_COLUMN_GAP = 18;
@@ -41,6 +43,14 @@ export interface ISectionSettingValues {
columnGap: number | undefined;
separatorType: ColumnSeparatorType | undefined;
sectionType: SectionType | undefined;
+ pageWidth: number | undefined;
+ pageHeight: number | undefined;
+ pageOrient: PageOrientType | undefined;
+ marginTop: number | undefined;
+ marginBottom: number | undefined;
+ marginLeft: number | undefined;
+ marginRight: number | undefined;
+ pageNumberStart: number | undefined;
}
function getCommonValue<T>(values: T[]): T | undefined {
@@ -56,12 +66,20 @@ function getSectionColumnGap(section: ISectionBreak): number {
return section.columnProperties?.[0]?.paddingEnd ?? DEFAULT_SECTION_COLUMN_GAP;
}
-export function getSectionSettingValues(sections: ISectionBreak[]): ISectionSettingValues {
+export function getSectionSettingValues(sections: ISectionBreak[], documentStyle: IDocumentStyle): ISectionSettingValues {
return {
columnCount: getCommonValue(sections.map(getSectionColumnCount)),
columnGap: getCommonValue(sections.map(getSectionColumnGap)),
separatorType: getCommonValue(sections.map((section) => section.columnSeparatorType ?? ColumnSeparatorType.NONE)),
sectionType: getCommonValue(sections.map((section) => section.sectionType ?? SectionType.SECTION_TYPE_UNSPECIFIED)),
+ pageWidth: getCommonValue(sections.map((section) => section.pageSize?.width ?? documentStyle.pageSize?.width)),
+ pageHeight: getCommonValue(sections.map((section) => section.pageSize?.height ?? documentStyle.pageSize?.height)),
+ pageOrient: getCommonValue(sections.map((section) => section.pageOrient ?? documentStyle.pageOrient)),
+ marginTop: getCommonValue(sections.map((section) => section.marginTop ?? documentStyle.marginTop ?? 0)),
+ marginBottom: getCommonValue(sections.map((section) => section.marginBottom ?? documentStyle.marginBottom ?? 0)),
+ marginLeft: getCommonValue(sections.map((section) => section.marginLeft ?? documentStyle.marginLeft ?? 0)),
+ marginRight: getCommonValue(sections.map((section) => section.marginRight ?? documentStyle.marginRight ?? 0)),
+ pageNumberStart: getCommonValue(sections.map((section) => section.pageNumberStart ?? documentStyle.pageNumberStart ?? 1)),
};
}
@@ -82,6 +100,26 @@ export function createSectionColumnUpdates(
});
}
+export function createSectionOrientationUpdates(
+ sections: ISectionBreak[],
+ documentStyle: IDocumentStyle,
+ pageOrient: PageOrientType
+): IDocumentSectionUpdate[] {
+ return sections.map((section) => {
+ const currentOrient = section.pageOrient ?? documentStyle.pageOrient ?? PageOrientType.PORTRAIT;
+ const currentPageSize = section.pageSize ?? documentStyle.pageSize;
+ return {
+ sectionId: section.sectionId,
+ config: {
+ pageOrient,
+ ...(currentOrient !== pageOrient && currentPageSize?.width != null && currentPageSize.height != null
+ ? { pageSize: { width: currentPageSize.height, height: currentPageSize.width } }
+ : {}),
+ },
+ };
+ });
+}
+
export function getSelectedSections(documentDataModel: DocumentDataModel, ranges: Readonly<ITextRangeParam[]>): ISectionBreak[] {
const body = documentDataModel.getBody();
if (!body || ranges.length === 0 || ranges.some((range) => Boolean(range.segmentId))) {
@@ -99,10 +137,28 @@ export function getSelectedSections(documentDataModel: DocumentDataModel, ranges
});
}
+function navigateToSection(
+ controller: DocSectionSettingController,
+ documentDataModel: DocumentDataModel | null | undefined,
+ sections: ISectionBreak[],
+ sectionId: string
+): void {
+ const index = sections.findIndex((section) => section.sectionId === sectionId);
+ if (!documentDataModel || index < 0) {
+ return;
+ }
+ controller.navigateToSectionEnd(
+ documentDataModel.getUnitId(),
+ index === 0 ? 0 : sections[index - 1].startIndex + 1,
+ sections[index].startIndex
+ );
+}
+
export function useSectionSetting() {
const commandService = useDependency(ICommandService);
const instanceService = useDependency(IUniverInstanceService);
const selectionManager = useDependency(DocSelectionManagerService);
+ const controller = useDependency(DocSectionSettingController);
const documentDataModel = useObservable(useMemo(
() => instanceService.getCurrentTypeOfUnit$<DocumentDataModel>(UniverInstanceType.UNIVER_DOC),
[instanceService]
@@ -121,7 +177,12 @@ export function useSectionSetting() {
false,
[documentDataModel, selectionManager]
);
- const values = getSectionSettingValues(sections);
+ const documentStyle = documentDataModel?.getDocumentStyle() ?? {};
+ const values = getSectionSettingValues(sections, documentStyle);
+ const body = documentDataModel?.getBody();
+ const allSections = documentDataModel?.getDocumentStyle().documentFlavor === DocumentFlavor.TRADITIONAL && body
+ ? getTopLevelSectionBreaks(body)
+ : [];
const update = (updates: IDocumentSectionUpdate[]) => {
if (!documentDataModel || updates.length === 0) {
@@ -140,7 +201,15 @@ export function useSectionSetting() {
return {
valid: Boolean(documentDataModel && sections.length > 0),
selectedCount: sections.length,
+ sectionOptions: allSections.map((section, index) => ({
+ label: `#${index + 1}`,
+ value: section.sectionId,
+ })),
+ selectedSectionId: sections.length === 1 ? sections[0].sectionId : undefined,
...values,
+ selectSection(sectionId: string) {
+ navigateToSection(controller, documentDataModel ?? undefined, allSections, sectionId);
+ },
setColumnCount(value: number) {
const next = Math.max(1, Math.round(value));
return update(documentDataModel
@@ -159,5 +228,35 @@ export function useSectionSetting() {
setSectionType(value: SectionType) {
return updateAll({ sectionType: value });
},
+ setPageWidth(value: number) {
+ return update(sections.map((section) => ({
+ sectionId: section.sectionId,
+ config: { pageSize: { ...documentStyle.pageSize, ...section.pageSize, width: Math.max(1, value) } },
+ })));
+ },
+ setPageHeight(value: number) {
+ return update(sections.map((section) => ({
+ sectionId: section.sectionId,
+ config: { pageSize: { ...documentStyle.pageSize, ...section.pageSize, height: Math.max(1, value) } },
+ })));
+ },
+ setPageOrient(value: PageOrientType) {
+ return update(createSectionOrientationUpdates(sections, documentStyle, value));
+ },
+ setMarginTop(value: number) {
+ return updateAll({ marginTop: Math.max(0, value) });
+ },
+ setMarginBottom(value: number) {
+ return updateAll({ marginBottom: Math.max(0, value) });
+ },
+ setMarginLeft(value: number) {
+ return updateAll({ marginLeft: Math.max(0, value) });
+ },
+ setMarginRight(value: number) {
+ return updateAll({ marginRight: Math.max(0, value) });
+ },
+ setPageNumberStart(value: number) {
+ return updateAll({ pageNumberStart: Math.max(1, Math.round(value)) });
+ },
};
}
diff --git a/packages/docs/src/commands/commands/__tests__/update-document-section.command.spec.ts b/packages/docs/src/commands/commands/__tests__/update-document-section.command.spec.ts
index d193ada058..dcfc62b2a5 100644
--- a/packages/docs/src/commands/commands/__tests__/update-document-section.command.spec.ts
+++ b/packages/docs/src/commands/commands/__tests__/update-document-section.command.spec.ts
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-import { ColumnSeparatorType, DocumentFlavor, ICommandService, SectionType } from '@univerjs/core';
+import { ColumnSeparatorType, DataStreamTreeTokenType, DocumentFlavor, ICommandService, IUndoRedoService, PageOrientType, RedoCommand, SectionType, UndoCommand } from '@univerjs/core';
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { createDocumentData, createTestBed } from '../../../facade/__tests__/create-test-bed';
-import { UpdateDocumentSectionCommand } from '../update-document-section.command';
+import { InsertDocumentColumnBreakCommand, InsertDocumentSectionBreakCommand, UpdateDocumentSectionCommand } from '../update-document-section.command';
describe('UpdateDocumentSectionCommand', () => {
let testBed: ReturnType<typeof createTestBed>;
@@ -97,4 +97,94 @@ describe('UpdateDocumentSectionCommand', () => {
updates: [{ sectionId: 'section_one', config: { sectionType: SectionType.NEXT_PAGE } }],
})).toBe(false);
});
+
+ it('rejects invalid page geometry without mutating the section', () => {
+ expect(commandService.syncExecuteCommand(UpdateDocumentSectionCommand.id, {
+ unitId: 'section-command-doc',
+ updates: [{ sectionId: 'section_one', config: { marginLeft: -1 } }],
+ })).toBe(false);
+ expect(commandService.syncExecuteCommand(UpdateDocumentSectionCommand.id, {
+ unitId: 'section-command-doc',
+ updates: [{
+ sectionId: 'section_one',
+ config: {
+ pageSize: { width: 100, height: 100 },
+ marginLeft: 50,
+ marginRight: 50,
+ },
+ }],
+ })).toBe(false);
+ expect(testBed.doc.getBody()?.sectionBreaks?.[0].marginLeft).toBeUndefined();
+ });
+
+ it('updates section page geometry and numbering through one rich-text mutation', () => {
+ expect(commandService.syncExecuteCommand(UpdateDocumentSectionCommand.id, {
+ unitId: 'section-command-doc',
+ updates: [{
+ sectionId: 'section_one',
+ config: {
+ pageNumberStart: 5,
+ pageSize: { width: 960, height: 720 },
+ pageOrient: PageOrientType.LANDSCAPE,
+ marginTop: 48,
+ marginBottom: 56,
+ marginLeft: 64,
+ marginRight: 72,
+ },
+ }],
+ })).toBe(true);
+
+ expect(testBed.doc.getBody()?.sectionBreaks?.[0]).toMatchObject({
+ pageNumberStart: 5,
+ pageSize: { width: 960, height: 720 },
+ pageOrient: PageOrientType.LANDSCAPE,
+ marginTop: 48,
+ marginBottom: 56,
+ marginLeft: 64,
+ marginRight: 72,
+ });
+ });
+
+ it('inserts a top-level column break with OOXML round-trip metadata', () => {
+ expect(commandService.syncExecuteCommand(InsertDocumentColumnBreakCommand.id, {
+ unitId: 'section-command-doc',
+ offset: 2,
+ })).toBe(true);
+
+ const body = testBed.doc.getBody()!;
+ expect(body.dataStream[2]).toBe(DataStreamTreeTokenType.COLUMN_BREAK);
+ expect(body.customRanges).toContainEqual(expect.objectContaining({
+ startIndex: 2,
+ endIndex: 2,
+ wholeEntity: true,
+ properties: { docxBreakType: 'column' },
+ }));
+ });
+
+ it('inserts a boundary and configures the following section as one undoable mutation', () => {
+ testBed.get(IUndoRedoService);
+ const originalBody = structuredClone(testBed.doc.getBody())!;
+
+ expect(commandService.syncExecuteCommand(InsertDocumentSectionBreakCommand.id, {
+ unitId: 'section-command-doc',
+ offset: 5,
+ sectionId: 'section_inserted',
+ nextSectionType: SectionType.ODD_PAGE,
+ })).toBe(true);
+ expect(testBed.doc.getBody()?.sectionBreaks).toEqual([
+ expect.objectContaining({ sectionId: 'section_one', startIndex: 4 }),
+ expect.objectContaining({ sectionId: 'section_inserted', startIndex: 5 }),
+ expect.objectContaining({ sectionId: 'section_two', startIndex: 10, sectionType: SectionType.ODD_PAGE }),
+ ]);
+
+ expect(commandService.syncExecuteCommand(UndoCommand.id)).toBe(true);
+ expect(testBed.doc.getBody()?.dataStream).toBe(originalBody.dataStream);
+ expect(testBed.doc.getBody()?.sectionBreaks).toEqual(originalBody.sectionBreaks);
+ expect(commandService.syncExecuteCommand(RedoCommand.id)).toBe(true);
+ expect(testBed.doc.getBody()?.sectionBreaks).toEqual([
+ expect.objectContaining({ sectionId: 'section_one', startIndex: 4 }),
+ expect.objectContaining({ sectionId: 'section_inserted', startIndex: 5 }),
+ expect.objectContaining({ sectionId: 'section_two', startIndex: 10, sectionType: SectionType.ODD_PAGE }),
+ ]);
+ });
});
diff --git a/packages/docs/src/commands/commands/update-document-section.command.ts b/packages/docs/src/commands/commands/update-document-section.command.ts
index 1858652541..0c38cdd023 100644
--- a/packages/docs/src/commands/commands/update-document-section.command.ts
+++ b/packages/docs/src/commands/commands/update-document-section.command.ts
@@ -14,13 +14,17 @@
* limitations under the License.
*/
-import type { DocumentDataModel, ICommand, IMutationInfo, ISectionBreak } from '@univerjs/core';
+import type { DocumentDataModel, ICommand, IDocumentBody, IMutationInfo, ISectionBreak } from '@univerjs/core';
import type { IRichTextEditingMutationParams } from '../mutations/core-editing.mutation';
import {
+ ColumnSeparatorType,
CommandType,
containsInteriorInsertionOffset,
+ CustomRangeType,
DataStreamTreeTokenType,
DocumentFlavor,
+ DocxBreakType,
+ generateRandomId,
getBlockRangeInterval,
getColumnGroupRangeInterval,
getRichTextEditPath,
@@ -29,12 +33,15 @@ import {
IUniverInstanceService,
JSONX,
MemoryCursor,
+ PageOrientType,
+ SectionType,
TextX,
TextXActionType,
Tools,
UniverInstanceType,
UpdateDocsAttributeType,
} from '@univerjs/core';
+import { getSectionContentWidth } from '../../utils/section-columns';
import { getTopLevelSectionBreaks } from '../../utils/sections';
import { RichTextEditingMutation } from '../mutations/core-editing.mutation';
@@ -55,6 +62,7 @@ export interface IInsertDocumentSectionBreakCommandParams {
offset: number;
sectionId: string;
config?: Partial<IDocumentSectionConfig>;
+ nextSectionType?: SectionType;
}
export interface IDeleteDocumentSectionBreakCommandParams {
@@ -62,6 +70,11 @@ export interface IDeleteDocumentSectionBreakCommandParams {
sectionId: string;
}
+export interface IInsertDocumentColumnBreakCommandParams {
+ unitId: string;
+ offset: number;
+}
+
export const UpdateDocumentSectionCommand: ICommand<IUpdateDocumentSectionCommandParams> = {
id: 'doc.command.update-section',
type: CommandType.COMMAND,
@@ -93,6 +106,13 @@ export const UpdateDocumentSectionCommand: ICommand<IUpdateDocumentSectionComman
if (sections.length !== selectedIds.size) {
return false;
}
+ const documentStyle = documentDataModel.getDocumentStyle();
+ if (sections.some((section) => !isValidSectionConfig(
+ { ...section, ...updates.get(section.sectionId) },
+ documentStyle
+ ))) {
+ return false;
+ }
const cursor = new MemoryCursor();
const textX = new TextX();
@@ -141,18 +161,19 @@ export const InsertDocumentSectionBreakCommand: ICommand<IInsertDocumentSectionB
return false;
}
const context = getTraditionalDocumentContext(accessor, params.unitId);
- if (!context || !params.sectionId || !Number.isInteger(params.offset)) {
+ if (!context || !params.sectionId || !Number.isInteger(params.offset) ||
+ (params.nextSectionType != null && !isValidEnumValue(SectionType, params.nextSectionType))) {
return false;
}
const { body, documentDataModel, commandService } = context;
- if (
- params.offset < 0 ||
- params.offset > body.dataStream.length ||
- body.sectionBreaks?.some((section) => section.sectionId === params.sectionId) ||
- body.tables?.some((range) => containsInteriorInsertionOffset(getTableRangeInterval(range), params.offset)) ||
- body.columnGroups?.some((range) => containsInteriorInsertionOffset(getColumnGroupRangeInterval(range), params.offset)) ||
- body.blockRanges?.some((range) => containsInteriorInsertionOffset(getBlockRangeInterval(range), params.offset))
- ) {
+ if (!isValidTopLevelInsertionOffset(body, params.offset) ||
+ body.sectionBreaks?.some((section) => section.sectionId === params.sectionId)) {
+ return false;
+ }
+ const nextSection = params.nextSectionType == null
+ ? undefined
+ : getTopLevelSectionBreaks(body).find((section) => section.startIndex >= params.offset);
+ if (params.nextSectionType != null && !nextSection) {
return false;
}
@@ -166,10 +187,55 @@ export const InsertDocumentSectionBreakCommand: ICommand<IInsertDocumentSectionB
startIndex: 0,
}],
});
+ if (nextSection && params.nextSectionType != null) {
+ textX.retain(nextSection.startIndex - params.offset);
+ textX.push({
+ t: TextXActionType.RETAIN,
+ len: 1,
+ coverType: UpdateDocsAttributeType.REPLACE,
+ body: {
+ dataStream: '',
+ sectionBreaks: [{
+ ...Tools.deepClone(nextSection),
+ sectionType: params.nextSectionType,
+ startIndex: 0,
+ }],
+ },
+ });
+ }
return executeSectionTextX(commandService, documentDataModel, textX, InsertDocumentSectionBreakCommand.id);
},
};
+export const InsertDocumentColumnBreakCommand: ICommand<IInsertDocumentColumnBreakCommandParams> = {
+ id: 'doc.command.insert-column-break',
+ type: CommandType.COMMAND,
+ handler: (accessor, params) => {
+ if (!params) {
+ return false;
+ }
+ const context = getTraditionalDocumentContext(accessor, params.unitId);
+ if (!context || !isValidTopLevelInsertionOffset(context.body, params.offset)) {
+ return false;
+ }
+
+ const textX = new TextX();
+ textX.retain(params.offset);
+ textX.insert(1, {
+ dataStream: DataStreamTreeTokenType.COLUMN_BREAK,
+ customRanges: [{
+ startIndex: 0,
+ endIndex: 0,
+ rangeId: `docx-break-${generateRandomId()}`,
+ rangeType: CustomRangeType.CUSTOM,
+ wholeEntity: true,
+ properties: { docxBreakType: DocxBreakType.COLUMN },
+ }],
+ });
+ return executeSectionTextX(context.commandService, context.documentDataModel, textX, InsertDocumentColumnBreakCommand.id);
+ },
+};
+
export const DeleteDocumentSectionBreakCommand: ICommand<IDeleteDocumentSectionBreakCommandParams> = {
id: 'doc.command.delete-section-break',
type: CommandType.COMMAND,
@@ -186,7 +252,7 @@ export const DeleteDocumentSectionBreakCommand: ICommand<IDeleteDocumentSectionB
return false;
}
const section = sections.find((item) => item.sectionId === params.sectionId);
- if (!section) {
+ if (!section || section === sections.at(-1)) {
return false;
}
@@ -214,6 +280,66 @@ function getTraditionalDocumentContext(accessor: Parameters<typeof UpdateDocumen
};
}
+function isValidTopLevelInsertionOffset(body: IDocumentBody, offset: number): boolean {
+ return Number.isInteger(offset) &&
+ offset >= 0 &&
+ offset <= body.dataStream.length &&
+ !body.tables?.some((range) => containsInteriorInsertionOffset(getTableRangeInterval(range), offset)) &&
+ !body.columnGroups?.some((range) => containsInteriorInsertionOffset(getColumnGroupRangeInterval(range), offset)) &&
+ !body.blockRanges?.some((range) => containsInteriorInsertionOffset(getBlockRangeInterval(range), offset));
+}
+
+function isValidSectionConfig(
+ section: ISectionBreak,
+ documentStyle: ReturnType<DocumentDataModel['getDocumentStyle']>
+): boolean {
+ if (section.sectionType != null && !isValidEnumValue(SectionType, section.sectionType)) {
+ return false;
+ }
+ if (section.pageOrient != null && !isValidEnumValue(PageOrientType, section.pageOrient)) {
+ return false;
+ }
+ if (section.columnSeparatorType != null && !isValidEnumValue(ColumnSeparatorType, section.columnSeparatorType)) {
+ return false;
+ }
+ if (section.pageNumberStart != null &&
+ (!Number.isInteger(section.pageNumberStart) || section.pageNumberStart < 1)) {
+ return false;
+ }
+ if (section.pageSize &&
+ (!isPositiveFinite(section.pageSize.width) || !isPositiveFinite(section.pageSize.height))) {
+ return false;
+ }
+ if ([section.marginTop, section.marginBottom, section.marginLeft, section.marginRight]
+ .some((margin) => margin != null && (!Number.isFinite(margin) || margin < 0))) {
+ return false;
+ }
+ const pageSize = section.pageSize ?? documentStyle.pageSize;
+ const marginTop = section.marginTop ?? documentStyle.marginTop ?? 0;
+ const marginBottom = section.marginBottom ?? documentStyle.marginBottom ?? 0;
+ const marginLeft = section.marginLeft ?? documentStyle.marginLeft ?? 0;
+ const marginRight = section.marginRight ?? documentStyle.marginRight ?? 0;
+ if ((pageSize?.width != null && marginLeft + marginRight >= pageSize.width) ||
+ (pageSize?.height != null && marginTop + marginBottom >= pageSize.height)) {
+ return false;
+ }
+ const columns = section.columnProperties ?? [];
+ if (columns.some(({ width, paddingEnd }) =>
+ !Number.isFinite(width) || !Number.isFinite(paddingEnd) || width < 0 || paddingEnd < 0)) {
+ return false;
+ }
+ return columns.reduce((sum, { width, paddingEnd }) => sum + width + paddingEnd, 0) <=
+ getSectionContentWidth(documentStyle, section);
+}
+
+function isPositiveFinite(value: number | undefined): boolean {
+ return value != null && Number.isFinite(value) && value > 0;
+}
+
+function isValidEnumValue(enumObject: object, value: number): boolean {
+ return Object.values(enumObject).includes(value);
+}
+
function executeSectionTextX(
commandService: ICommandService,
documentDataModel: DocumentDataModel,
diff --git a/packages/docs/src/facade/__tests__/f-document.node.spec.ts b/packages/docs/src/facade/__tests__/f-document.node.spec.ts
new file mode 100644
index 0000000000..e43d2e08f1
--- /dev/null
+++ b/packages/docs/src/facade/__tests__/f-document.node.spec.ts
@@ -0,0 +1,79 @@
+/**
+ * Copyright 2023-present DreamNum Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// @vitest-environment node
+
+import type { Univer } from '@univerjs/core';
+import { ColumnSeparatorType, DocumentFlavor, PageOrientType, SectionType } from '@univerjs/core';
+import { afterEach, describe, expect, it } from 'vitest';
+import { createDocumentData, createTestBed } from './create-test-bed';
+
+describe('FDocument in Node', () => {
+ let univer: Univer | undefined;
+
+ afterEach(() => {
+ univer?.dispose();
+ });
+
+ it('updates traditional sections without loading Docs UI or browser globals', () => {
+ const data = createDocumentData('node-section-facade', {
+ dataStream: 'Alpha\rBeta\r\n',
+ paragraphs: [
+ { startIndex: 5, paragraphId: 'alpha' },
+ { startIndex: 10, paragraphId: 'beta' },
+ ],
+ sectionBreaks: [{ sectionId: 'section_fixture_node', startIndex: 11 }],
+ });
+ data.documentStyle = { ...data.documentStyle, documentFlavor: DocumentFlavor.TRADITIONAL };
+ const testBed = createTestBed(data);
+ univer = testBed.univer;
+ const document = testBed.univerAPI.getActiveDocument();
+ const section = document?.getSection(0);
+
+ expect(globalThis).not.toHaveProperty('window');
+ expect(section?.setColumns(2, {
+ gap: 18,
+ separator: ColumnSeparatorType.BETWEEN_EACH_COLUMN,
+ })).toBe(true);
+ expect(section?.setSectionType(SectionType.NEXT_PAGE)).toBe(true);
+ expect(section?.setPageSetup({
+ pageNumberStart: 7,
+ pageSize: { width: 960, height: 720 },
+ pageOrient: PageOrientType.LANDSCAPE,
+ marginTop: 48,
+ marginBottom: 48,
+ marginLeft: 64,
+ marginRight: 64,
+ })).toBe(true);
+ expect(document?.insertColumnBreak(3)).toBe(true);
+
+ expect(section?.describe()).toMatchObject({
+ columnCount: 2,
+ columnSeparatorType: ColumnSeparatorType.BETWEEN_EACH_COLUMN,
+ sectionType: SectionType.NEXT_PAGE,
+ config: {
+ pageNumberStart: 7,
+ pageSize: { width: 960, height: 720 },
+ pageOrient: PageOrientType.LANDSCAPE,
+ },
+ });
+ expect(document?.save().body?.customRanges).toContainEqual(expect.objectContaining({
+ startIndex: 3,
+ endIndex: 3,
+ properties: { docxBreakType: 'column' },
+ }));
+ });
+});
diff --git a/packages/docs/src/facade/__tests__/f-document.spec.ts b/packages/docs/src/facade/__tests__/f-document.spec.ts
index 7f7dc4ca9c..56d7d420d2 100644
--- a/packages/docs/src/facade/__tests__/f-document.spec.ts
+++ b/packages/docs/src/facade/__tests__/f-document.spec.ts
@@ -16,7 +16,7 @@
import type { IDocumentData, Univer } from '@univerjs/core';
import type { FDocument } from '../f-document';
-import { ColumnSeparatorType, DataStreamTreeTokenType, DocumentFlavor, ICommandService, IResourceManagerService, IUndoRedoService, SectionType, UniverInstanceType } from '@univerjs/core';
+import { ColumnSeparatorType, DataStreamTreeTokenType, DocumentFlavor, ICommandService, IResourceManagerService, IUndoRedoService, PageOrientType, SectionType, UniverInstanceType } from '@univerjs/core';
import { InsertTextCommand } from '@univerjs/docs';
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { createDocumentData, createSimpleDocument, createTestBed } from './create-test-bed';
@@ -40,7 +40,14 @@ describe('FDocument', () => {
});
it('exposes section enums through univerAPI', () => {
- expect(univerAPI.Enum.SectionType.NEXT_PAGE).toBe(SectionType.NEXT_PAGE);
+ expect(univerAPI.Enum.SectionType).toMatchObject({
+ SECTION_TYPE_UNSPECIFIED: 0,
+ CONTINUOUS: 1,
+ NEXT_COLUMN: 2,
+ NEXT_PAGE: 3,
+ EVEN_PAGE: 4,
+ ODD_PAGE: 5,
+ });
expect(univerAPI.Enum.ColumnSeparatorType.BETWEEN_EACH_COLUMN).toBe(ColumnSeparatorType.BETWEEN_EACH_COLUMN);
});
@@ -208,9 +215,12 @@ describe('FDocument', () => {
expect(document.getSections()).toHaveLength(2);
expect(document.getSectionAt(6)?.getIndex()).toBe(1);
+ expect(document.getSectionAt(4)).toBeNull();
+ expect(document.getSectionAt(5)?.getIndex()).toBe(1);
const first = document.getSection(0)!;
expect(first.getRange()).toEqual({ startOffset: 0, endOffset: 4, segmentId: '' });
- expect(first.setColumns(2, { gap: 20, separator: true, sectionType: SectionType.CONTINUOUS })).toBe(true);
+ expect(first.setColumns(2, { gap: 20, separator: true })).toBe(true);
+ expect(first.setSectionType(SectionType.CONTINUOUS)).toBe(true);
expect(first.describe()).toMatchObject({
columnCount: 2,
columnSeparatorType: ColumnSeparatorType.BETWEEN_EACH_COLUMN,
@@ -221,7 +231,76 @@ describe('FDocument', () => {
expect(document.save().body?.sectionBreaks?.[0].defaultHeaderId).toBe(headerId);
expect(document.save().documentStyle.defaultHeaderId).toBeFalsy();
expect(document.insertColumnBreak(2)).toBe(true);
- expect(document.save().body?.dataStream[2]).toBe(DataStreamTreeTokenType.COLUMN_BREAK);
+ const body = document.save().body;
+ expect(body?.dataStream[2]).toBe(DataStreamTreeTokenType.COLUMN_BREAK);
+ expect(body?.customRanges).toContainEqual(expect.objectContaining({
+ startIndex: 2,
+ endIndex: 2,
+ wholeEntity: true,
+ properties: { docxBreakType: 'column' },
+ }));
+ });
+
+ it('rejects explicit columns that overflow the section content width', () => {
+ univer.dispose();
+ const data = createDocumentData('section-validation-doc', {
+ dataStream: 'One\r\n',
+ paragraphs: [{ startIndex: 3, paragraphId: 'para-section-validation' }],
+ sectionBreaks: [{ sectionId: 'section_validation', startIndex: 4 }],
+ });
+ data.documentStyle = { ...data.documentStyle, documentFlavor: DocumentFlavor.TRADITIONAL };
+ createDocumentFacade(data);
+ const section = document.getSection(0)!;
+
+ expect(() => section.setColumns(2, { gap: 20, widths: [300, 300] })).toThrow('exceed the available page content width');
+ expect(() => section.setColumnProperties([
+ { width: 300, paddingEnd: 20 },
+ { width: 300, paddingEnd: 0 },
+ ])).toThrow('exceed the available page content width');
+ });
+
+ it('updates per-section page setup through commands with undo and redo', () => {
+ univer.dispose();
+ const data = createDocumentData('section-page-setup-doc', {
+ dataStream: 'One\r\n',
+ paragraphs: [{ startIndex: 3, paragraphId: 'para-page-setup' }],
+ sectionBreaks: [{ sectionId: 'section_page_setup', startIndex: 4 }],
+ });
+ data.documentStyle = { ...data.documentStyle, documentFlavor: DocumentFlavor.TRADITIONAL };
+ createDocumentFacade(data);
+ get(IUndoRedoService);
+
+ const section = document.getSection(0)!;
+ expect(() => section.setPageSetup({
+ pageSize: { width: 100, height: 100 },
+ marginLeft: 50,
+ marginRight: 50,
+ })).toThrow('must leave a positive content area');
+ expect(() => section.setPageSetup({ marginTop: Number.NaN })).toThrow('must be finite');
+ const pageSetup = {
+ pageNumberStart: 3,
+ pageSize: { width: 960, height: 720 },
+ pageOrient: PageOrientType.LANDSCAPE,
+ marginTop: 48,
+ marginBottom: 56,
+ marginLeft: 64,
+ marginRight: 72,
+ };
+
+ expect(section.setPageSetup(pageSetup)).toBe(true);
+ expect(section.getPageSetup()).toEqual(pageSetup);
+ expect(document.undo()).toBe(true);
+ expect(section.getPageSetup()).toEqual({
+ pageNumberStart: undefined,
+ pageSize: undefined,
+ pageOrient: undefined,
+ marginTop: undefined,
+ marginBottom: undefined,
+ marginLeft: undefined,
+ marginRight: undefined,
+ });
+ expect(document.redo()).toBe(true);
+ expect(section.getPageSetup()).toEqual(pageSetup);
});
it('keeps traditional section mutation unavailable in modern documents', () => {
diff --git a/packages/docs/src/facade/f-document-section.ts b/packages/docs/src/facade/f-document-section.ts
index 95a828d619..78c5959b9b 100644
--- a/packages/docs/src/facade/f-document-section.ts
+++ b/packages/docs/src/facade/f-document-section.ts
@@ -14,24 +14,27 @@
* limitations under the License.
*/
-import type { Injector, IResolvedSectionHeaderFooterReference, ISectionBreak, ISectionColumnProperties, SectionHeaderFooterKind, SectionHeaderFooterVariant } from '@univerjs/core';
+import type { IResolvedSectionHeaderFooterReference, ISectionBreak, ISectionColumnProperties, SectionHeaderFooterKind, SectionHeaderFooterVariant } from '@univerjs/core';
import type { IHeaderFooterProps } from '@univerjs/docs';
import type { FDocument } from './f-document';
import type { IFDocumentTextRange } from './utils';
-import { ColumnSeparatorType, DocumentFlavor, generateRandomId, getSectionHeaderFooterReferenceKey, ICommandService, resolveSectionHeaderFooterReference, SectionType, Tools } from '@univerjs/core';
-import { CreateHeaderFooterCommand, createSectionColumnProperties, DeleteDocumentSectionBreakCommand, getTopLevelSectionBreaks, HeaderFooterType, SetSectionHeaderFooterLinkCommand, UpdateDocumentSectionCommand } from '@univerjs/docs';
+import { ColumnSeparatorType, DocumentFlavor, generateRandomId, getSectionHeaderFooterReferenceKey, ICommandService, PageOrientType, resolveSectionHeaderFooterReference, SectionType, Tools } from '@univerjs/core';
+import { CreateHeaderFooterCommand, createSectionColumnProperties, DeleteDocumentSectionBreakCommand, getSectionContentWidth, getTopLevelSectionBreaks, HeaderFooterType, SetSectionHeaderFooterLinkCommand, UpdateDocumentSectionCommand } from '@univerjs/docs';
export interface IFDocumentSectionColumnOptions {
- /** Gap after each column except the last, in points (pt). */
+ /** Gap after each column except the last, in 96-DPI layout pixels. */
gap?: number;
- /** Optional explicit column widths in points (pt). Length must equal `columnCount`. */
+ /** Optional explicit column widths in 96-DPI layout pixels. Length must equal `columnCount`. */
widths?: number[];
/** Whether to draw separators, or the exact separator enum value. */
separator?: boolean | ColumnSeparatorType;
- /** How the following section starts. */
- sectionType?: SectionType;
}
+export type FDocumentSectionPageSetup = Pick<
+ ISectionBreak,
+ 'pageNumberStart' | 'pageSize' | 'pageOrient' | 'marginTop' | 'marginBottom' | 'marginLeft' | 'marginRight'
+>;
+
export interface IFDocumentSectionDescription {
sectionId: string;
index: number;
@@ -70,7 +73,7 @@ export class FDocumentSection {
constructor(
private readonly _document: FDocument,
private readonly _sectionId: string,
- private readonly _injector: Injector
+ @ICommandService private readonly _commandService: ICommandService
) {}
/**
@@ -131,7 +134,7 @@ export class FDocumentSection {
/**
* Returns the explicit columns. An empty array means the normal single-column layout.
- * Column widths and trailing spaces are in points (pt).
+ * Column widths and trailing spaces are in 96-DPI layout pixels.
* @example
* ```ts
* const fDocument = univerAPI.getActiveDocument();
@@ -177,7 +180,7 @@ export class FDocumentSection {
/**
* Sets equal or explicitly sized columns for this traditional section.
* Use `columnCount = 1` to restore normal single-column layout.
- * `gap` and `widths` are in points (pt).
+ * `gap` and `widths` are in 96-DPI layout pixels.
* @example
* ```ts
* const fDocument = univerAPI.getActiveDocument();
@@ -194,6 +197,9 @@ export class FDocumentSection {
if (options.widths && options.widths.length !== columnCount) {
throw new RangeError('Section column widths must match the column count.');
}
+ if (options.gap != null && (!Number.isFinite(options.gap) || options.gap < 0)) {
+ throw new RangeError('Section column gap must be finite and non-negative.');
+ }
const gap = Math.max(0, options.gap ?? 18);
const config = this.getConfig();
@@ -207,16 +213,18 @@ export class FDocumentSection {
const separator = typeof options.separator === 'boolean'
? options.separator ? ColumnSeparatorType.BETWEEN_EACH_COLUMN : ColumnSeparatorType.NONE
: options.separator ?? ColumnSeparatorType.NONE;
+ if (!Object.values(ColumnSeparatorType).includes(separator)) {
+ throw new RangeError('Invalid section column separator type.');
+ }
return this._update({
columnProperties: columns,
columnSeparatorType: separator,
- ...(options.sectionType == null ? {} : { sectionType: options.sectionType }),
});
}
/**
- * Sets explicit OOXML-compatible column width and trailing-space values in points (pt).
+ * Sets explicit OOXML-compatible column width and trailing-space values in 96-DPI layout pixels.
* @example
* ```ts
* const fDocument = univerAPI.getActiveDocument();
@@ -230,8 +238,18 @@ export class FDocumentSection {
*/
setColumnProperties(columns: ISectionColumnProperties[], separator = ColumnSeparatorType.NONE): boolean {
this._assertTraditionalDocument();
- if (columns.some(({ width, paddingEnd }) => width < 0 || paddingEnd < 0)) {
- throw new RangeError('Section column widths and padding must be non-negative.');
+ if (!Object.values(ColumnSeparatorType).includes(separator)) {
+ throw new RangeError('Invalid section column separator type.');
+ }
+ if (columns.some(({ width, paddingEnd }) => !Number.isFinite(width) || !Number.isFinite(paddingEnd) || width < 0 || paddingEnd < 0)) {
+ throw new RangeError('Section column widths and padding must be finite and non-negative.');
+ }
+ const contentWidth = getSectionContentWidth(
+ this._document.getDocumentDataModel().getSnapshot().documentStyle,
+ this.getConfig()
+ );
+ if (columns.reduce((sum, { width, paddingEnd }) => sum + width + paddingEnd, 0) > contentWidth) {
+ throw new RangeError('Section columns exceed the available page content width.');
}
return this._update({
columnProperties: Tools.deepClone(columns),
@@ -240,7 +258,7 @@ export class FDocumentSection {
}
/**
- * Sets how the next section begins.
+ * Sets how this section begins relative to the previous section.
* @example
* ```ts
* const fDocument = univerAPI.getActiveDocument();
@@ -251,9 +269,74 @@ export class FDocumentSection {
*/
setSectionType(sectionType: SectionType): boolean {
this._assertTraditionalDocument();
+ if (!Object.values(SectionType).includes(sectionType)) {
+ throw new RangeError('Invalid section type.');
+ }
return this._update({ sectionType });
}
+ /**
+ * Returns this section's explicit page setup overrides.
+ * Missing values inherit from the document style. Geometry values use 96-DPI layout pixels.
+ */
+ getPageSetup(): FDocumentSectionPageSetup {
+ const {
+ pageNumberStart,
+ pageSize,
+ pageOrient,
+ marginTop,
+ marginBottom,
+ marginLeft,
+ marginRight,
+ } = this.getConfig();
+ return Tools.deepClone({
+ pageNumberStart,
+ pageSize,
+ pageOrient,
+ marginTop,
+ marginBottom,
+ marginLeft,
+ marginRight,
+ });
+ }
+
+ /**
+ * Updates this section's page setup through the document section command.
+ * Geometry values use 96-DPI layout pixels.
+ */
+ setPageSetup(pageSetup: FDocumentSectionPageSetup): boolean {
+ this._assertTraditionalDocument();
+ const { pageNumberStart, pageSize, pageOrient, marginTop, marginBottom, marginLeft, marginRight } = pageSetup;
+ if (pageNumberStart != null && (!Number.isInteger(pageNumberStart) || pageNumberStart < 1)) {
+ throw new RangeError('Section page number start must be a positive integer.');
+ }
+ if (pageSize && [pageSize.width, pageSize.height]
+ .some((size) => size != null && (!Number.isFinite(size) || size <= 0))) {
+ throw new RangeError('Section page size must be finite and positive.');
+ }
+ if (pageOrient != null && !Object.values(PageOrientType).includes(pageOrient)) {
+ throw new RangeError('Invalid section page orientation.');
+ }
+ if ([marginTop, marginBottom, marginLeft, marginRight]
+ .some((margin) => margin != null && (!Number.isFinite(margin) || margin < 0))) {
+ throw new RangeError('Section page margins must be finite and non-negative.');
+ }
+ const current = this.getConfig();
+ const documentStyle = this._document.getDocumentDataModel().getSnapshot().documentStyle;
+ const effectivePageSize = pageSize ?? current.pageSize ?? documentStyle.pageSize;
+ const effectiveMarginTop = marginTop ?? current.marginTop ?? documentStyle.marginTop ?? 0;
+ const effectiveMarginBottom = marginBottom ?? current.marginBottom ?? documentStyle.marginBottom ?? 0;
+ const effectiveMarginLeft = marginLeft ?? current.marginLeft ?? documentStyle.marginLeft ?? 0;
+ const effectiveMarginRight = marginRight ?? current.marginRight ?? documentStyle.marginRight ?? 0;
+ if ((effectivePageSize?.width != null &&
+ effectiveMarginLeft + effectiveMarginRight >= effectivePageSize.width) ||
+ (effectivePageSize?.height != null &&
+ effectiveMarginTop + effectiveMarginBottom >= effectivePageSize.height)) {
+ throw new RangeError('Section page margins must leave a positive content area.');
+ }
+ return this._update(Tools.deepClone(pageSetup));
+ }
+
/**
* Ensures a header segment linked specifically to this section.
* @example
@@ -366,7 +449,7 @@ export class FDocumentSection {
/**
* Updates header/footer switches and margins on this section break.
- * `marginHeader` and `marginFooter` are in points (pt).
+ * `marginHeader` and `marginFooter` are in 96-DPI layout pixels.
* @example
* ```ts
* const fDocument = univerAPI.getActiveDocument();
@@ -399,7 +482,7 @@ export class FDocumentSection {
*/
remove(): boolean {
this._assertTraditionalDocument();
- return this._injector.get(ICommandService).syncExecuteCommand(DeleteDocumentSectionBreakCommand.id, {
+ return this._commandService.syncExecuteCommand(DeleteDocumentSectionBreakCommand.id, {
unitId: this._document.getId(),
sectionId: this._sectionId,
});
@@ -407,7 +490,7 @@ export class FDocumentSection {
private _update(patch: Partial<ISectionBreak>): boolean {
const { sectionId: _sectionId, startIndex: _startIndex, ...config } = patch;
- return this._injector.get(ICommandService).syncExecuteCommand(UpdateDocumentSectionCommand.id, {
+ return this._commandService.syncExecuteCommand(UpdateDocumentSectionCommand.id, {
unitId: this._document.getId(),
updates: [{ sectionId: this._sectionId, config }],
});
@@ -425,7 +508,7 @@ export class FDocumentSection {
if (index > 0) {
const segmentId = generateRandomId(6);
- const success = this._injector.get(ICommandService).syncExecuteCommand(SetSectionHeaderFooterLinkCommand.id, {
+ const success = this._commandService.syncExecuteCommand(SetSectionHeaderFooterLinkCommand.id, {
unitId: this._document.getId(),
sectionId: this._sectionId,
kind,
@@ -445,7 +528,7 @@ export class FDocumentSection {
even: kind === 'header' ? HeaderFooterType.EVEN_PAGE_HEADER : HeaderFooterType.EVEN_PAGE_FOOTER,
};
const segmentId = generateRandomId(6);
- const success = this._injector.get(ICommandService).syncExecuteCommand(CreateHeaderFooterCommand.id, {
+ const success = this._commandService.syncExecuteCommand(CreateHeaderFooterCommand.id, {
unitId: this._document.getId(),
segmentId,
createType: types[variant],
@@ -488,7 +571,7 @@ export class FDocumentSection {
linkedToPrevious: boolean
): boolean {
this._assertTraditionalDocument();
- return this._injector.get(ICommandService).syncExecuteCommand(SetSectionHeaderFooterLinkCommand.id, {
+ return this._commandService.syncExecuteCommand(SetSectionHeaderFooterLinkCommand.id, {
unitId: this._document.getId(),
sectionId: this._sectionId,
kind,
diff --git a/packages/docs/src/facade/f-document.ts b/packages/docs/src/facade/f-document.ts
index cca2f9e06c..7a66cc21f7 100644
--- a/packages/docs/src/facade/f-document.ts
+++ b/packages/docs/src/facade/f-document.ts
@@ -34,7 +34,7 @@ import {
UndoCommand,
} from '@univerjs/core';
import { FBaseInitialable } from '@univerjs/core/facade';
-import { CreateHeaderFooterCommand, generateParagraphs, getTopLevelSectionBreaks, HeaderFooterType, InsertDocumentSectionBreakCommand } from '@univerjs/docs';
+import { CreateHeaderFooterCommand, generateParagraphs, getTopLevelSectionBreaks, HeaderFooterType, InsertDocumentColumnBreakCommand, InsertDocumentSectionBreakCommand } from '@univerjs/docs';
import { FDocumentParagraph } from './f-document-paragraph';
import { DocsSectionUnsupportedDocumentFlavorError, FDocumentSection } from './f-document-section';
import { FDocumentTextRange } from './f-document-text-range';
@@ -255,7 +255,7 @@ export class FDocument extends FBaseInitialable {
}
/**
- * Returns document-level header/footer switches and margins. Margin values are in points (pt).
+ * Returns document-level header/footer switches and margins. Margin values use 96-DPI layout pixels.
* @example
* ```ts
* const fDocument = univerAPI.getActiveDocument();
@@ -274,7 +274,7 @@ export class FDocument extends FBaseInitialable {
/**
* Updates document-level header/footer switches and margins in a traditional document.
- * `marginHeader` and `marginFooter` are in points (pt).
+ * `marginHeader` and `marginFooter` use 96-DPI layout pixels.
* @example
* ```ts
* const fDocument = univerAPI.getActiveDocument();
@@ -326,7 +326,7 @@ export class FDocument extends FBaseInitialable {
return [];
}
return getTopLevelSectionBreaks(this.getBody()).map((sectionBreak) =>
- this._injector.createInstance(FDocumentSection, this, sectionBreak.sectionId, this._injector));
+ this._injector.createInstance(FDocumentSection, this, sectionBreak.sectionId));
}
/**
@@ -356,14 +356,14 @@ export class FDocument extends FBaseInitialable {
getSectionAt(offset: number): FDocumentSection | null {
return this.getSections().find((section) => {
const range = section.getRange();
- return offset >= range.startOffset && offset <= range.endOffset;
+ return offset >= range.startOffset && offset < range.endOffset;
}) ?? null;
}
/**
* Inserts a traditional document section break and returns its stable facade.
* Modern documents must use ColumnGroup and throw `DocsSectionUnsupportedDocumentFlavorError`.
- * Numeric layout values in `config` are in points (pt).
+ * Numeric layout values in `config` are in 96-DPI layout pixels.
* @example
* ```ts
* const fDocument = univerAPI.getActiveDocument();
@@ -386,11 +386,12 @@ export class FDocument extends FBaseInitialable {
sectionId,
config,
});
- return success ? this._injector.createInstance(FDocumentSection, this, sectionId, this._injector) : null;
+ return success ? this._injector.createInstance(FDocumentSection, this, sectionId) : null;
}
/**
* Inserts a column-break token in a traditional document.
+ * In a single-column section, the traditional renderer advances to the next physical page.
* Modern documents must use ColumnGroup and throw `DocsSectionUnsupportedDocumentFlavorError`.
* @example
* ```ts
@@ -408,7 +409,10 @@ export class FDocument extends FBaseInitialable {
if (this._documentDataModel.getSnapshot().documentStyle.documentFlavor !== DocumentFlavor.TRADITIONAL) {
throw new DocsSectionUnsupportedDocumentFlavorError();
}
- return this.insertText(offset, DataStreamTreeTokenType.COLUMN_BREAK);
+ return this._commandService.syncExecuteCommand(InsertDocumentColumnBreakCommand.id, {
+ unitId: this.getId(),
+ offset,
+ });
}
/**
diff --git a/packages/docs/src/facade/index.ts b/packages/docs/src/facade/index.ts
index bfd9731e61..ce451b1091 100644
--- a/packages/docs/src/facade/index.ts
+++ b/packages/docs/src/facade/index.ts
@@ -21,7 +21,7 @@ export { FDocument } from './f-document';
export { FDocumentParagraph, isParagraphFacade } from './f-document-paragraph';
export type { IFDocumentParagraphInfo } from './f-document-paragraph';
export { DocsSectionUnsupportedDocumentFlavorError, FDocumentSection } from './f-document-section';
-export type { IFDocumentSectionColumnOptions, IFDocumentSectionDescription } from './f-document-section';
+export type { FDocumentSectionPageSetup, IFDocumentSectionColumnOptions, IFDocumentSectionDescription } from './f-document-section';
export { FDocumentTextRange } from './f-document-text-range';
export type { IFDocumentTextRangeDescription, IFDocumentTextStyleRun } from './f-document-text-range';
export * from './f-enum';
diff --git a/packages/docs/src/index.ts b/packages/docs/src/index.ts
index 99edae6b45..1076ae1882 100644
--- a/packages/docs/src/index.ts
+++ b/packages/docs/src/index.ts
@@ -33,8 +33,8 @@ export type {
} from './commands/commands/set-document-default-paragraph-style.command';
export { SetSectionHeaderFooterLinkCommand } from './commands/commands/set-section-header-footer-link.command';
export type { ISetSectionHeaderFooterLinkCommandParams } from './commands/commands/set-section-header-footer-link.command';
-export { DeleteDocumentSectionBreakCommand, InsertDocumentSectionBreakCommand, UpdateDocumentSectionCommand } from './commands/commands/update-document-section.command';
-export type { IDeleteDocumentSectionBreakCommandParams, IDocumentSectionConfig, IDocumentSectionUpdate, IInsertDocumentSectionBreakCommandParams, IUpdateDocumentSectionCommandParams } from './commands/commands/update-document-section.command';
+export { DeleteDocumentSectionBreakCommand, InsertDocumentColumnBreakCommand, InsertDocumentSectionBreakCommand, UpdateDocumentSectionCommand } from './commands/commands/update-document-section.command';
+export type { IDeleteDocumentSectionBreakCommandParams, IDocumentSectionConfig, IDocumentSectionUpdate, IInsertDocumentColumnBreakCommandParams, IInsertDocumentSectionBreakCommandParams, IUpdateDocumentSectionCommandParams } from './commands/commands/update-document-section.command';
export { RichTextEditingMutation } from './commands/mutations/core-editing.mutation';
export type { IRichTextEditingMutationParams } from './commands/mutations/core-editing.mutation';
export { SetTextSelectionsOperation } from './commands/operations/text-selection.operation';
@@ -86,7 +86,7 @@ export {
} from './utils/custom-range-factory';
export { generateParagraphs } from './utils/paragraphs';
export { replaceSelectionFactory } from './utils/replace-selection-factory';
-export { createSectionColumnProperties } from './utils/section-columns';
+export { createSectionColumnProperties, getSectionContentWidth } from './utils/section-columns';
export { getTopLevelSectionBreaks } from './utils/sections';
export { buildDocTransform, docDrawingPositionToTransform, transformToDocDrawingPosition } from './utils/transform-position';
export { consumeContentInsertRange, getContentInsertRange, isHeaderFooterSelection, normalizeTextRange } from './utils/util';
diff --git a/packages/docs/src/plugin.ts b/packages/docs/src/plugin.ts
index 8c07571afb..aa16fa92db 100644
--- a/packages/docs/src/plugin.ts
+++ b/packages/docs/src/plugin.ts
@@ -29,7 +29,7 @@ import { DeleteTextCommand, InsertTextCommand, UpdateTextCommand } from './comma
import { CreateHeaderFooterCommand } from './commands/commands/create-header-footer.command';
import { SetDocumentDefaultParagraphStyleCommand } from './commands/commands/set-document-default-paragraph-style.command';
import { SetSectionHeaderFooterLinkCommand } from './commands/commands/set-section-header-footer-link.command';
-import { DeleteDocumentSectionBreakCommand, InsertDocumentSectionBreakCommand, UpdateDocumentSectionCommand } from './commands/commands/update-document-section.command';
+import { DeleteDocumentSectionBreakCommand, InsertDocumentColumnBreakCommand, InsertDocumentSectionBreakCommand, UpdateDocumentSectionCommand } from './commands/commands/update-document-section.command';
import { RichTextEditingMutation } from './commands/mutations/core-editing.mutation';
import { DocsRenameMutation } from './commands/mutations/docs-rename.mutation';
import { SetTextSelectionsOperation } from './commands/operations/text-selection.operation';
@@ -79,6 +79,7 @@ export class UniverDocsPlugin extends Plugin {
SetSectionHeaderFooterLinkCommand,
UpdateDocumentSectionCommand,
InsertDocumentSectionBreakCommand,
+ InsertDocumentColumnBreakCommand,
DeleteDocumentSectionBreakCommand,
RichTextEditingMutation,
DocsRenameMutation,
diff --git a/packages/docs/src/utils/section-columns.ts b/packages/docs/src/utils/section-columns.ts
index 848356c8f2..5034421881 100644
--- a/packages/docs/src/utils/section-columns.ts
+++ b/packages/docs/src/utils/section-columns.ts
@@ -17,6 +17,18 @@
import type { IDocumentStyle, ISectionBreak, ISectionColumnProperties } from '@univerjs/core';
import { PAGE_SIZE, PaperType } from '@univerjs/core';
+/** Returns the usable horizontal layout width for a traditional section. */
+export function getSectionContentWidth(
+ documentStyle: IDocumentStyle | undefined,
+ section: ISectionBreak | undefined
+): number {
+ const pageWidth = section?.pageSize?.width ?? documentStyle?.pageSize?.width ?? PAGE_SIZE[PaperType.A4].width;
+ return Math.max(
+ 0,
+ pageWidth - (section?.marginLeft ?? documentStyle?.marginLeft ?? 72) - (section?.marginRight ?? documentStyle?.marginRight ?? 72)
+ );
+}
+
/** Creates explicit OOXML section columns from a count, gap, and optional widths. */
export function createSectionColumnProperties(
documentStyle: IDocumentStyle | undefined,
@@ -30,12 +42,16 @@ export function createSectionColumnProperties(
}
const safeGap = Math.max(0, gap);
- const pageWidth = section?.pageSize?.width ?? documentStyle?.pageSize?.width ?? PAGE_SIZE[PaperType.A4].width;
- const contentWidth = Math.max(
- 0,
- pageWidth - (section?.marginLeft ?? documentStyle?.marginLeft ?? 72) - (section?.marginRight ?? documentStyle?.marginRight ?? 72)
- );
+ const contentWidth = getSectionContentWidth(documentStyle, section);
const availableWidth = Math.max(0, contentWidth - safeGap * (columnCount - 1));
+ if (widths) {
+ if (widths.some((width) => !Number.isFinite(width) || width < 0)) {
+ throw new RangeError('Section column widths must be finite and non-negative.');
+ }
+ if (widths.reduce((sum, width) => sum + width, 0) > availableWidth) {
+ throw new RangeError('Section columns exceed the available page content width.');
+ }
+ }
const resolvedWidths = widths ?? Array.from({ length: columnCount }, () => availableWidth / columnCount);
return resolvedWidths.map((width, index) => ({
diff --git a/packages/engine-render/src/components/docs/__tests__/document.spec.ts b/packages/engine-render/src/components/docs/__tests__/document.spec.ts
index 19dbc58465..34ff1391c8 100644
--- a/packages/engine-render/src/components/docs/__tests__/document.spec.ts
+++ b/packages/engine-render/src/components/docs/__tests__/document.spec.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import { DashStyleType, DocumentFlavor } from '@univerjs/core';
+import { ColumnSeparatorType, DashStyleType, DocumentFlavor } from '@univerjs/core';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { setupRenderTestEnv } from '../../../__tests__/render-test-utils';
import {
@@ -25,13 +25,14 @@ import {
} from '../../../basics/i-document-skeleton-cached';
import { Vector2 } from '../../../basics/vector2';
import { Canvas } from '../../../canvas';
+import { UniverRenderingContext } from '../../../context';
import { Engine } from '../../../engine';
import { MAIN_VIEW_PORT_KEY, Scene } from '../../../scene';
import { Path, Rect } from '../../../shape';
import { Viewport } from '../../../viewport';
import { DocBackground } from '../doc-background';
import { DOCS_EXTENSION_TYPE } from '../doc-extension';
-import { Documents } from '../document';
+import { Documents, drawSectionColumnSeparators } from '../document';
import { getDocumentCompatibilityPolicy } from '../document-compatibility';
import { setDocsTableRenderViewportProvider } from '../table-render-viewport';
@@ -413,6 +414,53 @@ describe('documents render', () => {
documents.dispose();
});
+ it('draws section column separators between columns', () => {
+ const nativeContext = document.createElement('canvas').getContext('2d');
+ if (!nativeContext) {
+ throw new Error('Expected a canvas 2D context.');
+ }
+ const ctx = new UniverRenderingContext(nativeContext);
+ vi.spyOn(ctx, 'moveToByPrecision');
+ vi.spyOn(ctx, 'lineToByPrecision');
+ vi.spyOn(ctx, 'stroke');
+
+ drawSectionColumnSeparators(ctx, {
+ height: 300,
+ colCount: 2,
+ top: 0,
+ st: 0,
+ ed: 0,
+ columns: [
+ {
+ lines: [],
+ left: 0,
+ width: 120,
+ spaceWidth: 20,
+ separator: ColumnSeparatorType.BETWEEN_EACH_COLUMN,
+ st: 0,
+ ed: 0,
+ drawingLRIds: [],
+ isFull: false,
+ },
+ {
+ lines: [],
+ left: 140,
+ width: 120,
+ spaceWidth: 0,
+ separator: ColumnSeparatorType.BETWEEN_EACH_COLUMN,
+ st: 0,
+ ed: 0,
+ drawingLRIds: [],
+ isFull: false,
+ },
+ ],
+ }, 500, 96, 72);
+
+ expect(ctx.moveToByPrecision).toHaveBeenCalledWith(226, 72);
+ expect(ctx.lineToByPrecision).toHaveBeenCalledWith(226, 572);
+ expect(ctx.stroke).toHaveBeenCalledTimes(1);
+ });
+
it('aligns table cell background to precise start and end edges', () => {
const skeleton = { getSkeletonData: () => ({ pages: [] }) } as any;
const documents = new Documents('docs-background-precision', skeleton, {
diff --git a/packages/engine-render/src/components/docs/document.ts b/packages/engine-render/src/components/docs/document.ts
index fb9f177ab9..4df38bb579 100644
--- a/packages/engine-render/src/components/docs/document.ts
+++ b/packages/engine-render/src/components/docs/document.ts
@@ -22,6 +22,7 @@ import type {
IDocumentSkeletonLine,
IDocumentSkeletonPage,
IDocumentSkeletonRow,
+ IDocumentSkeletonSection,
IDocumentSkeletonTable,
} from '../../basics/i-document-skeleton-cached';
import type { Transform } from '../../basics/transform';
@@ -32,7 +33,7 @@ import type { ComponentExtension, IDrawInfo, IExtensionConfig } from '../extensi
import type { IDocumentsConfig, IPageMarginLayout } from './doc-component';
import type { DocumentSkeleton } from './layout/doc-skeleton';
import type { IDocsTableRenderViewport } from './table-render-viewport';
-import { CellValueType, DashStyleType, HorizontalAlign, VerticalAlign, WrapStrategy } from '@univerjs/core';
+import { CellValueType, ColumnSeparatorType, DashStyleType, HorizontalAlign, VerticalAlign, WrapStrategy } from '@univerjs/core';
import { Subject } from 'rxjs';
import { BORDER_TYPE as BORDER_LTRB, drawLineByBorderType } from '../../basics';
import { calculateRectRotate, getRotateOffsetAndFarthestHypotenuse } from '../../basics/draw';
@@ -70,6 +71,37 @@ export interface IDocumentOffsetConfig extends IPageMarginLayout {
documentTransform: Transform;
}
+export function drawSectionColumnSeparators(
+ ctx: UniverRenderingContext,
+ section: IDocumentSkeletonSection,
+ height: number,
+ offsetX = 0,
+ offsetY = 0
+): void {
+ if (section.columns.length < 2) {
+ return;
+ }
+
+ ctx.save();
+ ctx.strokeStyle = '#000000';
+ ctx.setLineWidthByPrecision(1);
+ ctx.beginPath();
+
+ for (const column of section.columns.slice(0, -1)) {
+ if (column.separator !== ColumnSeparatorType.BETWEEN_EACH_COLUMN) {
+ continue;
+ }
+
+ const separatorX = offsetX + column.left + column.width + column.spaceWidth / 2;
+ ctx.moveToByPrecision(separatorX, offsetY);
+ ctx.lineToByPrecision(separatorX, offsetY + height);
+ }
+
+ ctx.stroke();
+ ctx.closePath();
+ ctx.restore();
+}
+
export class Documents extends DocComponent {
private readonly _pageRender$ = new Subject<IPageRenderConfig>();
@@ -259,11 +291,26 @@ export class Documents extends DocComponent {
this._startRotation(ctx, finalAngle);
- for (const section of sections) {
+ for (const [sectionIndex, section] of sections.entries()) {
const { columns } = section;
+ const nextSectionTop = sections
+ .slice(sectionIndex + 1)
+ .find((candidate) => candidate.top > section.top)
+ ?.top;
+ const separatorHeight = Math.max(
+ 0,
+ (nextSectionTop ?? page.pageHeight - pagePaddingTop - pagePaddingBottom) - section.top
+ );
this._drawLiquid.translateSave();
this._drawLiquid.translateSection(section);
+ drawSectionColumnSeparators(
+ ctx,
+ section,
+ separatorHeight,
+ alignOffsetNoAngle.x,
+ alignOffsetNoAngle.y
+ );
for (const column of columns) {
const { lines, width: columnWidth } = column;
diff --git a/packages/engine-render/src/components/docs/layout/__tests__/doc-skeleton.spec.ts b/packages/engine-render/src/components/docs/layout/__tests__/doc-skeleton.spec.ts
index c00ec0d26c..1fda13c015 100644
--- a/packages/engine-render/src/components/docs/layout/__tests__/doc-skeleton.spec.ts
+++ b/packages/engine-render/src/components/docs/layout/__tests__/doc-skeleton.spec.ts
@@ -23,6 +23,7 @@ import {
LocaleService,
ObjectRelativeFromH,
ObjectRelativeFromV,
+ PageOrientType,
PositionedObjectLayoutType,
SectionType,
TableSizeType,
@@ -907,6 +908,420 @@ describe('doc skeleton', () => {
univer.dispose();
});
+ it('starts a NEXT_PAGE section on a distinct physical page', () => {
+ const first = `First${DataStreamTreeTokenType.PARAGRAPH}${DataStreamTreeTokenType.SECTION_BREAK}`;
+ const second = `Second${DataStreamTreeTokenType.PARAGRAPH}${DataStreamTreeTokenType.SECTION_BREAK}`;
+ const univer = new Univer();
+ const localeService = univer.__getInjector().get(LocaleService);
+ const documentModel = new DocumentDataModel({
+ id: 'next-page-sections',
+ body: {
+ dataStream: `${first}${second}`,
+ paragraphs: [
+ { startIndex: first.length - 2, paragraphId: 'first-paragraph' },
+ { startIndex: first.length + second.length - 2, paragraphId: 'second-paragraph' },
+ ],
+ sectionBreaks: [
+ { sectionId: 'first-section', startIndex: first.length - 1 },
+ {
+ sectionId: 'second-section',
+ startIndex: first.length + second.length - 1,
+ sectionType: SectionType.NEXT_PAGE,
+ },
+ ],
+ },
+ documentStyle: {
+ documentFlavor: DocumentFlavor.TRADITIONAL,
+ pageSize: { width: 320, height: 400 },
+ marginTop: 20,
+ marginBottom: 20,
+ marginLeft: 20,
+ marginRight: 20,
+ },
+ });
+ const skeleton = DocumentSkeleton.create(new DocumentViewModel(documentModel), localeService);
+
+ skeleton.calculate();
+
+ expect(skeleton.getSkeletonData()?.pages.map(({ pageNumber }) => pageNumber)).toEqual([1, 2]);
+
+ skeleton.dispose();
+ univer.dispose();
+ });
+
+ it('starts a NEXT_COLUMN section in the next available column', () => {
+ const first = `First${DataStreamTreeTokenType.PARAGRAPH}${DataStreamTreeTokenType.SECTION_BREAK}`;
+ const second = `Second${DataStreamTreeTokenType.PARAGRAPH}${DataStreamTreeTokenType.SECTION_BREAK}`;
+ const columns = [
+ { width: 130, paddingEnd: 20 },
+ { width: 130, paddingEnd: 0 },
+ ];
+ const univer = new Univer();
+ const localeService = univer.__getInjector().get(LocaleService);
+ const documentModel = new DocumentDataModel({
+ id: 'next-column-sections',
+ body: {
+ dataStream: `${first}${second}`,
+ paragraphs: [
+ { startIndex: first.length - 2, paragraphId: 'first-paragraph' },
+ { startIndex: first.length + second.length - 2, paragraphId: 'second-paragraph' },
+ ],
+ sectionBreaks: [
+ { sectionId: 'first-section', startIndex: first.length - 1, columnProperties: columns },
+ {
+ sectionId: 'second-section',
+ startIndex: first.length + second.length - 1,
+ sectionType: SectionType.NEXT_COLUMN,
+ columnProperties: columns,
+ },
+ ],
+ },
+ documentStyle: {
+ documentFlavor: DocumentFlavor.TRADITIONAL,
+ pageSize: { width: 320, height: 400 },
+ marginTop: 20,
+ marginBottom: 20,
+ marginLeft: 20,
+ marginRight: 20,
+ },
+ });
+ const skeleton = DocumentSkeleton.create(new DocumentViewModel(documentModel), localeService);
+
+ skeleton.calculate();
+
+ const pages = skeleton.getSkeletonData()?.pages ?? [];
+ expect(pages).toHaveLength(1);
+ expect(pages[0].sections).toHaveLength(2);
+ expect(pages[0].sections[1].columns[0].isFull).toBe(true);
+ expect(pages[0].sections[1].columns[1].lines.length).toBeGreaterThan(0);
+
+ skeleton.dispose();
+ univer.dispose();
+ });
+
+ it('keeps NEXT_COLUMN below the top of a preceding continuous section', () => {
+ const first = `First${DataStreamTreeTokenType.PARAGRAPH}${DataStreamTreeTokenType.SECTION_BREAK}`;
+ const second = `Second${DataStreamTreeTokenType.PARAGRAPH}${DataStreamTreeTokenType.SECTION_BREAK}`;
+ const third = `Third${DataStreamTreeTokenType.PARAGRAPH}${DataStreamTreeTokenType.SECTION_BREAK}`;
+ const columns = [
+ { width: 130, paddingEnd: 20 },
+ { width: 130, paddingEnd: 0 },
+ ];
+ const univer = new Univer();
+ const localeService = univer.__getInjector().get(LocaleService);
+ const documentModel = new DocumentDataModel({
+ id: 'continuous-next-column-sections',
+ body: {
+ dataStream: `${first}${second}${third}`,
+ paragraphs: [
+ { startIndex: first.length - 2, paragraphId: 'first-paragraph' },
+ { startIndex: first.length + second.length - 2, paragraphId: 'second-paragraph' },
+ { startIndex: first.length + second.length + third.length - 2, paragraphId: 'third-paragraph' },
+ ],
+ sectionBreaks: [
+ { sectionId: 'first-section', startIndex: first.length - 1, columnProperties: columns },
+ {
+ sectionId: 'second-section',
+ startIndex: first.length + second.length - 1,
+ sectionType: SectionType.CONTINUOUS,
+ columnProperties: columns,
+ },
+ {
+ sectionId: 'third-section',
+ startIndex: first.length + second.length + third.length - 1,
+ sectionType: SectionType.NEXT_COLUMN,
+ columnProperties: columns,
+ },
+ ],
+ },
+ documentStyle: {
+ documentFlavor: DocumentFlavor.TRADITIONAL,
+ pageSize: { width: 320, height: 400 },
+ marginTop: 20,
+ marginBottom: 20,
+ marginLeft: 20,
+ marginRight: 20,
+ },
+ });
+ const skeleton = DocumentSkeleton.create(new DocumentViewModel(documentModel), localeService);
+
+ skeleton.calculate();
+
+ const sections = skeleton.getSkeletonData()?.pages[0].sections ?? [];
+ expect(sections).toHaveLength(3);
+ expect(sections[2].top).toBe(sections[1].top);
+ expect(sections[2].columns[0].isFull).toBe(true);
+ expect(sections[2].columns[1].lines.length).toBeGreaterThan(0);
+
+ skeleton.dispose();
+ univer.dispose();
+ });
+
+ it('moves NEXT_COLUMN to the next page when no column remains', () => {
+ const first = `First${DataStreamTreeTokenType.PARAGRAPH}${DataStreamTreeTokenType.SECTION_BREAK}`;
+ const second = `Second${DataStreamTreeTokenType.PARAGRAPH}${DataStreamTreeTokenType.SECTION_BREAK}`;
+ const univer = new Univer();
+ const localeService = univer.__getInjector().get(LocaleService);
+ const documentModel = new DocumentDataModel({
+ id: 'next-column-overflow',
+ body: {
+ dataStream: `${first}${second}`,
+ paragraphs: [
+ { startIndex: first.length - 2, paragraphId: 'first-paragraph' },
+ { startIndex: first.length + second.length - 2, paragraphId: 'second-paragraph' },
+ ],
+ sectionBreaks: [
+ { sectionId: 'first-section', startIndex: first.length - 1 },
+ {
+ sectionId: 'second-section',
+ startIndex: first.length + second.length - 1,
+ sectionType: SectionType.NEXT_COLUMN,
+ },
+ ],
+ },
+ documentStyle: {
+ documentFlavor: DocumentFlavor.TRADITIONAL,
+ pageSize: { width: 320, height: 400 },
+ marginTop: 20,
+ marginBottom: 20,
+ marginLeft: 20,
+ marginRight: 20,
+ },
+ });
+ const skeleton = DocumentSkeleton.create(new DocumentViewModel(documentModel), localeService);
+
+ skeleton.calculate();
+
+ expect(skeleton.getSkeletonData()?.pages.map(({ pageNumber }) => pageNumber)).toEqual([1, 2]);
+
+ skeleton.dispose();
+ univer.dispose();
+ });
+
+ it('adds one skeleton-only filler page for an ODD_PAGE section', () => {
+ const first = `First${DataStreamTreeTokenType.PARAGRAPH}${DataStreamTreeTokenType.SECTION_BREAK}`;
+ const second = `Second${DataStreamTreeTokenType.PARAGRAPH}${DataStreamTreeTokenType.SECTION_BREAK}`;
+ const univer = new Univer();
+ const localeService = univer.__getInjector().get(LocaleService);
+ const documentModel = new DocumentDataModel({
+ id: 'odd-page-section',
+ body: {
+ dataStream: `${first}${second}`,
+ paragraphs: [
+ { startIndex: first.length - 2, paragraphId: 'first-paragraph' },
+ { startIndex: first.length + second.length - 2, paragraphId: 'second-paragraph' },
+ ],
+ sectionBreaks: [
+ { sectionId: 'first-section', startIndex: first.length - 1 },
+ {
+ sectionId: 'second-section',
+ startIndex: first.length + second.length - 1,
+ sectionType: SectionType.ODD_PAGE,
+ },
+ ],
+ },
+ documentStyle: {
+ documentFlavor: DocumentFlavor.TRADITIONAL,
+ pageSize: { width: 320, height: 400 },
+ marginTop: 20,
+ marginBottom: 20,
+ marginLeft: 20,
+ marginRight: 20,
+ },
+ });
+ const skeleton = DocumentSkeleton.create(new DocumentViewModel(documentModel), localeService);
+
+ skeleton.calculate();
+
+ const pages = skeleton.getSkeletonData()?.pages ?? [];
+ expect(pages.map(({ pageNumber }) => pageNumber)).toEqual([1, 2, 3]);
+ expect(pages[1].sections.every((section) => section.columns.every((column) => column.lines.length === 0))).toBe(true);
+ expect(pages[2].sections.some((section) => section.columns.some((column) => column.lines.length > 0))).toBe(true);
+
+ skeleton.dispose();
+ univer.dispose();
+ });
+
+ it('adds one skeleton-only filler page for an EVEN_PAGE section', () => {
+ const first = `First${DataStreamTreeTokenType.PARAGRAPH}${DataStreamTreeTokenType.SECTION_BREAK}`;
+ const second = `Second${DataStreamTreeTokenType.PARAGRAPH}${DataStreamTreeTokenType.SECTION_BREAK}`;
+ const univer = new Univer();
+ const localeService = univer.__getInjector().get(LocaleService);
+ const documentModel = new DocumentDataModel({
+ id: 'even-page-section',
+ body: {
+ dataStream: `${first}${second}`,
+ paragraphs: [
+ { startIndex: first.length - 2, paragraphId: 'first-paragraph' },
+ { startIndex: first.length + second.length - 2, paragraphId: 'second-paragraph' },
+ ],
+ sectionBreaks: [
+ { sectionId: 'first-section', startIndex: first.length - 1 },
+ {
+ sectionId: 'second-section',
+ startIndex: first.length + second.length - 1,
+ sectionType: SectionType.EVEN_PAGE,
+ },
+ ],
+ },
+ documentStyle: {
+ documentFlavor: DocumentFlavor.TRADITIONAL,
+ pageNumberStart: 2,
+ pageSize: { width: 320, height: 400 },
+ marginTop: 20,
+ marginBottom: 20,
+ marginLeft: 20,
+ marginRight: 20,
+ },
+ });
+ const skeleton = DocumentSkeleton.create(new DocumentViewModel(documentModel), localeService);
+
+ skeleton.calculate();
+
+ const pages = skeleton.getSkeletonData()?.pages ?? [];
+ expect(pages.map(({ pageNumber }) => pageNumber)).toEqual([2, 3, 4]);
+ expect(pages[1].sections.every((section) => section.columns.every((column) => column.lines.length === 0))).toBe(true);
+ expect(pages[2].sections.some((section) => section.columns.some((column) => column.lines.length > 0))).toBe(true);
+
+ skeleton.dispose();
+ univer.dispose();
+ });
+
+ it('treats an unspecified Section Type as NEXT_PAGE without changing the snapshot value', () => {
+ const first = `First${DataStreamTreeTokenType.PARAGRAPH}${DataStreamTreeTokenType.SECTION_BREAK}`;
+ const second = `Second${DataStreamTreeTokenType.PARAGRAPH}${DataStreamTreeTokenType.SECTION_BREAK}`;
+ const univer = new Univer();
+ const localeService = univer.__getInjector().get(LocaleService);
+ const documentModel = new DocumentDataModel({
+ id: 'unspecified-section',
+ body: {
+ dataStream: `${first}${second}`,
+ paragraphs: [
+ { startIndex: first.length - 2, paragraphId: 'first-paragraph' },
+ { startIndex: first.length + second.length - 2, paragraphId: 'second-paragraph' },
+ ],
+ sectionBreaks: [
+ { sectionId: 'first-section', startIndex: first.length - 1 },
+ {
+ sectionId: 'second-section',
+ startIndex: first.length + second.length - 1,
+ sectionType: SectionType.SECTION_TYPE_UNSPECIFIED,
+ },
+ ],
+ },
+ documentStyle: {
+ documentFlavor: DocumentFlavor.TRADITIONAL,
+ pageSize: { width: 320, height: 400 },
+ marginTop: 20,
+ marginBottom: 20,
+ marginLeft: 20,
+ marginRight: 20,
+ },
+ });
+ const skeleton = DocumentSkeleton.create(new DocumentViewModel(documentModel), localeService);
+
+ skeleton.calculate();
+
+ expect(skeleton.getSkeletonData()?.pages.map(({ pageNumber }) => pageNumber)).toEqual([1, 2]);
+ expect(documentModel.getBody()?.sectionBreaks?.[1].sectionType).toBe(SectionType.SECTION_TYPE_UNSPECIFIED);
+
+ skeleton.dispose();
+ univer.dispose();
+ });
+
+ it('restarts page numbering from an explicit section pageNumberStart', () => {
+ const first = `First${DataStreamTreeTokenType.PARAGRAPH}${DataStreamTreeTokenType.SECTION_BREAK}`;
+ const second = `Second${DataStreamTreeTokenType.PARAGRAPH}${DataStreamTreeTokenType.SECTION_BREAK}`;
+ const univer = new Univer();
+ const localeService = univer.__getInjector().get(LocaleService);
+ const documentModel = new DocumentDataModel({
+ id: 'section-page-number-start',
+ body: {
+ dataStream: `${first}${second}`,
+ paragraphs: [
+ { startIndex: first.length - 2, paragraphId: 'first-paragraph' },
+ { startIndex: first.length + second.length - 2, paragraphId: 'second-paragraph' },
+ ],
+ sectionBreaks: [
+ { sectionId: 'first-section', startIndex: first.length - 1 },
+ {
+ sectionId: 'second-section',
+ startIndex: first.length + second.length - 1,
+ sectionType: SectionType.NEXT_PAGE,
+ pageNumberStart: 7,
+ },
+ ],
+ },
+ documentStyle: {
+ documentFlavor: DocumentFlavor.TRADITIONAL,
+ pageSize: { width: 320, height: 400 },
+ marginTop: 20,
+ marginBottom: 20,
+ marginLeft: 20,
+ marginRight: 20,
+ },
+ });
+ const skeleton = DocumentSkeleton.create(new DocumentViewModel(documentModel), localeService);
+
+ skeleton.calculate();
+
+ expect(skeleton.getSkeletonData()?.pages.map(({ pageNumber }) => pageNumber)).toEqual([1, 7]);
+
+ skeleton.dispose();
+ univer.dispose();
+ });
+
+ it('starts a continuous section on a new page when its page geometry changes', () => {
+ const first = `First${DataStreamTreeTokenType.PARAGRAPH}${DataStreamTreeTokenType.SECTION_BREAK}`;
+ const second = `Second${DataStreamTreeTokenType.PARAGRAPH}${DataStreamTreeTokenType.SECTION_BREAK}`;
+ const univer = new Univer();
+ const localeService = univer.__getInjector().get(LocaleService);
+ const documentModel = new DocumentDataModel({
+ id: 'continuous-geometry-change',
+ body: {
+ dataStream: `${first}${second}`,
+ paragraphs: [
+ { startIndex: first.length - 2, paragraphId: 'first-paragraph' },
+ { startIndex: first.length + second.length - 2, paragraphId: 'second-paragraph' },
+ ],
+ sectionBreaks: [
+ { sectionId: 'first-section', startIndex: first.length - 1 },
+ {
+ sectionId: 'second-section',
+ startIndex: first.length + second.length - 1,
+ sectionType: SectionType.CONTINUOUS,
+ pageSize: { width: 400, height: 320 },
+ pageOrient: PageOrientType.LANDSCAPE,
+ marginLeft: 30,
+ marginRight: 30,
+ },
+ ],
+ },
+ documentStyle: {
+ documentFlavor: DocumentFlavor.TRADITIONAL,
+ pageSize: { width: 320, height: 400 },
+ marginTop: 20,
+ marginBottom: 20,
+ marginLeft: 20,
+ marginRight: 20,
+ },
+ });
+ const skeleton = DocumentSkeleton.create(new DocumentViewModel(documentModel), localeService);
+
+ skeleton.calculate();
+
+ const pages = skeleton.getSkeletonData()?.pages ?? [];
+ expect(pages.map(({ pageWidth, pageHeight }) => [pageWidth, pageHeight])).toEqual([
+ [320, 400],
+ [400, 320],
+ ]);
+ expect(pages[1].pageOrient).toBe(PageOrientType.LANDSCAPE);
+ expect(pages[1].marginLeft).toBe(30);
+
+ skeleton.dispose();
+ univer.dispose();
+ });
+
it('lays out a traditional form document with header footer and long fields', () => {
const univer = new Univer();
const localeService = univer.__getInjector().get(LocaleService);
diff --git a/packages/engine-render/src/components/docs/layout/block/paragraph/linebreaking.ts b/packages/engine-render/src/components/docs/layout/block/paragraph/linebreaking.ts
index ebfe5ff7f7..98fdfac550 100644
--- a/packages/engine-render/src/components/docs/layout/block/paragraph/linebreaking.ts
+++ b/packages/engine-render/src/components/docs/layout/block/paragraph/linebreaking.ts
@@ -42,6 +42,7 @@ import {
DataStreamTreeTokenType,
DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING,
DocumentBlockRangeType,
+ DocxBreakType,
PositionedObjectLayoutType,
resolveDocumentParagraphStyle,
} from '@univerjs/core';
@@ -65,9 +66,8 @@ function _endsWithToken(text: string, glyphs: IDocumentSkeletonGlyph[], token: D
function _isMarkedDocxColumnBreak(viewModel: DocumentViewModel, absoluteIndex: number): boolean {
const customRange = viewModel.getCustomRange(absoluteIndex);
- const properties = customRange?.properties as { docxBreakType?: unknown } | undefined;
- return properties?.docxBreakType === 'column';
+ return customRange?.properties?.docxBreakType === DocxBreakType.COLUMN;
}
function _glyphCount(glyphs: IDocumentSkeletonGlyph[]): number {
diff --git a/packages/engine-render/src/components/docs/layout/doc-skeleton.ts b/packages/engine-render/src/components/docs/layout/doc-skeleton.ts
index 3b621e9b22..83cbcf2d7d 100644
--- a/packages/engine-render/src/components/docs/layout/doc-skeleton.ts
+++ b/packages/engine-render/src/components/docs/layout/doc-skeleton.ts
@@ -44,6 +44,7 @@ import { LanguageDetector } from './hyphenation/language-detector';
import { createSkeletonPage } from './model/page';
import { createSkeletonSection } from './model/section';
import {
+ getLastNotFullColumnInfo,
getLastPage,
getNullSkeleton,
getPageFromPath,
@@ -54,6 +55,27 @@ import {
updateInlineDrawingCoordsAndBorder,
} from './tools';
+function getEffectiveSectionType(sectionType: SectionType | undefined): SectionType {
+ return sectionType == null || sectionType === SectionType.SECTION_TYPE_UNSPECIFIED
+ ? SectionType.NEXT_PAGE
+ : sectionType;
+}
+
+function hasCompatiblePageGeometry(page: IDocumentSkeletonPage, config: ReturnType<typeof prepareSectionBreakConfig>): boolean {
+ const { pageSize, pageOrient, marginTop, marginBottom, marginLeft, marginRight } = config;
+ return page.pageWidth === pageSize?.width &&
+ page.pageHeight === pageSize?.height &&
+ page.pageOrient === pageOrient &&
+ page.originMarginTop === marginTop &&
+ page.originMarginBottom === marginBottom &&
+ page.marginLeft === marginLeft &&
+ page.marginRight === marginRight;
+}
+
+function isTargetPageParity(pageNumber: number, sectionType: SectionType): boolean {
+ return sectionType === SectionType.EVEN_PAGE ? pageNumber % 2 === 0 : pageNumber % 2 === 1;
+}
+
export enum DocumentSkeletonState {
PENDING = 'pending',
CALCULATING = 'calculating',
@@ -1357,26 +1379,66 @@ export class DocumentSkeleton extends Skeleton {
const sectionNode = viewModel.getChildren()[i];
const sectionBreakConfig = prepareSectionBreakConfig(ctx, i);
const { sectionType, columnProperties, columnSeparatorType, sectionTypeNext, pageNumberStart = 1 } = sectionBreakConfig;
+ const explicitPageNumberStart = viewModel.getSectionBreak(sectionNode.endIndex)?.pageNumberStart;
+ const effectiveSectionType = getEffectiveSectionType(sectionType);
let curSkeletonPage = getLastPage(allSkeletonPages);
- let isContinuous = false;
+ let reuseCurrentPage = false;
+ let reuseNextColumn = false;
ctx.sectionBreakConfigCache.set(sectionNode.endIndex, sectionBreakConfig);
- if (sectionType === SectionType.CONTINUOUS && curSkeletonPage != null) {
+ if (
+ effectiveSectionType === SectionType.NEXT_COLUMN &&
+ layoutAnchor == null &&
+ curSkeletonPage != null &&
+ hasCompatiblePageGeometry(curSkeletonPage, sectionBreakConfig)
+ ) {
+ updateBlockIndex(allSkeletonPages, -1, ctx.docsConfig.documentCompatibilityPolicy);
+ reuseNextColumn = this._addNewSectionByNextColumn(
+ curSkeletonPage,
+ columnProperties!,
+ columnSeparatorType!
+ );
+ }
+
+ if (
+ effectiveSectionType === SectionType.CONTINUOUS &&
+ curSkeletonPage != null &&
+ hasCompatiblePageGeometry(curSkeletonPage, sectionBreakConfig)
+ ) {
updateBlockIndex(allSkeletonPages, -1, ctx.docsConfig.documentCompatibilityPolicy);
if (layoutAnchor != null && layoutAnchor >= sectionNode.startIndex && layoutAnchor <= sectionNode.endIndex) {
this._restoreContinuousSection(curSkeletonPage, columnProperties!, columnSeparatorType!);
} else {
this._addNewSectionByContinuous(curSkeletonPage, columnProperties!, columnSeparatorType!);
}
- isContinuous = true;
+ reuseCurrentPage = true;
+ } else if (reuseNextColumn) {
+ reuseCurrentPage = true;
} else if (layoutAnchor == null || curSkeletonPage == null) {
+ let nextPageNumber = curSkeletonPage == null
+ ? pageNumberStart
+ : explicitPageNumberStart ?? curSkeletonPage.pageNumber + 1;
+ if (
+ curSkeletonPage != null &&
+ (effectiveSectionType === SectionType.EVEN_PAGE || effectiveSectionType === SectionType.ODD_PAGE) &&
+ !isTargetPageParity(nextPageNumber, effectiveSectionType)
+ ) {
+ const fillerPage = createSkeletonPage(
+ ctx,
+ sectionBreakConfig,
+ skeletonResourceReference,
+ nextPageNumber
+ );
+ allSkeletonPages.push(fillerPage);
+ nextPageNumber++;
+ }
curSkeletonPage = createSkeletonPage(
ctx,
sectionBreakConfig,
skeletonResourceReference,
- curSkeletonPage?.pageNumber ?? pageNumberStart
+ nextPageNumber
);
}
@@ -1395,10 +1457,10 @@ export class DocumentSkeleton extends Skeleton {
// TODO
}
- if (isContinuous) {
- const continuousFirstPage = pages.shift();
- if (continuousFirstPage && allSkeletonPages.length > 0) {
- allSkeletonPages[allSkeletonPages.length - 1] = continuousFirstPage;
+ if (reuseCurrentPage) {
+ const reusedFirstPage = pages.shift();
+ if (reusedFirstPage && allSkeletonPages.length > 0) {
+ allSkeletonPages[allSkeletonPages.length - 1] = reusedFirstPage;
}
}
@@ -1470,6 +1532,43 @@ export class DocumentSkeleton extends Skeleton {
sections.push(newSection);
}
+ private _addNewSectionByNextColumn(
+ curSkeletonPage: IDocumentSkeletonPage,
+ columnProperties: ISectionColumnProperties[],
+ columnSeparatorType: ColumnSeparatorType
+ ): boolean {
+ const currentColumn = getLastNotFullColumnInfo(curSkeletonPage);
+ const nextColumnIndex = currentColumn == null ? 0 : currentColumn.index + 1;
+ const columnCount = columnProperties.length || 1;
+ if (nextColumnIndex >= columnCount) {
+ return false;
+ }
+
+ const {
+ pageWidth,
+ pageHeight,
+ marginTop,
+ marginBottom,
+ marginLeft,
+ marginRight,
+ } = curSkeletonPage;
+ const sectionTop = curSkeletonPage.sections.at(-1)?.top ?? 0;
+ const newSection = createSkeletonSection(
+ columnProperties,
+ columnSeparatorType,
+ sectionTop,
+ 0,
+ pageWidth - marginLeft - marginRight,
+ pageHeight - marginTop - marginBottom - sectionTop
+ );
+ newSection.columns.slice(0, nextColumnIndex).forEach((column) => {
+ column.isFull = true;
+ });
+ newSection.parent = curSkeletonPage;
+ curSkeletonPage.sections.push(newSection);
+ return true;
+ }
+
private _restoreContinuousSection(
curSkeletonPage: IDocumentSkeletonPage,
columnProperties: ISectionColumnProperties[],