@atlaskit/adf-schema 19.2.3 → 19.3.2

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/index.js +12 -0
  3. package/dist/cjs/schema/create-schema.js +5 -1
  4. package/dist/cjs/schema/default-schema.js +4 -8
  5. package/dist/cjs/schema/marks/link.js +1 -54
  6. package/dist/cjs/schema/nodes/emoji.js +4 -0
  7. package/dist/cjs/schema/nodes/panel.js +59 -28
  8. package/dist/cjs/schema/nodes/paragraph.js +167 -24
  9. package/dist/cjs/utils/index.js +12 -0
  10. package/dist/cjs/utils/url.js +55 -3
  11. package/dist/cjs/version.json +1 -1
  12. package/dist/es2019/index.js +1 -1
  13. package/dist/es2019/schema/create-schema.js +3 -1
  14. package/dist/es2019/schema/default-schema.js +5 -8
  15. package/dist/es2019/schema/marks/link.js +1 -49
  16. package/dist/es2019/schema/nodes/emoji.js +4 -0
  17. package/dist/es2019/schema/nodes/panel.js +45 -25
  18. package/dist/es2019/schema/nodes/paragraph.js +162 -24
  19. package/dist/es2019/utils/index.js +1 -1
  20. package/dist/es2019/utils/url.js +50 -3
  21. package/dist/es2019/version.json +1 -1
  22. package/dist/esm/index.js +1 -1
  23. package/dist/esm/schema/create-schema.js +3 -1
  24. package/dist/esm/schema/default-schema.js +5 -8
  25. package/dist/esm/schema/marks/link.js +1 -53
  26. package/dist/esm/schema/nodes/emoji.js +4 -0
  27. package/dist/esm/schema/nodes/panel.js +55 -28
  28. package/dist/esm/schema/nodes/paragraph.js +166 -24
  29. package/dist/esm/utils/index.js +1 -1
  30. package/dist/esm/utils/url.js +50 -3
  31. package/dist/esm/version.json +1 -1
  32. package/dist/types/index.d.ts +1 -1
  33. package/dist/types/schema/create-schema.d.ts +1 -0
  34. package/dist/types/schema/default-schema.d.ts +1 -1
  35. package/dist/types/schema/nodes/panel.d.ts +1 -1
  36. package/dist/types/utils/index.d.ts +1 -1
  37. package/dist/types/utils/url.d.ts +7 -2
  38. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @atlaskit/adf-schema
2
2
 
3
+ ## 19.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`f4ce830a2f2`](https://bitbucket.org/atlassian/atlassian-frontend/commits/f4ce830a2f2) - [HOT-97158] Fix paste link applying marks on block nodes
8
+
9
+ ## 19.3.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [`93da0afefce`](https://bitbucket.org/atlassian/atlassian-frontend/commits/93da0afefce) - CETI-78 Change panel nodeSpec to handle paste when feature flag is off
14
+ - [`971845eac0d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/971845eac0d) - CETI-96 Added new rule to emoji to solve the duplicate icon issue when we copy from renderer
15
+ - [`e856b56fd31`](https://bitbucket.org/atlassian/atlassian-frontend/commits/e856b56fd31) - ED-13669 reuse same links normalization method in plugin and adf schema
16
+
3
17
  ## 19.2.3
4
18
 
5
19
  ### Patch Changes
package/dist/cjs/index.js CHANGED
@@ -1059,6 +1059,18 @@ Object.defineProperty(exports, "isSafeUrl", {
1059
1059
  return _utils.isSafeUrl;
1060
1060
  }
1061
1061
  });
1062
+ Object.defineProperty(exports, "linkify", {
1063
+ enumerable: true,
1064
+ get: function get() {
1065
+ return _utils.linkify;
1066
+ }
1067
+ });
1068
+ Object.defineProperty(exports, "linkifyMatch", {
1069
+ enumerable: true,
1070
+ get: function get() {
1071
+ return _utils.linkifyMatch;
1072
+ }
1073
+ });
1062
1074
  Object.defineProperty(exports, "normalizeHexColor", {
1063
1075
  enumerable: true,
1064
1076
  get: function get() {
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "__esModule", {
8
8
  exports.createSchema = createSchema;
9
9
  exports.sanitizeNodes = sanitizeNodes;
10
10
  exports.sanitizeNodeSpecContent = sanitizeNodeSpecContent;
11
+ exports.allowCustomPanel = void 0;
11
12
 
12
13
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
14
 
@@ -351,4 +352,7 @@ function isContentSupported(nodes, contentKey) {
351
352
  }
352
353
 
353
354
  return false;
354
- }
355
+ }
356
+
357
+ var allowCustomPanel = true;
358
+ exports.allowCustomPanel = allowCustomPanel;
@@ -9,8 +9,6 @@ var _panel = require("./nodes/panel");
9
9
 
10
10
  var _layoutSection = require("./nodes/layout-section");
11
11
 
12
- var _dataConsumer = require("./marks/data-consumer");
13
-
14
12
  var _createSchema = require("./create-schema");
15
13
 
16
14
  var _nodes = require("./nodes");
@@ -18,8 +16,8 @@ var _nodes = require("./nodes");
18
16
  var getDefaultSchemaConfig = function getDefaultSchemaConfig() {
19
17
  var defaultSchemaConfig = {
20
18
  nodes: ['doc', 'paragraph', 'text', 'bulletList', 'orderedList', 'listItem', 'heading', 'blockquote', 'codeBlock', 'panel', 'rule', 'image', 'mention', 'media', 'mediaGroup', 'mediaSingle', 'mediaInline', 'confluenceUnsupportedBlock', 'confluenceUnsupportedInline', 'confluenceJiraIssue', 'expand', 'nestedExpand', 'extension', 'inlineExtension', 'bodiedExtension', 'hardBreak', 'emoji', 'table', 'tableCell', 'tableHeader', 'tableRow', 'decisionList', 'decisionItem', 'taskList', 'taskItem', 'unknownBlock', 'date', 'status', 'placeholder', 'layoutSection', 'layoutColumn', 'inlineCard', 'blockCard', 'embedCard', 'unsupportedBlock', 'unsupportedInline'],
21
- marks: ['link', 'em', 'strong', 'strike', 'subsup', 'underline', 'code', 'textColor', 'confluenceInlineComment', 'breakout', 'alignment', 'indentation', 'annotation', 'unsupportedMark', 'unsupportedNodeAttribute', 'typeAheadQuery' // https://product-fabric.atlassian.net/browse/ED-10214,
22
- ]
19
+ marks: ['link', 'em', 'strong', 'strike', 'subsup', 'underline', 'code', 'textColor', 'confluenceInlineComment', 'breakout', 'alignment', 'indentation', 'annotation', 'unsupportedMark', 'unsupportedNodeAttribute', 'typeAheadQuery', // https://product-fabric.atlassian.net/browse/ED-10214,
20
+ 'dataConsumer']
23
21
  };
24
22
  return defaultSchemaConfig;
25
23
  };
@@ -33,13 +31,11 @@ var getSchemaBasedOnStage = function getSchemaBasedOnStage() {
33
31
 
34
32
  if (stage === 'stage0') {
35
33
  defaultSchemaConfig.customNodeSpecs = {
36
- panel: _panel.customPanel,
34
+ panel: (0, _panel.customPanel)(_createSchema.allowCustomPanel),
37
35
  mediaSingle: _nodes.mediaSingleWithCaption,
38
36
  layoutSection: _layoutSection.layoutSectionWithSingleColumn
39
37
  };
40
- defaultSchemaConfig.customMarkSpecs = {
41
- dataConsumer: _dataConsumer.dataConsumer
42
- };
38
+ defaultSchemaConfig.customMarkSpecs = {};
43
39
  defaultSchemaConfig.nodes.push('caption');
44
40
  defaultSchemaConfig.nodes.push('mediaInline');
45
41
  }
@@ -9,8 +9,6 @@ exports.toJSON = exports.link = void 0;
9
9
 
10
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
11
 
12
- var _prosemirrorModel = require("prosemirror-model");
13
-
14
12
  var _groups = require("../groups");
15
13
 
16
14
  var _url = require("../../utils/url");
@@ -37,32 +35,6 @@ var getLinkAttrs = function getLinkAttrs(attribute) {
37
35
  };
38
36
  };
39
37
 
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
-
66
38
  var link = {
67
39
  excludes: "".concat(_groups.LINK, " ").concat(_groups.COLOR),
68
40
  // ED-5844 No multiple links in media node
@@ -80,39 +52,14 @@ var link = {
80
52
  contentElement: function contentElement(node) {
81
53
  var clone = node.cloneNode(true);
82
54
  clone.removeAttribute('data-block-link');
55
+ clone.setAttribute('data-skip-paste', 'true');
83
56
  var wrapper = document.createElement('div');
84
57
  wrapper.appendChild(clone);
85
58
  return wrapper;
86
59
  }
87
60
  }, {
88
61
  tag: 'a[href]',
89
- context: 'mediaSingle/|taskItem/|decisionItem/',
90
62
  getAttrs: getLinkAttrs('href')
91
- }, {
92
- tag: 'a[href]',
93
- getAttrs: getLinkAttrsWithCheck('href')
94
- }, {
95
- /**
96
- * When links aren't wrapped in a paragraph and due to
97
- * the odd nature of how our schema is set up, prosemirror will
98
- * add the link to the paragraph node itself where it should be on
99
- * the text node, this satisfies our schema because link is allowed
100
- * in many places (e.g. listitem)
101
- * This change comes through via prosemirror-model@1.9.1
102
- */
103
- tag: 'a[href]',
104
- getAttrs: getLinkAttrsWithCheck('href'),
105
- getContent: function getContent(node, schema) {
106
- if (node instanceof HTMLAnchorElement) {
107
- var href = node.getAttribute('href');
108
- var text = node.innerText;
109
- return _prosemirrorModel.Fragment.from(schema.nodes.paragraph.createChecked(undefined, schema.text(text, [schema.marks.link.create({
110
- href: href
111
- })])));
112
- }
113
-
114
- return _prosemirrorModel.Fragment.empty;
115
- }
116
63
  }],
117
64
  toDOM: function toDOM(node, isInline) {
118
65
  var attrs = Object.keys(node.attrs).reduce(function (attrs, key) {
@@ -32,6 +32,10 @@ var emoji = {
32
32
  text: dom.getAttribute('data-emoji-text') || emoji.attrs.text.default
33
33
  };
34
34
  }
35
+ }, // Handle copy/paste beautiful panel from renderer />
36
+ {
37
+ tag: 'div.ak-editor-panel__icon',
38
+ ignore: true
35
39
  }, // Handle copy/paste from old <ac:emoticon />
36
40
  {
37
41
  tag: 'img[data-emoticon-name]',
@@ -1,9 +1,18 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
8
  exports.panel = exports.customPanel = exports.PanelType = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
13
+
14
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
15
+
7
16
  var PanelType;
8
17
  exports.PanelType = PanelType;
9
18
 
@@ -17,12 +26,8 @@ exports.PanelType = PanelType;
17
26
  PanelType["CUSTOM"] = "custom";
18
27
  })(PanelType || (exports.PanelType = PanelType = {}));
19
28
 
20
- //TODO: ED-10445 rename to panel and merge with the other panel node spec, after emoji panels moved to full schema
21
- var customPanel = {
22
- group: 'block',
23
- content: '(paragraph | heading | bulletList | orderedList | blockCard | unsupportedBlock)+',
24
- marks: 'unsupportedMark unsupportedNodeAttribute',
25
- attrs: {
29
+ var getDefaultAttrs = function getDefaultAttrs() {
30
+ var attrs = {
26
31
  panelType: {
27
32
  default: 'info'
28
33
  },
@@ -32,30 +37,56 @@ var customPanel = {
32
37
  panelColor: {
33
38
  default: null
34
39
  }
35
- },
36
- parseDOM: [{
37
- tag: 'div[data-panel-type]',
38
- getAttrs: function getAttrs(dom) {
39
- return {
40
- panelType: dom.getAttribute('data-panel-type'),
41
- panelIcon: dom.getAttribute('data-panel-icon'),
42
- panelColor: dom.getAttribute('data-panel-color')
43
- };
44
- }
45
- }],
46
- toDOM: function toDOM(node) {
47
- var _node$attrs = node.attrs,
48
- panelType = _node$attrs.panelType,
49
- panelIcon = _node$attrs.panelIcon,
50
- panelColor = _node$attrs.panelColor;
51
- var attrs = {
52
- 'data-panel-type': panelType,
53
- 'data-panel-icon': panelIcon,
54
- 'data-panel-color': panelColor
55
- };
56
- return ['div', attrs, ['div', {}, 0]];
40
+ };
41
+ return attrs;
42
+ };
43
+
44
+ var getDomAttrs = function getDomAttrs(nodeAttrs) {
45
+ var attrs = {
46
+ 'data-panel-type': nodeAttrs.panelType,
47
+ 'data-panel-icon': nodeAttrs.panelIcon,
48
+ 'data-panel-color': nodeAttrs.panelColor
49
+ };
50
+ return attrs;
51
+ };
52
+
53
+ var getParseDOMAttrs = function getParseDOMAttrs(allowCustomPanel, dom) {
54
+ var parseDOMAttrs = {
55
+ panelType: dom.getAttribute('data-panel-type')
56
+ };
57
+
58
+ if (allowCustomPanel) {
59
+ parseDOMAttrs = _objectSpread(_objectSpread({}, parseDOMAttrs), {}, {
60
+ panelIcon: dom.getAttribute('data-panel-icon'),
61
+ panelColor: dom.getAttribute('data-panel-color')
62
+ });
63
+ } else {
64
+ parseDOMAttrs.panelType = parseDOMAttrs.panelType === PanelType.CUSTOM ? PanelType.INFO : parseDOMAttrs.panelType;
57
65
  }
66
+
67
+ return parseDOMAttrs;
58
68
  };
69
+
70
+ var customPanel = function customPanel(allowCustomPanel) {
71
+ var panelNodeSpec = {
72
+ group: 'block',
73
+ content: '(paragraph | heading | bulletList | orderedList | blockCard | unsupportedBlock)+',
74
+ marks: 'unsupportedMark unsupportedNodeAttribute',
75
+ attrs: getDefaultAttrs(),
76
+ parseDOM: [{
77
+ tag: 'div[data-panel-type]',
78
+ getAttrs: function getAttrs(dom) {
79
+ return getParseDOMAttrs(allowCustomPanel, dom);
80
+ }
81
+ }],
82
+ toDOM: function toDOM(node) {
83
+ var attrs = getDomAttrs(node.attrs);
84
+ return ['div', attrs, ['div', {}, 0]];
85
+ }
86
+ };
87
+ return panelNodeSpec;
88
+ };
89
+
59
90
  exports.customPanel = customPanel;
60
91
  var panel = {
61
92
  group: 'block',
@@ -5,30 +5,109 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.paragraph = void 0;
7
7
 
8
- /**
9
- * @name paragraph_node
10
- */
11
-
12
- /**
13
- * @name paragraph_with_no_marks_node
14
- */
15
-
16
- /**
17
- * NOTE: Need this because TS is too smart and inline everything.
18
- * So we need to give them separate identity.
19
- * Probably there's a way to solve it but that will need time and exploration.
20
- * // http://bit.ly/2raXFX5
21
- * type T1 = X | Y
22
- * type T2 = A | T1 | B // T2 = A | X | Y | B
23
- */
24
-
25
- /**
26
- * @name paragraph_with_alignment_node
27
- */
28
-
29
- /**
30
- * @name paragraph_with_indentation_node
31
- */
8
+ var _prosemirrorModel = require("prosemirror-model");
9
+
10
+ var _url = require("../../utils/url");
11
+
12
+ var getLinkContent = function getLinkContent(node, schema) {
13
+ if (!(node instanceof HTMLAnchorElement)) {
14
+ return _prosemirrorModel.Fragment.empty;
15
+ }
16
+
17
+ var href = node.getAttribute('href') || '';
18
+ var text = node.innerText;
19
+
20
+ if (!text || text.length === 0) {
21
+ return _prosemirrorModel.Fragment.empty;
22
+ }
23
+
24
+ var marks = (0, _url.isSafeUrl)(href) ? [schema.marks.link.create({
25
+ href: href
26
+ })] : [];
27
+ var textNode = schema.text(text, marks);
28
+ return _prosemirrorModel.Fragment.from(textNode);
29
+ };
30
+
31
+ var blockTags = {
32
+ address: true,
33
+ article: true,
34
+ aside: true,
35
+ blockquote: true,
36
+ canvas: true,
37
+ dd: true,
38
+ div: true,
39
+ dl: true,
40
+ fieldset: true,
41
+ figcaption: true,
42
+ figure: true,
43
+ footer: true,
44
+ form: true,
45
+ h1: true,
46
+ h2: true,
47
+ h3: true,
48
+ h4: true,
49
+ h5: true,
50
+ h6: true,
51
+ header: true,
52
+ hgroup: true,
53
+ hr: true,
54
+ li: true,
55
+ noscript: true,
56
+ ol: true,
57
+ output: true,
58
+ p: true,
59
+ pre: true,
60
+ section: true,
61
+ table: true,
62
+ tfoot: true,
63
+ ul: true
64
+ };
65
+
66
+ var isListItemNode = function isListItemNode(node) {
67
+ return Boolean(node && node.nodeName.toLowerCase() === 'li');
68
+ };
69
+
70
+ var isTextNode = function isTextNode(node) {
71
+ return Boolean(node && node.nodeType === Node.TEXT_NODE);
72
+ };
73
+
74
+ var isImageNode = function isImageNode(node) {
75
+ return Boolean(node && node.nodeName.toLowerCase() === 'img');
76
+ };
77
+
78
+ var hasInlineImage = function hasInlineImage(node) {
79
+ if (!node) {
80
+ return false;
81
+ }
82
+
83
+ return Array.from(node.childNodes).some(function (child) {
84
+ var isImage = isImageNode(child);
85
+
86
+ if (!isImage && child.childNodes) {
87
+ return Array.from(node.childNodes).some(function (node) {
88
+ return hasInlineImage(node);
89
+ });
90
+ }
91
+
92
+ return isImage;
93
+ });
94
+ };
95
+
96
+ var hasWhiteSpacePre = function hasWhiteSpacePre(node) {
97
+ return Boolean(node instanceof HTMLElement && node.style.whiteSpace === 'pre');
98
+ };
99
+
100
+ var hasFontFamilyMonospace = function hasFontFamilyMonospace(node) {
101
+ return Boolean(node instanceof HTMLElement && node.style.fontFamily.includes('monospace'));
102
+ };
103
+
104
+ var isBlockLevelNode = function isBlockLevelNode(node) {
105
+ return Boolean(node && blockTags.hasOwnProperty(node.nodeName.toLowerCase()));
106
+ };
107
+
108
+ var NOT_INTERNAL_LINKS = [':not([data-inline-card])', ':not([data-block-card])', ':not([data-block-link])', ':not([data-skip-paste])'].join('');
109
+ var ANCHOR_LINK = "a[href]".concat(NOT_INTERNAL_LINKS);
110
+ var NOT_INTERNAL_ELEMENTS = [':not(.code-block)', ':not([data-node-type])', ':not([data-embed-card])', ':not([data-layout-section])', ':not([data-pm-slice])', ':not([data-mark-type])'].join('');
32
111
  var pDOM = ['p', 0];
33
112
  var paragraph = {
34
113
  selectable: false,
@@ -37,6 +116,70 @@ var paragraph = {
37
116
  marks: 'strong code em link strike subsup textColor typeAheadQuery underline confluenceInlineComment action annotation unsupportedMark unsupportedNodeAttribute dataConsumer',
38
117
  parseDOM: [{
39
118
  tag: 'p'
119
+ }, {
120
+ tag: "div".concat(NOT_INTERNAL_ELEMENTS, ", li:not([data-pm-slice])"),
121
+ priority: 100,
122
+ getAttrs: function getAttrs(node) {
123
+ if (!(node instanceof Node)) {
124
+ return false;
125
+ }
126
+
127
+ var isCodeBlock = hasWhiteSpacePre(node) || hasFontFamilyMonospace(node);
128
+
129
+ if (isCodeBlock || !node.hasChildNodes()) {
130
+ return false;
131
+ }
132
+
133
+ var hasInlineChildren = Array.from(node.childNodes).every(function (child) {
134
+ return !isBlockLevelNode(child) && // IMG is considered block for mediaSingle
135
+ !isImageNode(child);
136
+ });
137
+
138
+ if (!hasInlineChildren) {
139
+ return false;
140
+ }
141
+
142
+ if ( // We can skip this rule for pure list items
143
+ isListItemNode(node) && Array.from(node.childNodes).every(isTextNode)) {
144
+ return false;
145
+ }
146
+
147
+ return null;
148
+ }
149
+ }, {
150
+ tag: ":not(span) + ".concat(ANCHOR_LINK),
151
+ priority: 100,
152
+ getContent: getLinkContent
153
+ }, {
154
+ tag: ":not(span) > ".concat(ANCHOR_LINK, ":first-child"),
155
+ getAttrs: function getAttrs(node) {
156
+ if (!(node instanceof Node)) {
157
+ return false;
158
+ }
159
+
160
+ if (isBlockLevelNode(node.firstChild)) {
161
+ return null;
162
+ }
163
+
164
+ if (hasInlineImage(node)) {
165
+ return false;
166
+ }
167
+
168
+ var isNextSiblingValid = node.nextSibling === null || node.nextSibling instanceof Text && (node.nextSibling.textContent || '').trim().length === 0;
169
+
170
+ if (isNextSiblingValid) {
171
+ return null;
172
+ } // This rule should not match when there is any sibling after the anchor
173
+
174
+
175
+ if (!isBlockLevelNode(node.nextSibling)) {
176
+ return false;
177
+ }
178
+
179
+ return null;
180
+ },
181
+ priority: 100,
182
+ getContent: getLinkContent
40
183
  }],
41
184
  toDOM: function toDOM() {
42
185
  return pDOM;
@@ -363,6 +363,18 @@ Object.defineProperty(exports, "normalizeUrl", {
363
363
  return _url.normalizeUrl;
364
364
  }
365
365
  });
366
+ Object.defineProperty(exports, "linkify", {
367
+ enumerable: true,
368
+ get: function get() {
369
+ return _url.linkify;
370
+ }
371
+ });
372
+ Object.defineProperty(exports, "linkifyMatch", {
373
+ enumerable: true,
374
+ get: function get() {
375
+ return _url.linkifyMatch;
376
+ }
377
+ });
366
378
 
367
379
  var _emoji = require("./confluence/emoji");
368
380
 
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.getLinkMatch = getLinkMatch;
9
9
  exports.normalizeUrl = normalizeUrl;
10
- exports.isSafeUrl = void 0;
10
+ exports.linkifyMatch = exports.LINK_REGEXP = exports.linkify = exports.isSafeUrl = void 0;
11
11
 
12
12
  var _linkifyIt = _interopRequireDefault(require("linkify-it"));
13
13
 
@@ -21,10 +21,62 @@ var isSafeUrl = function isSafeUrl(url) {
21
21
 
22
22
  exports.isSafeUrl = isSafeUrl;
23
23
  var linkify = (0, _linkifyIt.default)();
24
+ exports.linkify = linkify;
24
25
  linkify.add('sourcetree:', 'http:');
26
+ var tlds = 'biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф'.split('|');
27
+ var tlds2Char = 'a[cdefgilmnoqrtuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrtuvwxyz]|n[acefgilopruz]|om|p[aefghkmnrtw]|qa|r[eosuw]|s[abcdegijklmnrtuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]';
28
+ tlds.push(tlds2Char);
29
+ linkify.tlds(tlds, false);
30
+ var LINK_REGEXP = /(https?|ftp):\/\/[^\s]+/;
31
+ exports.LINK_REGEXP = LINK_REGEXP;
32
+
33
+ var linkifyMatch = function linkifyMatch(text) {
34
+ var matches = [];
35
+
36
+ if (!LINK_REGEXP.test(text)) {
37
+ return matches;
38
+ }
39
+
40
+ var startpos = 0;
41
+ var substr;
42
+
43
+ while (substr = text.substr(startpos)) {
44
+ var link = (substr.match(LINK_REGEXP) || [''])[0];
45
+
46
+ if (link) {
47
+ var index = substr.search(LINK_REGEXP);
48
+ var start = index >= 0 ? index + startpos : index;
49
+ var end = start + link.length;
50
+ matches.push({
51
+ index: start,
52
+ lastIndex: end,
53
+ raw: link,
54
+ url: link,
55
+ text: link,
56
+ schema: ''
57
+ });
58
+ startpos += end;
59
+ } else {
60
+ break;
61
+ }
62
+ }
63
+
64
+ return matches;
65
+ };
66
+
67
+ exports.linkifyMatch = linkifyMatch;
25
68
 
26
69
  function getLinkMatch(str) {
27
- var match = str && linkify.match(str);
70
+ if (!str) {
71
+ return null;
72
+ }
73
+
74
+ var match = linkifyMatch(str);
75
+
76
+ if (!match.length) {
77
+ match = linkify.match(str);
78
+ }
79
+
28
80
  return match && match[0];
29
81
  }
30
82
  /**
@@ -34,5 +86,5 @@ function getLinkMatch(str) {
34
86
 
35
87
  function normalizeUrl(url) {
36
88
  var match = getLinkMatch(url);
37
- return match && match.url || url;
89
+ return match && match.url || '';
38
90
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/adf-schema",
3
- "version": "19.2.3",
3
+ "version": "19.3.2",
4
4
  "sideEffects": false
5
5
  }
@@ -1,2 +1,2 @@
1
1
  export { AnnotationTypes, PanelType, alignment, alignmentPositionMap, annotation, bitbucketSchema, blockCard, blockquote, bodiedExtension, breakout, bulletList, bulletListSelector, caption, code, codeBlock, codeBlockToJSON, colorPalette, colorPaletteExtended, confluenceInlineComment, confluenceJiraIssue, confluenceSchema, confluenceSchemaWithMediaSingle, confluenceUnsupportedBlock, confluenceUnsupportedInline, copyPrivateMediaAttributes, createJIRASchema, createSchema, dataConsumer, dataConsumerToJSON, date, decisionItem, decisionList, decisionListSelector, defaultSchema, defaultSchemaConfig, doc, em, embedCard, emoji, expand, expandToJSON, extension, getSchemaBasedOnStage, hardBreak, heading, image, indentation, inlineCard, inlineExtension, inlineNodes, isSchemaWithAdvancedTextFormattingMarks, isSchemaWithBlockQuotes, isSchemaWithCodeBlock, isSchemaWithEmojis, isSchemaWithLinks, isSchemaWithLists, isSchemaWithMedia, isSchemaWithMentions, isSchemaWithSubSupMark, isSchemaWithTables, isSchemaWithTextColor, layoutColumn, layoutSection, link, linkToJSON, listItem, media, mediaGroup, mediaSingle, mediaSingleWithCaption, mediaInline, mediaSingleToJSON, mediaToJSON, mention, mentionToJSON, nestedExpand, orderedList, orderedListSelector, panel, customPanel, paragraph, placeholder, rule, sanitizeNodes, getCellAttrs, getCellDomAttrs, status, strike, strong, subsup, table, tableBackgroundBorderColor, tableBackgroundColorNames, tableBackgroundColorPalette, tableCell, tableCellContentDomSelector, tableCellContentWrapperSelector, tableCellSelector, tableHeader, tableHeaderSelector, tablePrefixSelector, tableRow, tableToJSON, taskItem, taskList, taskListSelector, text, textColor, toJSONTableCell, toJSONTableHeader, typeAheadQuery, underline, unknownBlock, unsupportedBlock, unsupportedInline, unsupportedNodeTypesForMediaCards, buildAnnotationMarkDataAttributes, AnnotationMarkStates, unsupportedMark, unsupportedNodeAttribute } from './schema';
2
- export { B100, B400, B50, B500, B75, G200, G300, G400, G50, G500, G75, N0, N20, N200, N30, N300, N40, N50, N500, N60, N80, N800, N90, P100, P300, P400, P50, P500, P75, R100, R300, R400, R50, R500, R75, T100, T300, T50, T500, T75, Y200, Y400, Y50, Y500, Y75, acNameToEmoji, acShortcutToEmoji, emojiIdToAcName, generateUuid, getEmojiAcName, getLinkMatch, hexToRgb, hexToRgba, isHex, isRgb, isSafeUrl, normalizeHexColor, normalizeUrl, rgbToHex, uuid } from './utils';
2
+ export { B100, B400, B50, B500, B75, G200, G300, G400, G50, G500, G75, N0, N20, N200, N30, N300, N40, N50, N500, N60, N80, N800, N90, P100, P300, P400, P50, P500, P75, R100, R300, R400, R50, R500, R75, T100, T300, T50, T500, T75, Y200, Y400, Y50, Y500, Y75, acNameToEmoji, acShortcutToEmoji, emojiIdToAcName, generateUuid, getEmojiAcName, getLinkMatch, hexToRgb, hexToRgba, isHex, isRgb, isSafeUrl, linkify, linkifyMatch, normalizeHexColor, normalizeUrl, rgbToHex, uuid } from './utils';
@@ -322,4 +322,6 @@ function isContentSupported(nodes, contentKey) {
322
322
  }
323
323
 
324
324
  return false;
325
- }
325
+ }
326
+
327
+ export const allowCustomPanel = true;
@@ -1,14 +1,13 @@
1
1
  import { customPanel } from './nodes/panel';
2
2
  import { layoutSectionWithSingleColumn } from './nodes/layout-section';
3
- import { dataConsumer } from './marks/data-consumer';
4
- import { createSchema } from './create-schema';
3
+ import { allowCustomPanel, createSchema } from './create-schema';
5
4
  import { mediaSingleWithCaption } from './nodes';
6
5
 
7
6
  const getDefaultSchemaConfig = () => {
8
7
  let defaultSchemaConfig = {
9
8
  nodes: ['doc', 'paragraph', 'text', 'bulletList', 'orderedList', 'listItem', 'heading', 'blockquote', 'codeBlock', 'panel', 'rule', 'image', 'mention', 'media', 'mediaGroup', 'mediaSingle', 'mediaInline', 'confluenceUnsupportedBlock', 'confluenceUnsupportedInline', 'confluenceJiraIssue', 'expand', 'nestedExpand', 'extension', 'inlineExtension', 'bodiedExtension', 'hardBreak', 'emoji', 'table', 'tableCell', 'tableHeader', 'tableRow', 'decisionList', 'decisionItem', 'taskList', 'taskItem', 'unknownBlock', 'date', 'status', 'placeholder', 'layoutSection', 'layoutColumn', 'inlineCard', 'blockCard', 'embedCard', 'unsupportedBlock', 'unsupportedInline'],
10
- marks: ['link', 'em', 'strong', 'strike', 'subsup', 'underline', 'code', 'textColor', 'confluenceInlineComment', 'breakout', 'alignment', 'indentation', 'annotation', 'unsupportedMark', 'unsupportedNodeAttribute', 'typeAheadQuery' // https://product-fabric.atlassian.net/browse/ED-10214,
11
- ]
9
+ marks: ['link', 'em', 'strong', 'strike', 'subsup', 'underline', 'code', 'textColor', 'confluenceInlineComment', 'breakout', 'alignment', 'indentation', 'annotation', 'unsupportedMark', 'unsupportedNodeAttribute', 'typeAheadQuery', // https://product-fabric.atlassian.net/browse/ED-10214,
10
+ 'dataConsumer']
12
11
  };
13
12
  return defaultSchemaConfig;
14
13
  };
@@ -19,13 +18,11 @@ export const getSchemaBasedOnStage = (stage = 'final') => {
19
18
 
20
19
  if (stage === 'stage0') {
21
20
  defaultSchemaConfig.customNodeSpecs = {
22
- panel: customPanel,
21
+ panel: customPanel(allowCustomPanel),
23
22
  mediaSingle: mediaSingleWithCaption,
24
23
  layoutSection: layoutSectionWithSingleColumn
25
24
  };
26
- defaultSchemaConfig.customMarkSpecs = {
27
- dataConsumer: dataConsumer
28
- };
25
+ defaultSchemaConfig.customMarkSpecs = {};
29
26
  defaultSchemaConfig.nodes.push('caption');
30
27
  defaultSchemaConfig.nodes.push('mediaInline');
31
28
  }