Skip to content

Commit bc61515

Browse files
committed
fix markdown editor scroll
1 parent 6e9aabc commit bc61515

File tree

2 files changed

+39
-27
lines changed

2 files changed

+39
-27
lines changed

packages/assets/styles/defaults.scss

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,21 +61,12 @@ textarea,
6161
font-weight: var(--font-weight-medium);
6262
transition: box-shadow 0.1s ease-in-out;
6363
min-height: 36px;
64-
box-shadow:
64+
box-shadow:
6565
var(--shadow-inset-sm),
6666
0 0 0 0 transparent;
6767
border: none;
6868
outline: none;
6969

70-
&:focus,
71-
&:focus-visible {
72-
box-shadow:
73-
inset 0 0 0 transparent,
74-
0 0 0 0.25rem var(--color-brand-shadow);
75-
color: var(--color-contrast);
76-
outline: none;
77-
}
78-
7970
&:disabled,
8071
&[disabled] {
8172
opacity: 0.6;

packages/ui/src/components/base/MarkdownEditor.vue

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<Button :action="() => linkModal?.hide()"><XIcon /> Cancel</Button>
4949
<Button
5050
color="primary"
51-
:disabled="linkValidationErrorMessage || !linkUrl"
51+
:disabled="!!linkValidationErrorMessage || !linkUrl"
5252
:action="
5353
() => {
5454
if (editor) markdownCommands.replaceSelection(editor, linkMarkdown)
@@ -189,7 +189,7 @@
189189
<Button :action="() => videoModal?.hide()"><XIcon /> Cancel</Button>
190190
<Button
191191
color="primary"
192-
:disabled="linkValidationErrorMessage || !linkUrl"
192+
:disabled="!!linkValidationErrorMessage || !linkUrl"
193193
:action="
194194
() => {
195195
if (editor) markdownCommands.replaceSelection(editor, videoMarkdown)
@@ -230,7 +230,7 @@
230230
</div>
231231
</div>
232232
<div ref="editorRef" :class="{ hide: previewMode }" />
233-
<div v-if="!previewMode" class="info-blurb">
233+
<div v-if="!previewMode" class="info-blurb mt-2">
234234
<div class="info-blurb">
235235
<InfoIcon />
236236
<span
@@ -270,7 +270,7 @@
270270
import { history, historyKeymap, indentWithTab } from '@codemirror/commands'
271271
import { markdown } from '@codemirror/lang-markdown'
272272
import { Compartment, EditorState } from '@codemirror/state'
273-
import { EditorView, keymap, placeholder as cm_placeholder } from '@codemirror/view'
273+
import { placeholder as cm_placeholder, EditorView, keymap } from '@codemirror/view'
274274
import {
275275
AlignLeftIcon,
276276
BoldIcon,
@@ -345,19 +345,32 @@ onMounted(() => {
345345
346346
const theme = EditorView.theme({
347347
// in defaults.scss there's references to .cm-content and such to inherit global styles
348+
'&': {
349+
borderRadius: 'var(--radius-md)',
350+
background: 'var(--color-button-bg)',
351+
border: '0.25rem solid transparent',
352+
transition: 'border-color 0.1s ease-in-out',
353+
},
354+
'&.cm-focused': {
355+
'box-shadow': 'inset 0 0 0 transparent, 0 0 0 0.25rem var(--color-brand-shadow)',
356+
color: 'var(--color-contrast)',
357+
outline: 'none',
358+
},
359+
'.cm-focused': {
360+
border: 'none',
361+
},
348362
'.cm-content': {
349363
marginBlockEnd: '0.5rem',
350364
padding: '0.5rem',
351365
minHeight: '200px',
352366
caretColor: 'var(--color-contrast)',
353367
width: '100%',
354-
overflowX: 'scroll',
355-
maxHeight: props.maxHeight ? `${props.maxHeight}px` : 'unset',
356-
overflowY: 'scroll',
357368
},
358369
'.cm-scroller': {
370+
borderRadius: 'var(--radius-md)',
359371
height: '100%',
360-
overflow: 'visible',
372+
maxHeight: props.maxHeight ? `${props.maxHeight}px` : 'unset',
373+
overflow: 'auto',
361374
},
362375
})
363376
@@ -581,23 +594,35 @@ watch(
581594
editorThemeCompartment.reconfigure(
582595
EditorView.theme({
583596
// in defaults.scss there's references to .cm-content and such to inherit global styles
597+
'&': {
598+
borderRadius: 'var(--radius-md)',
599+
background: 'var(--color-button-bg)',
600+
border: '0.25rem solid transparent',
601+
transition: 'border-color 0.1s ease-in-out',
602+
},
603+
'&.cm-focused': {
604+
'box-shadow': 'inset 0 0 0 transparent, 0 0 0 0.25rem var(--color-brand-shadow)',
605+
color: 'var(--color-contrast)',
606+
outline: 'none',
607+
},
608+
'.cm-focused': {
609+
border: 'none',
610+
},
584611
'.cm-content': {
585612
marginBlockEnd: '0.5rem',
586613
padding: '0.5rem',
587614
minHeight: '200px',
588615
caretColor: 'var(--color-contrast)',
589616
width: '100%',
590-
overflowX: 'scroll',
591-
maxHeight: props.maxHeight ? `${props.maxHeight}px` : 'unset',
592-
overflowY: 'scroll',
593-
594617
opacity: newValue ? 0.6 : 1,
595618
pointerEvents: newValue ? 'none' : 'all',
596619
cursor: newValue ? 'not-allowed' : 'auto',
597620
},
598621
'.cm-scroller': {
622+
borderRadius: 'var(--radius-md)',
599623
height: '100%',
600-
overflow: 'visible',
624+
maxHeight: props.maxHeight ? `${props.maxHeight}px` : 'unset',
625+
overflow: 'auto',
601626
},
602627
}),
603628
),
@@ -957,8 +982,4 @@ function openVideoModal() {
957982
pointer-events: none;
958983
cursor: not-allowed;
959984
}
960-
961-
:deep(.cm-content) {
962-
overflow: auto;
963-
}
964985
</style>

0 commit comments

Comments
 (0)