From 23b9f667590e996f16b979d885515d527bf18347 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 18 Mar 2022 17:30:57 +0300 Subject: Embed Telegram posts --- src/main/assets/embed.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/main/assets') diff --git a/src/main/assets/embed.js b/src/main/assets/embed.js index bef6f80c..739b95f3 100644 --- a/src/main/assets/embed.js +++ b/src/main/assets/embed.js @@ -283,6 +283,25 @@ function getEmbeddableLinkTypes() { return div; } }, + { + name: 'Telegram posts', + id: 'embed_telegram_posts', + className: 'tg compact', + ctsDefault: true, + re: /https?:\/\/t\.me\/(\S+)/i, + makeNode: function(aNode, reResult, div) { + let [url, post] = reResult; + // innerHTML cannot insert scripts, so... + let script = document.createElement('script'); + script.src = 'https://telegram.org/js/telegram-widget.js?18'; + script.setAttribute('data-telegram-post', post); + script.setAttribute('data-tme-mode', 'data-tme-mode'); + script.setAttribute('data-width', '100%'); + script.charset = 'utf-8'; + div.appendChild(script); + return div; + } + }, ]; } -- cgit v1.2.3