mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-06-05 18:04:33 +08:00
CM6: Further fixes/improvements after testing
- Updated event naming to be "cm6" when codemirror-specific. - Removed cm block border in md editor to prevent double bordering. - Updated copy handling to fallback to execCommand.
This commit is contained in:
@ -51,8 +51,20 @@ export class Clipboard {
|
||||
}
|
||||
}
|
||||
|
||||
export function copyTextToClipboard(text) {
|
||||
return navigator.clipboard.writeText(text);
|
||||
export async function copyTextToClipboard(text) {
|
||||
if (window.isSecureContext && navigator.clipboard) {
|
||||
await navigator.clipboard.writeText(text);
|
||||
return;
|
||||
}
|
||||
|
||||
// Backup option where we can't use the navigator.clipboard API
|
||||
const tempInput = document.createElement("textarea");
|
||||
tempInput.style = "position: absolute; left: -1000px; top: -1000px;";
|
||||
tempInput.value = text;
|
||||
document.body.appendChild(tempInput);
|
||||
tempInput.select();
|
||||
document.execCommand("copy");
|
||||
document.body.removeChild(tempInput);
|
||||
}
|
||||
|
||||
export default Clipboard;
|
Reference in New Issue
Block a user