Skip to content

v1.16.1 – Bug Fix: Copy button on code blocks no longer adds a trailing newline

Choose a tag to compare

@BobWs BobWs released this 19 Sep 10:02
· 2 commits to main since this release

Bug Fix

The copy button on code blocks was adding a trailing newline to the copied content. When pasting commands into a terminal, this caused them to execute immediately (the newline acts as an Enter keypress), which could be unintended and even dangerous.

What was happening:

  • Toast UI's syntax highlighter always appends a \n to the last line inside <code>
  • The copy function extracted this newline along with the code
  • Pasting into a terminal triggered execution instead of allowing review

What changed:

  • Added .trimEnd() to the extracted code before copying
  • Only trailing whitespace is stripped – leading indentation is preserved
  • Copied code is now clean and safe to paste

Why this matters:

  • Commands no longer auto-execute on paste
  • Code snippets paste cleanly into editors
  • Safe for documentation and tutorials where users copy-paste commands

Technical note: This was a one-line fix in ToastViewer.vue – the processCopyButtons() function now uses .trimEnd() on the extracted text.


Installation

docker pull dockerbobw/flatnotes-enhanced:latest
docker pull dockerbobw/flatnotes-enhanced:v1.16.1

Docker Compose

image: dockerbobw/flatnotes-enhanced:latest
# or pin to this version:
# image: dockerbobw/flatnotes-enhanced:v1.16.1

🔗 Links


🙏 Thank You

Thanks to @Limerick-gh who reported this issue #52 – pasting code is now clean and predictable.

Copy code safely! 📋