Replace brittle custom function with lodash implementation (#11188)

pull/28217/head
Michael Telatynski 2023-07-06 09:22:43 +01:00 committed by GitHub
parent d7677c7e21
commit b467d0700f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 12 deletions

View File

@ -20,20 +20,10 @@ import { diff_match_patch as DiffMatchPatch } from "diff-match-patch";
import { DiffDOM, IDiff } from "diff-dom"; import { DiffDOM, IDiff } from "diff-dom";
import { IContent } from "matrix-js-sdk/src/models/event"; import { IContent } from "matrix-js-sdk/src/models/event";
import { logger } from "matrix-js-sdk/src/logger"; import { logger } from "matrix-js-sdk/src/logger";
import { unescape } from "lodash";
import { bodyToHtml, checkBlockNode, IOptsReturnString } from "../HtmlUtils"; import { bodyToHtml, checkBlockNode, IOptsReturnString } from "../HtmlUtils";
const decodeEntities = (function () {
let textarea: HTMLTextAreaElement | undefined;
return function (str: string): string {
if (!textarea) {
textarea = document.createElement("textarea");
}
textarea.innerHTML = str;
return textarea.value;
};
})();
function textToHtml(text: string): string { function textToHtml(text: string): string {
const container = document.createElement("div"); const container = document.createElement("div");
container.textContent = text; container.textContent = text;
@ -153,7 +143,7 @@ function adjustRoutes(diff: IDiff, remainingDiffs: IDiff[]): void {
} }
function stringAsTextNode(string: string): Text { function stringAsTextNode(string: string): Text {
return document.createTextNode(decodeEntities(string)); return document.createTextNode(unescape(string));
} }
function renderDifferenceInDOM(originalRootNode: Node, diff: IDiff, diffMathPatch: DiffMatchPatch): void { function renderDifferenceInDOM(originalRootNode: Node, diff: IDiff, diffMathPatch: DiffMatchPatch): void {