Fixed copy functionality
This commit is contained in:
parent
09b99985eb
commit
995111612c
|
|
@ -858,6 +858,7 @@ function highlightTextNodes(root: HTMLElement, terms: string[]): number {
|
||||||
/>
|
/>
|
||||||
<template #content>
|
<template #content>
|
||||||
<UFieldGroup size="sm" orientation="horizontal" class="bg-white p-0 rounded-md shadow-md">
|
<UFieldGroup size="sm" orientation="horizontal" class="bg-white p-0 rounded-md shadow-md">
|
||||||
|
<UPopover>
|
||||||
<UButton
|
<UButton
|
||||||
v-if="hit.document.text"
|
v-if="hit.document.text"
|
||||||
icon="ph-note-pencil"
|
icon="ph-note-pencil"
|
||||||
|
|
@ -866,6 +867,13 @@ function highlightTextNodes(root: HTMLElement, terms: string[]): number {
|
||||||
size="lg"
|
size="lg"
|
||||||
@click="addNote(hit.document.id)"
|
@click="addNote(hit.document.id)"
|
||||||
></UButton>
|
></UButton>
|
||||||
|
|
||||||
|
<template #content>
|
||||||
|
<UEditor />
|
||||||
|
</template>
|
||||||
|
</UPopover>
|
||||||
|
|
||||||
|
<UPopover>
|
||||||
<UButton
|
<UButton
|
||||||
v-if="hit.document.text"
|
v-if="hit.document.text"
|
||||||
icon="ph-highlighter"
|
icon="ph-highlighter"
|
||||||
|
|
@ -874,6 +882,11 @@ function highlightTextNodes(root: HTMLElement, terms: string[]): number {
|
||||||
size="lg"
|
size="lg"
|
||||||
@click="highlightParagraph(hit.document.id)"
|
@click="highlightParagraph(hit.document.id)"
|
||||||
></UButton>
|
></UButton>
|
||||||
|
|
||||||
|
<template #content>
|
||||||
|
<UColorPicker />
|
||||||
|
</template>
|
||||||
|
</UPopover>
|
||||||
<UButton
|
<UButton
|
||||||
v-if="hit.document.text"
|
v-if="hit.document.text"
|
||||||
icon="ph-copy"
|
icon="ph-copy"
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,30 @@
|
||||||
/* Copy to Clipboard */
|
/* Copy to Clipboard */
|
||||||
export async function copyToClipboard(textToCopy: string, type: string, id: string) {
|
export async function copyToClipboard() {
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
|
|
||||||
|
const selection = window.getSelection()
|
||||||
|
|
||||||
|
const container = document.createElement('div')
|
||||||
|
const range = selection?.getRangeAt(0)
|
||||||
|
container.appendChild(range.cloneContents())
|
||||||
|
|
||||||
|
const htmlOutput = container.innerHTML
|
||||||
|
const textOutput = selection?.toString()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await navigator.clipboard.writeText(textToCopy)
|
// Modern Clipboard API requires ClipboardItem
|
||||||
|
const clipboardItem = new ClipboardItem({
|
||||||
|
'text/html': new Blob([htmlOutput], { type: 'text/html' }),
|
||||||
|
'text/plain': new Blob([textOutput], { type: 'text/plain' })
|
||||||
|
})
|
||||||
|
|
||||||
|
await navigator.clipboard.write([clipboardItem])
|
||||||
|
|
||||||
|
window.getSelection()?.removeAllRanges()
|
||||||
|
|
||||||
toast.add({
|
toast.add({
|
||||||
title: 'Texto copiado!',
|
title: 'Texto copiado!',
|
||||||
description: `${textToCopy}`,
|
description: `${textOutput}`,
|
||||||
icon: 'ph-clipboard-text',
|
icon: 'ph-clipboard-text',
|
||||||
color: type == 'activities' ? 'success' : 'info'
|
color: type == 'activities' ? 'success' : 'info'
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue