Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

feat(doc): apply update

DR-Univer3d6fc6ce84d4
diff --git a/packages/base-component/src/Helpers/Cell.ts b/packages/base-component/src/Helpers/Cell.ts
index ddc37e05c8..eabd193062 100644
--- a/packages/base-component/src/Helpers/Cell.ts
+++ b/packages/base-component/src/Helpers/Cell.ts
@@ -6,7 +6,7 @@ import {
HorizontalAlign,
ICellData,
IDocumentData,
- IElementsOrder,
+ IElement,
IRangeData,
IStyleData,
ITextDecoration,
@@ -43,8 +43,7 @@ export function handleDomToJson($dom: HTMLElement): IDocumentData | string {
if (nodeList.length === 1 && nodeList[0].nodeName === '#text') {
return nodeList[0].textContent as string;
}
- const elements = {};
- const elementOrder: IElementsOrder[] = [];
+ const elements: IElement[] = [];
let ed = 0;
for (let i = 0; i < nodeList.length; i++) {
@@ -65,7 +64,7 @@ export function handleDomToJson($dom: HTMLElement): IDocumentData | string {
ed = +item.length;
let eId = nanoid(6);
- elements[eId] = {
+ elements.push({
eId,
st: 0,
ed: item.length - 1,
@@ -74,13 +73,7 @@ export function handleDomToJson($dom: HTMLElement): IDocumentData | string {
ct: item,
ts: textStyle,
},
- };
-
- elementOrder.push({
- elementId: eId,
- paragraphElementType: 0,
});
-
// // 如果有 \n 说明有换行,另起一段
// if (item.includes('\n')) {
// const pStart = cot.length > 0 ? cot[cot.length].ed : 0;
@@ -115,18 +108,17 @@ export function handleDomToJson($dom: HTMLElement): IDocumentData | string {
let p = {
id: nanoid(6),
body: {
- blockElements: {
- [blockId]: {
+ blockElements: [
+ {
blockId,
st: 0,
ed,
blockType: 0,
paragraph: {
elements,
- elementOrder,
},
},
- b: {
+ {
blockId: 'b',
st: 0,
ed: 0,
@@ -137,8 +129,7 @@ export function handleDomToJson($dom: HTMLElement): IDocumentData | string {
sectionType: 0,
},
},
- },
- blockElementOrder: [blockId, 'b'],
+ ],
},
documentStyle: {},
};
diff --git a/packages/base-docs/src/Basic/DemoData.ts b/packages/base-docs/src/Basic/DemoData.ts
index ffc28b1e1e..10028329ee 100644
--- a/packages/base-docs/src/Basic/DemoData.ts
+++ b/packages/base-docs/src/Basic/DemoData.ts
@@ -123,8 +123,8 @@ export const DOCS_DEMO_DATA: IDocumentData = {
},
},
body: {
- blockElements: {
- oneParagraph: {
+ blockElements: [
+ {
blockId: 'oneParagraph',
st: 0,
ed: 59,
@@ -137,8 +137,8 @@ export const DOCS_DEMO_DATA: IDocumentData = {
fs: 20,
},
},
- elements: {
- oneElement: {
+ elements: [
+ {
eId: 'oneElement',
st: 0,
ed: 15,
@@ -156,7 +156,13 @@ export const DOCS_DEMO_DATA: IDocumentData = {
},
},
},
- smallSub: {
+ {
+ eId: 'shapeTest1',
+ et: ParagraphElementType.DRAWING,
+ ed: 0,
+ st: 0,
+ },
+ {
eId: 'smallSub',
st: 16,
ed: 17,
@@ -175,7 +181,7 @@ export const DOCS_DEMO_DATA: IDocumentData = {
},
},
},
- twoElement: {
+ {
eId: 'twoElement',
st: 18,
ed: 59,
@@ -193,28 +199,10 @@ export const DOCS_DEMO_DATA: IDocumentData = {
},
},
},
- },
- elementOrder: [
- {
- elementId: 'oneElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
- {
- elementId: 'shapeTest1',
- paragraphElementType: ParagraphElementType.DRAWING,
- },
- {
- elementId: 'smallSub',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
- {
- elementId: 'twoElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- twoParagraph: {
+ {
blockId: 'twoParagraph',
st: 60,
ed: 88,
@@ -227,8 +215,8 @@ export const DOCS_DEMO_DATA: IDocumentData = {
fs: 20,
},
},
- elements: {
- oneElement: {
+ elements: [
+ {
eId: 'oneElement',
st: 60,
ed: 74,
@@ -237,7 +225,7 @@ export const DOCS_DEMO_DATA: IDocumentData = {
ct: '细化埋点上报链路和指标方案梳理',
},
},
- twoElement: {
+ {
eId: 'twoElement',
st: 75,
ed: 88,
@@ -246,20 +234,10 @@ export const DOCS_DEMO_DATA: IDocumentData = {
ct: '目前通过每日定时任务发送报告',
},
},
- },
- elementOrder: [
- {
- elementId: 'oneElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
- {
- elementId: 'twoElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- threeParagraph: {
+ {
blockId: 'threeParagraph',
st: 89,
ed: 230,
@@ -272,8 +250,8 @@ export const DOCS_DEMO_DATA: IDocumentData = {
fs: 20,
},
},
- elements: {
- oneElement: {
+ elements: [
+ {
eId: 'oneElement',
st: 89,
ed: 138,
@@ -282,7 +260,7 @@ export const DOCS_DEMO_DATA: IDocumentData = {
ct: '自2018年首届进博会举办以来,进博会已经成为全球新品的首发地、前沿技术的首选地、创新服务的首推地。',
},
},
- twoElement: {
+ {
eId: 'twoElement',
st: 139,
ed: 230,
@@ -291,20 +269,10 @@ export const DOCS_DEMO_DATA: IDocumentData = {
ct: '中国这十年”对外开放成就展湖北展区主要以图文、图表、数据、视频、企业展品、实物模型、光电科技等体现湖北十年开放成就、重大开放平台及产业。湖北省共计17家企业、机构的展品将在这一展区展示',
},
},
- },
- elementOrder: [
- {
- elementId: 'oneElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
- {
- elementId: 'twoElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- fourParagraph: {
+ {
blockId: 'fourParagraph',
st: 231,
ed: 322,
@@ -317,8 +285,8 @@ export const DOCS_DEMO_DATA: IDocumentData = {
fs: 20,
},
},
- elements: {
- oneElement: {
+ elements: [
+ {
eId: 'oneElement',
st: 231,
ed: 286,
@@ -327,7 +295,7 @@ export const DOCS_DEMO_DATA: IDocumentData = {
ct: '国家主席习近平以视频方式出席在上海举行的第五届中国国际进口博览会开幕式并发表题为《共创开放繁荣的美好未来》的致辞',
},
},
- twoElement: {
+ {
eId: 'twoElement',
st: 287,
ed: 322,
@@ -336,20 +304,10 @@ export const DOCS_DEMO_DATA: IDocumentData = {
ct: '中国将推动各国各方共享深化国际合作机遇,全面深入参与世界贸易组织改革谈判',
},
},
- },
- elementOrder: [
- {
- elementId: 'oneElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
- {
- elementId: 'twoElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- fiveParagraph: {
+ {
blockId: 'fiveParagraph',
st: 323,
ed: 400,
@@ -362,8 +320,8 @@ export const DOCS_DEMO_DATA: IDocumentData = {
fs: 20,
},
},
- elements: {
- oneElement: {
+ elements: [
+ {
eId: 'oneElement',
st: 323,
ed: 360,
@@ -372,7 +330,7 @@ export const DOCS_DEMO_DATA: IDocumentData = {
ct: '中国男排两名现役国手彭世坤和张秉龙分别效力的三得利太阳鸟和东京大熊本轮遭遇。',
},
},
- twoElement: {
+ {
eId: 'twoElement',
st: 361,
ed: 400,
@@ -381,20 +339,10 @@ export const DOCS_DEMO_DATA: IDocumentData = {
ct: '双方经过激战,主场作战的卫冕冠军三得利技高一筹3-2逆转击败对手,力夺第3场胜利',
},
},
- },
- elementOrder: [
- {
- elementId: 'oneElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
- {
- elementId: 'twoElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- oneSectionBreak: {
+ {
blockId: 'oneSectionBreak',
st: 0,
ed: 0,
@@ -412,8 +360,7 @@ export const DOCS_DEMO_DATA: IDocumentData = {
// contentDirection: textDirection!,
},
},
- },
- blockElementOrder: ['oneParagraph', 'twoParagraph', 'threeParagraph', 'fourParagraph', 'fiveParagraph', 'oneSectionBreak'],
+ ],
},
documentStyle: {
pageSize: {
diff --git a/packages/base-render/src/Component/Docs/Block/Paragraph/Paragraph.ts b/packages/base-render/src/Component/Docs/Block/Paragraph/Paragraph.ts
index 348dfffe9b..1f27d0917a 100644
--- a/packages/base-render/src/Component/Docs/Block/Paragraph/Paragraph.ts
+++ b/packages/base-render/src/Component/Docs/Block/Paragraph/Paragraph.ts
@@ -1,15 +1,4 @@
-import {
- ColumnSeparatorType,
- IBullet,
- IDrawing,
- IDrawings,
- IElementsOrder,
- IParagraph,
- Nullable,
- ParagraphElementType,
- PositionedObjectLayoutType,
- ContextBase,
-} from '@univer/core';
+import { ColumnSeparatorType, IBullet, IDrawing, IDrawings, IParagraph, Nullable, ParagraphElementType, PositionedObjectLayoutType, ContextBase, IElement } from '@univer/core';
import { dealWidthTextRun } from './TextRun';
import { dealWidthBullet } from './Bullet';
import { dealWidthInlineDrawing } from './InlineDrawing';
@@ -50,7 +39,7 @@ export function dealWidthParagraph(
fontLocale,
} = sectionBreakConfig;
- const { elements, elementOrder, paragraphStyle = {}, bullet } = paragraph;
+ const { elements, paragraphStyle = {}, bullet } = paragraph;
// const paragraphAffectSkeDrawings = _changeDrawingToSkeletonFormat(drawingIds, drawings);
@@ -98,8 +87,8 @@ export function dealWidthParagraph(
_updateListLevelAncestors(bullet, bulletSkeleton, skeListLevel); // 更新最新的level缓存列表
paragraphConfig.bulletSkeleton = bulletSkeleton;
- elementOrder.forEach((elementOrderItem: IElementsOrder, elementIndex: number) => {
- const { elementId, paragraphElementType } = elementOrderItem;
+ elements.forEach((element: IElement, elementIndex: number) => {
+ const { eId: elementId, et: paragraphElementType } = element;
let currentPages: IDocumentSkeletonPage[] = [];
if (paragraphElementType === ParagraphElementType.DRAWING) {
const drawingOrigin = drawings[elementId];
@@ -114,8 +103,8 @@ export function dealWidthParagraph(
// let currentLine = createSkeletonLine({ ...paragraphConfig, bulletSkeleton, affectSkeDrawings: affectAllSkeDrawings });
// 处理1列的情况
// 如果下一节是连续的,则按照1列进行计算,计算结果返回后,用来预估列高度,然后在接来下的流程进行二次计算
- elementOrder.forEach((elementOrderItem: IElementsOrder, elementIndex: number) => {
- const { elementId, paragraphElementType } = elementOrderItem;
+ elements.forEach((element: IElement, elementIndex: number) => {
+ const { eId: elementId, et: paragraphElementType } = element;
let currentPages: IDocumentSkeletonPage[] = [];
if (paragraphElementType === ParagraphElementType.TEXT_RUN) {
const element = elements[elementId];
diff --git a/packages/base-render/src/Component/Docs/Common/Page.ts b/packages/base-render/src/Component/Docs/Common/Page.ts
index 5e1c89f215..3bdd9035f5 100644
--- a/packages/base-render/src/Component/Docs/Common/Page.ts
+++ b/packages/base-render/src/Component/Docs/Common/Page.ts
@@ -169,10 +169,9 @@ function _createSkeletonHeader(
drawings,
};
- const { blockElements, blockElementOrder } = headerOrFooterBody;
+ const { blockElements } = headerOrFooterBody;
const blockElementArray: IBlockElement[] = [];
- blockElementOrder.forEach((bId: string) => {
- const dcd = blockElements[bId];
+ blockElements.forEach((dcd: IBlockElement) => {
blockElementArray.push(dcd);
});
diff --git a/packages/base-render/src/Component/Docs/DocSkeleton.ts b/packages/base-render/src/Component/Docs/DocSkeleton.ts
index 1ffe90ce08..8c3435ee79 100644
--- a/packages/base-render/src/Component/Docs/DocSkeleton.ts
+++ b/packages/base-render/src/Component/Docs/DocSkeleton.ts
@@ -123,9 +123,9 @@ export class DocumentSkeleton extends Skeleton {
if (!body) {
return [];
}
- const { blockElements, blockElementOrder } = body;
+ const { blockElements } = body;
- if (!blockElements || blockElementOrder.length === 0) {
+ if (blockElements.length === 0) {
return [];
}
@@ -135,8 +135,7 @@ export class DocumentSkeleton extends Skeleton {
sectionBreak: undefined,
};
// sectionBreak会在一个段落的底部,定义之前所有段落的页样式。
- blockElementOrder.forEach((bId: string) => {
- const dcd = blockElements[bId];
+ blockElements.forEach((dcd: IBlockElement) => {
const { sectionBreak: sSectionBreak } = dcd;
if (sSectionBreak) {
documentContentMap.sectionBreak = sSectionBreak;
diff --git a/packages/base-render/src/Component/Sheets/SheetSkeleton.ts b/packages/base-render/src/Component/Sheets/SheetSkeleton.ts
index ab1fca5a78..765d94bf85 100644
--- a/packages/base-render/src/Component/Sheets/SheetSkeleton.ts
+++ b/packages/base-render/src/Component/Sheets/SheetSkeleton.ts
@@ -775,9 +775,7 @@ export class SpreadsheetSkeleton extends Skeleton {
document.documentStyle.renderConfig = renderConfig;
const blockElements = document.body.blockElements;
- const blockKeys = Object.keys(document.body.blockElements);
- for (let key of blockKeys) {
- const blockElement = blockElements[key];
+ for (let blockElement of blockElements) {
// if (blockElement.blockType === BlockType.SECTION_BREAK) {
// if (!blockElement.sectionBreak) {
// blockElement.sectionBreak = {};
@@ -829,8 +827,8 @@ export class SpreadsheetSkeleton extends Skeleton {
const documentData: IDocumentData = {
id: 'd',
body: {
- blockElements: {
- oneParagraph: {
+ blockElements: [
+ {
blockId: 'oneParagraph',
st: 0,
ed: contentLength,
@@ -839,8 +837,8 @@ export class SpreadsheetSkeleton extends Skeleton {
paragraphStyle: {
horizontalAlign,
},
- elements: {
- oneElement: {
+ elements: [
+ {
eId: 'oneElement',
st: 0,
ed: contentLength,
@@ -850,8 +848,7 @@ export class SpreadsheetSkeleton extends Skeleton {
ts: textStyle,
},
},
- },
- elementOrder: [{ elementId: 'oneElement', paragraphElementType: ParagraphElementType.TEXT_RUN }],
+ ],
},
},
// oneSectionBreak: {
@@ -867,8 +864,7 @@ export class SpreadsheetSkeleton extends Skeleton {
// // contentDirection: textDirection!,
// },
// },
- },
- blockElementOrder: ['oneParagraph'],
+ ],
},
documentStyle: {
pageSize: {
diff --git a/packages/base-render/src/Shape/RichText.ts b/packages/base-render/src/Shape/RichText.ts
index f1ef46010f..28d7ee4083 100644
--- a/packages/base-render/src/Shape/RichText.ts
+++ b/packages/base-render/src/Shape/RichText.ts
@@ -137,15 +137,15 @@ export class RichText extends BaseObject {
const documentData: IDocumentData = {
id: 'd',
body: {
- blockElements: {
- oneParagraph: {
+ blockElements: [
+ {
blockId: 'oneParagraph',
st: 0,
ed: contentLength,
blockType: BlockType.PARAGRAPH,
paragraph: {
- elements: {
- oneElement: {
+ elements: [
+ {
eId: 'oneElement',
st: 0,
ed: contentLength,
@@ -166,12 +166,10 @@ export class RichText extends BaseObject {
},
},
},
- },
- elementOrder: [{ elementId: 'oneElement', paragraphElementType: ParagraphElementType.TEXT_RUN }],
+ ],
},
},
- },
- blockElementOrder: ['oneParagraph'],
+ ],
},
documentStyle: {
pageSize: {
diff --git a/packages/common-plugin-data/src/Docs/DEFAULT_DOCUMENT_DATA.ts b/packages/common-plugin-data/src/Docs/DEFAULT_DOCUMENT_DATA.ts
index 63010a6d9e..734037696a 100644
--- a/packages/common-plugin-data/src/Docs/DEFAULT_DOCUMENT_DATA.ts
+++ b/packages/common-plugin-data/src/Docs/DEFAULT_DOCUMENT_DATA.ts
@@ -45,8 +45,8 @@ export const DEFAULT_DOCUMENT_DATA: IDocumentData = {
},
lists: DEFAULT_LIST_TEST,
body: {
- blockElements: {
- oneParagraph: {
+ blockElements: [
+ {
blockId: 'oneParagraph',
st: 0,
ed: 59,
@@ -59,8 +59,8 @@ export const DEFAULT_DOCUMENT_DATA: IDocumentData = {
fs: 20,
},
},
- elements: {
- oneElement: {
+ elements: [
+ {
eId: 'oneElement',
st: 0,
ed: 15,
@@ -78,7 +78,13 @@ export const DEFAULT_DOCUMENT_DATA: IDocumentData = {
},
},
},
- smallSub: {
+ {
+ eId: 'shapeTest1',
+ et: ParagraphElementType.DRAWING,
+ st: 0,
+ ed: 0,
+ },
+ {
eId: 'smallSub',
st: 16,
ed: 17,
@@ -97,7 +103,7 @@ export const DEFAULT_DOCUMENT_DATA: IDocumentData = {
},
},
},
- twoElement: {
+ {
eId: 'twoElement',
st: 18,
ed: 59,
@@ -115,28 +121,10 @@ export const DEFAULT_DOCUMENT_DATA: IDocumentData = {
},
},
},
- },
- elementOrder: [
- {
- elementId: 'oneElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
- {
- elementId: 'shapeTest1',
- paragraphElementType: ParagraphElementType.DRAWING,
- },
- {
- elementId: 'smallSub',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
- {
- elementId: 'twoElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- twoParagraph: {
+ {
blockId: 'twoParagraph',
st: 60,
ed: 88,
@@ -149,8 +137,8 @@ export const DEFAULT_DOCUMENT_DATA: IDocumentData = {
fs: 20,
},
},
- elements: {
- oneElement: {
+ elements: [
+ {
eId: 'oneElement',
st: 60,
ed: 74,
@@ -159,7 +147,7 @@ export const DEFAULT_DOCUMENT_DATA: IDocumentData = {
ct: '细化埋点上报链路和指标方案梳理',
},
},
- twoElement: {
+ {
eId: 'twoElement',
st: 75,
ed: 88,
@@ -168,20 +156,10 @@ export const DEFAULT_DOCUMENT_DATA: IDocumentData = {
ct: '目前通过每日定时任务发送报告',
},
},
- },
- elementOrder: [
- {
- elementId: 'oneElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
- {
- elementId: 'twoElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- threeParagraph: {
+ {
blockId: 'threeParagraph',
st: 89,
ed: 230,
@@ -194,8 +172,8 @@ export const DEFAULT_DOCUMENT_DATA: IDocumentData = {
fs: 20,
},
},
- elements: {
- oneElement: {
+ elements: [
+ {
eId: 'oneElement',
st: 89,
ed: 138,
@@ -204,7 +182,7 @@ export const DEFAULT_DOCUMENT_DATA: IDocumentData = {
ct: '自2018年首届进博会举办以来,进博会已经成为全球新品的首发地、前沿技术的首选地、创新服务的首推地。',
},
},
- twoElement: {
+ {
eId: 'twoElement',
st: 139,
ed: 230,
@@ -213,20 +191,10 @@ export const DEFAULT_DOCUMENT_DATA: IDocumentData = {
ct: '中国这十年”对外开放成就展湖北展区主要以图文、图表、数据、视频、企业展品、实物模型、光电科技等体现湖北十年开放成就、重大开放平台及产业。湖北省共计17家企业、机构的展品将在这一展区展示',
},
},
- },
- elementOrder: [
- {
- elementId: 'oneElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
- {
- elementId: 'twoElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- fourParagraph: {
+ {
blockId: 'fourParagraph',
st: 231,
ed: 322,
@@ -239,8 +207,8 @@ export const DEFAULT_DOCUMENT_DATA: IDocumentData = {
fs: 20,
},
},
- elements: {
- oneElement: {
+ elements: [
+ {
eId: 'oneElement',
st: 231,
ed: 286,
@@ -249,7 +217,7 @@ export const DEFAULT_DOCUMENT_DATA: IDocumentData = {
ct: '国家主席习近平以视频方式出席在上海举行的第五届中国国际进口博览会开幕式并发表题为《共创开放繁荣的美好未来》的致辞',
},
},
- twoElement: {
+ {
eId: 'twoElement',
st: 287,
ed: 322,
@@ -258,20 +226,10 @@ export const DEFAULT_DOCUMENT_DATA: IDocumentData = {
ct: '中国将推动各国各方共享深化国际合作机遇,全面深入参与世界贸易组织改革谈判',
},
},
- },
- elementOrder: [
- {
- elementId: 'oneElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
- {
- elementId: 'twoElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- fiveParagraph: {
+ {
blockId: 'fiveParagraph',
st: 323,
ed: 400,
@@ -284,8 +242,8 @@ export const DEFAULT_DOCUMENT_DATA: IDocumentData = {
fs: 20,
},
},
- elements: {
- oneElement: {
+ elements: [
+ {
eId: 'oneElement',
st: 323,
ed: 360,
@@ -294,7 +252,7 @@ export const DEFAULT_DOCUMENT_DATA: IDocumentData = {
ct: '中国男排两名现役国手彭世坤和张秉龙分别效力的三得利太阳鸟和东京大熊本轮遭遇。',
},
},
- twoElement: {
+ {
eId: 'twoElement',
st: 361,
ed: 400,
@@ -303,20 +261,10 @@ export const DEFAULT_DOCUMENT_DATA: IDocumentData = {
ct: '双方经过激战,主场作战的卫冕冠军三得利技高一筹3-2逆转击败对手,力夺第3场胜利',
},
},
- },
- elementOrder: [
- {
- elementId: 'oneElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
- {
- elementId: 'twoElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- oneSectionBreak: {
+ {
blockId: 'oneSectionBreak',
st: 0,
ed: 0,
@@ -334,8 +282,7 @@ export const DEFAULT_DOCUMENT_DATA: IDocumentData = {
// contentDirection: textDirection!,
},
},
- },
- blockElementOrder: ['oneParagraph', 'twoParagraph', 'threeParagraph', 'fourParagraph', 'fiveParagraph', 'oneSectionBreak'],
+ ],
},
documentStyle: {
pageSize: {
diff --git a/packages/common-plugin-data/src/Docs/DEFAULT_DOCUMENT_DATA_EN.ts b/packages/common-plugin-data/src/Docs/DEFAULT_DOCUMENT_DATA_EN.ts
index 6392845e25..bff8c78491 100644
--- a/packages/common-plugin-data/src/Docs/DEFAULT_DOCUMENT_DATA_EN.ts
+++ b/packages/common-plugin-data/src/Docs/DEFAULT_DOCUMENT_DATA_EN.ts
@@ -70,15 +70,15 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
},
lists: DEFAULT_LIST_TEST,
body: {
- blockElements: {
- p1: {
+ blockElements: [
+ {
blockId: 'p1',
st: 0,
ed: 66,
blockType: BlockType.PARAGRAPH,
paragraph: {
- elements: {
- e1: {
+ elements: [
+ {
eId: 'e1',
st: 0,
ed: 66,
@@ -94,16 +94,10 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
},
},
},
- },
- elementOrder: [
- {
- elementId: 'e1',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- p2: {
+ {
blockId: 'p2',
st: 67,
ed: 251,
@@ -113,8 +107,8 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
spaceAbove: 20,
indentFirstLine: 20,
},
- elements: {
- e1: {
+ elements: [
+ {
eId: 'e1',
st: 67,
ed: 251,
@@ -129,16 +123,10 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
},
},
},
- },
- elementOrder: [
- {
- elementId: 'e1',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- p3: {
+ {
blockId: 'p3',
st: 252,
ed: 401,
@@ -148,8 +136,8 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
spaceAbove: 20,
indentFirstLine: 20,
},
- elements: {
- e1: {
+ elements: [
+ {
eId: 'e1',
st: 252,
ed: 401,
@@ -161,16 +149,10 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
},
},
},
- },
- elementOrder: [
- {
- elementId: 'e1',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- p4: {
+ {
blockId: 'p4',
st: 402,
ed: 429,
@@ -186,8 +168,8 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
paragraphStyle: {
lineSpacing: 1.5,
},
- elements: {
- e1: {
+ elements: [
+ {
eId: 'e1',
st: 402,
ed: 429,
@@ -199,16 +181,10 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
},
},
},
- },
- elementOrder: [
- {
- elementId: 'e1',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- p5: {
+ {
blockId: 'p5',
st: 430,
ed: 479,
@@ -224,8 +200,8 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
paragraphStyle: {
lineSpacing: 1.5,
},
- elements: {
- e1: {
+ elements: [
+ {
eId: 'e1',
st: 430,
ed: 479,
@@ -237,16 +213,10 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
},
},
},
- },
- elementOrder: [
- {
- elementId: 'e1',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- p6: {
+ {
blockId: 'p6',
st: 480,
ed: 510,
@@ -262,8 +232,8 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
paragraphStyle: {
lineSpacing: 1.5,
},
- elements: {
- e1: {
+ elements: [
+ {
eId: 'e1',
st: 480,
ed: 510,
@@ -275,16 +245,10 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
},
},
},
- },
- elementOrder: [
- {
- elementId: 'e1',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- p7: {
+ {
blockId: 'p7',
st: 511,
ed: 705,
@@ -293,8 +257,8 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
paragraphStyle: {
indentFirstLine: 20,
},
- elements: {
- e1: {
+ elements: [
+ {
eId: 'e1',
st: 511,
ed: 672,
@@ -306,7 +270,7 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
},
},
},
- e2: {
+ {
eId: 'e2',
st: 673,
ed: 705,
@@ -322,20 +286,10 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
},
},
},
- },
- elementOrder: [
- {
- elementId: 'e1',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
- {
- elementId: 'e2',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- p8: {
+ {
blockId: 'p8',
st: 706,
ed: 762,
@@ -344,8 +298,8 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
paragraphStyle: {
spaceAbove: 20,
},
- elements: {
- e1: {
+ elements: [
+ {
eId: 'e1',
st: 706,
ed: 762,
@@ -363,16 +317,10 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
},
},
},
- },
- elementOrder: [
- {
- elementId: 'e1',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- p9: {
+ {
blockId: 'p9',
st: 763,
ed: 1233,
@@ -382,8 +330,8 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
spaceAbove: 20,
indentFirstLine: 20,
},
- elements: {
- e1: {
+ elements: [
+ {
eId: 'e1',
st: 763,
ed: 1233,
@@ -395,20 +343,16 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
},
},
},
- },
- elementOrder: [
{
- elementId: 'e1',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
- {
- elementId: 'shapeTest1',
- paragraphElementType: ParagraphElementType.DRAWING,
+ eId: 'shapeTest1',
+ st: 0,
+ ed: 0,
+ et: ParagraphElementType.DRAWING,
},
],
},
},
- oneSectionBreak: {
+ {
blockId: 'oneSectionBreak',
st: 0,
ed: 0,
@@ -421,7 +365,7 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
// contentDirection: textDirection!,
},
},
- p10: {
+ {
blockId: 'p10',
st: 1206 + 28,
ed: 1548 + 28,
@@ -430,8 +374,8 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
paragraphStyle: {
indentFirstLine: 20,
},
- elements: {
- e1: {
+ elements: [
+ {
eId: 'e1',
st: 1206 + 28,
ed: 1548 + 28,
@@ -443,16 +387,10 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
},
},
},
- },
- elementOrder: [
- {
- elementId: 'e1',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- p11: {
+ {
blockId: 'p11',
st: 1549 + 28,
ed: 1944 + 28,
@@ -461,8 +399,8 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
paragraphStyle: {
indentFirstLine: 20,
},
- elements: {
- e1: {
+ elements: [
+ {
eId: 'e1',
st: 1549 + 28,
ed: 1944 + 28,
@@ -474,16 +412,10 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
},
},
},
- },
- elementOrder: [
- {
- elementId: 'e1',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- p12: {
+ {
blockId: 'p12',
st: 1945 + 28,
ed: 2019 + 28,
@@ -492,8 +424,8 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
paragraphStyle: {
indentFirstLine: 20,
},
- elements: {
- e1: {
+ elements: [
+ {
eId: 'e1',
st: 1945 + 28,
ed: 2019 + 28,
@@ -505,16 +437,10 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
},
},
},
- },
- elementOrder: [
- {
- elementId: 'e1',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- p13: {
+ {
blockId: 'p13',
st: 2020 + 28,
ed: 2250 + 28,
@@ -530,8 +456,8 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
fs: 20,
},
},
- elements: {
- e1: {
+ elements: [
+ {
eId: 'e1',
st: 2020 + 28,
ed: 2042 + 28,
@@ -547,7 +473,7 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
},
},
},
- e2: {
+ {
eId: 'e2',
st: 2043 + 28,
ed: 2250 + 28,
@@ -559,21 +485,10 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
},
},
},
- },
- elementOrder: [
- {
- elementId: 'e1',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
-
- {
- elementId: 'e2',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- p14: {
+ {
blockId: 'p14',
st: 2251 + 28,
ed: 2393 + 28,
@@ -589,8 +504,8 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
fs: 20,
},
},
- elements: {
- e1: {
+ elements: [
+ {
eId: 'e1',
st: 2251 + 28,
ed: 2265 + 28,
@@ -606,7 +521,7 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
},
},
},
- e2: {
+ {
eId: 'e2',
st: 2266 + 28,
ed: 2393 + 28,
@@ -618,20 +533,10 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
},
},
},
- },
- elementOrder: [
- {
- elementId: 'e1',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
- {
- elementId: 'e2',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- p15: {
+ {
blockId: 'p15',
st: 2394 + 28,
ed: 2582 + 28,
@@ -647,8 +552,8 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
fs: 20,
},
},
- elements: {
- e1: {
+ elements: [
+ {
eId: 'e1',
st: 2394 + 28,
ed: 2422 + 28,
@@ -664,7 +569,7 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
},
},
},
- e2: {
+ {
eId: 'e2',
st: 2423 + 28,
ed: 2582 + 28,
@@ -676,20 +581,10 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
},
},
},
- },
- elementOrder: [
- {
- elementId: 'e1',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
- {
- elementId: 'e2',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- twoSectionBreak: {
+ {
blockId: 'twoSectionBreak',
st: 0,
ed: 0,
@@ -707,8 +602,7 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {
// contentDirection: textDirection!,
},
},
- },
- blockElementOrder: ['p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8', 'p9', 'oneSectionBreak', 'p10', 'p11', 'p12', 'p13', 'p14', 'p15', 'twoSectionBreak'],
+ ],
},
documentStyle: {
pageSize: {
diff --git a/packages/common-plugin-data/src/Sheets/DEFAULT_WORKBOOK_DATA.ts b/packages/common-plugin-data/src/Sheets/DEFAULT_WORKBOOK_DATA.ts
index 9096219cd5..5aab151722 100644
--- a/packages/common-plugin-data/src/Sheets/DEFAULT_WORKBOOK_DATA.ts
+++ b/packages/common-plugin-data/src/Sheets/DEFAULT_WORKBOOK_DATA.ts
@@ -129,8 +129,8 @@ const richTextTestFloat: IDocumentData = {
},
},
body: {
- blockElements: {
- oneParagraph: {
+ blockElements: [
+ {
blockId: 'oneParagraph',
st: 0,
ed: 15,
@@ -143,8 +143,8 @@ const richTextTestFloat: IDocumentData = {
fs: 20,
},
},
- elements: {
- oneElement: {
+ elements: [
+ {
eId: 'oneElement',
st: 0,
ed: 15,
@@ -162,7 +162,13 @@ const richTextTestFloat: IDocumentData = {
},
},
},
- smallSub: {
+ {
+ eId: 'shapeTest1',
+ et: ParagraphElementType.DRAWING,
+ st: 0,
+ ed: 0,
+ },
+ {
eId: 'smallSub',
st: 0,
ed: 15,
@@ -181,7 +187,7 @@ const richTextTestFloat: IDocumentData = {
},
},
},
- twoElement: {
+ {
eId: 'twoElement',
st: 0,
ed: 15,
@@ -199,28 +205,10 @@ const richTextTestFloat: IDocumentData = {
},
},
},
- },
- elementOrder: [
- {
- elementId: 'oneElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
- {
- elementId: 'shapeTest1',
- paragraphElementType: ParagraphElementType.DRAWING,
- },
- {
- elementId: 'smallSub',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
- {
- elementId: 'twoElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- twoParagraph: {
+ {
blockId: 'twoParagraph',
st: 0,
ed: 15,
@@ -233,8 +221,8 @@ const richTextTestFloat: IDocumentData = {
fs: 20,
},
},
- elements: {
- oneElement: {
+ elements: [
+ {
eId: 'oneElement',
st: 0,
ed: 15,
@@ -243,7 +231,7 @@ const richTextTestFloat: IDocumentData = {
ct: '细化埋点上报链路和指标方案梳理',
},
},
- twoElement: {
+ {
eId: 'twoElement',
st: 0,
ed: 15,
@@ -252,20 +240,10 @@ const richTextTestFloat: IDocumentData = {
ct: '目前通过每日定时任务发送报告',
},
},
- },
- elementOrder: [
- {
- elementId: 'oneElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
- {
- elementId: 'twoElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- threeParagraph: {
+ {
blockId: 'threeParagraph',
st: 0,
ed: 15,
@@ -278,8 +256,8 @@ const richTextTestFloat: IDocumentData = {
fs: 20,
},
},
- elements: {
- oneElement: {
+ elements: [
+ {
eId: 'oneElement',
st: 0,
ed: 15,
@@ -288,7 +266,7 @@ const richTextTestFloat: IDocumentData = {
ct: '自2018年首届进博会举办以来,进博会已经成为全球新品的首发地、前沿技术的首选地、创新服务的首推地。',
},
},
- twoElement: {
+ {
eId: 'twoElement',
st: 0,
ed: 15,
@@ -297,20 +275,10 @@ const richTextTestFloat: IDocumentData = {
ct: '中国这十年”对外开放成就展湖北展区主要以图文、图表、数据、视频、企业展品、实物模型、光电科技等体现湖北十年开放成就、重大开放平台及产业。湖北省共计17家企业、机构的展品将在这一展区展示',
},
},
- },
- elementOrder: [
- {
- elementId: 'oneElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
- {
- elementId: 'twoElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- fourParagraph: {
+ {
blockId: 'fourParagraph',
st: 0,
ed: 15,
@@ -323,8 +291,8 @@ const richTextTestFloat: IDocumentData = {
fs: 20,
},
},
- elements: {
- oneElement: {
+ elements: [
+ {
eId: 'oneElement',
st: 0,
ed: 15,
@@ -333,7 +301,7 @@ const richTextTestFloat: IDocumentData = {
ct: '国家主席习近平以视频方式出席在上海举行的第五届中国国际进口博览会开幕式并发表题为《共创开放繁荣的美好未来》的致辞',
},
},
- twoElement: {
+ {
eId: 'twoElement',
st: 0,
ed: 15,
@@ -342,20 +310,10 @@ const richTextTestFloat: IDocumentData = {
ct: '中国将推动各国各方共享深化国际合作机遇,全面深入参与世界贸易组织改革谈判',
},
},
- },
- elementOrder: [
- {
- elementId: 'oneElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
- {
- elementId: 'twoElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- fiveParagraph: {
+ {
blockId: 'fiveParagraph',
st: 0,
ed: 15,
@@ -368,8 +326,8 @@ const richTextTestFloat: IDocumentData = {
fs: 20,
},
},
- elements: {
- oneElement: {
+ elements: [
+ {
eId: 'oneElement',
st: 0,
ed: 15,
@@ -378,7 +336,7 @@ const richTextTestFloat: IDocumentData = {
ct: '中国男排两名现役国手彭世坤和张秉龙分别效力的三得利太阳鸟和东京大熊本轮遭遇。',
},
},
- twoElement: {
+ {
eId: 'twoElement',
st: 0,
ed: 15,
@@ -387,21 +345,10 @@ const richTextTestFloat: IDocumentData = {
ct: '双方经过激战,主场作战的卫冕冠军三得利技高一筹3-2逆转击败对手,力夺第3场胜利',
},
},
- },
- elementOrder: [
- {
- elementId: 'oneElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
- {
- elementId: 'twoElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- },
- blockElementOrder: ['oneParagraph', 'twoParagraph', 'threeParagraph', 'fourParagraph', 'fiveParagraph'],
+ ],
},
documentStyle: {
pageSize: {
@@ -418,15 +365,15 @@ const richTextTestFloat: IDocumentData = {
const richTextTest: IDocumentData = {
id: 'd',
body: {
- blockElements: {
- oneParagraph: {
+ blockElements: [
+ {
blockId: 'oneParagraph',
st: 0,
ed: 15,
blockType: BlockType.PARAGRAPH,
paragraph: {
- elements: {
- oneElement: {
+ elements: [
+ {
eId: 'oneElement',
st: 0,
ed: 15,
@@ -444,7 +391,7 @@ const richTextTest: IDocumentData = {
},
},
},
- smallSub: {
+ {
eId: 'twoElement',
st: 0,
ed: 15,
@@ -463,7 +410,7 @@ const richTextTest: IDocumentData = {
},
},
},
- twoElement: {
+ {
eId: 'twoElement',
st: 0,
ed: 15,
@@ -481,25 +428,10 @@ const richTextTest: IDocumentData = {
},
},
},
- },
- elementOrder: [
- {
- elementId: 'oneElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
- {
- elementId: 'smallSub',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
- {
- elementId: 'twoElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- },
- blockElementOrder: ['oneParagraph'],
+ ],
},
documentStyle: {
pageSize: {
diff --git a/packages/common-plugin-data/src/Sheets/Demo/DEFAULT_WORKBOOK_DATA_DEMO.ts b/packages/common-plugin-data/src/Sheets/Demo/DEFAULT_WORKBOOK_DATA_DEMO.ts
index e91c46af80..85b78281ce 100644
--- a/packages/common-plugin-data/src/Sheets/Demo/DEFAULT_WORKBOOK_DATA_DEMO.ts
+++ b/packages/common-plugin-data/src/Sheets/Demo/DEFAULT_WORKBOOK_DATA_DEMO.ts
@@ -4,15 +4,15 @@ import { PAGE5_RICHTEXT_1 } from '../../Slides/RichText/PAGE5_RICHTEXT_1';
const richTextDemo: IDocumentData = {
id: 'd',
body: {
- blockElements: {
- oneParagraph: {
+ blockElements: [
+ {
blockId: 'oneParagraph',
st: 0,
ed: 15,
blockType: BlockType.PARAGRAPH,
paragraph: {
- elements: {
- oneElement: {
+ elements: [
+ {
eId: 'oneElement',
st: 0,
ed: 15,
@@ -26,7 +26,13 @@ const richTextDemo: IDocumentData = {
},
},
},
- twoElement: {
+ {
+ eId: 'breakElement',
+ et: ParagraphElementType.PAGE_BREAK,
+ st: 0,
+ ed: 0,
+ },
+ {
eId: 'twoElement',
st: 0,
ed: 15,
@@ -40,7 +46,13 @@ const richTextDemo: IDocumentData = {
},
},
},
- threeElement: {
+ {
+ eId: 'breakElement1',
+ et: ParagraphElementType.PAGE_BREAK,
+ st: 0,
+ ed: 0,
+ },
+ {
eId: 'threeElement',
st: 0,
ed: 15,
@@ -54,7 +66,13 @@ const richTextDemo: IDocumentData = {
},
},
},
- fourElement: {
+ {
+ eId: 'breakElement2',
+ et: ParagraphElementType.PAGE_BREAK,
+ st: 0,
+ ed: 0,
+ },
+ {
eId: 'fourElement',
st: 0,
ed: 15,
@@ -68,7 +86,13 @@ const richTextDemo: IDocumentData = {
},
},
},
- fiveElement: {
+ {
+ eId: 'breakElement3',
+ et: ParagraphElementType.PAGE_BREAK,
+ st: 0,
+ ed: 0,
+ },
+ {
eId: 'fiveElement',
st: 0,
ed: 15,
@@ -82,44 +106,6 @@ const richTextDemo: IDocumentData = {
},
},
},
- },
- elementOrder: [
- {
- elementId: 'oneElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
- {
- elementId: 'breakElement',
- paragraphElementType: ParagraphElementType.PAGE_BREAK,
- },
- {
- elementId: 'twoElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
- {
- elementId: 'breakElement1',
- paragraphElementType: ParagraphElementType.PAGE_BREAK,
- },
- {
- elementId: 'threeElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
- {
- elementId: 'breakElement2',
- paragraphElementType: ParagraphElementType.PAGE_BREAK,
- },
- {
- elementId: 'fourElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
- {
- elementId: 'breakElement2',
- paragraphElementType: ParagraphElementType.PAGE_BREAK,
- },
- {
- elementId: 'fiveElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
paragraphStyle: {
spaceAbove: 10,
@@ -127,8 +113,7 @@ const richTextDemo: IDocumentData = {
},
},
},
- },
- blockElementOrder: ['oneParagraph'],
+ ],
},
documentStyle: {
pageSize: {
@@ -145,15 +130,15 @@ const richTextDemo: IDocumentData = {
const richTextDemo1: IDocumentData = {
id: 'd',
body: {
- blockElements: {
- oneParagraph: {
+ blockElements: [
+ {
blockId: 'oneParagraph',
st: 0,
ed: 15,
blockType: BlockType.PARAGRAPH,
paragraph: {
- elements: {
- oneElement: {
+ elements: [
+ {
eId: 'oneElement',
st: 0,
ed: 15,
@@ -168,7 +153,7 @@ const richTextDemo1: IDocumentData = {
},
},
},
- twoElement: {
+ {
eId: 'twoElement',
st: 0,
ed: 15,
@@ -183,21 +168,10 @@ const richTextDemo1: IDocumentData = {
},
},
},
- },
- elementOrder: [
- {
- elementId: 'oneElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
- {
- elementId: 'twoElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- },
- blockElementOrder: ['oneParagraph'],
+ ],
},
documentStyle: {
pageSize: {
diff --git a/packages/common-plugin-data/src/Sheets/Demo/DEFAULT_WORKBOOK_DATA_DEMO3.ts b/packages/common-plugin-data/src/Sheets/Demo/DEFAULT_WORKBOOK_DATA_DEMO3.ts
index 4ca9699629..7cff2ca263 100644
--- a/packages/common-plugin-data/src/Sheets/Demo/DEFAULT_WORKBOOK_DATA_DEMO3.ts
+++ b/packages/common-plugin-data/src/Sheets/Demo/DEFAULT_WORKBOOK_DATA_DEMO3.ts
@@ -3,15 +3,15 @@ import { BlockType, BooleanNumber, BorderStyleTypes, IDocumentData, IWorkbookCon
const richTextDemo: IDocumentData = {
id: 'd',
body: {
- blockElements: {
- oneParagraph: {
+ blockElements: [
+ {
blockId: 'oneParagraph',
st: 0,
ed: 15,
blockType: BlockType.PARAGRAPH,
paragraph: {
- elements: {
- oneElement: {
+ elements: [
+ {
eId: 'oneElement',
st: 0,
ed: 15,
@@ -25,7 +25,13 @@ const richTextDemo: IDocumentData = {
},
},
},
- twoElement: {
+ {
+ eId: 'breakElement',
+ et: ParagraphElementType.PAGE_BREAK,
+ st: 0,
+ ed: 0,
+ },
+ {
eId: 'twoElement',
st: 0,
ed: 15,
@@ -39,7 +45,13 @@ const richTextDemo: IDocumentData = {
},
},
},
- threeElement: {
+ {
+ eId: 'breakElement1',
+ et: ParagraphElementType.PAGE_BREAK,
+ st: 0,
+ ed: 0,
+ },
+ {
eId: 'threeElement',
st: 0,
ed: 15,
@@ -53,7 +65,13 @@ const richTextDemo: IDocumentData = {
},
},
},
- fourElement: {
+ {
+ eId: 'breakElement2',
+ et: ParagraphElementType.PAGE_BREAK,
+ st: 0,
+ ed: 0,
+ },
+ {
eId: 'fourElement',
st: 0,
ed: 15,
@@ -67,7 +85,13 @@ const richTextDemo: IDocumentData = {
},
},
},
- fiveElement: {
+ {
+ eId: 'breakElement3',
+ et: ParagraphElementType.PAGE_BREAK,
+ st: 0,
+ ed: 0,
+ },
+ {
eId: 'fiveElement',
st: 0,
ed: 15,
@@ -81,44 +105,6 @@ const richTextDemo: IDocumentData = {
},
},
},
- },
- elementOrder: [
- {
- elementId: 'oneElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
- {
- elementId: 'breakElement',
- paragraphElementType: ParagraphElementType.PAGE_BREAK,
- },
- {
- elementId: 'twoElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
- {
- elementId: 'breakElement1',
- paragraphElementType: ParagraphElementType.PAGE_BREAK,
- },
- {
- elementId: 'threeElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
- {
- elementId: 'breakElement2',
- paragraphElementType: ParagraphElementType.PAGE_BREAK,
- },
- {
- elementId: 'fourElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
- {
- elementId: 'breakElement2',
- paragraphElementType: ParagraphElementType.PAGE_BREAK,
- },
- {
- elementId: 'fiveElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
paragraphStyle: {
spaceAbove: 10,
@@ -126,8 +112,7 @@ const richTextDemo: IDocumentData = {
},
},
},
- },
- blockElementOrder: ['oneParagraph'],
+ ],
},
documentStyle: {
pageSize: {
diff --git a/packages/common-plugin-data/src/Sheets/Demo/DEFAULT_WORKBOOK_DATA_DEMO4.ts b/packages/common-plugin-data/src/Sheets/Demo/DEFAULT_WORKBOOK_DATA_DEMO4.ts
index d6316b2e78..66ea606e2a 100644
--- a/packages/common-plugin-data/src/Sheets/Demo/DEFAULT_WORKBOOK_DATA_DEMO4.ts
+++ b/packages/common-plugin-data/src/Sheets/Demo/DEFAULT_WORKBOOK_DATA_DEMO4.ts
@@ -3,15 +3,15 @@ import { BlockType, BooleanNumber, BorderStyleTypes, IDocumentData, IWorkbookCon
const richTextDemo1: IDocumentData = {
id: 'd',
body: {
- blockElements: {
- oneParagraph: {
+ blockElements: [
+ {
blockId: 'oneParagraph',
st: 0,
ed: 15,
blockType: BlockType.PARAGRAPH,
paragraph: {
- elements: {
- oneElement: {
+ elements: [
+ {
eId: 'oneElement',
st: 0,
ed: 15,
@@ -26,7 +26,7 @@ const richTextDemo1: IDocumentData = {
},
},
},
- twoElement: {
+ {
eId: 'twoElement',
st: 0,
ed: 15,
@@ -41,21 +41,10 @@ const richTextDemo1: IDocumentData = {
},
},
},
- },
- elementOrder: [
- {
- elementId: 'oneElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
- {
- elementId: 'twoElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- },
- blockElementOrder: ['oneParagraph'],
+ ],
},
documentStyle: {
pageSize: {
diff --git a/packages/common-plugin-data/src/Slides/RichText/PAGE3_RICHTEXT_1.ts b/packages/common-plugin-data/src/Slides/RichText/PAGE3_RICHTEXT_1.ts
index 6208fa258c..9c94da4c19 100644
--- a/packages/common-plugin-data/src/Slides/RichText/PAGE3_RICHTEXT_1.ts
+++ b/packages/common-plugin-data/src/Slides/RichText/PAGE3_RICHTEXT_1.ts
@@ -16,8 +16,8 @@ export const PAGE3_RICHTEXT_1 = {
id: 'd',
lists: DEFAULT_LIST_TEST,
body: {
- blockElements: {
- oneParagraph: {
+ blockElements: [
+ {
blockId: 'oneParagraph',
st: 0,
ed: 59,
@@ -33,8 +33,8 @@ export const PAGE3_RICHTEXT_1 = {
paragraphStyle: {
spaceBelow: 15,
},
- elements: {
- oneElement: {
+ elements: [
+ {
eId: 'oneElement',
st: 0,
ed: 15,
@@ -46,16 +46,10 @@ export const PAGE3_RICHTEXT_1 = {
},
},
},
- },
- elementOrder: [
- {
- elementId: 'oneElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- twoParagraph: {
+ {
blockId: 'twoParagraph',
st: 0,
ed: 59,
@@ -68,8 +62,8 @@ export const PAGE3_RICHTEXT_1 = {
fs: 20,
},
},
- elements: {
- oneElement: {
+ elements: [
+ {
eId: 'oneElement',
st: 0,
ed: 15,
@@ -81,17 +75,10 @@ export const PAGE3_RICHTEXT_1 = {
},
},
},
- },
- elementOrder: [
- {
- elementId: 'oneElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- },
- blockElementOrder: ['oneParagraph', 'twoParagraph'],
+ ],
},
documentStyle: {
pageSize: {
diff --git a/packages/common-plugin-data/src/Slides/RichText/PAGE3_RICHTEXT_2.ts b/packages/common-plugin-data/src/Slides/RichText/PAGE3_RICHTEXT_2.ts
index b85f4f174f..d147ad6ca8 100644
--- a/packages/common-plugin-data/src/Slides/RichText/PAGE3_RICHTEXT_2.ts
+++ b/packages/common-plugin-data/src/Slides/RichText/PAGE3_RICHTEXT_2.ts
@@ -16,8 +16,8 @@ export const PAGE3_RICHTEXT_2 = {
id: 'd',
lists: DEFAULT_LIST_TEST,
body: {
- blockElements: {
- oneParagraph: {
+ blockElements: [
+ {
blockId: 'oneParagraph',
st: 0,
ed: 59,
@@ -33,8 +33,8 @@ export const PAGE3_RICHTEXT_2 = {
paragraphStyle: {
spaceBelow: 15,
},
- elements: {
- oneElement: {
+ elements: [
+ {
eId: 'oneElement',
st: 0,
ed: 15,
@@ -46,16 +46,10 @@ export const PAGE3_RICHTEXT_2 = {
},
},
},
- },
- elementOrder: [
- {
- elementId: 'oneElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- twoParagraph: {
+ {
blockId: 'twoParagraph',
st: 0,
ed: 59,
@@ -68,8 +62,8 @@ export const PAGE3_RICHTEXT_2 = {
fs: 20,
},
},
- elements: {
- oneElement: {
+ elements: [
+ {
eId: 'oneElement',
st: 0,
ed: 15,
@@ -81,17 +75,10 @@ export const PAGE3_RICHTEXT_2 = {
},
},
},
- },
- elementOrder: [
- {
- elementId: 'oneElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- },
- blockElementOrder: ['oneParagraph', 'twoParagraph'],
+ ],
},
documentStyle: {
pageSize: {
diff --git a/packages/common-plugin-data/src/Slides/RichText/PAGE3_RICHTEXT_3.ts b/packages/common-plugin-data/src/Slides/RichText/PAGE3_RICHTEXT_3.ts
index d83e9c8a65..fb4a0482cc 100644
--- a/packages/common-plugin-data/src/Slides/RichText/PAGE3_RICHTEXT_3.ts
+++ b/packages/common-plugin-data/src/Slides/RichText/PAGE3_RICHTEXT_3.ts
@@ -16,8 +16,8 @@ export const PAGE3_RICHTEXT_3 = {
id: 'd',
lists: DEFAULT_LIST_TEST,
body: {
- blockElements: {
- oneParagraph: {
+ blockElements: [
+ {
blockId: 'oneParagraph',
st: 0,
ed: 59,
@@ -33,8 +33,8 @@ export const PAGE3_RICHTEXT_3 = {
paragraphStyle: {
spaceBelow: 15,
},
- elements: {
- oneElement: {
+ elements: [
+ {
eId: 'oneElement',
st: 0,
ed: 15,
@@ -46,16 +46,10 @@ export const PAGE3_RICHTEXT_3 = {
},
},
},
- },
- elementOrder: [
- {
- elementId: 'oneElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- twoParagraph: {
+ {
blockId: 'twoParagraph',
st: 0,
ed: 59,
@@ -68,8 +62,8 @@ export const PAGE3_RICHTEXT_3 = {
fs: 20,
},
},
- elements: {
- oneElement: {
+ elements: [
+ {
eId: 'oneElement',
st: 0,
ed: 15,
@@ -81,17 +75,10 @@ export const PAGE3_RICHTEXT_3 = {
},
},
},
- },
- elementOrder: [
- {
- elementId: 'oneElement',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- },
- blockElementOrder: ['oneParagraph', 'twoParagraph'],
+ ],
},
documentStyle: {
pageSize: {
diff --git a/packages/common-plugin-data/src/Slides/RichText/PAGE5_RICHTEXT_1.ts b/packages/common-plugin-data/src/Slides/RichText/PAGE5_RICHTEXT_1.ts
index de483281b9..043e480137 100644
--- a/packages/common-plugin-data/src/Slides/RichText/PAGE5_RICHTEXT_1.ts
+++ b/packages/common-plugin-data/src/Slides/RichText/PAGE5_RICHTEXT_1.ts
@@ -5,15 +5,15 @@ export const PAGE5_RICHTEXT_1: IDocumentData = {
id: 'd',
lists: DEFAULT_LIST_TEST,
body: {
- blockElements: {
- p1: {
+ blockElements: [
+ {
blockId: 'p1',
st: 0,
ed: 66,
blockType: BlockType.PARAGRAPH,
paragraph: {
- elements: {
- e1: {
+ elements: [
+ {
eId: 'e1',
st: 0,
ed: 66,
@@ -29,16 +29,10 @@ export const PAGE5_RICHTEXT_1: IDocumentData = {
},
},
},
- },
- elementOrder: [
- {
- elementId: 'e1',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- p2: {
+ {
blockId: 'p2',
st: 67,
ed: 251,
@@ -48,8 +42,8 @@ export const PAGE5_RICHTEXT_1: IDocumentData = {
spaceAbove: 20,
indentFirstLine: 20,
},
- elements: {
- e1: {
+ elements: [
+ {
eId: 'e1',
st: 67,
ed: 251,
@@ -64,16 +58,10 @@ export const PAGE5_RICHTEXT_1: IDocumentData = {
},
},
},
- },
- elementOrder: [
- {
- elementId: 'e1',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- p3: {
+ {
blockId: 'p3',
st: 252,
ed: 401,
@@ -83,8 +71,8 @@ export const PAGE5_RICHTEXT_1: IDocumentData = {
spaceAbove: 20,
indentFirstLine: 20,
},
- elements: {
- e1: {
+ elements: [
+ {
eId: 'e1',
st: 252,
ed: 401,
@@ -99,16 +87,10 @@ export const PAGE5_RICHTEXT_1: IDocumentData = {
},
},
},
- },
- elementOrder: [
- {
- elementId: 'e1',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- p4: {
+ {
blockId: 'p4',
st: 402,
ed: 429,
@@ -127,8 +109,8 @@ export const PAGE5_RICHTEXT_1: IDocumentData = {
paragraphStyle: {
lineSpacing: 1.5,
},
- elements: {
- e1: {
+ elements: [
+ {
eId: 'e1',
st: 402,
ed: 429,
@@ -143,16 +125,10 @@ export const PAGE5_RICHTEXT_1: IDocumentData = {
},
},
},
- },
- elementOrder: [
- {
- elementId: 'e1',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- p13: {
+ {
blockId: 'p13',
st: 2020 + 28,
ed: 2250 + 28,
@@ -168,8 +144,8 @@ export const PAGE5_RICHTEXT_1: IDocumentData = {
fs: 20,
},
},
- elements: {
- e1: {
+ elements: [
+ {
eId: 'e1',
st: 2020 + 28,
ed: 2042 + 28,
@@ -182,16 +158,10 @@ export const PAGE5_RICHTEXT_1: IDocumentData = {
},
},
},
- },
- elementOrder: [
- {
- elementId: 'e1',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- p14: {
+ {
blockId: 'p14',
st: 2251 + 28,
ed: 2393 + 28,
@@ -207,8 +177,8 @@ export const PAGE5_RICHTEXT_1: IDocumentData = {
fs: 20,
},
},
- elements: {
- e1: {
+ elements: [
+ {
eId: 'e1',
st: 2251 + 28,
ed: 2265 + 28,
@@ -222,16 +192,10 @@ export const PAGE5_RICHTEXT_1: IDocumentData = {
},
},
},
- },
- elementOrder: [
- {
- elementId: 'e1',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- p5: {
+ {
blockId: 'p5',
st: 430,
ed: 479,
@@ -250,8 +214,8 @@ export const PAGE5_RICHTEXT_1: IDocumentData = {
paragraphStyle: {
lineSpacing: 1.5,
},
- elements: {
- e1: {
+ elements: [
+ {
eId: 'e1',
st: 430,
ed: 479,
@@ -266,16 +230,10 @@ export const PAGE5_RICHTEXT_1: IDocumentData = {
},
},
},
- },
- elementOrder: [
- {
- elementId: 'e1',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- p15: {
+ {
blockId: 'p15',
st: 2394 + 28,
ed: 2582 + 28,
@@ -291,8 +249,8 @@ export const PAGE5_RICHTEXT_1: IDocumentData = {
fs: 20,
},
},
- elements: {
- e1: {
+ elements: [
+ {
eId: 'e1',
st: 2394 + 28,
ed: 2422 + 28,
@@ -308,16 +266,10 @@ export const PAGE5_RICHTEXT_1: IDocumentData = {
},
},
},
- },
- elementOrder: [
- {
- elementId: 'e1',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- p6: {
+ {
blockId: 'p6',
st: 480,
ed: 510,
@@ -336,8 +288,8 @@ export const PAGE5_RICHTEXT_1: IDocumentData = {
paragraphStyle: {
lineSpacing: 1.5,
},
- elements: {
- e1: {
+ elements: [
+ {
eId: 'e1',
st: 480,
ed: 510,
@@ -352,17 +304,10 @@ export const PAGE5_RICHTEXT_1: IDocumentData = {
},
},
},
- },
- elementOrder: [
- {
- elementId: 'e1',
- paragraphElementType: ParagraphElementType.TEXT_RUN,
- },
],
},
},
- },
- blockElementOrder: ['p1', 'p3', 'p4', 'p13', 'p14', 'p5', 'p15', 'p6'],
+ ],
},
documentStyle: {
pageSize: {
diff --git a/packages/core/src/Command/RegisterAction.ts b/packages/core/src/Command/RegisterAction.ts
index 0c50cccafd..02d3398584 100644
--- a/packages/core/src/Command/RegisterAction.ts
+++ b/packages/core/src/Command/RegisterAction.ts
@@ -65,6 +65,7 @@ import {
InsertSectionAction,
UpdateBulletAction,
UpdateParagraphBulletAction,
+ TextIndexAdjustAction,
} from '../Docs';
/**
@@ -232,3 +233,8 @@ CommandManager.register(
DOC_ACTION_NAMES.UPDATE_PARAGRAPH_BULLET_ACTION_NAME,
UpdateParagraphBulletAction
);
+
+CommandManager.register(
+ DOC_ACTION_NAMES.TEXT_INDEX_ADJUST_ACTION_NAME,
+ TextIndexAdjustAction
+);
diff --git a/packages/core/src/Const/DOC_ACTION_NAMES.ts b/packages/core/src/Const/DOC_ACTION_NAMES.ts
index c22a670c8f..3afc7498a9 100644
--- a/packages/core/src/Const/DOC_ACTION_NAMES.ts
+++ b/packages/core/src/Const/DOC_ACTION_NAMES.ts
@@ -20,4 +20,6 @@ export enum DOC_ACTION_NAMES {
INSERT_SECTION_ACTION_NAME = 'InsertSectionAction',
UPDATE_BULLET_ACTION_NAME = 'UpdateBulletAction',
UPDATE_PARAGRAPH_BULLET_ACTION_NAME = 'UpdateParagraphBulletAction',
+
+ TEXT_INDEX_ADJUST_ACTION_NAME = 'TextIndexAdjustAction',
}
diff --git a/packages/core/src/Docs/Action/DeleteTextAction.ts b/packages/core/src/Docs/Action/DeleteTextAction.ts
index be26e1d334..6d9d1fc303 100644
--- a/packages/core/src/Docs/Action/DeleteTextAction.ts
+++ b/packages/core/src/Docs/Action/DeleteTextAction.ts
@@ -3,12 +3,13 @@ import { ActionObservers, CommandUnit } from '../../Command';
import { DeleteTextApply } from '../Apply/DeleteTextApply';
import { IInsertTextActionData } from './InsertTextAction';
import { InsertTextApply } from '../Apply/InsertTextApply';
+import { ITextSelectionRangeParam } from '../../Interfaces/ISelectionData';
+import { DOC_ACTION_NAMES } from '../../Const/DOC_ACTION_NAMES';
-export interface IDeleteTextActionData extends IDocActionData {
+export interface IDeleteTextActionData
+ extends IDocActionData,
+ ITextSelectionRangeParam {
text: string;
- start: number;
- length: number;
- segmentId?: string; //The ID of the header, footer or footnote the location is in. An empty segment ID signifies the document's body.
}
export class DeleteTextAction extends DocActionBase<
@@ -23,8 +24,14 @@ export class DeleteTextAction extends DocActionBase<
super(actionData, commandUnit, observers);
this._doActionData = { ...actionData };
this.do();
- const { length, start } = actionData;
- this._oldActionData = { ...actionData, start: start - length };
+ const { text, cursorStart, isStartBack, segmentId } = actionData;
+ this._oldActionData = {
+ actionName: DOC_ACTION_NAMES.INSERT_TEXT_ACTION_NAME,
+ text,
+ cursorStart,
+ isStartBack,
+ segmentId,
+ };
}
redo(): void {
@@ -34,16 +41,30 @@ export class DeleteTextAction extends DocActionBase<
do(): void {
const actionData = this.getDoActionData();
const document = this.getDocument();
- const { length, start } = actionData;
- DeleteTextApply(document, { length, start });
+ const {
+ cursorStart,
+ cursorEnd,
+ isStartBack,
+ isEndBack,
+ isCollapse,
+ segmentId,
+ } = actionData;
+ DeleteTextApply(document, {
+ cursorStart,
+ cursorEnd,
+ isStartBack,
+ isEndBack,
+ isCollapse,
+ segmentId,
+ });
}
undo(): void {
// TODO ...
const actionData = this.getOldActionDaa();
const document = this.getDocument();
- const { text, start, length } = actionData;
- InsertTextApply(document, { text, start, length });
+ // const { text, start, length } = actionData;
+ InsertTextApply(document, { ...actionData });
}
validate(): boolean {
diff --git a/packages/core/src/Docs/Action/InsertTextAction.ts b/packages/core/src/Docs/Action/InsertTextAction.ts
index 9306ef8448..e4036a6ad7 100644
--- a/packages/core/src/Docs/Action/InsertTextAction.ts
+++ b/packages/core/src/Docs/Action/InsertTextAction.ts
@@ -3,11 +3,12 @@ import { ActionObservers, ActionType, CommandUnit } from '../../Command';
import { InsertTextApply } from '../Apply/InsertTextApply';
import { IDeleteTextActionData } from './DeleteTextAction';
import { DeleteTextApply } from '../Apply/DeleteTextApply';
+import { DOC_ACTION_NAMES } from '../../Const/DOC_ACTION_NAMES';
export interface IInsertTextActionData extends IDocActionData {
text: string;
- start: number;
- length: number;
+ cursorStart: number;
+ isStartBack: boolean;
segmentId?: string; //The ID of the header, footer or footnote the location is in. An empty segment ID signifies the document's body.
}
@@ -23,8 +24,14 @@ export class InsertTextAction extends DocActionBase<
super(actionData, commandUnit, observers);
this._doActionData = { ...actionData };
this.do();
- const { length, start } = actionData;
- this._oldActionData = { ...actionData, start: start + length };
+ const { cursorStart, isStartBack, text } = actionData;
+ this._oldActionData = {
+ ...actionData,
+ actionName: DOC_ACTION_NAMES.DELETE_TEXT_ACTION_NAME,
+ cursorEnd: cursorStart + text.length,
+ isEndBack: isStartBack,
+ isCollapse: true,
+ };
}
redo(): void {
@@ -34,8 +41,8 @@ export class InsertTextAction extends DocActionBase<
do(): void {
const actionData = this.getDoActionData();
const document = this.getDocument();
- const { text, start, length, segmentId } = actionData;
- InsertTextApply(document, { text, start, length, segmentId });
+ // const { text, start, length, segmentId } = actionData;
+ InsertTextApply(document, { ...actionData });
this._observers.notifyObservers({
type: ActionType.REDO,
@@ -47,8 +54,8 @@ export class InsertTextAction extends DocActionBase<
undo(): void {
const actionData = this.getOldActionDaa();
const document = this.getDocument();
- const { length, start, segmentId } = actionData;
- DeleteTextApply(document, { length, start, segmentId });
+ // const { length, start, segmentId } = actionData;
+ DeleteTextApply(document, { ...actionData });
this._observers.notifyObservers({
type: ActionType.UNDO,
diff --git a/packages/core/src/Docs/Action/TextIndexAdjustAction.ts b/packages/core/src/Docs/Action/TextIndexAdjustAction.ts
new file mode 100644
index 0000000000..a10d055ff9
--- /dev/null
+++ b/packages/core/src/Docs/Action/TextIndexAdjustAction.ts
@@ -0,0 +1,57 @@
+import { DocActionBase, IDocActionData } from '../../Command/DocActionBase';
+import { ActionObservers, ActionType, CommandUnit } from '../../Command';
+import { ITextSelectionRangeParam } from '../../Interfaces';
+import { textIndexAdjustApply } from '../Apply/TextIndexAdjustApply';
+
+export interface ITextIndexAdjustAction
+ extends IDocActionData,
+ ITextSelectionRangeParam {}
+
+export class TextIndexAdjustAction extends DocActionBase<
+ ITextIndexAdjustAction,
+ ITextIndexAdjustAction
+> {
+ constructor(
+ actionData: ITextIndexAdjustAction,
+ commandUnit: CommandUnit,
+ observers: ActionObservers
+ ) {
+ super(actionData, commandUnit, observers);
+ this._doActionData = { ...actionData };
+ this.do();
+ this._oldActionData = { ...actionData };
+ }
+
+ redo(): void {
+ this.do();
+ }
+
+ do(): void {
+ const actionData = this.getDoActionData();
+ const document = this.getDocument();
+ textIndexAdjustApply(document, actionData);
+
+ this._observers.notifyObservers({
+ type: ActionType.REDO,
+ data: this._doActionData,
+ action: this,
+ });
+ }
+
+ undo(): void {
+ const actionData = this.getOldActionDaa();
+ const document = this.getDocument();
+
+ textIndexAdjustApply(document, actionData);
+
+ this._observers.notifyObservers({
+ type: ActionType.UNDO,
+ data: this._oldActionData,
+ action: this,
+ });
+ }
+
+ validate(): boolean {
+ return false;
+ }
+}
diff --git a/packages/core/src/Docs/Action/index.ts b/packages/core/src/Docs/Action/index.ts
index 3eaac86fff..28e5f54d03 100644
--- a/packages/core/src/Docs/Action/index.ts
+++ b/packages/core/src/Docs/Action/index.ts
@@ -19,3 +19,5 @@ export * from './InsertParagraphBulletAction';
export * from './InsertSectionAction';
export * from './UpdateBulletAction';
export * from './UpdateParagraphBulletAction';
+
+export * from './TextIndexAdjustAction';
diff --git a/packages/core/src/Docs/Apply/DeleteTextApply.ts b/packages/core/src/Docs/Apply/DeleteTextApply.ts
index 7629414088..9d7ea23cdc 100644
--- a/packages/core/src/Docs/Apply/DeleteTextApply.ts
+++ b/packages/core/src/Docs/Apply/DeleteTextApply.ts
@@ -5,48 +5,27 @@ import {
IParagraph,
ParagraphElementType,
} from '../../Interfaces/IDocumentData';
+import { ITextSelectionRangeParam } from '../../Interfaces/ISelectionData';
import { DocumentModel } from '../Domain/DocumentModel';
-import {
- deleteContent,
- getTextStartByAnchor,
- moveBlockCharIndex,
- moveElementCharIndex,
-} from './Common';
+import { deleteContent, getDocsUpdateBody } from './Common';
export function DeleteTextApply(
document: DocumentModel,
- config: { start: number; length: number; segmentId?: string }
+ range: ITextSelectionRangeParam
) {
const doc = document.getSnapshot();
- const { start, length, segmentId } = config;
-
- const textStart = getTextStartByAnchor(start);
- let body = doc.body;
+ const { segmentId } = range;
- if (length === 0) {
- return;
- }
-
- if (segmentId) {
- const { headers, footers } = doc;
- if (headers?.[segmentId]) {
- body = headers[segmentId].body;
- } else if (footers?.[segmentId]) {
- body = footers[segmentId].body;
- }
- }
+ const body = getDocsUpdateBody(doc, segmentId);
if (body == null) {
throw new Error('no body has changed');
}
- const { blockElements, blockElementOrder } = body;
-
- let isApplied = false;
+ const { blockElements } = body;
- for (let blockId of blockElementOrder) {
- const blockElement = blockElements[blockId];
+ for (let blockElement of blockElements) {
if (blockElement == null) {
continue;
}
@@ -55,47 +34,30 @@ export function DeleteTextApply(
switch (blockType) {
case BlockType.PARAGRAPH:
- isApplied = paragraphApply(
- start,
- textStart,
- length,
- blockElement,
- blockElement.paragraph,
- isApplied
- );
+ if (blockElement.paragraph) {
+ deleteText(blockElement, blockElement.paragraph, range);
+ }
}
}
}
-function paragraphApply(
- start: number,
- textStart: number,
- length: number,
+function deleteText(
blockElement: IBlockElement,
- paragraph?: IParagraph,
- isApplied: boolean = false
+ paragraph: IParagraph,
+ range: ITextSelectionRangeParam
) {
- if (isApplied) {
- moveBlockCharIndex(blockElement, -length);
- }
+ const { cursorStart, cursorEnd, isStartBack, isEndBack, isCollapse } = range;
const { st, ed } = blockElement;
- let isApply = false;
-
- if (textStart > ed) {
- return isApply;
- }
-
- if (paragraph == null) {
- return isApply;
+ if (cursorStart > ed || cursorEnd < st) {
+ return;
}
- const { elements, elementOrder } = paragraph;
+ const { elements } = paragraph;
- for (let elementInfo of elementOrder) {
- const { elementId, paragraphElementType } = elementInfo;
- const element = elements[elementId];
+ for (let element of elements) {
+ const { et: paragraphElementType } = element;
if (paragraphElementType === ParagraphElementType.DRAWING) {
continue;
@@ -103,14 +65,10 @@ function paragraphApply(
const { st, ed, tr } = element;
- if ((isApply || isApplied) && textStart > ed) {
- moveElementCharIndex(element, -length);
- }
-
if (tr == null) {
continue;
}
- if (textStart < st || textStart > ed || isApplied) {
+ if (textStart < st || textStart > ed) {
continue;
}
@@ -121,8 +79,6 @@ function paragraphApply(
relative = 0;
}
- isApply = true;
-
if (tr.tab === BooleanNumber.TRUE) {
continue;
}
@@ -130,18 +86,6 @@ function paragraphApply(
const newContent = deleteContent(tr.ct || '', relative, length);
tr.ct = newContent;
-
- element.ed -= length;
}
}
-
- if (isApply === true && isApplied === false) {
- blockElement.ed -= length;
- }
-
- if (isApplied) {
- return true;
- }
-
- return isApply;
}
diff --git a/packages/core/src/Docs/Apply/InsertTextApply.ts b/packages/core/src/Docs/Apply/InsertTextApply.ts
index 46e03dd204..ed3b625089 100644
--- a/packages/core/src/Docs/Apply/InsertTextApply.ts
+++ b/packages/core/src/Docs/Apply/InsertTextApply.ts
@@ -7,10 +7,9 @@ import {
} from '../../Interfaces/IDocumentData';
import { DocumentModel } from '../Domain/DocumentModel';
import {
+ getDocsUpdateBody,
getTextStartByAnchor,
insertTextToContent,
- moveBlockCharIndex,
- moveElementCharIndex,
} from './Common';
export function InsertTextApply(
@@ -22,31 +21,19 @@ export function InsertTextApply(
const textStart = getTextStartByAnchor(start);
- let body = doc.body;
+ const body = getDocsUpdateBody(doc, segmentId);
if (length === 0) {
return;
}
- if (segmentId) {
- const { headers, footers } = doc;
- if (headers?.[segmentId]) {
- body = headers[segmentId].body;
- } else if (footers?.[segmentId]) {
- body = footers[segmentId].body;
- }
- }
-
if (body == null) {
throw new Error('no body has changed');
}
- const { blockElements, blockElementOrder } = body;
+ const { blockElements } = body;
- let isApplied = false;
-
- for (let blockId of blockElementOrder) {
- const blockElement = blockElements[blockId];
+ for (let blockElement of blockElements) {
if (blockElement == null) {
continue;
}
@@ -55,14 +42,12 @@ export function InsertTextApply(
switch (blockType) {
case BlockType.PARAGRAPH:
- isApplied = paragraphApply(
+ paragraphApply(
text,
start,
textStart,
- length,
blockElement,
- blockElement.paragraph,
- isApplied
+ blockElement.paragraph
);
}
}
@@ -72,32 +57,19 @@ function paragraphApply(
text: string,
start: number,
textStart: number,
- length: number,
blockElement: IBlockElement,
- paragraph?: IParagraph,
- isApplied: boolean = false
+ paragraph?: IParagraph
) {
- if (isApplied) {
- moveBlockCharIndex(blockElement, length);
- }
-
const { st, ed } = blockElement;
- let isApply = false;
-
- if (textStart > ed) {
- return isApply;
- }
-
- if (paragraph == null) {
- return isApply;
+ if (textStart > ed || paragraph == null) {
+ return;
}
- const { elements, elementOrder } = paragraph;
+ const { elements } = paragraph;
- for (let elementInfo of elementOrder) {
- const { elementId, paragraphElementType } = elementInfo;
- const element = elements[elementId];
+ for (let element of elements) {
+ const { et: paragraphElementType } = element;
if (paragraphElementType === ParagraphElementType.DRAWING) {
continue;
@@ -105,14 +77,10 @@ function paragraphApply(
const { st, ed, tr } = element;
- if ((isApply || isApplied) && textStart > ed) {
- moveElementCharIndex(element, length);
- }
-
if (tr == null) {
continue;
}
- if (textStart < st || textStart > ed || isApplied) {
+ if (textStart < st || textStart > ed) {
continue;
}
@@ -121,9 +89,8 @@ function paragraphApply(
textStart,
st,
ed,
- isApplied,
element,
- textStart < st || textStart > ed || isApplied
+ textStart < st || textStart > ed
);
if (paragraphElementType === ParagraphElementType.TEXT_RUN) {
@@ -133,8 +100,6 @@ function paragraphApply(
relative = 0;
}
- isApply = true;
-
if (tr.tab === BooleanNumber.TRUE) {
continue;
}
@@ -142,18 +107,6 @@ function paragraphApply(
const newContent = insertTextToContent(tr.ct || '', relative, text);
tr.ct = newContent;
-
- element.ed += length;
}
}
-
- if (isApply === true && isApplied === false) {
- blockElement.ed += length;
- }
-
- if (isApplied) {
- return true;
- }
-
- return isApply;
}
diff --git a/packages/core/src/Docs/Apply/TextIndexAdjustApply.ts b/packages/core/src/Docs/Apply/TextIndexAdjustApply.ts
new file mode 100644
index 0000000000..d6c9b0e2fd
--- /dev/null
+++ b/packages/core/src/Docs/Apply/TextIndexAdjustApply.ts
@@ -0,0 +1,114 @@
+import {
+ BlockType,
+ IBlockElement,
+ IElement,
+ IParagraph,
+ ParagraphElementType,
+} from '../../Interfaces/IDocumentData';
+import { ITextSelectionRangeParam } from '../../Interfaces/ISelectionData';
+import { Nullable } from '../../Shared';
+import { DocumentModel } from '../Domain/DocumentModel';
+import {
+ getDocsUpdateBody,
+ moveBlockCharIndex,
+ moveElementCharIndex,
+} from './Common';
+
+export function textIndexAdjustApply(
+ document: DocumentModel,
+ range: ITextSelectionRangeParam
+) {
+ const { segmentId } = range;
+
+ const doc = document.getSnapshot();
+ let body = getDocsUpdateBody(doc, segmentId);
+
+ if (body == null) {
+ throw new Error('no body has changed');
+ }
+
+ const { blockElements } = body;
+
+ let preBlockElement: Nullable<IBlockElement> = null;
+
+ for (let blockElement of blockElements) {
+ if (blockElement == null) {
+ continue;
+ }
+
+ const { blockType } = blockElement;
+
+ switch (blockType) {
+ case BlockType.PARAGRAPH:
+ if (blockElement.paragraph) {
+ paragraphIndexAdjust(
+ blockElement,
+ blockElement.paragraph,
+ range,
+ preBlockElement
+ );
+ }
+ }
+
+ preBlockElement = blockElement;
+ }
+}
+
+function paragraphIndexAdjust(
+ blockElement: IBlockElement,
+ paragraph: IParagraph,
+ range: ITextSelectionRangeParam,
+ preBlockElement: Nullable<IBlockElement>
+) {
+ const { cursorStart, cursorEnd, isCollapse, isEndBack, isStartBack } = range;
+
+ const { st: blockStart, ed: blockEnd } = blockElement;
+
+ if (cursorStart > blockEnd) {
+ return;
+ }
+
+ const { elements } = paragraph;
+
+ const preBlockEnd = preBlockElement ? preBlockElement.ed : 0;
+
+ if (cursorEnd < blockStart) {
+ const moveIndex = preBlockEnd - blockStart;
+
+ moveBlockCharIndex(blockElement, -moveIndex);
+
+ _iteratorElement(elements, (element) => {
+ moveElementCharIndex(element, -moveIndex);
+ });
+ } else {
+ let curStart = preBlockEnd + 1;
+ let preElementStart = curStart;
+ _iteratorElement(elements, (element) => {
+ const { tr: textRun } = element;
+
+ const content = textRun?.ct || '';
+
+ element.st = preElementStart;
+ element.ed = preElementStart + content.length - 1;
+
+ preElementStart = element.ed + 1;
+ });
+
+ blockElement.st = curStart;
+ blockElement.ed = preElementStart - 1;
+ }
+}
+
+function _iteratorElement(
+ elements: IElement[],
+ callback: (element: IElement) => void
+) {
+ for (let element of elements) {
+ const { et: paragraphElementType } = element;
+ if (paragraphElementType === ParagraphElementType.DRAWING) {
+ continue;
+ }
+
+ callback(element);
+ }
+}
diff --git a/packages/core/src/Docs/Domain/DocumentModel.ts b/packages/core/src/Docs/Domain/DocumentModel.ts
index f1a27058a8..323e5470db 100644
--- a/packages/core/src/Docs/Domain/DocumentModel.ts
+++ b/packages/core/src/Docs/Domain/DocumentModel.ts
@@ -5,6 +5,7 @@ import { BlockType, IDocumentData, ITextSelectionRange } from '../../Interfaces'
import { DEFAULT_DOC } from '../../Const';
import { DOC_ACTION_NAMES } from '../../Const/DOC_ACTION_NAMES';
import { getDocsUpdateBody } from '../Apply/Common';
+import { Nullable } from '../../Shared';
export class DocumentModel {
private _snapshot: IDocumentData;
@@ -54,16 +55,18 @@ export class DocumentModel {
deleteText(range: ITextSelectionRange, segmentId?: string): DocumentModel {
const { _context } = this;
const _commandManager = _context.getCommandManager();
- const deleteTextAction = {
- actionName: DOC_ACTION_NAMES.DELETE_TEXT_ACTION_NAME,
- ...range,
- segmentId,
- };
+ // const deleteTextAction = {
+ // actionName: DOC_ACTION_NAMES.DELETE_TEXT_ACTION_NAME,
+ // ...range,
+ // segmentId,
+ // };
+
+ const deleteTextActionList = this._getDeleteTextAction(range, segmentId);
const command = new Command(
{
DocumentUnit: this,
},
- deleteTextAction
+ ...deleteTextActionList
);
_commandManager.invoke(command);
return this;
@@ -99,6 +102,35 @@ export class DocumentModel {
}
private _getDeleteTextAction(range: ITextSelectionRange, segmentId?: string) {
+ const { cursorStart, cursorEnd, isCollapse, isEndBack, isStartBack } = range;
+ let actionList = [];
+ if (isCollapse) {
+ actionList = this._getDeleteTextActionCollapse(range, segmentId);
+ } else {
+ actionList = this._getDeleteTextActionRange(range, segmentId);
+ }
+
+ if (actionList.length === 0) {
+ return [];
+ }
+
+ actionList.push({
+ actionName: DOC_ACTION_NAMES.TEXT_INDEX_ADJUST_ACTION_NAME,
+ cursorStart,
+ cursorEnd,
+ isCollapse,
+ isEndBack,
+ isStartBack,
+ segmentId,
+ });
+
+ return actionList;
+ }
+
+ private _getDeleteTextActionCollapse(
+ range: ITextSelectionRange,
+ segmentId?: string
+ ) {
const snapshot = this._snapshot;
const body = getDocsUpdateBody(snapshot, segmentId);
@@ -107,39 +139,135 @@ export class DocumentModel {
return [];
}
- const { blockElements, blockElementOrder } = body;
+ const { blockElements } = body;
- const { cursorStart, cursorEnd, isCollapse, isEndBack, isStartBack } = range;
+ const { cursorStart, isCollapse, isStartBack } = range;
const actionList = [];
- for (let blockId of blockElementOrder) {
- const blockElement = blockElements[blockId];
+ let startBlockId: Nullable<string> = null;
+
+ let endBlockId: Nullable<string> = null;
+
+ let preBlockId: Nullable<string> = null;
+
+ for (let blockElement of blockElements) {
if (blockElement == null) {
continue;
}
- const { blockType, st, ed } = blockElement;
+ const { blockType, st, ed, blockId } = blockElement;
if (blockType === BlockType.PARAGRAPH) {
- if (cursorStart > ed || cursorEnd < st) {
+ if (cursorStart > ed || cursorStart < st) {
continue;
}
- if (cursorStart === st && isCollapse && isStartBack) {
- // bullet
+ if (cursorStart === st && isStartBack) {
+ if (blockElement.paragraph?.bullet) {
+ // bullet
+ actionList.push({
+ actionName: DOC_ACTION_NAMES.DELETE_BULLET_ACTION_NAME,
+ blockId,
+ blockElement,
+ segmentId,
+ });
+ } else {
+ startBlockId = preBlockId;
+ endBlockId = blockId;
+ }
+ } else {
+ // textRun
actionList.push({
- actionName: DOC_ACTION_NAMES.DELETE_BULLET_ACTION_NAME,
- cursorStart: st,
- cursorEnd: ed,
- isCollapse: false,
- isEndBack: false,
- isStartBack: true,
- blockId,
- blockElement,
+ actionName: DOC_ACTION_NAMES.DELETE_TEXT_ACTION_NAME,
+ cursorStart,
+ cursorEnd: cursorStart,
+ isCollapse: true,
+ isEndBack: isStartBack,
+ isStartBack,
segmentId,
});
- } else if (
+ }
+ }
+
+ preBlockId = blockId;
+ }
+
+ if (
+ startBlockId != null &&
+ endBlockId != null &&
+ startBlockId !== endBlockId
+ ) {
+ actionList.push({
+ actionName: DOC_ACTION_NAMES.MERGE_PARAGRAPH_ACTION_NAME,
+ startBlockId,
+ endBlockId,
+ segmentId,
+ cursorStart,
+ isStartBack,
+ });
+ }
+
+ return actionList;
+ }
+
+ private _getDeleteTextActionRange(
+ range: ITextSelectionRange,
+ segmentId?: string
+ ) {
+ const snapshot = this._snapshot;
+
+ const body = getDocsUpdateBody(snapshot, segmentId);
+
+ if (body == null) {
+ return [];
+ }
+
+ const { blockElements } = body;
+
+ const { cursorStart, cursorEnd, isCollapse, isEndBack, isStartBack } = range;
+
+ const actionList = [];
+
+ let startBlockId: Nullable<string> = null;
+
+ let endBlockId: Nullable<string> = null;
+
+ for (let blockElement of blockElements) {
+ if (blockElement == null) {
+ continue;
+ }
+
+ const { blockType, st, ed, blockId } = blockElement;
+
+ if (blockType === BlockType.PARAGRAPH) {
+ if (cursorStart > ed || cursorEnd < st) {
+ continue;
+ }
+
+ let start = st;
+
+ let end = ed;
+
+ let isStartBackCurrent = isStartBack;
+
+ let isEndBackCurrent = isEndBack;
+
+ if (st <= cursorStart && ed >= cursorStart) {
+ startBlockId = blockId;
+ start = cursorStart;
+ } else {
+ isStartBackCurrent = true;
+ }
+
+ if (st <= cursorEnd && ed >= cursorEnd) {
+ endBlockId = blockId;
+ end = cursorEnd;
+ } else {
+ isEndBackCurrent = false;
+ }
+
+ if (
(cursorStart < st || (cursorStart === st && isStartBack)) &&
(cursorEnd > ed || (cursorEnd === ed && !isEndBack)) &&
!isCollapse
@@ -160,11 +288,32 @@ export class DocumentModel {
// textRun
actionList.push({
actionName: DOC_ACTION_NAMES.DELETE_TEXT_ACTION_NAME,
- ...range,
+ cursorStart: start,
+ cursorEnd: end,
+ isCollapse,
+ isEndBack: isEndBackCurrent,
+ isStartBack: isStartBackCurrent,
segmentId,
});
}
}
}
+
+ if (
+ startBlockId != null &&
+ endBlockId != null &&
+ startBlockId !== endBlockId
+ ) {
+ actionList.push({
+ actionName: DOC_ACTION_NAMES.MERGE_PARAGRAPH_ACTION_NAME,
+ startBlockId,
+ endBlockId,
+ segmentId,
+ cursorStart,
+ isStartBack,
+ });
+ }
+
+ return actionList;
}
}
diff --git a/packages/core/src/Interfaces/IDocumentData.ts b/packages/core/src/Interfaces/IDocumentData.ts
index a76927e640..eef16e98c6 100644
--- a/packages/core/src/Interfaces/IDocumentData.ts
+++ b/packages/core/src/Interfaces/IDocumentData.ts
@@ -69,8 +69,7 @@ export interface ISizeData {
* Properties of document body
*/
export interface IDocumentBody {
- blockElements: { [bId: string]: IBlockElement }; // block elements
- blockElementOrder: string[]; // block element order
+ blockElements: IBlockElement[]; // block elements
}
/**
@@ -307,8 +306,7 @@ export interface ISectionColumnProperties {
}
export interface IParagraph {
- elements: { [eId: string]: IElement }; // elements
- elementOrder: IElementsOrder[]; // element order
+ elements: IElement[]; // elements
paragraphStyle?: IParagraphStyle; // paragraphStyle
bullet?: IBullet; // bullet
// dIds?: string[]; // drawingIds objectId
diff --git a/packages/core/src/Interfaces/ISelectionData.ts b/packages/core/src/Interfaces/ISelectionData.ts
index 20b3d24100..9dec31ed14 100644
--- a/packages/core/src/Interfaces/ISelectionData.ts
+++ b/packages/core/src/Interfaces/ISelectionData.ts
@@ -36,3 +36,7 @@ export interface ITextSelectionRange {
isEndBack: boolean;
isCollapse: boolean;
}
+
+export interface ITextSelectionRangeParam extends ITextSelectionRange {
+ segmentId?: string; //The ID of the header, footer or footnote the location is in. An empty segment ID signifies the document's body.
+}
diff --git a/packages/core/src/Shared/Migrate/Migrate.ts b/packages/core/src/Shared/Migrate/Migrate.ts
index abe4fffc2b..90b467dd56 100644
--- a/packages/core/src/Shared/Migrate/Migrate.ts
+++ b/packages/core/src/Shared/Migrate/Migrate.ts
@@ -3,9 +3,9 @@ import {
IWorkbookConfig,
IWorksheetConfig,
ICellData,
- IElementsOrder,
ITextStyle,
IStyleData,
+ IElement,
} from '../../Interfaces';
import { IKeyValue } from '../Types';
import { border } from './Border';
@@ -173,8 +173,7 @@ export function migrate(config: any): Partial<IWorkbookConfig> {
newSheet.cellData[cellItem.r][cellItem.c];
if (cell?.ct?.t === 'inlineStr') {
- const elements = {};
- const elementOrder: IElementsOrder[] = [];
+ const elements: IElement[] = [];
cell.ct.s.forEach((element: any) => {
const textStyle: ITextStyle = {};
@@ -228,7 +227,7 @@ export function migrate(config: any): Partial<IWorkbookConfig> {
}
const eId = nanoid(6);
- elements[eId] = {
+ elements.push({
eId,
st: 0,
ed: element.v.length - 1,
@@ -237,30 +236,23 @@ export function migrate(config: any): Partial<IWorkbookConfig> {
ct: element.v,
ts: textStyle,
},
- };
-
- elementOrder.push({
- elementId: eId,
- paragraphElementType: 0,
});
});
newCell.p = {
- documentId: nanoid(6),
+ id: nanoid(6),
body: {
- blockElements: {
- p1: {
+ blockElements: [
+ {
blockId: 'p1',
st: 0,
ed: cell.ct.s.length - 1,
blockType: 0,
paragraph: {
elements,
- elementOrder,
},
},
- },
- blockElementOrder: ['p1'],
+ ],
},
documentStyle: {},
};
@@ -273,8 +265,8 @@ export function migrate(config: any): Partial<IWorkbookConfig> {
// 显示值
if (cell.hasOwnProperty('m')) {
newCell.m = cell.m;
- }else{
- newCell.m = String(cell.v || '')
+ } else {
+ newCell.m = String(cell.v || '');
}
const cellStyle: IStyleData = {};
diff --git a/packages/core/src/Sheets/Apply/SetRangeStyle.ts b/packages/core/src/Sheets/Apply/SetRangeStyle.ts
index b6d3908058..28e7f4757b 100644
--- a/packages/core/src/Sheets/Apply/SetRangeStyle.ts
+++ b/packages/core/src/Sheets/Apply/SetRangeStyle.ts
@@ -192,39 +192,37 @@ export function mergeRichTextStyle(
p: IDocumentData,
newStyle: Nullable<IStyleData>
) {
- p.body?.blockElementOrder.forEach((blockId) => {
- if (p.body?.blockElements[blockId].blockType === 0) {
- const paragraph = p.body?.blockElements[blockId].paragraph;
- paragraph?.elementOrder.forEach(
- ({ elementId, paragraphElementType }) => {
- if (!paragraph.elements[elementId].tr) {
- paragraph.elements[elementId].tr = {};
- }
-
- const textRun = paragraph.elements[elementId].tr as ITextRun;
-
- if (!textRun.ts) {
- textRun.ts = {};
- }
-
- const oldStyle = textRun.ts;
-
- const merge = mergeStyle(
- oldStyle as Nullable<IStyleData>,
- newStyle,
- true
- );
-
- // then remove null
- merge && Tools.removeNull(merge);
-
- if (Tools.isEmptyObject(merge)) {
- delete textRun.ts;
- } else {
- textRun.ts = merge as ITextStyle;
- }
+ p.body?.blockElements.forEach((blockElement) => {
+ if (blockElement.blockType === 0) {
+ const paragraph = blockElement.paragraph;
+ paragraph?.elements.forEach((element) => {
+ if (!element.tr) {
+ element.tr = {};
}
- );
+
+ const textRun = element.tr as ITextRun;
+
+ if (!textRun.ts) {
+ textRun.ts = {};
+ }
+
+ const oldStyle = textRun.ts;
+
+ const merge = mergeStyle(
+ oldStyle as Nullable<IStyleData>,
+ newStyle,
+ true
+ );
+
+ // then remove null
+ merge && Tools.removeNull(merge);
+
+ if (Tools.isEmptyObject(merge)) {
+ delete textRun.ts;
+ } else {
+ textRun.ts = merge as ITextStyle;
+ }
+ });
}
});
}