forked from lab/libre-marker
nueva versión , con el Canvas en particular y JS / CSS en general depurados para que no consuman tantos recursos de la gráfica ... #1
752
index.html
752
index.html
|
|
@ -3,31 +3,25 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Visor y Editor Markdown - Futurista</title>
|
<title>Visor Markdown - Versión Optimizada</title>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
||||||
<style>
|
<style>
|
||||||
* {
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
body {
|
||||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||||
background: #0a0e27;
|
/* Optimizamos el fondo: degradado fijo en CSS en lugar de Canvas */
|
||||||
|
background: radial-gradient(circle at center, #0a0e27 0%, #050810 100%);
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
position: relative;
|
color: #e2e8f0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fondo de estrellas animadas */
|
|
||||||
#stars-canvas {
|
#stars-canvas {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
z-index: 0;
|
z-index: 0;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
@ -35,450 +29,73 @@
|
||||||
.container {
|
.container {
|
||||||
max-width: 1400px;
|
max-width: 1400px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
background: rgba(15, 23, 42, 0.85);
|
background: rgba(15, 23, 42, 0.9);
|
||||||
border-radius: 20px;
|
border-radius: 20px;
|
||||||
box-shadow: 0 0 60px rgba(59, 130, 246, 0.3), 0 0 100px rgba(139, 92, 246, 0.2);
|
/* Reducimos el radio de las sombras para mejorar el rendimiento */
|
||||||
|
box-shadow: 0 0 30px rgba(59, 130, 246, 0.2);
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
backdrop-filter: blur(10px);
|
|
||||||
border: 1px solid rgba(59, 130, 246, 0.2);
|
border: 1px solid rgba(59, 130, 246, 0.2);
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Estilos de Header y Botones (Mantenemos tu estética) */
|
||||||
.header {
|
.header {
|
||||||
background: linear-gradient(135deg, #1e3a8a 0%, #7c3aed 50%, #db2777 100%);
|
background: linear-gradient(135deg, #1e3a8a 0%, #7c3aed 50%, #db2777 100%);
|
||||||
color: white;
|
|
||||||
padding: 40px 30px;
|
padding: 40px 30px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
position: relative;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.header::before {
|
|
||||||
content: '';
|
|
||||||
position: absolute;
|
|
||||||
top: -50%;
|
|
||||||
left: -50%;
|
|
||||||
width: 200%;
|
|
||||||
height: 200%;
|
|
||||||
background: radial-gradient(circle, rgba(255,255,255,0.1) 1px, transparent 1px);
|
|
||||||
background-size: 50px 50px;
|
|
||||||
animation: moveGrid 20s linear infinite;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes moveGrid {
|
|
||||||
0% { transform: translate(0, 0); }
|
|
||||||
100% { transform: translate(50px, 50px); }
|
|
||||||
}
|
|
||||||
|
|
||||||
.header h1 {
|
|
||||||
font-size: 2.8em;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
font-weight: 700;
|
|
||||||
position: relative;
|
|
||||||
z-index: 1;
|
|
||||||
text-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
|
|
||||||
}
|
|
||||||
|
|
||||||
.header p {
|
|
||||||
opacity: 0.95;
|
|
||||||
font-size: 1.2em;
|
|
||||||
position: relative;
|
|
||||||
z-index: 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.controls {
|
.controls {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
padding: 25px;
|
padding: 20px;
|
||||||
background: rgba(15, 23, 42, 0.95);
|
background: rgba(15, 23, 42, 0.95);
|
||||||
border-bottom: 2px solid rgba(59, 130, 246, 0.3);
|
border-bottom: 1px solid rgba(59, 130, 246, 0.2);
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
align-items: center;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn {
|
.btn {
|
||||||
padding: 12px 24px;
|
|
||||||
border: 2px solid transparent;
|
|
||||||
border-radius: 10px;
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 600;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
position: relative;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn::before {
|
|
||||||
content: '';
|
|
||||||
position: absolute;
|
|
||||||
top: 50%;
|
|
||||||
left: 50%;
|
|
||||||
width: 0;
|
|
||||||
height: 0;
|
|
||||||
border-radius: 50%;
|
|
||||||
background: rgba(255, 255, 255, 0.2);
|
|
||||||
transform: translate(-50%, -50%);
|
|
||||||
transition: width 0.6s, height 0.6s;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn:hover::before {
|
|
||||||
width: 300px;
|
|
||||||
height: 300px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn span {
|
|
||||||
position: relative;
|
|
||||||
z-index: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-primary {
|
|
||||||
background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
|
|
||||||
color: white;
|
|
||||||
box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-primary:hover {
|
|
||||||
transform: translateY(-3px);
|
|
||||||
box-shadow: 0 6px 25px rgba(59, 130, 246, 0.6);
|
|
||||||
border-color: rgba(59, 130, 246, 0.5);
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-secondary {
|
|
||||||
background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
|
|
||||||
color: white;
|
|
||||||
box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-secondary:hover {
|
|
||||||
transform: translateY(-3px);
|
|
||||||
box-shadow: 0 6px 25px rgba(99, 102, 241, 0.6);
|
|
||||||
border-color: rgba(99, 102, 241, 0.5);
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-success {
|
|
||||||
background: linear-gradient(135deg, #10b981 0%, #059669 100%);
|
|
||||||
color: white;
|
|
||||||
box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-success:hover {
|
|
||||||
transform: translateY(-3px);
|
|
||||||
box-shadow: 0 6px 25px rgba(16, 185, 129, 0.6);
|
|
||||||
border-color: rgba(16, 185, 129, 0.5);
|
|
||||||
}
|
|
||||||
|
|
||||||
.file-input-wrapper {
|
|
||||||
position: relative;
|
|
||||||
overflow: hidden;
|
|
||||||
display: inline-block;
|
|
||||||
}
|
|
||||||
|
|
||||||
.file-input-wrapper input[type=file] {
|
|
||||||
position: absolute;
|
|
||||||
left: -9999px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mode-toggle {
|
|
||||||
margin-left: auto;
|
|
||||||
display: flex;
|
|
||||||
gap: 8px;
|
|
||||||
background: rgba(30, 41, 59, 0.8);
|
|
||||||
padding: 6px;
|
|
||||||
border-radius: 12px;
|
|
||||||
border: 1px solid rgba(59, 130, 246, 0.3);
|
|
||||||
}
|
|
||||||
|
|
||||||
.mode-btn {
|
|
||||||
padding: 10px 20px;
|
padding: 10px 20px;
|
||||||
border: none;
|
|
||||||
background: transparent;
|
|
||||||
cursor: pointer;
|
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
|
border: none;
|
||||||
|
cursor: pointer;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
transition: all 0.3s ease;
|
transition: transform 0.2s;
|
||||||
color: #94a3b8;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mode-btn.active {
|
.btn-primary { background: #3b82f6; }
|
||||||
background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
|
.btn-secondary { background: #6366f1; }
|
||||||
color: white;
|
.btn-success { background: #10b981; }
|
||||||
box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
|
.btn:hover { transform: translateY(-2px); }
|
||||||
}
|
|
||||||
|
|
||||||
.workspace {
|
.workspace {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr 1fr;
|
grid-template-columns: 1fr 1fr;
|
||||||
gap: 0;
|
|
||||||
min-height: 600px;
|
min-height: 600px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.workspace.preview-only {
|
.workspace.preview-only { grid-template-columns: 1fr; }
|
||||||
grid-template-columns: 1fr;
|
|
||||||
}
|
|
||||||
|
|
||||||
.editor-panel, .preview-panel {
|
.editor-panel, .preview-panel { padding: 30px; overflow-y: auto; max-height: 750px; }
|
||||||
padding: 30px;
|
.editor-panel { border-right: 1px solid rgba(59, 130, 246, 0.2); }
|
||||||
overflow-y: auto;
|
|
||||||
max-height: 700px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.editor-panel {
|
|
||||||
background: rgba(15, 23, 42, 0.95);
|
|
||||||
border-right: 2px solid rgba(59, 130, 246, 0.3);
|
|
||||||
}
|
|
||||||
|
|
||||||
.workspace.preview-only .editor-panel {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.editor-panel h3, .preview-panel h3 {
|
|
||||||
margin-bottom: 20px;
|
|
||||||
color: #60a5fa;
|
|
||||||
font-size: 1.3em;
|
|
||||||
text-shadow: 0 0 10px rgba(96, 165, 250, 0.5);
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.editor-panel h3::before {
|
|
||||||
content: '⚡';
|
|
||||||
font-size: 1.2em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.preview-panel h3::before {
|
|
||||||
content: '👁️';
|
|
||||||
font-size: 1.2em;
|
|
||||||
}
|
|
||||||
|
|
||||||
textarea {
|
textarea {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
min-height: 550px;
|
min-height: 550px;
|
||||||
padding: 20px;
|
padding: 15px;
|
||||||
border: 2px solid rgba(59, 130, 246, 0.3);
|
|
||||||
border-radius: 12px;
|
|
||||||
font-family: 'Courier New', monospace;
|
|
||||||
font-size: 14px;
|
|
||||||
line-height: 1.8;
|
|
||||||
resize: vertical;
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
background: rgba(30, 41, 59, 0.8);
|
|
||||||
color: #e2e8f0;
|
|
||||||
}
|
|
||||||
|
|
||||||
textarea:focus {
|
|
||||||
outline: none;
|
|
||||||
border-color: #3b82f6;
|
|
||||||
box-shadow: 0 0 20px rgba(59, 130, 246, 0.4);
|
|
||||||
}
|
|
||||||
|
|
||||||
textarea::placeholder {
|
|
||||||
color: #64748b;
|
|
||||||
}
|
|
||||||
|
|
||||||
.preview-panel {
|
|
||||||
background: rgba(15, 23, 42, 0.95);
|
|
||||||
}
|
|
||||||
|
|
||||||
#content {
|
|
||||||
line-height: 1.8;
|
|
||||||
color: #e2e8f0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#content h1, #content h2, #content h3, #content h4, #content h5, #content h6 {
|
|
||||||
margin-top: 24px;
|
|
||||||
margin-bottom: 16px;
|
|
||||||
font-weight: 600;
|
|
||||||
line-height: 1.25;
|
|
||||||
color: #60a5fa;
|
|
||||||
text-shadow: 0 0 10px rgba(96, 165, 250, 0.3);
|
|
||||||
}
|
|
||||||
|
|
||||||
#content h1 {
|
|
||||||
font-size: 2.2em;
|
|
||||||
border-bottom: 2px solid rgba(59, 130, 246, 0.4);
|
|
||||||
padding-bottom: 12px;
|
|
||||||
background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 100%);
|
|
||||||
-webkit-background-clip: text;
|
|
||||||
-webkit-text-fill-color: transparent;
|
|
||||||
background-clip: text;
|
|
||||||
}
|
|
||||||
|
|
||||||
#content h2 {
|
|
||||||
font-size: 1.7em;
|
|
||||||
border-bottom: 1px solid rgba(59, 130, 246, 0.3);
|
|
||||||
padding-bottom: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#content h3 { font-size: 1.4em; }
|
|
||||||
#content h4 { font-size: 1.1em; }
|
|
||||||
|
|
||||||
#content p {
|
|
||||||
margin-bottom: 16px;
|
|
||||||
color: #cbd5e1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#content a {
|
|
||||||
color: #60a5fa;
|
|
||||||
text-decoration: none;
|
|
||||||
font-weight: 500;
|
|
||||||
position: relative;
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
#content a:hover {
|
|
||||||
color: #93c5fd;
|
|
||||||
text-shadow: 0 0 10px rgba(96, 165, 250, 0.6);
|
|
||||||
}
|
|
||||||
|
|
||||||
#content img {
|
|
||||||
max-width: 100%;
|
|
||||||
border-radius: 12px;
|
|
||||||
margin: 20px 0;
|
|
||||||
box-shadow: 0 8px 30px rgba(59, 130, 246, 0.3);
|
|
||||||
border: 1px solid rgba(59, 130, 246, 0.3);
|
|
||||||
}
|
|
||||||
|
|
||||||
#content pre {
|
|
||||||
background: rgba(15, 23, 42, 0.95);
|
|
||||||
color: #e2e8f0;
|
|
||||||
padding: 20px;
|
|
||||||
border-radius: 12px;
|
|
||||||
overflow-x: auto;
|
|
||||||
margin: 20px 0;
|
|
||||||
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
|
|
||||||
border: 1px solid rgba(59, 130, 246, 0.3);
|
|
||||||
}
|
|
||||||
|
|
||||||
#content code {
|
|
||||||
background: rgba(30, 41, 59, 0.8);
|
|
||||||
padding: 3px 8px;
|
|
||||||
border-radius: 6px;
|
|
||||||
font-family: 'Courier New', monospace;
|
|
||||||
font-size: 0.9em;
|
|
||||||
color: #fbbf24;
|
|
||||||
border: 1px solid rgba(251, 191, 36, 0.3);
|
|
||||||
}
|
|
||||||
|
|
||||||
#content pre code {
|
|
||||||
background: transparent;
|
|
||||||
padding: 0;
|
|
||||||
color: #a5f3fc;
|
|
||||||
border: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
#content blockquote {
|
|
||||||
border-left: 4px solid #3b82f6;
|
|
||||||
padding-left: 20px;
|
|
||||||
margin: 20px 0;
|
|
||||||
color: #94a3b8;
|
|
||||||
font-style: italic;
|
|
||||||
background: rgba(59, 130, 246, 0.1);
|
|
||||||
padding: 15px 20px;
|
|
||||||
border-radius: 0 8px 8px 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#content ul, #content ol {
|
|
||||||
margin: 16px 0;
|
|
||||||
padding-left: 30px;
|
|
||||||
color: #cbd5e1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#content li {
|
|
||||||
margin: 10px 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#content table {
|
|
||||||
border-collapse: collapse;
|
|
||||||
width: 100%;
|
|
||||||
margin: 20px 0;
|
|
||||||
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
|
|
||||||
border-radius: 12px;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
#content table th, #content table td {
|
|
||||||
border: 1px solid rgba(59, 130, 246, 0.3);
|
|
||||||
padding: 14px;
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
#content table th {
|
|
||||||
background: rgba(59, 130, 246, 0.2);
|
|
||||||
font-weight: 600;
|
|
||||||
color: #60a5fa;
|
|
||||||
}
|
|
||||||
|
|
||||||
#content table td {
|
|
||||||
background: rgba(30, 41, 59, 0.5);
|
background: rgba(30, 41, 59, 0.5);
|
||||||
color: #cbd5e1;
|
color: #fff;
|
||||||
|
border: 1px solid rgba(59, 130, 246, 0.3);
|
||||||
|
border-radius: 8px;
|
||||||
|
font-family: 'Courier New', monospace;
|
||||||
|
resize: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
#content table tr:hover td {
|
/* Markdown Preview Styles */
|
||||||
background: rgba(59, 130, 246, 0.15);
|
#content h1 { color: #60a5fa; border-bottom: 1px solid #3b82f6; padding-bottom: 10px; margin-bottom: 20px; }
|
||||||
}
|
#content code { background: #1e293b; color: #fbbf24; padding: 2px 6px; border-radius: 4px; }
|
||||||
|
|
||||||
#content hr {
|
|
||||||
border: none;
|
|
||||||
border-top: 2px solid rgba(59, 130, 246, 0.3);
|
|
||||||
margin: 30px 0;
|
|
||||||
box-shadow: 0 1px 10px rgba(59, 130, 246, 0.3);
|
|
||||||
}
|
|
||||||
|
|
||||||
.placeholder {
|
|
||||||
color: #64748b;
|
|
||||||
font-style: italic;
|
|
||||||
text-align: center;
|
|
||||||
padding: 80px 20px;
|
|
||||||
font-size: 1.1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Scrollbar personalizado */
|
|
||||||
::-webkit-scrollbar {
|
|
||||||
width: 10px;
|
|
||||||
height: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
::-webkit-scrollbar-track {
|
|
||||||
background: rgba(15, 23, 42, 0.5);
|
|
||||||
}
|
|
||||||
|
|
||||||
::-webkit-scrollbar-thumb {
|
|
||||||
background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
|
|
||||||
border-radius: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
::-webkit-scrollbar-thumb:hover {
|
|
||||||
background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 100%);
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
|
||||||
.workspace {
|
|
||||||
grid-template-columns: 1fr;
|
|
||||||
}
|
|
||||||
|
|
||||||
.editor-panel {
|
|
||||||
border-right: none;
|
|
||||||
border-bottom: 2px solid rgba(59, 130, 246, 0.3);
|
|
||||||
}
|
|
||||||
|
|
||||||
.controls {
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mode-toggle {
|
|
||||||
margin-left: 0;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.header h1 {
|
|
||||||
font-size: 2em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
@ -486,262 +103,109 @@
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<h1>🚀 Visor y Editor Markdown</h1>
|
<h1>🚀 Visor Markdown Pro</h1>
|
||||||
<p>Editor futurista con vista previa en tiempo real</p>
|
<p>Optimizado para alto rendimiento</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<div class="file-input-wrapper">
|
<input type="file" id="file-upload" hidden>
|
||||||
<label for="file-upload" class="btn btn-primary">
|
<button onclick="document.getElementById('file-upload').click()" class="btn btn-primary">📁 Cargar</button>
|
||||||
<span>📁 Cargar archivo .md</span>
|
<button id="clear-btn" class="btn btn-secondary">🗑️ Limpiar</button>
|
||||||
</label>
|
<button id="download-btn" class="btn btn-success">💾 Descargar</button>
|
||||||
<input type="file" id="file-upload" accept=".md,.markdown,.txt">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button id="clear-btn" class="btn btn-secondary">
|
|
||||||
<span>🗑️ Limpiar</span>
|
|
||||||
</button>
|
|
||||||
<button id="download-btn" class="btn btn-success">
|
|
||||||
<span>💾 Descargar .md</span>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<div class="mode-toggle">
|
|
||||||
<button class="mode-btn active" data-mode="split">✂️ Dividido</button>
|
|
||||||
<button class="mode-btn" data-mode="preview">👁️ Vista previa</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="workspace" id="workspace">
|
<div class="workspace" id="workspace">
|
||||||
<div class="editor-panel">
|
<div class="editor-panel">
|
||||||
<h3>Editor Markdown</h3>
|
<textarea id="markdown-input" placeholder="# Empieza a escribir..."></textarea>
|
||||||
<textarea id="markdown-input" placeholder="# Escribe tu Markdown aquí...
|
|
||||||
|
|
||||||
## Ejemplo de uso
|
|
||||||
|
|
||||||
Puedes usar **negrita**, *cursiva*, y más.
|
|
||||||
|
|
||||||
### Lista de características:
|
|
||||||
- Editor en tiempo real
|
|
||||||
- Vista previa instantánea
|
|
||||||
- Descarga como archivo .md
|
|
||||||
- Diseño futurista oscuro
|
|
||||||
- Fondo con partículas de estrellas
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
console.log('¡Hola Mundo!');
|
|
||||||
```
|
|
||||||
|
|
||||||
> Esto es una cita inspiradora
|
|
||||||
|
|
||||||
[Enlace de ejemplo](https://example.com)
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
| Característica | Estado |
|
|
||||||
|---------------|---------|
|
|
||||||
| Editor | ✅ Activo |
|
|
||||||
| Preview | ✅ Activo |
|
|
||||||
| Descarga | ✅ Activo |"></textarea>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="preview-panel">
|
<div class="preview-panel">
|
||||||
<h3>Vista Previa</h3>
|
<div id="content"></div>
|
||||||
<div id="content" class="placeholder">
|
|
||||||
<p>✨ Carga un archivo .md o escribe en el editor para ver la vista previa aquí ✨</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// Configuración de partículas de estrellas
|
// --- OPTIMIZACIÓN DE CANVAS (Estrellas) ---
|
||||||
const canvas = document.getElementById('stars-canvas');
|
const canvas = document.getElementById('stars-canvas');
|
||||||
const ctx = canvas.getContext('2d');
|
const ctx = canvas.getContext('2d');
|
||||||
|
const offscreenCanvas = document.createElement('canvas');
|
||||||
|
const offCtx = offscreenCanvas.getContext('2d');
|
||||||
|
|
||||||
canvas.width = window.innerWidth;
|
canvas.width = window.innerWidth;
|
||||||
canvas.height = window.innerHeight;
|
canvas.height = window.innerHeight;
|
||||||
|
|
||||||
let stars = [];
|
// Pre-renderizamos una estrella una sola vez
|
||||||
const numStars = 200;
|
offscreenCanvas.width = 10;
|
||||||
|
offscreenCanvas.height = 10;
|
||||||
|
const grad = offCtx.createRadialGradient(5, 5, 0, 5, 5, 5);
|
||||||
|
grad.addColorStop(0, 'rgba(139, 92, 246, 1)');
|
||||||
|
grad.addColorStop(1, 'rgba(139, 92, 246, 0)');
|
||||||
|
offCtx.fillStyle = grad;
|
||||||
|
offCtx.fillRect(0, 0, 10, 10);
|
||||||
|
|
||||||
class Star {
|
let stars = [];
|
||||||
constructor() {
|
for (let i = 0; i < 150; i++) {
|
||||||
this.x = Math.random() * canvas.width;
|
stars.push({
|
||||||
this.y = Math.random() * canvas.height;
|
x: Math.random() * canvas.width,
|
||||||
this.size = Math.random() * 2;
|
y: Math.random() * canvas.height,
|
||||||
this.speedX = (Math.random() - 0.5) * 0.5;
|
s: Math.random() * 0.5 + 0.2,
|
||||||
this.speedY = (Math.random() - 0.5) * 0.5;
|
vx: (Math.random() - 0.5) * 0.3,
|
||||||
this.opacity = Math.random();
|
vy: (Math.random() - 0.5) * 0.3
|
||||||
this.fadeSpeed = (Math.random() - 0.5) * 0.02;
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
update() {
|
function animate() {
|
||||||
this.x += this.speedX;
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||||
this.y += this.speedY;
|
stars.forEach(s => {
|
||||||
this.opacity += this.fadeSpeed;
|
s.x = (s.x + s.vx + canvas.width) % canvas.width;
|
||||||
|
s.y = (s.y + s.vy + canvas.height) % canvas.height;
|
||||||
|
// Usamos drawImage en lugar de crear gradientes cada vez
|
||||||
|
ctx.drawImage(offscreenCanvas, s.x, s.y, 10 * s.s, 10 * s.s);
|
||||||
|
});
|
||||||
|
requestAnimationFrame(animate);
|
||||||
|
}
|
||||||
|
animate();
|
||||||
|
|
||||||
if (this.opacity <= 0 || this.opacity >= 1) {
|
// --- OPTIMIZACIÓN DE EDITOR (Debounce) ---
|
||||||
this.fadeSpeed *= -1;
|
const input = document.getElementById('markdown-input');
|
||||||
}
|
const content = document.getElementById('content');
|
||||||
|
|
||||||
if (this.x < 0) this.x = canvas.width;
|
function debounce(func, wait) {
|
||||||
if (this.x > canvas.width) this.x = 0;
|
let timeout;
|
||||||
if (this.y < 0) this.y = canvas.height;
|
return (...args) => {
|
||||||
if (this.y > canvas.height) this.y = 0;
|
clearTimeout(timeout);
|
||||||
}
|
timeout = setTimeout(() => func.apply(this, args), wait);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
draw() {
|
const updatePreview = debounce(() => {
|
||||||
ctx.fillStyle = `rgba(96, 165, 250, ${this.opacity})`;
|
content.innerHTML = marked.parse(input.value || '*Vista previa vacía*');
|
||||||
ctx.beginPath();
|
}, 300); // 300ms de espera
|
||||||
ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
|
|
||||||
ctx.fill();
|
|
||||||
|
|
||||||
// Efecto de brillo
|
input.addEventListener('input', updatePreview);
|
||||||
const gradient = ctx.createRadialGradient(this.x, this.y, 0, this.x, this.y, this.size * 3);
|
|
||||||
gradient.addColorStop(0, `rgba(139, 92, 246, ${this.opacity * 0.5})`);
|
|
||||||
gradient.addColorStop(1, 'rgba(139, 92, 246, 0)');
|
|
||||||
ctx.fillStyle = gradient;
|
|
||||||
ctx.fill();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function initStars() {
|
// Funciones básicas de botones
|
||||||
stars = [];
|
document.getElementById('clear-btn').onclick = () => {
|
||||||
for (let i = 0; i < numStars; i++) {
|
if(confirm('¿Limpiar?')) { input.value = ''; updatePreview(); }
|
||||||
stars.push(new Star());
|
};
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function animateStars() {
|
document.getElementById('download-btn').onclick = () => {
|
||||||
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
const blob = new Blob([input.value], {type: 'text/markdown'});
|
||||||
|
const a = document.createElement('a');
|
||||||
|
a.href = URL.createObjectURL(blob);
|
||||||
|
a.download = 'nota.md';
|
||||||
|
a.click();
|
||||||
|
};
|
||||||
|
|
||||||
// Fondo con gradiente
|
// Cargar archivo
|
||||||
const gradient = ctx.createRadialGradient(canvas.width / 2, canvas.height / 2, 0, canvas.width / 2, canvas.height / 2, canvas.width);
|
document.getElementById('file-upload').onchange = (e) => {
|
||||||
gradient.addColorStop(0, '#0a0e27');
|
const reader = new FileReader();
|
||||||
gradient.addColorStop(1, '#050810');
|
reader.onload = (ev) => { input.value = ev.target.result; updatePreview(); };
|
||||||
ctx.fillStyle = gradient;
|
reader.readAsText(e.target.files[0]);
|
||||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
};
|
||||||
|
|
||||||
stars.forEach(star => {
|
// Carga inicial
|
||||||
star.update();
|
updatePreview();
|
||||||
star.draw();
|
|
||||||
});
|
|
||||||
|
|
||||||
requestAnimationFrame(animateStars);
|
|
||||||
}
|
|
||||||
|
|
||||||
window.addEventListener('resize', () => {
|
|
||||||
canvas.width = window.innerWidth;
|
|
||||||
canvas.height = window.innerHeight;
|
|
||||||
initStars();
|
|
||||||
});
|
|
||||||
|
|
||||||
initStars();
|
|
||||||
animateStars();
|
|
||||||
|
|
||||||
// Funcionalidad del editor
|
|
||||||
const markdownInput = document.getElementById('markdown-input');
|
|
||||||
const contentDiv = document.getElementById('content');
|
|
||||||
const fileUpload = document.getElementById('file-upload');
|
|
||||||
const clearBtn = document.getElementById('clear-btn');
|
|
||||||
const downloadBtn = document.getElementById('download-btn');
|
|
||||||
const workspace = document.getElementById('workspace');
|
|
||||||
const modeBtns = document.querySelectorAll('.mode-btn');
|
|
||||||
|
|
||||||
// Configurar marked
|
|
||||||
marked.setOptions({
|
|
||||||
breaks: true,
|
|
||||||
gfm: true
|
|
||||||
});
|
|
||||||
|
|
||||||
// Actualizar vista previa en tiempo real
|
|
||||||
function updatePreview() {
|
|
||||||
const markdown = markdownInput.value;
|
|
||||||
if (markdown.trim() === '') {
|
|
||||||
contentDiv.innerHTML = '<p class="placeholder">✨ Carga un archivo .md o escribe en el editor para ver la vista previa aquí ✨</p>';
|
|
||||||
} else {
|
|
||||||
contentDiv.innerHTML = marked.parse(markdown);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
markdownInput.addEventListener('input', updatePreview);
|
|
||||||
|
|
||||||
// Cargar archivo
|
|
||||||
fileUpload.addEventListener('change', function(e) {
|
|
||||||
const file = e.target.files[0];
|
|
||||||
if (file) {
|
|
||||||
const reader = new FileReader();
|
|
||||||
reader.onload = function(e) {
|
|
||||||
markdownInput.value = e.target.result;
|
|
||||||
updatePreview();
|
|
||||||
};
|
|
||||||
reader.readAsText(file);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Limpiar editor
|
|
||||||
clearBtn.addEventListener('click', function() {
|
|
||||||
if (confirm('¿Estás seguro de que quieres limpiar el contenido?')) {
|
|
||||||
markdownInput.value = '';
|
|
||||||
updatePreview();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Descargar como archivo .md
|
|
||||||
downloadBtn.addEventListener('click', function() {
|
|
||||||
const markdownContent = markdownInput.value;
|
|
||||||
|
|
||||||
if (markdownContent.trim() === '') {
|
|
||||||
alert('No hay contenido para descargar. Escribe algo primero.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const blob = new Blob([markdownContent], { type: 'text/markdown' });
|
|
||||||
const url = URL.createObjectURL(blob);
|
|
||||||
const a = document.createElement('a');
|
|
||||||
a.href = url;
|
|
||||||
a.download = 'documento.md';
|
|
||||||
document.body.appendChild(a);
|
|
||||||
a.click();
|
|
||||||
document.body.removeChild(a);
|
|
||||||
URL.revokeObjectURL(url);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Cambiar modo de visualización
|
|
||||||
modeBtns.forEach(btn => {
|
|
||||||
btn.addEventListener('click', function() {
|
|
||||||
modeBtns.forEach(b => b.classList.remove('active'));
|
|
||||||
this.classList.add('active');
|
|
||||||
|
|
||||||
const mode = this.dataset.mode;
|
|
||||||
if (mode === 'preview') {
|
|
||||||
workspace.classList.add('preview-only');
|
|
||||||
} else {
|
|
||||||
workspace.classList.remove('preview-only');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Compatibilidad con URL (versión anterior)
|
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
|
||||||
const file = urlParams.get('file');
|
|
||||||
if (file) {
|
|
||||||
fetch(file)
|
|
||||||
.then(response => {
|
|
||||||
if (!response.ok) throw new Error("No se encontró el archivo.");
|
|
||||||
return response.text();
|
|
||||||
})
|
|
||||||
.then(text => {
|
|
||||||
markdownInput.value = text;
|
|
||||||
updatePreview();
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
contentDiv.innerHTML = `<p style="color: #ef4444;">❌ Error: ${err.message}</p>`;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Inicializar
|
|
||||||
updatePreview();
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Loading…
Reference in New Issue