Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
fix(facade): fix doc facade (#7169)
wpxp123456a140ee018b76
diff --git a/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts b/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.tsindex 974bf94849..74bd9b8cd7 100644--- a/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts+++ b/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts@@ -241,8 +241,9 @@ test('diff set force string cell', async () => {});activeWorkbook.startEditing();- window.univerAPI.getActiveDocument().appendText("'1");- activeWorkbook.endEditingAsync(true);+ const activeDocument = window.univerAPI.getActiveDocument();+ activeDocument.getBody().getElement(0)?.asParagraph().appendText("'1");+ await activeWorkbook.endEditingAsync(true);activeSheet.getRange('I1').setValue({v: '001',@@ -263,6 +264,7 @@ test('diff set force string cell', async () => {},});});+ await page.waitForTimeout(1000);const filename = generateSnapshotName('set-force-string-cell');const screenshot = await page.locator(SHEET_MAIN_CANVAS_ID).screenshot();diff --git a/packages/docs/src/facade/__tests__/f-document-body.spec.ts b/packages/docs/src/facade/__tests__/f-document-body.spec.tsindex 19d597764b..ebf1849482 100644--- a/packages/docs/src/facade/__tests__/f-document-body.spec.ts+++ b/packages/docs/src/facade/__tests__/f-document-body.spec.ts@@ -68,7 +68,7 @@ describe('FDocumentBody', () => {expect(body.deleteRange({ startOffset: 0, endOffset: 6 })).toBe(true);expect(document.save().body?.dataStream).toBe('Hello Alpha\rBeta\rGamma\rTail\r\n');- expect(body.replaceRange({ startOffset: 0, endOffset: 5 }, 'Hi')).toBe(true);+ expect(body.getElement(0)!.asParagraph().setText('Hi Alpha')).toBe(true);expect(document.save().body?.dataStream).toBe('Hi Alpha\rBeta\rGamma\rTail\r\n');expect(body.setTextStyle({ startOffset: 0, endOffset: 2 }, { bl: 1 })).toBe(true);diff --git a/packages/docs/src/facade/__tests__/f-document.spec.ts b/packages/docs/src/facade/__tests__/f-document.spec.tsindex aa0d83f5b8..71041251d7 100644--- a/packages/docs/src/facade/__tests__/f-document.spec.ts+++ b/packages/docs/src/facade/__tests__/f-document.spec.ts@@ -16,7 +16,8 @@import type { IDocumentData, Univer } from '@univerjs/core';import type { FDocument } from '../f-document';-import { IResourceManagerService, IUndoRedoService, UniverInstanceType } from '@univerjs/core';+import { ICommandService, IResourceManagerService, IUndoRedoService, 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';@@ -42,27 +43,20 @@ describe('FDocument', () => {univer.dispose();});- it('edits document text through append, insert and paragraph operations', () => {- expect(document.appendText('Univer')).toBe(true);+ it('edits document text through body and paragraph operations', () => {+ expect(document.getBody().insertText(6, 'Univer')).toBe(true);expect(document.save().body?.dataStream).toBe('Hello,Univer\r\n');univer.dispose();createDocumentFacade();- expect(document.insertText('Docs', {- endOffset: 4,- segmentId: '',- startOffset: 2,- })).toBe(true);+ expect(document.getBody().getElement(0)!.asParagraph().setText('HeDocso,')).toBe(true);expect(document.save().body?.dataStream).toBe('HeDocso,\r\n');univer.dispose();createDocumentFacade();- expect(document.insertParagraph('Line 1\nLine 2', {- endOffset: 6,- segmentId: '',- startOffset: 6,- })).toBe(true);- expect(document.save().body?.dataStream).toBe('Hello,Line 1\rLine 2\r\r\n');+ expect(document.getBody().appendParagraph('Line 1').getText()).toBe('Line 1');+ expect(document.getBody().appendParagraph('Line 2').getText()).toBe('Line 2');+ expect(document.save().body?.dataStream).toBe('Hello,\rLine 1\rLine 2\r\n');});it('includes current document resources in saved snapshots', () => {@@ -95,7 +89,12 @@ describe('FDocument', () => {it('runs undo and redo against the active document', () => {get(IUndoRedoService);- expect(document.appendText('One')).toBe(true);+ expect(get(ICommandService).syncExecuteCommand(InsertTextCommand.id, {+ unitId: document.getId(),+ body: { dataStream: 'One' },+ range: { startOffset: 6, endOffset: 6, collapsed: true, segmentId: '' },+ segmentId: '',+ })).toBe(true);expect(document.save().body?.dataStream).toBe('Hello,One\r\n');expect(document.undo()).toBe(true);diff --git a/packages/docs/src/facade/f-document-block-range.ts b/packages/docs/src/facade/f-document-block-range.tsindex fbb0939954..315c22b3d5 100644--- a/packages/docs/src/facade/f-document-block-range.ts+++ b/packages/docs/src/facade/f-document-block-range.ts@@ -15,7 +15,7 @@*/import type { DocumentBlockRangeType, IDocumentBlockRange, Injector } from '@univerjs/core';-import type { FDocumentBody } from './f-document-body';+import type { FDocumentBody, IFDocumentBodyEdit } from './f-document-body';import type { IFDocumentElementInfo } from './f-document-element';import { DocumentBlockType } from '@univerjs/core';import { FDocumentElement } from './f-document-element';@@ -36,10 +36,11 @@ interface IFDocumentBlockRangeMixin {export class FDocumentBlockRange extends FDocumentElement {constructor(protected readonly body: FDocumentBody,+ protected readonly bodyEdit: IFDocumentBodyEdit,protected readonly info: IFDocumentElementInfo,protected readonly injector: Injector) {- super(body, info, injector);+ super(body, bodyEdit, info, injector);if (this.getType() !== DocumentBlockType.BLOCK_RANGE) {throw new Error(`Element type is not a block range: ${this.getType()}`);@@ -138,7 +139,7 @@ export class FDocumentBlockRange extends FDocumentElement {endIndex: text.length,}];- return this._body.replaceRange({ startOffset: startIndex, endOffset: endIndex + 1 }, updateBody);+ return this._bodyEdit.replaceRange({ startOffset: startIndex, endOffset: endIndex + 1 }, updateBody);}/**@@ -171,7 +172,7 @@ export class FDocumentBlockRangeMixin extends FDocumentElement {if (this.getType() !== DocumentBlockType.BLOCK_RANGE) {throw new Error(`Element type is not a block range: ${this.getType()}`);}- return this._injector.createInstance(FDocumentBlockRange, this._body, this.getResolvedInfo(), this._injector);+ return this._injector.createInstance(FDocumentBlockRange, this._body, this._bodyEdit, this.getResolvedInfo(), this._injector);}}diff --git a/packages/docs/src/facade/f-document-body.ts b/packages/docs/src/facade/f-document-body.tsindex a25440026f..6ed21f08fd 100644--- a/packages/docs/src/facade/f-document-body.ts+++ b/packages/docs/src/facade/f-document-body.ts@@ -38,6 +38,11 @@ export interface IFDocumentTextRange {segmentId?: string;}+export interface IFDocumentBodyEdit {+ replaceRange: (range: IFDocumentTextRange, body: IDocumentBody) => boolean;+ retainRange: (range: IFDocumentTextRange, body: IDocumentBody, coverType: UpdateDocsAttributeType) => boolean;+}+/*** A Facade API object bounded to a document body or header/footer segment.* It provides Google Docs-like element access and range editing methods.@@ -48,11 +53,18 @@ export interface IFDocumentTextRange {* @hideconstructor*/export class FDocumentBody {+ private readonly _bodyEdit: IFDocumentBodyEdit;+constructor(private readonly _documentDataModel: DocumentDataModel,private readonly _injector: Injector,private readonly _segmentId = ''- ) {}+ ) {+ this._bodyEdit = {+ replaceRange: this._replaceBodyRange.bind(this),+ retainRange: this._retainBodyRange.bind(this),+ };+ }/*** Get the segment id of this document body facade.@@ -103,7 +115,13 @@ export class FDocumentBody {getElements(): FDocumentElement[] {const children = this._getChildren();return children.map((child) => {- return this._injector.createInstance(FDocumentElement, this, child, this._injector);+ return this._injector.createInstance(+ FDocumentElement,+ this,+ this._bodyEdit,+ child,+ this._injector+ );});}@@ -218,7 +236,13 @@ export class FDocumentBody {const info = this._resolveParagraphInfo(paragraph, index, paragraphs[index - 1]?.startIndex);- return this._injector.createInstance(FDocumentParagraph, this, info, this._injector);+ return this._injector.createInstance(+ FDocumentParagraph,+ this,+ this._bodyEdit,+ info,+ this._injector+ );}/**@@ -253,56 +277,6 @@ export class FDocumentBody {return this._replaceBodyRange(range, { dataStream: '' });}- /**- * Replace a range with plain text or rich text body data.- * @param {IFDocumentTextRange} range The text range to replace.- * @param {string | IDocumentBody | undefined} value The replacement text or rich text body data. If `undefined`, the range is deleted.- * @returns {boolean} `true` if the replacement was applied.- * @example- * ```ts- * const fDocument = univerAPI.getActiveDocument();- * const fDocumentBody = fDocument.getBody();- *- * // Replace a range with plain text- * fDocumentBody.replaceRange({ startOffset: 0, endOffset: 5 }, 'Hello');- *- * // Replace a range with rich text body data- * const richText = univerAPI.newRichText().insertText(5, 'World', { ff: 'Arial', fs: 12 });- * fDocumentBody.replaceRange({ startOffset: 5, endOffset: 10 }, richText);- * ```- */- replaceRange(range: IFDocumentTextRange, value: string | IDocumentBody | undefined): boolean {- let body: IDocumentBody = { dataStream: '' };-- if (typeof value === 'string') {- body = buildPlainTextInsertBody(value);- } else if (value) {- body = value;- }-- return this._replaceBodyRange(range, body);- }-- /**- * Retain a range with a new body and cover type.- * @param {IFDocumentTextRange} range The text range to retain.- * @param {IDocumentBody} body The new body data to retain.- * @param {UpdateDocsAttributeType} coverType The cover type for the retained range.- * @returns {boolean} `true` if the retention was applied.- * @example- * ```ts- * const fDocument = univerAPI.getActiveDocument();- * const fDocumentBody = fDocument.getBody();- *- * // Retain a range with a new body and cover type- * const newBody = univerAPI.newRichText().insertText(0, 'Retained text', { bl: 1 });- * fDocumentBody.retainRange({ startOffset: 0, endOffset: 5 }, newBody, univerAPI.Enum.UpdateDocsAttributeType.COVER);- * ```- */- retainRange(range: IFDocumentTextRange, body: IDocumentBody, coverType: UpdateDocsAttributeType): boolean {- return this._retainBodyRange(range, body, coverType);- }-/*** Remove a paragraph by paragraph id.* @param {FDocumentParagraph} paragraph The paragraph handle to remove.diff --git a/packages/docs/src/facade/f-document-custom-block.ts b/packages/docs/src/facade/f-document-custom-block.tsindex ce691f4516..58ff06e18f 100644--- a/packages/docs/src/facade/f-document-custom-block.ts+++ b/packages/docs/src/facade/f-document-custom-block.ts@@ -15,7 +15,7 @@*/import type { ICustomBlock, Injector } from '@univerjs/core';-import type { FDocumentBody } from './f-document-body';+import type { FDocumentBody, IFDocumentBodyEdit } from './f-document-body';import type { IFDocumentElementInfo } from './f-document-element';import { DocumentBlockType } from '@univerjs/core';import { FDocumentElement } from './f-document-element';@@ -31,10 +31,11 @@ interface IFDocumentCustomBlockMixin {export class FDocumentCustomBlock extends FDocumentElement {constructor(protected readonly body: FDocumentBody,+ protected readonly bodyEdit: IFDocumentBodyEdit,protected readonly info: IFDocumentElementInfo,protected readonly injector: Injector) {- super(body, info, injector);+ super(body, bodyEdit, info, injector);if (this.getType() !== DocumentBlockType.CUSTOM_BLOCK) {throw new Error(`Element type is not a custom block: ${this.getType()}`);@@ -71,7 +72,7 @@ export class FDocumentCustomBlockMixin extends FDocumentElement {if (this.getType() !== DocumentBlockType.CUSTOM_BLOCK) {throw new Error(`Element type is not a custom block: ${this.getType()}`);}- return this._injector.createInstance(FDocumentCustomBlock, this._body, this.getResolvedInfo(), this._injector);+ return this._injector.createInstance(FDocumentCustomBlock, this._body, this._bodyEdit, this.getResolvedInfo(), this._injector);}}diff --git a/packages/docs/src/facade/f-document-element.ts b/packages/docs/src/facade/f-document-element.tsindex 212cf18e13..8fbe0db145 100644--- a/packages/docs/src/facade/f-document-element.ts+++ b/packages/docs/src/facade/f-document-element.ts@@ -15,7 +15,7 @@*/import type { Injector } from '@univerjs/core';-import type { FDocumentBody } from './f-document-body';+import type { FDocumentBody, IFDocumentBodyEdit } from './f-document-body';import { DocumentBlockType } from '@univerjs/core';import { FBase } from '@univerjs/core/facade';@@ -40,6 +40,7 @@ export interface IFDocumentElementInfo {export class FDocumentElement extends FBase {constructor(protected readonly _body: FDocumentBody,+ protected readonly _bodyEdit: IFDocumentBodyEdit,protected readonly _info: IFDocumentElementInfo,protected readonly _injector: Injector) {diff --git a/packages/docs/src/facade/f-document-paragraph.ts b/packages/docs/src/facade/f-document-paragraph.tsindex 2383ad0695..d4dd800ff5 100644--- a/packages/docs/src/facade/f-document-paragraph.ts+++ b/packages/docs/src/facade/f-document-paragraph.ts@@ -15,10 +15,11 @@*/import type { IDocumentBody, Injector, IParagraph, IParagraphStyle } from '@univerjs/core';-import type { FDocumentBody, IFDocumentTextRange } from './f-document-body';+import type { FDocumentBody, IFDocumentBodyEdit, IFDocumentTextRange } from './f-document-body';import type { IFDocumentElementInfo } from './f-document-element';import { DocumentBlockType, PresetListType, RESTORE_INSERTED_PARAGRAPH_IDS, UpdateDocsAttributeType } from '@univerjs/core';import { FDocumentElement } from './f-document-element';+import { buildPlainTextInsertBody } from './utils';interface IFDocumentParagraphMixin {asParagraph(): FDocumentParagraph;@@ -50,10 +51,11 @@ export interface IFDocumentResolvedParagraph {export class FDocumentParagraph extends FDocumentElement {constructor(protected readonly body: FDocumentBody,+ protected readonly bodyEdit: IFDocumentBodyEdit,protected readonly info: IFDocumentElementInfo,protected readonly injector: Injector) {- super(body, info, injector);+ super(body, bodyEdit, info, injector);if (this.getType() !== DocumentBlockType.PARAGRAPH) {throw new Error(`Element type is not a paragraph: ${this.getType()}`);@@ -180,7 +182,7 @@ export class FDocumentParagraph extends FDocumentElement {*/setText(text: string): boolean {const { startOffset, endOffset } = this.getResolvedParagraphInfo();- return this._body.replaceRange({ startOffset, endOffset }, text);+ return this._bodyEdit.replaceRange({ startOffset, endOffset }, buildPlainTextInsertBody(text));}/**@@ -238,7 +240,7 @@ export class FDocumentParagraph extends FDocumentElement {this._preserveExplicitParagraphIds(updateBody);- return this._body.retainRange(+ return this._bodyEdit.retainRange({ startOffset: endOffset, endOffset: endOffset + 1 },updateBody,UpdateDocsAttributeType.REPLACE@@ -328,7 +330,7 @@ export class FDocumentParagraph extends FDocumentElement {this._preserveExplicitParagraphIds(updateBody);- return this._body.retainRange(+ return this._bodyEdit.retainRange({ startOffset: endOffset, endOffset: endOffset + 1 },updateBody,UpdateDocsAttributeType.REPLACE@@ -345,7 +347,7 @@ export class FDocumentParagraphMixin extends FDocumentElement {if (this.getType() !== DocumentBlockType.PARAGRAPH) {throw new Error(`Element type is not a paragraph: ${this.getType()}`);}- return this._injector.createInstance(FDocumentParagraph, this._body, this.getResolvedInfo(), this._injector);+ return this._injector.createInstance(FDocumentParagraph, this._body, this._bodyEdit, this.getResolvedInfo(), this._injector);}}diff --git a/packages/docs/src/facade/f-document-table.ts b/packages/docs/src/facade/f-document-table.tsindex 02e2efd987..1c7091be4c 100644--- a/packages/docs/src/facade/f-document-table.ts+++ b/packages/docs/src/facade/f-document-table.ts@@ -15,7 +15,7 @@*/import type { ICustomTable, Injector } from '@univerjs/core';-import type { FDocumentBody } from './f-document-body';+import type { FDocumentBody, IFDocumentBodyEdit } from './f-document-body';import type { IFDocumentElementInfo } from './f-document-element';import { DocumentBlockType } from '@univerjs/core';import { FDocumentElement } from './f-document-element';@@ -31,10 +31,11 @@ interface IFDocumentTableMixin {export class FDocumentTable extends FDocumentElement {constructor(protected readonly body: FDocumentBody,+ protected readonly bodyEdit: IFDocumentBodyEdit,protected readonly info: IFDocumentElementInfo,protected readonly injector: Injector) {- super(body, info, injector);+ super(body, bodyEdit, info, injector);if (this.getType() !== DocumentBlockType.TABLE) {throw new Error(`Element type is not a table: ${this.getType()}`);@@ -71,7 +72,7 @@ export class FDocumentTableMixin extends FDocumentElement {if (this.getType() !== DocumentBlockType.TABLE) {throw new Error(`Element type is not a table: ${this.getType()}`);}- return this._injector.createInstance(FDocumentTable, this._body, this.getResolvedInfo(), this._injector);+ return this._injector.createInstance(FDocumentTable, this._body, this._bodyEdit, this.getResolvedInfo(), this._injector);}}diff --git a/packages/docs/src/facade/f-document.ts b/packages/docs/src/facade/f-document.tsindex 2bb19fd910..a9df543ebb 100644--- a/packages/docs/src/facade/f-document.ts+++ b/packages/docs/src/facade/f-document.ts@@ -15,7 +15,6 @@*/import type { DocumentDataModel, IDocumentData } from '@univerjs/core';-import type { IInsertTextCommandParams } from '@univerjs/docs';import {ICommandService,Inject,@@ -26,20 +25,7 @@ import {UndoCommand,} from '@univerjs/core';import { FBaseInitialable } from '@univerjs/core/facade';-import { InsertTextCommand } from '@univerjs/docs';import { FDocumentBody } from './f-document-body';-import {- buildPlainTextInsertBody,- getNormalizedPlainTextCursorOffset,- getParagraphStyleAtOffset,-} from './utils';--export interface IDocumentInsertTextFacadeOptions {- startOffset?: number;- endOffset?: number;- segmentId?: string;- cursorOffset?: number;-}/*** Facade API object bounded to a document. It provides a set of methods to interact with the document.@@ -176,140 +162,4 @@ export class FDocument extends FBaseInitialable {this._univerInstanceService.focusUnit(this.id);return this._commandService.syncExecuteCommand(RedoCommand.id);}-- /**- * Adds the specified text to the end of this text region.- * @param {string} text - The text to be added to the end of this text region.- * @return {boolean} `true` if the text was successfully appended, or `false` if it failed.- * @example- * ```typescript- * const fDocument = univerAPI.getActiveDocument();- * const success = fDocument.appendText('Hello, world!');- * console.log(success);- * ```- */- appendText(text: string): boolean {- const { body } = this.save();-- if (!body) {- throw new Error('The document body is empty');- }-- const lastPosition = body.dataStream.length - 2;-- return this.insertText(text, {- startOffset: lastPosition,- endOffset: lastPosition,- segmentId: '',- });- }-- /**- * Inserts text at the provided document range. Defaults to appending before the final section break.- * @param {string} text - The text to insert.- * @param {IDocumentInsertTextFacadeOptions} options - Optional target range, segment id, and cursor offset.- * @returns {boolean} `true` if the text was successfully inserted, or `false` if it failed.- * @example- *- * // Insert text at a specific range in the document body- * ```typescript- * const fDocument = univerAPI.getActiveDocument();- * const success = fDocument.insertText('Hello, world!', {- * startOffset: 5,- * endOffset: 5,- * segmentId: '',- * cursorOffset: 13,- * });- * console.log(success);- * ```- *- * // Insert text at the beginning of a header or footer segment- * ```typescript- * const fDocument = univerAPI.getActiveDocument();- * const snapshot = fDocument.save();- * const { headers, footers } = snapshot;- *- * if (headers) {- * for (const headerId in headers) {- * if (headerId === 'target-header-id') {- * fDocument.insertText('Hello, header!', {- * startOffset: 0,- * endOffset: 0,- * segmentId: headerId,- * });- * }- * }- * }- *- * if (footers) {- * for (const footerId in footers) {- * if (footerId === 'target-footer-id') {- * fDocument.insertText('Hello, footer!', {- * startOffset: 0,- * endOffset: 0,- * segmentId: footerId,- * });- * }- * }- * }- * ```- */- insertText(text: string, options: IDocumentInsertTextFacadeOptions = {}): boolean {- const unitId = this.id;- const { body } = this.save();-- if (!body) {- throw new Error('The document body is empty');- }-- const startOffset = options.startOffset ?? Math.max(0, body.dataStream.length - 2);- const endOffset = options.endOffset ?? startOffset;- const segmentId = options.segmentId ?? '';- const activeRange = {- startOffset,- endOffset,- collapsed: startOffset === endOffset,- segmentId,- };- const removeLeadingParagraphBreak = startOffset === 0;- const insertBody = buildPlainTextInsertBody(text, {- paragraphStyle: getParagraphStyleAtOffset(body, startOffset),- removeLeadingParagraphBreak,- });- const cursorOffset = options.cursorOffset == null- ? undefined- : getNormalizedPlainTextCursorOffset(text, options.cursorOffset, removeLeadingParagraphBreak);-- return this._commandService.syncExecuteCommand<IInsertTextCommandParams>(InsertTextCommand.id, {- unitId,- body: insertBody,- range: activeRange,- segmentId,- ...(cursorOffset == null ? {} : { cursorOffset }),- });- }-- /**- * Inserts one or more plain-text paragraphs at the provided document range.- * @param {string} text - The paragraph text to insert. Newlines are normalized to document paragraph separators.- * @param {IDocumentInsertTextFacadeOptions} options - Optional target range, segment id, and cursor offset.- * @returns {boolean} `true` if the paragraphs were successfully inserted, or `false` if it failed.- * @example- * ```typescript- * const fDocument = univerAPI.getActiveDocument();- * const success = fDocument.insertParagraph('Hello, world! This is a new paragraph.', {- * startOffset: 5,- * endOffset: 5,- * });- * console.log(success);- * ```- */- insertParagraph(text = '', options: IDocumentInsertTextFacadeOptions = {}): boolean {- const dataStream = `${text.replace(/\r\n/g, '\n').replace(/\r/g, '\n').split('\n').join('\r\n')}\r\n`;-- return this.insertText(dataStream, {- ...options,- cursorOffset: options.cursorOffset ?? dataStream.length,- });- }}diff --git a/packages/docs/src/facade/f-enum.ts b/packages/docs/src/facade/f-enum.tsdeleted file mode 100644index 48095f334d..0000000000--- a/packages/docs/src/facade/f-enum.ts+++ /dev/null@@ -1,52 +0,0 @@-/**- * 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 { UpdateDocsAttributeType } from '@univerjs/core';-import { FEnum } from '@univerjs/core/facade';--/**- * @ignore- */-export interface IFDocsEnumMixin {- /**- * Update document attribute types. These types define how document attributes are updated.- * - `COVER`: If the attribute is not present, it will be added. If it is present, it will be overwritten while retaining the original properties.- * - `REPLACE`: The original properties will be replaced entirely.- * @example- * ```ts- * const fDocument = univerAPI.getActiveDocument();- * const fDocumentBody = fDocument.getBody();- *- * // Retain a range with a new body and cover type- * const newBody = univerAPI.newRichText().insertText(0, 'Retained text', { bl: 1 });- * fDocumentBody.retainRange({ startOffset: 0, endOffset: 5 }, newBody, univerAPI.Enum.UpdateDocsAttributeType.COVER);- * ```- */- UpdateDocsAttributeType: typeof UpdateDocsAttributeType;-}--export class FDocsEnumMixin extends FEnum implements IFDocsEnumMixin {- override get UpdateDocsAttributeType(): typeof UpdateDocsAttributeType {- return UpdateDocsAttributeType;- }-}--FEnum.extend(FDocsEnumMixin);-declare module '@univerjs/core/facade' {- // eslint-disable-next-line ts/naming-convention- export interface FEnum extends IFDocsEnumMixin {- }-}diff --git a/packages/docs/src/facade/index.ts b/packages/docs/src/facade/index.tsindex e0a3828280..7b48e4f27f 100644--- a/packages/docs/src/facade/index.ts+++ b/packages/docs/src/facade/index.ts@@ -15,7 +15,6 @@*/import './f-univer';-import './f-enum';export { FDocument } from './f-document';export { FDocumentBlockRange } from './f-document-block-range';