shortcodes: add style option to mimic code box color scheme

This commit is contained in:
Sören Weber 2023-06-06 17:44:06 +02:00
parent d39c0fb402
commit 67fe76a99c
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
10 changed files with 41 additions and 10 deletions
static/js

View file

@ -65,6 +65,23 @@ function adjustContentWidth(){
elc.style[ dir_padding_end ] = '' + end + 'px';
}
function fixCodeTabs(){
/* if only a single code block is contained in the tab and no style was selected, treat it like style=code */
var codeTabPanels = Array.from( document.querySelectorAll( '.tab-content.tab-panel-style.initial' ) ).filter( function( tabPanel ){
return tabPanel.querySelector( '.tab-content-text > div.highlight:only-child');
});
codeTabPanels.forEach( function( tabPanel ){
tabPanel.classList.remove( 'initial' );
tabPanel.classList.add( 'code' );
tabId = tabPanel.dataset.tabItem;
var p = tabPanel.parentNode.parentNode;
var tabButton = p.querySelector( '.tab-nav-button.tab-panel-style[data-tab-item="'+tabId+'"]' );
tabButton.classList.remove( 'initial' );
tabButton.classList.add( 'code' );
});
}
function switchTab(tabGroup, tabId) {
var tabs = Array.from( document.querySelectorAll( '.tab-panel[data-tab-group="'+tabGroup+'"]' ) ).filter( function( e ){
return !!e.querySelector( '[data-tab-item="'+tabId+'"]' );
@ -1251,6 +1268,7 @@ ready( function(){
initToc();
initAnchorClipboard();
initCodeClipboard();
fixCodeTabs();
restoreTabSelections();
initSwipeHandler();
initHistory();