cavalion-js 1.0.81 → 1.0.82

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/CHANGELOG.md CHANGED
@@ -1,4 +1,8 @@
1
- ### 2024/10/25 - 1.0.80
1
+ ### 2024/11/08 - 1.0.82
2
+
3
+ * Service build in favor of cavalion-code
4
+
5
+ ### 2024/11/01 - 1.0.81
2
6
 
3
7
  * Adds Array.sortValues
4
8
  * Adds Date.format (USE IT! ;-))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cavalion-js",
3
- "version": "1.0.81",
3
+ "version": "1.0.82",
4
4
  "description": "Cavalion common JavaScript library",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -0,0 +1,47 @@
1
+ define([], () => ({
2
+ copy: (text) => {
3
+ // Use the Async Clipboard API when available. Requires a secure browsing
4
+ // context (i.e. HTTPS)
5
+ if (navigator.clipboard) {
6
+ return navigator.clipboard.writeText(text).then(() => text).
7
+ catch(function (err) {
8
+ throw (err !== undefined ? err : new DOMException('The request is not allowed', 'NotAllowedError'))
9
+ })
10
+ }
11
+
12
+ // ...Otherwise, use document.execCommand() fallback
13
+
14
+ // Put the text to copy into a <span>
15
+ var span = document.createElement('span')
16
+ span.textContent = text
17
+
18
+ // Preserve consecutive spaces and newlines
19
+ span.style.whiteSpace = 'pre'
20
+ span.style.webkitUserSelect = 'auto'
21
+ span.style.userSelect = 'all'
22
+
23
+ // Add the <span> to the page
24
+ document.body.appendChild(span)
25
+
26
+ // Make a selection object representing the range of text selected by the user
27
+ var selection = window.getSelection()
28
+ var range = window.document.createRange()
29
+ selection.removeAllRanges()
30
+ range.selectNode(span)
31
+ selection.addRange(range)
32
+
33
+ // Copy text to the clipboard
34
+ var success = false
35
+ try {
36
+ success = window.document.execCommand('copy')
37
+ } catch(err) {
38
+ console.log('error', err)
39
+ }
40
+
41
+ // Cleanup
42
+ selection.removeAllRanges()
43
+ window.document.body.removeChild(span)
44
+
45
+ return success ? Promise.resolve(text) : Promise.reject(new DOMException('The request is not allowed', 'NotAllowedError'))
46
+ }
47
+ }));
package/src/util/Text.js CHANGED
@@ -2222,9 +2222,4 @@ diff_match_patch.patch_obj.prototype.toString = function() {
2222
2222
  return diff_match_patch;
2223
2223
  });
2224
2224
 
2225
- define(function(require) {
2226
-
2227
- const dmp = require("diff-match-patch");
2228
-
2229
- return { dmp: dmp }
2230
- })
2225
+ define(["diff-match-patch"], (dmp) => ({ dmp: dmp }));