Coder Social home page Coder Social logo

solid-copy-text's Introduction

solid-copy-to-clipboard

solid-copy-to-clipboard

solid-copy-to-clipboard is a advanced component for quickly packaging single-layer materials into content that can be copied after clicking.

Quick start

Install it:

npm i solid-copy-text
# or
yarn add solid-copy-text
# or
pnpm add solid-copy-text

Use it:

Component-Warp

import SolidCopyToClipboard from 'solid-copy-text'

function MyChartComponent() {
  return (
    <SolidCopyToClipboard
      text='is copy Context'
      onCpoy={(text, result) => alert('Copied!')}
    >
      <button>Click me copy</button>
    </SolidCopyToClipboard>
  );
}

directive

import {copyText} from 'solid-copy-text'

function MyChartComponent() {
  const [str, setStr] = createSignal<string>('hello world again')
  return (
    <div use:copyText='hello world'>Click me copy</div>
    <div use:copyText={str}>Click me copy</div>
    <div use:copyText={{
      text: 'hello world', 
      onCopy: () => alert('Copied!')
    }}>Click me copy</div>
    <div use:copyText={{
      text: 'hello world', 
      onCopy: () => alert('Copied!'),
      eventName: ['dbclick', 'contextmenu']
    }}>Click me copy</div>
  );
}

Props

  • option: copy-to-clipboard option object with data and configuration.
  • text: copy text, type string
  • onCpoy: used to handle the return of the copied logic. Will carry the text value and whether the copy was successful or not.
  • eventName: string Or string[] you can use the dom eventName https://developer.mozilla.org/en-US/docs/Web/Events. the default value is click.

Type

  • SolidCopyTextProps: Component type export

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.