Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support folding code blocks #679

Merged
merged 6 commits into from
Jul 28, 2023
Merged

Support folding code blocks #679

merged 6 commits into from
Jul 28, 2023

Conversation

stevenjoezhang
Copy link
Member

@stevenjoezhang stevenjoezhang commented Jul 25, 2023

PR Checklist

PR Type

  • Bugfix.
  • Feature.
  • Improvement.
  • Code style update (formatting, linting).
  • Refactoring (no functional changes).
  • Documentation.
  • Translation.
  • Other... Please describe:

What is the current behavior?

Issue resolved: #178
See also theme-next/hexo-theme-next#1732

What is the new behavior?

  • Link to demo site with this changes:
  • Screenshots with this changes:

How to use?

In NexT _config.yml:

codeblock:
  # Fold code block
  fold:
    enable: true
    threshold: 500

@coveralls
Copy link

coveralls commented Jul 25, 2023

Pull Request Test Coverage Report for Build 5665540687

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 97.416%

Totals Coverage Status
Change from base Build 5654367902: 0.0%
Covered Lines: 394
Relevant Lines: 399

💛 - Coveralls

@stevenjoezhang
Copy link
Member Author

Possible regression: #508

@PeichengLiu
Copy link
Contributor

PeichengLiu commented Aug 16, 2023

I like this feature. While it just does not work with tabs. Non-default tab(s) is not folded. Is it designed on purpose?

@stevenjoezhang
Copy link
Member Author

@PeichengLiu If a code block is within hidden tabs, the browser is unaware of the size of the code block (since it hasn't been rendered), so it doesn't know whether it exceeds the preset length and should be folded.

@PeichengLiu
Copy link
Contributor

@stevenjoezhang True, while we can still fold the code on the fly based on the following event dispatched every time a tab gets switched.

// Trigger event
tActive.dispatchEvent(new Event('tabs:click', {
bubbles: true
}));

Please take this as a sample, I'm happy to create a pull request.

@stevenjoezhang
Copy link
Member Author

@PeichengLiu Thanks, pull requests are welcomed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

是否可以加入 codeblock 的 fold 功能
3 participants