1import ApplicationController from "mensa/controllers/application_controller"; 2 3export default class CopyableComponentController extends ApplicationController { 4 static values = { 5 text: String, 6 }; 7 8 async copy(event) { 9 event.preventDefault(); 10 11 if (!this.hasTextValue) return; 12 13 if (navigator.clipboard?.writeText) { 14 await navigator.clipboard.writeText(this.textValue); 15 } else { 16 this._copyWithFallback(this.textValue); 17 } 18 } 19 20 _copyWithFallback(text) { 21 const input = document.createElement("textarea"); 22 input.value = text; 23 input.setAttribute("readonly", ""); 24 input.style.position = "fixed"; 25 input.style.top = "-9999px"; 26 input.style.left = "-9999px"; 27 document.body.appendChild(input); 28 input.select(); 29 document.execCommand("copy"); 30 input.remove(); 31 } 32};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.