Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | 1x 1x 1x 1x 1x 1x 21x 1x 230x | import { BulletListType } from '../../constants/BulletListType';
import { getMetadata, updateMetadata } from './updateMetadata';
import { NumberingListType } from '../../constants/NumberingListType';
import {
createBooleanDefinition,
createNumberDefinition,
createObjectDefinition,
} from './definitionCreators';
import type {
ListMetadataFormat,
ObjectDefinition,
ReadonlyContentModelWithDataset,
ShallowMutableContentModelWithDataset,
} from 'roosterjs-content-model-types';
/**
* Metadata definition for List
*/
export const ListMetadataDefinition: ObjectDefinition<ListMetadataFormat> = createObjectDefinition<
ListMetadataFormat
>(
{
orderedStyleType: createNumberDefinition(
true /** isOptional */,
undefined /** value **/,
NumberingListType.Min,
NumberingListType.Max
),
unorderedStyleType: createNumberDefinition(
true /** isOptional */,
undefined /** value **/,
BulletListType.Min,
BulletListType.Max
),
applyListStyleFromLevel: createBooleanDefinition(true /*isOptional*/),
},
true /** isOptional */,
true /** allowNull */
);
/**
* Get list metadata
* @param list The list Content Model (metadata holder)
*/
export function getListMetadata(
list: ReadonlyContentModelWithDataset<ListMetadataFormat>
): ListMetadataFormat | null {
return getMetadata(list, ListMetadataDefinition);
}
/**
* Update list metadata with a callback
* @param list The list Content Model (metadata holder)
* @param callback The callback function used for updating metadata
*/
export function updateListMetadata(
list: ShallowMutableContentModelWithDataset<ListMetadataFormat>,
callback?: (format: ListMetadataFormat | null) => ListMetadataFormat | null
): ListMetadataFormat | null {
return updateMetadata(list, callback, ListMetadataDefinition);
}
|