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(doc): remove isStartBack and isEndBack and fix issue #352 (#397)
Ran Luod81d994b820c
diff --git a/packages/base-docs/src/Controller/delete-left-input.controller.ts b/packages/base-docs/src/Controller/delete-left-input.controller.tsindex ed661c540c..bb76e39626 100644--- a/packages/base-docs/src/Controller/delete-left-input.controller.ts+++ b/packages/base-docs/src/Controller/delete-left-input.controller.ts@@ -76,20 +76,20 @@ export class DeleteLeftInputController extends Disposable {}const docsModel = this._currentUniverService.getCurrentUniverDocInstance();+const startNodePosition = activeSelection.getStart();+const preSpan = skeleton.findSpanByPosition(startNodePosition);const preIsBullet = hasListSpan(preSpan);const preIsIndent = isIndentBySpan(preSpan, docsModel.body);- const { cursorStart, isCollapse, isStartBack, segmentId, style } = activeRange;+ const { cursorStart, isCollapse, segmentId, style } = activeRange;let cursor = cursorStart;- if (isStartBack === true) {- cursor -= 1;- }+ cursor--;if (isCollapse === false) {cursor += 1;@@ -137,16 +137,15 @@ export class DeleteLeftInputController extends Disposable {paragraphs: [{ ...updateParagraph }],},range: {- cursorStart: paragraphIndex,- cursorEnd: paragraphIndex,- isEndBack: false,- isStartBack: false,+ cursorStart: paragraphIndex + 1,+ cursorEnd: paragraphIndex + 1,isCollapse: true,},segmentId,});} else {const endNodePosition = activeSelection?.getEnd();+if (endNodePosition != null) {const endSpan = skeleton.findSpanByPosition(endNodePosition);if (hasListSpan(endSpan) && !isSameLine(preSpan, endSpan)) {@@ -163,15 +162,8 @@ export class DeleteLeftInputController extends Disposable {skeleton?.calculate();- let isBack = false;-if (isUpdateParagraph) {- isBack = true;cursor++;- } else if (isFirstSpan(span)) {- isBack = true;- } else {- cursor--;}// move selection@@ -180,8 +172,6 @@ export class DeleteLeftInputController extends Disposable {cursorStart: cursor,cursorEnd: cursor,isCollapse: true,- isEndBack: isBack,- isStartBack: isBack,style,},]);diff --git a/packages/base-docs/src/Controller/ime-input.controller.ts b/packages/base-docs/src/Controller/ime-input.controller.tsindex d760462dc3..9b87782d62 100644--- a/packages/base-docs/src/Controller/ime-input.controller.ts+++ b/packages/base-docs/src/Controller/ime-input.controller.ts@@ -90,7 +90,7 @@ export class IMEInputController extends Disposable {const { event, activeRange } = config;- const { cursorStart, cursorEnd, isEndBack, isStartBack, segmentId, style } = this._previousIMERange;+ const { cursorStart, cursorEnd, segmentId, style } = this._previousIMERange;if (skeleton == null || activeRange == null) {return;@@ -122,8 +122,6 @@ export class IMEInputController extends Disposable {cursorStart: cursorStart + len,cursorEnd: cursorEnd + len,isCollapse: true,- isEndBack,- isStartBack,style,},]);diff --git a/packages/base-docs/src/Controller/line-break-input.controller.ts b/packages/base-docs/src/Controller/line-break-input.controller.tsindex 505444380f..4228aa161a 100644--- a/packages/base-docs/src/Controller/line-break-input.controller.ts+++ b/packages/base-docs/src/Controller/line-break-input.controller.ts@@ -18,6 +18,24 @@ import { BreakLineCommand, InsertCommand } from '../commands/commands/core-editiimport { DocSkeletonManagerService } from '../services/doc-skeleton-manager.service';import { TextSelectionManagerService } from '../services/text-selection-manager.service';+function generateParagraphs(dataStream: string) {+ const paragraphs: IParagraph[] = [];++ for (let i = 0, len = dataStream.length; i < len; i++) {+ const char = dataStream[i];++ if (char !== DataStreamTreeTokenType.PARAGRAPH) {+ continue;+ }++ paragraphs.push({+ startIndex: i,+ });+ }++ return paragraphs;+}+@OnLifecycle(LifecycleStages.Rendered, LineBreakInputController)export class LineBreakInputController extends Disposable {private _onInputSubscription: Nullable<Subscription>;@@ -67,23 +85,16 @@ export class LineBreakInputController extends Disposable {}const docsModel = this._currentUniverService.getCurrentUniverDocInstance();+ const unitId = docsModel.getUnitId();- const { cursorStart, cursorEnd, isCollapse, isEndBack, isStartBack, segmentId, style } = activeRange;+ const { cursorStart, segmentId, style } = activeRange;// split paragraph- let cursor = cursorStart;-- if (isStartBack === false) {- cursor += 1;- }-- // const selectionRemain = document.remainActiveSelection() as TextSelection | undefined;-this._commandService.executeCommand(InsertCommand.id, {- unitId: docsModel.getUnitId(),+ unitId,body: {dataStream: DataStreamTreeTokenType.PARAGRAPH,- paragraphs: this._generateParagraph(DataStreamTreeTokenType.PARAGRAPH),+ paragraphs: generateParagraphs(DataStreamTreeTokenType.PARAGRAPH),},range: activeRange,segmentId,@@ -94,33 +105,12 @@ export class LineBreakInputController extends Disposable {// move selectionthis._textSelectionManagerService.replace([{- cursorStart: cursor + 1,- cursorEnd: cursor + 1,+ cursorStart: cursorStart + 1,+ cursorEnd: cursorStart + 1,isCollapse: true,- isEndBack,- isStartBack,style,},]);-- // const span = document.findNodeByCharIndex(++cursor);-- // this._adjustSelection(document as Documents, selectionRemain, span, true);- }-- private _generateParagraph(dataStream: string) {- const paragraphs: IParagraph[] = [];- for (let i = 0, len = dataStream.length; i < len; i++) {- const char = dataStream[i];- if (char !== DataStreamTreeTokenType.PARAGRAPH) {- continue;- }-- paragraphs.push({- startIndex: i,- });- }- return paragraphs;}private _getDocObject() {diff --git a/packages/base-docs/src/Controller/move-cursor.controller.ts b/packages/base-docs/src/Controller/move-cursor.controller.tsindex 3def382620..c841e0a4d7 100644--- a/packages/base-docs/src/Controller/move-cursor.controller.ts+++ b/packages/base-docs/src/Controller/move-cursor.controller.ts@@ -11,7 +11,6 @@ import {import {Direction,Disposable,- getTextIndexByCursor,ICommandInfo,ICommandService,IUniverInstanceService,@@ -88,7 +87,7 @@ export class MoveCursorController extends Disposable {const documentOffsetConfig = docObject.document.getOffsetConfig();- const { cursorStart, cursorEnd, isEndBack, isStartBack, style } = activeRange;+ const { cursorStart, cursorEnd, style } = activeRange;if (direction === Direction.LEFT || direction === Direction.RIGHT) {let cursor;@@ -98,18 +97,18 @@ export class MoveCursorController extends Disposable {let max = -Infinity;for (const range of allRanges) {- min = Math.min(min, getTextIndexByCursor(range!.cursorStart, range!.isStartBack) + 1);- max = Math.max(max, getTextIndexByCursor(range!.cursorEnd, range!.isEndBack) + 1);+ min = Math.min(min, range!.cursorStart);+ max = Math.max(max, range!.cursorEnd);}cursor = direction === Direction.LEFT ? min : max;} else {if (direction === Direction.LEFT) {- cursor = Math.max(0, getTextIndexByCursor(cursorStart, isStartBack));+ cursor = Math.max(0, cursorStart - 1);} else {const dataStreamLength = skeleton.getModel().getBodyModel().getBody().dataStream.length ?? Infinity;// -1 because the length of the string will be 1 larger than the index, and the reason for subtracting another 1 is because it ends in \n- cursor = Math.min(dataStreamLength - 2, getTextIndexByCursor(cursorEnd, isEndBack) + 2);+ cursor = Math.min(dataStreamLength - 2, cursorEnd + 1);}}@@ -118,8 +117,6 @@ export class MoveCursorController extends Disposable {cursorStart: cursor,cursorEnd: cursor,isCollapse: true,- isEndBack: true,- isStartBack: true,style,},]);@@ -159,9 +156,7 @@ export class MoveCursorController extends Disposable {return;}- let isBack = selectionRange.isStartBack;-- const offsetLeft = this._getSpanLeftOffsetInLine(referenceSpan, isBack);+ const offsetLeft = this._getSpanLeftOffsetInLine(referenceSpan);const line = this._getNextOrPrevLine(span, direction);@@ -171,16 +166,15 @@ export class MoveCursorController extends Disposable {const position: Nullable<INodeSearch> = this._matchPositionByLeftOffset(docSkeleton, line, offsetLeft);- isBack = isBack == null ? false : isBack;-if (position == null) {return;}- return { ...position, isBack };+ // TODO: @jocs, hardcode isBack to true, `_getTopOrBottomPosition` need to rewrite.+ return { ...position, isBack: true };}- private _getSpanLeftOffsetInLine(span: IDocumentSkeletonSpan, isBack: boolean) {+ private _getSpanLeftOffsetInLine(span: IDocumentSkeletonSpan) {const divide = span.parent;if (divide == null) {@@ -189,15 +183,11 @@ export class MoveCursorController extends Disposable {const divideLeft = divide.left;- const { left, width } = span;+ const { left } = span;const start = divideLeft + left;- if (isBack === true) {- return start;- }-- return start + width;+ return start;}private _matchPositionByLeftOffset(docSkeleton: DocumentSkeleton, line: IDocumentSkeletonLine, offsetLeft: number) {diff --git a/packages/base-docs/src/Controller/normal-input.controller.ts b/packages/base-docs/src/Controller/normal-input.controller.tsindex 457ac9bc9e..f1f4f5cac8 100644--- a/packages/base-docs/src/Controller/normal-input.controller.ts+++ b/packages/base-docs/src/Controller/normal-input.controller.ts@@ -64,7 +64,7 @@ export class NormalInputController extends Disposable {return;}- const { cursorStart, isEndBack, isStartBack, segmentId, style } = activeRange;+ const { cursorStart, segmentId, style } = activeRange;await this._commandService.executeCommand(InsertCommand.id, {unitId: documentModel.getUnitId(),@@ -85,8 +85,6 @@ export class NormalInputController extends Disposable {cursorStart: cursorStart + len,cursorEnd: cursorStart + len,isCollapse: true,- isEndBack,- isStartBack,style,},]);diff --git a/packages/base-docs/src/commands/commands/__tests__/inline-format.command.spec.ts b/packages/base-docs/src/commands/commands/__tests__/inline-format.command.spec.tsindex 98c6db72ee..b65b838b2d 100644--- a/packages/base-docs/src/commands/commands/__tests__/inline-format.command.spec.ts+++ b/packages/base-docs/src/commands/commands/__tests__/inline-format.command.spec.ts@@ -69,9 +69,7 @@ describe('Test inline format commands', () => {selectionManager.add([{cursorStart: 0,- isStartBack: true,cursorEnd: 5,- isEndBack: false,isCollapse: false,segmentId: '',},diff --git a/packages/base-docs/src/commands/commands/core-editing.command.ts b/packages/base-docs/src/commands/commands/core-editing.command.tsindex bed5b9eeaf..f6ceb4918b 100644--- a/packages/base-docs/src/commands/commands/core-editing.command.ts+++ b/packages/base-docs/src/commands/commands/core-editing.command.ts@@ -1,7 +1,6 @@import {CommandType,createEmptyDocSnapshot,- getTextIndexByCursor,ICommand,ICommandInfo,ICommandService,@@ -23,19 +22,13 @@ import {export const DeleteLeftCommand: ICommand = {id: 'doc.command.delete-left',type: CommandType.COMMAND,- handler: async (accessor) =>- // const inputController = accessor.get(InputController);- // inputController.deleteLeft();- true,+ handler: async () => true,};export const BreakLineCommand: ICommand = {id: 'doc.command.break-line',type: CommandType.COMMAND,- handler: async (accessor) =>- // const inputController = accessor.get(InputController);- // inputController.breakLine();- true,+ handler: async () => true,};export interface IInsertCommandParams {@@ -56,8 +49,7 @@ export const InsertCommand: ICommand<IInsertCommandParams> = {const commandService = accessor.get(ICommandService);const { range, segmentId, body, unitId } = params;- const { cursorStart, isStartBack, isCollapse } = range;- const textStart = getTextIndexByCursor(cursorStart, isStartBack);+ const { cursorStart, isCollapse } = range;const doMutation: ICommandInfo<IRichTextEditingMutationParams> = {id: RichTextEditingMutation.id,@@ -70,7 +62,7 @@ export const InsertCommand: ICommand<IInsertCommandParams> = {if (isCollapse) {doMutation.params!.mutations.push({t: 'r',- len: textStart + 1,+ len: cursorStart,segmentId,});} else {@@ -85,14 +77,6 @@ export const InsertCommand: ICommand<IInsertCommandParams> = {segmentId,});- const undoMutation: ICommandInfo<IRichTextEditingMutationParams> = {- id: RichTextEditingMutation.id,- params: {- unitId,- mutations: [],- },- };-// TODO@wzhudev: prepare undo mutationconst result = commandService.syncExecuteCommand<IRichTextEditingMutationParams,@@ -200,20 +184,18 @@ export const UpdateCommand: ICommand<IUpdateCommandParams> = {},};- const { cursorStart, cursorEnd, isEndBack, isStartBack } = range;- const textStart = getTextIndexByCursor(cursorStart, isStartBack);- const textEnd = getTextIndexByCursor(cursorEnd, isEndBack);+ const { cursorStart, cursorEnd } = range;doMutation.params!.mutations.push({t: 'r',- len: textStart + 1,+ len: cursorStart,segmentId,});doMutation.params!.mutations.push({t: 'r',body: updateBody,- len: textEnd - textStart + 1,+ len: cursorEnd - cursorStart,segmentId,coverType,});@@ -267,11 +249,9 @@ export const IMEInputCommand: ICommand<IIMEInputCommandParams> = {};if (range.isCollapse) {- const start = getTextIndexByCursor(range.cursorStart, range.isStartBack);-doMutation.params!.mutations.push({t: 'r',- len: start + 1,+ len: range.cursorStart,segmentId,});} else {@@ -340,11 +320,11 @@ function getRetainAndDeleteFromReplace(range: ITextSelectionRange,segmentId?: string): Array<IRetainMutationParams | IDeleteMutationParams> {- const { cursorStart, cursorEnd, isEndBack, isStartBack, isCollapse } = range;+ const { cursorStart, cursorEnd, isCollapse } = range;const dos: Array<IRetainMutationParams | IDeleteMutationParams> = [];- const textStart = getTextIndexByCursor(cursorStart, isStartBack) + (isCollapse ? 0 : 1);- const textEnd = getTextIndexByCursor(cursorEnd, isEndBack);+ const textStart = cursorStart + (isCollapse ? -1 : 0);+ const textEnd = cursorEnd - 1;if (textStart > 0) {dos.push({diff --git a/packages/base-docs/src/commands/commands/inline-format.command.ts b/packages/base-docs/src/commands/commands/inline-format.command.tsindex 37c529e3df..2a4f98d410 100644--- a/packages/base-docs/src/commands/commands/inline-format.command.ts+++ b/packages/base-docs/src/commands/commands/inline-format.command.ts@@ -2,7 +2,6 @@ import { ITextSelectionRangeWithStyle } from '@univerjs/base-render';import {BooleanNumber,CommandType,- getTextIndexByCursor,ICommand,ICommandInfo,ICommandService,@@ -142,16 +141,14 @@ export const SetInlineFormatCommand: ICommand<ISetInlineFormatCommandParams> = {memoryCursor.reset();for (const selection of selections) {- const { cursorStart, cursorEnd, isStartBack, isEndBack } = selection;- const textStart = getTextIndexByCursor(cursorStart, isStartBack);- const textEnd = getTextIndexByCursor(cursorEnd, isEndBack);+ const { cursorStart, cursorEnd } = selection;const body: IDocumentBody = {dataStream: '',textRuns: [{st: 0,- ed: textEnd - textStart,+ ed: cursorEnd - cursorStart,ts: {[COMMAND_ID_TO_FORMAT_KEY_MAP[preCommandId]]: formatValue,},@@ -159,7 +156,7 @@ export const SetInlineFormatCommand: ICommand<ISetInlineFormatCommandParams> = {],};- const len = textStart + 1 - memoryCursor.cursor;+ const len = cursorStart - memoryCursor.cursor;if (len !== 0) {doMutation.params!.mutations.push({t: 'r',@@ -171,12 +168,12 @@ export const SetInlineFormatCommand: ICommand<ISetInlineFormatCommandParams> = {doMutation.params!.mutations.push({t: 'r',body,- len: textEnd - textStart,+ len: cursorEnd - cursorStart,segmentId,});memoryCursor.reset();- memoryCursor.moveCursor(textEnd + 1);+ memoryCursor.moveCursor(cursorEnd);}const result = commandService.syncExecuteCommand<@@ -220,17 +217,14 @@ function getReverseFormatValueInSelection(let si = 0;while (ti !== textRuns.length && si !== selections.length) {- const { cursorStart, cursorEnd, isStartBack, isEndBack } = selections[si];-- const textStart = getTextIndexByCursor(cursorStart, isStartBack) + 1;- const textEnd = getTextIndexByCursor(cursorEnd, isEndBack) + 1;+ const { cursorStart, cursorEnd } = selections[si];// TODO: @jocs handle sid in textRunconst { st, ed, ts } = textRuns[ti];- if (textEnd <= st) {+ if (cursorEnd <= st) {si++;- } else if (ed <= textStart) {+ } else if (ed <= cursorStart) {ti++;} else {if (ts?.[key] == null) {diff --git a/packages/base-docs/src/commands/mutations/core-editing.mutation.ts b/packages/base-docs/src/commands/mutations/core-editing.mutation.tsindex 0412ae37f1..452361ec6c 100644--- a/packages/base-docs/src/commands/mutations/core-editing.mutation.ts+++ b/packages/base-docs/src/commands/mutations/core-editing.mutation.ts@@ -59,13 +59,14 @@ export const RichTextEditingMutation: IMutation<IRichTextEditingMutationParams,handler: (accessor, params) => {const { unitId, mutations } = params;const univerInstanceService = accessor.get(IUniverInstanceService);-const documentModel = univerInstanceService.getUniverDocInstance(unitId);+if (!documentModel) {throw new Error(`DocumentModel not found for unitId: ${unitId}`);}const undoMutations: Array<IRetainMutationParams | IInsertMutationParams | IDeleteMutationParams> = [];+const memoryCursor = new MemoryCursor();memoryCursor.reset();diff --git a/packages/base-docs/src/commands/mutations/functions/common.ts b/packages/base-docs/src/commands/mutations/functions/common.tsindex a94456e517..7d05191923 100644--- a/packages/base-docs/src/commands/mutations/functions/common.ts+++ b/packages/base-docs/src/commands/mutations/functions/common.ts@@ -140,14 +140,16 @@ export function insertParagraphs(const paragraphIndexList = [];let firstInsertParagraphNextIndex = -1;+for (let i = 0, len = paragraphs.length; i < len; i++) {const paragraph = paragraphs[i];const { startIndex } = paragraph;+if (startIndex >= currentIndex) {paragraph.startIndex += textLength;}- if (firstInsertParagraphNextIndex === -1 && startIndex > currentIndex) {+ if (firstInsertParagraphNextIndex === -1 && startIndex >= currentIndex) {firstInsertParagraphNextIndex = i;}@@ -155,6 +157,7 @@ export function insertParagraphs(}let deleteReptIndex = -1;+if (insertParagraphs) {for (let i = 0, len = insertParagraphs.length; i < len; i++) {const insertParagraph = insertParagraphs[i];diff --git a/packages/base-docs/src/commands/mutations/functions/delete-apply.ts b/packages/base-docs/src/commands/mutations/functions/delete-apply.tsindex 55046c5811..21567b5b9c 100644--- a/packages/base-docs/src/commands/mutations/functions/delete-apply.ts+++ b/packages/base-docs/src/commands/mutations/functions/delete-apply.ts@@ -44,7 +44,7 @@ export function DeleteApply(recoveryBody(bodyModel, body, deleBody); // If the last paragraph in the document is deleted, restore an initial blank document.- console.log('删除的model打印', bodyModel, body, deleBody);+ // console.log('删除的model打印', bodyModel, body, deleBody);return deleBody;}diff --git a/packages/base-docs/src/commands/mutations/functions/insert-apply.ts b/packages/base-docs/src/commands/mutations/functions/insert-apply.tsindex ceb3b88aef..cad28b8d5c 100644--- a/packages/base-docs/src/commands/mutations/functions/insert-apply.ts+++ b/packages/base-docs/src/commands/mutations/functions/insert-apply.ts@@ -34,7 +34,7 @@ export function InsertApply(updateAttributeByInsert(body, insertBody, textLength, currentIndex);- // console.log('插入的model打印', bodyModel, body, textLength);+ console.log('插入的model打印', bodyModel, textLength, currentIndex);}function updateAttributeByInsert(diff --git a/packages/base-render/src/Component/Docs/Block/Paragraph/Layout.Ruler.ts b/packages/base-render/src/Component/Docs/Block/Paragraph/Layout.Ruler.tsindex b7492a700d..633efb4555 100644--- a/packages/base-render/src/Component/Docs/Block/Paragraph/Layout.Ruler.ts+++ b/packages/base-render/src/Component/Docs/Block/Paragraph/Layout.Ruler.ts@@ -92,6 +92,7 @@ function _divideOperator() {const lastPage = getLastPage(pages);const divideInfo = getLastNotFullDivideInfo(lastPage); // 取得最新一行里内容未满的第一个divide+if (divideInfo) {const width = __getSpanGroupWidth(spanGroup);const divide = divideInfo.divide;@@ -128,6 +129,7 @@ function _divideOperator(} else if (column && width > column.width) {// 一个字符超列宽setColumnFullState(column, true);+if (isBlankColumn(column)) {addSpanToDivide(divide, spanGroup, preOffsetLeft);// divide.spanGroup.push(...spanGroup);@@ -142,8 +144,12 @@ function _divideOperator();}} else if (divideInfo.isLast) {- // 最后一个divide- if (spanGroup.length === 1 && spanGroup[0].content === DataStreamTreeTokenType.SPACE) {+ // 最后一个 divide+ if (+ spanGroup.length === 1 &&+ (spanGroup[0].content === DataStreamTreeTokenType.SPACE ||+ spanGroup[0].content === DataStreamTreeTokenType.PARAGRAPH)+ ) {addSpanToDivide(divide, spanGroup, preOffsetLeft);} else {_lineOperator(diff --git a/packages/base-render/src/Component/Docs/Common/Span.ts b/packages/base-render/src/Component/Docs/Common/Span.tsindex ff2d4dcfa7..81a1368035 100644--- a/packages/base-render/src/Component/Docs/Common/Span.ts+++ b/packages/base-render/src/Component/Docs/Common/Span.ts@@ -1,210 +1,211 @@-import { BooleanNumber, BulletAlignment, DataStreamTreeTokenType as DT, GridType } from '@univerjs/core';--import { FontCache } from '../../../Basics/FontCache';-import {- IDocumentSkeletonBullet,- IDocumentSkeletonDivide,- IDocumentSkeletonSpan,- SpanType,-} from '../../../Basics/IDocumentSkeletonCached';-import { IFontCreateConfig } from '../../../Basics/Interfaces';-import { hasCJK } from '../../../Basics/Tools';-import { validationGrid } from './Tools';--export function createSkeletonWordSpan(- content: string,- config: IFontCreateConfig,- spanWidth?: number-): IDocumentSkeletonSpan {- return _createSkeletonWordOrLetter(SpanType.WORD, content, config, spanWidth);-}--export function createSkeletonLetterSpan(- content: string,- config: IFontCreateConfig,- spanWidth?: number-): IDocumentSkeletonSpan {- return _createSkeletonWordOrLetter(SpanType.LETTER, content, config, spanWidth);-}--export function createSkeletonTabSpan(config: IFontCreateConfig, spanWidth?: number): IDocumentSkeletonSpan {- return _createSkeletonWordOrLetter(SpanType.TAB, DT.TAB, config, spanWidth);-}--export function _createSkeletonWordOrLetter(- spanType: SpanType,- content: string,- config: IFontCreateConfig,- spanWidth?: number-): IDocumentSkeletonSpan {- const { fontStyle, textStyle, charSpace = 1, gridType = GridType.LINES, snapToGrid = BooleanNumber.FALSE } = config;- const skipWidthList: string[] = [- DT.SECTION_BREAK,- DT.TABLE_START,- DT.TABLE_END,- DT.TABLE_ROW_START,- DT.TABLE_ROW_END,- DT.TABLE_CELL_START,- DT.TABLE_CELL_END,- DT.CUSTOM_RANGE_START,- DT.CUSTOM_RANGE_END,- DT.COLUMN_BREAK,- DT.PAGE_BREAK,- DT.DOCS_END,- DT.CUSTOM_BLOCK,- ];- let streamType = DT.LETTER;- if (skipWidthList.indexOf(content) > -1) {- return {- content: '',- ts: textStyle,- fontStyle,- width: 0,- bBox: {- width: 0,- ba: 0,- bd: 0,- aba: 0,- abd: 0,- sp: 0,- sbr: 0,- sbo: 0,- spr: 0,- spo: 0,- },- paddingLeft: 0,- left: 0,- spanType: SpanType.PLACEHOLDER,- streamType: content as DT,- };- }- if (content === DT.PARAGRAPH) {- streamType = DT.PARAGRAPH;- }-- const bBox = FontCache.getTextSize(content, fontStyle);- const { width: contentWidth = 0 } = bBox;- let width = spanWidth ?? contentWidth;- let paddingLeft = 0;- if (validationGrid(gridType, snapToGrid)) {- // 当文字也需要对齐到网格式,进行处理- // const multiple = Math.ceil(contentWidth / charSpace);- width = contentWidth + (hasCJK(content) ? charSpace : charSpace / 2);- if (gridType === GridType.SNAP_TO_CHARS) {- paddingLeft = (width - contentWidth) / 2;- }- }- return {- content,- ts: textStyle,- fontStyle,- width,- bBox,- paddingLeft,- left: 0,- spanType,- streamType,- };-}--export function createSkeletonBulletSpan(- span: IDocumentSkeletonSpan,- bulletSkeleton: IDocumentSkeletonBullet,- charSpaceApply: number-): IDocumentSkeletonSpan {- const {- bBox: boundingBox,- symbol: content,- ts: textStyle,- fontStyle,- bulletAlign = BulletAlignment.START,- bulletType = false,- } = bulletSkeleton;- const contentWidth = boundingBox.width;- // 当文字也需要对齐到网格式,进行处理, LINES默认参照是doc全局字体大小-- const multiple = Math.ceil(contentWidth / charSpaceApply);- let width = (multiple < 2 ? 2 : multiple) * charSpaceApply; // 默认bullet有2个tab-- let left = 0;- if (bulletType) {- // 有序列表的处理,左对齐时left=0,其余情况根据contentWidth调整- if (bulletAlign === BulletAlignment.CENTER) {- left = -contentWidth / 2;- width -= left;- } else if (bulletAlign === BulletAlignment.END) {- left = -contentWidth;- width -= left;- }- }-- const bBox = _getMaxBoundingBox(span, bulletSkeleton);-- return {- content,- ts: textStyle,- fontStyle,- width,- paddingLeft: 0,- bBox,- left,- spanType: SpanType.LIST,- streamType: DT.LETTER,- };-}--export function setSpanGroupLeft(spanGroup: IDocumentSkeletonSpan[], left: number = 0) {- const spanGroupLen = spanGroup.length;- let preSpan;- for (let i = 0; i < spanGroupLen; i++) {- const span = spanGroup[i];- span.left = preSpan ? preSpan.left + preSpan.width : left;-- preSpan = span;- }-}--export function setSpanLeft(span: IDocumentSkeletonSpan, left: number = 0) {- span.left = left;-}--export function addSpanToDivide(- divide: IDocumentSkeletonDivide,- spanGroup: IDocumentSkeletonSpan[],- offsetLeft: number = 0-) {- // const line = divide.parent;- // if (line != null) {- // const isFirstLine = line.divides[0].spanGroup[0] == null;- // const firstSpan = spanGroup[0];- // const firstSpanContent = firstSpan.content || ' ';- // if (isFirstLine && firstSpanContent === ' ') {- // const width = firstSpan.width;- // firstSpan.width = 0;- // for (const span of spanGroup) {- // if (span === firstSpan) {- // continue;- // }-- // span.left -= width;- // }- // }- // }-- setSpanGroupLeft(spanGroup, offsetLeft);- for (const span of spanGroup) {- span.parent = divide;- }-- divide.spanGroup.push(...spanGroup);-}--function _getMaxBoundingBox(span: IDocumentSkeletonSpan, bulletSkeleton: IDocumentSkeletonBullet) {- const { ba: spanAscent, bd: spanDescent } = span.bBox;- const { ba: bulletAscent, bd: bulletDescent } = bulletSkeleton.bBox;-- if (spanAscent + spanDescent > bulletAscent + bulletDescent) {- return span.bBox;- }- return bulletSkeleton.bBox;-}+import { BooleanNumber, BulletAlignment, DataStreamTreeTokenType as DT, GridType } from '@univerjs/core';++import { FontCache } from '../../../Basics/FontCache';+import {+ IDocumentSkeletonBullet,+ IDocumentSkeletonDivide,+ IDocumentSkeletonSpan,+ SpanType,+} from '../../../Basics/IDocumentSkeletonCached';+import { IFontCreateConfig } from '../../../Basics/Interfaces';+import { hasCJK } from '../../../Basics/Tools';+import { validationGrid } from './Tools';++export function createSkeletonWordSpan(+ content: string,+ config: IFontCreateConfig,+ spanWidth?: number+): IDocumentSkeletonSpan {+ return _createSkeletonWordOrLetter(SpanType.WORD, content, config, spanWidth);+}++export function createSkeletonLetterSpan(+ content: string,+ config: IFontCreateConfig,+ spanWidth?: number+): IDocumentSkeletonSpan {+ return _createSkeletonWordOrLetter(SpanType.LETTER, content, config, spanWidth);+}++export function createSkeletonTabSpan(config: IFontCreateConfig, spanWidth?: number): IDocumentSkeletonSpan {+ return _createSkeletonWordOrLetter(SpanType.TAB, DT.TAB, config, spanWidth);+}++export function _createSkeletonWordOrLetter(+ spanType: SpanType,+ content: string,+ config: IFontCreateConfig,+ spanWidth?: number+): IDocumentSkeletonSpan {+ const { fontStyle, textStyle, charSpace = 1, gridType = GridType.LINES, snapToGrid = BooleanNumber.FALSE } = config;+ const skipWidthList: string[] = [+ DT.SECTION_BREAK,+ DT.TABLE_START,+ DT.TABLE_END,+ DT.TABLE_ROW_START,+ DT.TABLE_ROW_END,+ DT.TABLE_CELL_START,+ DT.TABLE_CELL_END,+ DT.CUSTOM_RANGE_START,+ DT.CUSTOM_RANGE_END,+ DT.COLUMN_BREAK,+ DT.PAGE_BREAK,+ DT.DOCS_END,+ DT.CUSTOM_BLOCK,+ ];+ let streamType = DT.LETTER;+ if (skipWidthList.indexOf(content) > -1) {+ return {+ content: '',+ ts: textStyle,+ fontStyle,+ width: 0,+ bBox: {+ width: 0,+ ba: 0,+ bd: 0,+ aba: 0,+ abd: 0,+ sp: 0,+ sbr: 0,+ sbo: 0,+ spr: 0,+ spo: 0,+ },+ paddingLeft: 0,+ left: 0,+ spanType: SpanType.PLACEHOLDER,+ streamType: content as DT,+ };+ }+ if (content === DT.PARAGRAPH) {+ streamType = DT.PARAGRAPH;+ }++ const bBox = FontCache.getTextSize(content, fontStyle);+ const { width: contentWidth = 0 } = bBox;+ let width = spanWidth ?? contentWidth;+ let paddingLeft = 0;+ if (validationGrid(gridType, snapToGrid)) {+ // 当文字也需要对齐到网格式,进行处理+ // const multiple = Math.ceil(contentWidth / charSpace);+ width = contentWidth + (hasCJK(content) ? charSpace : charSpace / 2);+ if (gridType === GridType.SNAP_TO_CHARS) {+ paddingLeft = (width - contentWidth) / 2;+ }+ }+ return {+ content,+ ts: textStyle,+ fontStyle,+ width,+ bBox,+ paddingLeft,+ left: 0,+ spanType,+ streamType,+ };+}++export function createSkeletonBulletSpan(+ span: IDocumentSkeletonSpan,+ bulletSkeleton: IDocumentSkeletonBullet,+ charSpaceApply: number+): IDocumentSkeletonSpan {+ const {+ bBox: boundingBox,+ symbol: content,+ ts: textStyle,+ fontStyle,+ bulletAlign = BulletAlignment.START,+ bulletType = false,+ } = bulletSkeleton;+ const contentWidth = boundingBox.width;+ // 当文字也需要对齐到网格式,进行处理, LINES默认参照是doc全局字体大小++ const multiple = Math.ceil(contentWidth / charSpaceApply);+ let width = (multiple < 2 ? 2 : multiple) * charSpaceApply; // 默认bullet有2个tab++ let left = 0;+ if (bulletType) {+ // 有序列表的处理,左对齐时left=0,其余情况根据contentWidth调整+ if (bulletAlign === BulletAlignment.CENTER) {+ left = -contentWidth / 2;+ width -= left;+ } else if (bulletAlign === BulletAlignment.END) {+ left = -contentWidth;+ width -= left;+ }+ }++ const bBox = _getMaxBoundingBox(span, bulletSkeleton);++ return {+ content,+ ts: textStyle,+ fontStyle,+ width,+ paddingLeft: 0,+ bBox,+ left,+ spanType: SpanType.LIST,+ streamType: DT.LETTER,+ };+}++export function setSpanGroupLeft(spanGroup: IDocumentSkeletonSpan[], left: number = 0) {+ const spanGroupLen = spanGroup.length;+ let preSpan;+ for (let i = 0; i < spanGroupLen; i++) {+ const span = spanGroup[i];+ span.left = preSpan ? preSpan.left + preSpan.width : left;++ preSpan = span;+ }+}++export function setSpanLeft(span: IDocumentSkeletonSpan, left: number = 0) {+ span.left = left;+}++export function addSpanToDivide(+ divide: IDocumentSkeletonDivide,+ spanGroup: IDocumentSkeletonSpan[],+ offsetLeft: number = 0+) {+ // const line = divide.parent;+ // if (line != null) {+ // const isFirstLine = line.divides[0].spanGroup[0] == null;+ // const firstSpan = spanGroup[0];+ // const firstSpanContent = firstSpan.content || ' ';+ // if (isFirstLine && firstSpanContent === ' ') {+ // const width = firstSpan.width;+ // firstSpan.width = 0;+ // for (const span of spanGroup) {+ // if (span === firstSpan) {+ // continue;+ // }++ // span.left -= width;+ // }+ // }+ // }++ setSpanGroupLeft(spanGroup, offsetLeft);++ for (const span of spanGroup) {+ span.parent = divide;+ }++ divide.spanGroup.push(...spanGroup);+}++function _getMaxBoundingBox(span: IDocumentSkeletonSpan, bulletSkeleton: IDocumentSkeletonBullet) {+ const { ba: spanAscent, bd: spanDescent } = span.bBox;+ const { ba: bulletAscent, bd: bulletDescent } = bulletSkeleton.bBox;++ if (spanAscent + spanDescent > bulletAscent + bulletDescent) {+ return span.bBox;+ }+ return bulletSkeleton.bBox;+}diff --git a/packages/base-render/src/Component/Docs/Common/TextSelection.ts b/packages/base-render/src/Component/Docs/Common/TextSelection.tsindex da54bdbd85..d2b2f4e75c 100644--- a/packages/base-render/src/Component/Docs/Common/TextSelection.ts+++ b/packages/base-render/src/Component/Docs/Common/TextSelection.ts@@ -34,21 +34,10 @@ export function cursorConvertToTextSelection(docSkeleton: DocumentSkeleton,documentOffsetConfig: IDocumentOffsetConfig): Nullable<TextSelection> {- const {- cursorStart,- cursorEnd,- isCollapse,- isEndBack,- isStartBack,- style = NORMAL_TEXT_SELECTION_PLUGIN_STYLE,- } = range;-- const startNode = docSkeleton.findNodePositionByCharIndex(cursorStart, isStartBack);- let endNode;-- if (isCollapse !== true) {- endNode = docSkeleton.findNodePositionByCharIndex(cursorEnd, isEndBack);- }+ const { cursorStart, cursorEnd, style = NORMAL_TEXT_SELECTION_PLUGIN_STYLE } = range;++ const startNode = docSkeleton.findNodePositionByCharIndex(cursorStart);+ const endNode = cursorStart !== cursorEnd ? docSkeleton.findNodePositionByCharIndex(cursorEnd) : null;const textSelection = new TextSelection(scene, startNode, endNode, style);@@ -157,19 +146,10 @@ export class TextSelection {return false;}- const activeStart = this._getCursorPosition(activeRange.cursorStart, activeRange.isStartBack);-- const activeEnd = this._getCursorPosition(activeRange.cursorEnd, activeRange.isEndBack);+ const { cursorStart: activeStart, cursorEnd: activeEnd } = activeRange;+ const { cursorStart: compareStart, cursorEnd: compareEnd } = compareRange;- const compareStart = this._getCursorPosition(compareRange.cursorStart, compareRange.isStartBack);-- const compareEnd = this._getCursorPosition(compareRange.cursorEnd, compareRange.isEndBack);-- if (activeStart > compareEnd || activeEnd < compareStart) {- return false;- }-- return true;+ return activeStart <= compareEnd && activeEnd >= compareStart;}refresh(documentOffsetConfig: IDocumentOffsetConfig, docSkeleton: DocumentSkeleton) {@@ -332,8 +312,4 @@ export class TextSelection {this._rangeList = rangeList;}-- private _getCursorPosition(index: number, isBack: boolean) {- return index - (isBack === true ? 1 : 0);- }}diff --git a/packages/base-render/src/Component/Docs/Common/Tools.ts b/packages/base-render/src/Component/Docs/Common/Tools.tsindex ce6cb07b75..6be09ae6c1 100644--- a/packages/base-render/src/Component/Docs/Common/Tools.ts+++ b/packages/base-render/src/Component/Docs/Common/Tools.ts@@ -284,6 +284,7 @@ export function updateBlockIndex(pages: IDocumentSkeletonPage[], start: number =// }let prePageStartIndex = start;+for (const page of pages) {const { sections } = page;const pageStartIndex = prePageStartIndex;@@ -291,6 +292,7 @@ export function updateBlockIndex(pages: IDocumentSkeletonPage[], start: number =let preSectionStartIndex = pageStartIndex;let maxContentWidth = -Infinity;let contentHeight = 0;+for (const section of sections) {const { columns } = section;const sectionStartIndex = preSectionStartIndex;@@ -298,6 +300,7 @@ export function updateBlockIndex(pages: IDocumentSkeletonPage[], start: number =let preColumnStartIndex = sectionStartIndex;let maxSectionHeight = -Infinity;let sectionWidth = 0;+for (const column of columns) {const { lines } = column;const columStartIndex = preColumnStartIndex;@@ -306,6 +309,7 @@ export function updateBlockIndex(pages: IDocumentSkeletonPage[], start: number =let columnHeight = 0;let maxColumnWidth = -Infinity;let preLine: Nullable<IDocumentSkeletonLine> = null;+for (const line of lines) {const { divides, lineHeight } = line;const lineStartIndex = preLineStartIndex;@@ -315,12 +319,14 @@ export function updateBlockIndex(pages: IDocumentSkeletonPage[], start: number =let maxLineAsc = 0;columnHeight += lineHeight;const divideLength = divides.length;+for (let i = 0; i < divideLength; i++) {const divide = divides[i];const { spanGroup } = divide;const divStartIndex = preDivideStartIndex;let divEndIndex = divStartIndex;+for (const span of spanGroup) {const increaseValue = span.spanType === SpanType.LIST ? 0 : span.count || 1;// pageEndIndex += increaseValue;diff --git a/packages/base-render/src/Component/Docs/Common/convert-cursor.ts b/packages/base-render/src/Component/Docs/Common/convert-cursor.tsindex fe730ec56a..9fccd5066a 100644--- a/packages/base-render/src/Component/Docs/Common/convert-cursor.ts+++ b/packages/base-render/src/Component/Docs/Common/convert-cursor.ts@@ -101,12 +101,14 @@ export function compareNodePositionLogic(pos1: INodePosition, pos2: INodePositioexport function compareNodePosition(pos1: INodePosition, pos2: INodePosition) {const compare = compareNodePositionLogic(pos1, pos2);+if (compare) {return {start: pos1,end: pos2,};}+return {start: pos2,end: pos1,@@ -114,23 +116,20 @@ export function compareNodePosition(pos1: INodePosition, pos2: INodePosition) {}export function getOneTextSelectionRange(rangeList: ITextSelectionRange[]): Nullable<ITextSelectionRange> {- const cursorList = rangeList;-- if (rangeList.length === 0) {+ const rangeCount = rangeList.length;+ if (rangeCount === 0) {return;}- const firstCursor = cursorList[0];+ const firstCursor = rangeList[0];- const lastCursor = cursorList[cursorList.length - 1];+ const lastCursor = rangeList[rangeCount - 1];- const isCollapse = cursorList.length === 1 && firstCursor.isCollapse;+ const isCollapse = rangeList.length === 1 && firstCursor.isCollapse;return {cursorStart: firstCursor.cursorStart,cursorEnd: lastCursor.cursorEnd,- isStartBack: firstCursor.isStartBack,- isEndBack: lastCursor.isEndBack,isCollapse,};}@@ -211,10 +210,6 @@ export class NodePositionConvertToCursor {const isEndBack = end.span === end_sp && isLast ? end.isBack : false;- // let isStartBackFin = isStartBack;-- // let isEndBackFin = isEndBack;-const isCollapse = start === end;if (start_sp === 0 && end_sp === spanGroup.length - 1) {@@ -253,11 +248,10 @@ export class NodePositionConvertToCursor {}pointGroup.push(this._pushToPoints(position));+cursorList.push({- isStartBack,- isEndBack,- cursorStart,- cursorEnd,+ cursorStart: isStartBack ? cursorStart : cursorStart + 1,+ cursorEnd: isEndBack ? cursorEnd : cursorEnd + 1,isCollapse,});});diff --git a/packages/base-render/src/Component/Docs/DocSkeleton.ts b/packages/base-render/src/Component/Docs/DocSkeleton.tsindex bb299f8014..517ac262a4 100644--- a/packages/base-render/src/Component/Docs/DocSkeleton.ts+++ b/packages/base-render/src/Component/Docs/DocSkeleton.ts@@ -164,7 +164,7 @@ export class DocumentSkeleton extends Skeleton {};}- findNodePositionByCharIndex(charIndex: number, isBack: boolean = false): Nullable<INodePosition> {+ findNodePositionByCharIndex(charIndex: number, isBack: boolean = true): Nullable<INodePosition> {const nodes = this._findNodeIterator(charIndex);if (nodes == null) {@@ -532,7 +532,9 @@ export class DocumentSkeleton extends Skeleton {skeleton.pages = allSkeletonPages;const bodyModel = this._docModel.bodyModel;+bodyModel.resetCache();+for (let i = 0, len = bodyModel.children.length; i < len; i++) {const sectionNode = bodyModel.children[i];const sectionBreak = bodyModel.getSectionBreak(sectionNode.endIndex) || DEFAULT_SECTION_BREAK;@@ -608,6 +610,7 @@ export class DocumentSkeleton extends Skeleton {let curSkeletonPage: IDocumentSkeletonPage = getLastPage(allSkeletonPages);let isContinuous = false;+if (sectionType === SectionType.CONTINUOUS) {updateBlockIndex(allSkeletonPages);this.__addNewSectionByContinuous(curSkeletonPage, columnProperties, columnSeparatorType);diff --git a/packages/base-render/src/Component/Docs/text-selection-render-manager.ts b/packages/base-render/src/Component/Docs/text-selection-render-manager.tsindex b1a066fee6..a492a5e0d8 100644--- a/packages/base-render/src/Component/Docs/text-selection-render-manager.ts+++ b/packages/base-render/src/Component/Docs/text-selection-render-manager.ts@@ -615,19 +615,16 @@ export class TextSelectionRenderManager extends RxDisposable implements ITextSelreturn;}- const { node: span, ratioX, ratioY } = node;+ const { node: span, ratioX } = node;const position = this._docSkeleton?.findPositionBySpan(span);if (position == null) {return;}+const HALF = 0.5;- let isBack = false;- //|| (span.streamType === DataStreamTreeTokenType.PARAGRAPH && isStart)- if (ratioX < HALF) {- isBack = true;- }+ const isBack = ratioX < HALF;return {...position,diff --git a/packages/base-render/src/Scene.Transformer.ts b/packages/base-render/src/Scene.Transformer.tsindex 55edc2c55a..b10b06cfe4 100644--- a/packages/base-render/src/Scene.Transformer.ts+++ b/packages/base-render/src/Scene.Transformer.ts@@ -803,8 +803,6 @@ export class Transformer implements ITransformerConfig {const scene = this.getScene();scene.addObject(transformerControl, 2);- console.log(scene, applyObject);-this._transformerControlMap.set(oKey, transformerControl);this.onCreateControlObservable.notifyObservers(transformerControl);diff --git a/packages/core/src/Docs/Domain/DataStreamTreeNode.ts b/packages/core/src/Docs/Domain/DataStreamTreeNode.tsindex c8045cc848..2d73d20e89 100644--- a/packages/core/src/Docs/Domain/DataStreamTreeNode.ts+++ b/packages/core/src/Docs/Domain/DataStreamTreeNode.ts@@ -69,14 +69,17 @@ export class DataStreamTreeNode {plus(len: number) {this.startIndex += len;this.endIndex += len;+this.addIndexForBlock(len);}selfPlus(len: number, index?: number) {this.endIndex += len;+if (index == null) {index = this.startIndex;}+this.addIndexForBlock(len, index);}@@ -91,14 +94,16 @@ export class DataStreamTreeNode {const firstEndIndex = index - startIndex;const lastStartIndex = firstEndIndex;- const lastEndIndex = endIndex;- const firstNode = DataStreamTreeNode.create(nodeType, content.slice(firstStartIndex, firstEndIndex));+ const firstNodeContent = content.slice(firstStartIndex, firstEndIndex);++ const firstNode = DataStreamTreeNode.create(nodeType, firstNodeContent);firstNode.parent = parent;firstNode.setIndexRange(firstStartIndex, firstEndIndex - 1);- const lastNodeContent = content.slice(lastStartIndex, lastEndIndex);+ const lastNodeContent = content.slice(lastStartIndex);+const lastNode = DataStreamTreeNode.create(nodeType, lastNodeContent);lastNode.parent = parent;@@ -109,6 +114,7 @@ export class DataStreamTreeNode {for (const node of children) {const { startIndex: childStartIndex } = node;+if (node.exclude(index)) {if (index < childStartIndex) {firstChildNodes.push(node);@@ -190,6 +196,7 @@ export class DataStreamTreeNode {private addIndexForBlock(addLen: number, index: number = -Infinity) {for (let i = 0, len = this.blocks.length; i < len; i++) {const block = this.blocks[i];+if (block >= index) {this.blocks[i] = block + addLen;}diff --git a/packages/core/src/Docs/Domain/DocumentBodyModel.ts b/packages/core/src/Docs/Domain/DocumentBodyModel.tsindex f7d8a5700a..2d74799215 100644--- a/packages/core/src/Docs/Domain/DocumentBodyModel.ts+++ b/packages/core/src/Docs/Domain/DocumentBodyModel.ts@@ -351,6 +351,7 @@ export class DocumentBodyModel extends DocumentBodyModelSimple {func: (node: DataStreamTreeNode | DocumentBodyModelOrSimple) => void) {let parent: Nullable<DataStreamTreeNode> = node;+while (parent) {func(parent);parent = parent.parent;@@ -667,7 +668,13 @@ export class DocumentBodyModel extends DocumentBodyModelSimple {currentNode.selfPlus(1, currentNode.getPositionInParent());const children = currentNode.children;let isStartFix = false;+for (const node of children) {+ // `insertedLastNode` no need to fix, because it already add 1.+ if (node === insertedLastNode) {+ continue;+ }+if (node.startIndex >= insertEndIndex + 1) {isStartFix = true;}diff --git a/packages/core/src/Shared/Common.ts b/packages/core/src/Shared/Common.tsindex dbb21a72b3..6af50e317f 100644--- a/packages/core/src/Shared/Common.ts+++ b/packages/core/src/Shared/Common.ts@@ -497,10 +497,6 @@ export function getBorderStyleType(type: string) {return str;}-export function getTextIndexByCursor(index: number, isBack: boolean = false) {- return isBack ? index - 1 : index;-}-export function getDocsUpdateBody(model: IDocumentData, segmentId?: string) {let body = model.body;diff --git a/packages/core/src/Shared/SortRules.ts b/packages/core/src/Shared/SortRules.tsindex 1547a761a3..afc30e82b6 100644--- a/packages/core/src/Shared/SortRules.ts+++ b/packages/core/src/Shared/SortRules.ts@@ -29,9 +29,11 @@ export function sortRulesFactory(key = 'index', ruler = 1) {if (oa[key] > ob[key]) {return ruler;}+if (oa[key] === ob[key]) {return 0;}+return -ruler;};}diff --git a/packages/core/src/Types/Interfaces/ISelectionData.ts b/packages/core/src/Types/Interfaces/ISelectionData.tsindex b0757a4398..f09cd722e6 100644--- a/packages/core/src/Types/Interfaces/ISelectionData.ts+++ b/packages/core/src/Types/Interfaces/ISelectionData.ts@@ -38,12 +38,10 @@ export interface ISelectionWithCoord {export interface ITextSelectionRangeStart {cursorStart: number;- isStartBack: boolean;}export interface ITextSelectionRange extends ITextSelectionRangeStart {cursorEnd: number;- isEndBack: boolean;isCollapse: boolean;}diff --git a/packages/ui-plugin-sheets/src/controllers/editor/start-edit.controller.ts b/packages/ui-plugin-sheets/src/controllers/editor/start-edit.controller.tsindex 1bf67f47a8..b902494d47 100644--- a/packages/ui-plugin-sheets/src/controllers/editor/start-edit.controller.ts+++ b/packages/ui-plugin-sheets/src/controllers/editor/start-edit.controller.ts@@ -166,8 +166,6 @@ export class StartEditController extends Disposable {cursorStart: 0,cursorEnd: 0,isCollapse: true,- isEndBack: true,- isStartBack: true,},]);@@ -463,8 +461,6 @@ export class StartEditController extends Disposable {cursorStart: 0,cursorEnd: 0,isCollapse: true,- isEndBack: true,- isStartBack: true,},]);} else {@@ -480,8 +476,6 @@ export class StartEditController extends Disposable {cursorStart: cursor,cursorEnd: cursor,isCollapse: true,- isEndBack: true,- isStartBack: true,},]);}