New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@hopsoft/copy-controller

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hopsoft/copy-controller

Copies text from `input` and `textarea` elements to the clipboard.

latest
Source
npmnpm
Version
0.0.5
Version published
Maintainers
1
Created
Source

Copy Controller

Copies text from input and textarea elements to the clipboard.

Quick Start

yarn add @hopsoft/copy-controller

app/javascript/controllers/index.js

import { Application } from 'stimulus'
import { definitionsFromContext } from 'stimulus/webpack-helpers'
import CopyController from '@hopsoft/copy-controller'

const application = Application.start()
const context = require.context('./controllers', true, /\.js$/)
application.load(definitionsFromContext(context))
application.register('copy', CopyController)

app/views/demos/copy.html.erb

<div data-controller="copy" data-copy-content='Copied...' data-copy-duration='1'>
  <textarea data-target='copy.source'></textarea>
  <button type="button" data-target='copy.target' data-action='click->copy#copy'>Copy</button>
</div>

Usage

The root element is a container that holds holds all other elements and is configured by setting:

data-controller="copy"

Configuration

AttributeDefaultDescription
data-copy-contentoptional"Copied..."Content to show in the button after a copy has been performed
data-copy-durationoptional2000How many milliseconds to show the copied content in the button before reverting to the original content

Copied content can be disabled by setting data-copy-content="" or data-copy-duration="0"

Targets

Targets are child elements identified by setting:

data-target="copy.TARGET_NAME"
NameDescription
sourcerequiredAn input or textarea that holds the content to be copied
triggerrequiredThe button used to perform the copy

Actions

Actions are behaviors that can be triggered and are identified by setting:

data-action="copy#ACTION_NAME"
NameDescription
copyrequiredPerforms the copy action (typically defined on the button target)

FAQs

Package last updated on 20 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts