diff --git a/client/components/LinkPreview.vue b/client/components/LinkPreview.vue index f5adfb79..e5bd50f4 100644 --- a/client/components/LinkPreview.vue +++ b/client/components/LinkPreview.vue @@ -126,6 +126,14 @@ export default { mounted() { const options = require("../js/options"); this.$set(this.link, "canDisplay", this.link.type !== "loading" && options.shouldOpenMessagePreview(this.link.type)); + + this.$nextTick(() => { + const escapedLink = this.link.link.replace(/["\\]/g, "\\$&"); + + this.$parent.$refs.text + .querySelector(`.toggle-preview[data-url="${escapedLink}"]`) + .removeAttribute("hidden"); + }); }, methods: { onPreviewReady() { diff --git a/client/components/Message.vue b/client/components/Message.vue index 207e04ed..6c7dc380 100644 --- a/client/components/Message.vue +++ b/client/components/Message.vue @@ -29,6 +29,7 @@ diff --git a/client/css/style.css b/client/css/style.css index 4dfc02e8..6fbe404c 100644 --- a/client/css/style.css +++ b/client/css/style.css @@ -325,8 +325,7 @@ kbd { #help .website-link::before, #help .documentation-link::before, -#help .report-issue-link::before, -#chat .toggle-button { +#help .report-issue-link::before { display: inline-block; margin-right: 5px; diff --git a/client/js/libs/handlebars/parse.js b/client/js/libs/handlebars/parse.js index 1c681452..7c120a5b 100644 --- a/client/js/libs/handlebars/parse.js +++ b/client/js/libs/handlebars/parse.js @@ -93,7 +93,8 @@ module.exports = function parse(text, users = []) { // Wrap these potentially styled fragments with links and channel buttons if (textPart.link) { const escapedLink = Handlebars.Utils.escapeExpression(textPart.link); - return `${fragments}`; + return `${fragments}` + + ``; } else if (textPart.channel) { const escapedChannel = Handlebars.Utils.escapeExpression(textPart.channel); return `${fragments}`; diff --git a/client/js/renderPreview.js b/client/js/renderPreview.js index cfef94f0..6a0b2bdd 100644 --- a/client/js/renderPreview.js +++ b/client/js/renderPreview.js @@ -111,10 +111,8 @@ $(window).on("resize", debounce(togglePreviewMoreButtonsIfNeeded, 150)); $("#chat").on("click", ".text .toggle-button", function() { const self = $(this); - const container = self.closest(".chat"); const content = self.closest(".content") .find(`.preview[data-url="${self.data("url")}"] .toggle-content`); - const bottom = container.isScrollBottom(); self.toggleClass("opened"); content.toggleClass("show"); @@ -134,11 +132,6 @@ $("#chat").on("click", ".text .toggle-button", function() { link: self.data("url"), shown: isExpanded, }); - - // If scrollbar was at the bottom before toggling the preview, keep it at the bottom - if (bottom) { - container.scrollBottom(); - } }); $("#chat").on("click", ".toggle-content .more", function() { diff --git a/client/views/msg_preview_toggle.tpl b/client/views/msg_preview_toggle.tpl deleted file mode 100644 index c9e48f6e..00000000 --- a/client/views/msg_preview_toggle.tpl +++ /dev/null @@ -1,10 +0,0 @@ -{{#preview}} - -{{/preview}}