diff --git a/package.json b/package.json index 616f3f541e..2bf2b7c5a9 100644 --- a/package.json +++ b/package.json @@ -82,6 +82,7 @@ "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#develop", "minimist": "^1.2.0", "pako": "^1.0.5", + "parse5": "^5.1.1", "png-chunks-extract": "^1.0.0", "project-name-generator": "^2.1.7", "prop-types": "^15.5.8", diff --git a/src/SlashCommands.tsx b/src/SlashCommands.tsx index 0afea63a78..ff9ebbc70a 100644 --- a/src/SlashCommands.tsx +++ b/src/SlashCommands.tsx @@ -36,6 +36,8 @@ import { getDefaultIdentityServerUrl, useDefaultIdentityServer } from './utils/I import {isPermalinkHost, parsePermalink} from "./utils/permalinks/Permalinks"; import {inviteUsersToRoom} from "./RoomInvite"; import { WidgetType } from "./widgets/WidgetType"; +import { Jitsi } from "./widgets/Jitsi"; +import { parseFragment as parseHtml } from "parse5"; // XXX: workaround for https://github.com/microsoft/TypeScript/issues/31816 interface HTMLInputEvent extends Event { @@ -765,18 +767,50 @@ export const Commands = [ }), new Command({ command: 'addwidget', - args: '', + args: '', description: _td('Adds a custom widget by URL to the room'), - runFn: function(roomId, args) { - if (!args || (!args.startsWith("https://") && !args.startsWith("http://"))) { + runFn: function(roomId, widgetUrl) { + if (!widgetUrl) { + return reject(_t("Please supply a widget URL or embed code")); + } + + // Try and parse out a widget URL from iframes + if (widgetUrl.toLowerCase().startsWith("