Skip to content

Commit 56a8711

Browse files
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.
1 parent 8403e45 commit 56a8711

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

scripts/code.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,4 +210,27 @@ function listPlugins(ul) {
210210

211211
$$('.plugin-list').forEach(listPlugins);
212212

213+
// small polyfill for Element#matches
214+
if (!Element.prototype.matches) {
215+
Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
216+
}
217+
218+
Prism && Prism.hooks.add('complete', function (env) {
219+
var element = env.element;
220+
221+
requestAnimationFrame(function () {
222+
if (!element.matches('div.code-toolbar > pre > code')) {
223+
return;
224+
}
225+
226+
var pre = element.parentElement;
227+
var wrapper = pre.parentElement;
228+
229+
// transfer margin of pre to wrapper
230+
wrapper.style.margin = window.getComputedStyle(pre).margin;
231+
pre.style.margin = "0";
232+
233+
});
234+
});
235+
213236
})();

style.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,3 +414,12 @@ label a.owner:not(:hover) {
414414
margin-bottom: 1em;
415415
margin-right: 1em;
416416
}
417+
418+
/*
419+
* Fix for Toolbar's overflow issue
420+
*/
421+
422+
div.code-toolbar {
423+
display: block;
424+
overflow: auto;
425+
}

0 commit comments

Comments
 (0)