feat: 添加代码块折行显示按钮 - #624
Open
jianyuewushuang wants to merge 5 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat:添加代码块折行显示按钮
功能效果
scrollWidth>clientWidth)时该按钮才会出现文件修改
_config.yml在
articles.code_block下新增开关wrap_toggle: true(默认开启)source/js/tools/codeBlock.js在
initCopyCode()中添加:wrap-toggle按钮resize监听source/css/common/codeblock/code-block.styl新增
.wrap-toggle-button样式:right:80pxopacity 0.copy-button/.fold-button在同一条hover选择器里被激活opacity 1source/css/common/codeblock/highlight.styl新增
.highlight-container.code-wrap-enabled下 pre / code / .line 的折行 white-space / word-break 规则已知问题
折叠代码后原来的行号会有轻微偏移,但不影响阅读
预览
如果有什么问题或需要修改的地方,请告诉我。
feat: Add code‑block word‑wrap toggle button
Feature Behavior
scrollWidth>clientWidth)File Modifications
_config.ymlAdd the switch
wrap_toggle: trueunderarticles.code_block(enabled by default)source/js/tools/codeBlock.jsAdd logic inside
initCopyCode()for:wrap‑toggleicon buttonresizeevent listenersource/css/common/codeblock/code‑block.stylAdd styles for
.wrap‑toggle‑button:right: 80pxopacity: 0opacity: 1within the samehoverselector as.copy‑button/.fold‑buttonsource/css/common/codeblock/highlight.stylAdd
white‑space/word‑breakwrapping rules forpre/code/.lineunder.highlight‑container.code‑wrap‑enabledKnown Issues
Slight offset occurs on original line numbers after code folding, though it does not impair readability.
If you have any questions or require modifications, feel free to tell me.