clipxjs 1.2.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -21
- package/README.md +410 -293
- package/dist/clipx.min.js +2 -2
- package/package.json +39 -25
- package/src/clipx.js +283 -275
package/README.md
CHANGED
|
@@ -1,293 +1,410 @@
|
|
|
1
|
-

|
|
2
|
-

|
|
3
|
-
|
|
4
|
-
# ClipX.js -Maximize Clipboard Power with Minimal Size
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
## Official Website
|
|
11
|
-
|
|
12
|
-
For more information about this project, please visit our official website: [ClipX](https://clipx.
|
|
13
|
-
|
|
14
|
-
---
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
- [
|
|
20
|
-
- [
|
|
21
|
-
- [
|
|
22
|
-
- [
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
- [Via
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
- [
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
- [Example: Using
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
- [`data-clipx-
|
|
35
|
-
- [`data-clipx-
|
|
36
|
-
- [`data-clipx-
|
|
37
|
-
- [`data-clipx-
|
|
38
|
-
- [`data-clipx-
|
|
39
|
-
- [`data-clipx-disable-
|
|
40
|
-
- [`data-clipx-toast
|
|
41
|
-
- [`data-clipx-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
###
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
###
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
###
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
```javascript
|
|
134
|
-
clipx.
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
**
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
1
|
+

|
|
2
|
+

|
|
3
|
+
|
|
4
|
+
# ClipX.js -Maximize Clipboard Power with Minimal Size
|
|
5
|
+
|
|
6
|
+
ClipX.js is an ultra-light JavaScript library that simplifies clipboard tasks and enriches user feedback. It offers straightforward `copy, cut, and paste` capabilities, and `built-in toast notifications` that you can easily customize, providing a quick and efficient way to handle clipboard and notification needs. ——— The Smarter Clipboard Solution.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Official Website
|
|
11
|
+
|
|
12
|
+
For more information about this project, please visit our official website: [ClipX](https://clipx.js.org/)
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Table of Contents 📑
|
|
17
|
+
|
|
18
|
+
1. [Why Choose ClipX.js?](#why-choose-clipxjs)
|
|
19
|
+
- [Lightweight & Fast](#lightweight--fast)
|
|
20
|
+
- [Built-in Feedback](#built-in-feedback)
|
|
21
|
+
- [Flexible Customization](#flexible-customization)
|
|
22
|
+
- [Easy Integration](#easy-integration)
|
|
23
|
+
- [Robust Error Handling](#robust-error-handling)
|
|
24
|
+
2. [Installation](#installation)
|
|
25
|
+
- [Via NPM](#via-npm)
|
|
26
|
+
- [Via CDN](#via-cdn)
|
|
27
|
+
3. [Initializing ClipX.js](#initializing-clipxjs)
|
|
28
|
+
- [Basic Initialization](#basic-initialization)
|
|
29
|
+
- [Configuration Options](#configuration-options)
|
|
30
|
+
4. [Attaching ClipX Functionality](#attaching-clipx-functionality)
|
|
31
|
+
- [Example: Using Data Attributes](#example-using-data-attributes)
|
|
32
|
+
- [Example: Using Class Names](#example-using-class-names)
|
|
33
|
+
5. [Attributes Overview](#attributes-overview)
|
|
34
|
+
- [`data-clipx-target`](#data-clipx-target)
|
|
35
|
+
- [`data-clipx-text`](#data-clipx-text)
|
|
36
|
+
- [`data-clipx-cut`](#data-clipx-cut)
|
|
37
|
+
- [`data-clipx-msg`](#data-clipx-msg)
|
|
38
|
+
- [`data-clipx-toast`](#data-clipx-toast)
|
|
39
|
+
- [`data-clipx-disable-msg`](#data-clipx-disable-msg)
|
|
40
|
+
- [`data-clipx-disable-toast`](#data-clipx-disable-toast)
|
|
41
|
+
- [`data-clipx-toast-position`](#data-clipx-toast-position)
|
|
42
|
+
- [`data-clipx-duration`](#data-clipx-duration)
|
|
43
|
+
6. [Example](#example)
|
|
44
|
+
7. [Demo](#demo--get-start-code)
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Why Choose ClipX.js?
|
|
49
|
+
|
|
50
|
+
### Lightweight & Fast
|
|
51
|
+
|
|
52
|
+
- At only 2KB, ClipX.js is smaller and faster than most clipboard libraries.
|
|
53
|
+
|
|
54
|
+
### Built-in Feedback
|
|
55
|
+
|
|
56
|
+
- Includes customizable toast notifications for clipboard actions—no need for additional UI libraries.
|
|
57
|
+
|
|
58
|
+
### Flexible Customization
|
|
59
|
+
|
|
60
|
+
- Easily style toasts, control message display, and integrate seamlessly with your app's design.
|
|
61
|
+
|
|
62
|
+
### Easy Integration
|
|
63
|
+
|
|
64
|
+
- Simple API with minimal setup, ensuring broad compatibility across modern and older browsers.
|
|
65
|
+
|
|
66
|
+
### Robust Error Handling
|
|
67
|
+
|
|
68
|
+
- Provides clear, customizable error feedback to enhance user experience and simplify debugging.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Installation
|
|
73
|
+
|
|
74
|
+
### Via NPM
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
npm i clipxjs
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Via CDN
|
|
81
|
+
|
|
82
|
+
Use only one `CDN`
|
|
83
|
+
|
|
84
|
+
**jsdelivr**
|
|
85
|
+
|
|
86
|
+
```html
|
|
87
|
+
<script src="https://cdn.jsdelivr.net/npm/clipxjs/dist/clipx.min.js"></script>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**OR**
|
|
91
|
+
|
|
92
|
+
**unpkg**
|
|
93
|
+
|
|
94
|
+
```html
|
|
95
|
+
<script src="https://unpkg.com/clipxjs/dist/clipx.min.js"></script>
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## Initializing ClipX.js
|
|
101
|
+
|
|
102
|
+
To get started with ClipX.js, follow these steps to set up and configure the library according to your needs:
|
|
103
|
+
|
|
104
|
+
## Basic Initialization
|
|
105
|
+
|
|
106
|
+
```javascript
|
|
107
|
+
/* Initialize ClipX.js instance */
|
|
108
|
+
var clipx = new clipx();
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Configuration Options
|
|
112
|
+
|
|
113
|
+
### 1. Disable Text Content Change Globally
|
|
114
|
+
|
|
115
|
+
To prevent the text content of elements from changing globally, set the `msg` property to `true`. Otherwise, set it to `false` to enable text content change.
|
|
116
|
+
|
|
117
|
+
```javascript
|
|
118
|
+
clipx.disable.msg = false; // Set to true to disable text content change globally
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### 2. Disable Toast Notifications Globally
|
|
122
|
+
|
|
123
|
+
To prevent toast notifications from showing globally, set the `toast` property to `true`. Otherwise, set it to `false` to enable toast notifications.
|
|
124
|
+
|
|
125
|
+
```javascript
|
|
126
|
+
clipx.disable.toast = false; // Set to true to disable toast notifications globally
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### 3. Set Custom Styles for Toast Notifications
|
|
130
|
+
|
|
131
|
+
Customize the appearance of toast notifications by providing CSS styles. For example, the following configuration sets a dark background with white text, padding, and rounded corners.
|
|
132
|
+
|
|
133
|
+
```javascript
|
|
134
|
+
clipx.setCustomStyles({
|
|
135
|
+
toast:
|
|
136
|
+
"background-color: #333; color: #fff; padding: 12px; border-radius: 5px;",
|
|
137
|
+
});
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### 4. Hide SVG Icon
|
|
141
|
+
|
|
142
|
+
To hide Svg Icon from toast
|
|
143
|
+
|
|
144
|
+
```css
|
|
145
|
+
.clipx-js-svg-icon {
|
|
146
|
+
display: none;
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Attaching ClipX Functionality
|
|
151
|
+
|
|
152
|
+
To bind ClipX.js functionality to elements, use the `attach` method with appropriate selectors. This method will enable clipboard operations on elements with the specified attributes or classes.
|
|
153
|
+
|
|
154
|
+
### Example: Using Data Attributes
|
|
155
|
+
|
|
156
|
+
Apply ClipX.js to elements with `data-clipx-text` or `data-clipx-target` attributes.
|
|
157
|
+
|
|
158
|
+
```javascript
|
|
159
|
+
clipx.attach("[data-clipx-text], [data-clipx-target]");
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Example: Using Class Names
|
|
163
|
+
|
|
164
|
+
Alternatively, apply ClipX.js to elements with specific classes.
|
|
165
|
+
|
|
166
|
+
```javascript
|
|
167
|
+
clipx.attach(".clipx, .copy-btn, .your-class");
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## Attributes Overview
|
|
173
|
+
|
|
174
|
+
### This All Are Attributes
|
|
175
|
+
|
|
176
|
+
- **`data-clipx-target`**: Element selector for text source.
|
|
177
|
+
- **`data-clipx-text`**: Static text to copy or cut.
|
|
178
|
+
- **`data-clipx-cut`**: Toggle cut operation.
|
|
179
|
+
- **`data-clipx-msg`**: Custom success message.
|
|
180
|
+
- **`data-clipx-toast`**: Show only toast, no text change.
|
|
181
|
+
- **`data-clipx-disable-msg`**: Disable element text change.
|
|
182
|
+
- **`data-clipx-disable-toast`**: Disable toast notification.
|
|
183
|
+
- **`data-clipx-toast-position`**: Position of the toast (top/bottom).
|
|
184
|
+
- **`data-clipx-duration`**: Duration of toast visibility.
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## Example
|
|
189
|
+
|
|
190
|
+
### `data-clipx-target`
|
|
191
|
+
|
|
192
|
+
**Description:** Specifies the target element whose text will be copied to the clipboard when the button is clicked.
|
|
193
|
+
|
|
194
|
+
**Example:**
|
|
195
|
+
|
|
196
|
+
```html
|
|
197
|
+
<button class="copy-btn" data-clipx-target="#text-to-copy">Copy Text</button>
|
|
198
|
+
<p id="text-to-copy">This is the text to be copied.</p>
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### `data-clipx-text`
|
|
202
|
+
|
|
203
|
+
**Description:** Defines a static text string that will be copied to the clipboard when the button is clicked.
|
|
204
|
+
|
|
205
|
+
**Example:**
|
|
206
|
+
|
|
207
|
+
```html
|
|
208
|
+
<button class="copy-btn" data-clipx-text="Static text to copy">
|
|
209
|
+
Copy Static Text
|
|
210
|
+
</button>
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### `data-clipx-cut`
|
|
214
|
+
|
|
215
|
+
**Description:** Cuts the text from the specified element, copying it to the clipboard and clearing the element's content.
|
|
216
|
+
|
|
217
|
+
**Example:**
|
|
218
|
+
|
|
219
|
+
```html
|
|
220
|
+
<textarea id="text-to-cut">This text will be cut.</textarea>
|
|
221
|
+
<button class="copy-btn" data-clipx-target="#text-to-cut" data-clipx-cut>
|
|
222
|
+
Cut Text
|
|
223
|
+
</button>
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### `data-clipx-msg`
|
|
227
|
+
|
|
228
|
+
**Description:** Copies the specified text to the clipboard and shows a toast notification with a custom message.
|
|
229
|
+
|
|
230
|
+
**Example:**
|
|
231
|
+
|
|
232
|
+
```html
|
|
233
|
+
<button
|
|
234
|
+
class="copy-btn"
|
|
235
|
+
data-clipx-text="Another static text"
|
|
236
|
+
data-clipx-msg="Text copied successfully!"
|
|
237
|
+
>
|
|
238
|
+
Copy with Custom Message
|
|
239
|
+
</button>
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### `data-clipx-toast`
|
|
243
|
+
|
|
244
|
+
**Description:** Displays a toast notification with the copied text. The button text remains unchanged.
|
|
245
|
+
|
|
246
|
+
**Example:**
|
|
247
|
+
|
|
248
|
+
```html
|
|
249
|
+
<button class="copy-btn" data-clipx-text="Text to copy" data-clipx-toast>
|
|
250
|
+
Copy with Toast Only
|
|
251
|
+
</button>
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### `data-clipx-disable-msg`
|
|
255
|
+
|
|
256
|
+
**Description:** Shows a toast notification without changing the button's text content.
|
|
257
|
+
|
|
258
|
+
**Example:**
|
|
259
|
+
|
|
260
|
+
```html
|
|
261
|
+
<button class="copy-btn" data-clipx-text="Text to copy" data-clipx-disable-msg>
|
|
262
|
+
Copy with Toast Only, No Text Change
|
|
263
|
+
</button>
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### `USE data-clipx-disable-toast & data-clipx-disable-msg`
|
|
267
|
+
|
|
268
|
+
**Description:** Copies the specified text to the clipboard without showing a toast notification And Changing Text Contents.
|
|
269
|
+
|
|
270
|
+
**Example:**
|
|
271
|
+
|
|
272
|
+
```html
|
|
273
|
+
<button
|
|
274
|
+
class="copy-btn"
|
|
275
|
+
data-clipx-text="Text to copy"
|
|
276
|
+
data-clipx-disable-toast
|
|
277
|
+
data-clipx-disable-msg
|
|
278
|
+
>
|
|
279
|
+
Copy without Toast & with Change Text
|
|
280
|
+
</button>
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### `data-clipx-disable-toast`
|
|
284
|
+
|
|
285
|
+
**Description:** Copies the specified text to the clipboard without showing a toast notification.
|
|
286
|
+
|
|
287
|
+
**Example:**
|
|
288
|
+
|
|
289
|
+
```html
|
|
290
|
+
<button
|
|
291
|
+
class="copy-btn"
|
|
292
|
+
data-clipx-text="Text to copy"
|
|
293
|
+
data-clipx-disable-toast
|
|
294
|
+
>
|
|
295
|
+
Copy without Toast
|
|
296
|
+
</button>
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
### `data-clipx-toast-position`
|
|
300
|
+
|
|
301
|
+
**Description:** Defines the position of the toast notification (top or bottom).
|
|
302
|
+
|
|
303
|
+
**Example:**
|
|
304
|
+
|
|
305
|
+
```html
|
|
306
|
+
<button
|
|
307
|
+
class="copy-btn"
|
|
308
|
+
data-clipx-text="Text to copy"
|
|
309
|
+
data-clipx-toast
|
|
310
|
+
data-clipx-toast-position="top"
|
|
311
|
+
>
|
|
312
|
+
Copy with Toast on Top
|
|
313
|
+
</button>
|
|
314
|
+
<button
|
|
315
|
+
class="copy-btn"
|
|
316
|
+
data-clipx-text="Text to copy"
|
|
317
|
+
data-clipx-toast
|
|
318
|
+
data-clipx-toast-position="bottom"
|
|
319
|
+
>
|
|
320
|
+
Copy with Toast on Bottom
|
|
321
|
+
</button>
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
### `data-clipx-duration`
|
|
325
|
+
|
|
326
|
+
**Description:** Sets the duration (in milliseconds) for which the toast notification is visible before it fades out.
|
|
327
|
+
|
|
328
|
+
**Example:**
|
|
329
|
+
|
|
330
|
+
```html
|
|
331
|
+
<button
|
|
332
|
+
class="copy-btn"
|
|
333
|
+
data-clipx-text="Text to copy"
|
|
334
|
+
data-clipx-toast
|
|
335
|
+
data-clipx-duration="3000"
|
|
336
|
+
>
|
|
337
|
+
Copy with 3 Seconds Toast
|
|
338
|
+
</button>
|
|
339
|
+
<button
|
|
340
|
+
class="copy-btn"
|
|
341
|
+
data-clipx-text="Text to copy"
|
|
342
|
+
data-clipx-duration="3000"
|
|
343
|
+
>
|
|
344
|
+
Copy with 3 Seconds Toast & Content Change
|
|
345
|
+
</button>
|
|
346
|
+
<button
|
|
347
|
+
class="copy-btn"
|
|
348
|
+
data-clipx-text="Text to copy"
|
|
349
|
+
data-clipx-disable-toast
|
|
350
|
+
data-clipx-duration="3000"
|
|
351
|
+
>
|
|
352
|
+
Copy 3 sec Content Change
|
|
353
|
+
</button>
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
---
|
|
357
|
+
|
|
358
|
+
## Demo || Get Start Code
|
|
359
|
+
|
|
360
|
+
```html
|
|
361
|
+
<h1>ClipX.js Demo</h1>
|
|
362
|
+
|
|
363
|
+
<button
|
|
364
|
+
class="copy-btn"
|
|
365
|
+
data-clipx-text="Static text to copy"
|
|
366
|
+
data-clipx-msg="Static text copied!"
|
|
367
|
+
>
|
|
368
|
+
Copy Static Text
|
|
369
|
+
</button>
|
|
370
|
+
|
|
371
|
+
<button class="copy-btn" data-clipx-target="#text-to-copy" data-clipx-cut>
|
|
372
|
+
Cut Text
|
|
373
|
+
</button>
|
|
374
|
+
<button class="copy-btn" data-clipx-target="#text-to-copy">Copy Text</button>
|
|
375
|
+
|
|
376
|
+
<p id="text-to-copy">This text will be cut and copied to the clipboard.</p>
|
|
377
|
+
|
|
378
|
+
<button
|
|
379
|
+
class="copy-btn"
|
|
380
|
+
data-clipx-text="Another static text"
|
|
381
|
+
data-clipx-toast
|
|
382
|
+
data-clipx-toast-position="bottom"
|
|
383
|
+
>
|
|
384
|
+
Copy with Toast Only
|
|
385
|
+
</button>
|
|
386
|
+
|
|
387
|
+
<button
|
|
388
|
+
class="copy-btn"
|
|
389
|
+
data-clipx-text="Text with 5 seconds toast"
|
|
390
|
+
data-clipx-toast
|
|
391
|
+
data-clipx-duration="5000"
|
|
392
|
+
>
|
|
393
|
+
Copy with 5 Seconds Toast
|
|
394
|
+
</button>
|
|
395
|
+
|
|
396
|
+
<script src="https://cdn.jsdelivr.net/npm/clipxjs/dist/clipx.min.js"></script>
|
|
397
|
+
<script>
|
|
398
|
+
// Initialize ClipX.js instance
|
|
399
|
+
var clipx = new clipx();
|
|
400
|
+
|
|
401
|
+
// Optional: Set custom styles for toast notifications
|
|
402
|
+
clipx.setCustomStyles({
|
|
403
|
+
toast:
|
|
404
|
+
"background-color: #333; color: #fff; padding: 12px; border-radius: 5px;",
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
// Attach ClipX.js functionality to elements
|
|
408
|
+
clipx.attach("[data-clipx-text], [data-clipx-target]");
|
|
409
|
+
</script>
|
|
410
|
+
```
|