Skip to content

Commit

Permalink
Version bump to 9.19.0 (#2941)
Browse files Browse the repository at this point in the history
* remove margins on Autoformat plugin

* fixes

* fix

* remove data-istrue

* use content change

* refactor

* Allow skipping marking hasNewContent in `formatContentModel` (#2933)

* Fix bridge plugin to be able to handle new event (#2935)

* Fix bridge plugin to be able to handle new event

* add test

* clean LegacySelectionPlugin

* Send anchor event in Auto Link (#2934)

After a text is automatically transformed into a link by typing and pressing space, send the anchor element when the ContentChanged event is triggered. Also add more unit tests.

* Respect font weight in TH element (#2939)

* Respect font weight in TH element

* add test

* improve

* fix build

* Fix resize table with width (#2940)

* Fix resize table with width

* fix test

* version bump

---------

Co-authored-by: Julia Roldi (from Dev Box) <[email protected]>
Co-authored-by: Julia Roldi <[email protected]>
  • Loading branch information
3 people authored Feb 7, 2025
1 parent e3f54c1 commit 5bac841
Show file tree
Hide file tree
Showing 28 changed files with 1,874 additions and 162 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const initialState: OptionState = {
autoOrdinals: true,
autoMailto: true,
autoTel: true,
removeListMargins: false,
},
markdownOptions: {
bold: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export class ExperimentalFeatures extends React.Component<DefaultFormatProps, {}
<>
{this.renderFeature('PersistCache')}
{this.renderFeature('HandleEnterKey')}
{this.renderFeature('LegacyImageSelection')}
</>
);
}
Expand Down
8 changes: 8 additions & 0 deletions demo/scripts/controlsV2/sidePane/editorOptions/Plugins.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export class Plugins extends PluginsBase<keyof BuildInPluginList> {
private autoOrdinals = React.createRef<HTMLInputElement>();
private autoTel = React.createRef<HTMLInputElement>();
private autoMailto = React.createRef<HTMLInputElement>();
private removeListMargins = React.createRef<HTMLInputElement>();
private markdownBold = React.createRef<HTMLInputElement>();
private markdownItalic = React.createRef<HTMLInputElement>();
private markdownStrikethrough = React.createRef<HTMLInputElement>();
Expand Down Expand Up @@ -180,6 +181,13 @@ export class Plugins extends PluginsBase<keyof BuildInPluginList> {
this.props.state.autoFormatOptions.autoMailto,
(state, value) => (state.autoFormatOptions.autoMailto = value)
)}
{this.renderCheckBox(
'Remove List Margins',
this.removeListMargins,
this.props.state.autoFormatOptions.removeListMargins,
(state, value) =>
(state.autoFormatOptions.removeListMargins = value)
)}
</>
)}
{this.renderPluginItem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,8 @@ export const formatContentModel: FormatContentModel = (
options,
domToModelOptions
) => {
const {
onNodeCreated,
getChangeData,
rawEvent,
selectionOverride,
scrollCaretIntoView: scroll,
} = options || {};
const { onNodeCreated, rawEvent, selectionOverride, scrollCaretIntoView: scroll } =
options || {};
const model = core.api.createContentModel(core, domToModelOptions, selectionOverride);
const context: FormatContentModelContext = {
newEntities: [],
Expand All @@ -47,7 +42,10 @@ export const formatContentModel: FormatContentModel = (

if (changed) {
const isNested = core.undo.isNested;
const shouldAddSnapshot = !skipUndoSnapshot && !isNested;
const shouldAddSnapshot =
(!skipUndoSnapshot || skipUndoSnapshot == 'DoNotSkip') && !isNested;
const shouldMarkNewContent =
(skipUndoSnapshot === true || skipUndoSnapshot == 'MarkNewContent') && !isNested;
let selection: DOMSelection | undefined;

if (shouldAddSnapshot) {
Expand Down Expand Up @@ -78,7 +76,7 @@ export const formatContentModel: FormatContentModel = (
contentModel: clearModelCache ? undefined : model,
selection: clearModelCache ? undefined : selection,
source: options?.changeSource || ChangeSource.Format,
data: getChangeData?.(),
data: options?.getChangeData?.(),
formatApiName: options?.apiName,
changedEntities: getChangedEntities(context, rawEvent),
};
Expand All @@ -94,7 +92,9 @@ export const formatContentModel: FormatContentModel = (

if (shouldAddSnapshot) {
core.api.addUndoSnapshot(core, false /*canUndoByBackspace*/, entityStates);
} else {
}

if (shouldMarkNewContent) {
core.undo.snapshotsManager.hasNewContent = true;
}
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ import type {
ParsedTable,
TableSelectionInfo,
TableCellCoordinate,
MouseUpEvent,
} from 'roosterjs-content-model-types';

const MouseLeftButton = 0;
const MouseMiddleButton = 1;
const MouseRightButton = 2;
const Up = 'ArrowUp';
const Down = 'ArrowDown';
Expand Down Expand Up @@ -141,7 +139,7 @@ class SelectionPlugin implements PluginWithState<SelectionPluginState> {
break;

case 'mouseUp':
this.onMouseUp(this.editor, event);
this.onMouseUp();
break;

case 'keyDown':
Expand All @@ -165,46 +163,30 @@ class SelectionPlugin implements PluginWithState<SelectionPluginState> {
let image: HTMLImageElement | null;

// Image selection
if (editor.isExperimentalFeatureEnabled('LegacyImageSelection')) {
if (
rawEvent.button === MouseRightButton &&
(image =
this.getClickingImage(rawEvent) ??
this.getContainedTargetImage(rawEvent, selection)) &&
image.isContentEditable
) {
this.selectImageWithRange(image, rawEvent);
return;
} else if (selection?.type == 'image' && selection.image !== rawEvent.target) {
this.selectBeforeOrAfterElement(editor, selection.image);
return;
}
} else {
if (
selection?.type == 'image' &&
(rawEvent.button == MouseLeftButton ||
(rawEvent.button == MouseRightButton &&
!this.getClickingImage(rawEvent) &&
!this.getContainedTargetImage(rawEvent, selection)))
) {
this.setDOMSelection(null /*domSelection*/, null /*tableSelection*/);
}
if (
selection?.type == 'image' &&
(rawEvent.button == MouseLeftButton ||
(rawEvent.button == MouseRightButton &&
!this.getClickingImage(rawEvent) &&
!this.getContainedTargetImage(rawEvent, selection)))
) {
this.setDOMSelection(null /*domSelection*/, null /*tableSelection*/);
}

if (
(image =
this.getClickingImage(rawEvent) ??
this.getContainedTargetImage(rawEvent, selection)) &&
image.isContentEditable
) {
this.setDOMSelection(
{
type: 'image',
image: image,
},
null
);
return;
}
if (
(image =
this.getClickingImage(rawEvent) ??
this.getContainedTargetImage(rawEvent, selection)) &&
image.isContentEditable
) {
this.setDOMSelection(
{
type: 'image',
image: image,
},
null
);
return;
}

// Table selection
Expand Down Expand Up @@ -245,25 +227,6 @@ class SelectionPlugin implements PluginWithState<SelectionPluginState> {
}
}

private selectImageWithRange(image: HTMLImageElement, event: Event) {
const range = image.ownerDocument.createRange();
range.selectNode(image);

const domSelection = this.editor?.getDOMSelection();
if (domSelection?.type == 'image' && image == domSelection.image) {
event.preventDefault();
} else {
this.setDOMSelection(
{
type: 'range',
isReverted: false,
range,
},
null
);
}
}

private onMouseMove = (event: Event) => {
if (this.editor && this.state.tableSelection) {
const hasTableSelection = !!this.state.tableSelection.lastCo;
Expand Down Expand Up @@ -324,21 +287,7 @@ class SelectionPlugin implements PluginWithState<SelectionPluginState> {
}
};

private onMouseUp(editor: IEditor, event: MouseUpEvent) {
let image: HTMLImageElement | null;

if (
editor.isExperimentalFeatureEnabled('LegacyImageSelection') &&
(image = this.getClickingImage(event.rawEvent)) &&
image.isContentEditable &&
event.rawEvent.button != MouseMiddleButton &&
(event.rawEvent.button ==
MouseRightButton /* it's not possible to drag using right click */ ||
event.isClicking)
) {
this.selectImageWithRange(image, event.rawEvent);
}

private onMouseUp() {
this.detachMouseEvent();
}

Expand Down
Loading

0 comments on commit 5bac841

Please sign in to comment.