Skip to content

Commit 8a71701

Browse files
ianeli1juliaroldiBryanValverdeUJiuqingSongCopilot
authored
Bump Rooster to 9.42.0 & react pkgs to 9.0.3 (#3212)
* support RTL (#3177) * Update ContextMenuProvider to accept event parameter and adjust related tests (#3175) * refactor: remove deprecated features and clean up related code in CachePlugin and CopyPastePlugin (#3178) * Add `test:fast` for faster unit test runs (#3179) * refactor: optimize karma configuration for improved performance * feat: add fast karma configuration and update package.json for debugging * refactor: streamline karma plugin declaration and update test scripts for clarity * refactor: update test commands to use fast karma configuration * Add support for retaining formats when splitting paragraphs on Enter/Delete/Backspace keypress (#3180) * refactor: optimize karma configuration for improved performance * feat: add fast karma configuration and update package.json for debugging * refactor: streamline karma plugin declaration and update test scripts for clarity * Add support for retaining formats when splitting paragraphs on Enter key press - Introduced `formatsToKeep` option in `EditOptions` to specify which formats to retain. - Updated `keyboardEnter`, `handleEnterOnParagraph`, and `splitParagraph` functions to handle the new formats. - Enhanced tests to verify the correct behavior of format retention during paragraph splits. * Remove unused import for handleEnterOnParagraph in keyboardEnterTest * Remove stray backtick from splitParagraph function * refactor: update test commands to use fast karma configuration * feat: implement class format handling and preserve formatting on paragraph split * feat: rename formatsToKeep to formatsToPreserveOnMerge and update related functionality * test: update spies in keyboardDelete tests and fix format property in preserveParagraphFormat tests * Support rowSpan equal to 0 (#3181) * fix: handle zero colSpan and rowSpan in tableProcessor to ensure proper cell creation * fix: correct colSpan condition in tableProcessor for accurate cell processing * feat: add spanUntilNextSection support in table cell processing and handling * refactor: remove spanUntilNextSection from table cell handling and related tests * refactor: simplify rowSpan handling and improve tableProcessor tests for edge cases * Remove unneeded changes * Remove * fix: update source map configuration for improved debugging accuracy (#3186) * Support passing event to getContextMenuItems when plugin is a MixedPlugin (#3188) * feat: enhance context menu handling to support V9 providers with event parameter * fix: enhance isV9ContextMenuProvider to check for mixed plugins * refactor: simplify spyOn usage for DarkColorHandler in BridgePlugin tests * fix: enhance isV9ContextMenuProvider to validate V9 provider signature * fix: update context menu provider check to use isMixedPluginProvider * New getContentForCopy API (#3182) New getContentForCopy API * feat: add announce options for bold, italic, and underline formatting (#3194) * feat: add announce options for bold, italic, and underline formatting; update shortcuts and tests * refactor: update context initialization in toggleBold, toggleItalic, and toggleUnderline tests for type safety * Address comments from review * test: add unit tests for bold, italic, and underline shortcuts with announceFormatChange * Add Find and Replace API and plugin (#3190) * Add Find and Replace API and plugin * Fix a comment * improve * feat: add announcements for table selection and unselection in the editor (#3195) * feat: add announce options for bold, italic, and underline formatting; update shortcuts and tests * refactor: update context initialization in toggleBold, toggleItalic, and toggleUnderline tests for type safety * feat: add announcements for text selection and unselection in the editor * refactor: simplify table selection logic by using TableSelection type in getIsSelectingOrUnselecting function * Update packages/roosterjs-content-model-core/lib/corePlugin/selection/tableSelectionUtils.ts Co-authored-by: Copilot <[email protected]> * Address comments from review * test: add unit tests for bold, italic, and underline shortcuts with announceFormatChange * Move functionality to a new plugin * Fix * Fix * Fix comment --------- Co-authored-by: Copilot <[email protected]> * Fix #396891 (#3199) * Fix #396891 * improve * improve * first colunm (#3202) * Fix 400434 (#3200) * Add format when insert table (#3203) Add the format parameter in the insertTable API, then it will be possible to insert a table with a predefined format. It can be used to add margin bottom to the table, then when a table is inserted under another their border does not overlay. * Move graduated feature to a separate type (#3205) * Move graduated feature to a separate type * improve * fix build * Translate lineHeight normal to 120% when pasting from Word Desktop and move parsers to their own file (#3209) * Translate lineHeight normal to 120% and move parsers to their own file * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]> * Fix text to bullet issue (#3210) * Fix text to bullet issue * fix test * Update version * Update version on react pkgs --------- Co-authored-by: Julia Roldi <[email protected]> Co-authored-by: Bryan Valverde U <[email protected]> Co-authored-by: Jiuqing Song <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent ff1129d commit 8a71701

File tree

47 files changed

+986
-344
lines changed

Some content is hidden

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

47 files changed

+986
-344
lines changed

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,7 @@ const initialState: OptionState = {
6363
},
6464
customReplacements: emojiReplacements,
6565
disableSideResize: false,
66-
experimentalFeatures: new Set<ExperimentalFeature>([
67-
'PersistCache',
68-
'HandleEnterKey',
69-
'CustomCopyCut',
70-
'CloneIndependentRoot',
71-
]),
66+
experimentalFeatures: new Set<ExperimentalFeature>(['HandleEnterKey', 'CloneIndependentRoot']),
7267
};
7368

7469
export class EditorOptionsPlugin extends SidePanePluginImpl<OptionsPane, OptionPaneProps> {

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ export class ExperimentalFeatures extends React.Component<DefaultFormatProps, {}
1111
render() {
1212
return (
1313
<>
14-
{this.renderFeature('PersistCache')}
1514
{this.renderFeature('HandleEnterKey')}
16-
{this.renderFeature('CustomCopyCut')}
15+
{this.renderFeature('KeepSelectionMarkerWhenEnteringTextNode')}
1716
{this.renderFeature('CloneIndependentRoot')}
1817
</>
1918
);

packages/roosterjs-content-model-api/lib/publicApi/table/insertTable.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,27 @@ import {
99
normalizeTable,
1010
setSelection,
1111
} from 'roosterjs-content-model-dom';
12-
import type { IEditor, TableMetadataFormat } from 'roosterjs-content-model-types';
12+
import type {
13+
ContentModelTableFormat,
14+
IEditor,
15+
TableMetadataFormat,
16+
} from 'roosterjs-content-model-types';
1317

1418
/**
1519
* Insert table into editor at current selection
1620
* @param editor The editor instance
1721
* @param columns Number of columns in table, it also controls the default table cell width:
1822
* if columns &lt;= 4, width = 120px; if columns &lt;= 6, width = 100px; else width = 70px
1923
* @param rows Number of rows in table
20-
* @param format (Optional) The table format. If not passed, the default format will be applied:
21-
* background color: #FFF; border color: #ABABAB
24+
* @param tableMetadataFormat (Optional) The table format that are stored as metadata. If not passed, the default format will be applied: background color: #FFF; border color: #ABABAB
25+
* @param format (Optional) The table format used for style attributes
2226
*/
2327
export function insertTable(
2428
editor: IEditor,
2529
columns: number,
2630
rows: number,
27-
format?: Partial<TableMetadataFormat>
31+
tableMetadataFormat?: Partial<TableMetadataFormat>,
32+
format?: ContentModelTableFormat
2833
) {
2934
editor.focus();
3035

@@ -35,14 +40,17 @@ export function insertTable(
3540
if (insertPosition) {
3641
const doc = createContentModelDocument();
3742
const table = createTableStructure(doc, columns, rows);
43+
if (format) {
44+
table.format = { ...format };
45+
}
3846

3947
normalizeTable(table, editor.getPendingFormat() || insertPosition.marker.format);
4048

4149
adjustTableIndentation(insertPosition, table);
4250

4351
// Assign default vertical align
44-
format = format || { verticalAlign: 'top' };
45-
applyTableFormat(table, format);
52+
tableMetadataFormat = tableMetadataFormat || { verticalAlign: 'top' };
53+
applyTableFormat(table, tableMetadataFormat);
4654
mergeModel(model, doc, context, {
4755
insertPosition,
4856
mergeFormat: 'mergeAll',

packages/roosterjs-content-model-api/test/modelApi/block/splitSelectedParagraphByBrTest.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,11 +468,13 @@ describe('splitSelectedParagraphByBr', () => {
468468
blockType: 'Paragraph',
469469
segments: [text3_1],
470470
format: {},
471+
cachedElement: mockedCache,
471472
},
472473
{
473474
blockType: 'Paragraph',
474475
segments: [text4_1],
475476
format: {},
477+
cachedElement: mockedCache,
476478
},
477479
{
478480
blockType: 'Paragraph',

packages/roosterjs-content-model-api/test/publicApi/table/insertTableTest.ts

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,5 +261,70 @@ describe('insertTable', () => {
261261
],
262262
});
263263
});
264+
265+
it('should insert table with format', () => {
266+
// Arrange
267+
const model: ContentModelDocument = {
268+
blockGroupType: 'Document',
269+
blocks: [
270+
{
271+
blockType: 'Paragraph',
272+
segments: [
273+
{
274+
segmentType: 'SelectionMarker',
275+
isSelected: true,
276+
format: {},
277+
},
278+
],
279+
format: {},
280+
},
281+
],
282+
};
283+
284+
let resultModel: ContentModelDocument | null = null;
285+
286+
formatContentModelSpy.and.callFake((callback: any) => {
287+
const result = callback(model, {
288+
newEntities: [],
289+
deletedEntities: [],
290+
newImages: [],
291+
});
292+
resultModel = model;
293+
return result;
294+
});
295+
296+
// Act
297+
insertTable(editor, 3, 3, undefined, {
298+
marginBottom: '1px',
299+
});
300+
301+
// Assert
302+
expect(resultModel!).toEqual({
303+
blockGroupType: 'Document',
304+
blocks: [
305+
{
306+
blockType: 'Table',
307+
rows: jasmine.any(Array),
308+
format: {
309+
borderCollapse: true,
310+
useBorderBox: true,
311+
marginBottom: '1px',
312+
},
313+
widths: jasmine.any(Array),
314+
dataset: jasmine.any(Object),
315+
},
316+
{
317+
blockType: 'Paragraph',
318+
segments: [
319+
{
320+
segmentType: 'Br',
321+
format: {},
322+
},
323+
],
324+
format: {},
325+
},
326+
],
327+
});
328+
});
264329
});
265330
});

packages/roosterjs-content-model-core/lib/command/createModelFromHtml/createDomToModelContextForSanitizing.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { pasteTextProcessor } from '../../override/pasteTextProcessor';
99
import { pasteWhiteSpaceFormatParser } from '../../override/pasteWhiteSpaceFormatParser';
1010
import type {
1111
ContentModelSegmentFormat,
12+
DOMHelper,
1213
DomToModelContext,
1314
DomToModelOption,
1415
DomToModelOptionForSanitizing,
@@ -32,7 +33,8 @@ export function createDomToModelContextForSanitizing(
3233
document: Document,
3334
defaultFormat?: ContentModelSegmentFormat,
3435
defaultOption?: DomToModelOption,
35-
additionalSanitizingOption?: Partial<DomToModelOptionForSanitizing>
36+
additionalSanitizingOption?: Partial<DomToModelOptionForSanitizing>,
37+
domHelper?: DOMHelper
3638
): DomToModelContext {
3739
const sanitizingOption: DomToModelOptionForSanitizing = {
3840
...DefaultSanitizingOption,
@@ -44,6 +46,7 @@ export function createDomToModelContextForSanitizing(
4446
defaultFormat,
4547
...getRootComputedStyleForContext(document),
4648
experimentalFeatures: [],
49+
editorViewWidth: domHelper?.getClientWidth(),
4750
},
4851
defaultOption,
4952
{

packages/roosterjs-content-model-core/lib/command/paste/mergePasteContent.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ export function mergePasteContent(
6161
editor.getDocument(),
6262
undefined /*defaultFormat*/,
6363
editor.getEnvironment().domToModelSettings.customized,
64-
domToModelOption
64+
domToModelOption,
65+
editor.getDOMHelper()
6566
);
6667

6768
domToModelContext.segmentFormat = getSegmentFormatForPaste(model, pasteType);

packages/roosterjs-content-model-core/lib/coreApi/createEditorContext/createEditorContext.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export const createEditorContext: CreateEditorContext = (core, saveIndex) => {
2121
zoomScale: domHelper.calculateZoomScale(),
2222
experimentalFeatures: core.experimentalFeatures ?? [],
2323
paragraphMap: core.cache.paragraphMap,
24+
editorViewWidth: domHelper.getClientWidth(),
2425
...getRootComputedStyleForContext(logicalRoot.ownerDocument),
2526
};
2627

packages/roosterjs-content-model-core/test/command/createModelFromHtml/createDomToModelContextForSanitizingTest.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ describe('createDomToModelContextForSanitizing', () => {
4545
defaultFormat: undefined,
4646
rootFontSize: 16,
4747
experimentalFeatures: [],
48+
editorViewWidth: undefined,
4849
},
4950
undefined,
5051
{
@@ -77,7 +78,10 @@ describe('createDomToModelContextForSanitizing', () => {
7778
document,
7879
mockedDefaultFormat,
7980
mockedOption,
80-
mockedAdditionalOption
81+
mockedAdditionalOption,
82+
{
83+
getClientWidth: () => 500,
84+
} as any
8185
);
8286

8387
const additionalOption = {
@@ -91,6 +95,7 @@ describe('createDomToModelContextForSanitizing', () => {
9195
defaultFormat: mockedDefaultFormat,
9296
rootFontSize: 16,
9397
experimentalFeatures: [],
98+
editorViewWidth: 500,
9499
},
95100
mockedOption,
96101
{

packages/roosterjs-content-model-core/test/command/paste/mergePasteContentTest.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
InsertPoint,
2525
IEditor,
2626
ClipboardData,
27+
DOMHelper,
2728
} from 'roosterjs-content-model-types';
2829

2930
describe('mergePasteContent', () => {
@@ -33,6 +34,7 @@ describe('mergePasteContent', () => {
3334
let sourceModel: ContentModelDocument;
3435
let editor: IEditor;
3536
let mockedClipboard: ClipboardData;
37+
let mockedDOMHelper: DOMHelper;
3638

3739
beforeEach(() => {
3840
formatResult = undefined;
@@ -54,12 +56,17 @@ describe('mergePasteContent', () => {
5456
expect(changedData).toBe(mockedClipboard);
5557
});
5658

59+
mockedDOMHelper = {
60+
getClientWidth: () => 800,
61+
} as any;
62+
5763
editor = {
5864
formatContentModel,
5965
getEnvironment: () => ({
6066
domToModelSettings: {},
6167
}),
6268
getDocument: () => document,
69+
getDOMHelper: () => mockedDOMHelper,
6370
} as any;
6471
});
6572

@@ -420,7 +427,8 @@ describe('mergePasteContent', () => {
420427
document,
421428
undefined,
422429
mockedDomToModelOptions,
423-
mockedDefaultDomToModelOptions
430+
mockedDefaultDomToModelOptions,
431+
mockedDOMHelper
424432
);
425433
expect(mockedDomToModelContext.segmentFormat).toEqual({ lineHeight: '1pt' });
426434
});

0 commit comments

Comments
 (0)