@adminforth/text-complete 1.4.1 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build.log CHANGED
@@ -9,5 +9,5 @@ custom/package-lock.json
9
9
  custom/package.json
10
10
  custom/tsconfig.json
11
11
 
12
- sent 18,697 bytes received 96 bytes 37,586.00 bytes/sec
13
- total size is 18,344 speedup is 0.98
12
+ sent 19,119 bytes received 96 bytes 38,430.00 bytes/sec
13
+ total size is 18,761 speedup is 0.98
@@ -11,7 +11,7 @@
11
11
  :debounceTime="meta.debounceTime"
12
12
  />
13
13
  <div class="absolute right-2 bottom-1">
14
- <Tooltip v-if="isUntouched">
14
+ <Tooltip v-if="isUntouched || (!currentValue.trim() && !isFocused)">
15
15
  <button
16
16
  @click.stop="handleFocus"
17
17
  @mousedown.prevent
@@ -25,7 +25,7 @@
25
25
  </Tooltip>
26
26
 
27
27
  <Spinner v-else-if="isLoading" class="w-6 h-6" lightFill="#000000" darkFill="#ffffff" />
28
- <Tooltip v-else>
28
+ <Tooltip v-else-if="isFocused">
29
29
  <button
30
30
  @click.stop="approveCompletion"
31
31
  @mousedown.prevent
@@ -64,11 +64,19 @@ const emit = defineEmits([
64
64
 
65
65
  const isLoading = ref<boolean>(false);
66
66
  const isUntouched = ref<boolean>(true);
67
+ const isFocused = ref<boolean>(false);
67
68
  const currentValue: Ref<string> = ref('');
68
69
  const suggestionInputRef = ref<InstanceType<typeof SuggestionInput> | null>(null);
69
70
 
70
71
  onMounted(() => {
71
72
  currentValue.value = props.record[props.column.name] || '';
73
+ if (suggestionInputRef.value) {
74
+ const editor = suggestionInputRef.value.$el.querySelector('.ql-editor');
75
+ if (editor) {
76
+ editor.addEventListener('focus', handleFocus);
77
+ editor.addEventListener('blur', handleBlur);
78
+ }
79
+ }
72
80
  });
73
81
 
74
82
  watch(() => currentValue.value, (value) => {
@@ -103,6 +111,7 @@ const approveCompletion = async () => {
103
111
  }
104
112
 
105
113
  function handleFocus() {
114
+ isFocused.value = true;
106
115
  if (suggestionInputRef.value) {
107
116
  const editor = suggestionInputRef.value.$el.querySelector('.ql-editor');
108
117
  if (editor) {
@@ -111,6 +120,10 @@ function handleFocus() {
111
120
  }
112
121
  }
113
122
 
123
+ function handleBlur() {
124
+ isFocused.value = false;
125
+ }
126
+
114
127
  </script>
115
128
 
116
129
  <style>
@@ -11,7 +11,7 @@
11
11
  :debounceTime="meta.debounceTime"
12
12
  />
13
13
  <div class="absolute right-2 bottom-1">
14
- <Tooltip v-if="isUntouched">
14
+ <Tooltip v-if="isUntouched || (!currentValue.trim() && !isFocused)">
15
15
  <button
16
16
  @click.stop="handleFocus"
17
17
  @mousedown.prevent
@@ -25,7 +25,7 @@
25
25
  </Tooltip>
26
26
 
27
27
  <Spinner v-else-if="isLoading" class="w-6 h-6" lightFill="#000000" darkFill="#ffffff" />
28
- <Tooltip v-else>
28
+ <Tooltip v-else-if="isFocused">
29
29
  <button
30
30
  @click.stop="approveCompletion"
31
31
  @mousedown.prevent
@@ -64,11 +64,19 @@ const emit = defineEmits([
64
64
 
65
65
  const isLoading = ref<boolean>(false);
66
66
  const isUntouched = ref<boolean>(true);
67
+ const isFocused = ref<boolean>(false);
67
68
  const currentValue: Ref<string> = ref('');
68
69
  const suggestionInputRef = ref<InstanceType<typeof SuggestionInput> | null>(null);
69
70
 
70
71
  onMounted(() => {
71
72
  currentValue.value = props.record[props.column.name] || '';
73
+ if (suggestionInputRef.value) {
74
+ const editor = suggestionInputRef.value.$el.querySelector('.ql-editor');
75
+ if (editor) {
76
+ editor.addEventListener('focus', handleFocus);
77
+ editor.addEventListener('blur', handleBlur);
78
+ }
79
+ }
72
80
  });
73
81
 
74
82
  watch(() => currentValue.value, (value) => {
@@ -103,6 +111,7 @@ const approveCompletion = async () => {
103
111
  }
104
112
 
105
113
  function handleFocus() {
114
+ isFocused.value = true;
106
115
  if (suggestionInputRef.value) {
107
116
  const editor = suggestionInputRef.value.$el.querySelector('.ql-editor');
108
117
  if (editor) {
@@ -111,6 +120,10 @@ function handleFocus() {
111
120
  }
112
121
  }
113
122
 
123
+ function handleBlur() {
124
+ isFocused.value = false;
125
+ }
126
+
114
127
  </script>
115
128
 
116
129
  <style>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/text-complete",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "description": "Text completion plugin for adminforth",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",