Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
feat(doc): support bullet and order list (#755)
Ran Luo0cb4142d4c9a
diff --git a/examples/src/data/docs/default-document-data-cn.ts b/examples/src/data/docs/default-document-data-cn.tsindex eff7175f41..8387ddb1ed 100644--- a/examples/src/data/docs/default-document-data-cn.ts+++ b/examples/src/data/docs/default-document-data-cn.ts@@ -15,13 +15,10 @@*/import type { IDocumentData } from '@univerjs/core';-import { BaselineOffset, BooleanNumber, TextDecoration } from '@univerjs/core';--import { DEFAULT_LIST_TEST } from './default-list';+import { BaselineOffset, BooleanNumber, PresetListType, TextDecoration } from '@univerjs/core';export const DEFAULT_DOCUMENT_DATA_CN: IDocumentData = {id: 'd',- lists: DEFAULT_LIST_TEST,body: {dataStream:'零.\t 开篇\r上标和下标:HO2 5X 删除线:🙌 🎂的内容 下划线:我是下划线\r这篇文章旨在帮助新人快速熟悉开조선어univer的架构及代码,也是我过去一段时间参与到 univer 开发中的学习和总结,肯定有不够准确或者理解偏差,欢迎大家评论指正\r第壹章,会聊聊我对univer架构的理解,univer是如何拆分模块,以及模块之间的依赖关系。然后将univer放入MMV的架构模式中,分别分析下其模型层、视图层、控制器的边界和职责\r第贰章,我们先来看看 univer sheet 的模型层数据结构设计,如何区分 workbook、sheet、row、column、style 等,了解他们的包含关系,这对后面深入理解代码是有帮助的\r第叁、肆章,我将从两条控制链路来分析 univer 的代码,一条链路是 univer 启动和初始化渲染的过程。在这条链路中,是从模型层到视图层的过程。另外一条链路是 univer 响应用户事件,并且触发模型层数据变更,页面重新渲染,在这条链路中,是从视图层到模型层的过程。在这两部分,我们会涉及到大量的源码分析,在保留代码主逻辑的前提,删除了边界 case 的代码。同时在每个代码块第一行,表示该代码块所在的 TS 文件,这样便于直接阅读源码\r\n',@@ -746,10 +743,15 @@ export const DEFAULT_DOCUMENT_DATA_CN: IDocumentData = {{startIndex: 126,bullet: {- listId: 'testBullet',+ listType: PresetListType.BULLET_LIST,+ listId: 'a',nestingLevel: 0,textStyle: {fs: 20,+ bl: BooleanNumber.TRUE,+ bg: {+ rgb: 'rgb(255, 255, 0)',+ },},},paragraphStyle: {@@ -761,7 +763,8 @@ export const DEFAULT_DOCUMENT_DATA_CN: IDocumentData = {{startIndex: 218,bullet: {- listId: 'testBullet',+ listType: PresetListType.ORDER_LIST,+ listId: 'b',nestingLevel: 0,textStyle: {fs: 20,diff --git a/examples/src/data/docs/default-document-data-en.ts b/examples/src/data/docs/default-document-data-en.tsindex 3bd1f75b59..595acd5a80 100644--- a/examples/src/data/docs/default-document-data-en.ts+++ b/examples/src/data/docs/default-document-data-en.ts@@ -21,12 +21,11 @@ import {ObjectRelativeFromH,ObjectRelativeFromV,PositionedObjectLayoutType,+ PresetListType,SectionType,WrapTextType,} from '@univerjs/core';-import { DEFAULT_LIST_TEST } from './default-list';-export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {id: 'd',drawings: {@@ -77,7 +76,6 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {wrapText: WrapTextType.BOTH_SIDES,},},- lists: DEFAULT_LIST_TEST,body: {dataStream:'What’s New in the 2022 Gartner Hype Cycle for Emerging Technologies\rEmerging technologies for 2022 fit into three main themes: evolving/expanding immersive experiences, accelerated artificial intelligence automation, and optimized technologist delivery.\rThe 2022 Gartner Hype Cycle identifies 25 must-know emerging technologies designed to help enterprise architecture and technology innovation leaders: \rExpand immersive experiences\rAccelerate artificial intelligence (AI) automation\rOptimize technologist delivery \rThese technologies are expected to greatly impact business and society over the next two to 10 years, but will especially enable CIOs and IT leaders to deliver on digital business transformation. \rThree Hype Cycle themes to think about in 2022 and beyond\rThe 2022 Gartner Hype Cycle features emerging technologies and distills insights from more than 2,000 technologies into a succinct high-potential set. Most technologies have multiple use cases but enterprise architecture and technology innovation leaders should prioritize those with the greatest potential benefit for their organization. (They will also need to launch a proof-of-concept project to demonstrate the feasibility of a technology for their target use case.)\b\r\nThe benefit of these technologies is that they provide individuals with more control over their identities and data, and expand their range of experiences into virtual venues and ecosystems that can be integrated with digital currencies. These technologies also provide new ways to reach customers to strengthen or open up new revenue streams.\rDigital twin of the customer (DToC) is a dynamic virtual representation of a customer that simulates and learns to emulate and anticipate behavior. It can be used to modify and enhance the customer experience (CX) and support new digitalization efforts, products, services and opportunities. DToC will take five to 10 years until mainstream adoption but will be transformational to organizations.\rOther critical technologies in immersive experiences include the following:\rDecentralized identity (DCI) allows an entity (typically a human user) to control their own digital identity by leveraging technologies such as blockchain or other distributed ledger technologies (DLTs), along with digital wallets.\rDigital humans are interactive, AI-driven representations that have some of the characteristics, personality, knowledge and mindset of a human.\rInternal talent marketplaces match internal employees and, in some cases, a pool of contingent workers, to time-boxed projects and various work opportunities, with no recruiter involvement.\r\n',@@ -266,7 +264,8 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {{startIndex: 433,bullet: {- listId: 'testBullet',+ listType: PresetListType.ORDER_LIST,+ listId: 'b',nestingLevel: 0,textStyle: {fs: 20,@@ -282,7 +281,8 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {{startIndex: 484,bullet: {- listId: 'testBullet',+ listType: PresetListType.ORDER_LIST,+ listId: 'b',nestingLevel: 0,textStyle: {fs: 20,@@ -295,7 +295,8 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {{startIndex: 516,bullet: {- listId: 'testBullet',+ listType: PresetListType.ORDER_LIST,+ listId: 'b',nestingLevel: 0,textStyle: {fs: 20,@@ -348,7 +349,8 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {indentFirstLine: 20,},bullet: {- listId: 'unorderedTest',+ listType: PresetListType.BULLET_LIST,+ listId: 'a',nestingLevel: 0,textStyle: {fs: 20,@@ -361,7 +363,8 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {indentFirstLine: 20,},bullet: {- listId: 'unorderedTest',+ listType: PresetListType.BULLET_LIST,+ listId: 'a',nestingLevel: 0,textStyle: {fs: 20,@@ -374,7 +377,8 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {indentFirstLine: 20,},bullet: {- listId: 'unorderedTest',+ listType: PresetListType.BULLET_LIST,+ listId: 'a',nestingLevel: 0,textStyle: {fs: 20,diff --git a/examples/src/data/docs/default-document-data.ts b/examples/src/data/docs/default-document-data.tsindex baeed6c493..465dfb0dfc 100644--- a/examples/src/data/docs/default-document-data.ts+++ b/examples/src/data/docs/default-document-data.ts@@ -22,12 +22,11 @@ import {ObjectRelativeFromH,ObjectRelativeFromV,PositionedObjectLayoutType,+ PresetListType,SectionType,WrapTextType,} from '@univerjs/core';-import { DEFAULT_LIST_TEST } from './default-list';-export const DEFAULT_DOCUMENT_DATA: IDocumentData = {id: 'd',drawings: {@@ -58,7 +57,6 @@ export const DEFAULT_DOCUMENT_DATA: IDocumentData = {wrapText: WrapTextType.BOTH_SIDES,},},- lists: DEFAULT_LIST_TEST,body: {dataStream: `在“第1题”工作表中完成以下操作\b上标日期列单元格数据验证,限制只能输入日期(介于1949年1月1日至2099年1月1日)\r细化埋点上报链路和指标方案梳理目前通过每日定时任务发送报告\r自2018年首届进博会举办以来,进博会已经成为全球新品的首发地、前沿技术的首选地、创新服务的首推地。中国这十年”对外开放成就展湖北展区主要以图文、图表、数据、视频、企业展品、实物模型、光电科技等体现湖北十年开放成就、重大开放平台及产业。湖北省共计17家企业、机构的展品将在这一展区展示\r国家主席习近平以视频方式出席在上海举行的第五届中国国际进口博览会开幕式并发表题为《共创开放繁荣的美好未来》的致辞中国将推动各国各方共享深化国际合作机遇,全面深入参与世界贸易组织改革谈判\r中国男排两名现役国手彭世坤和张秉龙分别效力的三得利太阳鸟和东京大熊本轮遭遇。双方经过激战,主场作战的卫冕冠军三得利技高一筹3-2逆转击败对手,力夺第3场胜利\r\n`,textRuns: [@@ -127,7 +125,8 @@ export const DEFAULT_DOCUMENT_DATA: IDocumentData = {{startIndex: 60,bullet: {- listId: 'testBullet',+ listType: PresetListType.ORDER_LIST,+ listId: 'a',nestingLevel: 0,textStyle: {fs: 20,@@ -137,7 +136,8 @@ export const DEFAULT_DOCUMENT_DATA: IDocumentData = {{startIndex: 91,bullet: {- listId: 'testBullet',+ listType: PresetListType.ORDER_LIST,+ listId: 'a',nestingLevel: 1,textStyle: {fs: 20,@@ -147,7 +147,8 @@ export const DEFAULT_DOCUMENT_DATA: IDocumentData = {{startIndex: 234,bullet: {- listId: 'testBullet',+ listType: PresetListType.ORDER_LIST,+ listId: 'a',nestingLevel: 1,textStyle: {fs: 20,@@ -157,7 +158,8 @@ export const DEFAULT_DOCUMENT_DATA: IDocumentData = {{startIndex: 327,bullet: {- listId: 'testBullet',+ listType: PresetListType.ORDER_LIST,+ listId: 'a',nestingLevel: 1,textStyle: {fs: 20,@@ -167,7 +169,8 @@ export const DEFAULT_DOCUMENT_DATA: IDocumentData = {{startIndex: 406,bullet: {- listId: 'testBullet',+ listType: PresetListType.ORDER_LIST,+ listId: 'a',nestingLevel: 2,textStyle: {fs: 20,diff --git a/examples/src/data/sheets/default-workbook-data.ts b/examples/src/data/sheets/default-workbook-data.tsindex 94d3399cde..b5b8deac95 100644--- a/examples/src/data/sheets/default-workbook-data.ts+++ b/examples/src/data/sheets/default-workbook-data.ts@@ -19,14 +19,13 @@ import {BaselineOffset,BooleanNumber,BorderStyleTypes,- BulletAlignment,ColumnSeparatorType,- GlyphType,HorizontalAlign,LocaleType,ObjectRelativeFromH,ObjectRelativeFromV,PositionedObjectLayoutType,+ PresetListType,SectionType,SheetTypes,Tools,@@ -65,84 +64,6 @@ const richTextTestFloat: IDocumentData = {wrapText: WrapTextType.BOTH_SIDES,},},- lists: {- unorderedTest: {- listId: 'unorderedTest',- nestingLevel: [- {- bulletAlignment: BulletAlignment.START,- glyphFormat: ' %0',- textStyle: {- fs: 12,- },- startNumber: 0,- glyphSymbol: '\u25CF',- hanging: 21,- indentStart: 21,- },- {- bulletAlignment: BulletAlignment.START,- glyphFormat: ' %1',- textStyle: {- fs: 12,- },- startNumber: 0,- glyphSymbol: '\u25A0',- hanging: 21,- indentStart: 42,- },- {- bulletAlignment: BulletAlignment.START,- glyphFormat: ' %1',- textStyle: {- fs: 12,- },- startNumber: 0,- glyphSymbol: '\u25C6',- hanging: 21,- indentStart: 63,- },- ],- },- testBullet: {- listId: 'testBullet',- nestingLevel: [- {- bulletAlignment: BulletAlignment.START,- glyphFormat: ' %1.',- textStyle: {- fs: 12,- },- startNumber: 0,- glyphType: GlyphType.ROMAN,- hanging: 21,- indentStart: 21,- },- {- bulletAlignment: BulletAlignment.START,- glyphFormat: ' %1.%2)',- textStyle: {- fs: 12,- },- startNumber: 0,- glyphType: GlyphType.ROMAN,- hanging: 21,- indentStart: 42,- },- {- bulletAlignment: BulletAlignment.START,- glyphFormat: ' %1.%2.%3.',- textStyle: {- fs: 12,- },- startNumber: 0,- glyphType: GlyphType.ROMAN,- hanging: 21,- indentStart: 63,- },- ],- },- },body: {dataStream: `在“第1题”工作表中完成以下操作\b上标日期列单元格数据验证,限制只能输入日期(介于1949年1月1日至2099年1月1日)\r\n`,textRuns: [@@ -191,7 +112,8 @@ const richTextTestFloat: IDocumentData = {{startIndex: 60,bullet: {- listId: 'testBullet',+ listId: 'orderList',+ listType: PresetListType.ORDER_LIST,nestingLevel: 0,textStyle: {fs: 20,@@ -277,7 +199,8 @@ const richTextTest: IDocumentData = {{startIndex: 60,bullet: {- listId: 'testBullet',+ listId: 'orderList',+ listType: PresetListType.ORDER_LIST,nestingLevel: 0,textStyle: {fs: 20,diff --git a/examples/src/data/slides/rich-text/page3-richtext1.ts b/examples/src/data/slides/rich-text/page3-richtext1.tsindex c181360d35..28492f143e 100644--- a/examples/src/data/slides/rich-text/page3-richtext1.ts+++ b/examples/src/data/slides/rich-text/page3-richtext1.ts@@ -14,9 +14,7 @@* limitations under the License.*/-import { PageElementType } from '@univerjs/core';--import { DEFAULT_LIST_TEST } from '../../docs/default-list';+import { PageElementType, PresetListType } from '@univerjs/core';export const PAGE3_RICHTEXT_1 = {id: 'detailContent1',@@ -31,7 +29,6 @@ export const PAGE3_RICHTEXT_1 = {richText: {rich: {id: 'd',- lists: DEFAULT_LIST_TEST,body: {dataStream: `Digital Immune System\rApplied Observability\r\n`,textRuns: [@@ -54,7 +51,8 @@ export const PAGE3_RICHTEXT_1 = {{startIndex: 21,bullet: {- listId: 'testBullet',+ listType: PresetListType.ORDER_LIST,+ listId: 'orderList',nestingLevel: 0,textStyle: {fs: 20,@@ -67,7 +65,8 @@ export const PAGE3_RICHTEXT_1 = {{startIndex: 43,bullet: {- listId: 'testBullet',+ listType: PresetListType.ORDER_LIST,+ listId: 'orderList',nestingLevel: 0,textStyle: {fs: 20,diff --git a/examples/src/data/slides/rich-text/page3-richtext2.ts b/examples/src/data/slides/rich-text/page3-richtext2.tsindex a523df6812..a5878e43f2 100644--- a/examples/src/data/slides/rich-text/page3-richtext2.ts+++ b/examples/src/data/slides/rich-text/page3-richtext2.ts@@ -14,9 +14,7 @@* limitations under the License.*/-import { PageElementType } from '@univerjs/core';--import { DEFAULT_LIST_TEST } from '../../docs/default-list';+import { PageElementType, PresetListType } from '@univerjs/core';export const PAGE3_RICHTEXT_2 = {id: 'detailContent2',@@ -31,7 +29,6 @@ export const PAGE3_RICHTEXT_2 = {richText: {rich: {id: 'd',- lists: DEFAULT_LIST_TEST,body: {dataStream: `combine SaaS, PaaS and IaaS with tailored\rprovides a curated set of tools, capabilities and processes that are packaged for easy consumption by developers and end users\r\n`,textRuns: [@@ -54,7 +51,8 @@ export const PAGE3_RICHTEXT_2 = {{startIndex: 41,bullet: {- listId: 'testBullet',+ listType: PresetListType.ORDER_LIST,+ listId: 'orderList',nestingLevel: 0,textStyle: {fs: 20,@@ -67,7 +65,8 @@ export const PAGE3_RICHTEXT_2 = {{startIndex: 168,bullet: {- listId: 'testBullet',+ listType: PresetListType.ORDER_LIST,+ listId: 'orderList',nestingLevel: 0,textStyle: {fs: 20,diff --git a/examples/src/data/slides/rich-text/page3-richtext3.ts b/examples/src/data/slides/rich-text/page3-richtext3.tsindex 21e44146df..ec9400f679 100644--- a/examples/src/data/slides/rich-text/page3-richtext3.ts+++ b/examples/src/data/slides/rich-text/page3-richtext3.ts@@ -14,9 +14,7 @@* limitations under the License.*/-import { PageElementType } from '@univerjs/core';--import { DEFAULT_LIST_TEST } from '../../docs/default-list';+import { PageElementType, PresetListType } from '@univerjs/core';export const PAGE3_RICHTEXT_3 = {id: 'detailContent3',@@ -31,7 +29,6 @@ export const PAGE3_RICHTEXT_3 = {richText: {rich: {id: 'd',- lists: DEFAULT_LIST_TEST,body: {dataStream: `SuperApps are more than composite applications that aggregate services.\rAdaptive AI allows for model behavior change post-deployment by using real-time feedback\r\n`,textRuns: [@@ -54,7 +51,8 @@ export const PAGE3_RICHTEXT_3 = {{startIndex: 71,bullet: {- listId: 'testBullet',+ listType: PresetListType.ORDER_LIST,+ listId: 'orderList',nestingLevel: 0,textStyle: {fs: 20,@@ -67,7 +65,8 @@ export const PAGE3_RICHTEXT_3 = {{startIndex: 160,bullet: {- listId: 'testBullet',+ listType: PresetListType.ORDER_LIST,+ listId: 'orderList',nestingLevel: 0,textStyle: {fs: 20,diff --git a/examples/src/data/slides/rich-text/page5-richtext1.ts b/examples/src/data/slides/rich-text/page5-richtext1.tsindex 2069324d19..39a9b09f8f 100644--- a/examples/src/data/slides/rich-text/page5-richtext1.ts+++ b/examples/src/data/slides/rich-text/page5-richtext1.ts@@ -15,13 +15,10 @@*/import type { IDocumentData } from '@univerjs/core';-import { BooleanNumber, ColumnSeparatorType, SectionType } from '@univerjs/core';--import { DEFAULT_LIST_TEST } from '../../docs/default-list';+import { BooleanNumber, ColumnSeparatorType, PresetListType, SectionType } from '@univerjs/core';export const PAGE5_RICHTEXT_1: IDocumentData = {id: 'd',- lists: DEFAULT_LIST_TEST,body: {dataStream:'What’s New in the 2022 Gartner Hype Cycle for Emerging Technologies\rEmerging technologies for 2022 fit into three main themes: evolving/expanding immersive experiences, accelerated artificial intelligence automation, and optimized technologist delivery.\rThe 2022 Gartner Hype Cycle identifies 25 must-know emerging technologies designed to help enterprise architecture and technology innovation leaders: \rExpand immersive experiences\rAccelerate artificial intelligence (AI) automation\rOptimize technologist delivery \r\n',@@ -109,6 +106,7 @@ export const PAGE5_RICHTEXT_1: IDocumentData = {{startIndex: 433,bullet: {+ listType: PresetListType.BULLET_LIST,listId: 'testBullet',nestingLevel: 0,textStyle: {@@ -122,6 +120,7 @@ export const PAGE5_RICHTEXT_1: IDocumentData = {{startIndex: 484,bullet: {+ listType: PresetListType.BULLET_LIST,listId: 'testBullet',nestingLevel: 0,textStyle: {@@ -135,6 +134,7 @@ export const PAGE5_RICHTEXT_1: IDocumentData = {{startIndex: 516,bullet: {+ listType: PresetListType.BULLET_LIST,listId: 'testBullet',nestingLevel: 0,textStyle: {diff --git a/examples/src/docs/main.ts b/examples/src/docs/main.tsindex bd5b27d65d..359c134483 100644--- a/examples/src/docs/main.ts+++ b/examples/src/docs/main.ts@@ -25,6 +25,15 @@ import { DEFAULT_DOCUMENT_DATA_CN } from '../data';import { DebuggerPlugin } from '../plugins/debugger';import { locales } from './locales';+// package info+// eslint-disable-next-line no-console+console.table({+ NODE_ENV: process.env.NODE_ENV,+ GIT_COMMIT_HASH: process.env.GIT_COMMIT_HASH,+ GIT_REF_NAME: process.env.GIT_REF_NAME,+ BUILD_TIME: process.env.BUILD_TIME,+});+// univerconst univer = new Univer({theme: defaultTheme,diff --git a/packages/core/src/common/memory-cursor.ts b/packages/core/src/common/memory-cursor.tsindex bd36bdc0b6..b7386c2ffc 100644--- a/packages/core/src/common/memory-cursor.ts+++ b/packages/core/src/common/memory-cursor.ts@@ -25,4 +25,8 @@ export class MemoryCursor {moveCursor(pos: number) {this.cursor += pos;}++ moveCursorTo(pos: number) {+ this.cursor = pos;+ }}diff --git a/packages/core/src/docs/data-model/apply-utils/update-apply.ts b/packages/core/src/docs/data-model/apply-utils/update-apply.tsindex 7220adcb4f..51010cf5a8 100644--- a/packages/core/src/docs/data-model/apply-utils/update-apply.ts+++ b/packages/core/src/docs/data-model/apply-utils/update-apply.ts@@ -25,6 +25,7 @@ import type {ITable,ITextRun,} from '../../../types/interfaces';+import { PresetListType } from '..';import {deleteCustomBlocks,deleteCustomRanges,@@ -223,7 +224,9 @@ function updateParagraphs(paragraphStyle: updateParagraphStyle,bullet: updateBullet,} = updateParagraph;+let splitUpdateParagraphs: IParagraph[] = [];+for (const removeParagraph of removeParagraphs) {const {startIndex: removeStartIndex,@@ -232,12 +235,27 @@ function updateParagraphs(} = removeParagraph;let newParagraphStyle;let newBullet;+if (coverType === UpdateDocsAttributeType.COVER) {newParagraphStyle = { ...removeParagraphStyle, ...updateParagraphStyle };- newBullet = { listId: '', nestingLevel: 0, textStyle: {}, ...removeBullet, ...updateBullet };+ newBullet = {+ listId: '',+ listType: PresetListType.BULLET_LIST,+ nestingLevel: 0,+ textStyle: {},+ ...removeBullet,+ ...updateBullet,+ };} else {newParagraphStyle = { ...updateParagraphStyle, ...removeParagraphStyle };- newBullet = { listId: '', nestingLevel: 0, textStyle: {}, ...updateBullet, ...removeBullet };+ newBullet = {+ listId: '',+ listType: PresetListType.BULLET_LIST,+ nestingLevel: 0,+ textStyle: {},+ ...updateBullet,+ ...removeBullet,+ };}if (updateStartIndex === removeStartIndex) {diff --git a/packages/core/src/docs/data-model/document-data-model.ts b/packages/core/src/docs/data-model/document-data-model.tsindex e75a54f3e6..29514b49df 100644--- a/packages/core/src/docs/data-model/document-data-model.ts+++ b/packages/core/src/docs/data-model/document-data-model.ts@@ -344,12 +344,7 @@ export class DocumentDataModel extends DocumentDataModelSimple {return { dataStream: '' };}- const deletedBody = updateAttributeByDelete(body, textLength, currentIndex);-- // TODO: @JOCS, find why need to recoveryBody and how to trigger remove all the content?- // recoveryBody(body, deletedBody); // If the last paragraph in the document is deleted, restore an initial blank document.-- return deletedBody;+ return updateAttributeByDelete(body, textLength, currentIndex);}private _insertApply(insertBody: IDocumentBody, textLength: number, currentIndex: number, segmentId?: string) {diff --git a/packages/core/src/docs/data-model/index.ts b/packages/core/src/docs/data-model/index.tsindex a5e0c9f20f..4c7c266344 100644--- a/packages/core/src/docs/data-model/index.ts+++ b/packages/core/src/docs/data-model/index.ts@@ -15,4 +15,5 @@*/export * from './document-data-model';+export * from './preset-list-type';export * from './types';diff --git a/examples/src/data/docs/default-list.ts b/packages/core/src/docs/data-model/preset-list-type.tssimilarity index 83%rename from examples/src/data/docs/default-list.tsrename to packages/core/src/docs/data-model/preset-list-type.tsindex 1226043e1e..d2e7ba7401 100644--- a/examples/src/data/docs/default-list.ts+++ b/packages/core/src/docs/data-model/preset-list-type.ts@@ -14,11 +14,16 @@* limitations under the License.*/-import { BulletAlignment, GlyphType } from '@univerjs/core';+import { BulletAlignment, GlyphType } from '../../types/interfaces/i-document-data';-export const DEFAULT_LIST_TEST = {- unorderedTest: {- listId: 'unorderedTest',+export enum PresetListType {+ BULLET_LIST = 'BULLET_LIST',+ ORDER_LIST = 'ORDER_LIST',+}++export const PRESET_LIST_TYPE = {+ [PresetListType.BULLET_LIST]: {+ listType: PresetListType.BULLET_LIST,nestingLevel: [{bulletAlignment: BulletAlignment.START,@@ -55,8 +60,8 @@ export const DEFAULT_LIST_TEST = {},],},- testBullet: {- listId: 'testBullet',+ [PresetListType.ORDER_LIST]: {+ listType: PresetListType.ORDER_LIST,nestingLevel: [{bulletAlignment: BulletAlignment.START,@@ -65,7 +70,7 @@ export const DEFAULT_LIST_TEST = {fs: 12,},startNumber: 0,- glyphType: GlyphType.ROMAN,+ glyphType: GlyphType.DECIMAL,hanging: 21,indentStart: 21,},@@ -76,7 +81,7 @@ export const DEFAULT_LIST_TEST = {fs: 12,},startNumber: 0,- glyphType: GlyphType.ROMAN,+ glyphType: GlyphType.DECIMAL,hanging: 21,indentStart: 42,},@@ -87,7 +92,7 @@ export const DEFAULT_LIST_TEST = {fs: 12,},startNumber: 0,- glyphType: GlyphType.ROMAN,+ glyphType: GlyphType.DECIMAL,hanging: 21,indentStart: 63,},diff --git a/packages/core/src/types/interfaces/i-document-data.ts b/packages/core/src/types/interfaces/i-document-data.tsindex 5dd62d6fe0..9b9363b0a9 100644--- a/packages/core/src/types/interfaces/i-document-data.ts+++ b/packages/core/src/types/interfaces/i-document-data.ts@@ -66,7 +66,7 @@ export interface IFooters {* Set of lists*/export interface ILists {- [listId: string]: IListData;+ [listType: string]: IListData;}/**@@ -158,7 +158,7 @@ export interface IHeaderData {* The properties of a list which describe the look and feel of bullets belonging to paragraphs associated with a list.*/export interface IListData {- listId: string;+ listType: string;nestingLevel: INestingLevel[];}@@ -477,6 +477,7 @@ export enum ParagraphElementType {* Properties of list*/export interface IBullet {+ listType: string; // listType orderList or bulletList etc.listId: string; // listIdnestingLevel: number; // nestingLeveltextStyle: ITextStyle; // textStylediff --git a/packages/docs-ui/src/controllers/doc-ui.controller.ts b/packages/docs-ui/src/controllers/doc-ui.controller.tsindex e8ac40acfb..fd755de369 100644--- a/packages/docs-ui/src/controllers/doc-ui.controller.ts+++ b/packages/docs-ui/src/controllers/doc-ui.controller.ts@@ -21,7 +21,9 @@ import { Inject, Injector } from '@wendellhu/redi';import {BoldMenuItemFactory,+ BulletListMenuItemFactory,ItalicMenuItemFactory,+ OrderListMenuItemFactory,StrikeThroughMenuItemFactory,SubscriptMenuItemFactory,SuperscriptMenuItemFactory,@@ -54,6 +56,8 @@ export class DocUIController extends Disposable {StrikeThroughMenuItemFactory,SubscriptMenuItemFactory,SuperscriptMenuItemFactory,+ OrderListMenuItemFactory,+ BulletListMenuItemFactory,] as IMenuItemFactory[]).forEach((factory) => {this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(factory)));diff --git a/packages/docs-ui/src/controllers/menu/menu.ts b/packages/docs-ui/src/controllers/menu/menu.tsindex 8b5bfab04d..0e6e6b66f6 100644--- a/packages/docs-ui/src/controllers/menu/menu.ts+++ b/packages/docs-ui/src/controllers/menu/menu.ts@@ -15,6 +15,8 @@*/import {+ BulletListCommand,+ OrderListCommand,SetInlineFormatBoldCommand,SetInlineFormatItalicCommand,SetInlineFormatStrikethroughCommand,@@ -23,13 +25,14 @@ import {SetInlineFormatUnderlineCommand,} from '@univerjs/docs';import type { IMenuButtonItem } from '@univerjs/ui';-import { MenuItemType, MenuPosition } from '@univerjs/ui';+import { MenuGroup, MenuItemType, MenuPosition } from '@univerjs/ui';import type { IAccessor } from '@wendellhu/redi';// TODO @Dushusir: use for test, change id laterexport function BoldMenuItemFactory(accessor: IAccessor): IMenuButtonItem {return {id: SetInlineFormatBoldCommand.id,+ group: MenuGroup.TOOLBAR_FORMAT,type: MenuItemType.BUTTON,icon: 'BoldSingle',title: 'Set bold',@@ -41,6 +44,7 @@ export function BoldMenuItemFactory(accessor: IAccessor): IMenuButtonItem {export function ItalicMenuItemFactory(accessor: IAccessor): IMenuButtonItem {return {id: SetInlineFormatItalicCommand.id,+ group: MenuGroup.TOOLBAR_FORMAT,type: MenuItemType.BUTTON,icon: 'ItalicSingle',title: 'Set italic',@@ -52,6 +56,7 @@ export function ItalicMenuItemFactory(accessor: IAccessor): IMenuButtonItem {export function UnderlineMenuItemFactory(accessor: IAccessor): IMenuButtonItem {return {id: SetInlineFormatUnderlineCommand.id,+ group: MenuGroup.TOOLBAR_FORMAT,type: MenuItemType.BUTTON,icon: 'UnderlineSingle',title: 'Set underline',@@ -63,6 +68,7 @@ export function UnderlineMenuItemFactory(accessor: IAccessor): IMenuButtonItem {export function StrikeThroughMenuItemFactory(accessor: IAccessor): IMenuButtonItem {return {id: SetInlineFormatStrikethroughCommand.id,+ group: MenuGroup.TOOLBAR_FORMAT,type: MenuItemType.BUTTON,icon: 'StrikethroughSingle',title: 'Set strike through',@@ -74,6 +80,7 @@ export function StrikeThroughMenuItemFactory(accessor: IAccessor): IMenuButtonItexport function SubscriptMenuItemFactory(accessor: IAccessor): IMenuButtonItem {return {id: SetInlineFormatSubscriptCommand.id,+ group: MenuGroup.TOOLBAR_FORMAT,type: MenuItemType.BUTTON,icon: 'FontSizeReduceSingleSingle',tooltip: 'toolbar.subscript',@@ -84,9 +91,32 @@ export function SubscriptMenuItemFactory(accessor: IAccessor): IMenuButtonItem {export function SuperscriptMenuItemFactory(accessor: IAccessor): IMenuButtonItem {return {id: SetInlineFormatSuperscriptCommand.id,+ group: MenuGroup.TOOLBAR_FORMAT,type: MenuItemType.BUTTON,icon: 'FontSizeIncreaseSingle',tooltip: 'toolbar.superscript',positions: [MenuPosition.TOOLBAR_START],};}++export function OrderListMenuItemFactory(accessor: IAccessor): IMenuButtonItem {+ return {+ id: OrderListCommand.id,+ group: MenuGroup.TOOLBAR_LAYOUT,+ type: MenuItemType.BUTTON,+ icon: 'OrderSingle',+ tooltip: 'toolbar.superscript',+ positions: [MenuPosition.TOOLBAR_START],+ };+}++export function BulletListMenuItemFactory(accessor: IAccessor): IMenuButtonItem {+ return {+ id: BulletListCommand.id,+ group: MenuGroup.TOOLBAR_LAYOUT,+ type: MenuItemType.BUTTON,+ icon: 'UnorderSingle',+ tooltip: 'toolbar.superscript',+ positions: [MenuPosition.TOOLBAR_START],+ };+}diff --git a/packages/docs/src/basics/demo-data.ts b/packages/docs/src/basics/demo-data.tsdeleted file mode 100644index 4a704617f7..0000000000--- a/packages/docs/src/basics/demo-data.ts+++ /dev/null@@ -1,281 +0,0 @@-/**- * Copyright 2023-present DreamNum Inc.- *- * Licensed under the Apache License, Version 2.0 (the "License");- * you may not use this file except in compliance with the License.- * You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */--import type { IDocumentData } from '@univerjs/core';-import {- BaselineOffset,- BooleanNumber,- BulletAlignment,- ColumnSeparatorType,- GlyphType,- ObjectRelativeFromH,- ObjectRelativeFromV,- PositionedObjectLayoutType,- SectionType,- WrapTextType,-} from '@univerjs/core';--export const DOCS_DEMO_DATA: IDocumentData = {- id: 'd',- drawings: {- shapeTest1: {- objectId: 'shapeTest1',- title: 'test shape',- description: 'test shape',- objectTransform: {- size: {- width: 100,- height: 400,- },- positionH: {- relativeFrom: ObjectRelativeFromH.COLUMN,- posOffset: 100,- },- positionV: {- relativeFrom: ObjectRelativeFromV.PARAGRAPH,- posOffset: 160,- },- angle: 0,- // imageProperties: {- // contentUrl: 'https://cnbabylon.com/assets/img/agents.png',- // },- },- layoutType: PositionedObjectLayoutType.WRAP_SQUARE,- behindDoc: BooleanNumber.FALSE,- wrapText: WrapTextType.BOTH_SIDES,- },- },- lists: {- unorderedTest: {- listId: 'unorderedTest',- nestingLevel: [- {- bulletAlignment: BulletAlignment.START,- glyphFormat: ' %0',- textStyle: {- fs: 12,- },- startNumber: 0,- glyphSymbol: '\u25CF',- hanging: 21,- indentStart: 21,- },- {- bulletAlignment: BulletAlignment.START,- glyphFormat: ' %1',- textStyle: {- fs: 12,- },- startNumber: 0,- glyphSymbol: '\u25A0',- hanging: 21,- indentStart: 42,- },- {- bulletAlignment: BulletAlignment.START,- glyphFormat: ' %1',- textStyle: {- fs: 12,- },- startNumber: 0,- glyphSymbol: '\u25C6',- hanging: 21,- indentStart: 63,- },- ],- },- testBullet: {- listId: 'testBullet',- nestingLevel: [- {- bulletAlignment: BulletAlignment.START,- glyphFormat: ' %1.',- textStyle: {- fs: 12,- },- startNumber: 0,- glyphType: GlyphType.ROMAN,- hanging: 21,- indentStart: 21,- },- {- bulletAlignment: BulletAlignment.START,- glyphFormat: ' %1.%2)',- textStyle: {- fs: 12,- },- startNumber: 0,- glyphType: GlyphType.ROMAN,- hanging: 21,- indentStart: 42,- },- {- bulletAlignment: BulletAlignment.START,- glyphFormat: ' %1.%2.%3.',- textStyle: {- fs: 12,- },- startNumber: 0,- glyphType: GlyphType.ROMAN,- hanging: 21,- indentStart: 63,- },- ],- },- },- body: {- dataStream: `在“第1题”工作表中完成以下操作\b上标日期列单元格数据验证,限制只能输入日期(介于1949年1月1日至2099年1月1日)\r细化埋点上报链路和指标方案梳理目前通过每日定时任务发送报告\r自2018年首届进博会举办以来,进博会已经成为全球新品的首发地、前沿技术的首选地、创新服务的首推地。中国这十年”对外开放成就展湖北展区主要以图文、图表、数据、视频、企业展品、实物模型、光电科技等体现湖北十年开放成就、重大开放平台及产业。湖北省共计17家企业、机构的展品将在这一展区展示\r国家主席习近平以视频方式出席在上海举行的第五届中国国际进口博览会开幕式并发表题为《共创开放繁荣的美好未来》的致辞中国将推动各国各方共享深化国际合作机遇,全面深入参与世界贸易组织改革谈判\r中国男排两名现役国手彭世坤和张秉龙分别效力的三得利太阳鸟和东京大熊本轮遭遇。双方经过激战,主场作战的卫冕冠军三得利技高一筹3-2逆转击败对手,力夺第3场胜利\r\n`,- textRuns: [- {- st: 0,- ed: 15,- ts: {- fs: 12,- bg: {- rgb: 'rgb(200,0,90)',- },- cl: {- rgb: 'rgb(255,130,0)',- },- },- },- {- st: 17,- ed: 18,- ts: {- fs: 14,- bg: {- rgb: 'rgb(2,128,2)',- },- cl: {- rgb: 'rgb(0,1,55)',- },- va: BaselineOffset.SUPERSCRIPT,- },- },- {- st: 19,- ed: 60,- ts: {- fs: 14,- bg: {- rgb: 'rgb(90,128,255)',- },- cl: {- rgb: 'rgb(0,1,255)',- },- },- },-- {- st: 62,- ed: 90,- },-- {- st: 92,- ed: 233,- },-- {- st: 235,- ed: 326,- },-- {- st: 328,- ed: 405,- },- ],- paragraphs: [- {- startIndex: 60,- bullet: {- listId: 'testBullet',- nestingLevel: 0,- textStyle: {- fs: 20,- },- },- },- {- startIndex: 91,- bullet: {- listId: 'testBullet',- nestingLevel: 1,- textStyle: {- fs: 20,- },- },- },- {- startIndex: 234,- bullet: {- listId: 'testBullet',- nestingLevel: 1,- textStyle: {- fs: 20,- },- },- },- {- startIndex: 327,- bullet: {- listId: 'testBullet',- nestingLevel: 1,- textStyle: {- fs: 20,- },- },- },- {- startIndex: 406,- bullet: {- listId: 'testBullet',- nestingLevel: 2,- textStyle: {- fs: 20,- },- },- },- ],- sectionBreaks: [- {- startIndex: 407,- columnProperties: [- {- width: 200,- paddingEnd: 20,- },- ],- columnSeparatorType: ColumnSeparatorType.NONE,- sectionType: SectionType.SECTION_TYPE_UNSPECIFIED,- // textDirection: textDirectionDocument,- // contentDirection: textDirection!,- },- ],- },- documentStyle: {- pageSize: {- width: 594.3,- height: 840.51,- },- marginTop: 72,- marginBottom: 72,- marginRight: 90,- marginLeft: 90,- },-};diff --git a/packages/docs/src/commands/commands/break-line.command.ts b/packages/docs/src/commands/commands/break-line.command.tsnew file mode 100644index 0000000000..f95ef32772--- /dev/null+++ b/packages/docs/src/commands/commands/break-line.command.ts@@ -0,0 +1,100 @@+/**+ * Copyright 2023-present DreamNum Inc.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { ICommand, IParagraph } from '@univerjs/core';+import { CommandType, DataStreamTreeTokenType, ICommandService, IUniverInstanceService, Tools } from '@univerjs/core';++import { TextSelectionManagerService } from '../../services/text-selection-manager.service';+import { InsertCommand } from './core-editing.command';++function generateParagraphs(dataStream: string, prevParagraph?: IParagraph): IParagraph[] {+ 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,+ });+ }++ if (prevParagraph) {+ for (const paragraph of paragraphs) {+ if (prevParagraph.bullet) {+ paragraph.bullet = Tools.deepClone(prevParagraph.bullet);+ }++ if (prevParagraph.paragraphStyle) {+ paragraph.paragraphStyle = Tools.deepClone(prevParagraph.paragraphStyle);+ }+ }+ }++ return paragraphs;+}++export const BreakLineCommand: ICommand = {+ id: 'doc.command.break-line',++ type: CommandType.COMMAND,++ handler: async (accessor) => {+ const textSelectionManagerService = accessor.get(TextSelectionManagerService);+ const currentUniverService = accessor.get(IUniverInstanceService);+ const commandService = accessor.get(ICommandService);++ const activeRange = textSelectionManagerService.getActiveRange();++ if (activeRange == null) {+ return false;+ }++ const docDataModel = currentUniverService.getCurrentUniverDocInstance();+ const unitId = docDataModel.getUnitId();++ const { startOffset, segmentId, style } = activeRange;++ // move selection+ const textRanges = [+ {+ startOffset: startOffset + 1,+ endOffset: startOffset + 1,+ style,+ },+ ];++ const paragraphs = docDataModel.getBody()?.paragraphs ?? [];+ const prevParagraph = paragraphs.find((p) => p.startIndex >= startOffset);++ // split paragraph into two.+ const result = await commandService.executeCommand(InsertCommand.id, {+ unitId,+ body: {+ dataStream: DataStreamTreeTokenType.PARAGRAPH,+ paragraphs: generateParagraphs(DataStreamTreeTokenType.PARAGRAPH, prevParagraph),+ },+ range: activeRange,+ textRanges,+ segmentId,+ });++ return result;+ },+};diff --git a/packages/docs/src/commands/commands/clipboard.inner.command.ts b/packages/docs/src/commands/commands/clipboard.inner.command.tsindex e978979aba..29c1d9b738 100644--- a/packages/docs/src/commands/commands/clipboard.inner.command.ts+++ b/packages/docs/src/commands/commands/clipboard.inner.command.ts@@ -190,13 +190,13 @@ export const CutContentCommand: ICommand<IInnerCutCommandParams> = {const len = startOffset - memoryCursor.cursor;if (collapsed) {- doMutation.params!.mutations.push({+ doMutation.params.mutations.push({t: 'r',len,segmentId,});} else {- doMutation.params!.mutations.push(+ doMutation.params.mutations.push(...getRetainAndDeleteAndExcludeLineBreak(selection, originBody, segmentId, memoryCursor.cursor));}diff --git a/packages/docs/src/commands/commands/core-editing.command.ts b/packages/docs/src/commands/commands/core-editing.command.tsindex c9df0bba34..07bb506beb 100644--- a/packages/docs/src/commands/commands/core-editing.command.ts+++ b/packages/docs/src/commands/commands/core-editing.command.ts@@ -30,25 +30,6 @@ import { TextSelectionManagerService } from '../../services/text-selection-managimport type { IRichTextEditingMutationParams } from '../mutations/core-editing.mutation';import { RichTextEditingMutation } from '../mutations/core-editing.mutation';-// TODO: @JOCS, do not use command as event bus.-export const DeleteLeftCommand: ICommand = {- id: 'doc.command.delete-left',- type: CommandType.COMMAND,- handler: async () => true,-};--export const DeleteRightCommand: ICommand = {- id: 'doc.command.delete-right',- type: CommandType.COMMAND,- handler: async () => true,-};--export const BreakLineCommand: ICommand = {- id: 'doc.command.break-line',- type: CommandType.COMMAND,- handler: async () => true,-};-export interface IInsertCommandParams {unitId: string;body: IDocumentBody;@@ -58,7 +39,7 @@ export interface IInsertCommandParams {}/**- * The command to insert text. The changed range could be non-collapsed.+ * The command to insert text. The changed range could be non-collapsed, mainly use in line break and normal input.*/export const InsertCommand: ICommand<IInsertCommandParams> = {id: 'doc.command.insert-text',@@ -82,16 +63,16 @@ export const InsertCommand: ICommand<IInsertCommandParams> = {};if (collapsed) {- doMutation.params!.mutations.push({+ doMutation.params.mutations.push({t: 'r',len: startOffset,segmentId,});} else {- doMutation.params!.mutations.push(...getRetainAndDeleteFromReplace(range, segmentId));+ doMutation.params.mutations.push(...getRetainAndDeleteFromReplace(range, segmentId));}- doMutation.params!.mutations.push({+ doMutation.params.mutations.push({t: 'i',body,len: body.dataStream.length,@@ -149,7 +130,7 @@ export interface IDeleteCommandParams {}/**- * The command to delete text, mainly used in BACKSPACE and DELETE when collapsed is true.+ * The command to delete text, mainly used in BACKSPACE and DELETE when collapsed is true. ONLY handle collapsed range!!!*/export const DeleteCommand: ICommand<IDeleteCommandParams> = {id: 'doc.command.delete-text',@@ -163,7 +144,8 @@ export const DeleteCommand: ICommand<IDeleteCommandParams> = {const { range, segmentId, unitId, direction, textRanges, len = 1 } = params;- const { collapsed, startOffset } = range;+ const { startOffset } = range;+const doMutation: IMutationInfo<IRichTextEditingMutationParams> = {id: RichTextEditingMutation.id,params: {@@ -172,26 +154,21 @@ export const DeleteCommand: ICommand<IDeleteCommandParams> = {},};- if (collapsed) {- if (startOffset > 0) {- doMutation.params!.mutations.push({- t: 'r',- len: direction === DeleteDirection.LEFT ? startOffset - len : startOffset,- segmentId,- });- }-- doMutation.params!.mutations.push({- t: 'd',- len,- line: 0,+ if (startOffset > 0) {+ doMutation.params.mutations.push({+ t: 'r',+ len: direction === DeleteDirection.LEFT ? startOffset - len : startOffset,segmentId,});- } else {- // Already handle in CutContentCommand, these code bellow will delete later?- doMutation.params!.mutations.push(...getRetainAndDeleteFromReplace(range, segmentId));}+ doMutation.params.mutations.push({+ t: 'd',+ len,+ line: 0,+ segmentId,+ });+const result = commandService.syncExecuteCommand<IRichTextEditingMutationParams,IRichTextEditingMutationParams@@ -259,13 +236,13 @@ export const UpdateCommand: ICommand<IUpdateCommandParams> = {const { startOffset, endOffset } = range;- doMutation.params!.mutations.push({+ doMutation.params.mutations.push({t: 'r',len: startOffset,segmentId,});- doMutation.params!.mutations.push({+ doMutation.params.mutations.push({t: 'r',body: updateBody,len: endOffset - startOffset,diff --git a/packages/docs/src/commands/commands/delete.command.ts b/packages/docs/src/commands/commands/delete.command.tsnew file mode 100644index 0000000000..0c93bed359--- /dev/null+++ b/packages/docs/src/commands/commands/delete.command.ts@@ -0,0 +1,442 @@+/**+ * Copyright 2023-present DreamNum Inc.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { ICommand, IDocumentBody, IMutationInfo, IParagraph, ITextRun } from '@univerjs/core';+import {+ CommandType,+ ICommandService,+ IUndoRedoService,+ IUniverInstanceService,+ UpdateDocsAttributeType,+} from '@univerjs/core';+import type { IActiveTextRange, TextRange } from '@univerjs/engine-render';+import { getParagraphBySpan, hasListSpan, isFirstSpan, isIndentBySpan } from '@univerjs/engine-render';++import { DocSkeletonManagerService } from '../../services/doc-skeleton-manager.service';+import type { ITextActiveRange } from '../../services/text-selection-manager.service';+import { TextSelectionManagerService } from '../../services/text-selection-manager.service';+import type { IRichTextEditingMutationParams } from '../mutations/core-editing.mutation';+import { RichTextEditingMutation } from '../mutations/core-editing.mutation';+import { CutContentCommand } from './clipboard.inner.command';+import { DeleteCommand, DeleteDirection, UpdateCommand } from './core-editing.command';++// Handle BACKSPACE.+export const DeleteLeftCommand: ICommand = {+ id: 'doc.command.delete-left',++ type: CommandType.COMMAND,++ handler: async (accessor) => {+ const textSelectionManagerService = accessor.get(TextSelectionManagerService);+ const docSkeletonManagerService = accessor.get(DocSkeletonManagerService);+ const currentUniverService = accessor.get(IUniverInstanceService);+ const commandService = accessor.get(ICommandService);++ const activeRange = textSelectionManagerService.getActiveRange();+ const ranges = textSelectionManagerService.getSelections();+ const skeleton = docSkeletonManagerService.getCurrent()?.skeleton;++ let result;++ if (activeRange == null || skeleton == null || ranges == null) {+ return false;+ }++ const docDataModel = currentUniverService.getCurrentUniverDocInstance();++ const { startOffset, collapsed, segmentId, style } = activeRange;++ // No need to delete when the cursor is at the first position of the first paragraph.+ if (startOffset === 0 && collapsed) {+ return true;+ }++ const preSpan = skeleton.findNodeByCharIndex(startOffset);++ // is in bullet list?+ const preIsBullet = hasListSpan(preSpan);+ // is in indented paragraph?+ const preIsIndent = isIndentBySpan(preSpan, docDataModel.body);++ let cursor = startOffset;++ // Get the deleted span.+ const span = skeleton.findNodeByCharIndex(startOffset - 1)!;++ const isUpdateParagraph =+ isFirstSpan(preSpan) && span !== preSpan && (preIsBullet === true || preIsIndent === true);++ if (isUpdateParagraph) {+ const paragraph = getParagraphBySpan(preSpan, docDataModel.body);++ if (paragraph == null) {+ return false;+ }++ const paragraphIndex = paragraph?.startIndex;++ const updateParagraph: IParagraph = { startIndex: 0 };++ const paragraphStyle = paragraph.paragraphStyle;++ if (preIsBullet === true) {+ const paragraphStyle = paragraph.paragraphStyle;++ if (paragraphStyle) {+ updateParagraph.paragraphStyle = paragraphStyle;+ }+ } else if (preIsIndent === true) {+ const bullet = paragraph.bullet;++ if (bullet) {+ updateParagraph.bullet = bullet;+ }++ if (paragraphStyle != null) {+ updateParagraph.paragraphStyle = { ...paragraphStyle };+ delete updateParagraph.paragraphStyle.hanging;+ delete updateParagraph.paragraphStyle.indentStart;+ }+ }++ const textRanges = [+ {+ startOffset: cursor,+ endOffset: cursor,+ style,+ },+ ];++ result = await commandService.executeCommand(UpdateCommand.id, {+ unitId: docDataModel.getUnitId(),+ updateBody: {+ dataStream: '',+ paragraphs: [{ ...updateParagraph }],+ },+ range: {+ startOffset: paragraphIndex,+ endOffset: paragraphIndex + 1,+ },+ textRanges,+ coverType: UpdateDocsAttributeType.REPLACE,+ segmentId,+ });+ } else {+ if (collapsed === true) {+ if (span.content === '\r') {+ result = await commandService.executeCommand(MergeTwoParagraphCommand.id, {+ direction: DeleteDirection.LEFT,+ range: activeRange,+ });+ } else {+ cursor -= span.count;++ const textRanges = [+ {+ startOffset: cursor,+ endOffset: cursor,+ style,+ },+ ];+ result = await commandService.executeCommand(DeleteCommand.id, {+ unitId: docDataModel.getUnitId(),+ range: activeRange,+ segmentId,+ direction: DeleteDirection.LEFT,+ len: span.count,+ textRanges,+ });+ }+ } else {+ const textRanges = getTextRangesWhenDelete(activeRange, ranges);+ // If the selection is not closed, the effect of Delete and+ // BACKSPACE is the same as CUT, so the CUT command is executed.+ result = await commandService.executeCommand(CutContentCommand.id, {+ segmentId,+ textRanges,+ });+ }+ }++ return result;+ },+};++// handle Delete key+export const DeleteRightCommand: ICommand = {+ id: 'doc.command.delete-right',++ type: CommandType.COMMAND,++ handler: async (accessor) => {+ const textSelectionManagerService = accessor.get(TextSelectionManagerService);+ const docSkeletonManagerService = accessor.get(DocSkeletonManagerService);+ const currentUniverService = accessor.get(IUniverInstanceService);+ const commandService = accessor.get(ICommandService);++ const activeRange = textSelectionManagerService.getActiveRange();+ const ranges = textSelectionManagerService.getSelections();++ const skeleton = docSkeletonManagerService.getCurrent()?.skeleton;++ let result;++ if (activeRange == null || skeleton == null || ranges == null) {+ return false;+ }++ const docDataModel = currentUniverService.getCurrentUniverDocInstance();++ const { startOffset, collapsed, segmentId, style } = activeRange;++ // No need to delete when the cursor is at the last position of the last paragraph.+ if (startOffset === docDataModel.getBody()!.dataStream.length - 2 && collapsed) {+ return true;+ }++ if (collapsed === true) {+ const needDeleteSpan = skeleton.findNodeByCharIndex(startOffset)!;++ if (needDeleteSpan.content === '\r') {+ result = await commandService.executeCommand(MergeTwoParagraphCommand.id, {+ direction: DeleteDirection.RIGHT,+ range: activeRange,+ });+ } else {+ const textRanges = [+ {+ startOffset,+ endOffset: startOffset,+ style,+ },+ ];++ result = await commandService.executeCommand(DeleteCommand.id, {+ unitId: docDataModel.getUnitId(),+ range: activeRange,+ segmentId,+ direction: DeleteDirection.RIGHT,+ textRanges,+ len: needDeleteSpan.count,+ });+ }+ } else {+ const textRanges = getTextRangesWhenDelete(activeRange, ranges);++ // If the selection is not closed, the effect of Delete and+ // BACKSPACE is the same as CUT, so the CUT command is executed.+ result = await commandService.executeCommand(CutContentCommand.id, {+ segmentId,+ textRanges,+ });+ }++ return result;+ },+};++interface IMergeTwoParagraphParams {+ direction: DeleteDirection;+ range: IActiveTextRange;+}++export const MergeTwoParagraphCommand: ICommand<IMergeTwoParagraphParams> = {+ id: 'doc.command.merge-two-paragraph',++ type: CommandType.COMMAND,++ handler: async (accessor, params: IMergeTwoParagraphParams) => {+ const textSelectionManagerService = accessor.get(TextSelectionManagerService);+ const currentUniverService = accessor.get(IUniverInstanceService);+ const commandService = accessor.get(ICommandService);+ const undoRedoService = accessor.get(IUndoRedoService);++ const { direction, range } = params;++ const activeRange = textSelectionManagerService.getActiveRange();+ const ranges = textSelectionManagerService.getSelections();++ if (activeRange == null || ranges == null) {+ return false;+ }++ const docDataModel = currentUniverService.getCurrentUniverDocInstance();++ const { startOffset, collapsed, segmentId, style } = activeRange;++ if (!collapsed) {+ return false;+ }++ const startIndex = direction === DeleteDirection.LEFT ? startOffset : startOffset + 1;+ const endIndex = docDataModel.getBody()?.paragraphs?.find((p) => p.startIndex >= startIndex)?.startIndex!;+ const body = getParagraphBody(docDataModel.getBody()!, startIndex, endIndex);++ const cursor = direction === DeleteDirection.LEFT ? startOffset - 1 : startOffset;++ const unitId = docDataModel.getUnitId();++ const textRanges = [+ {+ startOffset: cursor,+ endOffset: cursor,+ style,+ },+ ];++ const doMutation: IMutationInfo<IRichTextEditingMutationParams> = {+ id: RichTextEditingMutation.id,+ params: {+ unitId,+ mutations: [],+ },+ };++ doMutation.params.mutations.push({+ t: 'r',+ len: direction === DeleteDirection.LEFT ? startOffset - 1 : startOffset,+ segmentId,+ });++ if (body.dataStream.length) {+ doMutation.params.mutations.push({+ t: 'i',+ body,+ len: body.dataStream.length,+ line: 0,+ segmentId,+ });+ }++ doMutation.params.mutations.push({+ t: 'r',+ len: 1,+ segmentId,+ });++ doMutation.params.mutations.push({+ t: 'd',+ len: endIndex + 1 - startIndex,+ line: 0,+ segmentId,+ });++ const result = commandService.syncExecuteCommand<+ IRichTextEditingMutationParams,+ IRichTextEditingMutationParams+ >(doMutation.id, doMutation.params);++ textSelectionManagerService.replaceTextRanges(textRanges);++ if (result) {+ undoRedoService.pushUndoRedo({+ unitID: unitId,+ undoMutations: [{ id: RichTextEditingMutation.id, params: result }],+ redoMutations: [{ id: RichTextEditingMutation.id, params: doMutation.params }],+ undo() {+ commandService.syncExecuteCommand(RichTextEditingMutation.id, result);++ textSelectionManagerService.replaceTextRanges([range]);++ return true;+ },+ redo() {+ commandService.syncExecuteCommand(RichTextEditingMutation.id, doMutation.params);++ textSelectionManagerService.replaceTextRanges(textRanges);++ return true;+ },+ });++ return true;+ }++ return false;+ },+};++function getParagraphBody(body: IDocumentBody, startIndex: number, endIndex: number): IDocumentBody {+ const { textRuns: originTextRuns } = body;+ const dataStream = body.dataStream.substring(startIndex, endIndex);++ if (originTextRuns == null) {+ return {+ dataStream,+ };+ }++ const textRuns: ITextRun[] = [];++ for (const textRun of originTextRuns) {+ const { st, ed } = textRun;+ if (ed <= startIndex || st >= endIndex) {+ continue;+ }++ if (st < startIndex) {+ textRuns.push({+ ...textRun,+ st: 0,+ ed: ed - startIndex,+ });+ } else if (ed > endIndex) {+ textRuns.push({+ ...textRun,+ st: st - startIndex,+ ed: endIndex - startIndex,+ });+ } else {+ textRuns.push({+ ...textRun,+ st: st - startIndex,+ ed: ed - startIndex,+ });+ }+ }++ return {+ dataStream,+ textRuns,+ };+}++// get cursor position when BACKSPACE/DELETE excuse the CutContentCommand.+function getTextRangesWhenDelete(activeRange: ITextActiveRange, ranges: readonly TextRange[]) {+ let cursor = activeRange.endOffset;++ for (const range of ranges) {+ const { startOffset, endOffset } = range;++ if (startOffset == null || endOffset == null) {+ continue;+ }++ if (endOffset <= activeRange.endOffset) {+ cursor -= endOffset - startOffset;+ }+ }++ const textRanges = [+ {+ startOffset: cursor,+ endOffset: cursor,+ style: activeRange.style,+ },+ ];++ return textRanges;+}diff --git a/packages/docs/src/commands/commands/list.command.ts b/packages/docs/src/commands/commands/list.command.tsnew file mode 100644index 0000000000..65f2e1bac5--- /dev/null+++ b/packages/docs/src/commands/commands/list.command.ts@@ -0,0 +1,232 @@+/**+ * Copyright 2023-present DreamNum Inc.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { ICommand, IMutationInfo, IParagraph } from '@univerjs/core';+import {+ CommandType,+ ICommandService,+ IUndoRedoService,+ IUniverInstanceService,+ MemoryCursor,+ PresetListType,+ Tools,+ UpdateDocsAttributeType,+} from '@univerjs/core';+import type { IActiveTextRange } from '@univerjs/engine-render';++import { TextSelectionManagerService } from '../../services/text-selection-manager.service';+import type { IRichTextEditingMutationParams } from '../mutations/core-editing.mutation';+import { RichTextEditingMutation } from '../mutations/core-editing.mutation';++interface IBulletListCommandParams {}++export const BulletListCommand: ICommand<IBulletListCommandParams> = {+ id: 'doc.command.bullet-list',++ type: CommandType.COMMAND,++ handler: (accessor) => {+ const commandService = accessor.get(ICommandService);++ return commandService.syncExecuteCommand(ListOperationCommand.id, {+ listType: PresetListType.BULLET_LIST,+ });+ },+};++interface IOrderListCommandParams {}++export const OrderListCommand: ICommand<IOrderListCommandParams> = {+ id: 'doc.command.order-list',++ type: CommandType.COMMAND,++ handler: (accessor) => {+ const commandService = accessor.get(ICommandService);++ return commandService.syncExecuteCommand(ListOperationCommand.id, {+ listType: PresetListType.ORDER_LIST,+ });+ },+};++interface IListOperationCommandParams {+ listType: PresetListType;+}++export const ListOperationCommand: ICommand<IListOperationCommandParams> = {+ id: 'doc.command.list-operation',++ type: CommandType.COMMAND,++ handler: (accessor, params: IListOperationCommandParams) => {+ const textSelectionManagerService = accessor.get(TextSelectionManagerService);+ const currentUniverService = accessor.get(IUniverInstanceService);+ const commandService = accessor.get(ICommandService);+ const undoRedoService = accessor.get(IUndoRedoService);++ const { listType } = params;++ const dataModel = currentUniverService.getCurrentUniverDocInstance();++ const activeRange = textSelectionManagerService.getActiveRange();+ const paragraphs = dataModel.getBody()?.paragraphs;++ if (activeRange == null || paragraphs == null) {+ return false;+ }++ const currentParagraphs = getParagraphsInRange(activeRange, paragraphs);++ const { segmentId } = activeRange;++ const unitId = dataModel.getUnitId();++ const isAlreadyOrdered = currentParagraphs.every((paragraph) => paragraph.bullet?.listType === listType);++ const ID_LENGTH = 6;++ let listId = Tools.generateRandomId(ID_LENGTH);++ if (currentParagraphs.length === 1) {+ const curIndex = paragraphs.indexOf(currentParagraphs[0]);+ const prevParagraph = paragraphs[curIndex - 1];+ const nextParagraph = paragraphs[curIndex + 1];++ if (prevParagraph && prevParagraph.bullet && prevParagraph.bullet.listType === listType) {+ listId = prevParagraph.bullet.listId;+ } else if (nextParagraph && nextParagraph.bullet && nextParagraph.bullet.listType === listType) {+ listId = nextParagraph.bullet.listId;+ }+ }++ const doMutation: IMutationInfo<IRichTextEditingMutationParams> = {+ id: RichTextEditingMutation.id,+ params: {+ unitId,+ mutations: [],+ },+ };++ const memoryCursor = new MemoryCursor();++ memoryCursor.reset();++ for (const paragraph of currentParagraphs) {+ const { startIndex } = paragraph;++ doMutation.params.mutations.push({+ t: 'r',+ len: startIndex - memoryCursor.cursor,+ segmentId,+ });++ // See: univer/packages/engine-render/src/components/docs/block/paragraph/layout-ruler.ts line:802 comments.+ const paragraphStyle = {+ ...paragraph.paragraphStyle,+ hanging: undefined,+ indentStart: undefined,+ };++ doMutation.params.mutations.push({+ t: 'r',+ len: 1,+ body: {+ dataStream: '',+ paragraphs: [+ isAlreadyOrdered+ ? {+ paragraphStyle,+ startIndex: 0,+ }+ : {+ ...paragraph,+ startIndex: 0,+ bullet: {+ ...(paragraph.bullet ?? {+ nestingLevel: 0,+ textStyle: {+ fs: 20,+ },+ }),+ listType,+ listId,+ },+ },+ ],+ },+ segmentId,+ coverType: UpdateDocsAttributeType.REPLACE,+ });++ memoryCursor.moveCursorTo(startIndex + 1);+ }++ const result = commandService.syncExecuteCommand<+ IRichTextEditingMutationParams,+ IRichTextEditingMutationParams+ >(doMutation.id, doMutation.params);++ textSelectionManagerService.refreshSelection();++ if (result) {+ undoRedoService.pushUndoRedo({+ unitID: unitId,+ undoMutations: [{ id: RichTextEditingMutation.id, params: result }],+ redoMutations: [{ id: RichTextEditingMutation.id, params: doMutation.params }],+ undo() {+ commandService.syncExecuteCommand(RichTextEditingMutation.id, result);++ textSelectionManagerService.refreshSelection();++ return true;+ },+ redo() {+ commandService.syncExecuteCommand(RichTextEditingMutation.id, doMutation.params);++ textSelectionManagerService.refreshSelection();++ return true;+ },+ });++ return true;+ }++ return true;+ },+};++function getParagraphsInRange(activeRange: IActiveTextRange, paragraphs: IParagraph[]) {+ const { startOffset, endOffset } = activeRange;+ const results: IParagraph[] = [];++ let start = 0;++ for (const paragraph of paragraphs) {+ const { startIndex } = paragraph;++ if ((startOffset > start && startOffset <= startIndex) || (endOffset > start && endOffset <= startIndex)) {+ results.push(paragraph);+ } else if (startIndex >= startOffset && startIndex <= endOffset) {+ results.push(paragraph);+ }++ start = startIndex;+ }++ return results;+}diff --git a/packages/docs/src/commands/mutations/core-editing.mutation.ts b/packages/docs/src/commands/mutations/core-editing.mutation.tsindex 0044abd449..176fc733f9 100644--- a/packages/docs/src/commands/mutations/core-editing.mutation.ts+++ b/packages/docs/src/commands/mutations/core-editing.mutation.ts@@ -14,13 +14,7 @@* limitations under the License.*/-import {- CommandType,- type DocMutationParams,- type IMutation,- IUniverInstanceService,- MemoryCursor,-} from '@univerjs/core';+import { CommandType, type DocMutationParams, type IMutation, IUniverInstanceService } from '@univerjs/core';import { DocViewModelManagerService } from '../../services/doc-view-model-manager.service';@@ -35,7 +29,9 @@ export interface IRichTextEditingMutationParams {*/export const RichTextEditingMutation: IMutation<IRichTextEditingMutationParams, IRichTextEditingMutationParams> = {id: 'doc.mutation.rich-text-editing',+type: CommandType.MUTATION,+handler: (accessor, params) => {const { unitId, mutations } = params;const univerInstanceService = accessor.get(IUniverInstanceService);@@ -44,48 +40,19 @@ export const RichTextEditingMutation: IMutation<IRichTextEditingMutationParams,const docViewModelManagerService = accessor.get(DocViewModelManagerService);const documentViewModel = docViewModelManagerService.getViewModel(unitId);- if (!documentDataModel) {- throw new Error(`DocumentDataModel not found for unitId: ${unitId}`);+ if (documentDataModel == null || documentViewModel == null) {+ throw new Error(`DocumentDataModel or documentViewModel not found for unitId: ${unitId}`);}- // Step 1: Update Doc View Model.- const memoryCursor = new MemoryCursor();-- memoryCursor.reset();-- mutations.forEach((mutation) => {- const { segmentId, len } = mutation;- const segmentViewModel = documentViewModel?.getSelfOrHeaderFooterViewModel(segmentId)!;-- if (mutation.t === 'r') {- const { len } = mutation;-- memoryCursor.moveCursor(len);- } else if (mutation.t === 'i') {- const { body } = mutation;-- if (body.dataStream.length > 1 && /\r/.test(body.dataStream)) {- // TODO: @JOCS, The DocumentViewModel needs to be rewritten to better support the- // large area of updates that are brought about by the paste, abstract the- // methods associated with the DocumentViewModel insertion, and support atomic operations- const segmentDocumentDataModel = documentDataModel.getSelfOrHeaderFooterModel(segmentId);-- segmentViewModel.reset(segmentDocumentDataModel);- } else {- segmentViewModel.insert(body, memoryCursor.cursor);- }+ // Step 1: Update Doc Data Model.+ const undoMutations = documentDataModel.apply(mutations);- // this._insertApply(body!, len, memoryCursor.cursor, segmentId);- memoryCursor.moveCursor(len);- } else if (mutation.t === 'd') {- segmentViewModel.delete(memoryCursor.cursor, len);- } else {- throw new Error(`Unknown mutation type for mutation: ${mutation}.`);- }- });+ // Step 2: Update Doc View Model.+ const segmentId = mutations[0].segmentId;+ const segmentDocumentDataModel = documentDataModel.getSelfOrHeaderFooterModel(segmentId);+ const segmentViewModel = documentViewModel.getSelfOrHeaderFooterViewModel(segmentId);- // Step 2: Update Doc Data Model.- const undoMutations = documentDataModel.apply(mutations);+ segmentViewModel.reset(segmentDocumentDataModel);return {unitId,diff --git a/packages/docs/src/controllers/delete.controller.ts b/packages/docs/src/controllers/delete.controller.tsdeleted file mode 100644index 9017625a5d..0000000000--- a/packages/docs/src/controllers/delete.controller.ts+++ /dev/null@@ -1,291 +0,0 @@-/**- * Copyright 2023-present DreamNum Inc.- *- * Licensed under the Apache License, Version 2.0 (the "License");- * you may not use this file except in compliance with the License.- * You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */--import type { ICommandInfo, IParagraph } from '@univerjs/core';-import {- Disposable,- ICommandService,- IUniverInstanceService,- LifecycleStages,- OnLifecycle,- UpdateDocsAttributeType,-} from '@univerjs/core';-import { getParagraphBySpan, hasListSpan, isFirstSpan, isIndentBySpan, isSameLine } from '@univerjs/engine-render';-import { Inject } from '@wendellhu/redi';--import { CutContentCommand } from '../commands/commands/clipboard.inner.command';-import {- DeleteCommand,- DeleteDirection,- DeleteLeftCommand,- DeleteRightCommand,- UpdateCommand,-} from '../commands/commands/core-editing.command';-import { DocSkeletonManagerService } from '../services/doc-skeleton-manager.service';-import { TextSelectionManagerService } from '../services/text-selection-manager.service';--@OnLifecycle(LifecycleStages.Rendered, DeleteController)-export class DeleteController extends Disposable {- constructor(- @Inject(DocSkeletonManagerService) private readonly _docSkeletonManagerService: DocSkeletonManagerService,- @IUniverInstanceService private readonly _currentUniverService: IUniverInstanceService,- @ICommandService private readonly _commandService: ICommandService,- @Inject(TextSelectionManagerService) private readonly _textSelectionManagerService: TextSelectionManagerService- ) {- super();-- this._initialize();-- this._commandExecutedListener();- }-- private _initialize() {}-- private _commandExecutedListener() {- const updateCommandList = [DeleteLeftCommand.id, DeleteRightCommand.id];-- this.disposeWithMe(- this._commandService.onCommandExecuted((command: ICommandInfo) => {- if (!updateCommandList.includes(command.id)) {- return;- }-- switch (command.id) {- case DeleteLeftCommand.id:- this._handleDeleteLeft();- break;- case DeleteRightCommand.id:- this._handleDeleteRight();- break;- default:- throw new Error('Unknown command');- }- })- );- }-- // Use BACKSPACE to delete left.- private _handleDeleteLeft() {- const activeRange = this._textSelectionManagerService.getActiveRange();-- const skeleton = this._docSkeletonManagerService.getCurrent()?.skeleton;-- if (activeRange == null || skeleton == null) {- return;- }-- const docDataModel = this._currentUniverService.getCurrentUniverDocInstance();-- const { startOffset, collapsed, segmentId, style } = activeRange;-- // No need to delete when the cursor is at the first position of the first paragraph.- if (startOffset === 0 && collapsed) {- return;- }-- const preSpan = skeleton.findNodeByCharIndex(startOffset);-- // is in bullet list?- const preIsBullet = hasListSpan(preSpan);- // is in indented paragraph?- const preIsIndent = isIndentBySpan(preSpan, docDataModel.body);-- let cursor = startOffset;-- // Get the deleted span.- const span = skeleton.findNodeByCharIndex(startOffset - 1)!;-- const isUpdateParagraph =- isFirstSpan(preSpan) && span !== preSpan && (preIsBullet === true || preIsIndent === true);-- if (isUpdateParagraph) {- const paragraph = getParagraphBySpan(preSpan, docDataModel.body);-- if (paragraph == null) {- return;- }-- const paragraphIndex = paragraph?.startIndex;-- const updateParagraph: IParagraph = { startIndex: 0 };-- const paragraphStyle = paragraph.paragraphStyle;-- if (preIsBullet === true) {- const paragraphStyle = paragraph.paragraphStyle;-- if (paragraphStyle) {- updateParagraph.paragraphStyle = paragraphStyle;- }- } else if (preIsIndent === true) {- const bullet = paragraph.bullet;-- if (bullet) {- updateParagraph.bullet = bullet;- }-- if (paragraphStyle != null) {- updateParagraph.paragraphStyle = { ...paragraphStyle };- delete updateParagraph.paragraphStyle.hanging;- delete updateParagraph.paragraphStyle.indentStart;- }- }-- const textRanges = [- {- startOffset: cursor,- endOffset: cursor,- style,- },- ];-- this._commandService.executeCommand(UpdateCommand.id, {- unitId: docDataModel.getUnitId(),- updateBody: {- dataStream: '',- paragraphs: [{ ...updateParagraph }],- },- range: {- startOffset: paragraphIndex,- endOffset: paragraphIndex + 1,- },- textRanges,- coverType: UpdateDocsAttributeType.REPLACE,- segmentId,- });- } else {- const { endNodePosition } = activeRange;-- if (endNodePosition != null) {- const endSpan = skeleton.findSpanByPosition(endNodePosition);- if (hasListSpan(endSpan) && !isSameLine(preSpan, endSpan)) {- activeRange.endOffset -= 1;- }- }-- if (collapsed === true) {- cursor -= span.count;-- const textRanges = [- {- startOffset: cursor,- endOffset: cursor,- style,- },- ];- this._commandService.executeCommand(DeleteCommand.id, {- unitId: docDataModel.getUnitId(),- range: activeRange,- segmentId,- direction: DeleteDirection.LEFT,- len: span.count,- textRanges,- });- } else {- const textRanges = this._getTextRangesWhenDelete();- // If the selection is not closed, the effect of Delete and- // BACKSPACE is the same as CUT, so the CUT command is executed.- this._commandService.executeCommand(CutContentCommand.id, {- segmentId,- textRanges,- });- }- }-- skeleton?.calculate();- }-- // Use DELETE to delete right.- private _handleDeleteRight() {- const activeRange = this._textSelectionManagerService.getActiveRange();-- const skeleton = this._docSkeletonManagerService.getCurrent()?.skeleton;-- if (activeRange == null || skeleton == null) {- return;- }-- const docDataModel = this._currentUniverService.getCurrentUniverDocInstance();-- const { startOffset, collapsed, segmentId, style } = activeRange;-- // No need to delete when the cursor is at the last position of the last paragraph.- if (startOffset === docDataModel.getBody()!.dataStream.length - 2 && collapsed) {- return;- }-- if (collapsed === true) {- const textRanges = [- {- startOffset,- endOffset: startOffset,- style,- },- ];-- const needDeleteSpan = skeleton.findNodeByCharIndex(startOffset)!;-- this._commandService.executeCommand(DeleteCommand.id, {- unitId: docDataModel.getUnitId(),- range: activeRange,- segmentId,- direction: DeleteDirection.RIGHT,- textRanges,- len: needDeleteSpan.count,- });- } else {- const textRanges = this._getTextRangesWhenDelete();- // If the selection is not closed, the effect of Delete and- // BACKSPACE is the same as CUT, so the CUT command is executed.- this._commandService.executeCommand(CutContentCommand.id, {- segmentId,- textRanges,- });- }-- skeleton?.calculate();- }-- // get cursor position when BACKSPACE/DELETE excuse the CutContentCommand.- private _getTextRangesWhenDelete() {- const activeRange = this._textSelectionManagerService.getActiveRange()!;- const ranges = this._textSelectionManagerService.getSelections()!;-- let cursor = activeRange.endOffset;-- for (const range of ranges) {- const { startOffset, endOffset } = range;-- if (startOffset == null || endOffset == null) {- continue;- }-- if (endOffset <= activeRange.endOffset) {- cursor -= endOffset - startOffset;- }- }-- const textRanges = [- {- startOffset: cursor,- endOffset: cursor,- style: activeRange.style,- },- ];-- return textRanges;- }-}diff --git a/packages/docs/src/controllers/line-break-input.controller.ts b/packages/docs/src/controllers/line-break-input.controller.tsdeleted file mode 100644index 58cabc404b..0000000000--- a/packages/docs/src/controllers/line-break-input.controller.ts+++ /dev/null@@ -1,131 +0,0 @@-/**- * Copyright 2023-present DreamNum Inc.- *- * Licensed under the Apache License, Version 2.0 (the "License");- * you may not use this file except in compliance with the License.- * You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */--import type { ICommandInfo, IParagraph, Nullable } from '@univerjs/core';-import {- DataStreamTreeTokenType,- Disposable,- ICommandService,- IUniverInstanceService,- LifecycleStages,- OnLifecycle,-} from '@univerjs/core';-import { IRenderManagerService } from '@univerjs/engine-render';-import { Inject } from '@wendellhu/redi';-import type { Subscription } from 'rxjs';--import { getDocObject } from '../basics/component-tools';-import { BreakLineCommand, InsertCommand } from '../commands/commands/core-editing.command';-import { 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>;-- constructor(- @Inject(DocSkeletonManagerService) private readonly _docSkeletonManagerService: DocSkeletonManagerService,- @IUniverInstanceService private readonly _currentUniverService: IUniverInstanceService,- @IRenderManagerService private readonly _renderManagerService: IRenderManagerService,- @Inject(TextSelectionManagerService) private readonly _textSelectionManagerService: TextSelectionManagerService,- @ICommandService private readonly _commandService: ICommandService- ) {- super();-- this._initialize();-- this._commandExecutedListener();- }-- override dispose(): void {- this._onInputSubscription?.unsubscribe();- }-- private _initialize() {}-- private _commandExecutedListener() {- const updateCommandList = [BreakLineCommand.id];-- this.disposeWithMe(- this._commandService.onCommandExecuted((command: ICommandInfo) => {- if (!updateCommandList.includes(command.id)) {- return;- }-- this._handleBreakLine();- })- );- }-- private _handleBreakLine() {- const skeleton = this._docSkeletonManagerService.getCurrent()?.skeleton;-- const activeRange = this._textSelectionManagerService.getActiveRange();-- if (activeRange == null || skeleton == null) {- return;- }-- const docDataModel = this._currentUniverService.getCurrentUniverDocInstance();- const unitId = docDataModel.getUnitId();-- const { startOffset, segmentId, style } = activeRange;- // move selection- const textRanges = [- {- startOffset: startOffset + 1,- endOffset: startOffset + 1,- style,- },- ];-- // split paragraph- this._commandService.executeCommand(InsertCommand.id, {- unitId,- body: {- dataStream: DataStreamTreeTokenType.PARAGRAPH,- paragraphs: generateParagraphs(DataStreamTreeTokenType.PARAGRAPH),- },- range: activeRange,- textRanges,- segmentId,- });-- skeleton?.calculate();- }-- private _getDocObject() {- return getDocObject(this._currentUniverService, this._renderManagerService);- }-}diff --git a/packages/docs/src/controllers/normal-input.controller.ts b/packages/docs/src/controllers/normal-input.controller.tsindex f6da9a084e..3277098b50 100644--- a/packages/docs/src/controllers/normal-input.controller.ts+++ b/packages/docs/src/controllers/normal-input.controller.ts@@ -58,6 +58,8 @@ export class NormalInputController extends Disposable {const documentModel = this._currentUniverService.getCurrentUniverDocInstance();+ const unitId = documentModel.getUnitId();+const { event, content = '', activeRange } = config;const e = event as InputEvent;@@ -85,7 +87,7 @@ export class NormalInputController extends Disposable {];await this._commandService.executeCommand(InsertCommand.id, {- unitId: documentModel.getUnitId(),+ unitId,body: {dataStream: content,},@@ -93,8 +95,6 @@ export class NormalInputController extends Disposable {textRanges,segmentId,});-- skeleton.calculate();});}diff --git a/packages/docs/src/doc-plugin.ts b/packages/docs/src/doc-plugin.tsindex abd5acf3b7..3c1d4b0773 100644--- a/packages/docs/src/doc-plugin.ts+++ b/packages/docs/src/doc-plugin.ts@@ -28,14 +28,9 @@ import { IShortcutService } from '@univerjs/ui';import type { Dependency } from '@wendellhu/redi';import { Inject, Injector } from '@wendellhu/redi';-import {- BreakLineCommand,- DeleteCommand,- DeleteLeftCommand,- DeleteRightCommand,- InsertCommand,- UpdateCommand,-} from './commands/commands/core-editing.command';+import { BreakLineCommand } from './commands/commands/break-line.command';+import { DeleteCommand, InsertCommand, UpdateCommand } from './commands/commands/core-editing.command';+import { DeleteLeftCommand, DeleteRightCommand, MergeTwoParagraphCommand } from './commands/commands/delete.command';import { IMEInputCommand } from './commands/commands/ime-input.command';import {SetInlineFormatBoldCommand,@@ -49,6 +44,7 @@ import {SetInlineFormatTextColorCommand,SetInlineFormatUnderlineCommand,} from './commands/commands/inline-format.command';+import { BulletListCommand, ListOperationCommand, OrderListCommand } from './commands/commands/list.command';import { CoverContentCommand, ReplaceContentCommand } from './commands/commands/replace-content.command';import { SetDocZoomRatioCommand } from './commands/commands/set-doc-zoom-ratio.command';import { RichTextEditingMutation } from './commands/mutations/core-editing.mutation';@@ -57,12 +53,10 @@ import { SelectAllOperation } from './commands/operations/select-all.operation';import { SetDocZoomRatioOperation } from './commands/operations/set-doc-zoom-ratio.operation';import { SetTextSelectionsOperation } from './commands/operations/text-selection.operation';import { DocClipboardController } from './controllers/clipboard.controller';-import { DeleteController } from './controllers/delete.controller';import { DocRenderController } from './controllers/doc-render.controller';import { FloatingObjectController } from './controllers/floating-object.controller';import { IMEInputController } from './controllers/ime-input.controller';import { InlineFormatController } from './controllers/inline-format.controller';-import { LineBreakInputController } from './controllers/line-break-input.controller';import { MoveCursorController } from './controllers/move-cursor.controller';import { NormalInputController } from './controllers/normal-input.controller';import { PageRenderController } from './controllers/page-render.controller';@@ -142,6 +136,7 @@ export class UniverDocsPlugin extends Plugin {DeleteCommand,UpdateCommand,IMEInputCommand,+ MergeTwoParagraphCommand,RichTextEditingMutation,ReplaceContentCommand,CoverContentCommand,@@ -149,6 +144,9 @@ export class UniverDocsPlugin extends Plugin {SetDocZoomRatioOperation,SetTextSelectionsOperation,SelectAllOperation,+ OrderListCommand,+ BulletListCommand,+ ListOperationCommand,] as ICommand[]).forEach((command) => {this._injector.get(ICommandService).registerCommand(command);@@ -210,10 +208,8 @@ export class UniverDocsPlugin extends Plugin {[TextSelectionController],[NormalInputController],[IMEInputController],- [DeleteController],[InlineFormatController],[DocClipboardController],- [LineBreakInputController],[MoveCursorController],[ZoomController],[FloatingObjectController],diff --git a/packages/docs/src/index.ts b/packages/docs/src/index.tsindex f3245cbf38..6a868df75d 100644--- a/packages/docs/src/index.ts+++ b/packages/docs/src/index.ts@@ -16,11 +16,10 @@export { getDocObject } from './basics/component-tools';export * from './basics/docs-view-key';+export { BreakLineCommand } from './commands/commands/break-line.command';export { DocCopyCommand, DocCutCommand, DocPasteCommand } from './commands/commands/clipboard.command';export {- BreakLineCommand,DeleteCommand,- DeleteLeftCommand,type ICoverCommandParams,type IDeleteCommandParams,type IInsertCommandParams,@@ -28,6 +27,7 @@ export {type IUpdateCommandParams,UpdateCommand,} from './commands/commands/core-editing.command';+export { DeleteLeftCommand, DeleteRightCommand } from './commands/commands/delete.command';export { type IIMEInputCommandParams, IMEInputCommand } from './commands/commands/ime-input.command';export {SetInlineFormatBoldCommand,@@ -41,6 +41,7 @@ export {SetInlineFormatTextColorCommand,SetInlineFormatUnderlineCommand,} from './commands/commands/inline-format.command';+export { BulletListCommand, OrderListCommand } from './commands/commands/list.command';export { CoverContentCommand, ReplaceContentCommand } from './commands/commands/replace-content.command';export {type IRichTextEditingMutationParams,diff --git a/packages/docs/src/services/text-selection-manager.service.ts b/packages/docs/src/services/text-selection-manager.service.tsindex d6be8bac18..4d709ac2dd 100644--- a/packages/docs/src/services/text-selection-manager.service.ts+++ b/packages/docs/src/services/text-selection-manager.service.ts@@ -17,9 +17,12 @@import type { Nullable } from '@univerjs/core';import { ICommandService, RxDisposable } from '@univerjs/core';import type {+ INodePosition,ISuccinctTextRangeParam,ITextRangeWithStyle,ITextSelectionInnerParam,+ ITextSelectionStyle,+ RANGE_DIRECTION,TextRange,} from '@univerjs/engine-render';import { ITextSelectionRenderManager, NORMAL_TEXT_SELECTION_PLUGIN_STYLE } from '@univerjs/engine-render';@@ -32,6 +35,17 @@ interface ITextSelectionManagerSearchParam {subUnitId: string;}+export interface ITextActiveRange {+ startOffset: number;+ endOffset: number;+ collapsed: boolean;+ startNodePosition: Nullable<INodePosition>;+ endNodePosition: Nullable<INodePosition>;+ direction: RANGE_DIRECTION;+ segmentId: string;+ style: ITextSelectionStyle;+}+interface ITextSelectionManagerInsertParam extends ITextSelectionManagerSearchParam, ITextSelectionInnerParam {}type ITextSelectionInfo = Map<string, Map<string, ITextSelectionInnerParam>>;@@ -102,7 +116,7 @@ export class TextSelectionManagerService extends RxDisposable {return this._getTextRanges(this._currentSelection)?.textRanges;}- getActiveRange() {+ getActiveRange(): Nullable<ITextActiveRange> {const selectionInfo = this._getTextRanges(this._currentSelection);if (selectionInfo == null) {return;diff --git a/packages/docs/src/shortcuts/core-editing.shortcut.ts b/packages/docs/src/shortcuts/core-editing.shortcut.tsindex e36e9c5f01..8cf060a60d 100644--- a/packages/docs/src/shortcuts/core-editing.shortcut.ts+++ b/packages/docs/src/shortcuts/core-editing.shortcut.ts@@ -18,7 +18,8 @@ import { FOCUSING_DOC } from '@univerjs/core';import type { IShortcutItem } from '@univerjs/ui';import { KeyCode } from '@univerjs/ui';-import { BreakLineCommand, DeleteLeftCommand, DeleteRightCommand } from '../commands/commands/core-editing.command';+import { BreakLineCommand } from '../commands/commands/break-line.command';+import { DeleteLeftCommand, DeleteRightCommand } from '../commands/commands/delete.command';export const BreakLineShortcut: IShortcutItem = {id: BreakLineCommand.id,diff --git a/packages/engine-render/src/components/docs/block/paragraph/bullet-ruler.ts b/packages/engine-render/src/components/docs/block/paragraph/bullet-ruler.tsindex bf15428b50..a9c4d6ad40 100644--- a/packages/engine-render/src/components/docs/block/paragraph/bullet-ruler.ts+++ b/packages/engine-render/src/components/docs/block/paragraph/bullet-ruler.ts@@ -57,6 +57,7 @@ function decimal(startIndex: number, startNumber: number) {// // A number where single digit numbers are prefixed with a zero, like 01, 02, or 03. Numbers with more than one digit are not prefixed with a zero.function zeroDecimal(startIndex: number, startNumber: number) {const currentIndex = startIndex + startNumber;+ // eslint-disable-next-line no-magic-numbersif (currentIndex < 10) {return `0${currentIndex}`;}diff --git a/packages/engine-render/src/components/docs/block/paragraph/bullet.ts b/packages/engine-render/src/components/docs/block/paragraph/bullet.tsindex eadb0c8a12..52be92aaaf 100644--- a/packages/engine-render/src/components/docs/block/paragraph/bullet.ts+++ b/packages/engine-render/src/components/docs/block/paragraph/bullet.ts@@ -21,7 +21,7 @@ import type { IDocumentSkeletonBullet } from '../../../../basics/i-document-skelimport { getFontStyleString } from '../../../../basics/tools';import { getBulletOrderedSymbol } from './bullet-ruler';-export function dealWidthBullet(+export function dealWithBullet(bullet?: IBullet,lists?: ILists,listLevelAncestors?: Array<Nullable<IDocumentSkeletonBullet>>,@@ -31,9 +31,9 @@ export function dealWidthBullet(return;}- const { listId, nestingLevel = 0, textStyle } = bullet;+ const { listId, listType, nestingLevel = 0, textStyle } = bullet;- const list = lists[listId];+ const list = lists[listType];if (!list || !list.nestingLevel) {return getDefaultBulletSke(listId, listLevelAncestors?.[nestingLevel]?.startIndexItem);@@ -151,16 +151,21 @@ function __generateOrderedListSymbol(// <w:lvlText w:val="%1."/>// <w:lvlJc w:val="left"/>// </w:lvl>+const glyphFormatSplit = glyphFormat.split('%');const prefix = glyphFormatSplit[0];const resultSymbol = [prefix];+for (let i = 1; i < glyphFormatSplit.length; i++) {const levelAndSuffixPre = glyphFormatSplit[i];const { level, suffix } = ___getLevelAndSuffix(levelAndSuffixPre);+let startIndexItem = listLevelAncestors?.[level]?.startIndexItem || 1;+if (level !== nestingLevel && listLevelAncestors?.[level] !== null) {startIndexItem -= 1;}+const singleSymbol = ___getSymbolByBesting(startIndexItem, nestings[level]);// console.log(// '___getSymbolByBesting',@@ -174,6 +179,7 @@ function __generateOrderedListSymbol(// );resultSymbol.push(singleSymbol, suffix);}+return resultSymbol.join('');}diff --git a/packages/engine-render/src/components/docs/block/paragraph/layout-ruler.ts b/packages/engine-render/src/components/docs/block/paragraph/layout-ruler.tsindex 6dcb86380e..481d8101ad 100644--- a/packages/engine-render/src/components/docs/block/paragraph/layout-ruler.ts+++ b/packages/engine-render/src/components/docs/block/paragraph/layout-ruler.ts@@ -799,10 +799,12 @@ function __bulletIndentHandler(const { hanging: hangingBullet, indentStart: indentStartBullet } = bulletSkeleton;+ // TODO: @JOCS, do not modify snapshot data directly.if (hanging === undefined) {paragraphStyle.hanging = hangingBullet;}+ // TODO: @JOCS, do not modify snapshot data directly.if (indentStart === undefined) {paragraphStyle.indentStart =getNumberUnitValue(indentStartBullet || 0, charSpaceApply) -diff --git a/packages/engine-render/src/components/docs/block/paragraph/paragraph.ts b/packages/engine-render/src/components/docs/block/paragraph/paragraph.tsindex c6ce59ef89..47bb95a50f 100644--- a/packages/engine-render/src/components/docs/block/paragraph/paragraph.ts+++ b/packages/engine-render/src/components/docs/block/paragraph/paragraph.ts@@ -50,7 +50,7 @@ import {} from '../../common/tools';import type { DataStreamTreeNode } from '../../view-model/data-stream-tree-node';import type { DocumentViewModel } from '../../view-model/document-view-model';-import { dealWidthBullet } from './bullet';+import { dealWithBullet } from './bullet';import { dealWidthInlineDrawing } from './inline-drawing';import { ArabicHandler, emojiHandler, otherHandler, TibetanHandler } from './language-ruler';import { calculateParagraphLayout } from './layout-ruler';@@ -128,9 +128,11 @@ export function dealWidthParagraph(drawingAnchor,};- const listLevelAncestors = _getListLevelAncestors(bullet, skeListLevel); // 取得列表所有level的缓存- const bulletSkeleton = dealWidthBullet(bullet, lists, listLevelAncestors, localeService); // 生成bullet- _updateListLevelAncestors(bullet, bulletSkeleton, skeListLevel); // 更新最新的level缓存列表+ const listLevelAncestors = _getListLevelAncestors(bullet, skeListLevel); // 取得列表所有 level 的缓存+ const bulletSkeleton = dealWithBullet(bullet, lists, listLevelAncestors, localeService); // 生成 bullet++ _updateListLevelAncestors(bullet, bulletSkeleton, skeListLevel); // 更新最新的 level 缓存列表+paragraphConfig.bulletSkeleton = bulletSkeleton;const { horizontalAlign = HorizontalAlign.UNSPECIFIED, snapToGrid = BooleanNumber.TRUE } = paragraphStyle;@@ -362,8 +364,6 @@ function _getListLevelAncestors(listLevelAncestors[i] = bs || null;}- // console.log('SymbolByBesting', sameList, listLevelAncestors, level, listId, listLevel);-return listLevelAncestors;}diff --git a/packages/engine-render/src/components/docs/common/span.ts b/packages/engine-render/src/components/docs/common/span.tsindex 6656b0d4ef..f53c699ebf 100644--- a/packages/engine-render/src/components/docs/common/span.ts+++ b/packages/engine-render/src/components/docs/common/span.ts@@ -147,9 +147,10 @@ export function createSkeletonBulletSpan(// 当文字也需要对齐到网格式,进行处理, LINES默认参照是doc全局字体大小const multiple = Math.ceil(contentWidth / charSpaceApply);- let width = (multiple < 2 ? 2 : multiple) * charSpaceApply; // 默认bullet有2个tab+ let width = (multiple < 2 ? 2 : multiple) * charSpaceApply; // 默认 bullet 有 2 个 tablet left = 0;+if (bulletType) {// 有序列表的处理,左对齐时left=0,其余情况根据contentWidth调整if (bulletAlign === BulletAlignment.CENTER) {diff --git a/packages/engine-render/src/components/docs/doc-skeleton.ts b/packages/engine-render/src/components/docs/doc-skeleton.tsindex fb9e7fe654..49a9e7ec0f 100644--- a/packages/engine-render/src/components/docs/doc-skeleton.ts+++ b/packages/engine-render/src/components/docs/doc-skeleton.ts@@ -20,6 +20,7 @@ import {GridType,HorizontalAlign,PageOrientType,+ PRESET_LIST_TYPE,SectionType,VerticalAlign,WrapStrategy,@@ -471,8 +472,13 @@ export class DocumentSkeleton extends Skeleton {private _createSkeleton(bounds?: IBoundRect) {// 每一个布局const DEFAULT_PAGE_SIZE = { width: Infinity, height: Infinity };- const { headerTreeMap, footerTreeMap } = this.getViewModel();- const { documentStyle, lists, drawings } = this.getViewModel().getDataModel();+ const viewModel = this.getViewModel();+ const { headerTreeMap, footerTreeMap } = viewModel;+ const { documentStyle, drawings, lists: customLists = {} } = viewModel.getDataModel();+ const lists = {+ ...PRESET_LIST_TYPE,+ ...customLists,+ };const {pageNumberStart: global_pageNumberStart = 1, // pageNumberStartpageSize: global_pageSize = DEFAULT_PAGE_SIZE,diff --git a/packages/sheets/src/basics/__tests__/rangeMerge.spec.ts b/packages/sheets/src/basics/__tests__/rangeMerge.spec.tsindex 21b2fd070f..a5f34fd722 100644--- a/packages/sheets/src/basics/__tests__/rangeMerge.spec.ts+++ b/packages/sheets/src/basics/__tests__/rangeMerge.spec.ts@@ -142,7 +142,7 @@ describe('test rangeMerge', () => {{ startRow: 4, endRow: 6, startColumn: 8, endColumn: 10 },{ startRow: 7, endRow: 10, startColumn: 2, endColumn: 10 },]);- console.log(JSON.stringify(result, null, 2));+expect(result).toEqual([{startRow: 7,diff --git a/packages/slides/src/basics/demo-data.ts b/packages/slides/src/basics/demo-data.tsindex a76b3492f5..d23049c2da 100644--- a/packages/slides/src/basics/demo-data.ts+++ b/packages/slides/src/basics/demo-data.ts@@ -18,12 +18,11 @@ import type { IDocumentData } from '@univerjs/core';import {BaselineOffset,BooleanNumber,- BulletAlignment,ColumnSeparatorType,- GlyphType,ObjectRelativeFromH,ObjectRelativeFromV,PositionedObjectLayoutType,+ PresetListType,SectionType,WrapTextType,} from '@univerjs/core';@@ -58,84 +57,6 @@ export const docsDemoData: IDocumentData = {wrapText: WrapTextType.BOTH_SIDES,},},- lists: {- unorderedTest: {- listId: 'unorderedTest',- nestingLevel: [- {- bulletAlignment: BulletAlignment.START,- glyphFormat: ' %0',- textStyle: {- fs: 12,- },- startNumber: 0,- glyphSymbol: '\u25CF',- hanging: 21,- indentStart: 21,- },- {- bulletAlignment: BulletAlignment.START,- glyphFormat: ' %1',- textStyle: {- fs: 12,- },- startNumber: 0,- glyphSymbol: '\u25A0',- hanging: 21,- indentStart: 42,- },- {- bulletAlignment: BulletAlignment.START,- glyphFormat: ' %1',- textStyle: {- fs: 12,- },- startNumber: 0,- glyphSymbol: '\u25C6',- hanging: 21,- indentStart: 63,- },- ],- },- testBullet: {- listId: 'testBullet',- nestingLevel: [- {- bulletAlignment: BulletAlignment.START,- glyphFormat: ' %1.',- textStyle: {- fs: 12,- },- startNumber: 0,- glyphType: GlyphType.ROMAN,- hanging: 21,- indentStart: 21,- },- {- bulletAlignment: BulletAlignment.START,- glyphFormat: ' %1.%2)',- textStyle: {- fs: 12,- },- startNumber: 0,- glyphType: GlyphType.ROMAN,- hanging: 21,- indentStart: 42,- },- {- bulletAlignment: BulletAlignment.START,- glyphFormat: ' %1.%2.%3.',- textStyle: {- fs: 12,- },- startNumber: 0,- glyphType: GlyphType.ROMAN,- hanging: 21,- indentStart: 63,- },- ],- },- },body: {dataStream: `在“第1题”工作表中完成以下操作\b上标日期列单元格数据验证,限制只能输入日期(介于1949年1月1日至2099年1月1日)\r细化埋点上报链路和指标方案梳理目前通过每日定时任务发送报告\r自2018年首届进博会举办以来,进博会已经成为全球新品的首发地、前沿技术的首选地、创新服务的首推地。中国这十年”对外开放成就展湖北展区主要以图文、图表、数据、视频、企业展品、实物模型、光电科技等体现湖北十年开放成就、重大开放平台及产业。湖北省共计17家企业、机构的展品将在这一展区展示\r国家主席习近平以视频方式出席在上海举行的第五届中国国际进口博览会开幕式并发表题为《共创开放繁荣的美好未来》的致辞中国将推动各国各方共享深化国际合作机遇,全面深入参与世界贸易组织改革谈判\r中国男排两名现役国手彭世坤和张秉龙分别效力的三得利太阳鸟和东京大熊本轮遭遇。双方经过激战,主场作战的卫冕冠军三得利技高一筹3-2逆转击败对手,力夺第3场胜利\r\n`,textRuns: [@@ -204,7 +125,8 @@ export const docsDemoData: IDocumentData = {{startIndex: 60,bullet: {- listId: 'testBullet',+ listId: 'orderList',+ listType: PresetListType.ORDER_LIST,nestingLevel: 0,textStyle: {fs: 20,@@ -214,7 +136,8 @@ export const docsDemoData: IDocumentData = {{startIndex: 91,bullet: {- listId: 'testBullet',+ listId: 'orderList',+ listType: PresetListType.ORDER_LIST,nestingLevel: 1,textStyle: {fs: 20,@@ -224,7 +147,8 @@ export const docsDemoData: IDocumentData = {{startIndex: 234,bullet: {- listId: 'testBullet',+ listId: 'orderList',+ listType: PresetListType.ORDER_LIST,nestingLevel: 1,textStyle: {fs: 20,@@ -234,7 +158,8 @@ export const docsDemoData: IDocumentData = {{startIndex: 327,bullet: {- listId: 'testBullet',+ listId: 'orderList',+ listType: PresetListType.ORDER_LIST,nestingLevel: 1,textStyle: {fs: 20,@@ -244,7 +169,8 @@ export const docsDemoData: IDocumentData = {{startIndex: 406,bullet: {- listId: 'testBullet',+ listId: 'orderList',+ listType: PresetListType.ORDER_LIST,nestingLevel: 2,textStyle: {fs: 20,diff --git a/packages/ui/src/common/component-manager.ts b/packages/ui/src/common/component-manager.tsindex 11aadc6d2f..8e315d8af7 100644--- a/packages/ui/src/common/component-manager.ts+++ b/packages/ui/src/common/component-manager.ts@@ -69,6 +69,7 @@ import {NoBorderSingle,NoColor,NoRotationSingle,+ OrderSingle,OuterBorder,OverflowSingle,PaintBucket,@@ -86,6 +87,7 @@ import {TruncationSingle,UnderlineSingle,UndoSingle,+ UnorderSingle,UpBorder,VerticalCenterSingle,VerticalIntegrationSingle,@@ -143,6 +145,8 @@ export class ComponentManager {RightRotationFortyFiveDegreesSingle,RightRotationNinetyDegreesSingle,StrikethroughSingle,+ OrderSingle,+ UnorderSingle,TruncationSingle,UnderlineSingle,UndoSingle,