Spaces:
Sleeping
Sleeping
Upload 61 files
Browse files- App.tsx +61 -9
- components/DetailView.tsx +3 -11
App.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import { Card } from './components/Card';
|
|
| 4 |
import { DataForm } from './components/DataForm';
|
| 5 |
import { DetailView } from './components/DetailView';
|
| 6 |
import { Button } from './components/Button';
|
| 7 |
-
import { Plus, Search, Layers, Loader2, WifiOff, Settings, Code, Type, Clock, Calendar, Shuffle, ChevronsLeft, ChevronLeft, ChevronRight, ChevronsRight, Check, Trash, MapPin } from 'lucide-react';
|
| 8 |
import { subscribeToItems, addItem, updateItem, deleteItem } from './services/firebase';
|
| 9 |
import { subscribeToStyleConfig } from './services/codeStyleService';
|
| 10 |
import { BulkCategoryModal } from './components/BulkCategoryModal';
|
|
@@ -42,6 +42,12 @@ const App: React.FC = () => {
|
|
| 42 |
}
|
| 43 |
return false;
|
| 44 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
const [isFoldersPlusEnabled, setIsFoldersPlusEnabled] = useState(() => {
|
| 46 |
if (typeof window !== 'undefined') {
|
| 47 |
return localStorage.getItem('foldersPlusEnabled') === 'true';
|
|
@@ -107,17 +113,18 @@ const App: React.FC = () => {
|
|
| 107 |
localStorage.setItem('categoriesPlusEnabled', isCategoriesPlusEnabled.toString());
|
| 108 |
localStorage.setItem('deletePlusEnabled', isDeletePlusEnabled.toString());
|
| 109 |
localStorage.setItem('foldersPlusEnabled', isFoldersPlusEnabled.toString());
|
| 110 |
-
|
|
|
|
| 111 |
|
| 112 |
useEffect(() => {
|
| 113 |
localStorage.setItem('showBreadcrumbsEnabled', isShowBreadcrumbsEnabled.toString());
|
| 114 |
}, [isShowBreadcrumbsEnabled]);
|
| 115 |
|
| 116 |
useEffect(() => {
|
| 117 |
-
if (!isCategoriesPlusEnabled && !isDeletePlusEnabled && !isFoldersPlusEnabled) {
|
| 118 |
setSelectedItemIds(new Set());
|
| 119 |
}
|
| 120 |
-
}, [isCategoriesPlusEnabled, isDeletePlusEnabled, isFoldersPlusEnabled]);
|
| 121 |
|
| 122 |
// Handle URL Sync
|
| 123 |
useEffect(() => {
|
|
@@ -748,6 +755,27 @@ const App: React.FC = () => {
|
|
| 748 |
<span className={`pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out ${isFoldersPlusEnabled ? 'translate-x-5' : 'translate-x-0'}`} />
|
| 749 |
</button>
|
| 750 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 751 |
</div>
|
| 752 |
</div>
|
| 753 |
)}
|
|
@@ -862,7 +890,7 @@ const App: React.FC = () => {
|
|
| 862 |
key={item.id}
|
| 863 |
item={item}
|
| 864 |
onClick={(i) => {
|
| 865 |
-
if (isCategoriesPlusEnabled || isDeletePlusEnabled || isFoldersPlusEnabled) return;
|
| 866 |
if (i.isFolder) {
|
| 867 |
setCurrentFolderId(i.id);
|
| 868 |
setCurrentPage(1);
|
|
@@ -879,10 +907,10 @@ const App: React.FC = () => {
|
|
| 879 |
setView('DETAIL');
|
| 880 |
}
|
| 881 |
}}
|
| 882 |
-
isSelectable={viewMode === 'admin' && (isCategoriesPlusEnabled || isDeletePlusEnabled || isFoldersPlusEnabled)}
|
| 883 |
isSelected={selectedItemIds.has(item.id)}
|
| 884 |
onMouseDown={(e, i) => {
|
| 885 |
-
if (!(isCategoriesPlusEnabled || isDeletePlusEnabled || isFoldersPlusEnabled)) return;
|
| 886 |
setIsDragging(true);
|
| 887 |
const currentlySelected = selectedItemIds.has(i.id);
|
| 888 |
setDragMode(currentlySelected ? 'deselect' : 'select');
|
|
@@ -895,7 +923,7 @@ const App: React.FC = () => {
|
|
| 895 |
});
|
| 896 |
}}
|
| 897 |
onMouseEnter={(e, i) => {
|
| 898 |
-
if (!(isCategoriesPlusEnabled || isDeletePlusEnabled || isFoldersPlusEnabled) || !isDragging) return;
|
| 899 |
setSelectedItemIds(prev => {
|
| 900 |
const next = new Set(prev);
|
| 901 |
if (dragMode === 'select') next.add(i.id);
|
|
@@ -963,7 +991,7 @@ const App: React.FC = () => {
|
|
| 963 |
</main>
|
| 964 |
|
| 965 |
{/* Floating Action Bar for Bulk Mode */}
|
| 966 |
-
{(isCategoriesPlusEnabled || isDeletePlusEnabled || isFoldersPlusEnabled || selectedItemIds.size > 0) && viewMode === 'admin' && view === 'LIST' && (
|
| 967 |
<div className="fixed bottom-8 left-1/2 -translate-x-1/2 z-40 bg-[#121212] border border-white/10 p-4 rounded-2xl shadow-[0_0_30px_rgba(0,0,0,0.8)] flex items-center justify-between gap-6 min-w-[320px] animate-in slide-in-from-bottom-5 duration-300">
|
| 968 |
<div className="flex flex-col min-w-[120px]">
|
| 969 |
<span className="text-white font-bold">{selectedItemIds.size} seleccionados</span>
|
|
@@ -1006,6 +1034,30 @@ const App: React.FC = () => {
|
|
| 1006 |
<Trash size={16} /> <span className="hidden sm:inline">Eliminar</span>
|
| 1007 |
</Button>
|
| 1008 |
)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1009 |
{isFoldersPlusEnabled && (
|
| 1010 |
<Button
|
| 1011 |
onClick={() => setShowMoveToFolder(true)}
|
|
|
|
| 4 |
import { DataForm } from './components/DataForm';
|
| 5 |
import { DetailView } from './components/DetailView';
|
| 6 |
import { Button } from './components/Button';
|
| 7 |
+
import { Plus, Search, Layers, Loader2, WifiOff, Settings, Code, Type, Clock, Calendar, Shuffle, ChevronsLeft, ChevronLeft, ChevronRight, ChevronsRight, Check, Trash, MapPin, Copy } from 'lucide-react';
|
| 8 |
import { subscribeToItems, addItem, updateItem, deleteItem } from './services/firebase';
|
| 9 |
import { subscribeToStyleConfig } from './services/codeStyleService';
|
| 10 |
import { BulkCategoryModal } from './components/BulkCategoryModal';
|
|
|
|
| 42 |
}
|
| 43 |
return false;
|
| 44 |
});
|
| 45 |
+
const [isDuplicatePlusEnabled, setIsDuplicatePlusEnabled] = useState(() => {
|
| 46 |
+
if (typeof window !== 'undefined') {
|
| 47 |
+
return localStorage.getItem('duplicatePlusEnabled') === 'true';
|
| 48 |
+
}
|
| 49 |
+
return false;
|
| 50 |
+
});
|
| 51 |
const [isFoldersPlusEnabled, setIsFoldersPlusEnabled] = useState(() => {
|
| 52 |
if (typeof window !== 'undefined') {
|
| 53 |
return localStorage.getItem('foldersPlusEnabled') === 'true';
|
|
|
|
| 113 |
localStorage.setItem('categoriesPlusEnabled', isCategoriesPlusEnabled.toString());
|
| 114 |
localStorage.setItem('deletePlusEnabled', isDeletePlusEnabled.toString());
|
| 115 |
localStorage.setItem('foldersPlusEnabled', isFoldersPlusEnabled.toString());
|
| 116 |
+
localStorage.setItem('duplicatePlusEnabled', isDuplicatePlusEnabled.toString());
|
| 117 |
+
}, [isCategoriesPlusEnabled, isDeletePlusEnabled, isFoldersPlusEnabled, isDuplicatePlusEnabled]);
|
| 118 |
|
| 119 |
useEffect(() => {
|
| 120 |
localStorage.setItem('showBreadcrumbsEnabled', isShowBreadcrumbsEnabled.toString());
|
| 121 |
}, [isShowBreadcrumbsEnabled]);
|
| 122 |
|
| 123 |
useEffect(() => {
|
| 124 |
+
if (!isCategoriesPlusEnabled && !isDeletePlusEnabled && !isFoldersPlusEnabled && !isDuplicatePlusEnabled) {
|
| 125 |
setSelectedItemIds(new Set());
|
| 126 |
}
|
| 127 |
+
}, [isCategoriesPlusEnabled, isDeletePlusEnabled, isFoldersPlusEnabled, isDuplicatePlusEnabled]);
|
| 128 |
|
| 129 |
// Handle URL Sync
|
| 130 |
useEffect(() => {
|
|
|
|
| 755 |
<span className={`pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out ${isFoldersPlusEnabled ? 'translate-x-5' : 'translate-x-0'}`} />
|
| 756 |
</button>
|
| 757 |
</div>
|
| 758 |
+
|
| 759 |
+
<div
|
| 760 |
+
className="flex items-center justify-between px-3 py-3 mt-1 rounded-lg hover:bg-white/5 group border border-transparent hover:border-white/5 transition-all cursor-pointer"
|
| 761 |
+
onClick={() => setIsDuplicatePlusEnabled(!isDuplicatePlusEnabled)}
|
| 762 |
+
>
|
| 763 |
+
<div className="flex items-start gap-3">
|
| 764 |
+
<div className="p-2 bg-[#1a1f2e] group-hover:bg-[#22283a] border border-white/5 rounded-xl transition-colors">
|
| 765 |
+
<Copy size={18} className="text-gray-300 group-hover:text-white transition-colors" />
|
| 766 |
+
</div>
|
| 767 |
+
<div className="flex flex-col text-left justify-center">
|
| 768 |
+
<span className="text-sm font-medium text-white mb-0.5">Duplicar Plus</span>
|
| 769 |
+
<span className="text-[11px] text-gray-400 leading-tight">Habilitar selección masiva para duplicar entradas</span>
|
| 770 |
+
</div>
|
| 771 |
+
</div>
|
| 772 |
+
<button
|
| 773 |
+
className={`relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none ${isDuplicatePlusEnabled ? 'bg-primary' : 'bg-gray-600'}`}
|
| 774 |
+
>
|
| 775 |
+
<span className="sr-only">Habilitar Duplicar Plus</span>
|
| 776 |
+
<span className={`pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out ${isDuplicatePlusEnabled ? 'translate-x-5' : 'translate-x-0'}`} />
|
| 777 |
+
</button>
|
| 778 |
+
</div>
|
| 779 |
</div>
|
| 780 |
</div>
|
| 781 |
)}
|
|
|
|
| 890 |
key={item.id}
|
| 891 |
item={item}
|
| 892 |
onClick={(i) => {
|
| 893 |
+
if (isCategoriesPlusEnabled || isDeletePlusEnabled || isFoldersPlusEnabled || isDuplicatePlusEnabled) return;
|
| 894 |
if (i.isFolder) {
|
| 895 |
setCurrentFolderId(i.id);
|
| 896 |
setCurrentPage(1);
|
|
|
|
| 907 |
setView('DETAIL');
|
| 908 |
}
|
| 909 |
}}
|
| 910 |
+
isSelectable={viewMode === 'admin' && (isCategoriesPlusEnabled || isDeletePlusEnabled || isFoldersPlusEnabled || isDuplicatePlusEnabled)}
|
| 911 |
isSelected={selectedItemIds.has(item.id)}
|
| 912 |
onMouseDown={(e, i) => {
|
| 913 |
+
if (!(isCategoriesPlusEnabled || isDeletePlusEnabled || isFoldersPlusEnabled || isDuplicatePlusEnabled)) return;
|
| 914 |
setIsDragging(true);
|
| 915 |
const currentlySelected = selectedItemIds.has(i.id);
|
| 916 |
setDragMode(currentlySelected ? 'deselect' : 'select');
|
|
|
|
| 923 |
});
|
| 924 |
}}
|
| 925 |
onMouseEnter={(e, i) => {
|
| 926 |
+
if (!(isCategoriesPlusEnabled || isDeletePlusEnabled || isFoldersPlusEnabled || isDuplicatePlusEnabled) || !isDragging) return;
|
| 927 |
setSelectedItemIds(prev => {
|
| 928 |
const next = new Set(prev);
|
| 929 |
if (dragMode === 'select') next.add(i.id);
|
|
|
|
| 991 |
</main>
|
| 992 |
|
| 993 |
{/* Floating Action Bar for Bulk Mode */}
|
| 994 |
+
{(isCategoriesPlusEnabled || isDeletePlusEnabled || isFoldersPlusEnabled || isDuplicatePlusEnabled || selectedItemIds.size > 0) && viewMode === 'admin' && view === 'LIST' && (
|
| 995 |
<div className="fixed bottom-8 left-1/2 -translate-x-1/2 z-40 bg-[#121212] border border-white/10 p-4 rounded-2xl shadow-[0_0_30px_rgba(0,0,0,0.8)] flex items-center justify-between gap-6 min-w-[320px] animate-in slide-in-from-bottom-5 duration-300">
|
| 996 |
<div className="flex flex-col min-w-[120px]">
|
| 997 |
<span className="text-white font-bold">{selectedItemIds.size} seleccionados</span>
|
|
|
|
| 1034 |
<Trash size={16} /> <span className="hidden sm:inline">Eliminar</span>
|
| 1035 |
</Button>
|
| 1036 |
)}
|
| 1037 |
+
{isDuplicatePlusEnabled && (
|
| 1038 |
+
<Button
|
| 1039 |
+
onClick={async () => {
|
| 1040 |
+
try {
|
| 1041 |
+
await Promise.all(
|
| 1042 |
+
Array.from(selectedItemIds).map(async (id) => {
|
| 1043 |
+
const item = items.find(i => i.id === id);
|
| 1044 |
+
if (item) {
|
| 1045 |
+
const { id: _id, createdAt, updatedAt, ...rest } = item;
|
| 1046 |
+
await addItem({ ...rest, title: `${rest.title} (Copia)` });
|
| 1047 |
+
}
|
| 1048 |
+
})
|
| 1049 |
+
);
|
| 1050 |
+
setSelectedItemIds(new Set());
|
| 1051 |
+
} catch(e) {
|
| 1052 |
+
alert("Error al duplicar las entradas.");
|
| 1053 |
+
}
|
| 1054 |
+
}}
|
| 1055 |
+
className="!py-2 !px-4 bg-purple-500/10 text-purple-400 hover:bg-purple-500 hover:text-white border-transparent"
|
| 1056 |
+
disabled={selectedItemIds.size === 0}
|
| 1057 |
+
>
|
| 1058 |
+
<Copy size={16} /> <span className="hidden sm:inline">Duplicar</span>
|
| 1059 |
+
</Button>
|
| 1060 |
+
)}
|
| 1061 |
{isFoldersPlusEnabled && (
|
| 1062 |
<Button
|
| 1063 |
onClick={() => setShowMoveToFolder(true)}
|
components/DetailView.tsx
CHANGED
|
@@ -670,16 +670,6 @@ export const DetailView: React.FC<DetailViewProps> = ({ item, onBack, onUpdate,
|
|
| 670 |
|
| 671 |
{isEditable && (
|
| 672 |
<>
|
| 673 |
-
{onDuplicate && (
|
| 674 |
-
<Button
|
| 675 |
-
variant="outline"
|
| 676 |
-
onClick={onDuplicate}
|
| 677 |
-
className="!py-1.5 !px-3 text-xs h-8"
|
| 678 |
-
title="Duplicar entrada"
|
| 679 |
-
>
|
| 680 |
-
<Copy size={14} /> <span className="hidden sm:inline">Duplicar</span>
|
| 681 |
-
</Button>
|
| 682 |
-
)}
|
| 683 |
<Button
|
| 684 |
variant="outline"
|
| 685 |
onClick={() => setIsEditMode(true)}
|
|
@@ -706,10 +696,12 @@ export const DetailView: React.FC<DetailViewProps> = ({ item, onBack, onUpdate,
|
|
| 706 |
</div>
|
| 707 |
|
| 708 |
<h1
|
| 709 |
-
className="text-2xl md:text-3xl font-bold text-white mb-
|
| 710 |
dangerouslySetInnerHTML={{ __html: item.title || 'Título' }}
|
| 711 |
/>
|
| 712 |
|
|
|
|
|
|
|
| 713 |
<TipTapEditor
|
| 714 |
content={item.summary || '<p>Resumen</p>'}
|
| 715 |
onUpdate={() => { }}
|
|
|
|
| 670 |
|
| 671 |
{isEditable && (
|
| 672 |
<>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 673 |
<Button
|
| 674 |
variant="outline"
|
| 675 |
onClick={() => setIsEditMode(true)}
|
|
|
|
| 696 |
</div>
|
| 697 |
|
| 698 |
<h1
|
| 699 |
+
className="text-2xl md:text-3xl font-bold text-white mb-4 md:pr-32 [&>p]:inline [&>p]:m-0"
|
| 700 |
dangerouslySetInnerHTML={{ __html: item.title || 'Título' }}
|
| 701 |
/>
|
| 702 |
|
| 703 |
+
<hr className="border-white/10 mb-4" />
|
| 704 |
+
|
| 705 |
<TipTapEditor
|
| 706 |
content={item.summary || '<p>Resumen</p>'}
|
| 707 |
onUpdate={() => { }}
|