Lauri Ojansivu
27201f642f
Copy code block: reliable per-viewer button, copies raw text, translated ( #5149 ).
...
The copy-code-block feature existed but the reporter saw it 'work very sporadically (only a handful of items have it)' and lost after editing. Root causes: it ran ONCE in Template.editor.onRendered with a global document.querySelectorAll('.viewer > pre'), so it decorated only whichever viewers were on the page at that instant and never re-added the button after an edit re-rendered the viewer; and it copied the HTML-escaped innerHTML of the <pre>'s first child node (often the wrong content or undefined) via the deprecated execCommand. Now the decoration lives in Template.viewer.onRendered, so EVERY viewer (card description, checklist item, comment) gets a copy button and it is restored on every re-render; it is de-duplicated (skips a <pre> that already has its button) so re-renders never stack buttons; it copies the RAW code text (pre.textContent) via navigator.clipboard.writeText with an execCommand fallback; and the button title is translated (the existing 'copy-text-to-clipboard' i18n key) instead of a hard-coded English string.
Tests: tests/copyCodeBlock.test.cjs (5 checks) guards that the decoration is in Template.viewer.onRendered scoped to the viewer's <pre>, copies textContent (not innerHTML), de-dups, is translated, and uses the async Clipboard API with a fallback.
Thanks to C0rn3j and xet7 !
Fixes #5149 ,
2026-07-22 13:27:50 +03:00
..
2026-06-18 04:14:59 +03:00
2026-07-21 22:57:31 +03:00
2026-06-23 16:50:24 +03:00
2026-07-18 01:49:40 +03:00
2026-07-22 12:15:56 +03:00
2026-07-18 18:55:19 +03:00
2026-07-20 03:11:07 +03:00
2026-07-17 03:27:33 +03:00
2026-05-27 20:51:44 +03:00
2026-07-17 03:34:23 +03:00
2026-07-17 03:21:02 +03:00
2026-07-17 03:34:23 +03:00
2026-07-16 17:40:24 +03:00
2026-07-17 03:07:59 +03:00
2026-07-17 01:43:53 +03:00
2026-07-05 23:22:16 +03:00
2026-07-13 09:16:33 +03:00
2026-07-11 01:53:07 +03:00
2026-07-11 00:14:49 +03:00
2026-07-11 00:14:49 +03:00
2026-07-17 03:41:20 +03:00
2026-07-09 09:45:53 +03:00
2026-07-09 09:45:53 +03:00
2026-07-17 03:07:59 +03:00
2026-07-21 19:43:48 +03:00
2026-07-17 03:34:23 +03:00
2026-07-08 23:57:39 +03:00
2026-07-17 03:07:59 +03:00
2026-07-20 03:11:06 +03:00
2026-07-09 02:14:07 +03:00
2026-06-23 08:50:29 +03:00
2026-07-16 17:40:24 +03:00
2026-07-17 03:34:23 +03:00
2026-07-17 18:04:36 +03:00
2026-07-22 13:22:15 +03:00
2026-07-05 23:12:16 +03:00
2026-06-13 17:19:51 +03:00
2026-07-06 11:19:15 +03:00
2026-07-20 13:17:28 +03:00
2026-07-05 22:23:36 +03:00
2026-07-18 02:05:00 +03:00
2026-07-06 13:49:44 +03:00
2026-07-17 03:07:59 +03:00
2026-07-09 09:45:53 +03:00
2026-07-17 03:21:02 +03:00
2026-07-16 17:40:24 +03:00
2026-07-09 02:14:07 +03:00
2026-07-22 13:27:50 +03:00
2026-07-16 17:40:24 +03:00
2026-07-16 18:54:28 +03:00
2026-07-20 03:11:07 +03:00
2026-07-20 04:34:38 +03:00
2026-07-17 23:01:52 +03:00
2026-07-17 03:21:02 +03:00
2026-07-17 03:34:52 +03:00
2026-06-23 16:47:00 +03:00
2026-07-22 10:15:50 +03:00
2026-07-22 10:15:50 +03:00
2026-07-09 02:14:07 +03:00
2026-07-20 03:11:07 +03:00
2026-07-06 18:27:38 +03:00
2026-07-22 11:19:39 +03:00
2026-07-18 18:14:33 +03:00
2026-07-19 18:36:11 +03:00
2026-07-09 02:14:07 +03:00
2026-07-16 19:12:59 +03:00
2026-07-22 10:35:52 +03:00
2026-07-22 10:35:52 +03:00
2026-07-16 17:40:24 +03:00
2026-07-21 10:06:40 +03:00
2026-07-17 15:04:48 +03:00
2026-07-20 03:11:07 +03:00
2026-07-21 18:39:09 +03:00
2026-06-22 15:46:43 +03:00
2026-07-20 03:11:07 +03:00
2026-07-17 16:59:42 +03:00
2026-07-17 23:12:55 +03:00
2026-07-18 01:56:47 +03:00
2026-07-22 09:21:21 +03:00
2026-07-22 10:35:52 +03:00
2026-07-13 09:16:33 +03:00
2026-07-17 03:34:23 +03:00
2026-07-13 09:16:33 +03:00
2026-07-21 18:51:22 +03:00
2026-07-21 19:43:48 +03:00
2026-07-17 03:30:07 +03:00
2026-07-17 03:07:59 +03:00
2026-07-06 16:02:56 +03:00
2026-07-17 03:36:07 +03:00
2026-07-09 09:45:53 +03:00
2026-07-22 09:21:21 +03:00
2026-07-09 02:14:07 +03:00
2026-07-17 03:34:23 +03:00
2026-07-22 09:21:21 +03:00
2026-07-19 18:36:11 +03:00
2026-07-17 03:07:59 +03:00
2026-07-16 10:17:13 +02:00
2026-07-17 03:07:59 +03:00
2026-07-13 09:16:33 +03:00
2026-07-17 03:07:59 +03:00
2026-07-09 09:45:53 +03:00
2026-06-23 16:48:59 +03:00
2026-07-06 15:22:22 +03:00
2026-07-06 11:35:56 +03:00
2026-07-06 01:25:39 +03:00
2026-07-09 09:45:53 +03:00
2026-07-09 02:14:07 +03:00
2026-07-22 13:02:42 +03:00
2026-07-17 16:59:42 +03:00
2026-07-17 16:59:42 +03:00
2026-05-27 20:51:44 +03:00
2026-07-17 04:52:30 +03:00
2026-07-22 10:15:50 +03:00
2026-07-19 18:36:11 +03:00
2026-07-17 03:07:59 +03:00
2026-07-09 10:09:32 +03:00
2026-06-23 16:36:14 +03:00
2026-07-11 00:14:49 +03:00
2026-07-17 23:48:26 +03:00
2026-07-06 10:55:29 +03:00
2026-07-17 03:07:59 +03:00
2026-07-17 03:07:59 +03:00
2026-07-17 03:07:59 +03:00
2026-07-09 02:14:07 +03:00
2026-07-17 18:29:28 +03:00
2026-07-06 15:12:21 +03:00
2026-07-22 12:15:56 +03:00
2026-07-17 03:34:23 +03:00
2026-07-06 10:33:15 +03:00
2026-07-21 10:06:40 +03:00
2026-07-21 10:06:41 +03:00
2026-07-21 10:06:40 +03:00
2026-07-21 10:06:40 +03:00
2026-07-21 10:06:40 +03:00
2026-07-09 02:14:07 +03:00
2026-06-23 08:50:29 +03:00
2026-07-22 12:37:49 +03:00
2026-07-09 02:14:07 +03:00
2026-07-13 09:16:33 +03:00
2026-07-09 09:45:53 +03:00
2026-07-09 02:14:07 +03:00
2026-07-16 17:40:24 +03:00
2026-07-22 10:15:50 +03:00
2026-07-17 03:36:50 +03:00
2026-07-06 10:43:26 +03:00
2026-07-17 03:36:50 +03:00
2026-07-17 21:40:37 +03:00
2026-07-21 10:06:41 +03:00
2026-07-17 03:36:50 +03:00
2026-07-19 18:36:11 +03:00
2026-07-09 09:45:53 +03:00
2026-07-22 09:21:21 +03:00
2026-07-19 12:22:56 +03:00
2026-07-18 19:42:19 +03:00
2026-07-18 19:18:17 +03:00
2026-07-16 17:40:24 +03:00
2026-07-17 20:20:06 +03:00
2026-07-09 02:14:07 +03:00
2026-07-06 01:26:05 +03:00
2026-07-13 09:16:33 +03:00
2026-07-13 09:16:33 +03:00
2026-07-17 03:21:02 +03:00
2026-07-17 03:21:28 +03:00
2026-07-09 09:45:53 +03:00
2026-07-16 18:46:09 +03:00
2026-07-17 03:34:23 +03:00
2026-07-17 03:44:38 +03:00
2026-07-08 23:43:26 +03:00
2026-07-09 09:45:53 +03:00
2026-07-22 12:15:56 +03:00
2026-07-17 20:46:10 +03:00
2026-07-18 00:45:33 +03:00
2026-06-13 17:19:51 +03:00
2026-06-13 20:15:04 +03:00
2026-06-13 17:19:51 +03:00
2026-07-16 20:01:10 +03:00
2026-07-18 02:16:53 +03:00
2026-07-17 18:44:14 +03:00
2026-07-17 23:01:52 +03:00
2026-07-20 03:11:07 +03:00
2026-07-17 03:53:09 +03:00
2026-07-06 11:50:28 +03:00
2026-07-09 09:45:53 +03:00
2025-12-22 23:18:01 +02:00
2026-06-12 20:15:56 +03:00
2026-07-21 19:43:48 +03:00