Copy to clipboard

I am trying to create a simple craft extension where I can either add the web link, or the deep link of a note to the clipboard to then paste this in our Azure DevOps boards, but for some reason the code below is not working, am I missing something obvious?

<body>
        <div style="height: 44pt; text-align: center; font-size: 15pt;">
            <p>Link Generator</p>
        </div>
		<button class="button" id="btn-web-link">Copy Web Link To Clipboard</button>
		<button class="button" id="btn-deep-link">Copy Deep Link To Clipboard</button>

		<script>
			const buttonWebLink = document.getElementById("btn-web-link");

            const buttonDeepLink = document.getElementById("btn-deep-link");

			buttonWebLink.addEventListener("click", async () => {
				try {
                    result = await craft.editorApi.getSelection();

                    if (result.status !== "success") {
						throw new Error(result.message)
					} else {
						var selectedBlockData = result.data
					}

                    let webUrl = 'https://docs.craft.do/editor/d/' + selectedBlockData[0].spaceId + '/' + selectedBlockData[0].documentId + '/b/' + selectedBlockData[0].id;

                    navigator.clipboard.write(webUrl);
                }
                catch(err){
                    throw `${err.name}\n${err.message}`
                }
			});

            buttonDeepLink.addEventListener("click", async () => {
				try {
                    result = await craft.editorApi.getSelection();

                    if (result.status !== "success") {
						throw new Error(result.message)
					} else {
						var selectedBlockData = result.data
					}

                    let deepLink = 'craftdocs://open?blockId=' + selectedBlockData[0].id + '&spaceId=' + selectedBlockData[0].spaceId;

                    navigator.clipboard.write(deepLink);
                }
                catch(err){
                    throw `${err.name}\n${err.message}`
                }
			});
		</script>
	</body>

Hi! It’s likely that the security permissions don’t allow this. We will create a write-only clipboard API call which will route requests to the component which can do it - i.e. sg. like craft.clipboard.write(X).

Expect this in 2-3 weeks