Native Codemirror cursor

This commit is contained in:
Gregory Schier
2023-10-27 13:14:41 -07:00
parent 65efee2048
commit 408665c62d
4 changed files with 9 additions and 7 deletions

View File

@@ -17,7 +17,7 @@
} }
.cm-line { .cm-line {
@apply text-gray-800 pl-1 pr-1.5; @apply text-gray-800 caret-gray-800 pl-1 pr-1.5;
} }
.cm-placeholder { .cm-placeholder {

View File

@@ -37,6 +37,7 @@ import { text } from './text/extension';
import { twig } from './twig/extension'; import { twig } from './twig/extension';
import { url } from './url/extension'; import { url } from './url/extension';
import type { Environment } from '../../../lib/models'; import type { Environment } from '../../../lib/models';
import { EditorView } from 'codemirror';
export const myHighlightStyle = HighlightStyle.define([ export const myHighlightStyle = HighlightStyle.define([
{ {
@@ -116,7 +117,6 @@ export function getLanguageExtension({
export const baseExtensions = [ export const baseExtensions = [
highlightSpecialChars(), highlightSpecialChars(),
history(), history(),
drawSelection(),
dropCursor(), dropCursor(),
bracketMatching(), bracketMatching(),
// TODO: Figure out how to debounce showing of autocomplete in a good way // TODO: Figure out how to debounce showing of autocomplete in a good way

View File

@@ -39,14 +39,16 @@ const placeholderMatcher = new BetterMatchDecorator({
// Don't decorate if the cursor is inside the match // Don't decorate if the cursor is inside the match
for (const r of view.state.selection.ranges) { for (const r of view.state.selection.ranges) {
if (r.from > matchStartPos && r.to <= matchEndPos) return null; if (r.from > matchStartPos && r.to <= matchEndPos) {
return Decoration.replace({});
}
} }
const groupMatch = match[1]; const groupMatch = match[1];
if (groupMatch == null) { if (groupMatch == null) {
// Should never happen, but make TS happy // Should never happen, but make TS happy
console.warn('Group match was empty', match); console.warn('Group match was empty', match);
return null; return Decoration.replace({});;
} }
return Decoration.replace({ return Decoration.replace({

View File

@@ -116,9 +116,9 @@ export const Input = forwardRef<EditorView | undefined, InputProps>(function Inp
'border', 'border',
focused ? 'border-focus' : 'border-highlight', focused ? 'border-focus' : 'border-highlight',
!isValid && '!border-invalid', !isValid && '!border-invalid',
size === 'md' && 'h-md leading-md', size === 'md' && 'h-md',
size === 'sm' && 'h-sm leading-sm', size === 'sm' && 'h-sm',
size === 'auto' && '!min-h-sm', size === 'auto' && 'min-h-sm',
)} )}
> >
{leftSlot} {leftSlot}