Skip to content

Commit

Permalink
Fix files that were merged wrongly
Browse files Browse the repository at this point in the history
  • Loading branch information
romanisa committed Sep 21, 2023
1 parent 08560dc commit 4fc1f3a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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<HeadingLevelTags, string> = {
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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ describe('updateRotateHandlePosition', () => {
},
'-6px',
'0px',
'0px',
{
top: 2,
bottom: 3,
Expand Down

0 comments on commit 4fc1f3a

Please sign in to comment.