Skip to content

⬅️ Back to Table of Contents

📄 index.ts

📊 Analysis Summary

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

📚 Table of Contents

🛠️ File Location:

📂 packages/core/useClipboardItems/index.ts

📦 Imports

Name Source
ComputedRef vue
MaybeRefOrGetter vue
ConfigurableNavigator ../_configurable
useTimeoutFn @vueuse/shared
deepRef 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>

Code
export function useClipboardItems(options?: UseClipboardItemsOptions<undefined>): UseClipboardItemsReturn<false>
  • JSDoc:

    /**
     * Reactive Clipboard API.
     *
     * @see https://vueuse.org/useClipboardItems
     * @param options
     */
    

  • Parameters:

  • options: UseClipboardItemsOptions<undefined>
  • Return Type: UseClipboardItemsReturn<false>

updateContent(): void

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

copy(value: any): Promise<void>

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()
    }
  }
  • Parameters:
  • value: any
  • Return Type: Promise<void>
  • Calls:
  • navigator!.clipboard.write
  • 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
source Source
copiedDuring number

UseClipboardItemsReturn<Optional>

Interface Code
export interface UseClipboardItemsReturn<Optional> {
  isSupported: ComputedRef<boolean>
  content: ComputedRef<ClipboardItems>
  copied: ComputedRef<boolean>
  copy: Optional extends true ? (content?: ClipboardItems) => Promise<void> : (text: ClipboardItems) => Promise<void>
}

Properties

Name Type Optional Description
isSupported ComputedRef<boolean>
content ComputedRef<ClipboardItems>
copied ComputedRef<boolean>
copy Optional extends true ? (content?: ClipboardItems) => Promise<void> : (text: ClipboardItems) => Promise<void>