Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(editor): Autocomplete info box: improve structure and add examples #9019

Merged
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
c381d89
Restyle info box + add args, examples
elsmr Apr 2, 2024
f6a6792
Add examples for String.includes
elsmr Apr 2, 2024
ac1e7b6
Disable closeOnBlur
elsmr Apr 2, 2024
e88f4b4
Infobox styling.
gandreini Apr 9, 2024
86575bb
Merge branch 'master' into node-1280-autocomplete-info-box-improve-st…
elsmr Apr 9, 2024
4bde4c8
Improve infobox DOM structure
elsmr Apr 9, 2024
56ae4e5
Add string extension docs
elsmr Apr 10, 2024
9e92b66
Extension methods tweaks
elsmr Apr 10, 2024
f9920d6
Infobox styling.
gandreini Apr 19, 2024
bea19e1
Merge branch 'master' into node-1280-autocomplete-info-box-improve-st…
elsmr Apr 19, 2024
a372082
Add all String examples/descriptions
elsmr Apr 19, 2024
e38663a
Re-enable closeOnBlur
elsmr Apr 19, 2024
7a64761
Add test for microseconds toDateTime
elsmr Apr 19, 2024
20332e0
Fix tests
elsmr Apr 22, 2024
181f2e3
Fix dollar completion info box layout
elsmr Apr 23, 2024
0704b0e
Styling improvements
elsmr Apr 23, 2024
c40ed94
Remove section from toDateTime
elsmr Apr 23, 2024
5ab4423
Review fixes
elsmr Apr 23, 2024
a8173e0
Replace unneeded innerHTML with textContent
elsmr Apr 25, 2024
3f1a834
Remove type annotations to improve typing
elsmr Apr 25, 2024
6efb364
Fix review remarks
elsmr Apr 25, 2024
1cc70ca
Merge branch 'master' into node-1280-autocomplete-info-box-improve-st…
elsmr Apr 26, 2024
93e98ed
Hide autocomplete in e2e test
elsmr Apr 26, 2024
9c80c4f
Fix code node autocomplete styling
elsmr Apr 26, 2024
baf0b17
Minor style tweaks.
gandreini Apr 29, 2024
d966bcd
Fix review feedback
elsmr May 2, 2024
fa58b9a
Infobox CSS improvements.
gandreini May 2, 2024
70e48f6
Merge branch 'node-1280-autocomplete-info-box-improve-structure-and-a…
gandreini May 2, 2024
04e72d5
Render examples section with 1 border
elsmr May 2, 2024
1329425
Hide docURL
elsmr May 3, 2024
d507efc
Merge branch 'master' into node-1280-autocomplete-info-box-improve-st…
elsmr May 3, 2024
e3d550a
Infobox color for dark mode.
gandreini May 6, 2024
e8fba7f
Review fixes
elsmr May 7, 2024
47bfb55
Fix variadic methods, improve links style, bring back docURL
elsmr May 8, 2024
9a63353
Restore object sections
elsmr May 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ watchDebounced(
<style lang="scss" module>
.tip {
display: flex;
align-items: flex-start;
align-items: center;
gap: var(--spacing-4xs);
line-height: var(--font-line-height-regular);
color: var(--color-text-base);
Expand Down
25 changes: 24 additions & 1 deletion packages/editor-ui/src/composables/useExpressionEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
type Ref,
toValue,
watch,
onMounted,
} from 'vue';

import { ensureSyntaxTree } from '@codemirror/language';
Expand All @@ -24,7 +25,7 @@ import {
getResolvableState,
isEmptyExpression,
} from '@/utils/expressions';
import { completionStatus } from '@codemirror/autocomplete';
import { closeCompletion, completionStatus } from '@codemirror/autocomplete';
import {
Compartment,
EditorState,
Expand Down Expand Up @@ -158,6 +159,19 @@ export const useExpressionEditor = ({
debouncedUpdateSegments();
}

function blur() {
if (editor.value) {
editor.value.contentDOM.blur();
closeCompletion(editor.value);
}
}

function blurOnClickOutside(event: MouseEvent) {
if (event.target && !editor.value?.dom.contains(event.target as Node)) {
blur();
}
}

watch(editorRef, () => {
const parent = toValue(editorRef);

Expand All @@ -176,6 +190,10 @@ export const useExpressionEditor = ({
EditorView.focusChangeEffect.of((_, newHasFocus) => {
hasFocus.value = newHasFocus;
selection.value = state.selection.ranges[0];
if (!newHasFocus) {
autocompleteStatus.value = null;
debouncedUpdateSegments();
}
return null;
}),
EditorView.contentAttributes.of({ 'data-gramm': 'false' }), // disable grammarly
Expand Down Expand Up @@ -231,7 +249,12 @@ export const useExpressionEditor = ({
});
});

onMounted(() => {
document.addEventListener('click', blurOnClickOutside);
});

onBeforeUnmount(() => {
document.removeEventListener('click', blurOnClickOutside);
editor.value?.destroy();
});

Expand Down
Loading
Loading