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.

fix(doc): inline format affect layout (#778)

Ran Luoe1752d81529f
diff --git a/examples/src/data/docs/default-document-data-cn.ts b/examples/src/data/docs/default-document-data-cn.ts
index 8387ddb1ed..f7530cd4c2 100644
--- a/examples/src/data/docs/default-document-data-cn.ts
+++ b/examples/src/data/docs/default-document-data-cn.ts
@@ -15,17 +15,17 @@
*/
import type { IDocumentData } from '@univerjs/core';
-import { BaselineOffset, BooleanNumber, PresetListType, TextDecoration } from '@univerjs/core';
+import { BooleanNumber } from '@univerjs/core';
export const DEFAULT_DOCUMENT_DATA_CN: IDocumentData = {
- id: 'd',
+ id: 'default-document-id',
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',
+ '荷塘月色\r\r作者:朱自清\r\r这几天心里颇不宁静。今晚在院子里坐着乘凉,忽然想起日日走过的荷塘,在这满月的光里,总该另有一番样子吧。月亮渐渐地升高了,墙外马路上孩子们的欢笑,已经听不见了;妻在屋里拍着闰儿,迷迷糊糊地哼着眠歌。我悄悄地披了大衫,带上门出去。\r\r沿着荷塘,是一条曲折的小煤屑路。这是一条幽僻的路;白天也少人走,夜晚更加寂寞。荷塘四面,长着许多树,蓊蓊郁郁的。路的一旁,是些杨柳,和一些不知道名字的树。没有月光的晚上,这路上阴森森的,有些怕人。今晚却很好,虽然月光也还是淡淡的。\r\r路上只我一个人,背着手踱着。这一片天地好像是我的;我也像超出了平常的自己,到了另一个世界里。我爱热闹,也爱冷静;爱群居,也爱独处。像今晚上,一个人在这苍茫的月下,什么都可以想,什么都可以不想,便觉是个自由的人。白天里一定要做的事,一定要说的话,现在都可不理。这是独处的妙处,我且受用这无边的荷香月色好了。\r\r曲曲折折的荷塘上面,弥望的是田田的叶子。叶子出水很高,像亭亭的舞女的裙。层层的叶子中间,零星地点缀着些白花,有袅娜地开着的,有羞涩地打着朵儿的;正如一粒粒的明珠,又如碧天里的星星,又如刚出浴的美人。微风过处,送来缕缕清香,仿佛远处高楼上渺茫的歌声似的。这时候叶子与花也有一丝的颤动,像闪电般,霎时传过荷塘的那边去了。叶子本是肩并肩密密地挨着,这便宛然有了一道凝碧的波痕。叶子底下是脉脉的流水,遮住了,不能见一些颜色;而叶子却更见风致了。\r\r月光如流水一般,静静地泻在这一片叶子和花上。薄薄的青雾浮起在荷塘里。叶子和花仿佛在牛乳中洗过一样;又像笼着轻纱的梦。虽然是满月,天上却有一层淡淡的云,所以不能朗照;但我以为这恰是到了好处——酣眠固不可少,小睡也别有风味的。月光是隔了树照过来的,高处丛生的灌木,落下参差的斑驳的黑影,峭楞楞如鬼一般;弯弯的杨柳的稀疏的倩影,却又像是画在荷叶上。塘中的月色并不均匀;但光与影有着和谐的旋律,如梵婀玲上奏着的名曲。\r\r荷塘的四面,远远近近,高高低低都是树,而杨柳最多。这些树将一片荷塘重重围住;只在小路一旁,漏着几段空隙,像是特为月光留下的。树色一例是阴阴的,乍看像一团烟雾;但杨柳的丰姿,便在烟雾里也辨得出。树梢上隐隐约约的是一带远山,只有些大意罢了。树缝里也漏着一两点路灯光,没精打采的,是渴睡人的眼。这时候最热闹的,要数树上的蝉声与水里的蛙声;但热闹是它们的,我什么也没有。\r\r忽然想起采莲的事情来了。采莲是江南的旧俗,似乎很早就有,而六朝时为盛;从诗歌里可以约略知道。采莲的是少年的女子,她们是荡着小船,唱着艳歌去的。采莲人不用说很多,还有看采莲的人。那是一个热闹的季节,也是一个风流的季节。梁元帝《采莲赋》里说得好:\r\r于是妖童女,荡舟心许;鷁首徐回,兼传羽杯;櫂将移而藻挂,船欲动而萍开。尔其纤腰束素,迁延顾步;夏始春余,叶嫩花初,恐沾裳而浅笑,畏倾船而敛裾。\r\r可见当时嬉游的光景了。这真是有趣的事,可惜我们现在早已无福消受了。\r\r于是又记起,《西洲曲》里的句子:\r\r采莲南塘秋,莲花过人头;低头弄莲子,莲子清如水。\r\r今晚若有采莲人,这儿的莲花也算得“过人头”了;只不见一些流水的影子,是不行的。这令我到底惦着江南了。——这样想着,猛一抬头,不觉已是自己的门前;轻轻地推门进去,什么声息也没有,妻已睡熟好久了。\r\r一九二七年七月,北京清华园。\r\r\r\r《荷塘月色》语言朴素典雅,准确生动,贮满诗意,满溢着朱自清的散文语言一贯有朴素的美,不用浓墨重彩,画的是淡墨水彩。\r\r朱自清先生一笔写景一笔说情,看起来松散不知所云,可仔细体会下,就能感受到先生在字里行间表述出的苦闷,而随之读者也被先生的文字所感染,被带进了他当时那苦闷而无法明喻的心情。这就是优异散文的必须品质之一。\r\r扩展资料:\r一首长诗《毁灭》奠定了朱自清在文坛新诗人的地位,而《桨声灯影里的秦淮河》则被公认为白话美文的典范。朱自清用白话美文向复古派宣战,有力地回击了复古派“白话不能作美文”之说,他是“五四”新文学运动的开拓者之一。\r\r朱自清的美文影响了一代又一代人。作家贾平凹说:来到扬州,第一个想到的人是朱自清,他是知识分子中最最了不起的人物。\r\r实际上,朱自清的写作路程是非常曲折的,他早期的时候大多数作品都是诗歌,但是他的诗歌和我国古代诗人的诗有很大区别,他的诗是用白话文写的,这其实也是他写作的惯用风格。\r\r后来,朱自清开始写一些关于社会的文章,因为那个时候社会比较混乱,这时候的作品大多抨击社会的黑暗面,文体风格大多硬朗,基调伉俪。到了后期,大多是写关于山水的文章,这类文章的写作格调大多以清丽雅致为主。\r\r朱自清的写作风格虽然在不同的时期随着他的人生阅历和社会形态的不同而发生着变化,但是他文章的主基调是没有变的,他这一生,所写的所有文章风格上都有一个非常显著的特点,那就是简约平淡,他不是类似古代花间词派的诗人们,不管是他的诗词还是他的文章从来都不用过于华丽的辞藻,他崇尚的是平淡。\r\r英国友人戴立克试过英译朱自清几篇散文,译完一读显得单薄,远远不如原文流利。他不服气,改用稍微古奥的英文重译,好多了:“那是说,朱先生外圆内方,文字尽管浅白,心思却很深沉,译笔只好朝深处经营。”朱自清的很多文章,譬如《背影》《祭亡妇》,读来自有一番只可意会不可言传的东西。\r\r平淡就是朱自清的写作风格。他不是豪放派的作家,他在创作的时候钟情于清新的风格,给人耳目一新的感觉。在他的文章中包含了他对生活的向往,由此可见他的写作风格和他待人处事的态度也是有几分相似的。他的文章非常优美,但又不会让人觉得狭隘,给人一种豁达渊博的感觉,这就是朱自清的写作风格,更是朱自清的为人品质。\r\r写有《荷塘月色》《背影》等名篇的著名散文家朱自清先生,不仅自己一生风骨正气,还用无形的家风涵养子孙。良好的家风家规意蕴深远,催人向善,是凝聚情感、涵养德行、砥砺成才的人生信条。“北有朱自清,南有朱物华,一文一武,一南一北,双星闪耀”,这是中国知识界、教育界对朱家两兄弟的赞誉。\r\r朱自清性格温和,为人和善,对待年轻人平易近人,是个平和的人。他取字“佩弦”,意思要像弓弦那样将自己绷紧,给人的感觉是自我要求高,偶尔有呆气。朱自清教学负责,对学生要求严格,修他的课的学生都受益不少。\r\r1948年6月,患胃病多年的朱自清,在《抗议美国扶日政策并拒绝领取美援面粉宣言》上,一丝不苟地签下了自己的名字。随后,朱自清还将面粉配购证以及面粉票退了回去。1948年8月12日,朱自清因不堪胃病折磨,离开人世。在新的时代即将到来时,朱自清却匆匆地离人们远去。他为人们留下了无数经典的诗歌和文字,还有永不屈服的精神。\r\r朱自清没有豪言壮语,他只是用坚定的行动、朴实的语言,向世人展示了中国知识分子在祖国危难之际坚定的革命性,体现了中国人的骨气,表现了无比高贵的民族气节,呈现了人生最有价值的一面,谱就了生命中最华丽的乐章。\r\r他以“自清”为名,自勉在困境中不丧志;他身患重病,至死拒领美援面粉,其气节令世人感佩;他的《背影》《荷塘月色》《匆匆》脍炙人口;他的文字追求“真”,没有半点矫饰,却蕴藏着动人心弦的力量。\r\r朱自清不但在文学创作方面有很高的造诣,也是一名革命民主主义战士,在反饥饿、反内战的斗争中,他始终保持着一个正直的爱国知识分子的气节和情操。毛泽东对朱自清宁肯饿死不领美国“救济粉”的精神给予称赞,赞扬他“表现了我们民族的英雄气概”。\r\n',
textRuns: [
{
st: 0,
- ed: 2,
+ ed: 4,
ts: {
fs: 24,
ff: 'Microsoft YaHei',
@@ -34,760 +34,540 @@ export const DEFAULT_DOCUMENT_DATA_CN: IDocumentData = {
},
bl: BooleanNumber.TRUE,
bg: {
- rgb: 'rgb(255, 0, 0)',
+ rgb: '#FF6670',
},
},
},
{
- st: 2,
- ed: 4,
+ st: 5,
+ ed: 9,
ts: {
- fs: 9,
- ff: 'Times New Roman',
+ fs: 18,
+ ff: 'Microsoft YaHei',
cl: {
- rgb: 'rgb(255, 255, 255)',
- },
- bl: BooleanNumber.TRUE,
- bg: {
- rgb: 'rgb(255, 0, 0)',
+ rgb: 'rgb(30, 30, 30)',
},
+ bl: BooleanNumber.FALSE,
},
},
{
- st: 4,
- ed: 6,
+ st: 9,
+ ed: 13,
ts: {
- fs: 24,
+ fs: 18,
ff: 'Microsoft YaHei',
cl: {
- rgb: 'rgb(255, 255, 255)',
+ rgb: 'rgb(30, 30, 30)',
},
bl: BooleanNumber.TRUE,
- bg: {
- rgb: 'rgb(255, 0, 0)',
- },
},
},
{
- st: 7,
- ed: 13,
+ st: 13,
+ ed: 3057,
ts: {
fs: 14,
ff: 'Microsoft YaHei',
- bl: BooleanNumber.TRUE,
cl: {
- rgb: 'rgb(47, 85, 151)',
+ rgb: 'rgb(30, 30, 30)',
},
+ bl: BooleanNumber.FALSE,
},
},
+ ],
+ paragraphs: [
{
- st: 13,
- ed: 15,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
+ startIndex: 4,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 15,
- ed: 16,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
- va: BaselineOffset.SUBSCRIPT,
+ startIndex: 5,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 16,
- ed: 18,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
+ startIndex: 12,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 18,
- ed: 19,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
- va: BaselineOffset.SUPERSCRIPT,
+ startIndex: 13,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 19,
- ed: 20,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
+ startIndex: 127,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 20,
- ed: 24,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
+ startIndex: 128,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 24,
- ed: 33,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
- st: {
- s: BooleanNumber.TRUE,
- },
+ startIndex: 244,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 33,
- ed: 37,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
+ startIndex: 245,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 37,
- ed: 42,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
- ul: {
- s: BooleanNumber.TRUE,
- cl: {
- rgb: 'rgb(255, 0, 0)',
- },
- t: TextDecoration.DASH_DOT_DOT_HEAVY,
- },
+ startIndex: 398,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 43,
- ed: 47,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(255, 255, 255)',
- },
- bg: {
- rgb: 'rgb(255, 0, 255)',
- },
+ startIndex: 399,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 47,
- ed: 61,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
+ startIndex: 618,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 61,
- ed: 67,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(255, 192, 0)',
- },
- bl: BooleanNumber.TRUE,
- ul: {
- s: BooleanNumber.TRUE,
- },
+ startIndex: 619,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 67,
- ed: 87,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
+ startIndex: 824,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 87,
- ed: 93,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(255, 192, 0)',
- },
- bl: BooleanNumber.TRUE,
- ul: {
- s: BooleanNumber.TRUE,
- },
+ startIndex: 825,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 93,
- ed: 94,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
+ startIndex: 1007,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 94,
- ed: 126,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
+ startIndex: 1008,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 127,
- ed: 130,
- ts: {
- fs: 21,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
- bl: BooleanNumber.TRUE,
+ startIndex: 1130,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 130,
- ed: 136,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
+ startIndex: 1131,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 136,
- ed: 142,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
+ startIndex: 1203,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 142,
- ed: 148,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
+ startIndex: 1204,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 148,
- ed: 154,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
+ startIndex: 1238,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 154,
- ed: 177,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
+ startIndex: 1239,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 177,
- ed: 183,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
- bl: BooleanNumber.TRUE,
- ul: {
- s: BooleanNumber.TRUE,
- },
+ startIndex: 1256,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 183,
- ed: 185,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
+ startIndex: 1257,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 185,
- ed: 188,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
+ startIndex: 1282,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 188,
- ed: 218,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
+ startIndex: 1283,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 219,
- ed: 222,
- ts: {
- fs: 21,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
- bl: BooleanNumber.TRUE,
+ startIndex: 1380,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 222,
- ed: 229,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
+ startIndex: 1381,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 229,
- ed: 243,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
+ startIndex: 1396,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 243,
- ed: 259,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
+ startIndex: 1397,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 259,
- ed: 267,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
- it: BooleanNumber.TRUE,
- ul: {
- s: BooleanNumber.TRUE,
- t: TextDecoration.DASHED_HEAVY,
- },
+ startIndex: 1398,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 267,
- ed: 268,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
- it: BooleanNumber.TRUE,
+ startIndex: 1399,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 268,
- ed: 273,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
- it: BooleanNumber.TRUE,
- ul: {
- s: BooleanNumber.TRUE,
- t: TextDecoration.DASH_DOT_DOT_HEAVY,
- },
+ startIndex: 1457,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 273,
- ed: 274,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
- it: BooleanNumber.TRUE,
+ startIndex: 1458,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 274,
- ed: 277,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
- it: BooleanNumber.TRUE,
- ul: {
- s: BooleanNumber.TRUE,
- t: TextDecoration.DASH_LONG,
- },
+ startIndex: 1559,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 277,
- ed: 278,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
- it: BooleanNumber.TRUE,
+ startIndex: 1560,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 278,
- ed: 284,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
- it: BooleanNumber.TRUE,
- ul: {
- s: BooleanNumber.TRUE,
- t: TextDecoration.DASH_LONG_HEAVY,
- },
+ startIndex: 1566,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 284,
- ed: 285,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
- it: BooleanNumber.TRUE,
+ startIndex: 1670,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 285,
- ed: 290,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
- it: BooleanNumber.TRUE,
- ul: {
- s: BooleanNumber.TRUE,
- t: TextDecoration.DOT_DOT_DASH,
- },
+ startIndex: 1671,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 290,
- ed: 291,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
+ startIndex: 1728,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 291,
- ed: 318,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
+ startIndex: 1729,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 319,
- ed: 324,
- ts: {
- fs: 21,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
- bl: BooleanNumber.TRUE,
+ startIndex: 1811,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 324,
- ed: 337,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
+ startIndex: 1812,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 337,
- ed: 345,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
+ startIndex: 1912,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 345,
- ed: 354,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
+ startIndex: 1913,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 354,
- ed: 362,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
+ startIndex: 2053,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 362,
- ed: 401,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
+ startIndex: 2054,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 401,
- ed: 409,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
+ startIndex: 2190,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 409,
- ed: 492,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
+ startIndex: 2191,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 492,
- ed: 498,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
+ startIndex: 2341,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 498,
- ed: 523,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
+ startIndex: 2342,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 523,
- ed: 527,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
+ startIndex: 2481,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
{
- st: 527,
- ed: 540,
- ts: {
- fs: 14,
- ff: 'Microsoft YaHei',
- cl: {
- rgb: 'rgb(47, 85, 151)',
- },
+ startIndex: 2482,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
},
- ],
- paragraphs: [
{
- startIndex: 6,
+ startIndex: 2582,
paragraphStyle: {
- spaceAbove: 0,
+ spaceAbove: 10,
lineSpacing: 2,
- spaceBelow: 20,
+ spaceBelow: 0,
},
},
{
- startIndex: 42,
+ startIndex: 2583,
paragraphStyle: {
- spaceAbove: 20,
+ spaceAbove: 10,
lineSpacing: 2,
spaceBelow: 0,
},
},
{
- startIndex: 126,
- bullet: {
- listType: PresetListType.BULLET_LIST,
- listId: 'a',
- nestingLevel: 0,
- textStyle: {
- fs: 20,
- bl: BooleanNumber.TRUE,
- bg: {
- rgb: 'rgb(255, 255, 0)',
- },
- },
+ startIndex: 2742,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
+ },
+ {
+ startIndex: 2743,
paragraphStyle: {
- spaceAbove: 20,
+ spaceAbove: 10,
lineSpacing: 2,
spaceBelow: 0,
},
},
{
- startIndex: 218,
- bullet: {
- listType: PresetListType.ORDER_LIST,
- listId: 'b',
- nestingLevel: 0,
- textStyle: {
- fs: 20,
- },
+ startIndex: 2845,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
+ },
+ },
+ {
+ startIndex: 2846,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
},
+ },
+ {
+ startIndex: 2940,
paragraphStyle: {
- spaceAbove: 20,
+ spaceAbove: 10,
lineSpacing: 2,
spaceBelow: 0,
},
},
{
- startIndex: 318,
+ startIndex: 2941,
paragraphStyle: {
- spaceAbove: 20,
+ spaceAbove: 10,
lineSpacing: 2,
spaceBelow: 0,
},
},
{
- startIndex: 540,
+ startIndex: 3057,
paragraphStyle: {
- spaceAbove: 20,
+ spaceAbove: 10,
lineSpacing: 2,
spaceBelow: 0,
},
@@ -795,7 +575,7 @@ export const DEFAULT_DOCUMENT_DATA_CN: IDocumentData = {
],
sectionBreaks: [
{
- startIndex: 541,
+ startIndex: 3058,
// columnProperties: [
// {
// width: 250,
diff --git a/examples/src/data/docs/default-document.data-simple.ts b/examples/src/data/docs/default-document.data-simple.ts
new file mode 100644
index 0000000000..a3cb23de78
--- /dev/null
+++ b/examples/src/data/docs/default-document.data-simple.ts
@@ -0,0 +1,98 @@
+/**
+ * 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 { BooleanNumber } from '@univerjs/core';
+
+export const DEFAULT_DOCUMENT_DATA_SIMPLE: IDocumentData = {
+ id: 'default-document-id',
+ body: {
+ dataStream: '荷塘月色\r作者:朱自清\r\n',
+ textRuns: [
+ {
+ st: 0,
+ ed: 4,
+ ts: {
+ fs: 24,
+ ff: 'Microsoft YaHei',
+ cl: {
+ rgb: 'rgb(0, 0, 0)',
+ },
+ bl: BooleanNumber.TRUE,
+ },
+ },
+ {
+ st: 5,
+ ed: 11,
+ ts: {
+ fs: 18,
+ ff: 'Microsoft YaHei',
+ cl: {
+ rgb: 'rgb(30, 30, 30)',
+ },
+ bl: BooleanNumber.FALSE,
+ },
+ },
+ ],
+ paragraphs: [
+ {
+ startIndex: 4,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
+ },
+ },
+ {
+ startIndex: 11,
+ paragraphStyle: {
+ spaceAbove: 10,
+ lineSpacing: 2,
+ spaceBelow: 0,
+ },
+ },
+ ],
+ sectionBreaks: [
+ {
+ startIndex: 12,
+ // columnProperties: [
+ // {
+ // width: 250,
+ // paddingEnd: 15,
+ // },
+ // ],
+ // columnSeparatorType: ColumnSeparatorType.NONE,
+ // sectionType: SectionType.SECTION_TYPE_UNSPECIFIED,
+ // textDirection: textDirectionDocument,
+ // contentDirection: textDirection!,
+ },
+ ],
+ },
+ documentStyle: {
+ pageSize: {
+ width: 595,
+ height: 842,
+ },
+ marginTop: 50,
+ marginBottom: 50,
+ marginRight: 40,
+ marginLeft: 40,
+ renderConfig: {
+ vertexAngle: 0,
+ centerAngle: 0,
+ },
+ },
+};
diff --git a/examples/src/data/docs/index.ts b/examples/src/data/docs/index.ts
index 2153b9dcd9..90dbb6f783 100644
--- a/examples/src/data/docs/index.ts
+++ b/examples/src/data/docs/index.ts
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+export * from './default-document.data-simple';
export * from './default-document-data';
export * from './default-document-data-cn';
export * from './default-document-data-en';
diff --git a/packages/docs-ui/src/views/doc-container/DocContainer.tsx b/packages/docs-ui/src/views/doc-container/DocContainer.tsx
index ce54f7b83b..81f1aad567 100644
--- a/packages/docs-ui/src/views/doc-container/DocContainer.tsx
+++ b/packages/docs-ui/src/views/doc-container/DocContainer.tsx
@@ -20,7 +20,7 @@ import React, { Component, createRef } from 'react';
import type { IUniverDocsUIConfig } from '../../basics';
import style from './index.module.less';
-export interface BaseDocContainerProps extends BaseComponentProps {
+interface IBaseDocContainerProps extends BaseComponentProps {
config: IUniverDocsUIConfig;
changeLocale: (locale: string) => void;
methods?: any;
@@ -29,7 +29,7 @@ export interface BaseDocContainerProps extends BaseComponentProps {
/**
* One univerdoc instance DOM container
*/
-export class DocContainer extends Component<BaseDocContainerProps> {
+export class DocContainer extends Component<IBaseDocContainerProps> {
leftContentLeft: number = 0;
leftContentTop: number = 0;
@@ -42,7 +42,7 @@ export class DocContainer extends Component<BaseDocContainerProps> {
contentRef = createRef<HTMLDivElement>();
- constructor(props: BaseDocContainerProps) {
+ constructor(props: IBaseDocContainerProps) {
super(props);
this.changeSkin(props.config.container as string, 'default');
}
diff --git a/packages/docs/src/views/doc-canvas-view.ts b/packages/docs/src/views/doc-canvas-view.ts
index f3586566b3..0a05d528c7 100644
--- a/packages/docs/src/views/doc-canvas-view.ts
+++ b/packages/docs/src/views/doc-canvas-view.ts
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+/* eslint-disable no-magic-numbers */
+
import type { DocumentDataModel, EventState, Nullable } from '@univerjs/core';
import {
DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,
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.ts
index 481d8101ad..bcc54974c0 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
@@ -49,7 +49,6 @@ import {
getLastSection,
getLineHeightConfig,
getNumberUnitValue,
- getPageContentWidth,
getPositionHorizon,
getPositionVertical,
isColumnFull,
@@ -105,7 +104,6 @@ function _divideOperator(
const lastSpan = divide?.spanGroup?.[divide.spanGroup.length - 1];
const preWidth = lastSpan?.width || 0;
const preLeft = lastSpan?.left || 0;
- const pageContentWidth = getPageContentWidth(lastPage);
// Last span is western char and the current span is Chinese word or vice verse.
const isMixedCJKWesternTextLayout = hasMixedTextLayout(lastSpan, spanGroup[0]);
@@ -181,68 +179,6 @@ function _divideOperator(
defaultSpanLineHeight
);
}
-
- // if (width > pageContentWidth) {
- // // 一个字符 or word 超页内容宽
- // if (isBlankPage(lastPage)) {
- // addSpanToDivide(divide, spanGroup, preOffsetLeft);
- // __makeColumnsFull(column?.parent?.columns);
- // } else {
- // _pageOperator(
- // spanGroup,
- // pages,
- // sectionBreakConfig,
- // paragraphConfig,
- // paragraphStart,
- // defaultSpanLineHeight
- // );
- // }
- // } else if (column && width > column.width) {
- // // 一个字符 or word 超列宽
- // setColumnFullState(column, true);
-
- // if (isBlankColumn(column)) {
- // addSpanToDivide(divide, spanGroup, preOffsetLeft);
- // } else {
- // _columnOperator(
- // spanGroup,
- // pages,
- // sectionBreakConfig,
- // paragraphConfig,
- // paragraphStart,
- // defaultSpanLineHeight
- // );
- // }
- // } else if (divideInfo.isLast) {
- // // 最后一个 divide
- // if (
- // spanGroup.length === 1 &&
- // (spanGroup[0].content === DataStreamTreeTokenType.SPACE ||
- // spanGroup[0].content === DataStreamTreeTokenType.PARAGRAPH)
- // ) {
- // addSpanToDivide(divide, spanGroup, preOffsetLeft);
- // } else {
- // _lineOperator(
- // spanGroup,
- // pages,
- // sectionBreakConfig,
- // paragraphConfig,
- // paragraphStart,
- // defaultSpanLineHeight
- // );
- // }
- // } else {
- // // 不是最后一个divide
- // _divideOperator(
- // spanGroup,
- // pages,
- // sectionBreakConfig,
- // paragraphConfig,
- // paragraphStart,
- // false,
- // defaultSpanLineHeight
- // );
- // }
} else {
// w 不超过 divide 宽度,加入到 divide 中去
const currentLine = divide.parent;
@@ -280,14 +216,15 @@ function _divideOperator(
newSpanGroup = [spanGroupCached[0]];
}
const column = currentLine.parent;
- column?.lines.pop(); // Delete the previous line and recalculate according to the maximum content height
+
+ const { paragraphStart: lineIsStart } = column?.lines.pop()!; // Delete the previous line and recalculate according to the maximum content height
_lineOperator(
newSpanGroup,
pages,
sectionBreakConfig,
paragraphConfig,
- paragraphStart,
+ lineIsStart,
boundingBoxAscent + boundingBoxDescent
);
diff --git a/packages/engine-render/src/components/docs/common/tools.ts b/packages/engine-render/src/components/docs/common/tools.ts
index 5fa2feb079..27b614bdef 100644
--- a/packages/engine-render/src/components/docs/common/tools.ts
+++ b/packages/engine-render/src/components/docs/common/tools.ts
@@ -291,7 +291,6 @@ export function getCharSpaceConfig(sectionBreakConfig: ISectionBreakConfig, para
};
}
-// eslint-disable-next-line max-lines-per-function
export function updateBlockIndex(pages: IDocumentSkeletonPage[], start: number = -1) {
const firstPage = pages[0];
const { st: firstPageStartIndex } = firstPage;