fix: Handle link copy error (#13038)

This commit is contained in:
Tom Moor
2026-07-18 13:23:01 -04:00
committed by GitHub
parent 89a4584a7a
commit d2bf2b8c5a
2 changed files with 9 additions and 3 deletions
+8 -3
View File
@@ -129,9 +129,14 @@ export default class Heading extends Node<HeadingOptions> {
const normalizedUrl = window.location.href
.split("#")[0]
.replace("/edit", "");
copy(normalizedUrl + hash);
toast.message(t("Link copied to clipboard"));
try {
copy(normalizedUrl + hash);
toast.message(t("Link copied to clipboard"));
} catch (_err) {
// Some browser contexts disable the prompt() fallback used by
// copy-to-clipboard, causing it to throw surface it rather than crash.
toast.error(t("Sorry, the link could not be copied"));
}
};
keys({ type, schema }: { type: NodeType; schema: Schema }) {
@@ -1822,6 +1822,7 @@
"Show {{ count }} completed_many": "Show {{ count }} completed",
"Show {{ count }} completed_other": "Show {{ count }} completed",
"Hide completed": "Hide completed",
"Sorry, the link could not be copied": "Sorry, the link could not be copied",
"Write a caption": "Write a caption",
"Add title": "Add title",
"Add content": "Add content",