From 17fe43ecc89b03f2a66410c5d7f7bc46fbdc185d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lorber?= Date: Thu, 2 Jun 2022 17:40:42 +0200 Subject: [PATCH] fix(theme-classic): code block wrap mode should allow wrapping in the middle of a word (#7551) --- packages/docusaurus-theme-common/src/hooks/useCodeWordWrap.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/docusaurus-theme-common/src/hooks/useCodeWordWrap.ts b/packages/docusaurus-theme-common/src/hooks/useCodeWordWrap.ts index 35d645322355..12cf2eff4c8d 100644 --- a/packages/docusaurus-theme-common/src/hooks/useCodeWordWrap.ts +++ b/packages/docusaurus-theme-common/src/hooks/useCodeWordWrap.ts @@ -69,6 +69,9 @@ export function useCodeWordWrap(): { codeElement.removeAttribute('style'); } else { codeElement.style.whiteSpace = 'pre-wrap'; + // When code wrap is enabled, we want to avoid a scrollbar in any case + // Ensure that very very long words/strings/tokens still wrap + codeElement.style.overflowWrap = 'anywhere'; } setIsEnabled((value) => !value);