From 56a8711ca1edbdcf234ea167c45786ed31e9fca7 Mon Sep 17 00:00:00 2001 From: Michael Schmidt Date: Tue, 3 Sep 2019 20:52:15 +0200 Subject: [PATCH] Website: Fixed the Toolbar plusing's overflow issue (#1966) This fixes the overflow issue of all Toolbar related plugins where some button were hidden behind the theme selection. --- scripts/code.js | 23 +++++++++++++++++++++++ style.css | 9 +++++++++ 2 files changed, 32 insertions(+) diff --git a/scripts/code.js b/scripts/code.js index 69ac0b97d2..a4847e7174 100644 --- a/scripts/code.js +++ b/scripts/code.js @@ -210,4 +210,27 @@ function listPlugins(ul) { $$('.plugin-list').forEach(listPlugins); +// small polyfill for Element#matches +if (!Element.prototype.matches) { + Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector; +} + +Prism && Prism.hooks.add('complete', function (env) { + var element = env.element; + + requestAnimationFrame(function () { + if (!element.matches('div.code-toolbar > pre > code')) { + return; + } + + var pre = element.parentElement; + var wrapper = pre.parentElement; + + // transfer margin of pre to wrapper + wrapper.style.margin = window.getComputedStyle(pre).margin; + pre.style.margin = "0"; + + }); +}); + })(); diff --git a/style.css b/style.css index 221b6cd728..4f31839fac 100644 --- a/style.css +++ b/style.css @@ -414,3 +414,12 @@ label a.owner:not(:hover) { margin-bottom: 1em; margin-right: 1em; } + +/* + * Fix for Toolbar's overflow issue + */ + +div.code-toolbar { + display: block; + overflow: auto; +}