Skip to content

Commit 3e08a0d

Browse files
authored
feat: remove custome tiptap (#1295)
1 parent f31c9e6 commit 3e08a0d

1 file changed

Lines changed: 1 addition & 105 deletions

File tree

src/renderer/src/components/chat-input/ChatInput.vue

Lines changed: 1 addition & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,12 @@
6464
</div>
6565

6666
<!-- Editor -->
67-
<div ref="editorContainer" class="flex-1 min-h-0 overflow-y-auto relative">
67+
<div class="flex-1 min-h-0 overflow-y-auto relative">
6868
<editor-content
6969
:editor="editor"
7070
:class="['text-sm h-full', variant === 'chat' ? 'dark:text-white/80' : 'p-2']"
7171
@keydown="onKeydown"
7272
/>
73-
<div v-if="showFakeCaret" class="fake-caret" :style="fakeCaretStyle" />
7473
</div>
7574

7675
<!-- Footer -->
@@ -571,15 +570,7 @@ const { t } = useI18n()
571570
// === Local State ===
572571
const fileInput = ref<HTMLInputElement>()
573572
const modelSelectOpen = ref(false)
574-
const editorContainer = ref<HTMLElement | null>(null)
575-
const caretPosition = ref({ x: 0, y: 0, height: 18 })
576-
const caretVisible = ref(false)
577573
const isCallActive = ref(false)
578-
const fakeCaretStyle = computed(() => ({
579-
transform: `translate(${caretPosition.value.x}px, ${caretPosition.value.y}px)`,
580-
height: `${caretPosition.value.height}px`
581-
}))
582-
const showFakeCaret = computed(() => caretVisible.value && !props.disabled && !isCallActive.value)
583574
584575
// === Composable Integrations ===
585576
@@ -648,48 +639,6 @@ const editor = new Editor({
648639
]
649640
})
650641
651-
let caretAnimationFrame: number | null = null
652-
653-
const updateFakeCaretPosition = () => {
654-
if (!editorContainer.value) return
655-
656-
if (caretAnimationFrame) {
657-
cancelAnimationFrame(caretAnimationFrame)
658-
}
659-
660-
caretAnimationFrame = requestAnimationFrame(() => {
661-
if (!editorContainer.value) return
662-
663-
const view = editor.view
664-
const position = view.state.selection.$anchor.pos
665-
666-
let coords
667-
try {
668-
coords = view.coordsAtPos(position)
669-
} catch (error) {
670-
return
671-
}
672-
673-
const containerRect = editorContainer.value.getBoundingClientRect()
674-
const caretHeight = Math.max(coords.bottom - coords.top, 18)
675-
676-
caretPosition.value = {
677-
x: coords.left - containerRect.left,
678-
y: coords.top - containerRect.top,
679-
height: caretHeight
680-
}
681-
})
682-
}
683-
684-
const handleEditorFocus = () => {
685-
caretVisible.value = true
686-
updateFakeCaretPosition()
687-
}
688-
689-
const handleEditorBlur = () => {
690-
caretVisible.value = false
691-
}
692-
693642
// Set the editor instance in history after editor is created
694643
history.setEditor(editor)
695644
@@ -710,10 +659,6 @@ const editorComposable = usePromptInputEditor(
710659
711660
// Setup editor update handler
712661
editor.on('update', editorComposable.onEditorUpdate)
713-
editor.on('selectionUpdate', updateFakeCaretPosition)
714-
editor.on('transaction', updateFakeCaretPosition)
715-
editor.on('focus', handleEditorFocus)
716-
editor.on('blur', handleEditorBlur)
717662
718663
// Initialize context length tracking
719664
const contextLengthTracker = useContextLength({
@@ -970,9 +915,6 @@ const appendCustomMention = (mention: CategorizedData) => {
970915
return inserted
971916
}
972917
973-
useEventListener(window, 'resize', updateFakeCaretPosition)
974-
useEventListener(editorContainer, 'scroll', updateFakeCaretPosition)
975-
976918
// === Lifecycle Hooks ===
977919
onMounted(async () => {
978920
// Settings are auto-initialized by useInputSettings composable
@@ -990,8 +932,6 @@ onMounted(async () => {
990932
991933
// Setup editor paste handler
992934
editorComposable.setupEditorPasteHandler(files.handlePaste)
993-
994-
nextTick(updateFakeCaretPosition)
995935
})
996936
997937
useEventListener(window, 'context-menu-ask-ai', handleContextMenuAskAI)
@@ -1003,18 +943,8 @@ onUnmounted(() => {
1003943
1004944
// Remove editor update listener
1005945
editor.off('update', editorComposable.onEditorUpdate)
1006-
editor.off('selectionUpdate', updateFakeCaretPosition)
1007-
editor.off('transaction', updateFakeCaretPosition)
1008-
editor.off('focus', handleEditorFocus)
1009-
editor.off('blur', handleEditorBlur)
1010-
1011-
// Destroy editor instance
1012946
editor.destroy()
1013947
1014-
if (caretAnimationFrame) {
1015-
cancelAnimationFrame(caretAnimationFrame)
1016-
}
1017-
1018948
setWorkspaceMention(null)
1019949
})
1020950
@@ -1105,40 +1035,6 @@ defineExpose({
11051035
.duration-300 {
11061036
transition-duration: 300ms;
11071037
}
1108-
1109-
:deep(.tiptap) {
1110-
caret-color: transparent;
1111-
}
1112-
1113-
.fake-caret {
1114-
position: absolute;
1115-
top: 0;
1116-
left: 0;
1117-
width: 2px;
1118-
border-radius: 9999px;
1119-
background: var(--primary);
1120-
box-shadow: 0 0 10px var(--primary);
1121-
animation: fake-caret-blink 1.2s steps(1) infinite;
1122-
transition:
1123-
transform 140ms cubic-bezier(0.22, 1, 0.36, 1),
1124-
height 140ms cubic-bezier(0.22, 1, 0.36, 1),
1125-
opacity 120ms ease;
1126-
pointer-events: none;
1127-
will-change: transform, height, opacity;
1128-
opacity: 0.9;
1129-
}
1130-
1131-
@keyframes fake-caret-blink {
1132-
0%,
1133-
55% {
1134-
opacity: 0.9;
1135-
}
1136-
1137-
55%,
1138-
100% {
1139-
opacity: 0.35;
1140-
}
1141-
}
11421038
</style>
11431039

11441040
<style>

0 commit comments

Comments
 (0)