Skip to content

Commit

Permalink
Fix #2143 (#2145)
Browse files Browse the repository at this point in the history
  • Loading branch information
JiuqingSong authored Oct 16, 2023
1 parent db834e6 commit 165d4ea
Showing 1 changed file with 2 additions and 37 deletions.
39 changes: 2 additions & 37 deletions packages/roosterjs-editor-core/lib/corePlugins/LifecyclePlugin.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Browser, getObjectKeys, setColor } from 'roosterjs-editor-dom';
import { ChangeSource, DocumentCommand, PluginEventType } from 'roosterjs-editor-types';
import { ChangeSource, PluginEventType } from 'roosterjs-editor-types';
import { getObjectKeys, setColor } from 'roosterjs-editor-dom';
import type {
EditorOptions,
IEditor,
Expand All @@ -9,27 +9,6 @@ import type {
} from 'roosterjs-editor-types';

const CONTENT_EDITABLE_ATTRIBUTE_NAME = 'contenteditable';
const COMMANDS: Record<string, string> = Browser.isFirefox
? {
/**
* Disable these object resizing for firefox since other browsers don't have these behaviors
*/
[DocumentCommand.EnableObjectResizing]: (false as any) as string,
[DocumentCommand.EnableInlineTableEditing]: (false as any) as string,
}
: Browser.isIE
? {
/**
* Change the default paragraph separator to DIV. This is mainly for IE since its default setting is P
*/
[DocumentCommand.DefaultParagraphSeparator]: 'div',

/**
* Disable auto link feature in IE since we have our own implementation
*/
[DocumentCommand.AutoUrlDetect]: (false as any) as string,
}
: {};

const DARK_MODE_DEFAULT_FORMAT = {
backgroundColors: {
Expand Down Expand Up @@ -67,11 +46,9 @@ export default class LifecyclePlugin implements PluginWithState<LifecyclePluginS
this.initializer = () => {
contentDiv.contentEditable = 'true';
contentDiv.style.userSelect = 'text';
contentDiv.style.webkitUserSelect = 'text';
};
this.disposer = () => {
contentDiv.style.userSelect = '';
contentDiv.style.webkitUserSelect = '';
contentDiv.removeAttribute(CONTENT_EDITABLE_ATTRIBUTE_NAME);
};
}
Expand Down Expand Up @@ -158,9 +135,6 @@ export default class LifecyclePlugin implements PluginWithState<LifecyclePluginS
// Set editor background color for dark mode
this.adjustColor();

// Do proper change for browsers to disable some browser-specified behaviors.
this.adjustBrowserBehavior();

// Let other plugins know that we are ready
this.editor.triggerPluginEvent(PluginEventType.EditorReady, {}, true /*broadcast*/);
}
Expand Down Expand Up @@ -211,13 +185,4 @@ export default class LifecyclePlugin implements PluginWithState<LifecyclePluginS
this.adjustColor();
}
}

private adjustBrowserBehavior() {
getObjectKeys(COMMANDS).forEach(command => {
// Catch any possible exception since this should not block the initialization of editor
try {
this.editor?.getDocument().execCommand(command, false, COMMANDS[command]);
} catch {}
});
}
}

0 comments on commit 165d4ea

Please sign in to comment.