Spaces:
Sleeping
Sleeping
Upload 61 files
Browse files- components/CodeBlockComponent.tsx +22 -36
- components/DetailView.tsx +1 -67
- components/QuoteComponent.tsx +20 -34
components/CodeBlockComponent.tsx
CHANGED
|
@@ -44,19 +44,20 @@ export const CodeBlockComponent: React.FC<NodeViewProps> = (props) => {
|
|
| 44 |
setDetectedLang(defaultLanguage);
|
| 45 |
}
|
| 46 |
|
| 47 |
-
|
| 48 |
-
setContentHeight(contentRef.current.scrollHeight);
|
| 49 |
-
}
|
| 50 |
-
|
| 51 |
-
const handleResize = () => {
|
| 52 |
if (contentRef.current) {
|
|
|
|
|
|
|
| 53 |
setContentHeight(contentRef.current.scrollHeight);
|
|
|
|
| 54 |
}
|
| 55 |
};
|
| 56 |
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
|
|
|
|
|
|
| 60 |
|
| 61 |
useEffect(() => {
|
| 62 |
if (isEditingName && inputRef.current) {
|
|
@@ -106,13 +107,6 @@ export const CodeBlockComponent: React.FC<NodeViewProps> = (props) => {
|
|
| 106 |
}
|
| 107 |
};
|
| 108 |
|
| 109 |
-
const handleClick = (e: React.MouseEvent) => {
|
| 110 |
-
if (e.detail === 3 && props.editor.isEditable) {
|
| 111 |
-
e.preventDefault();
|
| 112 |
-
handleOpenSettings(e);
|
| 113 |
-
}
|
| 114 |
-
};
|
| 115 |
-
|
| 116 |
const handleOpenSettings = (e: React.MouseEvent) => {
|
| 117 |
e.preventDefault();
|
| 118 |
e.stopPropagation();
|
|
@@ -136,7 +130,6 @@ export const CodeBlockComponent: React.FC<NodeViewProps> = (props) => {
|
|
| 136 |
return (
|
| 137 |
<NodeViewWrapper
|
| 138 |
className="relative group my-6 rounded-xl overflow-hidden bg-[#151515] border border-white/10 shadow-2xl ring-1 ring-white/5 w-full not-prose"
|
| 139 |
-
onClick={handleClick}
|
| 140 |
>
|
| 141 |
<div className="flex items-center justify-between px-4 py-3 bg-[#202020] border-b border-white/5">
|
| 142 |
<div className="flex items-center gap-2">
|
|
@@ -184,6 +177,19 @@ export const CodeBlockComponent: React.FC<NodeViewProps> = (props) => {
|
|
| 184 |
</button>
|
| 185 |
</>
|
| 186 |
)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
<button
|
| 188 |
onClick={handleDownload}
|
| 189 |
contentEditable={false}
|
|
@@ -242,26 +248,6 @@ export const CodeBlockComponent: React.FC<NodeViewProps> = (props) => {
|
|
| 242 |
<NodeViewContent as="code" className="font-mono text-sm text-zinc-300 leading-relaxed block" />
|
| 243 |
</pre>
|
| 244 |
</div>
|
| 245 |
-
|
| 246 |
-
{props.node.attrs.collapsible && (
|
| 247 |
-
<div className="absolute bottom-2 right-2 z-10">
|
| 248 |
-
<button
|
| 249 |
-
onClick={(e) => {
|
| 250 |
-
e.stopPropagation();
|
| 251 |
-
toggleExpand();
|
| 252 |
-
}}
|
| 253 |
-
contentEditable={false}
|
| 254 |
-
className="text-zinc-400 hover:text-white transition-colors cursor-pointer select-none p-1 bg-[#151515]/80 rounded-full backdrop-blur-sm border border-white/5"
|
| 255 |
-
title={isManualExpanded ? "Contraer" : "Expandir"}
|
| 256 |
-
>
|
| 257 |
-
{isManualExpanded ? (
|
| 258 |
-
<ChevronUp size={16} />
|
| 259 |
-
) : (
|
| 260 |
-
<ChevronDown size={16} />
|
| 261 |
-
)}
|
| 262 |
-
</button>
|
| 263 |
-
</div>
|
| 264 |
-
)}
|
| 265 |
</NodeViewWrapper>
|
| 266 |
);
|
| 267 |
};
|
|
|
|
| 44 |
setDetectedLang(defaultLanguage);
|
| 45 |
}
|
| 46 |
|
| 47 |
+
const measureHeight = () => {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
if (contentRef.current) {
|
| 49 |
+
const currentMaxHeight = contentRef.current.style.maxHeight;
|
| 50 |
+
contentRef.current.style.maxHeight = 'none';
|
| 51 |
setContentHeight(contentRef.current.scrollHeight);
|
| 52 |
+
contentRef.current.style.maxHeight = currentMaxHeight;
|
| 53 |
}
|
| 54 |
};
|
| 55 |
|
| 56 |
+
measureHeight();
|
| 57 |
+
|
| 58 |
+
window.addEventListener('resize', measureHeight);
|
| 59 |
+
return () => window.removeEventListener('resize', measureHeight);
|
| 60 |
+
}, [props.node.textContent, showLineNumbers, wrapText]);
|
| 61 |
|
| 62 |
useEffect(() => {
|
| 63 |
if (isEditingName && inputRef.current) {
|
|
|
|
| 107 |
}
|
| 108 |
};
|
| 109 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
const handleOpenSettings = (e: React.MouseEvent) => {
|
| 111 |
e.preventDefault();
|
| 112 |
e.stopPropagation();
|
|
|
|
| 130 |
return (
|
| 131 |
<NodeViewWrapper
|
| 132 |
className="relative group my-6 rounded-xl overflow-hidden bg-[#151515] border border-white/10 shadow-2xl ring-1 ring-white/5 w-full not-prose"
|
|
|
|
| 133 |
>
|
| 134 |
<div className="flex items-center justify-between px-4 py-3 bg-[#202020] border-b border-white/5">
|
| 135 |
<div className="flex items-center gap-2">
|
|
|
|
| 177 |
</button>
|
| 178 |
</>
|
| 179 |
)}
|
| 180 |
+
{props.node.attrs.collapsible && (
|
| 181 |
+
<button
|
| 182 |
+
onClick={(e) => {
|
| 183 |
+
e.stopPropagation();
|
| 184 |
+
toggleExpand();
|
| 185 |
+
}}
|
| 186 |
+
contentEditable={false}
|
| 187 |
+
className="p-1.5 rounded-md transition-all duration-200 hover:bg-white/10 text-zinc-400 hover:text-white"
|
| 188 |
+
title={isManualExpanded ? "Contraer" : "Expandir"}
|
| 189 |
+
>
|
| 190 |
+
{isManualExpanded ? <ChevronUp size={14} /> : <ChevronDown size={14} />}
|
| 191 |
+
</button>
|
| 192 |
+
)}
|
| 193 |
<button
|
| 194 |
onClick={handleDownload}
|
| 195 |
contentEditable={false}
|
|
|
|
| 248 |
<NodeViewContent as="code" className="font-mono text-sm text-zinc-300 leading-relaxed block" />
|
| 249 |
</pre>
|
| 250 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 251 |
</NodeViewWrapper>
|
| 252 |
);
|
| 253 |
};
|
components/DetailView.tsx
CHANGED
|
@@ -703,40 +703,7 @@ export const DetailView: React.FC<DetailViewProps> = ({ item, onBack, onUpdate,
|
|
| 703 |
<hr className="border-white/10 mb-4" />
|
| 704 |
|
| 705 |
<div className="relative group/summary">
|
| 706 |
-
|
| 707 |
-
onClick={() => {
|
| 708 |
-
// Create a temporary element to extract text with formatting
|
| 709 |
-
const tempDiv = document.createElement('div');
|
| 710 |
-
tempDiv.innerHTML = item.summary || '';
|
| 711 |
-
|
| 712 |
-
// Replace common block elements with newlines to preserve structure
|
| 713 |
-
const paragraphs = tempDiv.querySelectorAll('p, div, br');
|
| 714 |
-
paragraphs.forEach(p => {
|
| 715 |
-
if (p.tagName === 'BR') {
|
| 716 |
-
p.after('\n');
|
| 717 |
-
} else {
|
| 718 |
-
p.after('\n\n');
|
| 719 |
-
}
|
| 720 |
-
});
|
| 721 |
-
|
| 722 |
-
const text = tempDiv.textContent || tempDiv.innerText || '';
|
| 723 |
-
const cleanedText = text.replace(/\n\s*\n/g, '\n\n').trim();
|
| 724 |
-
|
| 725 |
-
navigator.clipboard.writeText(cleanedText);
|
| 726 |
-
const btn = document.getElementById('copy-btn-summary');
|
| 727 |
-
if (btn) {
|
| 728 |
-
btn.innerHTML = 'Copiado';
|
| 729 |
-
setTimeout(() => {
|
| 730 |
-
if (btn) btn.innerHTML = '';
|
| 731 |
-
}, 2000);
|
| 732 |
-
}
|
| 733 |
-
}}
|
| 734 |
-
className="absolute -top-2 -right-2 p-2 bg-surface/50 backdrop-blur-sm border border-white/10 rounded-lg text-gray-400 hover:text-primary transition-all opacity-0 group-hover/summary:opacity-100 flex items-center gap-2 text-[10px] uppercase tracking-widest font-bold z-30"
|
| 735 |
-
title="Copiar descripción"
|
| 736 |
-
>
|
| 737 |
-
<Copy size={12} />
|
| 738 |
-
<span id="copy-btn-summary"></span>
|
| 739 |
-
</button>
|
| 740 |
|
| 741 |
<TipTapEditor
|
| 742 |
content={item.summary || '<p>Resumen</p>'}
|
|
@@ -823,39 +790,6 @@ export const DetailView: React.FC<DetailViewProps> = ({ item, onBack, onUpdate,
|
|
| 823 |
<div className="space-y-6 mb-8">
|
| 824 |
{item.blocks.map((block, blockIdx) => (
|
| 825 |
<div key={block.id} className={`${getCardClasses(item.cardStyle)} h-fit rounded-xl overflow-hidden p-6 transition-all duration-300 relative group/block`}>
|
| 826 |
-
<button
|
| 827 |
-
onClick={() => {
|
| 828 |
-
const tempDiv = document.createElement('div');
|
| 829 |
-
tempDiv.innerHTML = block.content || '';
|
| 830 |
-
|
| 831 |
-
const paragraphs = tempDiv.querySelectorAll('p, div, br');
|
| 832 |
-
paragraphs.forEach(p => {
|
| 833 |
-
if (p.tagName === 'BR') {
|
| 834 |
-
p.after('\n');
|
| 835 |
-
} else {
|
| 836 |
-
p.after('\n\n');
|
| 837 |
-
}
|
| 838 |
-
});
|
| 839 |
-
|
| 840 |
-
const text = tempDiv.textContent || tempDiv.innerText || '';
|
| 841 |
-
const cleanedText = text.replace(/\n\s*\n/g, '\n\n').trim();
|
| 842 |
-
|
| 843 |
-
navigator.clipboard.writeText(cleanedText);
|
| 844 |
-
const btn = document.getElementById(`copy-btn-block-${blockIdx}`);
|
| 845 |
-
if (btn) {
|
| 846 |
-
btn.innerHTML = 'Copiado';
|
| 847 |
-
setTimeout(() => {
|
| 848 |
-
if (btn) btn.innerHTML = '';
|
| 849 |
-
}, 2000);
|
| 850 |
-
}
|
| 851 |
-
}}
|
| 852 |
-
className="absolute top-4 right-4 p-2 bg-surface/50 backdrop-blur-sm border border-white/10 rounded-lg text-gray-400 hover:text-primary transition-all opacity-0 group-hover/block:opacity-100 flex items-center gap-2 text-[10px] uppercase tracking-widest font-bold z-30"
|
| 853 |
-
title="Copiar bloque"
|
| 854 |
-
>
|
| 855 |
-
<Copy size={12} />
|
| 856 |
-
<span id={`copy-btn-block-${blockIdx}`}></span>
|
| 857 |
-
</button>
|
| 858 |
-
|
| 859 |
<TipTapEditor
|
| 860 |
content={block.content}
|
| 861 |
onUpdate={() => { }}
|
|
|
|
| 703 |
<hr className="border-white/10 mb-4" />
|
| 704 |
|
| 705 |
<div className="relative group/summary">
|
| 706 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 707 |
|
| 708 |
<TipTapEditor
|
| 709 |
content={item.summary || '<p>Resumen</p>'}
|
|
|
|
| 790 |
<div className="space-y-6 mb-8">
|
| 791 |
{item.blocks.map((block, blockIdx) => (
|
| 792 |
<div key={block.id} className={`${getCardClasses(item.cardStyle)} h-fit rounded-xl overflow-hidden p-6 transition-all duration-300 relative group/block`}>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 793 |
<TipTapEditor
|
| 794 |
content={block.content}
|
| 795 |
onUpdate={() => { }}
|
components/QuoteComponent.tsx
CHANGED
|
@@ -12,19 +12,20 @@ export const QuoteComponent: React.FC<NodeViewProps> = (props) => {
|
|
| 12 |
const [contentHeight, setContentHeight] = useState<number>(0);
|
| 13 |
|
| 14 |
useEffect(() => {
|
| 15 |
-
|
| 16 |
-
setContentHeight(contentRef.current.scrollHeight);
|
| 17 |
-
}
|
| 18 |
-
|
| 19 |
-
const handleResize = () => {
|
| 20 |
if (contentRef.current) {
|
|
|
|
|
|
|
| 21 |
setContentHeight(contentRef.current.scrollHeight);
|
|
|
|
| 22 |
}
|
| 23 |
};
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
| 28 |
|
| 29 |
const toggleExpand = () => {
|
| 30 |
setIsManualExpanded(!isManualExpanded);
|
|
@@ -71,13 +72,6 @@ export const QuoteComponent: React.FC<NodeViewProps> = (props) => {
|
|
| 71 |
lineHeight: '1.5', // Enforce consistent line height
|
| 72 |
};
|
| 73 |
|
| 74 |
-
const handleClick = (e: React.MouseEvent) => {
|
| 75 |
-
if (e.detail === 3 && props.editor.isEditable) {
|
| 76 |
-
e.preventDefault();
|
| 77 |
-
handleOpenSettings(e);
|
| 78 |
-
}
|
| 79 |
-
};
|
| 80 |
-
|
| 81 |
const handleOpenSettings = (e: React.MouseEvent) => {
|
| 82 |
e.preventDefault();
|
| 83 |
e.stopPropagation();
|
|
@@ -97,10 +91,19 @@ export const QuoteComponent: React.FC<NodeViewProps> = (props) => {
|
|
| 97 |
<NodeViewWrapper
|
| 98 |
style={dynamicStyles}
|
| 99 |
className="group my-4 rounded-sm transition-all [&_p]:m-0"
|
| 100 |
-
onClick={handleClick}
|
| 101 |
>
|
| 102 |
-
{(attrs.showCopyButton || attrs.showDownloadButton || isEditing) && (
|
| 103 |
<div className="absolute top-2 right-2 z-10 flex gap-2">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
{isEditing && (
|
| 105 |
<button
|
| 106 |
onClick={(e) => handleOpenSettings(e)}
|
|
@@ -155,23 +158,6 @@ export const QuoteComponent: React.FC<NodeViewProps> = (props) => {
|
|
| 155 |
<NodeViewContent />
|
| 156 |
</div>
|
| 157 |
|
| 158 |
-
{/* --- Botón de Leer Más (Solo Icono) --- */}
|
| 159 |
-
{attrs.collapsible && (
|
| 160 |
-
<div className="mt-1 flex justify-end">
|
| 161 |
-
<button
|
| 162 |
-
onClick={toggleExpand}
|
| 163 |
-
contentEditable={false} // ¡CRUCIAL PARA QUE FUNCIONE EL CLIC!
|
| 164 |
-
className="text-zinc-400 hover:text-white transition-colors cursor-pointer select-none p-1"
|
| 165 |
-
title={isManualExpanded ? "Contraer" : "Expandir"}
|
| 166 |
-
>
|
| 167 |
-
{isManualExpanded ? (
|
| 168 |
-
<ChevronUp size={16} />
|
| 169 |
-
) : (
|
| 170 |
-
<ChevronDown size={16} />
|
| 171 |
-
)}
|
| 172 |
-
</button>
|
| 173 |
-
</div>
|
| 174 |
-
)}
|
| 175 |
</NodeViewWrapper>
|
| 176 |
);
|
| 177 |
};
|
|
|
|
| 12 |
const [contentHeight, setContentHeight] = useState<number>(0);
|
| 13 |
|
| 14 |
useEffect(() => {
|
| 15 |
+
const measureHeight = () => {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
if (contentRef.current) {
|
| 17 |
+
const currentMaxHeight = contentRef.current.style.maxHeight;
|
| 18 |
+
contentRef.current.style.maxHeight = 'none';
|
| 19 |
setContentHeight(contentRef.current.scrollHeight);
|
| 20 |
+
contentRef.current.style.maxHeight = currentMaxHeight;
|
| 21 |
}
|
| 22 |
};
|
| 23 |
|
| 24 |
+
measureHeight();
|
| 25 |
+
|
| 26 |
+
window.addEventListener('resize', measureHeight);
|
| 27 |
+
return () => window.removeEventListener('resize', measureHeight);
|
| 28 |
+
}, [node.textContent, attrs.collapsible]);
|
| 29 |
|
| 30 |
const toggleExpand = () => {
|
| 31 |
setIsManualExpanded(!isManualExpanded);
|
|
|
|
| 72 |
lineHeight: '1.5', // Enforce consistent line height
|
| 73 |
};
|
| 74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
const handleOpenSettings = (e: React.MouseEvent) => {
|
| 76 |
e.preventDefault();
|
| 77 |
e.stopPropagation();
|
|
|
|
| 91 |
<NodeViewWrapper
|
| 92 |
style={dynamicStyles}
|
| 93 |
className="group my-4 rounded-sm transition-all [&_p]:m-0"
|
|
|
|
| 94 |
>
|
| 95 |
+
{(attrs.showCopyButton || attrs.showDownloadButton || isEditing || attrs.collapsible) && (
|
| 96 |
<div className="absolute top-2 right-2 z-10 flex gap-2">
|
| 97 |
+
{attrs.collapsible && (
|
| 98 |
+
<button
|
| 99 |
+
onClick={toggleExpand}
|
| 100 |
+
contentEditable={false}
|
| 101 |
+
className="p-1 bg-zinc-800/50 rounded text-zinc-300 hover:text-white transition-all backdrop-blur-sm"
|
| 102 |
+
title={isManualExpanded ? "Contraer" : "Expandir"}
|
| 103 |
+
>
|
| 104 |
+
{isManualExpanded ? <ChevronUp size={14} /> : <ChevronDown size={14} />}
|
| 105 |
+
</button>
|
| 106 |
+
)}
|
| 107 |
{isEditing && (
|
| 108 |
<button
|
| 109 |
onClick={(e) => handleOpenSettings(e)}
|
|
|
|
| 158 |
<NodeViewContent />
|
| 159 |
</div>
|
| 160 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
</NodeViewWrapper>
|
| 162 |
);
|
| 163 |
};
|