mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-24 09:38:29 +02:00
Native Codemirror cursor
This commit is contained in:
@@ -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 {
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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({
|
||||||
|
|||||||
@@ -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}
|
||||||
|
|||||||
Reference in New Issue
Block a user