Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
7c35c40
Fix toggling format issue at composition stage for CJK (#3064)
haven2world Jun 11, 2025
3ba879c
Avoid "undefined" in HTML to Markdown generated content (#3069)
Durss Jun 11, 2025
a4e9602
Add focus handling in formatTableWithContentModel and its tests (#3072)
BryanValverdeU Jun 16, 2025
00e00f7
format applier (#3073)
juliaroldi Jun 16, 2025
87b1570
Keep implicit paragraph when pressing Enter at the start of it. (#3075)
BryanValverdeU Jun 18, 2025
184c018
Add beforeLogicalRootChanged event handling and related tests (#3077)
BryanValverdeU Jun 19, 2025
9da5af4
Disable isComposing check in DOM event propagation for Android (#3076)
Rain-Zheng Jun 20, 2025
7fab305
Allow plugins to store state in snapshot (#3079)
florian-msft Jun 26, 2025
7081cdd
Fix #3080 (#3084)
JiuqingSong Jul 1, 2025
fd808bd
Add auto direction to setDirection (#3082)
wisaulni Jul 7, 2025
327d6ab
Ensure image is loaded before creating image wrapper (#3090)
BryanValverdeU Jul 18, 2025
eb3685f
test (#3092)
juliaroldi Jul 22, 2025
3ad7db1
Fix #3085 (#3095)
JiuqingSong Jul 22, 2025
47271ff
Adjust the image wrapper to stay inline (#3093)
juliaroldi Jul 22, 2025
74bc3e4
Fix 309357 (#3097)
JiuqingSong Jul 22, 2025
6307ffb
Fix #3063 (#3096)
JiuqingSong Jul 23, 2025
82f0466
Fix #3087 Delete paragraph styles when there is nothing else to be de…
JiuqingSong Jul 23, 2025
2da7000
Remove karma changes (#3102)
juliaroldi Jul 24, 2025
16ba94c
Adjust Block Indentation (#3099)
juliaroldi Jul 25, 2025
596ed24
Process non-visible elements (#3089)
juliaroldi Jul 25, 2025
eb7cfaa
Fix runtime color for dark mode (#3101)
JiuqingSong Jul 27, 2025
6ed2303
table rtl (#3103)
juliaroldi Jul 28, 2025
bf46671
image-handles (#3104)
juliaroldi Jul 28, 2025
0437f87
Fix superscript rule (#3106)
juliaroldi Jul 30, 2025
4cddcac
Fix 380860 (#3107)
JiuqingSong Jul 31, 2025
9acc158
Support 'HTMLFast' mode when get HTML (#3109)
JiuqingSong Aug 10, 2025
dc7b236
Bump tmp from 0.2.1 to 0.2.4 (#3114)
dependabot[bot] Aug 11, 2025
be90b35
Fix #3110 (#3113)
BryanValverdeU Aug 12, 2025
deb3009
Add markdown support for strikethrough
francismengMS Aug 13, 2025
6fcf93a
Fix test
francismengMS Aug 13, 2025
e736fa9
Try fix unstable test (#3118)
BryanValverdeU Aug 14, 2025
b46c3e0
Merge branch 'master' into add-support-for-strikethrough
FrancisMengx Aug 14, 2025
cb770a5
Merge pull request #3117 from microsoft/add-support-for-strikethrough
FrancisMengx Aug 14, 2025
c00c270
add support for nested style markdowns
francismengMS Aug 14, 2025
9e25b8f
move let to const
francismengMS Aug 14, 2025
c363b6d
update
francismengMS Aug 14, 2025
25c9c9e
Support DL,DT,DD in content model (#3120)
JiuqingSong Aug 15, 2025
f7cf931
Add an experimental feature for 'HTMLFast' when export html (#3121)
JiuqingSong Aug 15, 2025
4dee325
Fix 276282 (#3125)
JiuqingSong Aug 19, 2025
283e7f8
Fix #3112 Delete empty block group when need (#3124)
JiuqingSong Aug 19, 2025
d367b9a
update
francismengMS Aug 20, 2025
91a1e0f
remove console log
francismengMS Aug 20, 2025
6b5f0e0
fix regression
francismengMS Aug 21, 2025
de2a396
update
francismengMS Aug 21, 2025
46a6b59
Merge branch 'master' into add-support-for-nested-style-markdown
FrancisMengx Aug 21, 2025
6464adf
Merge pull request #3119 from microsoft/add-support-for-nested-style-…
FrancisMengx Aug 22, 2025
43a8880
Do not add undo snapshot from ImageEdit plugin if image is not change…
JiuqingSong Aug 26, 2025
62dafa5
Support different options for empty line mode in mark down (#3128)
JiuqingSong Aug 26, 2025
622a089
Fix auto link (#3129)
juliaroldi Aug 27, 2025
3ab45b3
Graduate option "disableCache" (#3132)
JiuqingSong Aug 28, 2025
9f8abbf
Improve handleParagraph function (#3130)
JiuqingSong Aug 28, 2025
8d8f0fe
Remove console.log added accidentally in test code (#3134)
JiuqingSong Aug 28, 2025
26c4616
Toggle blockquote in Format Container (#3126)
juliaroldi Aug 28, 2025
63d7a7d
Fix auto-capitalization for iOS (#3131)
isnine Aug 30, 2025
0f17465
Fix RTL for Image Selection (#3136)
juliaroldi Sep 2, 2025
8e7a710
Revert "Improve handleParagraph function (#3130)" (#3137)
JiuqingSong Sep 2, 2025
1ea668f
add pointer event and touch plugin
Sep 8, 2025
5e0487e
[Image Edit] Fix mouse down selection (#3140)
juliaroldi Sep 9, 2025
4764716
Fix js error in keyboardInput (#3142)
JiuqingSong Sep 10, 2025
13bded5
Reset logical root before restore snapshot (#3144)
JiuqingSong Sep 10, 2025
169eff1
remove touch plugin and hadndle in SelectionPlugin
Sep 10, 2025
70cba10
revert previous unrelated change
Sep 10, 2025
260c95e
revert previous unrelated change
Sep 10, 2025
f9d14fc
revert previous unrelated change
Sep 10, 2025
552a5aa
revert previous unrelated change
Sep 10, 2025
ce2baa7
revert previous unrelated change
Sep 10, 2025
22e6ea4
revert previous unrelated change
Sep 10, 2025
81d310f
revert previous unrelated change
Sep 10, 2025
f168a1f
revert previous unrelated change
Sep 10, 2025
b12f7f8
revert previous unrelated change
Sep 10, 2025
9bc3422
fix
Sep 10, 2025
166a766
fix
Sep 10, 2025
02c9ebd
remove test
Sep 10, 2025
02beb48
Update packages/roosterjs-content-model-core/lib/corePlugin/selection…
vinguyen12 Sep 11, 2025
ffe15ea
Merge branch 'master' into u/nguyenvi/mouse-to-pointer
vinguyen12 Sep 11, 2025
367e2d8
Fix type error when continuing list (#3149)
juliaroldi Sep 11, 2025
e1891d2
Merge branch 'master' into u/nguyenvi/mouse-to-pointer
vinguyen12 Sep 11, 2025
92daf85
Merge pull request #3148 from microsoft/u/nguyenvi/mouse-to-pointer
vinguyen12 Sep 11, 2025
dfc06e6
Fix #3088 & #3139: Remove unneeded paddings from Word Desktop (#3147)
BryanValverdeU Sep 11, 2025
833e205
Merge branch 'master' into biwu/versionbump912
Sep 12, 2025
3c78013
version update
Sep 12, 2025
08761bc
udpate new version
Sep 12, 2025
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 @@ -11,7 +11,5 @@ export function restoreSnapshotLogicalRoot(core: EditorCore, snapshot: Snapshot)
if (restoredLogicalRoot !== core.logicalRoot) {
core.api.setLogicalRoot(core, restoredLogicalRoot);
}
} else {
core.api.setLogicalRoot(core, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ export const restoreUndoSnapshot: RestoreUndoSnapshot = (core, snapshot) => {
try {
core.undo.isRestoring = true;

// Force clear logical root before restoring snapshot, so the whole editor is editable.
// Without changing logical root, browser may want to maintain the scroll position of current logical root,
// which may cause the editor to scroll to a wrong position after content is changed.
core.api.setLogicalRoot(core, null /* logicalRoot */);

restoreSnapshotHTML(core, snapshot);
restoreSnapshotLogicalRoot(core, snapshot);
restoreSnapshotSelection(core, snapshot);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ class DOMEventPlugin implements PluginWithState<DOMEventPluginState> {
event.stopPropagation();

const isAndroid = this.editor?.getEnvironment()?.isAndroid ?? false;
const isComposing = !isAndroid && ((event as InputEvent).isComposing || this.state.isInIME);
const isComposing =
!isAndroid && ((event as InputEvent).isComposing || this.state.isInIME);

if (this.editor && !isComposing) {
this.editor.triggerEvent('input', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import type {
ParsedTable,
TableSelectionInfo,
TableCellCoordinate,
DOMEventRecord,
} from 'roosterjs-content-model-types';

const MouseLeftButton = 0;
Expand Down Expand Up @@ -48,6 +49,7 @@ class SelectionPlugin implements PluginWithState<SelectionPluginState> {
private isSafari = false;
private isMac = false;
private scrollTopCache: number = 0;
private pointerEvent: PointerEvent | null = null;

constructor(options: EditorOptions) {
this.state = {
Expand Down Expand Up @@ -99,18 +101,15 @@ class SelectionPlugin implements PluginWithState<SelectionPluginState> {
this.isSafari = !!env.isSafari;
this.isMac = !!env.isMac;
document.addEventListener('selectionchange', this.onSelectionChange);
if (this.isSafari) {
this.disposer = this.editor.attachDomEvent({
focus: { beforeDispatch: this.onFocus },
drop: { beforeDispatch: this.onDrop },
});
} else {
this.disposer = this.editor.attachDomEvent({
focus: { beforeDispatch: this.onFocus },
blur: { beforeDispatch: this.onBlur },
drop: { beforeDispatch: this.onDrop },
});
}
const eventHandlers: Partial<
{ [P in keyof HTMLElementEventMap]: DOMEventRecord<HTMLElementEventMap[P]> }
> = {
focus: { beforeDispatch: this.onFocus },
drop: { beforeDispatch: this.onDrop },
blur: this.isSafari ? undefined : { beforeDispatch: this.onBlur },
pointerdown: { beforeDispatch: (event: PointerEvent) => this.onPointerDown(event) },
};
this.disposer = this.editor.attachDomEvent(<Record<string, DOMEventRecord>>eventHandlers);
}

dispose() {
Expand Down Expand Up @@ -246,6 +245,10 @@ class SelectionPlugin implements PluginWithState<SelectionPluginState> {
},
});
}

if (rawEvent.defaultPrevented) {
this.pointerEvent = null;
}
}

private onMouseMove = (event: Event) => {
Expand Down Expand Up @@ -310,12 +313,27 @@ class SelectionPlugin implements PluginWithState<SelectionPluginState> {

private onMouseUp() {
this.detachMouseEvent();
if (this.pointerEvent && this.pointerEvent.pointerType === 'touch') {
requestAnimationFrame(() => {
if (this.editor && this.pointerEvent) {
// Handle touch selection here since the cursor position is updated
// Work-in-progress
}
this.pointerEvent = null;
});
}
}

private onDrop = () => {
this.detachMouseEvent();
};

private onPointerDown = (e: PointerEvent) => {
if (e.pointerType === 'touch' || e.pointerType === 'pen') {
this.pointerEvent = e;
}
};

private onKeyDown(editor: IEditor, rawEvent: KeyboardEvent) {
const key = rawEvent.key;
const selection = editor.getDOMSelection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,10 @@ const getPreviousListLevel = (
};

const getPreviousListStyle = (list?: ContentModelListItem) => {
if (list?.levels[0].dataset) {
return updateListMetadata(list.levels[0])?.orderedStyleType;
if (!list || list.levels.length < 1) {
return undefined;
}
return updateListMetadata(list.levels[0])?.orderedStyleType;
};

const bulletListType: Map<string, number> = new Map<string, number>([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ export function keyboardInput(editor: IEditor, rawEvent: KeyboardEvent) {
function shouldInputWithContentModel(selection: DOMSelection | null, rawEvent: KeyboardEvent) {
if (!selection) {
return false; // Nothing to delete
} else if (!isModifierKey(rawEvent) && (rawEvent.key == 'Space' || rawEvent.key.length == 1)) {
} else if (
!isModifierKey(rawEvent) &&
rawEvent.key &&
(rawEvent.key == 'Space' || rawEvent.key.length == 1)
) {
return selection.type != 'range' || !selection.range.collapsed;
} else {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,7 @@ export class ImageEditPlugin implements ImageEditor, EditorPlugin {
event.rawEvent.button !== MouseRightButton &&
!this.isCropMode
) {
this.applyFormatWithContentModel(
editor,
this.isCropMode,
this.shadowSpan === event.rawEvent.target
);
this.applyFormatWithContentModel(editor, this.isCropMode);
}
}

Expand Down Expand Up @@ -339,7 +335,7 @@ export class ImageEditPlugin implements ImageEditor, EditorPlugin {
protected applyFormatWithContentModel(
editor: IEditor,
isCropMode: boolean,
shouldSelectImage: boolean,
shouldSelectImage?: boolean,
isApiOperation?: boolean
) {
let editingImageModel: ContentModelImage | undefined;
Expand Down Expand Up @@ -389,9 +385,10 @@ export class ImageEditPlugin implements ImageEditor, EditorPlugin {
if (this.wasImageResized || changeState == 'FullyChanged') {
context.skipUndoSnapshot = false;
}

image.isSelected = shouldSelectImage;
image.isSelectedAsImageSelection = shouldSelectImage;
const isSameImage =
previousSelectedImage?.image === editingImage?.image;
image.isSelected = isSameImage || shouldSelectImage;
image.isSelectedAsImageSelection = isSameImage || shouldSelectImage;
image.format.imageState = undefined;

if (selection?.type == 'range' && !selection.range.collapsed) {
Expand Down Expand Up @@ -508,6 +505,7 @@ export class ImageEditPlugin implements ImageEditor, EditorPlugin {
if (!this.imageEditInfo) {
this.imageEditInfo = getSelectedImageMetadata(editor, image);
}

this.imageHTMLOptions = getHTMLImageOptions(editor, this.options, this.imageEditInfo);
this.lastSrc = image.getAttribute('src');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,11 @@ const listLevelParser: FormatParser<ContentModelListItemLevelFormat> = (
format.marginBottom = undefined;
};

const wordTableParser: FormatParser<ContentModelTableFormat> = (format): void => {
const wordTableParser: FormatParser<ContentModelTableFormat> = (format, element): void => {
if (format.marginLeft?.startsWith('-')) {
delete format.marginLeft;
}
if (format.htmlAlign) {
delete format.htmlAlign;
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,10 @@ function wordListPaddingParser(
format: ContentModelListItemLevelFormat,
element: HTMLElement
): void {
if (element.style.marginLeft && element.style.marginLeft != '0in') {
if (element.style.marginLeft && parseInt(element.style.marginLeft) != 0) {
format.paddingLeft = '0px';
}
if (element.style.marginRight && element.style.marginRight != '0in') {
if (element.style.marginRight && parseInt(element.style.marginRight) != 0) {
format.paddingRight = '0px';
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1356,4 +1356,59 @@ describe('getListTypeStyle', () => {
index: 3,
});
});

it('should create a new list', () => {
const model: ContentModelDocument = {
blockGroupType: 'Document',
blocks: [
{
formatHolder: {
isSelected: false,
segmentType: 'SelectionMarker',
format: {},
},
levels: [],
blockType: 'BlockGroup',
format: {},
blockGroupType: 'ListItem',
blocks: [
{
segments: [
{
segmentType: 'Br',
format: {},
},
],
segmentFormat: {},
blockType: 'Paragraph',
format: {},
},
],
},
{
segments: [
{
text: '1.',
segmentType: 'Text',
format: {},
},
{
isSelected: true,
segmentType: 'SelectionMarker',
format: {},
},
],
segmentFormat: {},
blockType: 'Paragraph',
format: {},
},
],
format: {},
};
runTest(model, {
listType: 'OL',
styleType: NumberingListType.Decimal,
index: undefined,
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ describe('updateWrapper', () => {
expect(imageClone.style.width).toBe('20px');
expect(imageClone.style.height).toBe('13.3333px');
expect(imageClone.style.position).toBe('absolute');
expect(imageClone.style.position).toBe('absolute');
image.remove();
});
});
Loading
Loading