@atlaskit/adf-schema 19.2.2 → 19.2.3

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/adf-schema
2
2
 
3
+ ## 19.2.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`a80f50a843c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/a80f50a843c) - [HOT-97158] Fix paste link heading issue
8
+
3
9
  ## 19.2.2
4
10
 
5
11
  ### Patch Changes
@@ -37,6 +37,32 @@ var getLinkAttrs = function getLinkAttrs(attribute) {
37
37
  };
38
38
  };
39
39
 
40
+ var getLinkAttrsWithCheck = function getLinkAttrsWithCheck(attribute) {
41
+ return function (domNode) {
42
+ var dom = domNode;
43
+ var hasTextOnlyChildren = Array.from(dom.childNodes).every(function (node) {
44
+ return node.nodeType === Node.TEXT_NODE || node.nodeName === 'SPAN';
45
+ });
46
+
47
+ if (hasTextOnlyChildren) {
48
+ var href = dom.getAttribute(attribute) || '';
49
+ var attrs = {
50
+ __confluenceMetadata: dom.hasAttribute('__confluenceMetadata') ? JSON.parse(dom.getAttribute('__confluenceMetadata') || '') : undefined
51
+ };
52
+
53
+ if ((0, _url.isSafeUrl)(href)) {
54
+ attrs.href = (0, _url.normalizeUrl)(href);
55
+ } else {
56
+ return false;
57
+ }
58
+
59
+ return attrs;
60
+ }
61
+
62
+ return false;
63
+ };
64
+ };
65
+
40
66
  var link = {
41
67
  excludes: "".concat(_groups.LINK, " ").concat(_groups.COLOR),
42
68
  // ED-5844 No multiple links in media node
@@ -60,8 +86,11 @@ var link = {
60
86
  }
61
87
  }, {
62
88
  tag: 'a[href]',
63
- context: 'paragraph/|heading/|mediaSingle/|taskItem/|decisionItem/',
89
+ context: 'mediaSingle/|taskItem/|decisionItem/',
64
90
  getAttrs: getLinkAttrs('href')
91
+ }, {
92
+ tag: 'a[href]',
93
+ getAttrs: getLinkAttrsWithCheck('href')
65
94
  }, {
66
95
  /**
67
96
  * When links aren't wrapped in a paragraph and due to
@@ -72,7 +101,7 @@ var link = {
72
101
  * This change comes through via prosemirror-model@1.9.1
73
102
  */
74
103
  tag: 'a[href]',
75
- getAttrs: getLinkAttrs('href'),
104
+ getAttrs: getLinkAttrsWithCheck('href'),
76
105
  getContent: function getContent(node, schema) {
77
106
  if (node instanceof HTMLAnchorElement) {
78
107
  var href = node.getAttribute('href');
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/adf-schema",
3
- "version": "19.2.2",
3
+ "version": "19.2.3",
4
4
  "sideEffects": false
5
5
  }
@@ -18,6 +18,28 @@ const getLinkAttrs = attribute => domNode => {
18
18
  return attrs;
19
19
  };
20
20
 
21
+ const getLinkAttrsWithCheck = attribute => domNode => {
22
+ const dom = domNode;
23
+ const hasTextOnlyChildren = Array.from(dom.childNodes).every(node => node.nodeType === Node.TEXT_NODE || node.nodeName === 'SPAN');
24
+
25
+ if (hasTextOnlyChildren) {
26
+ const href = dom.getAttribute(attribute) || '';
27
+ const attrs = {
28
+ __confluenceMetadata: dom.hasAttribute('__confluenceMetadata') ? JSON.parse(dom.getAttribute('__confluenceMetadata') || '') : undefined
29
+ };
30
+
31
+ if (isSafeUrl(href)) {
32
+ attrs.href = normalizeUrl(href);
33
+ } else {
34
+ return false;
35
+ }
36
+
37
+ return attrs;
38
+ }
39
+
40
+ return false;
41
+ };
42
+
21
43
  export const link = {
22
44
  excludes: `${LINK} ${COLOR}`,
23
45
  // ED-5844 No multiple links in media node
@@ -41,8 +63,11 @@ export const link = {
41
63
  }
42
64
  }, {
43
65
  tag: 'a[href]',
44
- context: 'paragraph/|heading/|mediaSingle/|taskItem/|decisionItem/',
66
+ context: 'mediaSingle/|taskItem/|decisionItem/',
45
67
  getAttrs: getLinkAttrs('href')
68
+ }, {
69
+ tag: 'a[href]',
70
+ getAttrs: getLinkAttrsWithCheck('href')
46
71
  }, {
47
72
  /**
48
73
  * When links aren't wrapped in a paragraph and due to
@@ -53,7 +78,7 @@ export const link = {
53
78
  * This change comes through via prosemirror-model@1.9.1
54
79
  */
55
80
  tag: 'a[href]',
56
- getAttrs: getLinkAttrs('href'),
81
+ getAttrs: getLinkAttrsWithCheck('href'),
57
82
  getContent: (node, schema) => {
58
83
  if (node instanceof HTMLAnchorElement) {
59
84
  const href = node.getAttribute('href');
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/adf-schema",
3
- "version": "19.2.2",
3
+ "version": "19.2.3",
4
4
  "sideEffects": false
5
5
  }
@@ -26,6 +26,32 @@ var getLinkAttrs = function getLinkAttrs(attribute) {
26
26
  };
27
27
  };
28
28
 
29
+ var getLinkAttrsWithCheck = function getLinkAttrsWithCheck(attribute) {
30
+ return function (domNode) {
31
+ var dom = domNode;
32
+ var hasTextOnlyChildren = Array.from(dom.childNodes).every(function (node) {
33
+ return node.nodeType === Node.TEXT_NODE || node.nodeName === 'SPAN';
34
+ });
35
+
36
+ if (hasTextOnlyChildren) {
37
+ var href = dom.getAttribute(attribute) || '';
38
+ var attrs = {
39
+ __confluenceMetadata: dom.hasAttribute('__confluenceMetadata') ? JSON.parse(dom.getAttribute('__confluenceMetadata') || '') : undefined
40
+ };
41
+
42
+ if (isSafeUrl(href)) {
43
+ attrs.href = normalizeUrl(href);
44
+ } else {
45
+ return false;
46
+ }
47
+
48
+ return attrs;
49
+ }
50
+
51
+ return false;
52
+ };
53
+ };
54
+
29
55
  export var link = {
30
56
  excludes: "".concat(LINK, " ").concat(COLOR),
31
57
  // ED-5844 No multiple links in media node
@@ -49,8 +75,11 @@ export var link = {
49
75
  }
50
76
  }, {
51
77
  tag: 'a[href]',
52
- context: 'paragraph/|heading/|mediaSingle/|taskItem/|decisionItem/',
78
+ context: 'mediaSingle/|taskItem/|decisionItem/',
53
79
  getAttrs: getLinkAttrs('href')
80
+ }, {
81
+ tag: 'a[href]',
82
+ getAttrs: getLinkAttrsWithCheck('href')
54
83
  }, {
55
84
  /**
56
85
  * When links aren't wrapped in a paragraph and due to
@@ -61,7 +90,7 @@ export var link = {
61
90
  * This change comes through via prosemirror-model@1.9.1
62
91
  */
63
92
  tag: 'a[href]',
64
- getAttrs: getLinkAttrs('href'),
93
+ getAttrs: getLinkAttrsWithCheck('href'),
65
94
  getContent: function getContent(node, schema) {
66
95
  if (node instanceof HTMLAnchorElement) {
67
96
  var href = node.getAttribute('href');
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/adf-schema",
3
- "version": "19.2.2",
3
+ "version": "19.2.3",
4
4
  "sideEffects": false
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/adf-schema",
3
- "version": "19.2.2",
3
+ "version": "19.2.3",
4
4
  "description": "Shared package that contains the ADF-schema (json) and ProseMirror node/mark specs",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"