# docs/copybutton.md
# CopyButton
All parameters are optional.
| Parameter | Type | Description of Parameter |
| :-------------- | :-----: | :--------------------------------------------------------------------------- |
| `text` | String | Text to be copied |
| `next` | Boolean | Copy next element text |
| `prev` | Boolean | Copy previous element text |
| `all` | Boolean | Copy parent element text |
| `anchor` | Boolean | Copy anchor text (the id) |
| `margin` | String | [CSS margin](https://developer.mozilla.org/en-US/docs/Web/CSS/margin) String |
## Usage
With automatic text detection:
```markdown
```
With a set text:
```markdown
```
With a boolean parameter:
```markdown
```
See the [Examples](../guides/examples.md) for more ways to use the CopyButton.
::: tip Request a Feature
If you need more options, please [open a feature request](https://github.com/cssnr/vitepress-plugin-copybutton/discussions/categories/feature-requests)
:::
---
# guides/examples.md
# Copy Button Examples
Can be added directly to [headings](#headings), [text](#text), [tables](#table) and [more](#demos).
## Headings
### Heading 1
::: code-group
```markdown [Code]
### Heading 1
```
```plain [Result]
Heading 1
```
:::
### Heading 2
::: code-group
```markdown [Code]
### Heading 2
```
```plain [Result]
Heading 2
```
:::
### Heading 3
::: code-group
```markdown [Code]
### Heading 3
```
```plain [Result]
Heading 3
```
:::
### Heading 4 {#custom_anchor_2}
::: code-group
```markdown [Code]
### Heading 4 {#custom_anchor_2}
```
```plain [Result]
custom_anchor_2
```
:::
### Heading 5
::: code-group
```markdown [Code]
### Heading 5
```
```plain [Result]
Custom Text
```
:::
## Text
Lorem ipsum dolor sit amet.
::: code-group
```markdown [Code]
Lorem ipsum dolor sit amet.
```
```plain [Result]
Lorem ipsum dolor sit amet.
```
:::
Some text. `some inline code`
::: code-group
```markdown [Code]
Some text. `some inline code`
```
```plain [Result]
Some text.
```
:::
Some text. `some inline code`
::: code-group
```markdown [Code]
Some text. `some inline code`
```
```plain [Result]
some inline code
```
:::
Some text. `some inline code`
::: code-group
```markdown [Code]
Some text. `some inline code`
```
```plain [Result]
Some text. some inline code
```
:::
## Table
| Key | Tag Used | Result |
| :------------------------------------ | :-----------: | ----------------------- |
| `inline code` | `` | inline code |
| text string | `` | text string |
| text string `inline code` | `` | text string |
| text string `inline code` | `` | inline code |
| text string `inline code` | `` | inline code text string |
## Demos
The plugin is used extensively on these pages:
- https://docker-deploy.cssnr.com/docs/inputs
- https://portainer-deploy.cssnr.com/docs/inputs
If you have a live demo, let us know and we will post it here...
See the [CopyButton Documentation](../docs/copybutton.md) for `` tag usage.
---
# guides/get-started.md
# Getting Started
A [VitePress](https://vitepress.dev/) Plugin to easily add a copy button to a heading, table, code snippet or paragraph with automatic text detection or pass any string.
To get started, [install](#install) the package, [setup](#setup) the plugin, and view the [usage](#usage).
## Install
Install or Download from NPM npmjs.com
Install directly to your VitePress from [npmjs](https://www.npmjs.com/package/@cssnr/vitepress-plugin-copybutton) with the following command.
::: code-group
```shell [npm]
npm i @cssnr/vitepress-plugin-copybutton
```
```shell [pnpm]
pnpm i @cssnr/vitepress-plugin-copybutton
```
```shell [yarn]
yarn add @cssnr/vitepress-plugin-copybutton
```
```shell [bun]
bun i @cssnr/vitepress-plugin-copybutton
```
:::
_Note: you can also [copy the source](source.md) file to your project._ WIP
## Setup
Add these 3 lines to your `index.[js,ts]`.
_If you don't have a [.vitepress/theme/index.ts](https://vitepress.dev/guide/custom-theme#theme-resolving) file, create one._
```javascript [.vitepress/theme/index.ts]
import DefaultTheme, { VPBadge } from 'vitepress/theme' // [!code highlight]
import CopyButton from '@cssnr/vitepress-plugin-copybutton' // [!code ++]
import '@cssnr/vitepress-plugin-copybutton/style.css' // [!code ++]
export default {
...DefaultTheme,
enhanceApp({ app }) {
app.component('Badge', VPBadge) // [!code highlight]
app.component('CB', CopyButton) // [!code ++]
},
}
```
VPBadge Only required if you are using the VitePress [Badge](https://vitepress.dev/reference/default-theme-badge#badge).
Note: The component name `CB` is an arbitrary string based on your preference.
## Usage
Simply add a `` tag to your markdown or component.
Jump to the [documentation](../docs/copybutton.md) or view [examples](examples.md).
With a set text:
```markdown
```
With automatic text detection:
```markdown
```
See the [CopyButton Documentation](../docs/copybutton.md) for `` tag usage or view the [Examples](examples.md).
---
# guides/source.md
# Use from Source
::: warning Work in Progress
This guide is not yet complete but should get you started.
:::
You can easily add the source file to your project for full control over the [template](../docs/copybutton.md).
Download or copy the [CopyButton.vue](https://github.com/cssnr/vitepress-plugin-copybutton/blob/master/src/CopyButton.vue)
file to your project.
- Source File: [CopyButton.vue](https://github.com/cssnr/vitepress-plugin-copybutton/blob/master/src/CopyButton.vue)
- Target Location: `.vitepress/theme/components/CopyButton.vue`
Add these 2 lines to your `index.[js,ts]`.
```javascript [.vitepress/theme/index.ts]
import DefaultTheme, { VPBadge } from 'vitepress/theme' // [!code highlight]
import CopyButton from './components/CopyButton.vue' // [!code ++]
export default {
...DefaultTheme,
enhanceApp({ app }) {
app.component('Badge', VPBadge) // [!code highlight]
app.component('CB', CopyButton) // [!code ++]
},
}
```
VPBadge Only required if you are using the VitePress [Badge](https://vitepress.dev/reference/default-theme-badge#badge).
See the [CopyButton Documentation](../docs/copybutton.md) for `` tag usage or view the [Examples](examples.md).
---
# support.md
# Support
[](https://github.com/cssnr/vitepress-plugin-copybutton/issues/new?template=1-feature.yaml)
[](https://github.com/cssnr/vitepress-plugin-copybutton/issues)
[](https://github.com/cssnr/vitepress-plugin-copybutton/discussions)
[](https://discord.gg/wXy6m2X8wY)
If you run into any issues or want to see any new features, please let us know!
Contributing is as easy as telling us [what features or changes](https://github.com/cssnr/vitepress-plugin-copybutton/discussions/categories/feature-requests) you want to see next…
[[toc]]
### GitHub Discussions
If you have a question or need help with anything,
start a discussion in [General](https://github.com/cssnr/vitepress-plugin-copybutton/discussions/categories/general)
or [Q&A](https://github.com/cssnr/vitepress-plugin-copybutton/discussions/categories/q-a).
If you want to see a new feature, start a discussion in
the [Feature Requests](https://github.com/cssnr/vitepress-plugin-copybutton/discussions/categories/feature-requests) section.
[](https://github.com/cssnr/vitepress-plugin-copybutton/discussions)
### GitHub Issues
If you run into any problems or find a bug, please [open an issue](https://github.com/cssnr/vitepress-plugin-copybutton/issues).
**These reports are treated with the highest priority.**
[](https://github.com/cssnr/vitepress-plugin-copybutton/issues)
### Discord Chat
You can chat with us about anything [on discord](https://discord.gg/wXy6m2X8wY).
From here you can contact me directly, `Shane@111150265075298304`.
[](https://discord.gg/wXy6m2X8wY)
[{ width="360" }](https://ko-fi.com/cssnr)