Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions demo/scripts/controlsV2/mainPane/MainPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,7 @@ const AnnounceStringMap: Record<KnownAnnounceStrings, string> = {
announceUnderlineOff: 'Underline Off',
selected: '{0}, selected',
unselected: '{0}, unselected',
newLineInserted: 'New line',
};

function getAnnouncingString(key: KnownAnnounceStrings) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,10 @@ export const handleEnterOnParagraph: (
context.deleteResult = 'range';
context.lastParagraph = newPara;
context.insertPoint.paragraph = newPara;
if (context.formatContext) {
context.formatContext.announceData = {
defaultStrings: 'newLineInserted',
};
}
}
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { handleEnterOnParagraph } from '../../../lib/edit/inputSteps/handleEnterOnParagraph';
import { ValidDeleteSelectionContext } from 'roosterjs-content-model-types';
import {
FormatContentModelContext,
ValidDeleteSelectionContext,
} from 'roosterjs-content-model-types';
import {
createContentModelDocument,
createParagraph,
Expand Down Expand Up @@ -43,6 +46,11 @@ describe('handleEnterOnParagraph', () => {
const mockedCache = {} as any;
const text1 = createText('test1');
const text2 = createText('test1');
const formatContext: FormatContentModelContext = {
newEntities: [],
deletedEntities: [],
newImages: [],
};

para.segments.push(text1, marker, text2);
doc.blocks.push(para);
Expand All @@ -55,6 +63,7 @@ describe('handleEnterOnParagraph', () => {
marker: marker,
path: [doc],
},
formatContext,
};

handleEnterOnParagraph([])(context);
Expand Down Expand Up @@ -98,6 +107,9 @@ describe('handleEnterOnParagraph', () => {
marker: marker,
path: [doc],
});
expect(formatContext.announceData).toEqual({
defaultStrings: 'newLineInserted',
});
});

it('Not deleted, split current paragraph with id', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,15 @@ export type KnownAnnounceStrings =
* @example
* {0}, unselected
*/
| 'unselected';
| 'unselected'

/**
* String announced when a new line is inserted in the editor.
* Used when Enter is pressed and a new line is inserted in the editor.
* @example
* New line inserted
*/
| 'newLineInserted';

/**
* Represents data, that can be used to announce text to screen reader.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const KnownAnnounceStringsNewToOld: Record<
announceUnderlineOff: undefined,
selected: undefined,
unselected: undefined,
newLineInserted: undefined,
};

const EntityOperationOldToNew: Record<OldEntityOperation, NewEntityOperation | undefined> = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,34 @@ describe('newEventToOldEvent', () => {
expect(result.additionalData!.getEntityState!()).toEqual(mockedEntityState);
});

it('ContentChanged with unsupported announce string', () => {
const mockedSource = 'SOURCE';
const result = runTest(
{
eventType: 'contentChanged',
eventDataCache: mockedDataCache,
source: mockedSource,
announceData: {
defaultStrings: 'newLineInserted',
},
},
undefined,
{
eventType: PluginEventType.ContentChanged,
eventDataCache: mockedDataCache,
additionalData: {
formatApiName: undefined,
getAnnounceData: jasmine.anything() as any,
getEntityState: undefined,
},
data: undefined,
source: mockedSource,
}
) as ContentChangedEvent;

expect(result.additionalData!.getAnnounceData!()).toBeUndefined();
});

it('ContextMenu', () => {
const mockedItems = 'ITEMS' as any;

Expand Down
Loading