@atlaskit/adf-schema 26.2.1 → 26.2.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/adf-schema
2
2
 
3
+ ## 26.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`56e6ce31c75`](https://bitbucket.org/atlassian/atlassian-frontend/commits/56e6ce31c75) - ED-19040 improve handle paste media
8
+
3
9
  ## 26.2.1
4
10
 
5
11
  ### Patch Changes
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
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
+ var _richMediaCommon = require("./types/rich-media-common");
10
+ var _parseDOM = require("../../utils/parseDOM");
9
11
  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
12
  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; }
11
13
  /**
@@ -47,19 +49,33 @@ var mediaSingleSpec = function mediaSingleSpec(_ref) {
47
49
  var content = withCaption ? 'media|unsupportedBlock+|media (caption|unsupportedBlock) unsupportedBlock*' : 'media|unsupportedBlock+|media unsupportedBlock+';
48
50
  var atom = !withCaption;
49
51
  var getAttrs = function getAttrs(dom) {
50
- var domAttrs = {
51
- layout: dom.getAttribute('data-layout') || 'center',
52
- width: Number(dom.getAttribute('data-width')) || null
53
- };
52
+ if (!(0, _parseDOM.isDOMElement)(dom)) {
53
+ // this should never happen
54
+ return {
55
+ layout: 'center'
56
+ };
57
+ }
58
+ var layout = dom.getAttribute('data-layout') || 'center';
59
+ var width = Number(dom.getAttribute('data-width')) || null;
60
+ var widthType = dom.getAttribute('data-width-type');
54
61
  if (withExtendedWidthTypes) {
55
- var widthType = dom.getAttribute('data-width-type');
56
- if (widthType) {
57
- return _objectSpread(_objectSpread({}, domAttrs), {}, {
58
- widthType: widthType
59
- });
60
- }
62
+ return {
63
+ layout: layout,
64
+ width: width,
65
+ widthType: widthType
66
+ };
67
+ } else if (widthType === _richMediaCommon.WidthType.PIXEL) {
68
+ // if editor does not support widthType attribute.
69
+ // We ignore width and widthType together.
70
+ return {
71
+ layout: layout
72
+ };
73
+ } else {
74
+ return {
75
+ layout: layout,
76
+ width: width
77
+ };
61
78
  }
62
- return domAttrs;
63
79
  };
64
80
  var getAttrsFromNode = function getAttrsFromNode(node) {
65
81
  var _node$attrs = node.attrs,
@@ -76,7 +92,7 @@ var mediaSingleSpec = function mediaSingleSpec(_ref) {
76
92
  if (withExtendedWidthTypes && node.attrs.widthType) {
77
93
  var widthType = node.attrs.widthType;
78
94
  return _objectSpread(_objectSpread({}, attrs), {}, {
79
- 'data-width-type': widthType || 'percentage'
95
+ 'data-width-type': widthType || _richMediaCommon.WidthType.PERCENTAGE
80
96
  });
81
97
  }
82
98
  return attrs;
@@ -2,4 +2,15 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
- });
5
+ });
6
+ exports.WidthType = void 0;
7
+ /**
8
+ * @stage 0
9
+ * @description The widthType attribute is used to support fixed with media single
10
+ */
11
+ var WidthType = /*#__PURE__*/function (WidthType) {
12
+ WidthType["PIXEL"] = "pixel";
13
+ WidthType["PERCENTAGE"] = "percentage";
14
+ return WidthType;
15
+ }({});
16
+ exports.WidthType = WidthType;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/adf-schema",
3
- "version": "26.2.1",
3
+ "version": "26.2.2",
4
4
  "sideEffects": false
5
5
  }
@@ -1,3 +1,6 @@
1
+ import { WidthType } from './types/rich-media-common';
2
+ import { isDOMElement } from '../../utils/parseDOM';
3
+
1
4
  /**
2
5
  * @name mediaSingle_node
3
6
  * @additionalProperties true
@@ -35,20 +38,33 @@ export const mediaSingleSpec = ({
35
38
  const content = withCaption ? 'media|unsupportedBlock+|media (caption|unsupportedBlock) unsupportedBlock*' : 'media|unsupportedBlock+|media unsupportedBlock+';
36
39
  const atom = !withCaption;
37
40
  const getAttrs = dom => {
38
- const domAttrs = {
39
- layout: dom.getAttribute('data-layout') || 'center',
40
- width: Number(dom.getAttribute('data-width')) || null
41
- };
41
+ if (!isDOMElement(dom)) {
42
+ // this should never happen
43
+ return {
44
+ layout: 'center'
45
+ };
46
+ }
47
+ const layout = dom.getAttribute('data-layout') || 'center';
48
+ const width = Number(dom.getAttribute('data-width')) || null;
49
+ const widthType = dom.getAttribute('data-width-type');
42
50
  if (withExtendedWidthTypes) {
43
- const widthType = dom.getAttribute('data-width-type');
44
- if (widthType) {
45
- return {
46
- ...domAttrs,
47
- widthType
48
- };
49
- }
51
+ return {
52
+ layout,
53
+ width,
54
+ widthType
55
+ };
56
+ } else if (widthType === WidthType.PIXEL) {
57
+ // if editor does not support widthType attribute.
58
+ // We ignore width and widthType together.
59
+ return {
60
+ layout
61
+ };
62
+ } else {
63
+ return {
64
+ layout,
65
+ width
66
+ };
50
67
  }
51
- return domAttrs;
52
68
  };
53
69
  const getAttrsFromNode = node => {
54
70
  const {
@@ -69,7 +85,7 @@ export const mediaSingleSpec = ({
69
85
  } = node.attrs;
70
86
  return {
71
87
  ...attrs,
72
- 'data-width-type': widthType || 'percentage'
88
+ 'data-width-type': widthType || WidthType.PERCENTAGE
73
89
  };
74
90
  }
75
91
  return attrs;
@@ -1 +1,10 @@
1
- export {};
1
+ /**
2
+ * @stage 0
3
+ * @description The widthType attribute is used to support fixed with media single
4
+ */
5
+
6
+ export let WidthType = /*#__PURE__*/function (WidthType) {
7
+ WidthType["PIXEL"] = "pixel";
8
+ WidthType["PERCENTAGE"] = "percentage";
9
+ return WidthType;
10
+ }({});
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/adf-schema",
3
- "version": "26.2.1",
3
+ "version": "26.2.2",
4
4
  "sideEffects": false
5
5
  }
@@ -1,6 +1,9 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  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; }
3
3
  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) { _defineProperty(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; }
4
+ import { WidthType } from './types/rich-media-common';
5
+ import { isDOMElement } from '../../utils/parseDOM';
6
+
4
7
  /**
5
8
  * @name mediaSingle_node
6
9
  * @additionalProperties true
@@ -39,19 +42,33 @@ export var mediaSingleSpec = function mediaSingleSpec(_ref) {
39
42
  var content = withCaption ? 'media|unsupportedBlock+|media (caption|unsupportedBlock) unsupportedBlock*' : 'media|unsupportedBlock+|media unsupportedBlock+';
40
43
  var atom = !withCaption;
41
44
  var getAttrs = function getAttrs(dom) {
42
- var domAttrs = {
43
- layout: dom.getAttribute('data-layout') || 'center',
44
- width: Number(dom.getAttribute('data-width')) || null
45
- };
45
+ if (!isDOMElement(dom)) {
46
+ // this should never happen
47
+ return {
48
+ layout: 'center'
49
+ };
50
+ }
51
+ var layout = dom.getAttribute('data-layout') || 'center';
52
+ var width = Number(dom.getAttribute('data-width')) || null;
53
+ var widthType = dom.getAttribute('data-width-type');
46
54
  if (withExtendedWidthTypes) {
47
- var widthType = dom.getAttribute('data-width-type');
48
- if (widthType) {
49
- return _objectSpread(_objectSpread({}, domAttrs), {}, {
50
- widthType: widthType
51
- });
52
- }
55
+ return {
56
+ layout: layout,
57
+ width: width,
58
+ widthType: widthType
59
+ };
60
+ } else if (widthType === WidthType.PIXEL) {
61
+ // if editor does not support widthType attribute.
62
+ // We ignore width and widthType together.
63
+ return {
64
+ layout: layout
65
+ };
66
+ } else {
67
+ return {
68
+ layout: layout,
69
+ width: width
70
+ };
53
71
  }
54
- return domAttrs;
55
72
  };
56
73
  var getAttrsFromNode = function getAttrsFromNode(node) {
57
74
  var _node$attrs = node.attrs,
@@ -68,7 +85,7 @@ export var mediaSingleSpec = function mediaSingleSpec(_ref) {
68
85
  if (withExtendedWidthTypes && node.attrs.widthType) {
69
86
  var widthType = node.attrs.widthType;
70
87
  return _objectSpread(_objectSpread({}, attrs), {}, {
71
- 'data-width-type': widthType || 'percentage'
88
+ 'data-width-type': widthType || WidthType.PERCENTAGE
72
89
  });
73
90
  }
74
91
  return attrs;
@@ -1 +1,10 @@
1
- export {};
1
+ /**
2
+ * @stage 0
3
+ * @description The widthType attribute is used to support fixed with media single
4
+ */
5
+
6
+ export var WidthType = /*#__PURE__*/function (WidthType) {
7
+ WidthType["PIXEL"] = "pixel";
8
+ WidthType["PERCENTAGE"] = "percentage";
9
+ return WidthType;
10
+ }({});
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/adf-schema",
3
- "version": "26.2.1",
3
+ "version": "26.2.2",
4
4
  "sideEffects": false
5
5
  }
@@ -30,5 +30,9 @@ interface FixedLayoutMediaAttributes {
30
30
  widthType: 'pixel';
31
31
  layout: Layout;
32
32
  }
33
+ export declare enum WidthType {
34
+ PIXEL = "pixel",
35
+ PERCENTAGE = "percentage"
36
+ }
33
37
  export type ExtendedMediaAttributes = DefaultMediaAttributes | FixedLayoutMediaAttributes;
34
38
  export {};
@@ -30,5 +30,9 @@ interface FixedLayoutMediaAttributes {
30
30
  widthType: 'pixel';
31
31
  layout: Layout;
32
32
  }
33
+ export declare enum WidthType {
34
+ PIXEL = "pixel",
35
+ PERCENTAGE = "percentage"
36
+ }
33
37
  export type ExtendedMediaAttributes = DefaultMediaAttributes | FixedLayoutMediaAttributes;
34
38
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/adf-schema",
3
- "version": "26.2.1",
3
+ "version": "26.2.2",
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/"