Skip to content

Commit 7f2df00

Browse files
committed
fix: remove autofocus from text editor as create conversation form opens.
- Adds new prop autofocus on text editor - rename ConversationTextEditor to TextEditor
1 parent 6c523ac commit 7f2df00

File tree

8 files changed

+41
-33
lines changed

8 files changed

+41
-33
lines changed

frontend/src/features/conversation/ConversationTextEditor.vue renamed to frontend/src/components/editor/TextEditor.vue

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
</template>
9292

9393
<script setup>
94-
import { ref, watch, watchEffect, onUnmounted } from 'vue'
94+
import { ref, watch, watchEffect, onUnmounted, computed } from 'vue'
9595
import { useEditor, EditorContent, BubbleMenu } from '@tiptap/vue-3'
9696
import {
9797
ChevronDown,
@@ -136,6 +136,10 @@ const props = defineProps({
136136
setInlineImage: Object,
137137
insertContent: String,
138138
clearContent: Boolean,
139+
autoFocus: {
140+
type: Boolean,
141+
default: true
142+
},
139143
aiPrompts: {
140144
type: Array,
141145
default: () => []
@@ -188,7 +192,7 @@ const CustomTableHeader = TableHeader.extend({
188192
}
189193
})
190194
191-
const editorConfig = {
195+
const editorConfig = computed(() => ({
192196
extensions: [
193197
StarterKit.configure(),
194198
Image.configure({ HTMLAttributes: { class: 'inline-image' } }),
@@ -201,7 +205,7 @@ const editorConfig = {
201205
CustomTableCell,
202206
CustomTableHeader
203207
],
204-
autofocus: true,
208+
autofocus: props.autoFocus,
205209
editorProps: {
206210
attributes: { class: 'outline-none' },
207211
handleKeyDown: (view, event) => {
@@ -210,17 +214,17 @@ const editorConfig = {
210214
return true
211215
}
212216
if (event.ctrlKey && event.key.toLowerCase() === 'b') {
213-
// Prevent outer listeners
217+
// Prevent outer listeners
214218
event.stopPropagation()
215219
return false
216220
}
217221
}
218222
}
219-
}
223+
}))
220224
221225
const editor = ref(
222226
useEditor({
223-
...editorConfig,
227+
...editorConfig.value,
224228
content: htmlContent.value,
225229
onSelectionUpdate: ({ editor }) => {
226230
const { from, to } = editor.state.selection

frontend/src/features/admin/automation/ActionBox.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
<Editor
6969
v-model:htmlContent="action.value[0]"
7070
@update:htmlContent="(value) => handleEditorChange(value, index)"
71-
:placeholder="t('editor.placeholder')"
71+
:placeholder="t('editor.newLine') + t('editor.send') + t('editor.cmdK')"
7272
/>
7373
</div>
7474
</div>
@@ -101,7 +101,7 @@ import { SelectTag } from '@/components/ui/select'
101101
import { useConversationFilters } from '@/composables/useConversationFilters'
102102
import { getTextFromHTML } from '@/utils/strings.js'
103103
import { useI18n } from 'vue-i18n'
104-
import Editor from '@/features/conversation/ConversationTextEditor.vue'
104+
import Editor from '@/components/editor/TextEditor.vue'
105105
import SelectComboBox from '@/components/combobox/SelectCombobox.vue'
106106
107107
const props = defineProps({

frontend/src/features/admin/macros/MacroForm.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<Editor
2020
v-model:htmlContent="componentField.modelValue"
2121
@update:htmlContent="(value) => componentField.onChange(value)"
22-
:placeholder="t('editor.placeholder')"
22+
:placeholder="t('editor.newLine') + t('editor.send') + t('editor.cmdK')"
2323
/>
2424
</div>
2525
</FormControl>
@@ -167,7 +167,7 @@ import {
167167
SelectTag
168168
} from '@/components/ui/select'
169169
import { useI18n } from 'vue-i18n'
170-
import Editor from '@/features/conversation/ConversationTextEditor.vue'
170+
import Editor from '@/components/editor/TextEditor.vue'
171171
172172
const { macroActions } = useConversationFilters()
173173
const { t } = useI18n()

frontend/src/features/contact/ContactNotes.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<Editor
2828
v-model:htmlContent="newNote"
2929
@update:htmlContent="(value) => (newNote = value)"
30-
:placeholder="t('editor.placeholder')"
30+
:placeholder="t('editor.newLine') + t('editor.send') + t('editor.cmdK')"
3131
/>
3232
</div>
3333
<div class="flex justify-end space-x-3 pt-2">
@@ -148,7 +148,7 @@ import {
148148
ClockIcon,
149149
MessageSquareIcon
150150
} from 'lucide-vue-next'
151-
import Editor from '@/features/conversation/ConversationTextEditor.vue'
151+
import Editor from '@/components/editor/TextEditor.vue'
152152
import { useI18n } from 'vue-i18n'
153153
import { useEmitter } from '@/composables/useEmitter'
154154
import { EMITTER_EVENTS } from '@/constants/emitterEvents.js'

frontend/src/features/conversation/CreateConversation.vue

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div>
3-
<Dialog :open="dialogOpen" @update:open="dialogOpen = false">
3+
<Dialog v-model:open="dialogOpen">
44
<DialogContent class="max-w-5xl w-full h-[90vh] flex flex-col">
55
<DialogHeader>
66
<DialogTitle>
@@ -13,7 +13,7 @@
1313
</DialogHeader>
1414
<form @submit="createConversation" class="flex flex-col flex-1 overflow-hidden">
1515
<!-- Form Fields Section -->
16-
<div class="space-y-4 overflow-y-auto pb-2 flex-shrink-0">
16+
<div class="space-y-4 pb-2 flex-shrink-0">
1717
<div class="space-y-2">
1818
<FormField name="contact_email">
1919
<FormItem class="relative">
@@ -31,7 +31,7 @@
3131

3232
<ul
3333
v-if="searchResults.length"
34-
class="border rounded p-2 max-h-60 overflow-y-auto absolute w-full z-50 shadow-lg bg-background"
34+
class="border rounded p-2 max-h-60 overflow-y-auto absolute w-full z-50 shadow bg-background"
3535
>
3636
<li
3737
v-for="contact in searchResults"
@@ -161,11 +161,11 @@
161161
<Editor
162162
v-model:htmlContent="componentField.modelValue"
163163
@update:htmlContent="(value) => componentField.onChange(value)"
164-
v-model:cursorPosition="cursorPosition"
165164
:contentToSet="contentToSet"
166-
:placeholder="t('editor.placeholder')"
165+
:placeholder="t('editor.newLine') + t('editor.send') + t('editor.cmdK')"
167166
:clearContent="clearEditorContent"
168167
:insertContent="insertContent"
168+
:autoFocus="false"
169169
class="w-full flex-1 overflow-y-auto p-2 box min-h-0"
170170
/>
171171

@@ -244,7 +244,7 @@ import {
244244
} from '@/components/ui/select'
245245
import { useI18n } from 'vue-i18n'
246246
import { useFileUpload } from '@/composables/useFileUpload'
247-
import Editor from '@/features/conversation/ConversationTextEditor.vue'
247+
import Editor from '@/components/editor/TextEditor.vue'
248248
import { useMacroStore } from '@/stores/macro'
249249
import SelectComboBox from '@/components/combobox/SelectCombobox.vue'
250250
import api from '@/api'
@@ -266,7 +266,6 @@ const conversationStore = useConversationStore()
266266
const macroStore = useMacroStore()
267267
let timeoutId = null
268268
269-
const cursorPosition = ref(null)
270269
const contentToSet = ref('')
271270
const clearEditorContent = ref(false)
272271
const insertContent = ref('')

frontend/src/features/conversation/ReplyBoxContent.vue

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,15 @@
9090
v-model:htmlContent="htmlContent"
9191
v-model:textContent="textContent"
9292
v-model:cursorPosition="cursorPosition"
93-
:placeholder="editorPlaceholder"
93+
:placeholder="t('editor.newLine') + t('editor.send') + t('editor.cmdK')"
9494
:aiPrompts="aiPrompts"
9595
@aiPromptSelected="handleAiPromptSelected"
9696
:contentToSet="contentToSet"
9797
@send="handleSend"
9898
:clearContent="clearEditorContent"
9999
:setInlineImage="setInlineImage"
100100
:insertContent="insertContent"
101+
:autoFocus="true"
101102
/>
102103
</div>
103104

@@ -140,7 +141,7 @@
140141
import { ref, computed, nextTick, watch } from 'vue'
141142
import { EMITTER_EVENTS } from '@/constants/emitterEvents.js'
142143
import { Maximize2, Minimize2 } from 'lucide-vue-next'
143-
import Editor from './ConversationTextEditor.vue'
144+
import Editor from '@/components/editor/TextEditor.vue'
144145
import { useConversationStore } from '@/stores/conversation'
145146
import { Input } from '@/components/ui/input'
146147
import { Button } from '@/components/ui/button'
@@ -214,7 +215,6 @@ const { t } = useI18n()
214215
215216
const insertContent = ref(null)
216217
const setInlineImage = ref(null)
217-
const editorPlaceholder = t('replyBox.editor.placeholder')
218218
219219
const toggleBcc = async () => {
220220
showBcc.value = !showBcc.value
@@ -304,11 +304,15 @@ const handleAiPromptSelected = (key) => {
304304
}
305305
306306
// Watch and update macro view based on message type this filters our macros.
307-
watch(messageType, (newType) => {
308-
if (newType === 'reply') {
309-
macroStore.setCurrentView('replying')
310-
} else if (newType === 'private_note') {
311-
macroStore.setCurrentView('adding_private_note')
312-
}
313-
}, { immediate: true })
307+
watch(
308+
messageType,
309+
(newType) => {
310+
if (newType === 'reply') {
311+
macroStore.setCurrentView('replying')
312+
} else if (newType === 'private_note') {
313+
macroStore.setCurrentView('adding_private_note')
314+
}
315+
},
316+
{ immediate: true }
317+
)
314318
</script>

frontend/src/features/conversation/sidebar/ConversationSideBarWrapper.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
<button
1515
v-if="!conversationSidebarOpen"
1616
@click="toggleSidebar"
17-
class="absolute right-full top-16 p-2 rounded-l-full bg-background text-primary hover:bg-opacity-90 transition-all duration-200 shadow-lg group dark:border"
17+
class="absolute right-full top-16 p-2 rounded-l-full bg-background text-primary hover:bg-opacity-90 transition-all duration-200 border shadow hover:scale-105"
1818
>
19-
<ChevronLeft size="16" class="group-hover:scale-110 transition-transform" />
19+
<ChevronLeft size="16"/>
2020
</button>
2121
</Sidebar>
2222
</SidebarProvider>

i18n/en.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,13 +589,14 @@
589589
"conversation.sidebar.previousConvo": "Previous conversations",
590590
"conversation.sidebar.noPreviousConvo": "No previous conversations",
591591
"conversation.sidebar.notAvailable": "Not available",
592-
"editor.placeholder": "Shift + Enter to add a new line",
592+
"editor.newLine": "Shift + Enter to add a new line. ",
593+
"editor.send": " Cmd + Enter to send. ",
594+
"editor.cmdK": "Cmd + K to open command bar. ",
593595
"ai.apiKeyNotSet": "{provider} API Key is not set. Please ask administrator to set it up",
594596
"ai.enterOpenAIAPIKey": "Enter OpenAI API Key",
595597
"ai.apiKey.description": "{provider} API Key is not set or invalid. Please enter a valid API key to use AI features.",
596598
"replyBox.reply": "Reply",
597599
"replyBox.emailAddresess": "Email addresses separated by comma",
598-
"replyBox.editor.placeholder": "Shift + Enter to add a new line. Cmd + Enter to send. Cmd + K to open command bar.",
599600
"replyBox.invalidEmailsIn": "Invalid email(s) in",
600601
"replyBox.correctEmailErrors": "Please correct the email errors before sending.",
601602
"contact.blockConfirm": "Are you sure you want to block this contact? They will no longer be able to interact with you.",

0 commit comments

Comments
 (0)