Skip to content

Commit

Permalink
fix: dup list glyph type name
Browse files Browse the repository at this point in the history
  • Loading branch information
Jocs committed Nov 28, 2024
1 parent 1a9f83d commit d123405
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 73 deletions.
110 changes: 55 additions & 55 deletions packages/core/src/docs/data-model/preset-list-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import type { IListData, INestingLevel, ITextStyle } from '../../types/interfaces/i-document-data';
import { Tools } from '../../shared';
import { BooleanNumber } from '../../types/enum';
import { BulletAlignment, GlyphType } from '../../types/interfaces/i-document-data';
import { BulletAlignment, ListGlyphType } from '../../types/interfaces/i-document-data';

export enum QuickListType {
ORDER_LIST_QUICK_1 = '1.',
Expand Down Expand Up @@ -73,12 +73,12 @@ export enum PresetListType {
}

const orderListSymbolMap = {
'a)': { glyphFormat: '%1)', glyphType: GlyphType.DECIMAL },
'1.': { glyphFormat: '%1.', glyphType: GlyphType.DECIMAL },
'a.': { glyphFormat: '%1.', glyphType: GlyphType.LOWER_LETTER },
'A.': { glyphFormat: '%1.', glyphType: GlyphType.UPPER_LETTER },
'i.': { glyphFormat: '%1.', glyphType: GlyphType.LOWER_ROMAN },
'I.': { glyphFormat: '%1.', glyphType: GlyphType.UPPER_LETTER },
'a)': { glyphFormat: '%1)', glyphType: ListGlyphType.DECIMAL },
'1.': { glyphFormat: '%1.', glyphType: ListGlyphType.DECIMAL },
'a.': { glyphFormat: '%1.', glyphType: ListGlyphType.LOWER_LETTER },
'A.': { glyphFormat: '%1.', glyphType: ListGlyphType.UPPER_LETTER },
'i.': { glyphFormat: '%1.', glyphType: ListGlyphType.LOWER_ROMAN },
'I.': { glyphFormat: '%1.', glyphType: ListGlyphType.UPPER_LETTER },
};

type BulletSymbols = [string, string, string];
Expand All @@ -102,7 +102,7 @@ const bulletListFactory = (symbols: BulletSymbols): INestingLevel[] => {
}));
};

const orderListFactory = (options: { glyphFormat: string; glyphType: GlyphType }[]): INestingLevel[] => {
const orderListFactory = (options: { glyphFormat: string; glyphType: ListGlyphType }[]): INestingLevel[] => {
return options.map((format, i) => ({
...format,
bulletAlignment: BulletAlignment.START,
Expand Down Expand Up @@ -163,29 +163,29 @@ export const PRESET_LIST_TYPE: Record<string, IListData> = {
[PresetListType.ORDER_LIST]: {
listType: PresetListType.ORDER_LIST,
nestingLevel: orderListFactory([
{ glyphFormat: '%1.', glyphType: GlyphType.DECIMAL },
{ glyphFormat: '%2.', glyphType: GlyphType.LOWER_LETTER },
{ glyphFormat: '%3.', glyphType: GlyphType.LOWER_ROMAN },
{ glyphFormat: '%4.', glyphType: GlyphType.DECIMAL },
{ glyphFormat: '%5.', glyphType: GlyphType.LOWER_LETTER },
{ glyphFormat: '%6.', glyphType: GlyphType.LOWER_ROMAN },
{ glyphFormat: '%7.', glyphType: GlyphType.DECIMAL },
{ glyphFormat: '%8.', glyphType: GlyphType.LOWER_LETTER },
{ glyphFormat: '%9.', glyphType: GlyphType.LOWER_ROMAN },
{ glyphFormat: '%1.', glyphType: ListGlyphType.DECIMAL },
{ glyphFormat: '%2.', glyphType: ListGlyphType.LOWER_LETTER },
{ glyphFormat: '%3.', glyphType: ListGlyphType.LOWER_ROMAN },
{ glyphFormat: '%4.', glyphType: ListGlyphType.DECIMAL },
{ glyphFormat: '%5.', glyphType: ListGlyphType.LOWER_LETTER },
{ glyphFormat: '%6.', glyphType: ListGlyphType.LOWER_ROMAN },
{ glyphFormat: '%7.', glyphType: ListGlyphType.DECIMAL },
{ glyphFormat: '%8.', glyphType: ListGlyphType.LOWER_LETTER },
{ glyphFormat: '%9.', glyphType: ListGlyphType.LOWER_ROMAN },
]),
} as IListData,
[PresetListType.ORDER_LIST_1]: {
listType: PresetListType.ORDER_LIST,
nestingLevel: orderListFactory([
{ glyphFormat: '%1)', glyphType: GlyphType.DECIMAL },
{ glyphFormat: '%2)', glyphType: GlyphType.LOWER_LETTER },
{ glyphFormat: '%3)', glyphType: GlyphType.LOWER_ROMAN },
{ glyphFormat: '%4)', glyphType: GlyphType.DECIMAL },
{ glyphFormat: '%5)', glyphType: GlyphType.LOWER_LETTER },
{ glyphFormat: '%6)', glyphType: GlyphType.LOWER_ROMAN },
{ glyphFormat: '%7)', glyphType: GlyphType.DECIMAL },
{ glyphFormat: '%8)', glyphType: GlyphType.LOWER_LETTER },
{ glyphFormat: '%9)', glyphType: GlyphType.LOWER_ROMAN },
{ glyphFormat: '%1)', glyphType: ListGlyphType.DECIMAL },
{ glyphFormat: '%2)', glyphType: ListGlyphType.LOWER_LETTER },
{ glyphFormat: '%3)', glyphType: ListGlyphType.LOWER_ROMAN },
{ glyphFormat: '%4)', glyphType: ListGlyphType.DECIMAL },
{ glyphFormat: '%5)', glyphType: ListGlyphType.LOWER_LETTER },
{ glyphFormat: '%6)', glyphType: ListGlyphType.LOWER_ROMAN },
{ glyphFormat: '%7)', glyphType: ListGlyphType.DECIMAL },
{ glyphFormat: '%8)', glyphType: ListGlyphType.LOWER_LETTER },
{ glyphFormat: '%9)', glyphType: ListGlyphType.LOWER_ROMAN },
]),
} as IListData,
[PresetListType.ORDER_LIST_2]: {
Expand All @@ -198,48 +198,48 @@ export const PRESET_LIST_TYPE: Record<string, IListData> = {
'%1.%2.%3.%4.%5.',
'%1.%2.%3.%4.%5.%6.',
'%1.%2.%3.%4.%5.%6.%7.',
].map((format) => ({ glyphFormat: format, glyphType: GlyphType.DECIMAL }))),
].map((format) => ({ glyphFormat: format, glyphType: ListGlyphType.DECIMAL }))),
} as IListData,
[PresetListType.ORDER_LIST_3]: {
listType: PresetListType.ORDER_LIST,
nestingLevel: orderListFactory([
{ glyphFormat: '%1.', glyphType: GlyphType.UPPER_LETTER },
{ glyphFormat: '%2.', glyphType: GlyphType.LOWER_LETTER },
{ glyphFormat: '%3.', glyphType: GlyphType.LOWER_ROMAN },
{ glyphFormat: '%4.', glyphType: GlyphType.UPPER_LETTER },
{ glyphFormat: '%5.', glyphType: GlyphType.LOWER_LETTER },
{ glyphFormat: '%6.', glyphType: GlyphType.LOWER_ROMAN },
{ glyphFormat: '%7.', glyphType: GlyphType.UPPER_LETTER },
{ glyphFormat: '%8.', glyphType: GlyphType.LOWER_LETTER },
{ glyphFormat: '%9.', glyphType: GlyphType.LOWER_ROMAN },
{ glyphFormat: '%1.', glyphType: ListGlyphType.UPPER_LETTER },
{ glyphFormat: '%2.', glyphType: ListGlyphType.LOWER_LETTER },
{ glyphFormat: '%3.', glyphType: ListGlyphType.LOWER_ROMAN },
{ glyphFormat: '%4.', glyphType: ListGlyphType.UPPER_LETTER },
{ glyphFormat: '%5.', glyphType: ListGlyphType.LOWER_LETTER },
{ glyphFormat: '%6.', glyphType: ListGlyphType.LOWER_ROMAN },
{ glyphFormat: '%7.', glyphType: ListGlyphType.UPPER_LETTER },
{ glyphFormat: '%8.', glyphType: ListGlyphType.LOWER_LETTER },
{ glyphFormat: '%9.', glyphType: ListGlyphType.LOWER_ROMAN },
]),
} as IListData,
[PresetListType.ORDER_LIST_4]: {
listType: PresetListType.ORDER_LIST,
nestingLevel: orderListFactory([
{ glyphFormat: '%1.', glyphType: GlyphType.UPPER_LETTER },
{ glyphFormat: '%2.', glyphType: GlyphType.DECIMAL },
{ glyphFormat: '%3.', glyphType: GlyphType.LOWER_ROMAN },
{ glyphFormat: '%4.', glyphType: GlyphType.UPPER_LETTER },
{ glyphFormat: '%5.', glyphType: GlyphType.DECIMAL },
{ glyphFormat: '%6.', glyphType: GlyphType.LOWER_ROMAN },
{ glyphFormat: '%7.', glyphType: GlyphType.UPPER_LETTER },
{ glyphFormat: '%8.', glyphType: GlyphType.DECIMAL },
{ glyphFormat: '%9.', glyphType: GlyphType.LOWER_ROMAN },
{ glyphFormat: '%1.', glyphType: ListGlyphType.UPPER_LETTER },
{ glyphFormat: '%2.', glyphType: ListGlyphType.DECIMAL },
{ glyphFormat: '%3.', glyphType: ListGlyphType.LOWER_ROMAN },
{ glyphFormat: '%4.', glyphType: ListGlyphType.UPPER_LETTER },
{ glyphFormat: '%5.', glyphType: ListGlyphType.DECIMAL },
{ glyphFormat: '%6.', glyphType: ListGlyphType.LOWER_ROMAN },
{ glyphFormat: '%7.', glyphType: ListGlyphType.UPPER_LETTER },
{ glyphFormat: '%8.', glyphType: ListGlyphType.DECIMAL },
{ glyphFormat: '%9.', glyphType: ListGlyphType.LOWER_ROMAN },
]),
} as IListData,
[PresetListType.ORDER_LIST_5]: {
listType: PresetListType.ORDER_LIST,
nestingLevel: orderListFactory([
{ glyphFormat: '%1.', glyphType: GlyphType.DECIMAL_ZERO },
{ glyphFormat: '%2.', glyphType: GlyphType.LOWER_LETTER },
{ glyphFormat: '%3.', glyphType: GlyphType.LOWER_ROMAN },
{ glyphFormat: '%4.', glyphType: GlyphType.DECIMAL_ZERO },
{ glyphFormat: '%5.', glyphType: GlyphType.LOWER_LETTER },
{ glyphFormat: '%6.', glyphType: GlyphType.LOWER_ROMAN },
{ glyphFormat: '%7.', glyphType: GlyphType.DECIMAL_ZERO },
{ glyphFormat: '%8.', glyphType: GlyphType.LOWER_LETTER },
{ glyphFormat: '%9.', glyphType: GlyphType.LOWER_ROMAN },
{ glyphFormat: '%1.', glyphType: ListGlyphType.DECIMAL_ZERO },
{ glyphFormat: '%2.', glyphType: ListGlyphType.LOWER_LETTER },
{ glyphFormat: '%3.', glyphType: ListGlyphType.LOWER_ROMAN },
{ glyphFormat: '%4.', glyphType: ListGlyphType.DECIMAL_ZERO },
{ glyphFormat: '%5.', glyphType: ListGlyphType.LOWER_LETTER },
{ glyphFormat: '%6.', glyphType: ListGlyphType.LOWER_ROMAN },
{ glyphFormat: '%7.', glyphType: ListGlyphType.DECIMAL_ZERO },
{ glyphFormat: '%8.', glyphType: ListGlyphType.LOWER_LETTER },
{ glyphFormat: '%9.', glyphType: ListGlyphType.LOWER_ROMAN },
]),
} as IListData,

Expand All @@ -260,7 +260,7 @@ export const PRESET_LIST_TYPE: Record<string, IListData> = {
} as IListData,
};

const generateOrderList = (opt: { glyphFormat: string; glyphType: GlyphType }) => {
const generateOrderList = (opt: { glyphFormat: string; glyphType: ListGlyphType }) => {
const { glyphFormat, glyphType } = opt;

const data = Tools.deepClone(PRESET_LIST_TYPE[PresetListType.ORDER_LIST]);
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/types/interfaces/i-document-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export interface INestingLevel {
startNumber: number;

// Union field glyph_kind can be only one of the following:
glyphType?: GlyphType; // ordered list string is to support custom rules https://developers.google.com/docs/api/reference/rest/v1/documents#glyphtype, ms numFmt: GlyphType
glyphType?: ListGlyphType; // 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.
}
Expand All @@ -214,7 +214,7 @@ export enum FollowNumberWithType {
/**
* An enumeration of the supported glyph types.
*/
export enum GlyphType {
export enum ListGlyphType {
BULLET, // The glyph type is unspecified or unsupported.
NONE, // An empty string.
DECIMAL, // A number, like 1, 2, or 3.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,34 @@
* limitations under the License.
*/

import { GlyphType, numberToListABC } from '@univerjs/core';
import { ListGlyphType, numberToListABC } from '@univerjs/core';

export function getBulletOrderedSymbol(startIndex: number, startNumber: number, glyphType: GlyphType | string) {
export function getBulletOrderedSymbol(startIndex: number, startNumber: number, glyphType: ListGlyphType | string) {
// if (!(glyphType in GlyphType)) {
// return dealWidthCustomBulletOrderedSymbol(startIndex, startNumber, glyphType as string); // 插件定义更多类型的bullet
// }

return generateOrderedSymbol(startIndex, startNumber, glyphType as GlyphType);
return generateOrderedSymbol(startIndex, startNumber, glyphType as ListGlyphType);
}

function generateOrderedSymbol(startIndex: number, startNumber: number, glyphType: GlyphType) {
function generateOrderedSymbol(startIndex: number, startNumber: number, glyphType: ListGlyphType) {
// startIndex从0开始,startNumber为用户输入默认是1
if (glyphType === GlyphType.DECIMAL) {
if (glyphType === ListGlyphType.DECIMAL) {
return decimal(startIndex, startNumber);
}
if (glyphType === GlyphType.DECIMAL_ZERO) {
if (glyphType === ListGlyphType.DECIMAL_ZERO) {
return zeroDecimal(startIndex, startNumber);
}
if (glyphType === GlyphType.UPPER_LETTER) {
if (glyphType === ListGlyphType.UPPER_LETTER) {
return upperAlpha(startIndex, startNumber);
}
if (glyphType === GlyphType.LOWER_LETTER) {
if (glyphType === ListGlyphType.LOWER_LETTER) {
return alpha(startIndex, startNumber);
}
if (glyphType === GlyphType.UPPER_ROMAN) {
if (glyphType === ListGlyphType.UPPER_ROMAN) {
return upperRoman(startIndex, startNumber);
}
if (glyphType === GlyphType.LOWER_ROMAN) {
if (glyphType === ListGlyphType.LOWER_ROMAN) {
return roman(startIndex, startNumber);
}

Expand Down
12 changes: 6 additions & 6 deletions packages/engine-render/src/components/docs/layout/model/glyph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@
* limitations under the License.
*/

import { BooleanNumber, BulletAlignment, DataStreamTreeTokenType as DT, GridType } from '@univerjs/core';

import { GlyphType } from '../../../../basics/i-document-skeleton-cached';
import { hasCJK, hasCJKText, isCjkCenterAlignedPunctuation, isCjkLeftAlignedPunctuation, isCjkRightAlignedPunctuation, ptToPixel } from '../../../../basics/tools';
import { FontCache } from '../shaping-engine/font-cache';
import { validationGrid } from '../tools';
import type {
IAdjustability,
IDocumentSkeletonBoundingBox,
IDocumentSkeletonBullet,
IDocumentSkeletonDivide,
IDocumentSkeletonGlyph,
} from '../../../../basics/i-document-skeleton-cached';

import type { IFontCreateConfig } from '../../../../basics/interfaces';
import type { IOpenTypeGlyphInfo } from '../shaping-engine/text-shaping';
import { BooleanNumber, BulletAlignment, DataStreamTreeTokenType as DT, GridType } from '@univerjs/core';
import { GlyphType } from '../../../../basics/i-document-skeleton-cached';
import { hasCJK, hasCJKText, isCjkCenterAlignedPunctuation, isCjkLeftAlignedPunctuation, isCjkRightAlignedPunctuation, ptToPixel } from '../../../../basics/tools';
import { FontCache } from '../shaping-engine/font-cache';
import { validationGrid } from '../tools';

export function isSpace(char: string) {
const SPACE_CHARS = [' ', '\u{00A0}', ' '];
Expand Down

0 comments on commit d123405

Please sign in to comment.