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): list update (#2862)

Univerb045042001c9
diff --git a/packages/core/src/docs/data-model/preset-list-type.ts b/packages/core/src/docs/data-model/preset-list-type.ts
index 89124d0938..ff48f01095 100644
--- a/packages/core/src/docs/data-model/preset-list-type.ts
+++ b/packages/core/src/docs/data-model/preset-list-type.ts
@@ -34,8 +34,10 @@ export const PRESET_LIST_TYPE = {
},
startNumber: 0,
glyphSymbol: '\u25CF',
- hanging: { v: 21 },
- indentStart: { v: 21 },
+ paragraphProperties: {
+ hanging: { v: 21 },
+ indentStart: { v: 21 },
+ },
},
{
bulletAlignment: BulletAlignment.START,
@@ -45,8 +47,10 @@ export const PRESET_LIST_TYPE = {
},
startNumber: 0,
glyphSymbol: '\u25A0',
- hanging: { v: 21 },
- indentStart: { v: 42 },
+ paragraphProperties: {
+ hanging: { v: 21 },
+ indentStart: { v: 42 },
+ },
},
{
bulletAlignment: BulletAlignment.START,
@@ -56,8 +60,10 @@ export const PRESET_LIST_TYPE = {
},
startNumber: 0,
glyphSymbol: '\u25C6',
- hanging: { v: 21 },
- indentStart: { v: 63 },
+ paragraphProperties: {
+ hanging: { v: 21 },
+ indentStart: { v: 63 },
+ },
},
] as INestingLevel[],
} as IListData,
@@ -72,8 +78,10 @@ export const PRESET_LIST_TYPE = {
},
startNumber: 0,
glyphType: GlyphType.DECIMAL,
- hanging: { v: 21 },
- indentStart: { v: 21 },
+ paragraphProperties: {
+ hanging: { v: 21 },
+ indentStart: { v: 21 },
+ },
},
{
bulletAlignment: BulletAlignment.START,
@@ -83,8 +91,10 @@ export const PRESET_LIST_TYPE = {
},
startNumber: 0,
glyphType: GlyphType.DECIMAL,
- hanging: { v: 21 },
- indentStart: { v: 42 },
+ paragraphProperties: {
+ hanging: { v: 21 },
+ indentStart: { v: 42 },
+ },
},
{
bulletAlignment: BulletAlignment.START,
@@ -94,8 +104,10 @@ export const PRESET_LIST_TYPE = {
},
startNumber: 0,
glyphType: GlyphType.DECIMAL,
- hanging: { v: 21 },
- indentStart: { v: 63 },
+ paragraphProperties: {
+ hanging: { v: 21 },
+ indentStart: { v: 63 },
+ },
},
] as INestingLevel[],
} as IListData,
diff --git a/packages/core/src/types/enum/text-style.ts b/packages/core/src/types/enum/text-style.ts
index cbe0f8be45..4aff53bf2b 100644
--- a/packages/core/src/types/enum/text-style.ts
+++ b/packages/core/src/types/enum/text-style.ts
@@ -54,6 +54,8 @@ export enum HorizontalAlign {
CENTER, // The text is explicitly aligned to the center of the cell.
RIGHT, // The text is explicitly aligned to the right of the cell.
JUSTIFIED, // The paragraph is justified.
+ BOTH, // The paragraph is justified.
+ DISTRIBUTED, // The text is distributed across the width of the cell.
}
/**
diff --git a/packages/core/src/types/interfaces/i-document-data.ts b/packages/core/src/types/interfaces/i-document-data.ts
index e1cab4b4c6..312152146d 100644
--- a/packages/core/src/types/interfaces/i-document-data.ts
+++ b/packages/core/src/types/interfaces/i-document-data.ts
@@ -181,17 +181,19 @@ export interface IListData {
/**
* Contains properties describing the look and feel of a list bullet at a given level of nesting.
*/
-export interface INestingLevel extends IIndentStart {
- bulletAlignment: BulletAlignment; // ordered list support
+export interface INestingLevel {
+ paragraphProperties?: IParagraphProperties;
+
+ bulletAlignment: BulletAlignment; // ordered list support lvlJc
// The glyph format contains one or more placeholders, and these placeholder are replaced with the appropriate values depending on the glyphType or glyphSymbol. The placeholders follow the pattern %[nestingLevel]. Furthermore, placeholders can have prefixes and suffixes. Thus, the glyph format follows the pattern <prefix>%[nestingLevel]<suffix>. Note that the prefix and suffix are optional and can be arbitrary strings.
// <prefix>%[nestingLevel]<suffix>
glyphFormat: string; // https://developers.google.com/docs/api/reference/rest/v1/documents#nestinglevel,ms word lvlText
- textStyle: ITextStyle;
+ textStyle?: ITextStyle;
startNumber: number;
// Union field glyph_kind can be only one of the following:
- glyphType?: GlyphType | string; // ordered list string is to support custom rules https://developers.google.com/docs/api/reference/rest/v1/documents#glyphtype, ms numFmt: GlyphType | string
+ glyphType?: GlyphType; // ordered list string is to support custom rules https://developers.google.com/docs/api/reference/rest/v1/documents#glyphtype, ms numFmt: GlyphType
glyphSymbol?: string; // the tag of the unordered list
// End of list of possible types for union field glyph_kind.
}
@@ -209,14 +211,72 @@ export enum FollowNumberWithType {
* An enumeration of the supported glyph types.
*/
export enum GlyphType {
- GLYPH_TYPE_UNSPECIFIED, // The glyph type is unspecified or unsupported.
+ BULLET, // The glyph type is unspecified or unsupported.
NONE, // An empty string.
DECIMAL, // A number, like 1, 2, or 3.
- ZERO_DECIMAL, // 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.
- UPPER_ALPHA, // An uppercase letter, like A, B, or C.
- ALPHA, // A lowercase letter, like a, b, or c.
+ DECIMAL_ZERO, // 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.
+ UPPER_LETTER, // An uppercase letter, like A, B, or C.
+ LOWER_LETTER, // A lowercase letter, like a, b, or c.
UPPER_ROMAN, // An uppercase Roman numeral, like I, II, or III.
- ROMAN, // A lowercase Roman numeral, like i, ii, or iii.
+ LOWER_ROMAN, // A lowercase Roman numeral, like i, ii, or iii.
+
+ /**
+ * Not yet achieved, aligned with Excel's standards.
+ * 17.18.59 ST_NumberFormat (Numbering Format)
+ */
+ ORDINAL = 8,
+ CARDINAL_TEXT = 9,
+ ORDINAL_TEXT = 10,
+ HEX = 11,
+ CHICAGO = 12,
+ IDEOGRAPH_DIGITAL = 13,
+ JAPANESE_COUNTING = 14,
+ AIUEO = 15,
+ IROHA = 16,
+ DECIMAL_FULL_WIDTH = 17,
+ DECIMAL_HALF_WIDTH = 18,
+ JAPANESE_LEGAL = 19,
+ JAPANESE_DIGITAL_TEN_THOUSAND = 20,
+ DECIMAL_ENCLOSED_CIRCLE = 21,
+ DECIMAL_FULL_WIDTH2 = 22,
+ AIUEO_FULL_WIDTH = 23,
+ IROHA_FULL_WIDTH = 24,
+ GANADA = 25,
+ CHOSUNG = 26,
+ DECIMAL_ENCLOSED_FULLSTOP = 27,
+ DECIMAL_ENCLOSED_PAREN = 28,
+ DECIMAL_ENCLOSED_CIRCLE_CHINESE = 29,
+ IDEOGRAPH_ENCLOSED_CIRCLE = 30,
+ IDEOGRAPH_TRADITIONAL = 31,
+ IDEOGRAPH_ZODIAC = 32,
+ IDEOGRAPH_ZODIAC_TRADITIONAL = 33,
+ TAIWANESE_COUNTING = 34,
+ IDEOGRAPH_LEGAL_TRADITIONAL = 35,
+ TAIWANESE_COUNTING_THOUSAND = 36,
+ TAIWANESE_DIGITAL = 37,
+ CHINESE_COUNTING = 38,
+ CHINESE_LEGAL_SIMPLIFIED = 39,
+ CHINESE_COUNTING_THOUSAND = 40,
+ KOREAN_DIGITAL = 41,
+ KOREAN_COUNTING = 42,
+ KOREAN_LEGAL = 43,
+ KOREAN_DIGITAL2 = 44,
+ VIETNAMESE_COUNTING = 45,
+ RUSSIAN_LOWER = 46,
+ RUSSIAN_UPPER = 47,
+ NUMBER_IN_DASH = 48,
+ HEBREW1 = 49,
+ HEBREW2 = 50,
+ ARABIC_ALPHA = 51,
+ ARABIC_ABJAD = 52,
+ HINDI_VOWELS = 53,
+ HINDI_CONSONANTS = 54,
+ HINDI_NUMBERS = 55,
+ HINDI_COUNTING = 56,
+ THAI_LETTERS = 57,
+ THAI_NUMBERS = 58,
+ THAI_COUNTING = 59,
+ CUSTOM = 60,
}
/**
@@ -227,6 +287,9 @@ export enum BulletAlignment {
START, // The bullet is aligned to the start of the space allotted for rendering the bullet. Left-aligned for LTR text, right-aligned otherwise.
CENTER, // The bullet is aligned to the center of the space allotted for rendering the bullet.
END, // The bullet is aligned to the end of the space allotted for rendering the bullet. Right-aligned for LTR text, left-aligned otherwise.
+
+ //Not achieved, aligned with Excel's standards.
+ BOTH, // The bullet is aligned such that it is equidistant from both the start and end of the space allotted for rendering the bullet.
}
// /**
@@ -536,7 +599,7 @@ export interface IBullet {
listType: string; // listType orderList or bulletList etc.
listId: string; // listId
nestingLevel: number; // nestingLevel
- textStyle: ITextStyle; // textStyle
+ textStyle?: ITextStyle; // textStyle
}
/**
@@ -635,12 +698,18 @@ export interface IIndentStart {
hanging?: INumberUnit ; // hanging,offset of first word except first line
indentStart?: INumberUnit ; // indentStart
tabStops?: ITabStop[]; // tabStops
+ indentEnd?: INumberUnit ; // indentEnd
}
/**
* Properties of paragraph style
*/
-export interface IParagraphStyle extends IIndentStart {
+export interface IParagraphStyle extends IParagraphProperties {
+ // Not achieved, aligned with Excel's standards.
+ textStyle?: ITextStyle; // paragraph textStyle
+}
+
+export interface IParagraphProperties extends IIndentStart {
headingId?: string; // headingId
namedStyleType?: NamedStyleType; // namedStyleType
horizontalAlign?: HorizontalAlign; // Horizontal alignment
@@ -655,7 +724,6 @@ export interface IParagraphStyle extends IIndentStart {
borderBottom?: IParagraphBorder; // borderBottom
borderLeft?: IParagraphBorder; // borderLeft
borderRight?: IParagraphBorder; // borderRight
- indentEnd?: INumberUnit ; // indentEnd
keepLines?: BooleanNumber; // 17.3.1.14 keepLines (Keep All Lines On One Page)
keepNext?: BooleanNumber; // 17.3.1.15 keepNext (Keep Paragraph With Next Paragraph)
wordWrap?: BooleanNumber; // 17.3.1.45 wordWrap (Allow Line Breaking At Character Level)
diff --git a/packages/docs/src/commands/commands/list.command.ts b/packages/docs/src/commands/commands/list.command.ts
index 7f06464759..caf6a93011 100644
--- a/packages/docs/src/commands/commands/list.command.ts
+++ b/packages/docs/src/commands/commands/list.command.ts
@@ -122,7 +122,8 @@ export const ListOperationCommand: ICommand<IListOperationCommandParams> = {
for (const paragraph of currentParagraphs) {
const { startIndex, paragraphStyle = {} } = paragraph;
const { indentFirstLine, snapToGrid, indentStart } = paragraphStyle;
- const { hanging: listHanging, indentStart: listIndentStart } = lists[listType].nestingLevel[0];
+ const paragraphProperties = lists[listType].nestingLevel[0].paragraphProperties || {};
+ const { hanging: listHanging, indentStart: listIndentStart } = paragraphProperties;
const { charSpace, gridType } = findNearestSectionBreak(startIndex, sectionBreaks) || { charSpace: 0, gridType: GridType.LINES };
const charSpaceApply = getCharSpaceApply(charSpace, defaultTabStop, gridType, snapToGrid);
diff --git a/packages/engine-render/src/basics/i-document-skeleton-cached.ts b/packages/engine-render/src/basics/i-document-skeleton-cached.ts
index 646c86ff43..4434fc4a90 100644
--- a/packages/engine-render/src/basics/i-document-skeleton-cached.ts
+++ b/packages/engine-render/src/basics/i-document-skeleton-cached.ts
@@ -20,8 +20,8 @@ import type {
DataStreamTreeTokenType,
IDocDrawingBase,
IDocumentRenderConfig,
- IIndentStart,
INestingLevel,
+ IParagraphProperties,
ITextStyle,
PageOrientType,
} from '@univerjs/core';
@@ -196,7 +196,7 @@ export interface IDocumentSkeletonGlyph {
drawingId?: string; // drawing.drawingId
}
-export interface IDocumentSkeletonBullet extends IIndentStart {
+export interface IDocumentSkeletonBullet {
listId: string; // listId
symbol: string; // symbol 列表的内容
ts: ITextStyle; // 文字样式
@@ -206,6 +206,7 @@ export interface IDocumentSkeletonBullet extends IIndentStart {
nestingLevel?: INestingLevel;
bulletAlign?: BulletAlignment;
bulletType?: boolean; // bulletType false unordered, true ordered;
+ paragraphProperties?: IParagraphProperties;
// bp: number; // bulletPosition 列表离页边的距离
// ti: number; // textIndent 内容距列表的距离,取Max(textIndent, followWith+)
// fw: number; // followWidth 内容距离列表的间隔距离
diff --git a/packages/engine-render/src/components/docs/layout/block/paragraph/bullet-ruler.ts b/packages/engine-render/src/components/docs/layout/block/paragraph/bullet-ruler.ts
index 904b772f14..3c604c165f 100644
--- a/packages/engine-render/src/components/docs/layout/block/paragraph/bullet-ruler.ts
+++ b/packages/engine-render/src/components/docs/layout/block/paragraph/bullet-ruler.ts
@@ -29,19 +29,19 @@ function generateOrderedSymbol(startIndex: number, startNumber: number, glyphTyp
if (glyphType === GlyphType.DECIMAL) {
return decimal(startIndex, startNumber);
}
- if (glyphType === GlyphType.ZERO_DECIMAL) {
+ if (glyphType === GlyphType.DECIMAL_ZERO) {
return zeroDecimal(startIndex, startNumber);
}
- if (glyphType === GlyphType.UPPER_ALPHA) {
+ if (glyphType === GlyphType.UPPER_LETTER) {
return upperAlpha(startIndex, startNumber);
}
- if (glyphType === GlyphType.ALPHA) {
+ if (glyphType === GlyphType.LOWER_LETTER) {
return alpha(startIndex, startNumber);
}
if (glyphType === GlyphType.UPPER_ROMAN) {
return upperRoman(startIndex, startNumber);
}
- if (glyphType === GlyphType.ROMAN) {
+ if (glyphType === GlyphType.LOWER_ROMAN) {
return roman(startIndex, startNumber);
}
diff --git a/packages/engine-render/src/components/docs/layout/block/paragraph/bullet.ts b/packages/engine-render/src/components/docs/layout/block/paragraph/bullet.ts
index 476b159e88..1d6e956db8 100644
--- a/packages/engine-render/src/components/docs/layout/block/paragraph/bullet.ts
+++ b/packages/engine-render/src/components/docs/layout/block/paragraph/bullet.ts
@@ -78,9 +78,11 @@ export function getDefaultBulletSke(listId: string, startIndex: number = 1): IDo
spr: 0.5,
spo: 0,
},
- indentFirstLine: { v: 0 },
- hanging: { v: 21 },
- indentStart: { v: 0 },
+ paragraphProperties: {
+ indentFirstLine: { v: 0 },
+ hanging: { v: 21 },
+ indentStart: { v: 0 },
+ },
};
}
@@ -96,13 +98,10 @@ function _getBulletSke(
const {
bulletAlignment,
glyphFormat,
- textStyle: textStyleFirst,
+ textStyle: textStyleFirst = {},
startNumber,
glyphType,
glyphSymbol,
- indentFirstLine,
- hanging,
- indentStart,
} = nesting;
const textStyle = { ...textStyleConfig, ...textStyleFirst };
@@ -131,9 +130,7 @@ function _getBulletSke(
nestingLevel: nesting,
bulletAlign: bulletAlignment,
bulletType: glyphSymbol ? false : !!glyphType, // 默认是无序列表,假如glyphSymbol为空且glyphType不为空才是有序列表
- indentFirstLine,
- hanging,
- indentStart,
+ paragraphProperties: nesting.paragraphProperties,
};
}
diff --git a/packages/engine-render/src/components/docs/layout/block/paragraph/layout-ruler.ts b/packages/engine-render/src/components/docs/layout/block/paragraph/layout-ruler.ts
index 1b88d9f36d..9b257971c8 100644
--- a/packages/engine-render/src/components/docs/layout/block/paragraph/layout-ruler.ts
+++ b/packages/engine-render/src/components/docs/layout/block/paragraph/layout-ruler.ts
@@ -72,6 +72,13 @@ export function layoutParagraph(
// 如果是一个段落的开头,需要加入bullet
const { gridType = GridType.LINES, charSpace = 0, defaultTabStop = 10.5 } = sectionBreakConfig;
+ const paragraphProperties = bulletSkeleton.paragraphProperties || {};
+
+ paragraphConfig.paragraphStyle = {
+ ...paragraphConfig.paragraphStyle,
+ ...paragraphProperties,
+ };
+
const { snapToGrid = BooleanNumber.TRUE } = paragraphStyle;
const charSpaceApply = getCharSpaceApply(charSpace, defaultTabStop, gridType, snapToGrid);