Simplify types (#28749)

This commit is contained in:
Michael Telatynski
2024-12-23 16:12:56 +00:00
committed by GitHub
parent db02f26005
commit 0b24d33c64
6 changed files with 12 additions and 41 deletions
+3 -4
View File
@@ -7,7 +7,7 @@ Please see LICENSE files in the repository root for full details.
*/
import React, { ReactElement } from "react";
import sanitizeHtml from "sanitize-html";
import sanitizeHtml, { IOptions } from "sanitize-html";
import { merge } from "lodash";
import _Linkify from "linkify-react";
@@ -17,7 +17,6 @@ import {
ELEMENT_URL_PATTERN,
options as linkifyMatrixOptions,
} from "./linkify-matrix";
import { IExtendedSanitizeOptions } from "./@types/sanitize-html";
import SettingsStore from "./settings/SettingsStore";
import { tryTransformPermalinkToLocalHref } from "./utils/permalinks/Permalinks";
import { mediaFromMxc } from "./customisations/Media";
@@ -26,7 +25,7 @@ import { PERMITTED_URL_SCHEMES } from "./utils/UrlUtils";
const COLOR_REGEX = /^#[0-9a-fA-F]{6}$/;
const MEDIA_API_MXC_REGEX = /\/_matrix\/media\/r0\/(?:download|thumbnail)\/(.+?)\/(.+?)(?:[?/]|$)/;
export const transformTags: NonNullable<IExtendedSanitizeOptions["transformTags"]> = {
export const transformTags: NonNullable<IOptions["transformTags"]> = {
// custom to matrix
// add blank targets to all hyperlinks except vector URLs
"a": function (tagName: string, attribs: sanitizeHtml.Attributes) {
@@ -137,7 +136,7 @@ export const transformTags: NonNullable<IExtendedSanitizeOptions["transformTags"
},
};
export const sanitizeHtmlParams: IExtendedSanitizeOptions = {
export const sanitizeHtmlParams: IOptions = {
allowedTags: [
// These tags are suggested by the spec https://spec.matrix.org/v1.10/client-server-api/#mroommessage-msgtypes
"font", // custom to matrix for IRC-style font coloring