@atlaskit/editor-plugin-paste-options-toolbar 12.0.4 → 12.0.5

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,5 +1,11 @@
1
1
  # @atlaskit/editor-plugin-paste-options-toolbar
2
2
 
3
+ ## 12.0.5
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
3
9
  ## 12.0.4
4
10
 
5
11
  ### Patch Changes
@@ -7,9 +7,10 @@ exports.isNotSingleLink = void 0;
7
7
  /**
8
8
  * Returns true if the given text node's sole mark is a `link` mark whose href
9
9
  * matches the node's text content exactly (i.e. the link label IS the URL).
10
+ * Or if the text content is a parseable URL.
10
11
  */
11
12
  var isUrlOnlyLinkTextNode = function isUrlOnlyLinkTextNode(node) {
12
- var _node$marks$0$attrs$h, _node$marks$0$attrs;
13
+ var _node$marks$0$attrs$h, _node$marks$0$attrs, _node$text;
13
14
  if (!node.isText) {
14
15
  return false;
15
16
  }
@@ -17,7 +18,29 @@ var isUrlOnlyLinkTextNode = function isUrlOnlyLinkTextNode(node) {
17
18
  return false;
18
19
  }
19
20
  var href = (_node$marks$0$attrs$h = (_node$marks$0$attrs = node.marks[0].attrs) === null || _node$marks$0$attrs === void 0 ? void 0 : _node$marks$0$attrs.href) !== null && _node$marks$0$attrs$h !== void 0 ? _node$marks$0$attrs$h : '';
20
- return node.text === href;
21
+
22
+ // Check if the text content is a URL
23
+ var textOfNode = (_node$text = node.text) !== null && _node$text !== void 0 ? _node$text : '';
24
+ var parseableUrl = isParseableUrl(textOfNode);
25
+ return node.text === href || parseableUrl;
26
+ };
27
+
28
+ /**
29
+ * Checks if a given string is parseable as a URL.
30
+ */
31
+ var isParseableUrl = function isParseableUrl(text) {
32
+ var _URL;
33
+ if (typeof ((_URL = URL) === null || _URL === void 0 ? void 0 : _URL.canParse) === 'function') {
34
+ return URL.canParse(text);
35
+ }
36
+
37
+ // Fallback for older environments
38
+ try {
39
+ new URL(text);
40
+ return true;
41
+ } catch (e) {
42
+ return false;
43
+ }
21
44
  };
22
45
 
23
46
  /**
@@ -1,9 +1,10 @@
1
1
  /**
2
2
  * Returns true if the given text node's sole mark is a `link` mark whose href
3
3
  * matches the node's text content exactly (i.e. the link label IS the URL).
4
+ * Or if the text content is a parseable URL.
4
5
  */
5
6
  const isUrlOnlyLinkTextNode = node => {
6
- var _node$marks$0$attrs$h, _node$marks$0$attrs;
7
+ var _node$marks$0$attrs$h, _node$marks$0$attrs, _node$text;
7
8
  if (!node.isText) {
8
9
  return false;
9
10
  }
@@ -11,7 +12,29 @@ const isUrlOnlyLinkTextNode = node => {
11
12
  return false;
12
13
  }
13
14
  const href = (_node$marks$0$attrs$h = (_node$marks$0$attrs = node.marks[0].attrs) === null || _node$marks$0$attrs === void 0 ? void 0 : _node$marks$0$attrs.href) !== null && _node$marks$0$attrs$h !== void 0 ? _node$marks$0$attrs$h : '';
14
- return node.text === href;
15
+
16
+ // Check if the text content is a URL
17
+ const textOfNode = (_node$text = node.text) !== null && _node$text !== void 0 ? _node$text : '';
18
+ const parseableUrl = isParseableUrl(textOfNode);
19
+ return node.text === href || parseableUrl;
20
+ };
21
+
22
+ /**
23
+ * Checks if a given string is parseable as a URL.
24
+ */
25
+ const isParseableUrl = text => {
26
+ var _URL;
27
+ if (typeof ((_URL = URL) === null || _URL === void 0 ? void 0 : _URL.canParse) === 'function') {
28
+ return URL.canParse(text);
29
+ }
30
+
31
+ // Fallback for older environments
32
+ try {
33
+ new URL(text);
34
+ return true;
35
+ } catch (e) {
36
+ return false;
37
+ }
15
38
  };
16
39
 
17
40
  /**
@@ -1,9 +1,10 @@
1
1
  /**
2
2
  * Returns true if the given text node's sole mark is a `link` mark whose href
3
3
  * matches the node's text content exactly (i.e. the link label IS the URL).
4
+ * Or if the text content is a parseable URL.
4
5
  */
5
6
  var isUrlOnlyLinkTextNode = function isUrlOnlyLinkTextNode(node) {
6
- var _node$marks$0$attrs$h, _node$marks$0$attrs;
7
+ var _node$marks$0$attrs$h, _node$marks$0$attrs, _node$text;
7
8
  if (!node.isText) {
8
9
  return false;
9
10
  }
@@ -11,7 +12,29 @@ var isUrlOnlyLinkTextNode = function isUrlOnlyLinkTextNode(node) {
11
12
  return false;
12
13
  }
13
14
  var href = (_node$marks$0$attrs$h = (_node$marks$0$attrs = node.marks[0].attrs) === null || _node$marks$0$attrs === void 0 ? void 0 : _node$marks$0$attrs.href) !== null && _node$marks$0$attrs$h !== void 0 ? _node$marks$0$attrs$h : '';
14
- return node.text === href;
15
+
16
+ // Check if the text content is a URL
17
+ var textOfNode = (_node$text = node.text) !== null && _node$text !== void 0 ? _node$text : '';
18
+ var parseableUrl = isParseableUrl(textOfNode);
19
+ return node.text === href || parseableUrl;
20
+ };
21
+
22
+ /**
23
+ * Checks if a given string is parseable as a URL.
24
+ */
25
+ var isParseableUrl = function isParseableUrl(text) {
26
+ var _URL;
27
+ if (typeof ((_URL = URL) === null || _URL === void 0 ? void 0 : _URL.canParse) === 'function') {
28
+ return URL.canParse(text);
29
+ }
30
+
31
+ // Fallback for older environments
32
+ try {
33
+ new URL(text);
34
+ return true;
35
+ } catch (e) {
36
+ return false;
37
+ }
15
38
  };
16
39
 
17
40
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-paste-options-toolbar",
3
- "version": "12.0.4",
3
+ "version": "12.0.5",
4
4
  "description": "Paste options toolbar for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -42,7 +42,7 @@
42
42
  "@atlaskit/icon": "^35.4.0",
43
43
  "@atlaskit/platform-feature-flags": "^1.1.0",
44
44
  "@atlaskit/primitives": "^19.0.0",
45
- "@atlaskit/tmp-editor-statsig": "^92.0.0",
45
+ "@atlaskit/tmp-editor-statsig": "^93.0.0",
46
46
  "@atlaskit/tokens": "^13.3.0",
47
47
  "@babel/runtime": "^7.0.0",
48
48
  "@compiled/react": "patch:@compiled/react@npm%3A0.20.0#~/.yarn/patches/@compiled-react-npm-0.20.0-a771aa67a6.patch",