mirror of
https://github.com/hcengineering/platform.git
synced 2025-06-06 07:46:32 +00:00
ATS-13: support multiple docs for copying (#3526)
Signed-off-by: Vyacheslav Tumanov <me@slavatumanov.me>
This commit is contained in:
parent
a539f9465b
commit
f4183e7d33
@ -31,7 +31,7 @@ import contact from '@hcengineering/contact'
|
|||||||
* - props - additional text provider props.
|
* - props - additional text provider props.
|
||||||
*/
|
*/
|
||||||
async function CopyTextToClipboard (
|
async function CopyTextToClipboard (
|
||||||
doc: Doc,
|
doc: Doc | Doc[],
|
||||||
evt: Event,
|
evt: Event,
|
||||||
props: {
|
props: {
|
||||||
textProvider: Resource<(doc: Doc, props?: Record<string, any>) => Promise<string>>
|
textProvider: Resource<(doc: Doc, props?: Record<string, any>) => Promise<string>>
|
||||||
@ -42,13 +42,18 @@ async function CopyTextToClipboard (
|
|||||||
try {
|
try {
|
||||||
// Safari specific behavior
|
// Safari specific behavior
|
||||||
// see https://bugs.webkit.org/show_bug.cgi?id=222262
|
// see https://bugs.webkit.org/show_bug.cgi?id=222262
|
||||||
|
const text = Array.isArray(doc)
|
||||||
|
? (await Promise.all(doc.map(async (d) => await getText(d, props.props)))).join(',')
|
||||||
|
: await getText(doc, props.props)
|
||||||
const clipboardItem = new ClipboardItem({
|
const clipboardItem = new ClipboardItem({
|
||||||
'text/plain': getText(doc, props.props)
|
'text/plain': text
|
||||||
})
|
})
|
||||||
await navigator.clipboard.write([clipboardItem])
|
await navigator.clipboard.write([clipboardItem])
|
||||||
} catch {
|
} catch {
|
||||||
// Fallback to default clipboard API implementation
|
// Fallback to default clipboard API implementation
|
||||||
const text = await getText(doc, props.props)
|
const text = Array.isArray(doc)
|
||||||
|
? (await Promise.all(doc.map(async (d) => await getText(d, props.props)))).join(',')
|
||||||
|
: await getText(doc, props.props)
|
||||||
await navigator.clipboard.writeText(text)
|
await navigator.clipboard.writeText(text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user