Coder Social home page Coder Social logo

docsify-copy-code's Introduction

docsify-copy-code

NPM License: MIT

A docsify plugin that adds a button to easily copy code blocks to your clipboard.

Installation

Production

Add following script tag to your index.html after docsify. Specifying the @[version] in the URL ensures that the release of a major update (v3.x) will not break your production site:

<!-- Latest v2.x.x -->
<script src="https://unpkg.com/docsify-copy-code@2"></script>

Development

If you prefer to load the latest version of the library, you may do so by omitting the @[version] from the above URL.

<!-- Latest (not recommended for production) -->
<script src="https://unpkg.com/docsify-copy-code"></script>

Usage

Create a markdown code block with help of triple backticks at the beginning and end of your code. This block will have a copy button on the top right when hovering over it.

Options

Button text

Button text can be customized as follows:

window.$docsify = {
  // docsify-copy-code (defaults)
  copyCode: {
    buttonText : 'Copy to clipboard',
    errorText  : 'Error',
    successText: 'Copied'
  }
}

Localization (l10n)

Button text can also be customized based on the current URL. Object key/value pairs are processed in the order provided.

window.$docsify = {
  copyCode: {
    buttonText: {
      '/zh-cn/': '点击复制',
      '/ru/'   : 'Скопировать в буфер обмена',
      '/de-de/': 'Klicken Sie zum Kopieren',
      '/es/'   : 'Haga clic para copiar',
      '/'      : 'Copy to clipboard'
    },
    errorText: {
      '/zh-cn/': '错误',
      '/ru/'   : 'ошибка',
      '/'      : 'Error'
    },
    successText: {
      '/zh-cn/': '复制',
      '/ru/'   : 'Скопировано',
      '/de-de/': 'Kopiert',
      '/es/'   : 'Copiado',
      '/'      : 'Copied'
    }
  }
}

Note: Docsify's alias option makes it easy to manage local content using separate directories. See the /demo/ content in this repo for an example.

License

This project is licensed under the MIT License. See the LICENSE for details.

docsify-copy-code's People

Contributors

dependabot[bot] avatar jhildenbiddle avatar jperasmus avatar masontin avatar rene78 avatar yash-singh1 avatar

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.