From 2ede8efc1ee6f67a08572dcb0b5ac04120ee767e Mon Sep 17 00:00:00 2001 From: Jiuqing Song Date: Thu, 29 Jun 2023 16:30:52 -0700 Subject: [PATCH] Content Model code improvement 1: remove "includeRoot" (#1922) * Content Model code improvement 1 * fix build * fix build * Remove unnecessary isDarkMode * Reorganize index --- .../context/createDomToModelContext.ts | 4 +- .../lib/domToModel/domToContentModel.ts | 21 +++--- .../common/backgroundColorFormatHandler.ts | 4 +- .../segment/textColorFormatHandler.ts | 4 +- .../context/createModelToDomContext.ts | 5 +- .../context/createDomToModelContextTest.ts | 4 +- .../context/createModelToDomContextTest.ts | 4 +- .../test/domToModel/domToContentModelTest.ts | 44 +----------- .../lib/index.ts | 69 +++++++++++++++++-- .../lib/publicApi/index.ts | 46 ------------- .../lib/publicTypes/index.ts | 21 ------ .../editor/plugins/paste/linkParserTest.ts | 5 +- .../processPastedContentFromExcelTest.ts | 1 - .../paste/processPastedContentFromWacTest.ts | 2 - ...processPastedContentFromWordDesktopTest.ts | 1 - .../publicApi/segment/changeFontSizeTest.ts | 8 +-- .../lib/context/DomToModelOption.ts | 7 +- .../lib/context/EditorContext.ts | 2 +- 18 files changed, 88 insertions(+), 164 deletions(-) delete mode 100644 packages-content-model/roosterjs-content-model-editor/lib/publicApi/index.ts delete mode 100644 packages-content-model/roosterjs-content-model-editor/lib/publicTypes/index.ts diff --git a/packages-content-model/roosterjs-content-model-dom/lib/domToModel/context/createDomToModelContext.ts b/packages-content-model/roosterjs-content-model-dom/lib/domToModel/context/createDomToModelContext.ts index 7caaf8999d1..f2e8e7aa50c 100644 --- a/packages-content-model/roosterjs-content-model-dom/lib/domToModel/context/createDomToModelContext.ts +++ b/packages-content-model/roosterjs-content-model-dom/lib/domToModel/context/createDomToModelContext.ts @@ -14,9 +14,7 @@ export function createDomToModelContext( options?: DomToModelOption ): DomToModelContext { const context: DomToModelContext = { - ...(editorContext || { - isDarkMode: false, - }), + ...editorContext, blockFormat: {}, segmentFormat: {}, diff --git a/packages-content-model/roosterjs-content-model-dom/lib/domToModel/domToContentModel.ts b/packages-content-model/roosterjs-content-model-dom/lib/domToModel/domToContentModel.ts index 7ba4f7e4a50..b347c6a21b6 100644 --- a/packages-content-model/roosterjs-content-model-dom/lib/domToModel/domToContentModel.ts +++ b/packages-content-model/roosterjs-content-model-dom/lib/domToModel/domToContentModel.ts @@ -1,9 +1,10 @@ import { createContentModelDocument } from '../modelApi/creators/createContentModelDocument'; import { createDomToModelContext } from './context/createDomToModelContext'; +import { isNodeOfType } from '../domUtils/isNodeOfType'; +import { NodeType } from 'roosterjs-editor-types'; import { normalizeContentModel } from '../modelApi/common/normalizeContentModel'; import { parseFormat } from './utils/parseFormat'; import { rootDirectionFormatHandler } from '../formatHandlers/root/rootDirectionFormatHandler'; -import { safeInstanceOf } from 'roosterjs-editor-dom'; import { zoomScaleFormatHandler } from '../formatHandlers/root/zoomScaleFormatHandler'; import { ContentModelDocument, @@ -20,28 +21,22 @@ import { */ export function domToContentModel( root: HTMLElement | DocumentFragment, - editorContext: EditorContext, - option: DomToModelOption + editorContext?: EditorContext, + option?: DomToModelOption ): ContentModelDocument { - const model = createContentModelDocument(editorContext.defaultFormat); + const model = createContentModelDocument(editorContext?.defaultFormat); const context = createDomToModelContext(editorContext, option); - if (safeInstanceOf(root, 'DocumentFragment')) { - context.elementProcessors.child(model, root, context); - } else { + if (isNodeOfType(root, NodeType.Element)) { // Need to calculate direction (ltr or rtl), use it as initial value parseFormat(root, [rootDirectionFormatHandler.parse], context.blockFormat, context); // Need to calculate zoom scale value from root element, use this value to calculate sizes for elements parseFormat(root, [zoomScaleFormatHandler.parse], context.zoomScaleFormat, context); - - const processor = option.includeRoot - ? context.elementProcessors.element - : context.elementProcessors.child; - - processor(model, root, context); } + context.elementProcessors.child(model, root, context); + normalizeContentModel(model); return model; diff --git a/packages-content-model/roosterjs-content-model-dom/lib/formatHandlers/common/backgroundColorFormatHandler.ts b/packages-content-model/roosterjs-content-model-dom/lib/formatHandlers/common/backgroundColorFormatHandler.ts index 97406d8ae0b..1b04cf9d11a 100644 --- a/packages-content-model/roosterjs-content-model-dom/lib/formatHandlers/common/backgroundColorFormatHandler.ts +++ b/packages-content-model/roosterjs-content-model-dom/lib/formatHandlers/common/backgroundColorFormatHandler.ts @@ -12,7 +12,7 @@ export const backgroundColorFormatHandler: FormatHandler element, true /*isBackground*/, context.darkColorHandler, - context.isDarkMode + !!context.isDarkMode ) || defaultStyle.backgroundColor; if (backgroundColor) { @@ -26,7 +26,7 @@ export const backgroundColorFormatHandler: FormatHandler format.backgroundColor, true /*isBackground*/, context.darkColorHandler, - context.isDarkMode + !!context.isDarkMode ); } }, diff --git a/packages-content-model/roosterjs-content-model-dom/lib/formatHandlers/segment/textColorFormatHandler.ts b/packages-content-model/roosterjs-content-model-dom/lib/formatHandlers/segment/textColorFormatHandler.ts index 45228d0992b..36d00d5378b 100644 --- a/packages-content-model/roosterjs-content-model-dom/lib/formatHandlers/segment/textColorFormatHandler.ts +++ b/packages-content-model/roosterjs-content-model-dom/lib/formatHandlers/segment/textColorFormatHandler.ts @@ -12,7 +12,7 @@ export const textColorFormatHandler: FormatHandler = { element, false /*isBackground*/, context.darkColorHandler, - context.isDarkMode + !!context.isDarkMode ) || defaultStyle.color; if (textColor && textColor != 'inherit') { @@ -28,7 +28,7 @@ export const textColorFormatHandler: FormatHandler = { format.textColor, false /*isBackground*/, context.darkColorHandler, - context.isDarkMode + !!context.isDarkMode ); } }, diff --git a/packages-content-model/roosterjs-content-model-dom/lib/modelToDom/context/createModelToDomContext.ts b/packages-content-model/roosterjs-content-model-dom/lib/modelToDom/context/createModelToDomContext.ts index 91bcfeead88..290fbce8d00 100644 --- a/packages-content-model/roosterjs-content-model-dom/lib/modelToDom/context/createModelToDomContext.ts +++ b/packages-content-model/roosterjs-content-model-dom/lib/modelToDom/context/createModelToDomContext.ts @@ -18,9 +18,8 @@ export function createModelToDomContext( options = options || {}; return { - ...(editorContext || { - isDarkMode: false, - }), + ...editorContext, + regularSelection: { current: { block: null, diff --git a/packages-content-model/roosterjs-content-model-dom/test/domToModel/context/createDomToModelContextTest.ts b/packages-content-model/roosterjs-content-model-dom/test/domToModel/context/createDomToModelContextTest.ts index 59aa1b3c1ed..2f488ee1570 100644 --- a/packages-content-model/roosterjs-content-model-dom/test/domToModel/context/createDomToModelContextTest.ts +++ b/packages-content-model/roosterjs-content-model-dom/test/domToModel/context/createDomToModelContextTest.ts @@ -9,9 +9,7 @@ import { } from '../../../lib/formatHandlers/defaultFormatHandlers'; describe('createDomToModelContext', () => { - const editorContext: EditorContext = { - isDarkMode: false, - }; + const editorContext: EditorContext = {}; const listFormat: DomToModelListFormat = { threadItemCounts: [], levels: [], diff --git a/packages-content-model/roosterjs-content-model-dom/test/domToModel/context/createModelToDomContextTest.ts b/packages-content-model/roosterjs-content-model-dom/test/domToModel/context/createModelToDomContextTest.ts index f613413fab6..c029262fdf3 100644 --- a/packages-content-model/roosterjs-content-model-dom/test/domToModel/context/createModelToDomContextTest.ts +++ b/packages-content-model/roosterjs-content-model-dom/test/domToModel/context/createModelToDomContextTest.ts @@ -8,9 +8,7 @@ import { } from '../../../lib/formatHandlers/defaultFormatHandlers'; describe('createModelToDomContext', () => { - const editorContext: EditorContext = { - isDarkMode: false, - }; + const editorContext: EditorContext = {}; const defaultResult: ModelToDomContext = { ...editorContext, regularSelection: { diff --git a/packages-content-model/roosterjs-content-model-dom/test/domToModel/domToContentModelTest.ts b/packages-content-model/roosterjs-content-model-dom/test/domToModel/domToContentModelTest.ts index cbc14a6bad5..9c069447636 100644 --- a/packages-content-model/roosterjs-content-model-dom/test/domToModel/domToContentModelTest.ts +++ b/packages-content-model/roosterjs-content-model-dom/test/domToModel/domToContentModelTest.ts @@ -25,9 +25,7 @@ describe('domToContentModel', () => { spyOn(normalizeContentModel, 'normalizeContentModel'); const rootElement = document.createElement('div'); - const options = { - includeRoot: false, - }; + const options = {}; const editorContext: EditorContext = { isDarkMode: false, defaultFormat: { @@ -55,44 +53,4 @@ describe('domToContentModel', () => { expect(normalizeContentModel.normalizeContentModel).toHaveBeenCalledTimes(1); expect(normalizeContentModel.normalizeContentModel).toHaveBeenCalledWith(result); }); - - it('Include root', () => { - const elementProcessor = jasmine.createSpy('elementProcessor'); - const childProcessor = jasmine.createSpy('childProcessor'); - const mockContext = ({ - elementProcessors: { - element: elementProcessor, - child: childProcessor, - }, - defaultStyles: {}, - zoomScaleFormat: {}, - segmentFormat: {}, - } as any) as DomToModelContext; - - spyOn(createDomToModelContext, 'createDomToModelContext').and.returnValue(mockContext); - spyOn(normalizeContentModel, 'normalizeContentModel'); - - const rootElement = document.createElement('div'); - const options = { - includeRoot: true, - }; - const editorContext: EditorContext = { isDarkMode: false }; - const model = domToContentModel(rootElement, editorContext, options); - const result: ContentModelDocument = { - blockGroupType: 'Document', - blocks: [], - }; - - expect(model).toEqual(result); - expect(createDomToModelContext.createDomToModelContext).toHaveBeenCalledTimes(1); - expect(createDomToModelContext.createDomToModelContext).toHaveBeenCalledWith( - editorContext, - options - ); - expect(childProcessor).not.toHaveBeenCalled(); - expect(elementProcessor).toHaveBeenCalledTimes(1); - expect(elementProcessor).toHaveBeenCalledWith(result, rootElement, mockContext); - expect(normalizeContentModel.normalizeContentModel).toHaveBeenCalledTimes(1); - expect(normalizeContentModel.normalizeContentModel).toHaveBeenCalledWith(result); - }); }); diff --git a/packages-content-model/roosterjs-content-model-editor/lib/index.ts b/packages-content-model/roosterjs-content-model-editor/lib/index.ts index 26976b5012f..babe9d24c2c 100644 --- a/packages-content-model/roosterjs-content-model-editor/lib/index.ts +++ b/packages-content-model/roosterjs-content-model-editor/lib/index.ts @@ -1,5 +1,68 @@ -export * from './publicTypes/index'; -export * from './publicApi/index'; +export { ContentModelFormatState } from './publicTypes/format/formatState/ContentModelFormatState'; +export { ImageFormatState } from './publicTypes/format/formatState/ImageFormatState'; +export { Border } from './publicTypes/interface/Border'; +export { + CreateEditorContext, + ContentModelCoreApiMap, + ContentModelEditorCore, + CreateContentModel, + SetContentModel, +} from './publicTypes/ContentModelEditorCore'; +export { + default as ContentModelBeforePasteEvent, + ContentModelBeforePasteEventData, + CompatibleContentModelBeforePasteEvent, +} from './publicTypes/event/ContentModelBeforePasteEvent'; +export { IContentModelEditor, ContentModelEditorOptions } from './publicTypes/IContentModelEditor'; +export { InsertPoint } from './publicTypes/selection/InsertPoint'; +export { TableSelectionContext } from './publicTypes/selection/TableSelectionContext'; + +export { default as insertTable } from './publicApi/table/insertTable'; +export { default as formatTable } from './publicApi/table/formatTable'; +export { default as setTableCellShade } from './publicApi/table/setTableCellShade'; +export { default as editTable } from './publicApi/table/editTable'; +export { default as toggleBullet } from './publicApi/list/toggleBullet'; +export { default as toggleNumbering } from './publicApi/list/toggleNumbering'; +export { default as toggleBold } from './publicApi/segment/toggleBold'; +export { default as toggleItalic } from './publicApi/segment/toggleItalic'; +export { default as toggleUnderline } from './publicApi/segment/toggleUnderline'; +export { default as toggleStrikethrough } from './publicApi/segment/toggleStrikethrough'; +export { default as toggleSubscript } from './publicApi/segment/toggleSubscript'; +export { default as toggleSuperscript } from './publicApi/segment/toggleSuperscript'; +export { default as setBackgroundColor } from './publicApi/segment/setBackgroundColor'; +export { default as setFontName } from './publicApi/segment/setFontName'; +export { default as setFontSize } from './publicApi/segment/setFontSize'; +export { default as setTextColor } from './publicApi/segment/setTextColor'; +export { default as changeFontSize } from './publicApi/segment/changeFontSize'; +export { default as applySegmentFormat } from './publicApi/segment/applySegmentFormat'; +export { default as changeCapitalization } from './publicApi/segment/changeCapitalization'; +export { default as insertImage } from './publicApi/image/insertImage'; +export { default as setListStyle } from './publicApi/list/setListStyle'; +export { default as setListStartNumber } from './publicApi/list/setListStartNumber'; +export { default as hasSelectionInBlock } from './publicApi/selection/hasSelectionInBlock'; +export { default as hasSelectionInSegment } from './publicApi/selection/hasSelectionInSegment'; +export { default as hasSelectionInBlockGroup } from './publicApi/selection/hasSelectionInBlockGroup'; +export { default as setIndentation } from './publicApi/block/setIndentation'; +export { default as setAlignment } from './publicApi/block/setAlignment'; +export { default as setDirection } from './publicApi/block/setDirection'; +export { default as setHeaderLevel } from './publicApi/block/setHeaderLevel'; +export { default as toggleBlockQuote } from './publicApi/block/toggleBlockQuote'; +export { default as setSpacing } from './publicApi/block/setSpacing'; +export { default as setImageBorder } from './publicApi/image/setImageBorder'; +export { default as setImageBoxShadow } from './publicApi/image/setImageBoxShadow'; +export { default as changeImage } from './publicApi/image/changeImage'; +export { default as getFormatState } from './publicApi/format/getFormatState'; +export { default as getSegmentFormat } from './publicApi/format/getSegmentFormat'; +export { default as applyPendingFormat } from './publicApi/format/applyPendingFormat'; +export { default as clearFormat } from './publicApi/format/clearFormat'; +export { default as insertLink } from './publicApi/link/insertLink'; +export { default as removeLink } from './publicApi/link/removeLink'; +export { default as adjustLinkSelection } from './publicApi/link/adjustLinkSelection'; +export { default as setImageAltText } from './publicApi/image/setImageAltText'; +export { default as adjustImageSelection } from './publicApi/image/adjustImageSelection'; +export { default as setParagraphMargin } from './publicApi/block/setParagraphMargin'; +export { default as toggleCode } from './publicApi/segment/toggleCode'; +export { default as paste } from './publicApi/utils/paste'; export { default as ContentModelEditor } from './editor/ContentModelEditor'; export { default as isContentModelEditor } from './editor/isContentModelEditor'; @@ -16,5 +79,3 @@ export { combineBorderValue, extractBorderValues } from './domUtils/borderValues export { updateImageMetadata } from './domUtils/metadata/updateImageMetadata'; export { updateTableCellMetadata } from './domUtils/metadata/updateTableCellMetadata'; export { updateTableMetadata } from './domUtils/metadata/updateTableMetadata'; - -export { IContentModelEditor, ContentModelEditorOptions } from './publicTypes/IContentModelEditor'; diff --git a/packages-content-model/roosterjs-content-model-editor/lib/publicApi/index.ts b/packages-content-model/roosterjs-content-model-editor/lib/publicApi/index.ts deleted file mode 100644 index 2d0ab5e5f18..00000000000 --- a/packages-content-model/roosterjs-content-model-editor/lib/publicApi/index.ts +++ /dev/null @@ -1,46 +0,0 @@ -export { default as insertTable } from './table/insertTable'; -export { default as formatTable } from './table/formatTable'; -export { default as setTableCellShade } from './table/setTableCellShade'; -export { default as editTable } from './table/editTable'; -export { default as toggleBullet } from './list/toggleBullet'; -export { default as toggleNumbering } from './list/toggleNumbering'; -export { default as toggleBold } from './segment/toggleBold'; -export { default as toggleItalic } from './segment/toggleItalic'; -export { default as toggleUnderline } from './segment/toggleUnderline'; -export { default as toggleStrikethrough } from './segment/toggleStrikethrough'; -export { default as toggleSubscript } from './segment/toggleSubscript'; -export { default as toggleSuperscript } from './segment/toggleSuperscript'; -export { default as setBackgroundColor } from './segment/setBackgroundColor'; -export { default as setFontName } from './segment/setFontName'; -export { default as setFontSize } from './segment/setFontSize'; -export { default as setTextColor } from './segment/setTextColor'; -export { default as changeFontSize } from './segment/changeFontSize'; -export { default as applySegmentFormat } from './segment/applySegmentFormat'; -export { default as changeCapitalization } from './segment/changeCapitalization'; -export { default as insertImage } from './image/insertImage'; -export { default as setListStyle } from './list/setListStyle'; -export { default as setListStartNumber } from './list/setListStartNumber'; -export { default as hasSelectionInBlock } from './selection/hasSelectionInBlock'; -export { default as hasSelectionInSegment } from './selection/hasSelectionInSegment'; -export { default as hasSelectionInBlockGroup } from './selection/hasSelectionInBlockGroup'; -export { default as setIndentation } from './block/setIndentation'; -export { default as setAlignment } from './block/setAlignment'; -export { default as setDirection } from './block/setDirection'; -export { default as setHeaderLevel } from './block/setHeaderLevel'; -export { default as toggleBlockQuote } from './block/toggleBlockQuote'; -export { default as setSpacing } from './block/setSpacing'; -export { default as setImageBorder } from './image/setImageBorder'; -export { default as setImageBoxShadow } from './image/setImageBoxShadow'; -export { default as changeImage } from './image/changeImage'; -export { default as getFormatState } from './format/getFormatState'; -export { default as getSegmentFormat } from './format/getSegmentFormat'; -export { default as applyPendingFormat } from './format/applyPendingFormat'; -export { default as clearFormat } from './format/clearFormat'; -export { default as insertLink } from './link/insertLink'; -export { default as removeLink } from './link/removeLink'; -export { default as adjustLinkSelection } from './link/adjustLinkSelection'; -export { default as setImageAltText } from './image/setImageAltText'; -export { default as adjustImageSelection } from './image/adjustImageSelection'; -export { default as setParagraphMargin } from './block/setParagraphMargin'; -export { default as toggleCode } from './segment/toggleCode'; -export { default as paste } from './utils/paste'; diff --git a/packages-content-model/roosterjs-content-model-editor/lib/publicTypes/index.ts b/packages-content-model/roosterjs-content-model-editor/lib/publicTypes/index.ts deleted file mode 100644 index a0f8a3dffdc..00000000000 --- a/packages-content-model/roosterjs-content-model-editor/lib/publicTypes/index.ts +++ /dev/null @@ -1,21 +0,0 @@ -export { InsertPoint } from './selection/InsertPoint'; -export { TableSelectionContext } from './selection/TableSelectionContext'; - -export { ContentModelFormatState } from './format/formatState/ContentModelFormatState'; -export { ImageFormatState } from './format/formatState/ImageFormatState'; - -export { Border } from './interface/Border'; - -export { - CreateEditorContext, - ContentModelCoreApiMap, - ContentModelEditorCore, - CreateContentModel, - SetContentModel, -} from './ContentModelEditorCore'; - -export { - default as ContentModelBeforePasteEvent, - ContentModelBeforePasteEventData, - CompatibleContentModelBeforePasteEvent, -} from './event/ContentModelBeforePasteEvent'; diff --git a/packages-content-model/roosterjs-content-model-editor/test/editor/plugins/paste/linkParserTest.ts b/packages-content-model/roosterjs-content-model-editor/test/editor/plugins/paste/linkParserTest.ts index 1b09af1596e..87d158942be 100644 --- a/packages-content-model/roosterjs-content-model-editor/test/editor/plugins/paste/linkParserTest.ts +++ b/packages-content-model/roosterjs-content-model-editor/test/editor/plugins/paste/linkParserTest.ts @@ -27,10 +27,7 @@ describe('link parser test', () => { { isDarkMode: false, }, - { - ...event.domToModelOption, - includeRoot: true, - } + event.domToModelOption ); if (expectedModel) { expect(model).toEqual(expectedModel); diff --git a/packages-content-model/roosterjs-content-model-editor/test/editor/plugins/paste/processPastedContentFromExcelTest.ts b/packages-content-model/roosterjs-content-model-editor/test/editor/plugins/paste/processPastedContentFromExcelTest.ts index eafb275f880..e0bae2d44e2 100644 --- a/packages-content-model/roosterjs-content-model-editor/test/editor/plugins/paste/processPastedContentFromExcelTest.ts +++ b/packages-content-model/roosterjs-content-model-editor/test/editor/plugins/paste/processPastedContentFromExcelTest.ts @@ -29,7 +29,6 @@ describe('processPastedContentFromExcelTest', () => { }, { ...event.domToModelOption, - includeRoot: true, disableCacheElement: true, } ); diff --git a/packages-content-model/roosterjs-content-model-editor/test/editor/plugins/paste/processPastedContentFromWacTest.ts b/packages-content-model/roosterjs-content-model-editor/test/editor/plugins/paste/processPastedContentFromWacTest.ts index 5094b4c7d01..ef284a1fe00 100644 --- a/packages-content-model/roosterjs-content-model-editor/test/editor/plugins/paste/processPastedContentFromWacTest.ts +++ b/packages-content-model/roosterjs-content-model-editor/test/editor/plugins/paste/processPastedContentFromWacTest.ts @@ -26,7 +26,6 @@ describe('processPastedContentFromWacTest', () => { }, { ...event.domToModelOption, - includeRoot: true, } ); if (expectedModel) { @@ -137,7 +136,6 @@ describe('wordOnlineHandler', () => { }, { ...event.domToModelOption, - includeRoot: true, disableCacheElement: true, } ); diff --git a/packages-content-model/roosterjs-content-model-editor/test/editor/plugins/paste/processPastedContentFromWordDesktopTest.ts b/packages-content-model/roosterjs-content-model-editor/test/editor/plugins/paste/processPastedContentFromWordDesktopTest.ts index 11058c96a8c..f18688aeb97 100644 --- a/packages-content-model/roosterjs-content-model-editor/test/editor/plugins/paste/processPastedContentFromWordDesktopTest.ts +++ b/packages-content-model/roosterjs-content-model-editor/test/editor/plugins/paste/processPastedContentFromWordDesktopTest.ts @@ -27,7 +27,6 @@ describe('processPastedContentFromWordDesktopTest', () => { }, { ...event.domToModelOption, - includeRoot: true, disableCacheElement: true, } ); diff --git a/packages-content-model/roosterjs-content-model-editor/test/publicApi/segment/changeFontSizeTest.ts b/packages-content-model/roosterjs-content-model-editor/test/publicApi/segment/changeFontSizeTest.ts index 62bac4e6ba5..e4ae664344c 100644 --- a/packages-content-model/roosterjs-content-model-editor/test/publicApi/segment/changeFontSizeTest.ts +++ b/packages-content-model/roosterjs-content-model-editor/test/publicApi/segment/changeFontSizeTest.ts @@ -352,7 +352,6 @@ describe('changeFontSize', () => { areAllCollapsed: false, ranges: [createRange(sub)], }, - includeRoot: true, ...option, } ), @@ -370,18 +369,15 @@ describe('changeFontSize', () => { { blockType: 'Paragraph', format: {}, - segmentFormat: { fontSize: '20pt' }, segments: [ { segmentType: 'Text', text: 'test', - format: { - fontSize: '22pt', - superOrSubScriptSequence: 'sub', - }, + format: { superOrSubScriptSequence: 'sub' }, isSelected: true, }, ], + isImplicit: true, }, ], }, diff --git a/packages-content-model/roosterjs-content-model-types/lib/context/DomToModelOption.ts b/packages-content-model/roosterjs-content-model-types/lib/context/DomToModelOption.ts index 71b67249f84..172427850da 100644 --- a/packages-content-model/roosterjs-content-model-types/lib/context/DomToModelOption.ts +++ b/packages-content-model/roosterjs-content-model-types/lib/context/DomToModelOption.ts @@ -1,20 +1,15 @@ +import { SelectionRangeEx } from 'roosterjs-editor-types'; import { DefaultStyleMap, ElementProcessorMap, FormatParsers, FormatParsersPerCategory, } from './DomToModelSettings'; -import { SelectionRangeEx } from 'roosterjs-editor-types'; /** * Options for creating DomToModelContext */ export interface DomToModelOption { - /** - * True to create content model from the root element itself, false to create from all child nodes of root. @default false - */ - includeRoot?: boolean; - /** * Selection range to be included in Content Model */ diff --git a/packages-content-model/roosterjs-content-model-types/lib/context/EditorContext.ts b/packages-content-model/roosterjs-content-model-types/lib/context/EditorContext.ts index 151ce645eb5..3d8ae58c568 100644 --- a/packages-content-model/roosterjs-content-model-types/lib/context/EditorContext.ts +++ b/packages-content-model/roosterjs-content-model-types/lib/context/EditorContext.ts @@ -8,7 +8,7 @@ export interface EditorContext { /** * Whether current content is in dark mode */ - isDarkMode: boolean; + isDarkMode?: boolean; /** * Default format of editor