-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
Global toggle code wrap button #7875
Comments
We probably won't add a button (otherwise we need a "user control panel", which may not be a totally bad idea, like how MUI is doing it). But a global option seems worthwhile. Why would you want to wrap the code? I've almost never wanted to wrap it. |
Oh I am sorry. It seems this went sideways. What I meant is when the user toggles one it should toggle all others too (to be clear, I am also not a big fan of wrapping it - but some of our customers are now using the feature as it got shipped with docusaurus). Basically only this line would be touched: https://github.com/facebook/docusaurus/blob/main/packages/docusaurus-theme-common/src/hooks/useCodeWordWrap.ts#L61 E.g.: - const [isEnabled, setIsEnabled] = useState(false);
+ const [isEnabled, setIsEnabled] = useLocalstorageState(false); |
Oh, I see your point. Would you be happy with a theme option that syncs the wrap state between all code blocks? |
Of course that would be ideal. |
Others looking for a similar feature: @jaredcbaum in #5468 (comment) Please help us decide what should be done so that all of you are satisfied ;) |
I would propose a new theme configuration. I think with these everything should be covered:
|
IMHO this would be an ideal config setup for code blocks. Since these options would be in |
I like that! The only thing I miss is the localStorage/global sync (which was the origin of this issue). |
I noticed in #7769 it was suggested that this could be enabled/forced for a single code block. I have the odd code block where it makes sense to have it forced on, or at least enabled by default. So this syntax (or similar) would be great for me:
I could also add some linebreaks 🤷 However, most snippets are far better with word wrap disabled, so I wouldn't really want to change the default for the whole site, or to even remember it page by page. |
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
We started working on this in #9349, and a few questions arise because there are orthogonal needs
As you can see, there are still design elements to discuss. On the technical side, there are also important UX details to consider:
|
Hi everyone, do we have any updates on this 'wordWrap' feature? |
As a workaround, I wrap the code block in a <div className="wrapcode">
```
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /path/to/graphile.config.ts
require() of ES modules is not supported.
require() of /path/to/graphile.config.ts from /path/to/node_modules/graphile-config/dist/loadConfig.js is an ES module file as it is a .ts file whose nearest parent package.json contains "type": "module" which defines all .ts files in that package scope as ES modules.
Instead change the requiring code to use import(), or remove "type": "module" from /path/to/package.json.
```
</div> and added the .wrapcode code {
white-space: pre-wrap;
} |
Have you read the Contributing Guidelines on issues?
Motivation
Code wrap buttons have been implemented: #7036
The thing is that it is a little cumbersome if this needs to be done on each codeblock individually. This proposal is that this setting will be stored globally to set it to the users needs.
Self-service
The text was updated successfully, but these errors were encountered: