Skip to content

Commit

Permalink
fix: Change msgbox flex direction based on offsetHeight (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
nfnfgo authored Jul 4, 2024
1 parent 9e32a1e commit 7b0c416
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
10 changes: 10 additions & 0 deletions src/components/code_block.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,14 @@ export function addOnClickHandleForLatexBlock(element) {
;
}
});
}

export function changeDirectionToColumnWhenLargerHeight() {
var msgBlocks = document.querySelectorAll('.mix-message__inner');
Array.from(msgBlocks).forEach(function (block) {
var height = block.offsetHeight;
if (height > 30) {
block.style.flexDirection = 'column';
}
});
}
7 changes: 5 additions & 2 deletions src/renderer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import {
HighLightedCodeBlock,
addOnClickHandleForCopyButton,
renderInlineCodeBlockString,
addOnClickHandleForLatexBlock
addOnClickHandleForLatexBlock,
changeDirectionToColumnWhenLargerHeight
} from './components/code_block';

// States
Expand Down Expand Up @@ -185,7 +186,9 @@ function render() {
.forEach((elem) => {
posBase.before(elem)
})
messageBox.removeChild(posBase)
messageBox.removeChild(posBase);

changeDirectionToColumnWhenLargerHeight();

})

Expand Down
3 changes: 2 additions & 1 deletion src/style/markdown.css
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,9 @@ pre.hl-code-block>button.lang_copy:not(:hover)>p.copy {
/* 修复轻量工具箱等插件时间显示多出换行的问题 */
.mix-message__inner {
display: flex;
flex-direction: row;
}

.lite-tools-slot.embed-slot {
flex: none;
}
}

0 comments on commit 7b0c416

Please sign in to comment.