Update rich text editor dependency and associated changes (#11098)

* fix logic error

* update types

* extract message content to variable

* use the new messageContent property

* sort out mention types to make them a  map

* update getMentionAttributes to use AllowedMentionAttributes

* add plain text handling

* change type and handling for attributes when creating a mention in plain text

* tidy, add comment

* revert TS config change

* fix broken types in test

* update tests

* bump rte

* fix import and ts errors

* fix broken tests
This commit is contained in:
alunturner 2023-06-19 09:00:11 +01:00 committed by GitHub
parent 97765613bc
commit fa31ed55d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 108 additions and 77 deletions

View file

@ -72,7 +72,7 @@ describe("processMention", () => {
it("returns early when suggestion is null", () => {
const mockSetSuggestion = jest.fn();
const mockSetText = jest.fn();
processMention("href", "displayName", {}, null, mockSetSuggestion, mockSetText);
processMention("href", "displayName", new Map(), null, mockSetSuggestion, mockSetText);
expect(mockSetSuggestion).not.toHaveBeenCalled();
expect(mockSetText).not.toHaveBeenCalled();
@ -95,7 +95,7 @@ describe("processMention", () => {
processMention(
href,
displayName,
{ "data-test-attribute": "test" },
new Map([["style", "test"]]),
{ node: textNode, startOffset: 0, endOffset: 2 } as unknown as Suggestion,
mockSetSuggestionData,
mockSetText,
@ -109,7 +109,7 @@ describe("processMention", () => {
expect(linkElement).toBeInstanceOf(HTMLAnchorElement);
expect(linkElement).toHaveAttribute(href, href);
expect(linkElement).toHaveAttribute("contenteditable", "false");
expect(linkElement).toHaveAttribute("data-test-attribute", "test");
expect(linkElement).toHaveAttribute("style", "test");
expect(linkElement.textContent).toBe(displayName);
expect(mockSetText).toHaveBeenCalledWith();