This repository was archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 826
Update rich text editor dependency and associated changes #11098
Merged
artcodespace
merged 17 commits into
develop
from
alunturner/format-message-output-correctly
Jun 19, 2023
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
a224b68
fix logic error
eeabf03
update types
62a948b
extract message content to variable
b8457b0
use the new messageContent property
5b7a111
sort out mention types to make them a map
5198c12
update getMentionAttributes to use AllowedMentionAttributes
7671598
add plain text handling
ee89c25
change type and handling for attributes when creating a mention in pl…
cda3f99
tidy, add comment
b802965
revert TS config change
1eb6acc
fix broken types in test
b5ca2b1
Merge remote-tracking branch 'origin/develop' into alunturner/format-…
a36412e
update tests
86448e5
Merge branch 'develop' into alunturner/format-message-output-correctly
be7745b
bump rte
30b4352
fix import and ts errors
88a2540
fix broken tests
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ limitations under the License. | |
*/ | ||
|
||
import { KeyboardEvent, RefObject, SyntheticEvent, useCallback, useRef, useState } from "react"; | ||
import { Attributes, MappedSuggestion } from "@matrix-org/matrix-wysiwyg"; | ||
import { AllowedMentionAttributes, MappedSuggestion } from "@matrix-org/matrix-wysiwyg"; | ||
import { IEventRelation } from "matrix-js-sdk/src/matrix"; | ||
|
||
import { useSettingValue } from "../../../../../hooks/useSettings"; | ||
|
@@ -72,7 +72,8 @@ export function usePlainTextListeners( | |
onPaste(event: SyntheticEvent<HTMLDivElement, InputEvent | ClipboardEvent>): void; | ||
onKeyDown(event: KeyboardEvent<HTMLDivElement>): void; | ||
setContent(text?: string): void; | ||
handleMention: (link: string, text: string, attributes: Attributes) => void; | ||
handleMention: (link: string, text: string, attributes: AllowedMentionAttributes) => void; | ||
handleAtRoomMention: (attributes: AllowedMentionAttributes) => void; | ||
handleCommand: (text: string) => void; | ||
onSelect: (event: SyntheticEvent<HTMLDivElement>) => void; | ||
suggestion: MappedSuggestion | null; | ||
|
@@ -97,10 +98,11 @@ export function usePlainTextListeners( | |
setContent(text); | ||
onChange?.(text); | ||
} else if (isNotNull(ref) && isNotNull(ref.current)) { | ||
// if called with no argument, read the current innerHTML from the ref | ||
// if called with no argument, read the current innerHTML from the ref and amend it as per `onInput` | ||
const currentRefContent = ref.current.innerHTML; | ||
setContent(currentRefContent); | ||
onChange?.(currentRefContent); | ||
const amendedContent = amendInnerHtml(currentRefContent); | ||
setContent(amendedContent); | ||
onChange?.(amendedContent); | ||
Comment on lines
+103
to
+105
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was an error I picked up working in the area, the content of the composer needs to be run through |
||
} | ||
}, | ||
[onChange, ref], | ||
|
@@ -109,7 +111,7 @@ export function usePlainTextListeners( | |
// For separation of concerns, the suggestion handling is kept in a separate hook but is | ||
// nested here because we do need to be able to update the `content` state in this hook | ||
// when a user selects a suggestion from the autocomplete menu | ||
const { suggestion, onSelect, handleCommand, handleMention } = useSuggestion(ref, setText); | ||
const { suggestion, onSelect, handleCommand, handleMention, handleAtRoomMention } = useSuggestion(ref, setText); | ||
|
||
const enterShouldSend = !useSettingValue<boolean>("MessageComposerInput.ctrlEnterToSend"); | ||
const onInput = useCallback( | ||
|
@@ -188,5 +190,6 @@ export function usePlainTextListeners( | |
onSelect, | ||
handleCommand, | ||
handleMention, | ||
handleAtRoomMention, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the change that ensures our message content, when sent, is correctly formatted according to the matrix spec as opposed to being exactly the markup used in the html inside the composer.