Skip to content

Commit 05317bd

Browse files
[INTEG-3278] fix: rich text diff editor now sticks when scrolling (#10231)
* fix: rich text diff editor now sticks when scrolling * cleanup: css even more for scroll * fix: cleanup css for rich text diff
1 parent 384629c commit 05317bd

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { css } from 'emotion';
2+
3+
/**
4+
* Rich Text Editor - Sticky Toolbar
5+
* Makes the formatting toolbar remain visible when scrolling through content
6+
*/
7+
8+
// CSS custom properties for configuration
9+
const rteEditorMaxHeight = '500px';
10+
const rteToolbarZIndex = 100;
11+
12+
export const styles = {
13+
richTextEditorContainer: css({
14+
position: 'relative',
15+
overflow: 'visible',
16+
17+
// Sticky toolbar positioning
18+
'& > div > div:first-child > div': {
19+
position: 'sticky',
20+
top: 0,
21+
zIndex: rteToolbarZIndex,
22+
},
23+
24+
// Scrollable editor content area
25+
'& [data-slate-editor="true"]': {
26+
maxHeight: rteEditorMaxHeight,
27+
overflowY: 'auto',
28+
overflowX: 'hidden',
29+
// Smooth scrolling for better UX
30+
scrollBehavior: 'smooth',
31+
// Prevent scroll chaining to parent
32+
overscrollBehavior: 'contain',
33+
},
34+
}),
35+
};

apps/rich-text-versioning/src/locations/Field.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { Document } from '@contentful/rich-text-types';
88
import { EntrySys } from '@contentful/app-sdk/dist/types/utils';
99
import { convertToSerializableJson, ErrorInfo } from '../utils';
1010
import { ReleaseEntrySys } from '@contentful/app-sdk/dist/types/entry.types';
11+
import { styles } from './Field.styles';
1112

1213
const Field = () => {
1314
const sdk = useSDK<FieldAppSDK>();
@@ -93,7 +94,9 @@ const Field = () => {
9394

9495
return (
9596
<>
96-
<RichTextEditor sdk={sdk} isInitiallyDisabled={false} />
97+
<div className={styles.richTextEditorContainer}>
98+
<RichTextEditor sdk={sdk} isInitiallyDisabled={false} />
99+
</div>
97100
<Tooltip
98101
placement="top"
99102
content={

0 commit comments

Comments
 (0)