11<script setup lang="ts">
2- // TODO - Limit the number of characters in the note title and content
32import { type Note } from " @/composables/useNotes" ;
43import { categories as CategoryList , type Category } from " @/utils/categories" ;
4+ import { useClipboard } from " @/composables/useClipboard" ;
5+ const { copyToClipboard } = useClipboard ();
56
67const props = defineProps ({
78 note: {
@@ -32,6 +33,10 @@ const editNote = () => {
3233const deleteNote = () => {
3334 emit (" delete" );
3435};
36+
37+ const limitText = (text : string , limit : number ) => {
38+ return text .length > limit ? text .slice (0 , limit ) + " ..." : text ;
39+ };
3540 </script >
3641
3742<template >
@@ -45,30 +50,45 @@ const deleteNote = () => {
4550 <Icon :name =" category?.icon" size =" 1.5em" />
4651 </div >
4752
48- <div class =" text-background/95 text-sm font-semibold" >
49- {{ props.note?.title || "Untitled" }}
53+ <div
54+ class =" text-background/95 text-sm font-semibold"
55+ @click =" editNote()"
56+ >
57+ {{ limitText(props.note?.title, 25) || "Untitled" }}
5058 </div >
5159 </div >
5260
5361 <!-- actions -->
54- <div class =" flex items-center space-x-2 text-white" >
62+ <div class =" flex items-center space-x-2 text-background/75" >
63+ <button
64+ @click =" copyToClipboard(props.note.content || props.note.title)"
65+ title =" Copy to clipboard"
66+ class =" hover:text-vue-green transition-colors cursor-pointer"
67+ >
68+ <Icon name =" mdi:clipboard" size =" 22" />
69+ </button >
5570 <button
5671 @click =" editNote()"
72+ title =" Edit note"
5773 class =" hover:text-vue-green transition-colors cursor-pointer"
5874 >
59- <Icon name =" mdi:edit" size =" 20 " />
75+ <Icon name =" mdi:edit" size =" 22 " />
6076 </button >
6177 <button
6278 @click =" deleteNote()"
79+ title =" Delete note"
6380 class =" hover:text-vue-green transition-colors cursor-pointer"
6481 >
65- <Icon name =" mdi:trash" size =" 20 " />
82+ <Icon name =" mdi:trash" size =" 22 " />
6683 </button >
6784 </div >
6885 </div >
6986
70- <p class =" mt-2 text-gray-500 text-sm font-light leading-relaxed" >
71- {{ props.note?.content || "No content available." }}
87+ <p
88+ class =" mt-2 text-gray-500 text-sm font-light leading-relaxed"
89+ @click =" editNote()"
90+ >
91+ {{ limitText(props.note?.content, 50) || "No content available." }}
7292 </p >
7393 </div >
7494 </div >
0 commit comments