diff --git a/demo/scripts/controlsV2/mainPane/MainPane.tsx b/demo/scripts/controlsV2/mainPane/MainPane.tsx index 94132a551d4..22296506b4d 100644 --- a/demo/scripts/controlsV2/mainPane/MainPane.tsx +++ b/demo/scripts/controlsV2/mainPane/MainPane.tsx @@ -496,10 +496,11 @@ export class MainPane extends React.Component<{}, MainPaneState> { autoFormatOptions, linkTitle, customReplacements, + editPluginOptions, } = this.state.initState; return [ pluginList.autoFormat && new AutoFormatPlugin(autoFormatOptions), - pluginList.edit && new EditPlugin(), + pluginList.edit && new EditPlugin(editPluginOptions), pluginList.paste && new PastePlugin(allowExcelNoBorderTable), pluginList.shortcut && new ShortcutPlugin(), pluginList.tableEdit && new TableEditPlugin(), diff --git a/demo/scripts/controlsV2/sidePane/editorOptions/EditorOptionsPlugin.ts b/demo/scripts/controlsV2/sidePane/editorOptions/EditorOptionsPlugin.ts index 53df2b411aa..a6d4c5af32a 100644 --- a/demo/scripts/controlsV2/sidePane/editorOptions/EditorOptionsPlugin.ts +++ b/demo/scripts/controlsV2/sidePane/editorOptions/EditorOptionsPlugin.ts @@ -52,6 +52,9 @@ const initialState: OptionState = { strikethrough: true, codeFormat: {}, }, + editPluginOptions: { + handleTabKey: true, + }, customReplacements: emojiReplacements, experimentalFeatures: new Set(['PersistCache']), }; diff --git a/demo/scripts/controlsV2/sidePane/editorOptions/OptionState.ts b/demo/scripts/controlsV2/sidePane/editorOptions/OptionState.ts index 8283c17f874..dbf2a967302 100644 --- a/demo/scripts/controlsV2/sidePane/editorOptions/OptionState.ts +++ b/demo/scripts/controlsV2/sidePane/editorOptions/OptionState.ts @@ -1,4 +1,9 @@ -import { AutoFormatOptions, CustomReplace, MarkdownOptions } from 'roosterjs-content-model-plugins'; +import { + AutoFormatOptions, + CustomReplace, + EditOptions, + MarkdownOptions, +} from 'roosterjs-content-model-plugins'; import type { SidePaneElementProps } from '../SidePaneElement'; import type { ContentModelSegmentFormat, ExperimentalFeature } from 'roosterjs-content-model-types'; @@ -31,6 +36,7 @@ export interface OptionState { autoFormatOptions: AutoFormatOptions; markdownOptions: MarkdownOptions; customReplacements: CustomReplace[]; + editPluginOptions: EditOptions; // Legacy plugin options defaultFormat: ContentModelSegmentFormat; diff --git a/demo/scripts/controlsV2/sidePane/editorOptions/OptionsPane.tsx b/demo/scripts/controlsV2/sidePane/editorOptions/OptionsPane.tsx index 6e775fa3a14..951aa42d49f 100644 --- a/demo/scripts/controlsV2/sidePane/editorOptions/OptionsPane.tsx +++ b/demo/scripts/controlsV2/sidePane/editorOptions/OptionsPane.tsx @@ -140,6 +140,7 @@ export class OptionsPane extends React.Component { markdownOptions: { ...this.state.markdownOptions }, customReplacements: this.state.customReplacements, experimentalFeatures: this.state.experimentalFeatures, + editPluginOptions: { ...this.state.editPluginOptions }, }; if (callback) { diff --git a/demo/scripts/controlsV2/sidePane/editorOptions/Plugins.tsx b/demo/scripts/controlsV2/sidePane/editorOptions/Plugins.tsx index be1b559a310..86ebfe53fdf 100644 --- a/demo/scripts/controlsV2/sidePane/editorOptions/Plugins.tsx +++ b/demo/scripts/controlsV2/sidePane/editorOptions/Plugins.tsx @@ -98,6 +98,7 @@ abstract class PluginsBase extends Re export class Plugins extends PluginsBase { private allowExcelNoBorderTable = React.createRef(); + private handleTabKey = React.createRef(); private listMenu = React.createRef(); private tableMenu = React.createRef(); private imageMenu = React.createRef(); @@ -167,7 +168,16 @@ export class Plugins extends PluginsBase { )} )} - {this.renderPluginItem('edit', 'Edit')} + {this.renderPluginItem( + 'edit', + 'Edit', + this.renderCheckBox( + 'Handle Tab Key', + this.handleTabKey, + this.props.state.editPluginOptions.handleTabKey, + (state, value) => (state.editPluginOptions.handleTabKey = value) + ) + )} {this.renderPluginItem( 'paste', 'Paste', diff --git a/packages/roosterjs-content-model-plugins/lib/edit/EditPlugin.ts b/packages/roosterjs-content-model-plugins/lib/edit/EditPlugin.ts index 8a688f07590..82bf6f54b52 100644 --- a/packages/roosterjs-content-model-plugins/lib/edit/EditPlugin.ts +++ b/packages/roosterjs-content-model-plugins/lib/edit/EditPlugin.ts @@ -19,14 +19,11 @@ export type EditOptions = { * Whether to handle Tab key in keyboard. @default true */ handleTabKey?: boolean; -} +}; const BACKSPACE_KEY = 8; const DELETE_KEY = 46; -/** - * @internal - */ const DefaultOptions: Partial = { handleTabKey: true, };