diff --git a/packages-content-model/roosterjs-content-model-editor/lib/editor/coreApi/switchShadowEdit.ts b/packages-content-model/roosterjs-content-model-editor/lib/editor/coreApi/switchShadowEdit.ts index 55ea53a46a3..feb4d828d94 100644 --- a/packages-content-model/roosterjs-content-model-editor/lib/editor/coreApi/switchShadowEdit.ts +++ b/packages-content-model/roosterjs-content-model-editor/lib/editor/coreApi/switchShadowEdit.ts @@ -44,8 +44,16 @@ export const switchShadowEdit: SwitchShadowEdit = (editorCore, isOn): void => { core.lifecycle.shadowEditFragment = null; core.lifecycle.shadowEditSelectionPath = null; - if (core.cachedModel) { - core.api.setContentModel(core, core.cachedModel); + core.api.triggerEvent( + core, + { + eventType: PluginEventType.LeavingShadowEdit, + }, + false /*broadcast*/ + ); + + if (core.cache.cachedModel) { + core.api.setContentModel(core, core.cache.cachedModel); } } } diff --git a/packages-content-model/roosterjs-content-model-editor/lib/publicApi/block/setHeadingLevel.ts b/packages-content-model/roosterjs-content-model-editor/lib/publicApi/block/setHeadingLevel.ts index cbb797b2107..83fd603ba54 100644 --- a/packages-content-model/roosterjs-content-model-editor/lib/publicApi/block/setHeadingLevel.ts +++ b/packages-content-model/roosterjs-content-model-editor/lib/publicApi/block/setHeadingLevel.ts @@ -1,13 +1,18 @@ -import { defaultImplicitFormatMap } from 'roosterjs-content-model-dom'; +import { ContentModelParagraphDecorator } from 'roosterjs-content-model-types'; import { formatParagraphWithContentModel } from '../utils/formatParagraphWithContentModel'; import { IContentModelEditor } from '../../publicTypes/IContentModelEditor'; -import { - ContentModelParagraphDecorator, - ContentModelSegmentFormat, -} from 'roosterjs-content-model-types'; type HeadingLevelTags = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'; +const HeaderFontSizes: Record = { + h1: '2em', + h2: '1.5em', + h3: '1.17em', + h4: '1em', + h5: '0.83em', + h6: '0.67em', +}; + /** * Set heading level of selected paragraphs * @param editor The editor to set heading level to @@ -22,13 +27,16 @@ export default function setHeadingLevel( headingLevel > 0 ? (('h' + headingLevel) as HeadingLevelTags | null) : getExistingHeadingTag(para.decorator); - const headingStyle = - (tagName && (defaultImplicitFormatMap[tagName] as ContentModelSegmentFormat)) || {}; if (headingLevel > 0) { para.decorator = { tagName: tagName!, - format: { ...headingStyle }, + format: tagName + ? { + fontWeight: 'bold', + fontSize: HeaderFontSizes[tagName], + } + : {}, }; // Remove existing formats since tags have default font size and weight diff --git a/packages/roosterjs-editor-plugins/test/imageEdit/rotatorTest.ts b/packages/roosterjs-editor-plugins/test/imageEdit/rotatorTest.ts index 57c2e02b2e0..4f34ca2dc34 100644 --- a/packages/roosterjs-editor-plugins/test/imageEdit/rotatorTest.ts +++ b/packages/roosterjs-editor-plugins/test/imageEdit/rotatorTest.ts @@ -231,6 +231,7 @@ describe('updateRotateHandlePosition', () => { }, '-6px', '0px', + '0px', { top: 2, bottom: 3,