Switch to linkify-react for element Linkification as it handles React subtrees without exploding (#10060

* Switch to linkify-react instead of our faulty implementation

Fixes a series of soft crashes where errors include "The node to be removed is not a child of this node."

* Improve types

* Fix types

* Update snapshots

* Add test

* Fix test
This commit is contained in:
Michael Telatynski 2023-02-03 08:59:21 +00:00 committed by GitHub
parent 089557005a
commit 2bde31dcff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 101 additions and 193 deletions

View file

@ -16,7 +16,7 @@ limitations under the License.
*/
import * as linkifyjs from "linkifyjs";
import { registerCustomProtocol, registerPlugin } from "linkifyjs";
import { Opts, registerCustomProtocol, registerPlugin } from "linkifyjs";
import linkifyElement from "linkify-element";
import linkifyString from "linkify-string";
import { RoomMember } from "matrix-js-sdk/src/models/room-member";
@ -139,9 +139,9 @@ export const ELEMENT_URL_PATTERN =
"(?:app|beta|staging|develop)\\.element\\.io/" +
")(#.*)";
export const options = {
events: function (href: string, type: Type | string): Partial<GlobalEventHandlers> {
switch (type) {
export const options: Opts = {
events: function (href: string, type: string): Partial<GlobalEventHandlers> {
switch (type as Type) {
case Type.URL: {
// intercept local permalinks to users and show them like userids (in userinfo of current room)
try {