feat(editor): add collapse/expand functionality to code block component (#14884)

This PR fixes #14040 

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Code blocks can be collapsed and expanded via a toolbar toggle
(visible when the document is editable).
* Collapsed code blocks show a limited preview (~8 lines) with a bottom
fade overlay and reduced padding.
* Toolbar button updates icon and tooltip to reflect collapsed/expanded
state.
* Collapse state is preserved on the block so its current
collapsed/expanded setting is retained.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Ahsan Khaleeq
2026-05-04 02:07:42 +05:00
committed by GitHub
parent 5d234ad6a8
commit 9e412f58ec
6 changed files with 106 additions and 1 deletions
@@ -14,6 +14,7 @@ type CodeBlockProps = {
caption: string;
preview?: boolean;
lineNumber?: boolean;
collapsed?: boolean;
comments?: Record<string, boolean>;
} & BlockMeta;
@@ -27,6 +28,7 @@ export const CodeBlockSchema = defineBlockSchema({
caption: '',
preview: undefined,
lineNumber: undefined,
collapsed: undefined,
comments: undefined,
'meta:createdAt': undefined,
'meta:createdBy': undefined,