Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove public enum from Content Model #2204

Merged
merged 1 commit into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import { createCheckboxFormatRenderer } from '../utils/createCheckboxFormatRende
import { createColorFormatRenderer } from '../utils/createColorFormatRender';
import { createDropDownFormatRenderer } from '../utils/createDropDownFormatRenderer';
import { FormatRenderer } from '../utils/FormatRenderer';
import { TableBorderFormat, TableMetadataFormat } from 'roosterjs-content-model-types';
import { getObjectKeys } from 'roosterjs-content-model-dom';
import { TableBorderFormat } from 'roosterjs-content-model-core';
import { TableMetadataFormat } from 'roosterjs-content-model-types';

export const TableMetadataFormatRenders: FormatRenderer<TableMetadataFormat>[] = [
createColorFormatRenderer<TableMetadataFormat>(
Expand Down Expand Up @@ -60,17 +62,20 @@ export const TableMetadataFormatRenders: FormatRenderer<TableMetadataFormat>[] =
createDropDownFormatRenderer<TableMetadataFormat, keyof typeof TableBorderFormat>(
'TableBorderFormat',
[
'DEFAULT',
'LIST_WITH_SIDE_BORDERS',
'NO_HEADER_BORDERS',
'NO_SIDE_BORDERS',
'FIRST_COLUMN_HEADER_EXTERNAL',
'ESPECIAL_TYPE_1',
'ESPECIAL_TYPE_2',
'ESPECIAL_TYPE_3',
'CLEAR',
'Default',
'ListWithSideBorders',
'NoHeaderBorders',
'NoSideBorders',
'FirstColumnHeaderExternal',
'EspecialType1',
'EspecialType2',
'EspecialType3',
'Clear',
],
format => TableBorderFormat[format.tableBorderFormat] as keyof typeof TableBorderFormat,
format =>
getObjectKeys(TableBorderFormat)[
Object.values(TableBorderFormat).indexOf(format.tableBorderFormat)
],
(format, newValue) => (format.tableBorderFormat = TableBorderFormat[newValue])
),
];
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { formatTable } from 'roosterjs-content-model-api';
import { isContentModelEditor } from 'roosterjs-content-model-editor';
import { RibbonButton } from 'roosterjs-react';
import { TableBorderFormat, TableMetadataFormat } from 'roosterjs-content-model-types';
import { TableBorderFormat } from 'roosterjs-content-model-core';
import { TableMetadataFormat } from 'roosterjs-content-model-types';

const PREDEFINED_STYLES: Record<
string,
Expand All @@ -16,7 +17,7 @@ const PREDEFINED_STYLES: Record<
false /** bandedColumns */,
false /** headerRow */,
false /** firstColumn */,
TableBorderFormat.DEFAULT /** tableBorderFormat */,
TableBorderFormat.Default /** tableBorderFormat */,
null /** bgColorEven */,
lightColor /** bgColorOdd */,
color /** headerRowColor */
Expand All @@ -30,7 +31,7 @@ const PREDEFINED_STYLES: Record<
false /** bandedColumns */,
false /** headerRow */,
false /** firstColumn */,
TableBorderFormat.DEFAULT /** tableBorderFormat */,
TableBorderFormat.Default /** tableBorderFormat */,
null /** bgColorEven */,
lightColor /** bgColorOdd */,
color /** headerRowColor */
Expand All @@ -44,7 +45,7 @@ const PREDEFINED_STYLES: Record<
false /** bandedColumns */,
false /** headerRow */,
false /** firstColumn */,
TableBorderFormat.NO_SIDE_BORDERS /** tableBorderFormat */,
TableBorderFormat.NoSideBorders /** tableBorderFormat */,
null /** bgColorEven */,
lightColor /** bgColorOdd */,
color /** headerRowColor */
Expand All @@ -58,7 +59,7 @@ const PREDEFINED_STYLES: Record<
false /** bandedColumns */,
false /** headerRow */,
false /** firstColumn */,
TableBorderFormat.DEFAULT /** tableBorderFormat */,
TableBorderFormat.Default /** tableBorderFormat */,
null /** bgColorEven */,
lightColor /** bgColorOdd */,
color /** headerRowColor */
Expand All @@ -72,7 +73,7 @@ const PREDEFINED_STYLES: Record<
false /** bandedColumns */,
false /** headerRow */,
false /** firstColumn */,
TableBorderFormat.FIRST_COLUMN_HEADER_EXTERNAL /** tableBorderFormat */,
TableBorderFormat.FirstColumnHeaderExternal /** tableBorderFormat */,
'#B0B0B0' /** bgColorEven */,
lightColor /** bgColorOdd */,
color /** headerRowColor */
Expand All @@ -86,7 +87,7 @@ const PREDEFINED_STYLES: Record<
false /** bandedColumns */,
false /** headerRow */,
false /** firstColumn */,
TableBorderFormat.LIST_WITH_SIDE_BORDERS /** tableBorderFormat */,
TableBorderFormat.ListWithSideBorders /** tableBorderFormat */,
null /** bgColorEven */,
lightColor /** bgColorOdd */,
color /** headerRowColor */
Expand All @@ -100,7 +101,7 @@ const PREDEFINED_STYLES: Record<
false /** bandedColumns */,
false /** headerRow */,
false /** firstColumn */,
TableBorderFormat.NO_HEADER_BORDERS /** tableBorderFormat */,
TableBorderFormat.NoHeaderBorders /** tableBorderFormat */,
null /** bgColorEven */,
lightColor /** bgColorOdd */,
color /** headerRowColor */
Expand All @@ -114,7 +115,7 @@ const PREDEFINED_STYLES: Record<
false /** bandedColumns */,
false /** headerRow */,
false /** firstColumn */,
TableBorderFormat.ESPECIAL_TYPE_1 /** tableBorderFormat */,
TableBorderFormat.EspecialType1 /** tableBorderFormat */,
null /** bgColorEven */,
lightColor /** bgColorOdd */,
color /** headerRowColor */
Expand All @@ -128,7 +129,7 @@ const PREDEFINED_STYLES: Record<
false /** bandedColumns */,
false /** headerRow */,
false /** firstColumn */,
TableBorderFormat.ESPECIAL_TYPE_2 /** tableBorderFormat */,
TableBorderFormat.EspecialType2 /** tableBorderFormat */,
null /** bgColorEven */,
lightColor /** bgColorOdd */,
color /** headerRowColor */
Expand All @@ -142,7 +143,7 @@ const PREDEFINED_STYLES: Record<
false /** bandedColumns */,
false /** headerRow */,
false /** firstColumn */,
TableBorderFormat.ESPECIAL_TYPE_3 /** tableBorderFormat */,
TableBorderFormat.EspecialType3 /** tableBorderFormat */,
lightColor /** bgColorEven */,
null /** bgColorOdd */,
color /** headerRowColor */
Expand All @@ -156,7 +157,7 @@ const PREDEFINED_STYLES: Record<
false /** bandedColumns */,
false /** headerRow */,
false /** firstColumn */,
TableBorderFormat.CLEAR /** tableBorderFormat */,
TableBorderFormat.Clear /** tableBorderFormat */,
lightColor /** bgColorEven */,
null /** bgColorOdd */,
color /** headerRowColor */
Expand All @@ -171,7 +172,7 @@ export function createTableFormat(
bandedColumns?: boolean,
headerRow?: boolean,
firstColumn?: boolean,
borderFormat?: TableBorderFormat,
borderFormat?: number,
bgColorEven?: string,
bgColorOdd?: string,
headerRowColor?: string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BulletListType } from 'roosterjs-content-model-types';
import { BulletListType } from 'roosterjs-content-model-core';
import { isContentModelEditor } from 'roosterjs-content-model-editor';
import { RibbonButton } from 'roosterjs-react';
import { setListStyle } from 'roosterjs-content-model-api';
Expand All @@ -21,7 +21,7 @@ export const setBulletedListStyleButton: RibbonButton<'ribbonButtonBulletedListS
iconName: 'BulletedList',
isDisabled: formatState => !formatState.isBullet,
onClick: (editor, key) => {
const value = parseInt(key) as BulletListType;
const value = parseInt(key);

if (isContentModelEditor(editor)) {
setListStyle(editor, {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isContentModelEditor } from 'roosterjs-content-model-editor';
import { NumberingListType } from 'roosterjs-content-model-types';
import { NumberingListType } from 'roosterjs-content-model-core';
import { RibbonButton } from 'roosterjs-react';
import { setListStyle } from 'roosterjs-content-model-api';

Expand Down Expand Up @@ -33,7 +33,7 @@ export const setNumberedListStyleButton: RibbonButton<'ribbonButtonNumberedListS
iconName: 'NumberedList',
isDisabled: formatState => !formatState.isNumbering,
onClick: (editor, key) => {
const value = parseInt(key) as NumberingListType;
const value = parseInt(key);

if (isContentModelEditor(editor)) {
setListStyle(editor, {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* Enum used to control the different types of bullet list
*/
export const BulletListType = {
/**
* Minimum value of the enum
*/
Min: 1,
/**
* Bullet triggered by *
*/
Disc: 1,
/**
* Bullet triggered by -
*/
Dash: 2,
/**
* Bullet triggered by --
*/
Square: 3,
/**
* Bullet triggered by >
*/
ShortArrow: 4,
/**
* Bullet triggered by ->
*/
LongArrow: 5,
/**
* Bullet triggered by =>
*/
UnfilledArrow: 6,
/**
* Bullet triggered by —
*/
Hyphen: 7,
/**
* Bullet triggered by -->
*/
DoubleLongArrow: 8,
/**
* Bullet type circle
*/
Circle: 9,
/**
* Maximum value of the enum
*/
Max: 9,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/**
* Enum used to control the different types of numbering list
*/
export const NumberingListType = {
/**
* Minimum value of the enum
*/
Min: 1,
/**
* Numbering triggered by 1.
*/
Decimal: 1,
/**
* Numbering triggered by 1-
*/
DecimalDash: 2,
/**
* Numbering triggered by 1)
*/
DecimalParenthesis: 3,
/**
* Numbering triggered by (1)
*/
DecimalDoubleParenthesis: 4,
/**
* Numbering triggered by a.
*/
LowerAlpha: 5,
/**
* Numbering triggered by a)
*/
LowerAlphaParenthesis: 6,
/**
* Numbering triggered by (a)
*/
LowerAlphaDoubleParenthesis: 7,
/**
* Numbering triggered by a-
*/
LowerAlphaDash: 8,
/**
* Numbering triggered by A.
*/
UpperAlpha: 9,
/**
* Numbering triggered by A)
*/
UpperAlphaParenthesis: 10,
/**
* Numbering triggered by (A)
*/
UpperAlphaDoubleParenthesis: 11,
/**
* Numbering triggered by A-
*/
UpperAlphaDash: 12,
/**
* Numbering triggered by i.
*/
LowerRoman: 13,
/**
* Numbering triggered by i)
*/
LowerRomanParenthesis: 14,
/**
* Numbering triggered by (i)
*/
LowerRomanDoubleParenthesis: 15,
/**
* Numbering triggered by i-
*/
LowerRomanDash: 16,
/**
* Numbering triggered by I.
*/
UpperRoman: 17,
/**
* Numbering triggered by I)
*/
UpperRomanParenthesis: 18,
/**
* Numbering triggered by (I)
*/
UpperRomanDoubleParenthesis: 19,
/**
* Numbering triggered by I-
*/
UpperRomanDash: 20,
/**
* Maximum value of the enum
*/
Max: 20,
};
Loading
Loading