Skip to content

Commit 8de71ec

Browse files
committed
update docs
1 parent 5258c5f commit 8de71ec

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

elements/pfe-clipboard/docs/index.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ tags:
1111
- component
1212
---
1313

14+
1415
::: section header
1516
# {{ title }}
1617
:::
@@ -38,6 +39,36 @@ npm install @patternfly/pfe-clipboard
3839
<pfe-clipboard role="button" tabindex="0"></pfe-clipboard>
3940
```
4041

42+
### Copy text from element
43+
<pfe-clipboard role="button" tabindex="0" copy-from="#textToCopy">
44+
<span slot="text">This will copy the text in the text field below!</span>
45+
<span slot="text--success">Making some copies!</span>
46+
</pfe-clipboard>
47+
<input type="text" id="textToCopy" value="This text will be copied!!11"></input>
48+
```html
49+
<pfe-clipboard role="button" tabindex="0" copy-from="#textToCopy">
50+
<span slot="text">This will copy the text in the text field below!</span>
51+
<span slot="text--success">Making some copies!</span>
52+
</pfe-clipboard>
53+
<input type="text" id="textToCopy" value="This text will be copied!!11"></input>
54+
```
55+
56+
### Copying text from property
57+
<pfe-clipboard role="button" tabindex="0" copy-from="property" id="propertyCopy"></pfe-clipboard>
58+
<script>
59+
window.addEventListener('load', function() {
60+
document.getElementById('propertyCopy').contentToCopy = ' <h2>Clipboard: with custom text & copying text from element</h2>\n <pfe-clipboard role="button" tabindex="0" copy-from="#textToCopy">\n <span slot="text">This will copy the text in the text field below!</span>\n <span slot="text--success">Making some copies!</span>\n </pfe-clipboard>\n <input type="text" id="textToCopy" value="This text will be copied!!11"></input>';
61+
})
62+
</script>
63+
```html
64+
<pfe-clipboard role="button" tabindex="0" copy-from="property" id="propertyCopy"></pfe-clipboard>
65+
<script>
66+
window.addEventListener('load', function() {
67+
document.getElementById('propertyCopy').contentToCopy = ' <h2>Clipboard: with custom text & copying text from element</h2>\n <pfe-clipboard role="button" tabindex="0" copy-from="#textToCopy">\n <span slot="text">This will copy the text in the text field below!</span>\n <span slot="text--success">Making some copies!</span>\n </pfe-clipboard>\n <input type="text" id="textToCopy" value="This text will be copied!!11"></input>';
68+
})
69+
</script>
70+
```
71+
4172
### Optionally hide the icon
4273
<pfe-clipboard no-icon role="button" tabindex="0"></pfe-clipboard>
4374
```html

0 commit comments

Comments
 (0)