@atlaskit/adf-schema 25.10.1 → 26.0.1

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 (50) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/index.js +18 -0
  3. package/dist/cjs/schema/default-schema.js +2 -1
  4. package/dist/cjs/schema/index.js +18 -0
  5. package/dist/cjs/schema/nodes/index.js +18 -0
  6. package/dist/cjs/schema/nodes/media-single.js +69 -23
  7. package/dist/cjs/version.json +1 -1
  8. package/dist/es2019/index.js +1 -1
  9. package/dist/es2019/schema/create-schema.js +1 -1
  10. package/dist/es2019/schema/default-schema.js +3 -2
  11. package/dist/es2019/schema/index.js +1 -1
  12. package/dist/es2019/schema/nodes/index.js +1 -1
  13. package/dist/es2019/schema/nodes/media-single.js +69 -21
  14. package/dist/es2019/version.json +1 -1
  15. package/dist/esm/index.js +1 -1
  16. package/dist/esm/schema/create-schema.js +1 -1
  17. package/dist/esm/schema/default-schema.js +3 -2
  18. package/dist/esm/schema/index.js +1 -1
  19. package/dist/esm/schema/nodes/index.js +1 -1
  20. package/dist/esm/schema/nodes/media-single.js +65 -22
  21. package/dist/esm/version.json +1 -1
  22. package/dist/json-schema/v1/stage-0.json +60 -20
  23. package/dist/types/index.d.ts +2 -2
  24. package/dist/types/schema/default-schema.d.ts +1 -0
  25. package/dist/types/schema/index.d.ts +2 -2
  26. package/dist/types/schema/nodes/index.d.ts +2 -2
  27. package/dist/types/schema/nodes/media-single.d.ts +10 -4
  28. package/dist/types/schema/nodes/types/rich-media-common.d.ts +21 -0
  29. package/dist/types/steps/analytics.d.ts +2 -2
  30. package/dist/types/steps/link-meta-step.d.ts +2 -2
  31. package/dist/types/steps/set-attrs.d.ts +1 -1
  32. package/dist/types/steps/table/add-column.d.ts +5 -5
  33. package/dist/types/steps/table/sort-column.d.ts +2 -2
  34. package/dist/types/steps/type-ahead.d.ts +2 -2
  35. package/dist/types-ts4.5/index.d.ts +2 -2
  36. package/dist/types-ts4.5/schema/default-schema.d.ts +1 -0
  37. package/dist/types-ts4.5/schema/index.d.ts +2 -2
  38. package/dist/types-ts4.5/schema/nodes/index.d.ts +2 -2
  39. package/dist/types-ts4.5/schema/nodes/media-single.d.ts +10 -4
  40. package/dist/types-ts4.5/schema/nodes/types/rich-media-common.d.ts +21 -0
  41. package/dist/types-ts4.5/steps/analytics.d.ts +2 -2
  42. package/dist/types-ts4.5/steps/link-meta-step.d.ts +2 -2
  43. package/dist/types-ts4.5/steps/set-attrs.d.ts +1 -1
  44. package/dist/types-ts4.5/steps/table/add-column.d.ts +5 -5
  45. package/dist/types-ts4.5/steps/table/sort-column.d.ts +2 -2
  46. package/dist/types-ts4.5/steps/type-ahead.d.ts +2 -2
  47. package/json-schema/v1/stage-0.json +60 -20
  48. package/package.json +2 -5
  49. package/report.api.md +36 -1
  50. package/tmp/api-report-tmp.d.ts +31 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/adf-schema
2
2
 
3
+ ## 26.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`5f5ba16de66`](https://bitbucket.org/atlassian/atlassian-frontend/commits/5f5ba16de66) - [ED-13910] Fix prosemirror types
8
+
9
+ ## 26.0.0
10
+
11
+ ### Major Changes
12
+
13
+ - [`68ef7e6146c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/68ef7e6146c) - [ADF change] added widthType attribute to mediaSingle node, to support fixed width media node.
14
+
3
15
  ## 25.10.1
4
16
 
5
17
  ### Patch Changes
package/dist/cjs/index.js CHANGED
@@ -711,6 +711,18 @@ Object.defineProperty(exports, "mediaSingle", {
711
711
  return _schema.mediaSingle;
712
712
  }
713
713
  });
714
+ Object.defineProperty(exports, "mediaSingleFull", {
715
+ enumerable: true,
716
+ get: function get() {
717
+ return _schema.mediaSingleFull;
718
+ }
719
+ });
720
+ Object.defineProperty(exports, "mediaSingleSpec", {
721
+ enumerable: true,
722
+ get: function get() {
723
+ return _schema.mediaSingleSpec;
724
+ }
725
+ });
714
726
  Object.defineProperty(exports, "mediaSingleToJSON", {
715
727
  enumerable: true,
716
728
  get: function get() {
@@ -723,6 +735,12 @@ Object.defineProperty(exports, "mediaSingleWithCaption", {
723
735
  return _schema.mediaSingleWithCaption;
724
736
  }
725
737
  });
738
+ Object.defineProperty(exports, "mediaSingleWithWidthType", {
739
+ enumerable: true,
740
+ get: function get() {
741
+ return _schema.mediaSingleWithWidthType;
742
+ }
743
+ });
726
744
  Object.defineProperty(exports, "mediaToJSON", {
727
745
  enumerable: true,
728
746
  get: function get() {
@@ -26,7 +26,8 @@ var getSchemaBasedOnStage = (0, _memoizeOne.default)(function () {
26
26
  if (stage === 'stage0') {
27
27
  defaultSchemaConfig.customNodeSpecs = {
28
28
  layoutSection: _nodes.layoutSectionWithSingleColumn,
29
- table: _nodes.tableWithCustomWidth
29
+ table: _nodes.tableWithCustomWidth,
30
+ mediaSingle: _nodes.mediaSingleFull
30
31
  };
31
32
  defaultSchemaConfig.customMarkSpecs = {
32
33
  border: _marks.border
@@ -369,6 +369,18 @@ Object.defineProperty(exports, "mediaSingle", {
369
369
  return _nodes.mediaSingle;
370
370
  }
371
371
  });
372
+ Object.defineProperty(exports, "mediaSingleFull", {
373
+ enumerable: true,
374
+ get: function get() {
375
+ return _nodes.mediaSingleFull;
376
+ }
377
+ });
378
+ Object.defineProperty(exports, "mediaSingleSpec", {
379
+ enumerable: true,
380
+ get: function get() {
381
+ return _nodes.mediaSingleSpec;
382
+ }
383
+ });
372
384
  Object.defineProperty(exports, "mediaSingleToJSON", {
373
385
  enumerable: true,
374
386
  get: function get() {
@@ -381,6 +393,12 @@ Object.defineProperty(exports, "mediaSingleWithCaption", {
381
393
  return _nodes.mediaSingleWithCaption;
382
394
  }
383
395
  });
396
+ Object.defineProperty(exports, "mediaSingleWithWidthType", {
397
+ enumerable: true,
398
+ get: function get() {
399
+ return _nodes.mediaSingleWithWidthType;
400
+ }
401
+ });
384
402
  Object.defineProperty(exports, "mediaToJSON", {
385
403
  enumerable: true,
386
404
  get: function get() {
@@ -232,6 +232,18 @@ Object.defineProperty(exports, "mediaSingle", {
232
232
  return _mediaSingle.mediaSingle;
233
233
  }
234
234
  });
235
+ Object.defineProperty(exports, "mediaSingleFull", {
236
+ enumerable: true,
237
+ get: function get() {
238
+ return _mediaSingle.mediaSingleFull;
239
+ }
240
+ });
241
+ Object.defineProperty(exports, "mediaSingleSpec", {
242
+ enumerable: true,
243
+ get: function get() {
244
+ return _mediaSingle.mediaSingleSpec;
245
+ }
246
+ });
235
247
  Object.defineProperty(exports, "mediaSingleToJSON", {
236
248
  enumerable: true,
237
249
  get: function get() {
@@ -244,6 +256,12 @@ Object.defineProperty(exports, "mediaSingleWithCaption", {
244
256
  return _mediaSingle.mediaSingleWithCaption;
245
257
  }
246
258
  });
259
+ Object.defineProperty(exports, "mediaSingleWithWidthType", {
260
+ enumerable: true,
261
+ get: function get() {
262
+ return _mediaSingle.mediaSingleWithWidthType;
263
+ }
264
+ });
247
265
  Object.defineProperty(exports, "mediaToJSON", {
248
266
  enumerable: true,
249
267
  get: function get() {
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.toJSON = exports.mediaSingleWithCaption = exports.mediaSingle = exports.defaultAttrs = void 0;
7
+ exports.toJSON = exports.mediaSingleWithWidthType = exports.mediaSingleWithCaption = exports.mediaSingleSpec = exports.mediaSingleFull = exports.mediaSingle = exports.defaultAttrs = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
10
10
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
@@ -39,24 +39,29 @@ var defaultAttrs = {
39
39
  }
40
40
  };
41
41
  exports.defaultAttrs = defaultAttrs;
42
- var mediaSingle = {
43
- inline: false,
44
- group: 'block',
45
- selectable: true,
46
- atom: true,
47
- content: 'media|unsupportedBlock+|media unsupportedBlock+',
48
- attrs: defaultAttrs,
49
- marks: 'unsupportedMark unsupportedNodeAttribute border link',
50
- parseDOM: [{
51
- tag: 'div[data-node-type="mediaSingle"]',
52
- getAttrs: function getAttrs(dom) {
53
- return {
54
- layout: dom.getAttribute('data-layout') || 'center',
55
- width: Number(dom.getAttribute('data-width')) || null
56
- };
42
+ var mediaSingleSpec = function mediaSingleSpec(_ref) {
43
+ var _ref$withCaption = _ref.withCaption,
44
+ withCaption = _ref$withCaption === void 0 ? false : _ref$withCaption,
45
+ _ref$withExtendedWidt = _ref.withExtendedWidthTypes,
46
+ withExtendedWidthTypes = _ref$withExtendedWidt === void 0 ? false : _ref$withExtendedWidt;
47
+ var content = withCaption ? 'media|unsupportedBlock+|media (caption|unsupportedBlock) unsupportedBlock*' : 'media|unsupportedBlock+|media unsupportedBlock+';
48
+ var atom = !withCaption;
49
+ var getAttrs = function getAttrs(dom) {
50
+ var domAttrs = {
51
+ layout: dom.getAttribute('data-layout') || 'center',
52
+ width: Number(dom.getAttribute('data-width')) || null
53
+ };
54
+ if (withExtendedWidthTypes) {
55
+ var widthType = dom.getAttribute('data-width-type');
56
+ if (widthType) {
57
+ return _objectSpread(_objectSpread({}, domAttrs), {}, {
58
+ widthType: widthType
59
+ });
60
+ }
57
61
  }
58
- }],
59
- toDOM: function toDOM(node) {
62
+ return domAttrs;
63
+ };
64
+ var getAttrsFromNode = function getAttrsFromNode(node) {
60
65
  var _node$attrs = node.attrs,
61
66
  layout = _node$attrs.layout,
62
67
  width = _node$attrs.width;
@@ -68,15 +73,56 @@ var mediaSingle = {
68
73
  if (width) {
69
74
  attrs['data-width'] = isFinite(width) && Math.floor(width) === width ? width : width.toFixed(2);
70
75
  }
71
- return ['div', attrs, 0];
72
- }
76
+ if (withExtendedWidthTypes && node.attrs.widthType) {
77
+ var widthType = node.attrs.widthType;
78
+ return _objectSpread(_objectSpread({}, attrs), {}, {
79
+ 'data-width-type': widthType || 'percentage'
80
+ });
81
+ }
82
+ return attrs;
83
+ };
84
+ return {
85
+ inline: false,
86
+ group: 'block',
87
+ selectable: true,
88
+ atom: atom,
89
+ content: content,
90
+ attrs: withExtendedWidthTypes ? _objectSpread(_objectSpread({}, defaultAttrs), {}, {
91
+ widthType: {
92
+ default: null
93
+ }
94
+ }) : defaultAttrs,
95
+ marks: 'unsupportedMark unsupportedNodeAttribute border link',
96
+ parseDOM: [{
97
+ tag: 'div[data-node-type="mediaSingle"]',
98
+ getAttrs: getAttrs
99
+ }],
100
+ toDOM: function toDOM(node) {
101
+ return ['div', getAttrsFromNode(node), 0];
102
+ }
103
+ };
73
104
  };
105
+ exports.mediaSingleSpec = mediaSingleSpec;
106
+ var mediaSingle = mediaSingleSpec({
107
+ withCaption: false,
108
+ withExtendedWidthTypes: false
109
+ });
74
110
  exports.mediaSingle = mediaSingle;
75
- var mediaSingleWithCaption = _objectSpread(_objectSpread({}, mediaSingle), {}, {
76
- atom: false,
77
- content: 'media|unsupportedBlock+|media (caption|unsupportedBlock) unsupportedBlock*'
111
+ var mediaSingleWithCaption = mediaSingleSpec({
112
+ withCaption: true,
113
+ withExtendedWidthTypes: false
78
114
  });
79
115
  exports.mediaSingleWithCaption = mediaSingleWithCaption;
116
+ var mediaSingleWithWidthType = mediaSingleSpec({
117
+ withCaption: false,
118
+ withExtendedWidthTypes: true
119
+ });
120
+ exports.mediaSingleWithWidthType = mediaSingleWithWidthType;
121
+ var mediaSingleFull = mediaSingleSpec({
122
+ withCaption: true,
123
+ withExtendedWidthTypes: true
124
+ });
125
+ exports.mediaSingleFull = mediaSingleFull;
80
126
  var toJSON = function toJSON(node) {
81
127
  return {
82
128
  attrs: Object.keys(node.attrs).reduce(function (obj, key) {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/adf-schema",
3
- "version": "25.10.1",
3
+ "version": "26.0.1",
4
4
  "sideEffects": false
5
5
  }
@@ -1,3 +1,3 @@
1
1
  export { PanelType, AnnotationTypes, alignment, alignmentPositionMap, annotation, blockCard, blockquote, bodiedExtension, breakout, bulletList, bulletListSelector, caption, code, codeBlock, codeBlockToJSON, colorPalette, /** @deprecated [ED-15849] The extended palette is now rolled into the main one. Use `colorPalette` instead. */
2
- colorPaletteExtended, confluenceInlineComment, confluenceJiraIssue, confluenceUnsupportedBlock, confluenceUnsupportedInline, copyPrivateMediaAttributes, createSchema, dataConsumer, dataConsumerToJSON, date, decisionItem, decisionList, decisionListSelector, doc, em, embedCard, emoji, expand, expandToJSON, extension, fragment, fragmentToJSON, hardBreak, heading, image, indentation, inlineCard, inlineExtension, inlineNodes, layoutColumn, layoutSection, link, linkToJSON, listItem, media, mediaGroup, mediaSingle, mediaSingleWithCaption, mediaInline, mediaSingleToJSON, mediaToJSON, mention, mentionToJSON, nestedExpand, orderedList, orderedListSelector, orderedListWithOrder, panel, paragraph, placeholder, rule, sanitizeNodes, getCellAttrs, getCellDomAttrs, status, strike, strong, subsup, table, tableWithCustomWidth, 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, border, borderColorPalette } from './schema';
2
+ colorPaletteExtended, confluenceInlineComment, confluenceJiraIssue, confluenceUnsupportedBlock, confluenceUnsupportedInline, copyPrivateMediaAttributes, createSchema, dataConsumer, dataConsumerToJSON, date, decisionItem, decisionList, decisionListSelector, doc, em, embedCard, emoji, expand, expandToJSON, extension, fragment, fragmentToJSON, hardBreak, heading, image, indentation, inlineCard, inlineExtension, inlineNodes, layoutColumn, layoutSection, link, linkToJSON, listItem, media, mediaGroup, mediaSingle, mediaSingleWithCaption, mediaSingleWithWidthType, mediaSingleFull, mediaSingleSpec, mediaInline, mediaSingleToJSON, mediaToJSON, mention, mentionToJSON, nestedExpand, orderedList, orderedListSelector, orderedListWithOrder, panel, paragraph, placeholder, rule, sanitizeNodes, getCellAttrs, getCellDomAttrs, status, strike, strong, subsup, table, tableWithCustomWidth, 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, border, borderColorPalette } from './schema';
3
3
  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';
@@ -1,7 +1,7 @@
1
1
  import { Schema } from 'prosemirror-model';
2
2
  import { COLOR, FONT_STYLE, SEARCH_QUERY, LINK } from './groups';
3
3
  import { link, em, strong, textColor, strike, subsup, underline, code, typeAheadQuery, confluenceInlineComment, breakout, alignment, indentation, annotation, unsupportedMark, unsupportedNodeAttribute, dataConsumer, fragment, border } from './marks';
4
- import { confluenceJiraIssue, confluenceUnsupportedBlock, confluenceUnsupportedInline, doc, paragraph, text, bulletList, orderedListWithOrder, listItem, heading, blockquote, codeBlock, panel, rule, image, mention, media, mediaInline, mediaGroup, mediaSingleWithCaption, hardBreak, emoji, table, tableCell, tableHeader, tableRow, decisionList, decisionItem, taskList, taskItem, unknownBlock, extension, inlineExtension, bodiedExtension, date, placeholder, layoutSection, layoutColumn, inlineCard, blockCard, unsupportedBlock, unsupportedInline, status, expand, nestedExpand, embedCard, caption } from './nodes';
4
+ import { confluenceJiraIssue, confluenceUnsupportedBlock, confluenceUnsupportedInline, doc, paragraph, text, bulletList, orderedListWithOrder, listItem, heading, blockquote, codeBlock, panel, rule, image, mention, media, mediaInline, mediaSingleWithCaption, mediaGroup, hardBreak, emoji, table, tableCell, tableHeader, tableRow, decisionList, decisionItem, taskList, taskItem, unknownBlock, extension, inlineExtension, bodiedExtension, date, placeholder, layoutSection, layoutColumn, inlineCard, blockCard, unsupportedBlock, unsupportedInline, status, expand, nestedExpand, embedCard, caption } from './nodes';
5
5
  function addItems(builtInItems, config, customSpecs = {}) {
6
6
  if (!config) {
7
7
  return {};
@@ -1,5 +1,5 @@
1
1
  import memoizeOne from 'memoize-one';
2
- import { layoutSectionWithSingleColumn, tableWithCustomWidth } from './nodes';
2
+ import { mediaSingleFull, layoutSectionWithSingleColumn, tableWithCustomWidth } from './nodes';
3
3
  import { border } from './marks';
4
4
  import { createSchema } from './create-schema';
5
5
  const getDefaultSchemaConfig = () => {
@@ -17,7 +17,8 @@ export const getSchemaBasedOnStage = memoizeOne((stage = 'final') => {
17
17
  if (stage === 'stage0') {
18
18
  defaultSchemaConfig.customNodeSpecs = {
19
19
  layoutSection: layoutSectionWithSingleColumn,
20
- table: tableWithCustomWidth
20
+ table: tableWithCustomWidth,
21
+ mediaSingle: mediaSingleFull
21
22
  };
22
23
  defaultSchemaConfig.customMarkSpecs = {
23
24
  border
@@ -1,4 +1,4 @@
1
- export { PanelType, blockCard, blockquote, bodiedExtension, bulletList, bulletListSelector, caption, codeBlock, codeBlockToJSON, confluenceJiraIssue, confluenceUnsupportedBlock, confluenceUnsupportedInline, copyPrivateMediaAttributes, date, decisionItem, decisionList, decisionListSelector, doc, embedCard, emoji, expand, expandToJSON, extension, hardBreak, heading, image, inlineCard, inlineExtension, layoutColumn, layoutSection, layoutSectionWithSingleColumn, listItem, media, mediaGroup, mediaSingle, mediaInline, mediaSingleWithCaption, mediaSingleToJSON, mediaToJSON, mention, mentionToJSON, nestedExpand, orderedList, orderedListSelector, orderedListWithOrder, panel, paragraph, placeholder, rule, getCellAttrs, getCellDomAttrs, status, table, tableWithCustomWidth, tableBackgroundBorderColor, tableBackgroundColorNames, tableBackgroundColorPalette, tableCell, tableCellContentDomSelector, tableCellContentWrapperSelector, tableCellSelector, tableHeader, tableHeaderSelector, tablePrefixSelector, tableRow, tableToJSON, taskItem, taskList, taskListSelector, text, toJSONTableCell, toJSONTableHeader, unknownBlock, unsupportedBlock, unsupportedInline } from './nodes';
1
+ export { PanelType, blockCard, blockquote, bodiedExtension, bulletList, bulletListSelector, caption, codeBlock, codeBlockToJSON, confluenceJiraIssue, confluenceUnsupportedBlock, confluenceUnsupportedInline, copyPrivateMediaAttributes, date, decisionItem, decisionList, decisionListSelector, doc, embedCard, emoji, expand, expandToJSON, extension, hardBreak, heading, image, inlineCard, inlineExtension, layoutColumn, layoutSection, layoutSectionWithSingleColumn, listItem, media, mediaGroup, mediaSingle, mediaSingleSpec, mediaInline, mediaSingleWithCaption, mediaSingleWithWidthType, mediaSingleFull, mediaSingleToJSON, mediaToJSON, mention, mentionToJSON, nestedExpand, orderedList, orderedListSelector, orderedListWithOrder, panel, paragraph, placeholder, rule, getCellAttrs, getCellDomAttrs, status, table, tableWithCustomWidth, tableBackgroundBorderColor, tableBackgroundColorNames, tableBackgroundColorPalette, tableCell, tableCellContentDomSelector, tableCellContentWrapperSelector, tableCellSelector, tableHeader, tableHeaderSelector, tablePrefixSelector, tableRow, tableToJSON, taskItem, taskList, taskListSelector, text, toJSONTableCell, toJSONTableHeader, unknownBlock, unsupportedBlock, unsupportedInline } from './nodes';
2
2
  export { AnnotationTypes, alignment, alignmentPositionMap, annotation, breakout, code, colorPalette, /** @deprecated [ED-15849] The extended palette is now rolled into the main one. Use `colorPalette` instead. */
3
3
  colorPaletteExtended, confluenceInlineComment, dataConsumer, dataConsumerToJSON, em, fragment, fragmentToJSON, indentation, link, linkToJSON, strike, strong, subsup, textColor, typeAheadQuery, underline, buildAnnotationMarkDataAttributes, AnnotationMarkStates, unsupportedMark, unsupportedNodeAttribute, border, borderColorPalette } from './marks';
4
4
  export { unsupportedNodeTypesForMediaCards } from './unsupported';
@@ -22,7 +22,7 @@ export { caption } from './caption';
22
22
  export { media, copyPrivateAttributes as copyPrivateMediaAttributes, toJSON as mediaToJSON } from './media';
23
23
  export { mediaGroup } from './media-group';
24
24
  export { mediaInline } from './media-inline';
25
- export { mediaSingle, mediaSingleWithCaption, toJSON as mediaSingleToJSON } from './media-single';
25
+ export { mediaSingle, mediaSingleSpec, mediaSingleWithCaption, mediaSingleWithWidthType, mediaSingleFull, toJSON as mediaSingleToJSON } from './media-single';
26
26
  export { table, tableWithCustomWidth, tableToJSON, tableCell, toJSONTableCell, tableHeader, toJSONTableHeader, tableRow, tableBackgroundColorPalette, tableBackgroundBorderColor, tableBackgroundColorNames, getCellAttrs, getCellDomAttrs, tablePrefixSelector, tableCellSelector, tableHeaderSelector, tableCellContentWrapperSelector, tableCellContentDomSelector } from './tableNodes';
27
27
  export { decisionList, decisionListSelector } from './decision-list';
28
28
  export { decisionItem } from './decision-item';
@@ -28,22 +28,29 @@ export const defaultAttrs = {
28
28
  default: 'center'
29
29
  }
30
30
  };
31
- export const mediaSingle = {
32
- inline: false,
33
- group: 'block',
34
- selectable: true,
35
- atom: true,
36
- content: 'media|unsupportedBlock+|media unsupportedBlock+',
37
- attrs: defaultAttrs,
38
- marks: 'unsupportedMark unsupportedNodeAttribute border link',
39
- parseDOM: [{
40
- tag: 'div[data-node-type="mediaSingle"]',
41
- getAttrs: dom => ({
31
+ export const mediaSingleSpec = ({
32
+ withCaption = false,
33
+ withExtendedWidthTypes = false
34
+ }) => {
35
+ const content = withCaption ? 'media|unsupportedBlock+|media (caption|unsupportedBlock) unsupportedBlock*' : 'media|unsupportedBlock+|media unsupportedBlock+';
36
+ const atom = !withCaption;
37
+ const getAttrs = dom => {
38
+ const domAttrs = {
42
39
  layout: dom.getAttribute('data-layout') || 'center',
43
40
  width: Number(dom.getAttribute('data-width')) || null
44
- })
45
- }],
46
- toDOM(node) {
41
+ };
42
+ if (withExtendedWidthTypes) {
43
+ const widthType = dom.getAttribute('data-width-type');
44
+ if (widthType) {
45
+ return {
46
+ ...domAttrs,
47
+ widthType
48
+ };
49
+ }
50
+ }
51
+ return domAttrs;
52
+ };
53
+ const getAttrsFromNode = node => {
47
54
  const {
48
55
  layout,
49
56
  width
@@ -56,14 +63,55 @@ export const mediaSingle = {
56
63
  if (width) {
57
64
  attrs['data-width'] = isFinite(width) && Math.floor(width) === width ? width : width.toFixed(2);
58
65
  }
59
- return ['div', attrs, 0];
60
- }
61
- };
62
- export const mediaSingleWithCaption = {
63
- ...mediaSingle,
64
- atom: false,
65
- content: 'media|unsupportedBlock+|media (caption|unsupportedBlock) unsupportedBlock*'
66
+ if (withExtendedWidthTypes && node.attrs.widthType) {
67
+ const {
68
+ widthType
69
+ } = node.attrs;
70
+ return {
71
+ ...attrs,
72
+ 'data-width-type': widthType || 'percentage'
73
+ };
74
+ }
75
+ return attrs;
76
+ };
77
+ return {
78
+ inline: false,
79
+ group: 'block',
80
+ selectable: true,
81
+ atom,
82
+ content,
83
+ attrs: withExtendedWidthTypes ? {
84
+ ...defaultAttrs,
85
+ widthType: {
86
+ default: null
87
+ }
88
+ } : defaultAttrs,
89
+ marks: 'unsupportedMark unsupportedNodeAttribute border link',
90
+ parseDOM: [{
91
+ tag: 'div[data-node-type="mediaSingle"]',
92
+ getAttrs
93
+ }],
94
+ toDOM(node) {
95
+ return ['div', getAttrsFromNode(node), 0];
96
+ }
97
+ };
66
98
  };
99
+ export const mediaSingle = mediaSingleSpec({
100
+ withCaption: false,
101
+ withExtendedWidthTypes: false
102
+ });
103
+ export const mediaSingleWithCaption = mediaSingleSpec({
104
+ withCaption: true,
105
+ withExtendedWidthTypes: false
106
+ });
107
+ export const mediaSingleWithWidthType = mediaSingleSpec({
108
+ withCaption: false,
109
+ withExtendedWidthTypes: true
110
+ });
111
+ export const mediaSingleFull = mediaSingleSpec({
112
+ withCaption: true,
113
+ withExtendedWidthTypes: true
114
+ });
67
115
  export const toJSON = node => ({
68
116
  attrs: Object.keys(node.attrs).reduce((obj, key) => {
69
117
  if (node.attrs[key] !== null) {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/adf-schema",
3
- "version": "25.10.1",
3
+ "version": "26.0.1",
4
4
  "sideEffects": false
5
5
  }
package/dist/esm/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  export { PanelType, AnnotationTypes, alignment, alignmentPositionMap, annotation, blockCard, blockquote, bodiedExtension, breakout, bulletList, bulletListSelector, caption, code, codeBlock, codeBlockToJSON, colorPalette, /** @deprecated [ED-15849] The extended palette is now rolled into the main one. Use `colorPalette` instead. */
2
- colorPaletteExtended, confluenceInlineComment, confluenceJiraIssue, confluenceUnsupportedBlock, confluenceUnsupportedInline, copyPrivateMediaAttributes, createSchema, dataConsumer, dataConsumerToJSON, date, decisionItem, decisionList, decisionListSelector, doc, em, embedCard, emoji, expand, expandToJSON, extension, fragment, fragmentToJSON, hardBreak, heading, image, indentation, inlineCard, inlineExtension, inlineNodes, layoutColumn, layoutSection, link, linkToJSON, listItem, media, mediaGroup, mediaSingle, mediaSingleWithCaption, mediaInline, mediaSingleToJSON, mediaToJSON, mention, mentionToJSON, nestedExpand, orderedList, orderedListSelector, orderedListWithOrder, panel, paragraph, placeholder, rule, sanitizeNodes, getCellAttrs, getCellDomAttrs, status, strike, strong, subsup, table, tableWithCustomWidth, 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, border, borderColorPalette } from './schema';
2
+ colorPaletteExtended, confluenceInlineComment, confluenceJiraIssue, confluenceUnsupportedBlock, confluenceUnsupportedInline, copyPrivateMediaAttributes, createSchema, dataConsumer, dataConsumerToJSON, date, decisionItem, decisionList, decisionListSelector, doc, em, embedCard, emoji, expand, expandToJSON, extension, fragment, fragmentToJSON, hardBreak, heading, image, indentation, inlineCard, inlineExtension, inlineNodes, layoutColumn, layoutSection, link, linkToJSON, listItem, media, mediaGroup, mediaSingle, mediaSingleWithCaption, mediaSingleWithWidthType, mediaSingleFull, mediaSingleSpec, mediaInline, mediaSingleToJSON, mediaToJSON, mention, mentionToJSON, nestedExpand, orderedList, orderedListSelector, orderedListWithOrder, panel, paragraph, placeholder, rule, sanitizeNodes, getCellAttrs, getCellDomAttrs, status, strike, strong, subsup, table, tableWithCustomWidth, 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, border, borderColorPalette } from './schema';
3
3
  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';
@@ -4,7 +4,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
4
4
  import { Schema } from 'prosemirror-model';
5
5
  import { COLOR, FONT_STYLE, SEARCH_QUERY, LINK } from './groups';
6
6
  import { link, em, strong, textColor, strike, subsup, underline, code, typeAheadQuery, confluenceInlineComment, breakout, alignment, indentation, annotation, unsupportedMark, unsupportedNodeAttribute, dataConsumer, fragment, border } from './marks';
7
- import { confluenceJiraIssue, confluenceUnsupportedBlock, confluenceUnsupportedInline, doc, paragraph, text, bulletList, orderedListWithOrder, listItem, heading, blockquote, codeBlock, panel, rule, image, mention, media, mediaInline, mediaGroup, mediaSingleWithCaption, hardBreak, emoji, table, tableCell, tableHeader, tableRow, decisionList, decisionItem, taskList, taskItem, unknownBlock, extension, inlineExtension, bodiedExtension, date, placeholder, layoutSection, layoutColumn, inlineCard, blockCard, unsupportedBlock, unsupportedInline, status, expand, nestedExpand, embedCard, caption } from './nodes';
7
+ import { confluenceJiraIssue, confluenceUnsupportedBlock, confluenceUnsupportedInline, doc, paragraph, text, bulletList, orderedListWithOrder, listItem, heading, blockquote, codeBlock, panel, rule, image, mention, media, mediaInline, mediaSingleWithCaption, mediaGroup, hardBreak, emoji, table, tableCell, tableHeader, tableRow, decisionList, decisionItem, taskList, taskItem, unknownBlock, extension, inlineExtension, bodiedExtension, date, placeholder, layoutSection, layoutColumn, inlineCard, blockCard, unsupportedBlock, unsupportedInline, status, expand, nestedExpand, embedCard, caption } from './nodes';
8
8
  function addItems(builtInItems, config) {
9
9
  var customSpecs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
10
10
  if (!config) {
@@ -1,5 +1,5 @@
1
1
  import memoizeOne from 'memoize-one';
2
- import { layoutSectionWithSingleColumn, tableWithCustomWidth } from './nodes';
2
+ import { mediaSingleFull, layoutSectionWithSingleColumn, tableWithCustomWidth } from './nodes';
3
3
  import { border } from './marks';
4
4
  import { createSchema } from './create-schema';
5
5
  var getDefaultSchemaConfig = function getDefaultSchemaConfig() {
@@ -18,7 +18,8 @@ export var getSchemaBasedOnStage = memoizeOne(function () {
18
18
  if (stage === 'stage0') {
19
19
  defaultSchemaConfig.customNodeSpecs = {
20
20
  layoutSection: layoutSectionWithSingleColumn,
21
- table: tableWithCustomWidth
21
+ table: tableWithCustomWidth,
22
+ mediaSingle: mediaSingleFull
22
23
  };
23
24
  defaultSchemaConfig.customMarkSpecs = {
24
25
  border: border
@@ -1,4 +1,4 @@
1
- export { PanelType, blockCard, blockquote, bodiedExtension, bulletList, bulletListSelector, caption, codeBlock, codeBlockToJSON, confluenceJiraIssue, confluenceUnsupportedBlock, confluenceUnsupportedInline, copyPrivateMediaAttributes, date, decisionItem, decisionList, decisionListSelector, doc, embedCard, emoji, expand, expandToJSON, extension, hardBreak, heading, image, inlineCard, inlineExtension, layoutColumn, layoutSection, layoutSectionWithSingleColumn, listItem, media, mediaGroup, mediaSingle, mediaInline, mediaSingleWithCaption, mediaSingleToJSON, mediaToJSON, mention, mentionToJSON, nestedExpand, orderedList, orderedListSelector, orderedListWithOrder, panel, paragraph, placeholder, rule, getCellAttrs, getCellDomAttrs, status, table, tableWithCustomWidth, tableBackgroundBorderColor, tableBackgroundColorNames, tableBackgroundColorPalette, tableCell, tableCellContentDomSelector, tableCellContentWrapperSelector, tableCellSelector, tableHeader, tableHeaderSelector, tablePrefixSelector, tableRow, tableToJSON, taskItem, taskList, taskListSelector, text, toJSONTableCell, toJSONTableHeader, unknownBlock, unsupportedBlock, unsupportedInline } from './nodes';
1
+ export { PanelType, blockCard, blockquote, bodiedExtension, bulletList, bulletListSelector, caption, codeBlock, codeBlockToJSON, confluenceJiraIssue, confluenceUnsupportedBlock, confluenceUnsupportedInline, copyPrivateMediaAttributes, date, decisionItem, decisionList, decisionListSelector, doc, embedCard, emoji, expand, expandToJSON, extension, hardBreak, heading, image, inlineCard, inlineExtension, layoutColumn, layoutSection, layoutSectionWithSingleColumn, listItem, media, mediaGroup, mediaSingle, mediaSingleSpec, mediaInline, mediaSingleWithCaption, mediaSingleWithWidthType, mediaSingleFull, mediaSingleToJSON, mediaToJSON, mention, mentionToJSON, nestedExpand, orderedList, orderedListSelector, orderedListWithOrder, panel, paragraph, placeholder, rule, getCellAttrs, getCellDomAttrs, status, table, tableWithCustomWidth, tableBackgroundBorderColor, tableBackgroundColorNames, tableBackgroundColorPalette, tableCell, tableCellContentDomSelector, tableCellContentWrapperSelector, tableCellSelector, tableHeader, tableHeaderSelector, tablePrefixSelector, tableRow, tableToJSON, taskItem, taskList, taskListSelector, text, toJSONTableCell, toJSONTableHeader, unknownBlock, unsupportedBlock, unsupportedInline } from './nodes';
2
2
  export { AnnotationTypes, alignment, alignmentPositionMap, annotation, breakout, code, colorPalette, /** @deprecated [ED-15849] The extended palette is now rolled into the main one. Use `colorPalette` instead. */
3
3
  colorPaletteExtended, confluenceInlineComment, dataConsumer, dataConsumerToJSON, em, fragment, fragmentToJSON, indentation, link, linkToJSON, strike, strong, subsup, textColor, typeAheadQuery, underline, buildAnnotationMarkDataAttributes, AnnotationMarkStates, unsupportedMark, unsupportedNodeAttribute, border, borderColorPalette } from './marks';
4
4
  export { unsupportedNodeTypesForMediaCards } from './unsupported';
@@ -22,7 +22,7 @@ export { caption } from './caption';
22
22
  export { media, copyPrivateAttributes as copyPrivateMediaAttributes, toJSON as mediaToJSON } from './media';
23
23
  export { mediaGroup } from './media-group';
24
24
  export { mediaInline } from './media-inline';
25
- export { mediaSingle, mediaSingleWithCaption, toJSON as mediaSingleToJSON } from './media-single';
25
+ export { mediaSingle, mediaSingleSpec, mediaSingleWithCaption, mediaSingleWithWidthType, mediaSingleFull, toJSON as mediaSingleToJSON } from './media-single';
26
26
  export { table, tableWithCustomWidth, tableToJSON, tableCell, toJSONTableCell, tableHeader, toJSONTableHeader, tableRow, tableBackgroundColorPalette, tableBackgroundBorderColor, tableBackgroundColorNames, getCellAttrs, getCellDomAttrs, tablePrefixSelector, tableCellSelector, tableHeaderSelector, tableCellContentWrapperSelector, tableCellContentDomSelector } from './tableNodes';
27
27
  export { decisionList, decisionListSelector } from './decision-list';
28
28
  export { decisionItem } from './decision-item';
@@ -31,24 +31,29 @@ export var defaultAttrs = {
31
31
  default: 'center'
32
32
  }
33
33
  };
34
- export var mediaSingle = {
35
- inline: false,
36
- group: 'block',
37
- selectable: true,
38
- atom: true,
39
- content: 'media|unsupportedBlock+|media unsupportedBlock+',
40
- attrs: defaultAttrs,
41
- marks: 'unsupportedMark unsupportedNodeAttribute border link',
42
- parseDOM: [{
43
- tag: 'div[data-node-type="mediaSingle"]',
44
- getAttrs: function getAttrs(dom) {
45
- return {
46
- layout: dom.getAttribute('data-layout') || 'center',
47
- width: Number(dom.getAttribute('data-width')) || null
48
- };
34
+ export var mediaSingleSpec = function mediaSingleSpec(_ref) {
35
+ var _ref$withCaption = _ref.withCaption,
36
+ withCaption = _ref$withCaption === void 0 ? false : _ref$withCaption,
37
+ _ref$withExtendedWidt = _ref.withExtendedWidthTypes,
38
+ withExtendedWidthTypes = _ref$withExtendedWidt === void 0 ? false : _ref$withExtendedWidt;
39
+ var content = withCaption ? 'media|unsupportedBlock+|media (caption|unsupportedBlock) unsupportedBlock*' : 'media|unsupportedBlock+|media unsupportedBlock+';
40
+ var atom = !withCaption;
41
+ var getAttrs = function getAttrs(dom) {
42
+ var domAttrs = {
43
+ layout: dom.getAttribute('data-layout') || 'center',
44
+ width: Number(dom.getAttribute('data-width')) || null
45
+ };
46
+ if (withExtendedWidthTypes) {
47
+ var widthType = dom.getAttribute('data-width-type');
48
+ if (widthType) {
49
+ return _objectSpread(_objectSpread({}, domAttrs), {}, {
50
+ widthType: widthType
51
+ });
52
+ }
49
53
  }
50
- }],
51
- toDOM: function toDOM(node) {
54
+ return domAttrs;
55
+ };
56
+ var getAttrsFromNode = function getAttrsFromNode(node) {
52
57
  var _node$attrs = node.attrs,
53
58
  layout = _node$attrs.layout,
54
59
  width = _node$attrs.width;
@@ -60,12 +65,50 @@ export var mediaSingle = {
60
65
  if (width) {
61
66
  attrs['data-width'] = isFinite(width) && Math.floor(width) === width ? width : width.toFixed(2);
62
67
  }
63
- return ['div', attrs, 0];
64
- }
68
+ if (withExtendedWidthTypes && node.attrs.widthType) {
69
+ var widthType = node.attrs.widthType;
70
+ return _objectSpread(_objectSpread({}, attrs), {}, {
71
+ 'data-width-type': widthType || 'percentage'
72
+ });
73
+ }
74
+ return attrs;
75
+ };
76
+ return {
77
+ inline: false,
78
+ group: 'block',
79
+ selectable: true,
80
+ atom: atom,
81
+ content: content,
82
+ attrs: withExtendedWidthTypes ? _objectSpread(_objectSpread({}, defaultAttrs), {}, {
83
+ widthType: {
84
+ default: null
85
+ }
86
+ }) : defaultAttrs,
87
+ marks: 'unsupportedMark unsupportedNodeAttribute border link',
88
+ parseDOM: [{
89
+ tag: 'div[data-node-type="mediaSingle"]',
90
+ getAttrs: getAttrs
91
+ }],
92
+ toDOM: function toDOM(node) {
93
+ return ['div', getAttrsFromNode(node), 0];
94
+ }
95
+ };
65
96
  };
66
- export var mediaSingleWithCaption = _objectSpread(_objectSpread({}, mediaSingle), {}, {
67
- atom: false,
68
- content: 'media|unsupportedBlock+|media (caption|unsupportedBlock) unsupportedBlock*'
97
+ export var mediaSingle = mediaSingleSpec({
98
+ withCaption: false,
99
+ withExtendedWidthTypes: false
100
+ });
101
+ export var mediaSingleWithCaption = mediaSingleSpec({
102
+ withCaption: true,
103
+ withExtendedWidthTypes: false
104
+ });
105
+ export var mediaSingleWithWidthType = mediaSingleSpec({
106
+ withCaption: false,
107
+ withExtendedWidthTypes: true
108
+ });
109
+ export var mediaSingleFull = mediaSingleSpec({
110
+ withCaption: true,
111
+ withExtendedWidthTypes: true
69
112
  });
70
113
  export var toJSON = function toJSON(node) {
71
114
  return {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/adf-schema",
3
- "version": "25.10.1",
3
+ "version": "26.0.1",
4
4
  "sideEffects": false
5
5
  }