chore: added copy button to note view 87210aa2
Steve · 2026-04-03 19:41 1 file(s) · +12 −0
apps/jotts/templates/view.html +12 −0
7 7
  </div>
8 8
  <div class="note-actions">
9 9
    <a href="/notes/{{ note.short_id }}/edit">edit</a>
10 +
    <button type="button" class="link-button" id="copy-md-btn" onclick="copyMarkdown()">copy</button>
10 11
    <form method="POST" action="/notes/{{ note.short_id }}/delete" class="inline-form">
11 12
      <button type="submit" class="link-button" onclick="return confirm('delete this note?')">delete</button>
12 13
    </form>
13 14
  </div>
15 +
  <template id="raw-md">{{ note.content }}</template>
14 16
  <article class="markdown-body">
15 17
    {{ rendered_content|safe }}
16 18
  </article>
19 +
  <script>
20 +
    function copyMarkdown() {
21 +
      const md = document.getElementById("raw-md").content.textContent;
22 +
      const btn = document.getElementById("copy-md-btn");
23 +
      navigator.clipboard.writeText(md).then(() => {
24 +
        btn.textContent = "copied!";
25 +
        setTimeout(() => { btn.textContent = "copy"; }, 1500);
26 +
      });
27 +
    }
28 +
  </script>
17 29
{% endblock %}