cavalion-js 1.0.80 → 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/.md CHANGED
@@ -25,6 +25,7 @@
25
25
  - **[util](src/:/)** / [net](src/util/:/) / [HttpStatusCode.js](src/util/net/:) - [Url.js](src/util/net/:)
26
26
  - [Ajax.js](src/util/:) - [Command.js](src/util/:)
27
27
  - [Browser.js](src/util/:) - [CssSelectorParser.js](src/util/:)
28
+ - [Clipboard.js](src/util/:)
28
29
  - [DocumentHook.js](src/util/:) - [Event.js](src/util/:) - [Fullscreen.js](src/util/:)
29
30
  - [HotkeyManager.js](src/util/:) - [HtmlElement.js](src/util/:)
30
31
  - [Hash.js](src/util/:)
package/CHANGELOG.md CHANGED
@@ -1,10 +1,13 @@
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! ;-))
5
9
  * Fixes/prepares js.nameOf() for some exotic use case with dropped files
6
10
 
7
-
8
11
  ### 2024/07/07 - 1.0.79
9
12
 
10
13
  * Removes `Array.prototype.last` and -`first`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cavalion-js",
3
- "version": "1.0.80",
3
+ "version": "1.0.82",
4
4
  "description": "Cavalion common JavaScript library",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -19,7 +19,7 @@ define(function(require) {
19
19
  var DeferredNode = require("./node/Deferred");
20
20
  var PromiseNode = require("./node/Promise");
21
21
 
22
- js.override(Node, {
22
+ Method.override(Node, {
23
23
  create: function(value, key, NodeClass) {
24
24
  var line;
25
25
 
@@ -5,6 +5,7 @@ define(function(require) {
5
5
  var ObjectNode = require("../Object");
6
6
  var Node = require("../../Node");
7
7
  var js = require("js");
8
+ var Method = require("js/Method");
8
9
 
9
10
  return (ComponentNode = ComponentNode(require, {
10
11
  inherits: ObjectNode,
@@ -31,12 +32,12 @@ define(function(require) {
31
32
  statics: {
32
33
  initialize: function() {
33
34
  /*- FIXME Introduce some registration infra at Node */
34
- js.override(Node, "create", function(value, key, NodeClass) {
35
+ Method.override(Node, "create", function(value, key, NodeClass) {
35
36
  if(NodeClass === undefined && value instanceof Component) {
36
37
  /*- Yee, use the specific Component impl */
37
38
  return new ComponentNode(value, key);
38
39
  }
39
- return js.inherited(this, arguments);
40
+ return Method.callInherited(this, arguments);
40
41
  });
41
42
  }
42
43
  }
package/src/js/_js.js CHANGED
@@ -24,11 +24,15 @@ define(function(require) {
24
24
  return (js = {
25
25
 
26
26
  // handy-dandy
27
- inh: Method.callInherited,
28
- inherited: Method.callInherited,
29
- override: Method.override,
30
- connect: Method.connect,
31
- disconnect: Method.disconnect,
27
+ // inh: Method.callInherited,
28
+ // inherited: Method.callInherited,
29
+
30
+ override: function override(obj, method, factory) {
31
+ obj[method] = factory(obj[method]);
32
+ },
33
+
34
+ // connect: Method.connect,
35
+ // disconnect: Method.disconnect,
32
36
  args2strs: Method.args2strs,
33
37
  copy_args: Method.copy_args,
34
38
 
@@ -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
+ }));
@@ -2,7 +2,7 @@ define(function(require) {
2
2
 
3
3
  var Browser = require("./Browser");
4
4
  var singleSeperator = (str, sep) => str.split(sep).filter(_ => _).join(sep);
5
-
5
+
6
6
  var HtmlElement = {
7
7
 
8
8
  defaultComputedStyleObj : {
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 }));