mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-23 00:58:32 +02:00
Don't send request on completion (Fixes #27)
This commit is contained in:
@@ -331,21 +331,7 @@ function getExtensions({
|
|||||||
undefined;
|
undefined;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
// NOTE: These *must* be anonymous functions so the references update properly
|
...baseExtensions, // Must be first
|
||||||
EditorView.domEventHandlers({
|
|
||||||
focus: () => {
|
|
||||||
onFocus.current?.();
|
|
||||||
},
|
|
||||||
blur: () => {
|
|
||||||
onBlur.current?.();
|
|
||||||
},
|
|
||||||
keydown: (e) => {
|
|
||||||
onKeyDown.current?.(e);
|
|
||||||
},
|
|
||||||
paste: (e) => {
|
|
||||||
onPaste.current?.(e.clipboardData?.getData('text/plain') ?? '');
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
tooltips({ parent }),
|
tooltips({ parent }),
|
||||||
keymap.of(singleLine ? defaultKeymap.filter((k) => k.key !== 'Enter') : defaultKeymap),
|
keymap.of(singleLine ? defaultKeymap.filter((k) => k.key !== 'Enter') : defaultKeymap),
|
||||||
...(singleLine ? [singleLineExt()] : []),
|
...(singleLine ? [singleLineExt()] : []),
|
||||||
@@ -354,14 +340,31 @@ function getExtensions({
|
|||||||
? [EditorState.readOnly.of(true), EditorView.contentAttributes.of({ tabindex: '-1' })]
|
? [EditorState.readOnly.of(true), EditorView.contentAttributes.of({ tabindex: '-1' })]
|
||||||
: []),
|
: []),
|
||||||
|
|
||||||
// Handle onChange
|
// ------------------------ //
|
||||||
|
// Things that must be last //
|
||||||
|
// ------------------------ //
|
||||||
|
|
||||||
EditorView.updateListener.of((update) => {
|
EditorView.updateListener.of((update) => {
|
||||||
if (onChange && update.docChanged) {
|
if (onChange && update.docChanged) {
|
||||||
onChange.current?.(update.state.doc.toString());
|
onChange.current?.(update.state.doc.toString());
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
...baseExtensions,
|
EditorView.domEventHandlers({
|
||||||
|
focus: () => {
|
||||||
|
onFocus.current?.();
|
||||||
|
},
|
||||||
|
blur: () => {
|
||||||
|
onBlur.current?.();
|
||||||
|
},
|
||||||
|
keydown: (e, cm) => {
|
||||||
|
console.log('KEY DOWN', e, cm);
|
||||||
|
onKeyDown.current?.(e);
|
||||||
|
},
|
||||||
|
paste: (e) => {
|
||||||
|
onPaste.current?.(e.clipboardData?.getData('text/plain') ?? '');
|
||||||
|
},
|
||||||
|
}),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,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';
|
||||||
|
|
||||||
export const myHighlightStyle = HighlightStyle.define([
|
export const syntaxHighlightStyle = HighlightStyle.define([
|
||||||
{
|
{
|
||||||
tag: [t.documentMeta, t.blockComment, t.lineComment, t.docComment, t.comment],
|
tag: [t.documentMeta, t.blockComment, t.lineComment, t.docComment, t.comment],
|
||||||
color: 'var(--fg-subtler)',
|
color: 'var(--fg-subtler)',
|
||||||
@@ -61,7 +61,7 @@ export const myHighlightStyle = HighlightStyle.define([
|
|||||||
{ tag: [t.atom, t.meta, t.operator, t.bool, t.null, t.keyword], color: 'var(--fg-danger)' },
|
{ tag: [t.atom, t.meta, t.operator, t.bool, t.null, t.keyword], color: 'var(--fg-danger)' },
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const myTheme = EditorView.theme({}, { dark: true });
|
const syntaxTheme = EditorView.theme({}, { dark: true });
|
||||||
|
|
||||||
const syntaxExtensions: Record<string, LanguageSupport> = {
|
const syntaxExtensions: Record<string, LanguageSupport> = {
|
||||||
'application/graphql': graphqlLanguageSupport(),
|
'application/graphql': graphqlLanguageSupport(),
|
||||||
@@ -108,8 +108,8 @@ export const baseExtensions = [
|
|||||||
return (a.boost ?? 0) - (b.boost ?? 0);
|
return (a.boost ?? 0) - (b.boost ?? 0);
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
syntaxHighlighting(myHighlightStyle),
|
syntaxHighlighting(syntaxHighlightStyle),
|
||||||
myTheme,
|
syntaxTheme,
|
||||||
EditorState.allowMultipleSelections.of(true),
|
EditorState.allowMultipleSelections.of(true),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user