design.tmpl 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. {{showFile "templates/design/sections/head.tmpl"}}
  2. <body class="bg-zinc-950 text-zinc-200 h-screen overflow-hidden flex">
  3. {{showFile "templates/design/sections/nav_small.tmpl"}}
  4. {{showFile "templates/design/sections/nav_big.tmpl"}}
  5. <main class="flex-1 flex flex-col relative bg-zinc-900/20 overflow-auto">
  6. {{showFile "templates/design/sections/nav_header.tmpl"}}
  7. <div class="flex-1 flex">
  8. <section class="flex-1 overflow-y-auto custom-scrollbar p-12">
  9. <div class="w-full grid grid-cols-2 gap-0 border border-zinc-700">
  10. <div class="h-[85vh] bg-[#446454]">
  11. <textarea
  12. id="editor"
  13. placeholder="Start typing..."
  14. class="p-6 w-full h-full bg-transparent text-zinc-100 text-[14px] focus:outline-none resize-none custom-scrollbar"
  15. ></textarea>
  16. </div>
  17. <div id="preview" class="border-r border-zinc-700 h-[85vh] bg-[#454644] p-2 text-zinc-100 overflow-y-auto font-sans prose prose-invert prose-zinc max-w-none
  18. /* --- Code Blocks (Pre) --- */
  19. [&_pre]:bg-zinc-900/80 [&_pre]:p-4 [&_pre]:rounded-lg [&_pre]:border [&_pre]:border-zinc-700
  20. [&_pre]:my-6 [&_pre]:overflow-x-auto [&_pre]:shadow-inner
  21. /* --- Inline Code (<code>) --- */
  22. [&_code]:font-mono [&_code]:text-indigo-300 [&_code]:bg-zinc-800/50
  23. [&_code]:px-1.5 [&_code]:py-0.5 [&_code]:rounded [&_code]:text-[0.9em]
  24. /* Evităm background-ul dublu când codul este în interiorul unui <pre> */
  25. [&_pre_code]:bg-transparent [&_pre_code]:p-0 [&_pre_code]:text-zinc-200 [&_pre_code]:text-[0.85em]
  26. /* --- Stiluri Blockquote --- */
  27. [&_blockquote]:border-l-4 [&_blockquote]:border-indigo-500 [&_blockquote]:bg-zinc-800/30
  28. [&_blockquote]:py-2 [&_blockquote]:px-5 [&_blockquote]:my-4 [&_blockquote]:italic [&_blockquote]:text-zinc-300
  29. /* --- Stiluri Bold & Italic --- */
  30. [&_strong]:text-white [&_strong]:font-bold
  31. [&_em]:text-indigo-200 [&_em]:italic
  32. /* --- Stiluri pentru Tabele --- */
  33. [&_table]:w-full [&_table]:my-6 [&_table]:border-collapse [&_table]:border [&_table]:border-zinc-600
  34. [&_thead]:bg-zinc-800/50
  35. [&_th]:border [&_th]:border-zinc-600 [&_th]:p-3 [&_th]:text-left [&_th]:text-indigo-300 [&_th]:uppercase [&_th]:text-[11px]
  36. [&_td]:border [&_td]:border-zinc-600 [&_td]:p-3 [&_td]:text-sm
  37. [&_tr:nth-child(even)]:bg-zinc-700/30
  38. /* --- Stiluri pentru Liste & Headings --- */
  39. [&_ul]:list-disc [&_ul]:ml-6 [&_ol]:list-decimal [&_ol]:ml-6
  40. [&_h1]:text-3xl [&_h1]:font-bold [&_h1]:border-b [&_h1]:border-zinc-600 [&_h1]:pb-2 [&_h1]:mb-4
  41. [&_h2]:text-xl [&_h2]:font-semibold [&_h2]:text-indigo-400 [&_h2]:mt-6 custom-scrollbar">
  42. Your preview will appear here...
  43. </div>
  44. </div>
  45. </section>
  46. </div>
  47. </main>
  48. <script>
  49. const editor = document.getElementById('editor');
  50. const preview = document.getElementById('preview');
  51. // Debounce helper
  52. function debounce(func, delay) {
  53. let timeout;
  54. return function(...args) {
  55. clearTimeout(timeout);
  56. timeout = setTimeout(() => func.apply(this, args), delay);
  57. };
  58. }
  59. // The API Call
  60. const updatePreview = async () => {
  61. const content = editor.value;
  62. try {
  63. const response = await fetch('/live_preview/', {
  64. method: 'POST',
  65. headers: { 'Content-Type': 'application/json' },
  66. body: JSON.stringify({ markdown: content })
  67. });
  68. if (response.ok) {
  69. const htmlResult = await response.text();
  70. preview.innerHTML = htmlResult;
  71. // 1. Aplică etichetele de limbaj (codul de mai devreme)
  72. preview.querySelectorAll('pre code').forEach((codeBlock) => {
  73. const pre = codeBlock.parentElement;
  74. const langClass = Array.from(codeBlock.classList).find(c => c.startsWith('language-'));
  75. if (langClass) {
  76. pre.setAttribute('data-language', langClass.replace('language-', ''));
  77. }
  78. // 2. Declanșează evidențierea sintaxei
  79. hljs.highlightElement(codeBlock);
  80. });
  81. console.log("Remote Preview & Highlighting Updated!");
  82. }
  83. } catch (error) {
  84. console.error("Error:", error);
  85. }
  86. };
  87. // Listen for input, trigger every 500ms of "pause"
  88. editor.addEventListener('input', debounce(updatePreview, 500));
  89. </script>
  90. </body>
  91. </html>