11<script setup lang="ts">
22import type { DraftItem , DatabaseItem , DatabasePageItem } from ' ../../types'
33import type { PropType } from ' vue'
4- import { ref , computed , nextTick , watch } from ' vue'
4+ import { ref , computed , nextTick , watch , onMounted , onUnmounted } from ' vue'
55import { DraftStatus , ContentFileExtension } from ' ../../types'
66import { getFileExtension } from ' ../../utils/file'
77import { generateContentFromDocument , isEqual } from ' ../../utils/content'
@@ -25,6 +25,46 @@ const isLoadingContent = ref(false)
2525const isOpen = ref (false )
2626const isAutomaticFormattingDetected = ref (false )
2727
28+ const height = ref (200 )
29+ const isResizing = ref (false )
30+ const resizeStartY = ref (0 )
31+ const resizeStartHeight = ref (0 )
32+ const MIN_HEIGHT = 200
33+ const MAX_HEIGHT = 600
34+
35+ function startResize(event : MouseEvent ) {
36+ event .preventDefault ()
37+ isResizing .value = true
38+ resizeStartY .value = event .clientY
39+ resizeStartHeight .value = height .value
40+ }
41+
42+ function handleMouseMove(event : MouseEvent ) {
43+ if (! isResizing .value ) return
44+
45+ event .preventDefault ()
46+ const deltaY = event .clientY - resizeStartY .value
47+ const newHeight = resizeStartHeight .value + deltaY
48+
49+ // Limit to constraints
50+ height .value = Math .min (MAX_HEIGHT , Math .max (MIN_HEIGHT , newHeight ))
51+ }
52+
53+ function handleMouseUp() {
54+ if (! isResizing .value ) return
55+ isResizing .value = false
56+ }
57+
58+ onMounted (() => {
59+ document .addEventListener (' mousemove' , handleMouseMove )
60+ document .addEventListener (' mouseup' , handleMouseUp )
61+ })
62+
63+ onUnmounted (() => {
64+ document .removeEventListener (' mousemove' , handleMouseMove )
65+ document .removeEventListener (' mouseup' , handleMouseUp )
66+ })
67+
2868const language = computed (() => {
2969 const ext = getFileExtension (props .draftItem .fsPath )
3070 switch (ext ) {
@@ -65,7 +105,6 @@ async function initializeEditor() {
65105 language: language .value ,
66106 colorMode: ui .colorMode ,
67107 editorOptions: {
68- // hide unchanged regions
69108 hideUnchangedRegions: {
70109 enabled: true ,
71110 },
@@ -91,7 +130,10 @@ async function initializeEditor() {
91130 :draft-item =" draftItem"
92131 >
93132 <template #open >
94- <div class =" bg-elevated h-[200px]" >
133+ <div
134+ class =" bg-elevated relative"
135+ :style =" { height: `${height}px` }"
136+ >
95137 <div
96138 v-if =" isLoadingContent"
97139 class =" p-4 flex items-center justify-center h-full"
@@ -116,6 +158,18 @@ async function initializeEditor() {
116158 class =" w-full h-full"
117159 />
118160 </div >
161+
162+ <!-- Resize handle -->
163+ <div
164+ class =" absolute bottom-0 left-0 right-0 h-1 cursor-row-resize bg-transparent hover:bg-accented transition-colors duration-200 group"
165+ :class =" { 'bg-accented': isResizing }"
166+ @mousedown =" startResize"
167+ >
168+ <div
169+ class =" absolute bottom-0 left-1/2 transform -translate-x-1/2 h-1 w-8 bg-inverted rounded-t opacity-0 group-hover:opacity-100 transition-opacity duration-200"
170+ :class =" { 'opacity-100': isResizing }"
171+ />
172+ </div >
119173 </div >
120174 </template >
121175 </ItemCardReview >
0 commit comments