Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
feat(board): support explicit locale exports (#7182)
Univer5ea22853229f
diff --git a/packages/core/src/services/__tests__/authz-resource.integration.spec.ts b/packages/core/src/services/__tests__/authz-resource.integration.spec.tsindex 24f913417d..15006b5795 100644--- a/packages/core/src/services/__tests__/authz-resource.integration.spec.ts+++ b/packages/core/src/services/__tests__/authz-resource.integration.spec.ts@@ -16,8 +16,9 @@import type { Univer } from '../../univer';import { UnitAction, UnitObject, UnitRole } from '@univerjs/protocol';+import { BehaviorSubject } from 'rxjs';import { afterEach, beforeEach, describe, expect, it } from 'vitest';-import { UniverInstanceType } from '../../common/unit';+import { UnitModel, UniverInstanceType } from '../../common/unit';import { IAuthzIoService } from '../authz-io/type';import { IUniverInstanceService } from '../instance/instance.service';import { IMentionIOService } from '../mention-io/type';@@ -25,6 +26,49 @@ import { IResourceLoaderService } from '../resource-loader/type';import { UserManagerService } from '../user-manager/user-manager.service';import { createTestBed } from './create-test-bed';+interface ITestBoardData {+ id: string;+ name?: string;+ resources?: Array<{ name: string; data: string }>;+}++class MockBoardUnit extends UnitModel<ITestBoardData, UniverInstanceType.UNIVER_BOARD> {+ override readonly type = UniverInstanceType.UNIVER_BOARD;+ override name$ = new BehaviorSubject('');+ private readonly _snapshot: ITestBoardData;++ constructor(snapshot: Partial<ITestBoardData> = {}) {+ super();+ this._snapshot = {+ id: 'board-resource',+ name: '',+ ...snapshot,+ };+ this.name$.next(this._snapshot.name ?? '');+ }++ override getUnitId(): string {+ return this._snapshot.id;+ }++ override setName(name: string): void {+ this._snapshot.name = name;+ this.name$.next(name);+ }++ override getSnapshot(): ITestBoardData {+ return this._snapshot;+ }++ override getRev(): number {+ return 1;+ }++ override incrementRev(): void { }++ override setRev(): void { }+}+describe('Authz/resource integration', () => {let univer: Univer;let unitId: string;@@ -133,6 +177,55 @@ describe('Authz/resource integration', () => {expect(reloaded[0].actions).toEqual([{ action: UnitAction.Edit, allowed: false }]);});+ it('should persist and reload permission resources for board units', async () => {+ const injector = univer.__getInjector();+ const authzIoService = injector.get(IAuthzIoService);+ const resourceLoaderService = injector.get(IResourceLoaderService);+ const univerInstanceService = injector.get(IUniverInstanceService);++ univerInstanceService.registerCtorForType(UniverInstanceType.UNIVER_BOARD, MockBoardUnit);+ const board = univer.createUnit<ITestBoardData, MockBoardUnit>(UniverInstanceType.UNIVER_BOARD, {+ id: 'board-resource',+ });+ const objectID = await authzIoService.create({+ objectType: UnitObject.Workbook,+ worksheetObject: {+ unitID: board.getUnitId(),+ name: 'Board permission',+ collaborators: [],+ strategies: [{ action: UnitAction.Edit, role: UnitRole.Owner }],+ scope: undefined,+ },+ });++ const snapshot = resourceLoaderService.saveUnit<ITestBoardData>(board.getUnitId());+ const authzResource = snapshot?.resources?.find((resource) => resource.name === 'SHEET_AuthzIoMockService_PLUGIN');++ expect(authzResource?.data).toContain(objectID);++ expect(univerInstanceService.disposeUnit(board.getUnitId())).toBe(true);++ const unloaded = await authzIoService.list({+ unitID: board.getUnitId(),+ objectIDs: [objectID],+ actions: [UnitAction.Edit],+ });++ expect(unloaded[0].name).toBe('');+ expect(unloaded[0].actions).toEqual([{ action: UnitAction.Edit, allowed: true }]);++ univer.createUnit<ITestBoardData, MockBoardUnit>(UniverInstanceType.UNIVER_BOARD, snapshot!);++ const reloaded = await authzIoService.list({+ unitID: board.getUnitId(),+ objectIDs: [objectID],+ actions: [UnitAction.Edit],+ });++ expect(reloaded[0].name).toBe('Board permission');+ expect(reloaded[0].actions).toEqual([{ action: UnitAction.Edit, allowed: true }]);+ });+it('should expose current user data consistently through mention and user services', async () => {const injector = univer.__getInjector();const userManagerService = injector.get(UserManagerService);diff --git a/packages/core/src/services/__tests__/resources.spec.ts b/packages/core/src/services/__tests__/resources.spec.tsindex 92cca93f80..fa2d239aec 100644--- a/packages/core/src/services/__tests__/resources.spec.ts+++ b/packages/core/src/services/__tests__/resources.spec.ts@@ -49,6 +49,12 @@ interface ITestSlideData {resources?: IResources;}+interface ITestBoardData {+ id: string;+ name?: string;+ resources?: IResources;+}+class MockSlideUnit extends UnitModel<ITestSlideData> {override type = UniverInstanceType.UNIVER_SLIDE;override name$ = new BehaviorSubject('');@@ -86,6 +92,43 @@ class MockSlideUnit extends UnitModel<ITestSlideData> {override setRev(): void { }}+class MockBoardUnit extends UnitModel<ITestBoardData, UniverInstanceType.UNIVER_BOARD> {+ override readonly type = UniverInstanceType.UNIVER_BOARD;+ override name$ = new BehaviorSubject('');+ private readonly _snapshot: ITestBoardData;++ constructor(snapshot: Partial<ITestBoardData> = {}) {+ super();+ this._snapshot = {+ id: 'board-resource',+ name: '',+ ...snapshot,+ };+ this.name$.next(this._snapshot.name ?? '');+ }++ override getUnitId(): string {+ return this._snapshot.id;+ }++ override setName(name: string): void {+ this._snapshot.name = name;+ this.name$.next(name);+ }++ override getSnapshot(): ITestBoardData {+ return this._snapshot;+ }++ override getRev(): number {+ return 1;+ }++ override incrementRev(): void { }++ override setRev(): void { }+}+describe('Test resources service', () => {let univer: Univer;@@ -232,6 +275,68 @@ describe('Test resources service', () => {expect(loads).toEqual([['slide-late-resource', 'late']]);});+ it('should load and unload board resources through the real unit lifecycle', () => {+ const injector = univer.__getInjector();+ const resourceManagerService = injector.get(IResourceManagerService);+ const resourceLoaderService = injector.get(IResourceLoaderService);+ const univerInstanceService = injector.get(IUniverInstanceService);+ const pluginName = 'BOARD_TEST_PLUGIN' as never;+ const loads: Array<[string, string]> = [];+ const unloads: string[] = [];++ univerInstanceService.registerCtorForType(UniverInstanceType.UNIVER_BOARD, MockBoardUnit);+ resourceManagerService.registerPluginResource<{ kind: string }>({+ pluginName,+ businesses: [UniverInstanceType.UNIVER_BOARD],+ onLoad: (unitId, resource) => loads.push([unitId, resource.kind]),+ onUnLoad: (unitId) => unloads.push(unitId),+ toJson: (unitId) => JSON.stringify({ kind: `saved:${unitId}` }),+ parseJson: (bytes) => JSON.parse(bytes),+ });++ const board = univer.createUnit<ITestBoardData, MockBoardUnit>(UniverInstanceType.UNIVER_BOARD, {+ id: 'board-resource',+ resources: [+ { name: pluginName, data: '{"kind":"loaded"}' },+ ],+ });++ expect(loads).toContainEqual(['board-resource', 'loaded']);+ expect(resourceLoaderService.saveUnit<ITestBoardData>('board-resource')?.resources).toEqual([+ { name: pluginName, data: '{"kind":"saved:board-resource"}' },+ ]);++ expect(univerInstanceService.disposeUnit(board.getUnitId())).toBe(true);+ expect(unloads).toEqual(['board-resource']);+ });++ it('should load resources for existing board units when hooks register later', () => {+ const injector = univer.__getInjector();+ const resourceManagerService = injector.get(IResourceManagerService);+ const univerInstanceService = injector.get(IUniverInstanceService);+ const pluginName = 'BOARD_LATE_PLUGIN' as never;+ const loads: Array<[string, string]> = [];++ univerInstanceService.registerCtorForType(UniverInstanceType.UNIVER_BOARD, MockBoardUnit);+ univer.createUnit<ITestBoardData, MockBoardUnit>(UniverInstanceType.UNIVER_BOARD, {+ id: 'board-late-resource',+ resources: [+ { name: pluginName, data: '{"kind":"late"}' },+ ],+ });++ resourceManagerService.registerPluginResource<{ kind: string }>({+ pluginName,+ businesses: [UniverInstanceType.UNIVER_BOARD],+ onLoad: (unitId, resource) => loads.push([unitId, resource.kind]),+ onUnLoad: () => undefined,+ toJson: () => '{}',+ parseJson: (bytes) => JSON.parse(bytes),+ });++ expect(loads).toEqual([['board-late-resource', 'late']]);+ });+it('should load array-shaped slide plugin resources through the unit lifecycle', () => {const injector = univer.__getInjector();const resourceManagerService = injector.get(IResourceManagerService);diff --git a/packages/core/src/services/authz-io/authz-io-local.service.ts b/packages/core/src/services/authz-io/authz-io-local.service.tsindex f25e8a4441..326db5426f 100644--- a/packages/core/src/services/authz-io/authz-io-local.service.ts+++ b/packages/core/src/services/authz-io/authz-io-local.service.ts@@ -100,7 +100,12 @@ export class AuthzIoLocalService implements IAuthzIoService {return JSON.parse(json);},pluginName: 'SHEET_AuthzIoMockService_PLUGIN',- businesses: [UniverInstanceType.UNIVER_SHEET, UniverInstanceType.UNIVER_DOC, UniverInstanceType.UNIVER_SLIDE],+ businesses: [+ UniverInstanceType.UNIVER_SHEET,+ UniverInstanceType.UNIVER_DOC,+ UniverInstanceType.UNIVER_SLIDE,+ UniverInstanceType.UNIVER_BOARD,+ ],onLoad: (_unitId, resource) => {for (const key in resource) {this._permissionMap.set(key, resource[key]);@@ -333,7 +338,7 @@ export class AuthzIoLocalService implements IAuthzIoService {return undefined;}- async putCollaborators(config: IPutCollaboratorsRequest): Promise<void> {+ async putCollaborators(_config: IPutCollaboratorsRequest): Promise<void> {return undefined;}diff --git a/packages/core/src/services/instance/__tests__/instance.service.spec.ts b/packages/core/src/services/instance/__tests__/instance.service.spec.tsindex 21896c7ec9..e53509a010 100644--- a/packages/core/src/services/instance/__tests__/instance.service.spec.ts+++ b/packages/core/src/services/instance/__tests__/instance.service.spec.ts@@ -71,6 +71,17 @@ class MockSlideUnit extends UnitModel {override setRev() {}}+class MockBoardUnit extends UnitModel {+ override type = UniverInstanceType.UNIVER_BOARD;+ override name$ = new BehaviorSubject('');+ override setName() {}+ override getSnapshot() { return {}; }+ override getUnitId() { return 'board-unit'; }+ override getRev() { return 1; }+ override incrementRev() {}+ override setRev() {}+}+describe('UniverInstanceService', () => {let service: UniverInstanceService;let contextService: ContextService;@@ -89,12 +100,15 @@ describe('UniverInstanceService', () => {service.registerCtorForType(UniverInstanceType.UNIVER_SHEET, WorkbookModel as never);service.registerCtorForType(UniverInstanceType.UNIVER_DOC, DocumentDataModel as never);service.registerCtorForType(UniverInstanceType.UNIVER_SLIDE, MockSlideUnit as never);+ service.registerCtorForType(UniverInstanceType.UNIVER_BOARD, MockBoardUnit as never);service.__setCreateHandler((type, data, _ctor, options) => {let unit: UnitModel;if (type === UniverInstanceType.UNIVER_SHEET) {unit = injector.createInstance(WorkbookModel as never, data as Partial<IWorkbookData>, logService) as UnitModel;} else if (type === UniverInstanceType.UNIVER_DOC) {unit = injector.createInstance(DocumentDataModel as never, data as Partial<IDocumentData>) as UnitModel;+ } else if (type === UniverInstanceType.UNIVER_BOARD) {+ unit = new MockBoardUnit();} else {unit = injector.createInstance(MockSlideUnit);}@@ -192,4 +206,15 @@ describe('UniverInstanceService', () => {expect(currentIds).toContain('sheet-unit');expect(currentIds).toContain('sheet-unit-2');});++ it('should create board units as an independent unit type', () => {+ const board = service.createUnit<object, MockBoardUnit>(UniverInstanceType.UNIVER_BOARD, {});++ expect(UniverInstanceType.UNIVER_BOARD).toBe(6);+ expect(board.getUnitId()).toBe('board-unit');+ expect(service.getCurrentUnitOfType<MockBoardUnit>(UniverInstanceType.UNIVER_BOARD)?.getUnitId()).toBe('board-unit');+ expect(service.getUnit<MockBoardUnit>('board-unit', UniverInstanceType.UNIVER_BOARD)).toBe(board);+ expect(service.getAllUnitsForType<MockBoardUnit>(UniverInstanceType.UNIVER_BOARD)).toEqual([board]);+ expect(service.getUnitType('board-unit')).toBe(UniverInstanceType.UNIVER_BOARD);+ });});diff --git a/packages/core/src/services/resource-loader/resource-loader.service.ts b/packages/core/src/services/resource-loader/resource-loader.service.tsindex 498a2584c1..ef1658d93d 100644--- a/packages/core/src/services/resource-loader/resource-loader.service.ts+++ b/packages/core/src/services/resource-loader/resource-loader.service.ts@@ -72,6 +72,12 @@ export class ResourceLoaderService extends Disposable implements IResourceLoader});break;}+ case UniverInstanceType.UNIVER_BOARD: {+ this._univerInstanceService.getAllUnitsForType<UnitModel<{ resources?: IResources }>>(UniverInstanceType.UNIVER_BOARD).forEach((board) => {+ loadHookResource(hook, board.getUnitId(), board.getSnapshot().resources, 'Board');+ });+ break;+ }case UniverInstanceType.UNIVER_SHEET: {this._univerInstanceService.getAllUnitsForType<Workbook>(UniverInstanceType.UNIVER_SHEET).forEach((workbook) => {loadHookResource(hook, workbook.getUnitId(), workbook.getSnapshot().resources, 'Workbook');@@ -108,6 +114,12 @@ export class ResourceLoaderService extends Disposable implements IResourceLoaderthis._resourceManagerService.loadResources(slide.getUnitId(), slide.getSnapshot().resources);}));+ this.disposeWithMe(+ this._univerInstanceService.getTypeOfUnitAdded$<UnitModel<{ resources?: IResources }>>(UniverInstanceType.UNIVER_BOARD).subscribe((event) => {+ const { unit: board } = event;+ this._resourceManagerService.loadResources(board.getUnitId(), board.getSnapshot().resources);+ })+ );this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$<Workbook>(UniverInstanceType.UNIVER_SHEET).subscribe((workbook) => {@@ -125,6 +137,11 @@ export class ResourceLoaderService extends Disposable implements IResourceLoaderthis._resourceManagerService.unloadResources(slide.getUnitId(), UniverInstanceType.UNIVER_SLIDE);}));+ this.disposeWithMe(+ this._univerInstanceService.getTypeOfUnitDisposed$<UnitModel>(UniverInstanceType.UNIVER_BOARD).subscribe((board) => {+ this._resourceManagerService.unloadResources(board.getUnitId(), UniverInstanceType.UNIVER_BOARD);+ })+ );}saveUnit<T = object>(unitId: string) {diff --git a/packages/engine-render/src/components/docs/layout/__tests__/doc-no-wrap-measure.spec.ts b/packages/engine-render/src/components/docs/layout/__tests__/doc-no-wrap-measure.spec.tsnew file mode 100644index 0000000000..e7678d37e9--- /dev/null+++ b/packages/engine-render/src/components/docs/layout/__tests__/doc-no-wrap-measure.spec.ts@@ -0,0 +1,61 @@+/**+ * 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 { IDocumentData } from '@univerjs/core';+import { describe, expect, it, vi } from 'vitest';+import { FontCache } from '../shaping-engine/font-cache';+import { measureDocumentNoWrapTextWidth } from '../doc-no-wrap-measure';++function createDocument(dataStream: string): IDocumentData {+ return {+ id: 'doc-no-wrap-measure-test',+ body: {+ dataStream,+ textRuns: [],+ paragraphs: [],+ },+ documentStyle: {+ pageSize: {+ width: 4000,+ height: Infinity,+ },+ },+ };+}++describe('measureDocumentNoWrapTextWidth', () => {+ it('uses docs CJK-Latin spacing for mixed no-wrap text', () => {+ const measureSpy = vi.spyOn(FontCache, 'getMeasureText').mockImplementation((text: string) => ({+ width: Array.from(text).reduce((total, char) => total + (/[\u2E80-\u9FFF\uF900-\uFAFF]/u.test(char) ? 20 : 10), 0),+ }) as never);++ expect(measureDocumentNoWrapTextWidth(createDocument('A好B\r\n'))).toBe(50);+ expect(measureDocumentNoWrapTextWidth(createDocument('ABC\r\n'))).toBe(30);+ expect(measureDocumentNoWrapTextWidth(createDocument('你好\r\n'))).toBe(40);++ measureSpy.mockRestore();+ });++ it('keeps trailing whitespace local to the current line', () => {+ const measureSpy = vi.spyOn(FontCache, 'getMeasureText').mockImplementation((text: string) => ({+ width: text.length * 10,+ }) as never);++ expect(measureDocumentNoWrapTextWidth(createDocument('A \r\nBBBB\r\n'))).toBe(40);++ measureSpy.mockRestore();+ });+});diff --git a/packages/engine-render/src/components/docs/layout/doc-no-wrap-measure.ts b/packages/engine-render/src/components/docs/layout/doc-no-wrap-measure.tsnew file mode 100644index 0000000000..f1bbc96841--- /dev/null+++ b/packages/engine-render/src/components/docs/layout/doc-no-wrap-measure.ts@@ -0,0 +1,174 @@+/**+ * 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 { IDocumentData, ITextStyle } from '@univerjs/core';+import { getFontStyleString } from '../../../basics/tools';+import { FontCache } from './shaping-engine/font-cache';++interface IDocumentNoWrapTextRunLike {+ st?: number;+ ed?: number;+ ts?: ITextStyle;+}++function splitDocumentNoWrapMeasureLines(text: string): string[] {+ return text.replace(/\r\n/g, '\n').replace(/\r/g, '\n').split('\n');+}++function isDocumentNoWrapMeasureTrailingWhitespace(char: string): boolean {+ return char === ' ' || char === '\t' || char === '\u00A0';+}++function getDocumentNoWrapMeasureTrailingWhitespaceStart(text: string): number {+ let index = text.length;+ while (index > 0 && isDocumentNoWrapMeasureTrailingWhitespace(text[index - 1])) {+ index--;+ }+ return index;+}++function isDocumentNoWrapMeasureCJKText(char: string): boolean {+ return /[\u2E80-\u9FFF\uF900-\uFAFF]/u.test(char);+}++function isDocumentNoWrapMeasureLatinText(char: string): boolean {+ return /[a-z\d]/i.test(char);+}++function measureDocumentNoWrapTextByStyle(text: string, textStyle: ITextStyle | undefined): number {+ if (!text) {+ return 0;+ }++ return FontCache.getMeasureText(text, getFontStyleString(textStyle).fontCache).width;+}++function measureDocumentNoWrapCJKLatinSpacing(+ segment: string,+ textStyle: ITextStyle | undefined,+ previous: { char: string; cjkWidth: number }+): number {+ let spacing = 0;++ for (const char of Array.from(segment)) {+ const isCJK = isDocumentNoWrapMeasureCJKText(char);+ const cjkWidth = isCJK ? measureDocumentNoWrapTextByStyle(char, textStyle) : 0;++ if (isCJK && isDocumentNoWrapMeasureLatinText(previous.char)) {+ spacing += cjkWidth / 4;+ }++ if (isDocumentNoWrapMeasureLatinText(char) && isDocumentNoWrapMeasureCJKText(previous.char)) {+ spacing += previous.cjkWidth / 4;+ }++ previous.char = char;+ previous.cjkWidth = cjkWidth;+ }++ return spacing;+}++function measureDocumentNoWrapLineByStyle(text: string, textStyle: ITextStyle | undefined): number {+ const previous = { char: '', cjkWidth: 0 };++ return measureDocumentNoWrapTextByStyle(text, textStyle) ++ measureDocumentNoWrapCJKLatinSpacing(text, textStyle, previous);+}++function measureDocumentNoWrapRunsWidth(+ dataStream: string,+ textRuns: IDocumentNoWrapTextRunLike[]+): number {+ let currentLineWidth = 0;+ let maxLineWidth = 0;+ let pendingTrailingWhitespaceWidth = 0;+ const previous = { char: '', cjkWidth: 0 };++ const appendSegment = (segment: string, textStyle: ITextStyle | undefined) => {+ if (!segment) {+ return;+ }++ const trailingStart = getDocumentNoWrapMeasureTrailingWhitespaceStart(segment);+ const visibleSegment = segment.slice(0, trailingStart);+ const trailingWhitespace = segment.slice(trailingStart);++ if (visibleSegment) {+ currentLineWidth += pendingTrailingWhitespaceWidth;+ pendingTrailingWhitespaceWidth = 0;+ currentLineWidth += measureDocumentNoWrapTextByStyle(visibleSegment, textStyle);+ currentLineWidth += measureDocumentNoWrapCJKLatinSpacing(visibleSegment, textStyle, previous);+ }++ if (trailingWhitespace) {+ pendingTrailingWhitespaceWidth += measureDocumentNoWrapTextByStyle(trailingWhitespace, textStyle);+ measureDocumentNoWrapCJKLatinSpacing(trailingWhitespace, textStyle, previous);+ }+ };++ const finishLine = () => {+ maxLineWidth = Math.max(maxLineWidth, currentLineWidth);+ currentLineWidth = 0;+ pendingTrailingWhitespaceWidth = 0;+ previous.char = '';+ previous.cjkWidth = 0;+ };++ textRuns.forEach((run) => {+ const start = Math.max(0, run.st ?? 0);+ const end = Math.max(start, run.ed ?? start);+ const segments = splitDocumentNoWrapMeasureLines(dataStream.slice(start, end));++ segments.forEach((segment, index) => {+ if (index > 0) {+ finishLine();+ }++ appendSegment(segment, run.ts);+ });+ });++ return Math.max(maxLineWidth, currentLineWidth);+}++/**+ * Measures the widest no-wrap line using the same text-width policy that docs+ * layout relies on for lightweight shape/text-box autofit flows.+ *+ * This is intentionally not a full document layout replacement: callers that+ * need line breaking, pagination, floating objects, or final line metrics should+ * use `DocumentSkeleton`. This helper exists for consumers that must size a+ * no-wrap host before committing a full layout pass. Keep docs-specific glyph+ * width adjustments here so feature packages do not duplicate paragraph shaping+ * details such as CJK-Latin spacing.+ */+export function measureDocumentNoWrapTextWidth(documentData: IDocumentData | null | undefined): number {+ const body = documentData?.body;+ const dataStream = body?.dataStream ?? '';+ const textRuns = body?.textRuns as IDocumentNoWrapTextRunLike[] | undefined;++ if (textRuns?.length) {+ return measureDocumentNoWrapRunsWidth(dataStream, textRuns);+ }++ const fallbackTextStyle = documentData?.documentStyle?.textStyle;++ return Math.max(+ 0,+ ...splitDocumentNoWrapMeasureLines(dataStream).map((line) => measureDocumentNoWrapLineByStyle(line, fallbackTextStyle))+ );+}diff --git a/packages/engine-render/src/index.ts b/packages/engine-render/src/index.tsindex 9ba5824645..6c4ae39db0 100644--- a/packages/engine-render/src/index.ts+++ b/packages/engine-render/src/index.ts@@ -24,6 +24,7 @@ export { Documents } from './components/docs/document';export type { IPageRenderConfig } from './components/docs/document';export type { IDocumentOffsetConfig } from './components/docs/document';export { getTableIdAndSliceIndex } from './components/docs/layout/block/table';+export { measureDocumentNoWrapTextWidth } from './components/docs/layout/doc-no-wrap-measure';export * from './components/docs/layout/doc-simple-skeleton';export { DocumentSkeleton } from './components/docs/layout/doc-skeleton';export type { IFindNodeRestrictions } from './components/docs/layout/doc-skeleton';