mirror of
https://github.com/bwya77/collapsible-code-blocks.git
synced 2026-07-22 12:00:25 +00:00
Merge b205b45dc2 into 4875b52e7d
This commit is contained in:
commit
bc6a1e3915
2 changed files with 0 additions and 35 deletions
|
|
@ -54,28 +54,10 @@ export function setupReadView(app: ExtendedApp, settings: CollapsibleCodeBlockSe
|
|||
}
|
||||
|
||||
function updateCodeBlockVisibility(pre: HTMLElement, forceRefresh: boolean = false) {
|
||||
const isCollapsed = pre.classList.contains('collapsed');
|
||||
const markdownView = app.workspace.getActiveViewOfType(MarkdownView);
|
||||
if (!markdownView?.previewMode?.containerEl) return;
|
||||
|
||||
const previewElement = markdownView.previewMode.containerEl;
|
||||
const rect = pre.getBoundingClientRect();
|
||||
const scrollTop = previewElement.scrollTop;
|
||||
const elementTop = rect.top + scrollTop;
|
||||
|
||||
let curr = pre.nextElementSibling;
|
||||
while (curr && !(curr instanceof HTMLPreElement)) {
|
||||
if (curr instanceof HTMLElement) {
|
||||
if (isCollapsed) {
|
||||
curr.classList.add('element-hidden');
|
||||
curr.classList.remove('element-visible', 'element-spacing');
|
||||
} else {
|
||||
curr.classList.remove('element-hidden');
|
||||
curr.classList.add('element-visible');
|
||||
}
|
||||
}
|
||||
curr = curr.nextElementSibling;
|
||||
}
|
||||
|
||||
void pre.offsetHeight;
|
||||
|
||||
|
|
|
|||
17
styles.css
17
styles.css
|
|
@ -81,23 +81,6 @@ body[data-ccb-horizontal-scroll="true"] .markdown-preview-view pre.ccb-code-bloc
|
|||
width: 0;
|
||||
}
|
||||
|
||||
/* New styles for dynamic states */
|
||||
.hidden {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.element-hidden {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.element-visible {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.element-spacing {
|
||||
margin-top: var(--element-spacing);
|
||||
}
|
||||
|
||||
/* Custom properties for dynamic values */
|
||||
:root {
|
||||
--element-spacing: 0px;
|
||||
|
|
|
|||
Loading…
Reference in a new issue