Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto format fixes #2520

Merged
merged 9 commits into from
Mar 22, 2024
Merged

Auto format fixes #2520

merged 9 commits into from
Mar 22, 2024

Conversation

juliaroldi
Copy link
Contributor

@juliaroldi juliaroldi commented Mar 21, 2024

This PR includes the followings fixes:

  1. Remove circular formatContentModel call
  2. Add api name for keyboardListTrigger function, then AutoFormatSettings plugin from OWA can recognize a list was triggered.
  3. Support undo by backspace

@juliaroldi juliaroldi marked this pull request as ready for review March 21, 2024 22:41
@juliaroldi juliaroldi changed the title WIP: Auto format fixes Auto format fixes Mar 21, 2024
private handleEditorInputEvent(editor: IEditor, event: EditorInputEvent) {
const rawEvent = event.rawEvent;
if (rawEvent.inputType === 'insertText') {
const { autoBullet, autoNumbering } = this.options;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this line down, only do this when you need it

private handleKeyDownEvent(editor: IEditor, event: KeyDownEvent) {
const rawEvent = event.rawEvent;
if (!rawEvent.defaultPrevented && !event.handledByEditFeature) {
const { autoBullet, autoNumbering, autoUnlink, autoLink } = this.options;
const { autoUnlink, autoLink } = this.options;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Comment on lines 55 to 73
const listItem = getFirstSelectedListItem(model);
if (listItem) {
const listItems = findListItemsInSameThread(model, listItem);
const levelIndex = listItem.levels.length - 1;
// If the index < 1, it is a new list, so it will be starting by 1, then no need to set startNumber
if (index && index > 1 && isOrderedList) {
const level = listItem?.levels[levelIndex];
if (level) {
level.format.startNumberOverride = index;
}
}

listItems.forEach(listItem => {
const level = listItem.levels[levelIndex];
if (level) {
updateListMetadata(level, metadata =>
Object.assign(
{},
metadata,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these code copied from the format API? Can we try not duplicate the code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I split in two apis

@juliaroldi juliaroldi merged commit c6d3934 into master Mar 22, 2024
7 checks passed
@juliaroldi juliaroldi deleted the u/julairoldi/refactor-auto-format branch March 22, 2024 15:23
@juliaroldi juliaroldi mentioned this pull request Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants