Skip to content

⬅️ Back to Table of Contents

📄 useClipboardItems

📊 Analysis Summary

Metric Count
🔧 Functions 3
📦 Imports 12
⚡ Async/Await Patterns 2
📐 Interfaces 2

📚 Table of Contents

🛠️ File Location:

📂 packages/core/useClipboardItems/index.ts

📦 Imports

Name Source
MaybeRefOrGetter vue
Ref vue
ShallowRef vue
ConfigurableNavigator ../_configurable
Supportable ../types
useTimeoutFn @vueuse/shared
shallowReadonly vue
shallowRef vue
toValue vue
defaultNavigator ../_configurable
useEventListener ../useEventListener
useSupported ../useSupported

Async/Await Patterns

Type Function Await Expressions Promise Chains
promise-chain updateContent none navigator!.clipboard.read().then
async-function copy navigator!.clipboard.write(value) none

Functions

useClipboardItems(options: UseClipboardItemsOptions<undefined>): UseClipboardItemsReturn<false>

Reactive Clipboard API.

Parameters:

  • options any: No description

See: https://vueuse.org/useClipboardItems

Tags: @__NO_SIDE_EFFECTS__

Raw JSDoc
/**
 * Reactive Clipboard API.
 *
 * @see https://vueuse.org/useClipboardItems
 * @param options
 *
 * @__NO_SIDE_EFFECTS__
 */
Code
export function useClipboardItems(options?: UseClipboardItemsOptions<undefined>): UseClipboardItemsReturn<false>

Internal helpers

Declared inside another function in this file.

updateContent(): void

Returns: void

Calls:

  • navigator!.clipboard.read().then
Code
function updateContent() {
    if (isSupported.value) {
      navigator!.clipboard.read().then((items) => {
        content.value = items
      })
    }
  }

copy(value: any): Promise<void>

Parameters:

  • value any

Returns: Promise<void>

Calls:

  • navigator!.clipboard.write
  • timeout.start
Code
async function copy(value = toValue(source)) {
    if (isSupported.value && value != null) {
      await navigator!.clipboard.write(value)

      content.value = value
      copied.value = true
      timeout.start()
    }
  }

Interfaces

UseClipboardItemsOptions<Source>

Interface Code
export interface UseClipboardItemsOptions<Source> extends ConfigurableNavigator {
  /**
   * Enabled reading for clipboard
   *
   * @default false
   */
  read?: boolean

  /**
   * Copy source
   */
  source?: Source

  /**
   * Milliseconds to reset state of `copied` ref
   *
   * @default 1500
   */
  copiedDuring?: number
}

Properties

Name Type Optional Description
read boolean not shown
source Source not shown
copiedDuring number not shown

UseClipboardItemsReturn<Optional>

Interface Code
export interface UseClipboardItemsReturn<Optional> extends Supportable {
  content: Readonly<Ref<ClipboardItems>>
  copied: Readonly<ShallowRef<boolean>>
  copy: Optional extends true ? (content?: ClipboardItems) => Promise<void> : (text: ClipboardItems) => Promise<void>
  read: () => void
}

Properties

Name Type Optional Description
content Readonly<Ref<ClipboardItems>> not shown
copied Readonly<ShallowRef<boolean>> not shown
copy Optional extends true ? (content?: ClipboardItems) => Promise<void> : (text: ... not shown
read () => void not shown

Generated by Syntax Scribe