Skip to content

Commit 0e7da61

Browse files
committed
Fix #3171 #3184
1 parent 2fac28c commit 0e7da61

File tree

14 files changed

+247
-58
lines changed

14 files changed

+247
-58
lines changed

demo/scripts/controlsV2/sidePane/editorOptions/EditorOptionsPlugin.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,13 @@ const initialState: OptionState = {
5959
codeFormat: {},
6060
},
6161
editPluginOptions: {
62-
handleTabKey: true,
62+
handleTabKey: {
63+
indentMultipleBlocks: true,
64+
indentTable: true,
65+
appendTableRow: true,
66+
indentList: true,
67+
indentParagraph: true,
68+
},
6369
},
6470
customReplacements: emojiReplacements,
6571
disableSideResize: false,

demo/scripts/controlsV2/sidePane/editorOptions/OptionState.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
AutoFormatOptions,
33
CustomReplace,
44
EditOptions,
5+
HandleTabOptions,
56
MarkdownOptions,
67
} from 'roosterjs-content-model-plugins';
78
import type { SidePaneElementProps } from '../SidePaneElement';
@@ -39,7 +40,7 @@ export interface OptionState {
3940
autoFormatOptions: AutoFormatOptions;
4041
markdownOptions: MarkdownOptions;
4142
customReplacements: CustomReplace[];
42-
editPluginOptions: EditOptions;
43+
editPluginOptions: EditOptions & { handleTabKey: HandleTabOptions };
4344
disableSideResize: boolean;
4445

4546
// Legacy plugin options

demo/scripts/controlsV2/sidePane/editorOptions/Plugins.tsx

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,40 @@ export class Plugins extends PluginsBase<keyof BuildInPluginList> {
205205
'Edit',
206206
<>
207207
{this.renderCheckBox(
208-
'Handle Tab Key',
208+
'Tab to indent multiple blocks',
209209
this.handleTabKey,
210-
this.props.state.editPluginOptions.handleTabKey,
211-
(state, value) => (state.editPluginOptions.handleTabKey = value)
210+
this.props.state.editPluginOptions.handleTabKey
211+
.indentMultipleBlocks,
212+
(state, value) =>
213+
(state.editPluginOptions.handleTabKey.indentMultipleBlocks = value)
214+
)}
215+
{this.renderCheckBox(
216+
'Tab to indent table',
217+
this.handleTabKey,
218+
this.props.state.editPluginOptions.handleTabKey.indentTable,
219+
(state, value) =>
220+
(state.editPluginOptions.handleTabKey.indentTable = value)
221+
)}
222+
{this.renderCheckBox(
223+
'Tab to append table row',
224+
this.handleTabKey,
225+
this.props.state.editPluginOptions.handleTabKey.appendTableRow,
226+
(state, value) =>
227+
(state.editPluginOptions.handleTabKey.appendTableRow = value)
228+
)}
229+
{this.renderCheckBox(
230+
'Tab to indent list items',
231+
this.handleTabKey,
232+
this.props.state.editPluginOptions.handleTabKey.indentList,
233+
(state, value) =>
234+
(state.editPluginOptions.handleTabKey.indentList = value)
235+
)}
236+
{this.renderCheckBox(
237+
'Tab to indent paragraph',
238+
this.handleTabKey,
239+
this.props.state.editPluginOptions.handleTabKey.indentParagraph,
240+
(state, value) =>
241+
(state.editPluginOptions.handleTabKey.indentParagraph = value)
212242
)}
213243
{this.renderCheckBox(
214244
'Handle Enter Key',

packages/roosterjs-content-model-api/lib/modelApi/block/setModelIndentation.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
getOperationalBlocks,
88
isBlockGroupOfType,
99
mutateBlock,
10+
normalizeContentModel,
1011
parseValueWithUnit,
1112
updateListMetadata,
1213
} from 'roosterjs-content-model-dom';
@@ -134,7 +135,13 @@ export function setModelIndentation(
134135
}
135136
});
136137

137-
return paragraphOrListItem.length > 0;
138+
if (paragraphOrListItem.length > 0) {
139+
normalizeContentModel(model);
140+
141+
return true;
142+
} else {
143+
return false;
144+
}
138145
}
139146

140147
function isSelected(listItem: ReadonlyContentModelListItem) {

packages/roosterjs-content-model-api/lib/publicApi/block/setIndentation.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { normalizeContentModel } from 'roosterjs-content-model-dom';
21
import { setModelIndentation } from '../../modelApi/block/setModelIndentation';
32
import type { IEditor } from 'roosterjs-content-model-types';
43

@@ -19,10 +18,6 @@ export function setIndentation(
1918
(model, context) => {
2019
const result = setModelIndentation(model, indentation, length);
2120

22-
if (result) {
23-
normalizeContentModel(model);
24-
}
25-
2621
context.newPendingFormat = 'preserve';
2722

2823
return result;

0 commit comments

Comments
 (0)