@cocreate/clipboard 1.5.0 → 1.7.0

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/CONTRIBUTING.md CHANGED
@@ -13,7 +13,7 @@ Fork the [project on Github](https://github.com/CoCreate-app/CoCreate-clipboard)
13
13
  ```
14
14
  git clone https://github.com/contributor/CoCreate-clipboard.git
15
15
  cd CoCreate-clipboard
16
- git remote add upstream https://github.com/CoCreate-app/CoCreate-clipboard.git
16
+ git remote add upstream https://gitlab.com/cocreatejs/CoCreate-clipboard.git
17
17
  ```
18
18
 
19
19
  ## Create a Topic Branch
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/clipboard",
3
- "version": "1.5.0",
3
+ "version": "1.7.0",
4
4
  "description": "A simple clipboard component in vanilla javascript. Easily configured using HTML5 data-attributes and/or JavaScript API.",
5
5
  "keywords": [
6
6
  "clipboard",
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "repository": {
24
24
  "type": "git",
25
- "url": "git+https://github.com/CoCreate-app/CoCreate-clipboard.git"
25
+ "url": "git+https://gitlab.com/cocreatejs/CoCreate-clipboard.git"
26
26
  },
27
27
  "author": "CoCreate LLC",
28
28
  "license": "MIT",
@@ -38,11 +38,11 @@
38
38
  "dependencies": {
39
39
  "@cocreate/actions": "^1.24.0",
40
40
  "@cocreate/element-prototype": "^1.35.0",
41
- "@cocreate/observer": "^1.22.0",
42
- "@cocreate/utils": "^1.52.0"
41
+ "@cocreate/observer": "^1.23.0",
42
+ "@cocreate/utils": "^1.54.0"
43
43
  },
44
44
  "devDependencies": {
45
- "@cocreate/webpack": "^1.8.0"
45
+ "@cocreate/webpack": "^1.9.0"
46
46
  },
47
47
  "allowScripts": {
48
48
  "@cocreate/actions@1.21.4": true,
package/src/index.js CHANGED
@@ -63,17 +63,9 @@ async function clipboard(element, elements) {
63
63
  try {
64
64
  const clipboardItems = [];
65
65
 
66
- for (let element of elements) {
67
- let value = await element.getValue();
68
- const valueType = element.getAttribute("clipboard-value-type");
69
- if (valueType === "innerText") {
70
- value = value.replace(/<[^>]*>/g, "");
71
- new ClipboardItem({
72
- "text/plain": new Blob([value], {
73
- type: "text/plain"
74
- })
75
- });
76
- } else if (typeof value === "string") {
66
+ for (const target of elements) {
67
+ const value = await target.getValue();
68
+ if (typeof value === "string") {
77
69
  // Handle string content as plain text
78
70
  clipboardItems.push(
79
71
  new ClipboardItem({
@@ -87,7 +79,16 @@ async function clipboard(element, elements) {
87
79
  // Handle Blob content directly
88
80
  clipboardItems.push(
89
81
  new ClipboardItem({
90
- [value.type]: value
82
+ [value.type || "application/octet-stream"]: value
83
+ })
84
+ );
85
+ } else if (value !== undefined) {
86
+ const content = JSON.stringify(value, null, 2);
87
+ clipboardItems.push(
88
+ new ClipboardItem({
89
+ "text/plain": new Blob([content], {
90
+ type: "text/plain"
91
+ })
91
92
  })
92
93
  );
93
94
  } else {
@@ -118,7 +119,7 @@ Actions.init([
118
119
  name: "clipboard",
119
120
  endEvent: "clipboarded",
120
121
  callback: (action) => {
121
- queryClipboardElement(action);
122
+ queryClipboardElement(action.element || action);
122
123
  }
123
124
  }
124
125
  ]);