Skip to content

Commit 7c91f36

Browse files
committed
Fix scrolling bugs
1 parent 21407e6 commit 7c91f36

File tree

2 files changed

+73
-14
lines changed

2 files changed

+73
-14
lines changed

src/components/RichTextEditor.tsx

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,12 @@ import {
2929
import { useEffect, useState, CSSProperties } from 'react';
3030
import { VimExtension, toggleVimMode, loadVimModeState } from '../utils/VimExtension';
3131
import { KeySwapExtension } from '../utils/KeySwapExtension';
32+
import '../styles/editor-overrides.css';
3233

3334
const tableStyles = {
3435
'.ProseMirror': {
36+
overflow: 'auto',
37+
height: '100%',
3538
'& table': {
3639
borderCollapse: 'collapse',
3740
margin: '1rem 0',
@@ -167,7 +170,7 @@ export function RichTextEditor({ content, onChange, isMobile }: RichTextEditorPr
167170
editorProps: {
168171
attributes: {
169172
class: 'rich-text-editor',
170-
style: 'height: 100%',
173+
style: 'height: 100%; overflow: visible;',
171174
},
172175
},
173176
});
@@ -189,6 +192,22 @@ export function RichTextEditor({ content, onChange, isMobile }: RichTextEditorPr
189192
}
190193
}, [vimModeEnabled, editor]);
191194

195+
useEffect(() => {
196+
if (isMobile) {
197+
const handleResize = () => {
198+
const vh = window.innerHeight * 0.01;
199+
document.documentElement.style.setProperty('--editor-vh', `${vh}px`);
200+
};
201+
202+
handleResize();
203+
window.addEventListener('resize', handleResize);
204+
205+
return () => {
206+
window.removeEventListener('resize', handleResize);
207+
};
208+
}
209+
}, [isMobile]);
210+
192211
if (!editor) {
193212
return null;
194213
}
@@ -379,9 +398,10 @@ export function RichTextEditor({ content, onChange, isMobile }: RichTextEditorPr
379398
borderBottom: '1px solid var(--mantine-color-gray-3)',
380399
borderTop: 'none',
381400
borderRadius: '8px',
382-
padding: '1rem',
383-
overflow: 'hidden',
384-
flex: 1
401+
padding: '0.5rem',
402+
overflow: 'auto',
403+
flex: 1,
404+
WebkitOverflowScrolling: 'touch'
385405
} : {
386406
border: '1px solid var(--mantine-color-gray-3)',
387407
borderRadius: 'var(--mantine-radius-md)',
@@ -395,29 +415,23 @@ export function RichTextEditor({ content, onChange, isMobile }: RichTextEditorPr
395415
display: 'flex',
396416
flexDirection: 'column',
397417
height: '100%',
398-
overflow: 'hidden'
418+
position: 'relative',
399419
}}>
400420
{ToolbarWrapper}
401421
<Box
402422
style={{
403423
flex: '1 1 auto',
404-
display: 'flex',
405-
flexDirection: 'column',
406-
minHeight: 0,
407-
overflowY: 'auto',
408-
WebkitOverflowScrolling: 'touch',
424+
overflow: 'auto',
425+
position: 'relative',
409426
...tableStyles,
410427
...mobileBorderStyle
411428
}}
412429
>
413430
<EditorContent
414431
editor={editorInstance}
415432
style={{
416-
flex: '1 1 auto',
417-
display: 'flex',
418-
flexDirection: 'column',
419433
height: '100%',
420-
overflow: 'visible',
434+
minHeight: '100%',
421435
}}
422436
className={`rich-text-table-container ${isMobile ? 'mobile-editor' : ''}`}
423437
/>

src/styles/editor-overrides.css

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,50 @@
11
/* Aggressive style overrides for TipTap editor */
22

3+
/* CSS Variables */
4+
:root {
5+
--editor-vh: 1vh;
6+
}
7+
8+
/* Editor scrolling fixes */
9+
.rich-text-editor {
10+
height: 100% !important;
11+
overflow: auto !important;
12+
}
13+
14+
.ProseMirror {
15+
height: 100% !important;
16+
overflow: auto !important;
17+
min-height: 100% !important;
18+
}
19+
20+
.rich-text-table-container {
21+
height: 100% !important;
22+
overflow: auto !important;
23+
}
24+
25+
/* Mobile specific fixes */
26+
.mobile-editor {
27+
padding-bottom: 40px !important;
28+
}
29+
30+
body.mobile-view .ProseMirror {
31+
font-size: 16px !important;
32+
line-height: 1.5 !important;
33+
}
34+
35+
body.keyboard-visible .mobile-editor {
36+
max-height: calc(100 * var(--editor-vh));
37+
overflow: auto !important;
38+
}
39+
40+
body.keyboard-visible .rich-text-table-container {
41+
height: auto !important;
42+
}
43+
44+
body.mobile-view .rich-text-table-container {
45+
min-height: calc(100 * var(--editor-vh) - 120px);
46+
}
47+
348
/* Remove all hover effects */
449
.ProseMirror .is-editor-empty:first-child::before,
550
.ProseMirror p.is-editor-empty:first-child::before,

0 commit comments

Comments
 (0)