Skip to content

Commit 10c1d9d

Browse files
Andres-CT98juliaroldiJiuqingSongBryanValverdeURain-Zheng
authored
Bump version 9.3.1 -> 9.4 (#2658)
* code suport * markdown * adjust * demo site * WIP * fix code pen * fix demo site * Handle Tab key on whole table selection or last cell on Edit Plugin (#2536) * Implement indent whole table * implement tab on last cell new row * add Table selection and single cell handling * export clearSelectedCells * undefined check, simplify * add tests * add test for list in table edge case * Fix seelection on void element (#2551) * port hyphen * Implement movement with Tab key inside Table (#2529) * implement tab movement, tests * remove unused variable * fix name, normalisation, add test * fix wrong parethesis * restore normalizePos * fix tests * add formatTextSegmentBeforeSelectionMarker * Improve backspace on list (#2555) * fix selection with ctrl+a * refactor code using formatTextSegmentBeforeSelectionMarkerTest * remove getLinkSegment * Set default format in demo site (#2559) * clean demo site * clean * Enable selecting image when the only element in the range is an Image (#2554) * init * Address comment * Reuse isReverted from Range Selection * Fix build * Fix build * Unselect image when Up or Down, or it remains selected * remove unneeded changes and improve name of tests * Update --------- Co-authored-by: Julia Roldi <[email protected]> * fix markdown plugin * Port Hyperlink plugin (#2560) * Port Hyperlink plugin * improve --------- Co-authored-by: Bryan Valverde U <[email protected]> * export formatTextSegmentBeforeSelectionMarker * fix build * Prevent ScrollTop to be lost when the focus is done to the editor (#2564) * init * init --------- Co-authored-by: Julia Roldi <[email protected]> * Fix 265959: extra empty line generated when get plain text (#2566) Co-authored-by: Bryan Valverde U <[email protected]> * Fix #2500 Hyperlink misses color (#2570) * Fix #2500 * fix test * mac shortcuts * fix test * restore selection (#2577) * fix: on webkit-based applications, when the selection is empty, focus will cause the window to scroll to the top (#2571) Co-authored-by: Julia Roldi <[email protected]> Co-authored-by: Jiuqing Song <[email protected]> * Port PickerPlugin (#2569) * Port PickerPlugin * fix buid * Improve * fix build * Improve * Improve * add test * Improve * adjust image * fix test * fixes * remove * Preserve reverted selection info in Content Model (#2580) * Preserve reverted selection info in Content Model * improve * fix empty text * trigger Events * Allow Shift+Delete to Cut (#2585) * Allow Shift+Delete to Cut * improve * change source * fix build * Fix #2584: Safari context menu event causes selection to be expanded (#2588) * Fix #2584: Safari context menu event causes selection to be expanded * fix test * Port AnnouncePlugin step 1: refactor list number code (#2589) * test * refactor * fix demo site * Select image after inserting it (#2593) * Focus image after insertion * Revert "Focus image after insertion" This reverts commit 887c9e5. * Use setSelection * Port AnnouncePlugin Step 2: Add announce core API (#2591) * Port AnnouncePlugin step 1: refactor list number code * Port AnnouncePlugin step 2 --------- Co-authored-by: Bryan Valverde U <[email protected]> * WIP * custom replace * Fix table mover selector (#2596) * fix edge case tables and trigger contentchanged * revert event * trigger autolink * wip * Port AnnouncePlugin step 3: Add announce features for list and table (#2592) * Port AnnouncePlugin step 1: refactor list number code * Port AnnouncePlugin step 2 * Port AnnouncePlugin ste 3 * add test * Fix #2575 Entity delimiter cursor moving (#2581) * Preserve reverted selection info in Content Model * Entity delimiter cursor moving (#2575) * improve * Add test * add test * Allow customizability for table editors (#2603) * init * Simplify type callback * Also allow using Ctrl-Shift-Z on Windows (#2607) * Also allow using Ctrl-Shift-Z on Windows * Fix failing test * Fix broken test * Fix failing test * Keep and deprecate old ShortcutRedoMacOS * Remove test not needed anymore * Wip * add span * fix test * changes * remove code * fixes * fixes * Hide watermark when input with IME (#2611) * Updated watermark property access modifier to protected (#2614) * Move Content Model type files into contentModel folder (#2602) * Fix 262779 (#2600) * Add undo snapshot when mouse down if there is new content after last undo snapshot (#2604) * Fix #2601 allow customization when convert from content model to plain text (#2605) * Fix #2601 allow customization when convert from content model to plain text * Improve * fix test * fix build * Scroll caret into view when call formatContentModel (#2617) * Perf step 0: Do not allow getting connected model (#2615) * Perf: Do not allow getting connected model * fix build * fix build * debug firefox options (#2620) * Updated isModelEmptyFast to consider changed indentation as not empty string (#2625) * Updated isModelEmptyFast * Tests fix * Add parameter to Disable table edit features (#2624) * disableFeatures, renaming * Export Table Feature Ids * Modify and create tests * move Id to respective feature, add tests, cleanup * export feature names * TableEditFeatureName * Implement Table Movement (#2599) * isNodeEditor * domHelper test * implementation and test fix * fix undefined * isNodeEditor * implement live focus, restore initial selection on cancel * broswer drag and drop attempt * use getNodePositionFromEvent, add move cursor while dragging * restore class * fix import * restore DOMHelper * remove unneeded snapshots and checks, add copy feature * cleanup * fix merge * cursor change on copy, remove onEditorCreated * fix disposal issue * removed unused forEach, * export formatInsertPointWithContentModel * use formatInsertPointWithContentModel for table movement * reorder function * Add tests for table movement * optimisations and exports for testing * restore final table selection after move * added test * fix and add more tests * comments, remove copy feature, fix tests * fix test * fix test * implement disable movement * Do not apply Table selection if table is not editable (#2628) * Fix #2633 `scrollCaretIntoView` causes unexpected scroll (#2634) * Fix #2633 * add comment * Added tableCellSelectionBackgroundColor option (#2640) * Added tableCellSelectionBackgroundColor option * Fixed a test * Tests fix * Tests fix * Add dark color handling for table and image selection (#2647) * Added tableCellSelectionBackgroundColor option * Fixed a test * Tests fix * Tests fix * Add dark color check * Add more tests * Updated login and tests * Functionality update * Update checks * Added transparent options test * Code review fixes * Fix cursor jump issue when applying Gboard suggestions (#2638) * fix cursor issue * resolve comment --------- Co-authored-by: Jiuqing Song <[email protected]> * Content Model Cache improvement - Step 1: Introduce Readonly types and mutate utility (#2629) * Readonly types (3rd try * Improve * fix build * Improve * improve * Improve * Add shallow mutable type * improve * Improve * improve * improve * add test * improve * improve * improve * test * test * link preview * remove auto format plugin code * Content Model Cache improvement - Step 2: Prepare utility functions (#2641) * Readonly types (3rd try * Improve * fix build * Improve * improve * Improve * Add shallow mutable type * improve * Improve * improve * improve * add test * Readonly types step 2 * add test * Improve * improve * improve * improve * Improve * fix test * improve * Content Model Cache improvement - Step 3: Let creators accept readonly types (#2642) * Readonly types (3rd try * Improve * fix build * Improve * improve * Improve * Add shallow mutable type * improve * Improve * improve * improve * add test * Readonly types step 3 * improve * improve * improve * Content Model Cache improvement - Step 4: Port "readonly" functions (#2643) * Readonly types (3rd try * Improve * fix build * Improve * improve * Improve * Add shallow mutable type * improve * Improve * improve * improve * add test * Readonly types step 2 * Readonly types step 3 * Readonly type step 4 * add test * Improve * improve * improve * improve * improve * Improve * improve * fix test * improve * Fix Table first column (#2652) * create Table Options button for demo * fix setFirstColumnFormat * fix dependency * restore background color check for first column * remove logs, move TableOptionsMenuItemStringKey, isHeader * remove import * Content Model Cache improvement - Step 5: Port roosterjs-content-model-dom package (#2648) * Readonly types (3rd try * Improve * fix build * Improve * improve * Improve * Add shallow mutable type * improve * Improve * improve * improve * add test * Readonly types step 2 * Readonly types step 3 * Readonly type step 4 * add test * Improve * improve * improve * Readonly types step 5: dom package * add change * improve * improve * Improve * improve * fix test * Improve * fix build * improve * Optimise content model table fetching for Table Edit Plugins (#2656) * optimise cmTable fetching * create getCMTableFromTable * Fix normalisation and First Column issues (#2657) * optimise cmTable fetching * First Column not apply to very first cell * fix normalisation * fix first cell color for First Column * fix and add test * fix test * fix tests * fix test and hasHeaderRow case * reorder rows * bump * bump --------- Co-authored-by: Júlia Roldi <[email protected]> Co-authored-by: Julia Roldi <[email protected]> Co-authored-by: Jiuqing Song <[email protected]> Co-authored-by: Bryan Valverde U <[email protected]> Co-authored-by: Rain-Zheng <[email protected]> Co-authored-by: 庄黛淳华 <[email protected]> Co-authored-by: florian-msft <[email protected]> Co-authored-by: vhuseinova-msft <[email protected]>
1 parent 5638d0e commit 10c1d9d

File tree

161 files changed

+4315
-987
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

161 files changed

+4315
-987
lines changed

demo/scripts/controlsV2/demoButtons/setTableHeaderButton.ts

-13
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { formatTable, getFormatState } from 'roosterjs-content-model-api';
2+
import { TableMetadataFormat } from 'roosterjs-content-model-types';
3+
import type { RibbonButton } from '../roosterjsReact/ribbon';
4+
5+
const TableEditOperationMap: Partial<Record<
6+
TableOptionsMenuItemStringKey,
7+
keyof TableMetadataFormat
8+
>> = {
9+
menuNameTableSetHeaderRow: 'hasHeaderRow',
10+
menuNameTableSetFirstColumn: 'hasFirstColumn',
11+
menuNameTableSetBandedColumns: 'hasBandedColumns',
12+
menuNameTableSetBandedRows: 'hasBandedRows',
13+
};
14+
15+
/**
16+
* Key of localized strings of Table Options menu items
17+
*/
18+
type TableOptionsMenuItemStringKey =
19+
| 'menuNameTableSetHeaderRow'
20+
| 'menuNameTableSetFirstColumn'
21+
| 'menuNameTableSetBandedColumns'
22+
| 'menuNameTableSetBandedRows';
23+
24+
export const tableOptionsButton: RibbonButton<
25+
'ribbonButtonTableOptions' | TableOptionsMenuItemStringKey
26+
> = {
27+
key: 'ribbonButtonTableOptions',
28+
iconName: '',
29+
unlocalizedText: 'Options',
30+
isDisabled: formatState => !formatState.isInTable,
31+
dropDownMenu: {
32+
items: {
33+
menuNameTableSetHeaderRow: 'Header Row',
34+
menuNameTableSetFirstColumn: 'First Column',
35+
menuNameTableSetBandedColumns: 'Banded Columns',
36+
menuNameTableSetBandedRows: 'Banded Rows',
37+
},
38+
},
39+
onClick: (editor, key) => {
40+
if (key != 'ribbonButtonTableOptions') {
41+
const format = getFormatState(editor);
42+
const tableFormatProperty = TableEditOperationMap[key];
43+
formatTable(
44+
editor,
45+
{ [tableFormatProperty]: !format.tableFormat[tableFormatProperty] },
46+
true /*keepCellShade*/
47+
);
48+
}
49+
},
50+
commandBarProperties: {
51+
iconOnly: false,
52+
},
53+
};

demo/scripts/controlsV2/sidePane/apiPlayground/insertEntity/InsertEntityPane.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { ApiPaneProps } from '../ApiPaneProps';
33
import { insertEntity } from 'roosterjs-content-model-api';
44
import { trustedHTMLHandler } from '../../../../utils/trustedHTMLHandler';
55
import {
6-
ContentModelBlockGroup,
76
ContentModelEntity,
87
InsertEntityOptions,
8+
ReadonlyContentModelBlockGroup,
99
} from 'roosterjs-content-model-types';
1010

1111
const styles = require('./InsertEntityPane.scss');
@@ -155,7 +155,7 @@ export default class InsertEntityPane extends React.Component<ApiPaneProps, Inse
155155
};
156156
}
157157

158-
function findAllEntities(group: ContentModelBlockGroup, result: ContentModelEntity[]) {
158+
function findAllEntities(group: ReadonlyContentModelBlockGroup, result: ContentModelEntity[]) {
159159
group.blocks.forEach(block => {
160160
switch (block.blockType) {
161161
case 'BlockGroup':

demo/scripts/controlsV2/sidePane/contentModel/ContentModelPanePlugin.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { cloneModel } from 'roosterjs-content-model-dom';
12
import { ContentModelPane, ContentModelPaneProps } from './ContentModelPane';
23
import { createRibbonPlugin, RibbonButton, RibbonPlugin } from '../../roosterjsReact/ribbon';
34
import { getRefreshButton } from './buttons/refreshButton';
@@ -70,8 +71,9 @@ export class ContentModelPanePlugin extends SidePanePluginImpl<
7071
this.getComponent(component => {
7172
this.editor.formatContentModel(
7273
model => {
73-
component.setContentModel(model);
74-
setCurrentContentModel(model);
74+
const clonedModel = cloneModel(model);
75+
component.setContentModel(clonedModel);
76+
setCurrentContentModel(clonedModel);
7577

7678
return false;
7779
},

demo/scripts/controlsV2/sidePane/contentModel/components/format/MetadataView.tsx

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
import * as React from 'react';
2-
import { ContentModelWithDataset } from 'roosterjs-content-model-types';
32
import { FormatRenderer } from './utils/FormatRenderer';
3+
import {
4+
ContentModelWithDataset,
5+
ShallowMutableContentModelWithDataset,
6+
} from 'roosterjs-content-model-types';
47

58
const styles = require('./FormatView.scss');
69

710
export function MetadataView<T>(props: {
811
model: ContentModelWithDataset<T>;
912
renderers: FormatRenderer<T>[];
10-
updater: (model: ContentModelWithDataset<T>, callback: (format: T | null) => T | null) => void;
13+
updater: (
14+
model: ShallowMutableContentModelWithDataset<T>,
15+
callback: (format: T | null) => T | null
16+
) => void;
1117
}) {
1218
const { model, renderers, updater } = props;
1319
const metadata = React.useRef<T>(null);

demo/scripts/controlsV2/tabs/ribbonButtons.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ import { setBulletedListStyleButton } from '../demoButtons/setBulletedListStyleB
3737
import { setHeadingLevelButton } from '../roosterjsReact/ribbon/buttons/setHeadingLevelButton';
3838
import { setNumberedListStyleButton } from '../demoButtons/setNumberedListStyleButton';
3939
import { setTableCellShadeButton } from '../demoButtons/setTableCellShadeButton';
40-
import { setTableHeaderButton } from '../demoButtons/setTableHeaderButton';
4140
import { spaceAfterButton, spaceBeforeButton } from '../demoButtons/spaceBeforeAfterButtons';
4241
import { spacingButton } from '../demoButtons/spacingButton';
4342
import { strikethroughButton } from '../roosterjsReact/ribbon/buttons/strikethroughButton';
@@ -47,6 +46,7 @@ import { tableBorderApplyButton } from '../demoButtons/tableBorderApplyButton';
4746
import { tableBorderColorButton } from '../demoButtons/tableBorderColorButton';
4847
import { tableBorderStyleButton } from '../demoButtons/tableBorderStyleButton';
4948
import { tableBorderWidthButton } from '../demoButtons/tableBorderWidthButton';
49+
import { tableOptionsButton } from '../demoButtons/tableOptionsButton';
5050
import { tabNames } from './getTabs';
5151
import { textColorButton } from '../roosterjsReact/ribbon/buttons/textColorButton';
5252
import { underlineButton } from '../roosterjsReact/ribbon/buttons/underlineButton';
@@ -79,7 +79,7 @@ const tableButtons: RibbonButton<any>[] = [
7979
insertTableButton,
8080
formatTableButton,
8181
setTableCellShadeButton,
82-
setTableHeaderButton,
82+
tableOptionsButton,
8383
tableInsertButton,
8484
tableDeleteButton,
8585
tableBorderApplyButton,
@@ -169,7 +169,7 @@ const allButtons: RibbonButton<any>[] = [
169169
listStartNumberButton,
170170
formatTableButton,
171171
setTableCellShadeButton,
172-
setTableHeaderButton,
172+
tableOptionsButton,
173173
tableInsertButton,
174174
tableDeleteButton,
175175
tableMergeButton,

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

+14-12
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@ import {
44
createListLevel,
55
getOperationalBlocks,
66
isBlockGroupOfType,
7+
mutateBlock,
78
parseValueWithUnit,
89
updateListMetadata,
910
} from 'roosterjs-content-model-dom';
1011
import type {
11-
ContentModelBlock,
1212
ContentModelBlockFormat,
13-
ContentModelBlockGroup,
14-
ContentModelDocument,
1513
ContentModelListItem,
1614
ContentModelListLevel,
1715
FormatContentModelContext,
16+
ReadonlyContentModelBlock,
17+
ReadonlyContentModelBlockGroup,
18+
ReadonlyContentModelDocument,
19+
ReadonlyContentModelListItem,
1820
} from 'roosterjs-content-model-types';
1921

2022
const IndentStepInPixel = 40;
@@ -26,7 +28,7 @@ const IndentStepInPixel = 40;
2628
* Set indentation for selected list items or paragraphs
2729
*/
2830
export function setModelIndentation(
29-
model: ContentModelDocument,
31+
model: ReadonlyContentModelDocument,
3032
indentation: 'indent' | 'outdent',
3133
length: number = IndentStepInPixel,
3234
context?: FormatContentModelContext
@@ -37,7 +39,7 @@ export function setModelIndentation(
3739
['TableCell']
3840
);
3941
const isIndent = indentation == 'indent';
40-
const modifiedBlocks: ContentModelBlock[] = [];
42+
const modifiedBlocks: ReadonlyContentModelBlock[] = [];
4143

4244
paragraphOrListItem.forEach(({ block, parent, path }) => {
4345
if (isBlockGroupOfType<ContentModelListItem>(block, 'ListItem')) {
@@ -89,12 +91,12 @@ export function setModelIndentation(
8991
}
9092
}
9193
} else if (block) {
92-
let currentBlock: ContentModelBlock = block;
93-
let currentParent: ContentModelBlockGroup = parent;
94+
let currentBlock: ReadonlyContentModelBlock = block;
95+
let currentParent: ReadonlyContentModelBlockGroup = parent;
9496

9597
while (currentParent && modifiedBlocks.indexOf(currentBlock) < 0) {
9698
const index = path.indexOf(currentParent);
97-
const { format } = currentBlock;
99+
const { format } = mutateBlock(currentBlock);
98100
const newValue = calculateMarginValue(format, isIndent, length);
99101

100102
if (newValue !== null) {
@@ -124,7 +126,7 @@ export function setModelIndentation(
124126
return paragraphOrListItem.length > 0;
125127
}
126128

127-
function isSelected(listItem: ContentModelListItem) {
129+
function isSelected(listItem: ReadonlyContentModelListItem) {
128130
return listItem.blocks.some(block => {
129131
if (block.blockType == 'Paragraph') {
130132
return block.segments.some(segment => segment.isSelected);
@@ -137,9 +139,9 @@ function isSelected(listItem: ContentModelListItem) {
137139
* Otherwise, the margin of the first item will be changed, and the sub list will be created, creating a unintentional margin difference between the list items.
138140
*/
139141
function isMultilevelSelection(
140-
model: ContentModelDocument,
141-
listItem: ContentModelListItem,
142-
parent: ContentModelBlockGroup
142+
model: ReadonlyContentModelDocument,
143+
listItem: ReadonlyContentModelListItem,
144+
parent: ReadonlyContentModelBlockGroup
143145
) {
144146
const listIndex = parent.blocks.indexOf(listItem);
145147
for (let i = listIndex - 1; i >= 0; i--) {

packages/roosterjs-content-model-api/lib/modelApi/entity/insertEntityModel.ts

+12-9
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,18 @@ import {
66
deleteSelection,
77
getClosestAncestorBlockGroupIndex,
88
setSelection,
9+
mutateBlock,
910
} from 'roosterjs-content-model-dom';
1011
import type {
11-
ContentModelBlock,
12-
ContentModelBlockGroup,
1312
ContentModelDocument,
1413
ContentModelEntity,
15-
ContentModelParagraph,
1614
FormatContentModelContext,
1715
InsertEntityPosition,
1816
InsertPoint,
17+
ReadonlyContentModelBlock,
18+
ShallowMutableContentModelBlock,
19+
ShallowMutableContentModelBlockGroup,
20+
ShallowMutableContentModelParagraph,
1921
} from 'roosterjs-content-model-types';
2022

2123
/**
@@ -30,7 +32,7 @@ export function insertEntityModel(
3032
context?: FormatContentModelContext,
3133
insertPointOverride?: InsertPoint
3234
) {
33-
let blockParent: ContentModelBlockGroup | undefined;
35+
let blockParent: ShallowMutableContentModelBlockGroup | undefined;
3436
let blockIndex = -1;
3537
let insertPoint: InsertPoint | null;
3638

@@ -57,9 +59,10 @@ export function insertEntityModel(
5759
position == 'root'
5860
? getClosestAncestorBlockGroupIndex(path, ['TableCell', 'Document'])
5961
: 0;
60-
blockParent = path[pathIndex];
62+
blockParent = mutateBlock(path[pathIndex]);
63+
6164
const child = path[pathIndex - 1];
62-
const directChild: ContentModelBlock =
65+
const directChild: ReadonlyContentModelBlock =
6366
child?.blockGroupType == 'FormatContainer' ||
6467
child?.blockGroupType == 'General' ||
6568
child?.blockGroupType == 'ListItem'
@@ -71,16 +74,16 @@ export function insertEntityModel(
7174
}
7275

7376
if (blockIndex >= 0 && blockParent) {
74-
const blocksToInsert: ContentModelBlock[] = [];
75-
let nextParagraph: ContentModelParagraph | undefined;
77+
const blocksToInsert: ShallowMutableContentModelBlock[] = [];
78+
let nextParagraph: ShallowMutableContentModelParagraph | undefined;
7679

7780
if (isBlock) {
7881
const nextBlock = blockParent.blocks[blockIndex];
7982

8083
blocksToInsert.push(entityModel);
8184

8285
if (nextBlock?.blockType == 'Paragraph') {
83-
nextParagraph = nextBlock;
86+
nextParagraph = mutateBlock(nextBlock);
8487
} else if (!nextBlock || nextBlock.blockType == 'Entity' || focusAfterEntity) {
8588
nextParagraph = createParagraph(false /*isImplicit*/, {}, model.format);
8689
nextParagraph.segments.push(createBr(model.format));

packages/roosterjs-content-model-api/lib/modelApi/list/findListItemsInSameThread.ts

+33-10
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,45 @@
1-
import type { ContentModelBlockGroup, ContentModelListItem } from 'roosterjs-content-model-types';
1+
import type {
2+
ContentModelBlockGroup,
3+
ContentModelListItem,
4+
ReadonlyContentModelBlockGroup,
5+
ReadonlyContentModelListItem,
6+
} from 'roosterjs-content-model-types';
27

38
/**
9+
* Search for all list items in the same thread as the current list item
410
* @param model The content model
511
* @param currentItem The current list item
6-
* Search for all list items in the same thread as the current list item
712
*/
813
export function findListItemsInSameThread(
914
group: ContentModelBlockGroup,
1015
currentItem: ContentModelListItem
11-
): ContentModelListItem[] {
16+
): ContentModelListItem[];
17+
18+
/**
19+
* Search for all list items in the same thread as the current list item (Readonly)
20+
* @param model The content model
21+
* @param currentItem The current list item
22+
*/
23+
export function findListItemsInSameThread(
24+
group: ReadonlyContentModelBlockGroup,
25+
currentItem: ReadonlyContentModelListItem
26+
): ReadonlyContentModelListItem[];
27+
28+
export function findListItemsInSameThread(
29+
group: ReadonlyContentModelBlockGroup,
30+
currentItem: ReadonlyContentModelListItem
31+
): ReadonlyContentModelListItem[] {
1232
const items: (ContentModelListItem | null)[] = [];
1333

1434
findListItems(group, items);
1535

1636
return filterListItems(items, currentItem);
1737
}
1838

19-
function findListItems(group: ContentModelBlockGroup, result: (ContentModelListItem | null)[]) {
39+
function findListItems(
40+
group: ReadonlyContentModelBlockGroup,
41+
result: (ReadonlyContentModelListItem | null)[]
42+
) {
2043
group.blocks.forEach(block => {
2144
switch (block.blockType) {
2245
case 'BlockGroup':
@@ -56,7 +79,7 @@ function findListItems(group: ContentModelBlockGroup, result: (ContentModelListI
5679
});
5780
}
5881

59-
function pushNullIfNecessary(result: (ContentModelListItem | null)[]) {
82+
function pushNullIfNecessary(result: (ReadonlyContentModelListItem | null)[]) {
6083
const last = result[result.length - 1];
6184

6285
if (!last || last !== null) {
@@ -65,10 +88,10 @@ function pushNullIfNecessary(result: (ContentModelListItem | null)[]) {
6588
}
6689

6790
function filterListItems(
68-
items: (ContentModelListItem | null)[],
69-
currentItem: ContentModelListItem
91+
items: (ReadonlyContentModelListItem | null)[],
92+
currentItem: ReadonlyContentModelListItem
7093
) {
71-
const result: ContentModelListItem[] = [];
94+
const result: ReadonlyContentModelListItem[] = [];
7295
const currentIndex = items.indexOf(currentItem);
7396
const levelLength = currentItem.levels.length;
7497
const isOrderedList = currentItem.levels[levelLength - 1]?.listType == 'OL';
@@ -131,7 +154,7 @@ function filterListItems(
131154
}
132155

133156
function areListTypesCompatible(
134-
listItems: (ContentModelListItem | null)[],
157+
listItems: (ReadonlyContentModelListItem | null)[],
135158
currentIndex: number,
136159
compareToIndex: number
137160
): boolean {
@@ -146,7 +169,7 @@ function areListTypesCompatible(
146169
);
147170
}
148171

149-
function hasStartNumberOverride(item: ContentModelListItem, levelLength: number): boolean {
172+
function hasStartNumberOverride(item: ReadonlyContentModelListItem, levelLength: number): boolean {
150173
return item.levels
151174
.slice(0, levelLength)
152175
.some(level => level.format.startNumberOverride !== undefined);

0 commit comments

Comments
 (0)