};
// Emit a pre-event public event to allow tweaking of the configure before view creation.
- window.$events.emitPublic(elem, 'editor-markdown-cm::pre-init', {cmEditorViewConfig: config});
+ window.$events.emitPublic(elem, 'editor-markdown-cm6::pre-init', {editorViewConfig: config});
// Create editor view, hide original input
const ev = createView(config);
}
}
-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;
\ No newline at end of file