mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
fix(core): link copying and pasting (#8157)
Related to: https://github.com/toeverything/blocksuite/pull/8233
This commit is contained in:
@@ -72,14 +72,20 @@ function createCopyLinkToBlockMenuItem(
|
|||||||
const str = generateUrl(options);
|
const str = generateUrl(options);
|
||||||
if (!str) return;
|
if (!str) return;
|
||||||
|
|
||||||
track.doc.editor.toolbar.copyBlockToLink({ type: model.flavour });
|
const type = model.flavour;
|
||||||
|
const title = editor.doc.title$.value;
|
||||||
|
const page = editor.editorContainer$.value;
|
||||||
|
|
||||||
navigator.clipboard
|
page?.host?.std.clipboard
|
||||||
.writeText(str)
|
.writeToClipboard(items => {
|
||||||
|
items['text/plain'] = str;
|
||||||
|
// wrap a link
|
||||||
|
items['text/html'] = `<a title="${title}" href="${str}">${title}</a>`;
|
||||||
|
return items;
|
||||||
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
notify.success({
|
track.doc.editor.toolbar.copyBlockToLink({ type });
|
||||||
title: I18n['Copied link to clipboard'](),
|
notify.success({ title: I18n['Copied link to clipboard']() });
|
||||||
});
|
|
||||||
})
|
})
|
||||||
.catch(console.error);
|
.catch(console.error);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -114,14 +114,18 @@ function createCopyLinkToBlockMenuItem(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
track.doc.editor.toolbar.copyBlockToLink({ type });
|
const title = editor.doc.title$.value;
|
||||||
|
|
||||||
navigator.clipboard
|
ctx.std.clipboard
|
||||||
.writeText(str)
|
.writeToClipboard(items => {
|
||||||
|
items['text/plain'] = str;
|
||||||
|
// wrap a link
|
||||||
|
items['text/html'] = `<a title="${title}" href="${str}">${title}</a>`;
|
||||||
|
return items;
|
||||||
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
notify.success({
|
track.doc.editor.toolbar.copyBlockToLink({ type });
|
||||||
title: I18n['Copied link to clipboard'](),
|
notify.success({ title: I18n['Copied link to clipboard']() });
|
||||||
});
|
|
||||||
})
|
})
|
||||||
.catch(console.error);
|
.catch(console.error);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user