@atlaskit/editor-core 185.5.2 → 185.5.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.
Files changed (70) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/cjs/plugins/breakout/ui/LayoutButton.js +5 -28
  3. package/dist/cjs/plugins/card/index.js +20 -6
  4. package/dist/cjs/plugins/card/nodeviews/datasource.js +39 -4
  5. package/dist/cjs/plugins/card/pm-plugins/actions.js +31 -1
  6. package/dist/cjs/plugins/card/pm-plugins/main.js +48 -3
  7. package/dist/cjs/plugins/card/pm-plugins/reducers.js +22 -0
  8. package/dist/cjs/plugins/card/styles.js +1 -1
  9. package/dist/cjs/plugins/card/ui/LayoutButton/index.js +113 -0
  10. package/dist/cjs/plugins/card/ui/LayoutButton/styled.js +17 -0
  11. package/dist/cjs/plugins/card/ui/LayoutButton/types.js +5 -0
  12. package/dist/cjs/plugins/card/ui/LayoutButton/utils.js +19 -0
  13. package/dist/cjs/plugins/media/pm-plugins/main.js +20 -1
  14. package/dist/cjs/version-wrapper.js +1 -1
  15. package/dist/cjs/version.json +1 -1
  16. package/dist/es2019/plugins/breakout/ui/LayoutButton.js +3 -26
  17. package/dist/es2019/plugins/breakout/utils/get-breakout-mode.js +0 -1
  18. package/dist/es2019/plugins/card/index.js +20 -3
  19. package/dist/es2019/plugins/card/nodeviews/datasource.js +38 -1
  20. package/dist/es2019/plugins/card/pm-plugins/actions.js +16 -0
  21. package/dist/es2019/plugins/card/pm-plugins/main.js +55 -4
  22. package/dist/es2019/plugins/card/pm-plugins/reducers.js +25 -0
  23. package/dist/es2019/plugins/card/styles.js +6 -0
  24. package/dist/es2019/plugins/card/ui/LayoutButton/index.js +106 -0
  25. package/dist/es2019/plugins/card/ui/LayoutButton/styled.js +10 -0
  26. package/dist/es2019/plugins/card/ui/LayoutButton/types.js +1 -0
  27. package/dist/es2019/plugins/card/ui/LayoutButton/utils.js +15 -0
  28. package/dist/es2019/plugins/media/pm-plugins/main.js +25 -3
  29. package/dist/es2019/version-wrapper.js +1 -1
  30. package/dist/es2019/version.json +1 -1
  31. package/dist/esm/plugins/breakout/ui/LayoutButton.js +3 -26
  32. package/dist/esm/plugins/breakout/utils/get-breakout-mode.js +0 -1
  33. package/dist/esm/plugins/card/index.js +20 -3
  34. package/dist/esm/plugins/card/nodeviews/datasource.js +37 -3
  35. package/dist/esm/plugins/card/pm-plugins/actions.js +27 -0
  36. package/dist/esm/plugins/card/pm-plugins/main.js +49 -4
  37. package/dist/esm/plugins/card/pm-plugins/reducers.js +22 -0
  38. package/dist/esm/plugins/card/styles.js +1 -1
  39. package/dist/esm/plugins/card/ui/LayoutButton/index.js +102 -0
  40. package/dist/esm/plugins/card/ui/LayoutButton/styled.js +10 -0
  41. package/dist/esm/plugins/card/ui/LayoutButton/types.js +1 -0
  42. package/dist/esm/plugins/card/ui/LayoutButton/utils.js +12 -0
  43. package/dist/esm/plugins/media/pm-plugins/main.js +22 -3
  44. package/dist/esm/version-wrapper.js +1 -1
  45. package/dist/esm/version.json +1 -1
  46. package/dist/types/plugins/breakout/commands/set-breakout-mode.d.ts +1 -1
  47. package/dist/types/plugins/breakout/utils/get-breakout-mode.d.ts +1 -1
  48. package/dist/types/plugins/card/index.d.ts +3 -1
  49. package/dist/types/plugins/card/nodeviews/datasource.d.ts +18 -2
  50. package/dist/types/plugins/card/pm-plugins/actions.d.ts +7 -0
  51. package/dist/types/plugins/card/pm-plugins/plugin-key.d.ts +2 -1
  52. package/dist/types/plugins/card/pm-plugins/util/state.d.ts +2 -0
  53. package/dist/types/plugins/card/types.d.ts +17 -1
  54. package/dist/types/plugins/card/ui/LayoutButton/index.d.ts +9 -0
  55. package/dist/types/plugins/card/ui/LayoutButton/styled.d.ts +1 -0
  56. package/dist/types/plugins/card/ui/LayoutButton/types.d.ts +19 -0
  57. package/dist/types/plugins/card/ui/LayoutButton/utils.d.ts +5 -0
  58. package/dist/types-ts4.5/plugins/breakout/commands/set-breakout-mode.d.ts +1 -1
  59. package/dist/types-ts4.5/plugins/breakout/utils/get-breakout-mode.d.ts +1 -1
  60. package/dist/types-ts4.5/plugins/card/index.d.ts +3 -1
  61. package/dist/types-ts4.5/plugins/card/nodeviews/datasource.d.ts +18 -2
  62. package/dist/types-ts4.5/plugins/card/pm-plugins/actions.d.ts +7 -0
  63. package/dist/types-ts4.5/plugins/card/pm-plugins/plugin-key.d.ts +2 -1
  64. package/dist/types-ts4.5/plugins/card/pm-plugins/util/state.d.ts +2 -0
  65. package/dist/types-ts4.5/plugins/card/types.d.ts +17 -1
  66. package/dist/types-ts4.5/plugins/card/ui/LayoutButton/index.d.ts +9 -0
  67. package/dist/types-ts4.5/plugins/card/ui/LayoutButton/styled.d.ts +1 -0
  68. package/dist/types-ts4.5/plugins/card/ui/LayoutButton/types.d.ts +19 -0
  69. package/dist/types-ts4.5/plugins/card/ui/LayoutButton/utils.d.ts +5 -0
  70. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @atlaskit/editor-core
2
2
 
3
+ ## 185.5.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [`072578e8f55`](https://bitbucket.org/atlassian/atlassian-frontend/commits/072578e8f55) - [ux] The change here enables the datasource table to be configured with varying width based on 3 layout modes.
8
+ - [`dd532ad4f99`](https://bitbucket.org/atlassian/atlassian-frontend/commits/dd532ad4f99) - [MEX-2457] fix wrong upload position for mediaGroup
9
+
3
10
  ## 185.5.2
4
11
 
5
12
  ### Patch Changes
@@ -25,41 +25,18 @@ var _ToolbarButton = _interopRequireDefault(require("../../../ui/ToolbarButton")
25
25
  var _getBreakoutMode = require("../utils/get-breakout-mode");
26
26
  var _setBreakoutMode = require("../commands/set-breakout-mode");
27
27
  var _removeBreakout = require("../commands/remove-breakout");
28
- var _messages = _interopRequireDefault(require("../../../messages"));
29
28
  var _constants = require("../constants");
30
29
  var _isBreakoutMarkAllowed = require("../utils/is-breakout-mark-allowed");
31
30
  var _pluginKey = require("../plugin-key");
32
31
  var _prosemirrorState = require("prosemirror-state");
33
32
  var _isSupportedNode = require("../utils/is-supported-node");
34
33
  var _constants2 = require("@atlaskit/theme/constants");
34
+ var _utils = require("@atlaskit/editor-common/utils");
35
35
  var _templateObject;
36
36
  /** @jsx jsx */
37
37
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
38
38
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
39
39
  var toolbarButtonWrapper = (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n && button {\n background: ", ";\n color: ", ";\n :hover {\n background: ", ";\n color: ", " !important;\n }\n }\n"])), "var(--ds-background-neutral, ".concat(_colors.N20A, ")"), "var(--ds-icon, ".concat(_colors.N300, ")"), "var(--ds-background-neutral-hovered, ".concat(_colors.B300, ")"), "var(--ds-icon, white)");
40
- var BREAKOUT_MODE = {
41
- FULL_WIDTH: 'full-width',
42
- CENTER: 'center',
43
- WIDE: 'wide'
44
- };
45
- var getNextBreakoutMode = function getNextBreakoutMode(currentMode) {
46
- if (currentMode === BREAKOUT_MODE.FULL_WIDTH) {
47
- return BREAKOUT_MODE.CENTER;
48
- } else if (currentMode === BREAKOUT_MODE.WIDE) {
49
- return BREAKOUT_MODE.FULL_WIDTH;
50
- }
51
- return BREAKOUT_MODE.WIDE;
52
- };
53
- var getTitle = function getTitle(layout) {
54
- switch (layout) {
55
- case BREAKOUT_MODE.FULL_WIDTH:
56
- return _messages.default.layoutFixedWidth;
57
- case BREAKOUT_MODE.WIDE:
58
- return _messages.default.layoutFullWidth;
59
- default:
60
- return _messages.default.layoutWide;
61
- }
62
- };
63
40
  function getBreakoutNodeElement(pluginState, selection, editorView) {
64
41
  if (selection instanceof _prosemirrorState.NodeSelection && (0, _isSupportedNode.isSupportedNodeForBreakout)(selection.node)) {
65
42
  return (0, _prosemirrorUtils.findDomRefAtPos)(selection.from, editorView.domAtPos.bind(editorView));
@@ -81,7 +58,7 @@ var LayoutButton = /*#__PURE__*/function (_React$Component) {
81
58
  var _this$props$editorVie = _this.props.editorView,
82
59
  state = _this$props$editorVie.state,
83
60
  dispatch = _this$props$editorVie.dispatch;
84
- if ([BREAKOUT_MODE.WIDE, BREAKOUT_MODE.FULL_WIDTH].indexOf(breakoutMode) !== -1) {
61
+ if (['wide', 'full-width'].indexOf(breakoutMode) !== -1) {
85
62
  (0, _setBreakoutMode.setBreakoutMode)(breakoutMode)(state, dispatch);
86
63
  } else {
87
64
  (0, _removeBreakout.removeBreakout)()(state, dispatch);
@@ -105,9 +82,9 @@ var LayoutButton = /*#__PURE__*/function (_React$Component) {
105
82
  return null;
106
83
  }
107
84
  var breakoutMode = (0, _getBreakoutMode.getBreakoutMode)(editorView.state);
108
- var titleMessage = getTitle(breakoutMode);
85
+ var titleMessage = (0, _utils.getTitle)(breakoutMode);
109
86
  var title = formatMessage(titleMessage);
110
- var nextBreakoutMode = getNextBreakoutMode(breakoutMode);
87
+ var nextBreakoutMode = (0, _utils.getNextBreakoutMode)(breakoutMode);
111
88
  var belowOtherPopupsZIndex = _constants2.layers.layer() - 1;
112
89
  var pluginState = (0, _pluginKey.getPluginState)(state);
113
90
  var element = getBreakoutNodeElement(pluginState, state.selection, editorView);
@@ -136,7 +113,7 @@ var LayoutButton = /*#__PURE__*/function (_React$Component) {
136
113
  title: title,
137
114
  testId: titleMessage.id,
138
115
  onClick: this.handleClick(nextBreakoutMode),
139
- iconBefore: breakoutMode === BREAKOUT_MODE.FULL_WIDTH ? (0, _react2.jsx)(_collapse.default, {
116
+ iconBefore: breakoutMode === 'full-width' ? (0, _react2.jsx)(_collapse.default, {
140
117
  label: title
141
118
  }) : (0, _react2.jsx)(_expand.default, {
142
119
  label: title
@@ -1,21 +1,20 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof = require("@babel/runtime/helpers/typeof");
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = void 0;
9
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
- var _react = _interopRequireWildcard(require("react"));
9
+ var _react = _interopRequireDefault(require("react"));
11
10
  var _adfSchema = require("@atlaskit/adf-schema");
12
11
  var _main = require("./pm-plugins/main");
13
12
  var _toolbar = require("./toolbar");
14
13
  var _EditorSmartCardEvents = require("./ui/EditorSmartCardEvents");
15
14
  var _keymap = require("./pm-plugins/keymap");
16
15
  var _EditorSmartCardEventsNext = require("./ui/EditorSmartCardEventsNext");
17
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
18
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
16
+ var _LayoutButton = _interopRequireDefault(require("./ui/LayoutButton"));
17
+ var _pluginKey = require("./pm-plugins/plugin-key");
19
18
  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; }
20
19
  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; }
21
20
  var cardPlugin = function cardPlugin(options, api) {
@@ -23,6 +22,12 @@ var cardPlugin = function cardPlugin(options, api) {
23
22
  var featureFlags = (api === null || api === void 0 ? void 0 : (_api$dependencies = api.dependencies) === null || _api$dependencies === void 0 ? void 0 : (_api$dependencies$fea = _api$dependencies.featureFlags) === null || _api$dependencies$fea === void 0 ? void 0 : _api$dependencies$fea.sharedState.currentState()) || {};
24
23
  return {
25
24
  name: 'card',
25
+ getSharedState: function getSharedState(editorState) {
26
+ if (!editorState) {
27
+ return null;
28
+ }
29
+ return _pluginKey.pluginKey.getState(editorState);
30
+ },
26
31
  nodes: function nodes() {
27
32
  var nodes = [{
28
33
  name: 'inlineCard',
@@ -66,12 +71,21 @@ var cardPlugin = function cardPlugin(options, api) {
66
71
  return plugins;
67
72
  },
68
73
  contentComponent: function contentComponent(_ref2) {
69
- var editorView = _ref2.editorView;
74
+ var editorView = _ref2.editorView,
75
+ popupsMountPoint = _ref2.popupsMountPoint,
76
+ popupsScrollableElement = _ref2.popupsScrollableElement,
77
+ popupsBoundariesElement = _ref2.popupsBoundariesElement;
70
78
  var lpAnalyticsEventsNext = featureFlags.lpAnalyticsEventsNext;
71
- return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_EditorSmartCardEvents.EditorSmartCardEvents, {
79
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_EditorSmartCardEvents.EditorSmartCardEvents, {
72
80
  editorView: editorView
73
81
  }), lpAnalyticsEventsNext && /*#__PURE__*/_react.default.createElement(_EditorSmartCardEventsNext.EditorSmartCardEventsNext, {
74
82
  editorView: editorView
83
+ }), /*#__PURE__*/_react.default.createElement(_LayoutButton.default, {
84
+ api: api,
85
+ editorView: editorView,
86
+ mountPoint: popupsMountPoint,
87
+ scrollableElement: popupsScrollableElement,
88
+ boundariesElement: popupsBoundariesElement
75
89
  }));
76
90
  },
77
91
  pluginsOptions: {
@@ -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.DatasourceComponent = exports.Datasource = void 0;
7
+ exports.DatasourceComponent = exports.Datasource = exports.DATASOURCE_INNER_CONTAINER_CLASSNAME = void 0;
8
8
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
9
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
10
  var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
@@ -17,10 +17,14 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
17
17
  var _react2 = require("@emotion/react");
18
18
  var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/react-node-view"));
19
19
  var _linkDatasource = require("@atlaskit/link-datasource");
20
+ var _styles = require("@atlaskit/editor-common/styles");
21
+ var _utils = require("@atlaskit/editor-common/utils");
20
22
  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; }
21
23
  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; }
22
24
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
23
25
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } /** @jsx jsx */
26
+ var DATASOURCE_INNER_CONTAINER_CLASSNAME = 'datasourceView-content-inner-wrap';
27
+ exports.DATASOURCE_INNER_CONTAINER_CLASSNAME = DATASOURCE_INNER_CONTAINER_CLASSNAME;
24
28
  var containerStyles = (0, _react2.css)({
25
29
  height: '500px',
26
30
  overflow: 'auto'
@@ -118,15 +122,46 @@ exports.DatasourceComponent = DatasourceComponent;
118
122
  var Datasource = /*#__PURE__*/function (_ReactNodeView) {
119
123
  (0, _inherits2.default)(Datasource, _ReactNodeView);
120
124
  var _super2 = _createSuper(Datasource);
121
- function Datasource() {
125
+ function Datasource(props) {
126
+ var _props$pluginInjectio, _props$pluginInjectio2, _props$pluginInjectio3, _sharedState$currentS;
127
+ var _this2;
122
128
  (0, _classCallCheck2.default)(this, Datasource);
123
- return _super2.apply(this, arguments);
129
+ _this2 = _super2.call(this, props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props, undefined, true, undefined, props.hasIntlContext);
130
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "calcTableWidth", function (layout, containerWidth) {
131
+ if (layout === 'center') {
132
+ return 'inherit';
133
+ }
134
+ return (0, _utils.calcBreakoutWidthPx)(layout, containerWidth);
135
+ });
136
+ var sharedState = props === null || props === void 0 ? void 0 : (_props$pluginInjectio = props.pluginInjectionApi) === null || _props$pluginInjectio === void 0 ? void 0 : (_props$pluginInjectio2 = _props$pluginInjectio.dependencies) === null || _props$pluginInjectio2 === void 0 ? void 0 : (_props$pluginInjectio3 = _props$pluginInjectio2.width) === null || _props$pluginInjectio3 === void 0 ? void 0 : _props$pluginInjectio3.sharedState;
137
+ _this2.tableWidth = sharedState === null || sharedState === void 0 ? void 0 : (_sharedState$currentS = sharedState.currentState()) === null || _sharedState$currentS === void 0 ? void 0 : _sharedState$currentS.width;
138
+ sharedState === null || sharedState === void 0 ? void 0 : sharedState.onChange(function (_ref2) {
139
+ var nextSharedState = _ref2.nextSharedState;
140
+ if (nextSharedState !== null && nextSharedState !== void 0 && nextSharedState.width && _this2.tableWidth !== (nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.width)) {
141
+ _this2.tableWidth = nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.width;
142
+ _this2.update(_this2.node, []); // required to update the width when page is resized.
143
+ }
144
+ });
145
+ return _this2;
124
146
  }
125
147
  (0, _createClass2.default)(Datasource, [{
148
+ key: "createDomRef",
149
+ value: function createDomRef() {
150
+ var domRef = document.createElement('div');
151
+ domRef.classList.add(_styles.SmartCardSharedCssClassName.DATASOURCE_CONTAINER);
152
+ return domRef;
153
+ }
154
+ }, {
126
155
  key: "render",
127
156
  value: function render() {
157
+ var attrs = this.node.attrs;
158
+ var calculatedWidth = this.calcTableWidth(attrs.layout, this.tableWidth);
128
159
  return (0, _react2.jsx)("div", {
129
- css: containerStyles
160
+ className: DATASOURCE_INNER_CONTAINER_CLASSNAME,
161
+ css: containerStyles,
162
+ style: {
163
+ minWidth: calculatedWidth
164
+ }
130
165
  }, (0, _react2.jsx)(DatasourceComponent, {
131
166
  node: this.node,
132
167
  view: this.view,
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.showLinkToolbar = exports.setProvider = exports.resolveCard = exports.registerSmartCardEventsNext = exports.registerSmartCardEvents = exports.registerCard = exports.queueCards = exports.hideLinkToolbar = exports.cardAction = void 0;
6
+ exports.showLinkToolbar = exports.setProvider = exports.setDatasourceTableRef = exports.setCardLayoutAndDatasourceTableRef = exports.setCardLayout = exports.resolveCard = exports.registerSmartCardEventsNext = exports.registerSmartCardEvents = exports.registerCard = exports.queueCards = exports.hideLinkToolbar = exports.cardAction = void 0;
7
7
  var _pluginKey = require("./plugin-key");
8
8
  var cardAction = function cardAction(tr, action) {
9
9
  return tr.setMeta(_pluginKey.pluginKey, action);
@@ -63,6 +63,36 @@ var setProvider = function setProvider(cardProvider) {
63
63
  };
64
64
  };
65
65
  exports.setProvider = setProvider;
66
+ var setDatasourceTableRef = function setDatasourceTableRef(datasourceTableRef) {
67
+ return function (tr) {
68
+ return cardAction(tr, {
69
+ type: 'SET_DATASOURCE_TABLE_REF',
70
+ datasourceTableRef: datasourceTableRef
71
+ });
72
+ };
73
+ };
74
+ exports.setDatasourceTableRef = setDatasourceTableRef;
75
+ var setCardLayout = function setCardLayout(layout) {
76
+ return function (tr) {
77
+ return cardAction(tr, {
78
+ type: 'SET_CARD_LAYOUT',
79
+ layout: layout
80
+ });
81
+ };
82
+ };
83
+ exports.setCardLayout = setCardLayout;
84
+ var setCardLayoutAndDatasourceTableRef = function setCardLayoutAndDatasourceTableRef(_ref) {
85
+ var layout = _ref.layout,
86
+ datasourceTableRef = _ref.datasourceTableRef;
87
+ return function (tr) {
88
+ return cardAction(tr, {
89
+ type: 'SET_CARD_LAYOUT_AND_DATASOURCE_TABLE_REF',
90
+ layout: layout,
91
+ datasourceTableRef: datasourceTableRef
92
+ });
93
+ };
94
+ };
95
+ exports.setCardLayoutAndDatasourceTableRef = setCardLayoutAndDatasourceTableRef;
66
96
  var showLinkToolbar = function showLinkToolbar(tr) {
67
97
  return cardAction(tr, {
68
98
  type: 'SHOW_LINK_TOOLBAR'
@@ -13,6 +13,7 @@ Object.defineProperty(exports, "pluginKey", {
13
13
  });
14
14
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
15
15
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
16
+ var _prosemirrorState = require("prosemirror-state");
16
17
  var _rafSchd = _interopRequireDefault(require("raf-schd"));
17
18
  var _reactNodeView = require("@atlaskit/editor-common/react-node-view");
18
19
  var _blockCard = require("../nodeviews/blockCard");
@@ -24,6 +25,8 @@ var _resolve = require("./util/resolve");
24
25
  var _state = require("./util/state");
25
26
  var _analytics = require("./analytics");
26
27
  var _datasource = require("../nodeviews/datasource");
28
+ var _actions = require("./actions");
29
+ var _prosemirrorUtils = require("prosemirror-utils");
27
30
  var createPlugin = function createPlugin(options, pluginInjectionApi) {
28
31
  return function (pmPluginFactoryParams) {
29
32
  var lpAnalyticsEventsNext = pmPluginFactoryParams.featureFlags.lpAnalyticsEventsNext;
@@ -46,7 +49,9 @@ var createPlugin = function createPlugin(options, pluginInjectionApi) {
46
49
  smartLinkEvents: undefined,
47
50
  smartLinkEventsNext: undefined,
48
51
  createAnalyticsEvent: createAnalyticsEvent,
49
- editorAppearance: editorAppearance
52
+ editorAppearance: editorAppearance,
53
+ datasourceTableRef: undefined,
54
+ layout: undefined
50
55
  };
51
56
  },
52
57
  apply: function apply(tr, pluginState, prevEditorState) {
@@ -72,12 +77,42 @@ var createPlugin = function createPlugin(options, pluginInjectionApi) {
72
77
  var subscriptionHandler = function subscriptionHandler(name, provider) {
73
78
  return (0, _resolve.handleProvider)(name, provider, _view);
74
79
  };
80
+ var domAtPos = _view.domAtPos.bind(_view);
75
81
  var rafCancellationCallbacks = [];
76
82
  pmPluginFactoryParams.providerFactory.subscribe('cardProvider', subscriptionHandler);
77
83
  return {
78
84
  update: function update(view, prevState) {
85
+ var _selection$node;
79
86
  var currentState = (0, _state.getPluginState)(view.state);
80
87
  var oldState = (0, _state.getPluginState)(prevState);
88
+ var state = view.state,
89
+ dispatch = view.dispatch;
90
+ var selection = state.selection,
91
+ tr = state.tr,
92
+ schema = state.schema;
93
+ var isBlockCardSelected = selection instanceof _prosemirrorState.NodeSelection && ((_selection$node = selection.node) === null || _selection$node === void 0 ? void 0 : _selection$node.type) === schema.nodes.blockCard;
94
+ if (isBlockCardSelected) {
95
+ var _findDomRefAtPos, _node$attrs;
96
+ var datasourceTableRef = (_findDomRefAtPos = (0, _prosemirrorUtils.findDomRefAtPos)(selection.from, domAtPos)) === null || _findDomRefAtPos === void 0 ? void 0 : _findDomRefAtPos.querySelector(".".concat(_datasource.DATASOURCE_INNER_CONTAINER_CLASSNAME));
97
+ var node = selection.node;
98
+ var isDatasource = !!(node !== null && node !== void 0 && (_node$attrs = node.attrs) !== null && _node$attrs !== void 0 && _node$attrs.datasource);
99
+ var shouldUpdateTableRef = datasourceTableRef && (currentState === null || currentState === void 0 ? void 0 : currentState.datasourceTableRef) !== datasourceTableRef;
100
+ if (isDatasource && shouldUpdateTableRef) {
101
+ var _node$attrs2;
102
+ // since we use the plugin state, which is a shared state, we need to update the datasourceTableRef, layout on each selection
103
+ var layout = (node === null || node === void 0 ? void 0 : (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.layout) || 'center';
104
+
105
+ // we use cardAction to set the same meta, hence, we will need to combine both layout+datasourceTableRef in one transaction
106
+ dispatch((0, _actions.setCardLayoutAndDatasourceTableRef)({
107
+ datasourceTableRef: datasourceTableRef,
108
+ layout: layout
109
+ })(tr));
110
+ }
111
+ } else {
112
+ if (currentState !== null && currentState !== void 0 && currentState.datasourceTableRef) {
113
+ dispatch((0, _actions.setDatasourceTableRef)(undefined)(tr));
114
+ }
115
+ }
81
116
  if (currentState && currentState.provider) {
82
117
  // Find requests in this state that weren't in the old one.
83
118
  var newRequests = (0, _state.getNewRequests)(oldState, currentState);
@@ -123,6 +158,7 @@ var createPlugin = function createPlugin(options, pluginInjectionApi) {
123
158
  }
124
159
  }),
125
160
  blockCard: function blockCard(node, view, getPos) {
161
+ var _node$attrs3;
126
162
  var portalProviderAPI = pmPluginFactoryParams.portalProviderAPI,
127
163
  eventDispatcher = pmPluginFactoryParams.eventDispatcher;
128
164
  var reactComponentProps = {
@@ -130,8 +166,17 @@ var createPlugin = function createPlugin(options, pluginInjectionApi) {
130
166
  showServerActions: showServerActions
131
167
  };
132
168
  var hasIntlContext = true;
133
- if (node.attrs.datasource) {
134
- return new _datasource.Datasource(node, view, getPos, portalProviderAPI, eventDispatcher, undefined, undefined, true, undefined, hasIntlContext).init();
169
+ var isDatasource = !!(node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.datasource);
170
+ if (isDatasource) {
171
+ return new _datasource.Datasource({
172
+ node: node,
173
+ view: view,
174
+ getPos: getPos,
175
+ portalProviderAPI: portalProviderAPI,
176
+ eventDispatcher: eventDispatcher,
177
+ hasIntlContext: hasIntlContext,
178
+ pluginInjectionApi: pluginInjectionApi
179
+ }).init();
135
180
  }
136
181
  return new _blockCard.BlockCard(node, view, getPos, portalProviderAPI, eventDispatcher, reactComponentProps, undefined, true, undefined, hasIntlContext).init();
137
182
  },
@@ -36,6 +36,22 @@ var setProvider = function setProvider(state, action) {
36
36
  provider: action.provider
37
37
  });
38
38
  };
39
+ var setCardLayout = function setCardLayout(state, action) {
40
+ return _objectSpread(_objectSpread({}, state), {}, {
41
+ layout: action.layout
42
+ });
43
+ };
44
+ var setDatasourceTableRef = function setDatasourceTableRef(state, action) {
45
+ return _objectSpread(_objectSpread({}, state), {}, {
46
+ datasourceTableRef: action.datasourceTableRef
47
+ });
48
+ };
49
+ var setCardLayoutDatasourceTableRef = function setCardLayoutDatasourceTableRef(state, action) {
50
+ return _objectSpread(_objectSpread({}, state), {}, {
51
+ datasourceTableRef: action.datasourceTableRef,
52
+ layout: action.layout
53
+ });
54
+ };
39
55
  var registerEvents = function registerEvents(state, action) {
40
56
  return _objectSpread(_objectSpread({}, state), {}, {
41
57
  smartLinkEvents: action.smartLinkEvents
@@ -65,6 +81,12 @@ var _default = function _default(state, action) {
65
81
  return registerEvents(state, action);
66
82
  case 'REGISTER_EVENTS_NEXT':
67
83
  return registerEventsNext(state, action);
84
+ case 'SET_DATASOURCE_TABLE_REF':
85
+ return setDatasourceTableRef(state, action);
86
+ case 'SET_CARD_LAYOUT':
87
+ return setCardLayout(state, action);
88
+ case 'SET_CARD_LAYOUT_AND_DATASOURCE_TABLE_REF':
89
+ return setCardLayoutDatasourceTableRef(state, action);
68
90
  case 'SHOW_LINK_TOOLBAR':
69
91
  case 'HIDE_LINK_TOOLBAR':
70
92
  return setLinkToolbar(state, action);
@@ -13,5 +13,5 @@ var _styles = require("@atlaskit/editor-common/styles");
13
13
  var _templateObject;
14
14
  var FLOATING_TOOLBAR_LINKPICKER_CLASSNAME = 'card-floating-toolbar--link-picker';
15
15
  exports.FLOATING_TOOLBAR_LINKPICKER_CLASSNAME = FLOATING_TOOLBAR_LINKPICKER_CLASSNAME;
16
- var smartCardStyles = (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n .", " {\n max-width: calc(100% - 20px);\n vertical-align: top;\n word-break: break-all;\n\n .card {\n padding-left: 2px;\n padding-right: 2px;\n padding-top: 0.5em;\n padding-bottom: 0.5em;\n margin-bottom: -0.5em;\n\n .", " > a:focus {\n ", "\n }\n }\n\n &.", "\n .", "\n > a {\n ", "\n }\n .", " > a {\n /* EDM-1717: box-shadow Safari fix start */\n z-index: 1;\n position: relative;\n /* EDM-1717: box-shadow Safari fix end */\n }\n\n &.danger {\n .", " > a {\n box-shadow: 0 0 0 1px\n ", ";\n /* EDM-1717: box-shadow Safari fix start */\n z-index: 2;\n /* EDM-1717: box-shadow Safari fix end */\n }\n }\n }\n\n .", " {\n .", " > div {\n cursor: pointer;\n &:hover {\n background-color: ", ";\n }\n }\n\n &.", "\n .", "\n > div {\n ", "\n }\n\n &.danger {\n .", " > div {\n box-shadow: 0 0 0 1px\n ", " !important;\n }\n }\n }\n\n .", " {\n .", " > div {\n cursor: pointer;\n &::after {\n transition: box-shadow 0s;\n }\n }\n &.", "\n .", "\n > div {\n ", "\n }\n\n &.", "\n .", "\n > div::after {\n ", "\n }\n\n &.danger {\n .media-card-frame::after {\n box-shadow: 0 0 0 1px\n ", " !important;\n background: ", " !important;\n }\n .richMedia-resize-handle-right::after,\n .richMedia-resize-handle-left::after {\n background: ", ";\n }\n }\n }\n\n .", " {\n padding: 0;\n }\n"])), _styles.SmartCardSharedCssClassName.INLINE_CARD_CONTAINER, _styles.SmartCardSharedCssClassName.LOADER_WRAPPER, (0, _editorSharedStyles.getSelectionStyles)([_editorSharedStyles.SelectionStyle.BoxShadow]), _editorSharedStyles.akEditorSelectedNodeClassName, _styles.SmartCardSharedCssClassName.LOADER_WRAPPER, (0, _editorSharedStyles.getSelectionStyles)([_editorSharedStyles.SelectionStyle.BoxShadow]), _styles.SmartCardSharedCssClassName.LOADER_WRAPPER, _styles.SmartCardSharedCssClassName.LOADER_WRAPPER, "var(--ds-border-danger, ".concat(_editorSharedStyles.akEditorDeleteBorder, ")"), _styles.SmartCardSharedCssClassName.BLOCK_CARD_CONTAINER, _styles.SmartCardSharedCssClassName.LOADER_WRAPPER, "var(--ds-background-neutral-subtle-hovered, ".concat(_colors.N20, ")"), _editorSharedStyles.akEditorSelectedNodeClassName, _styles.SmartCardSharedCssClassName.LOADER_WRAPPER, (0, _editorSharedStyles.getSelectionStyles)([_editorSharedStyles.SelectionStyle.BoxShadow]), _styles.SmartCardSharedCssClassName.LOADER_WRAPPER, "var(--ds-border-danger, ".concat(_editorSharedStyles.akEditorDeleteBorder, ")"), _styles.SmartCardSharedCssClassName.EMBED_CARD_CONTAINER, _styles.SmartCardSharedCssClassName.LOADER_WRAPPER, _editorSharedStyles.akEditorSelectedNodeClassName, _styles.SmartCardSharedCssClassName.LOADER_WRAPPER, (0, _editorSharedStyles.getSelectionStyles)([_editorSharedStyles.SelectionStyle.BoxShadow]), _editorSharedStyles.akEditorSelectedNodeClassName, _styles.SmartCardSharedCssClassName.LOADER_WRAPPER, (0, _editorSharedStyles.getSelectionStyles)([_editorSharedStyles.SelectionStyle.BoxShadow]), "var(--ds-border-danger, ".concat(_editorSharedStyles.akEditorDeleteBorder, ")"), "var(--ds-background-danger, ".concat(_editorSharedStyles.akEditorDeleteBackground, ")"), "var(--ds-border-danger, ".concat(_editorSharedStyles.akEditorDeleteBorder, ")"), FLOATING_TOOLBAR_LINKPICKER_CLASSNAME);
16
+ var smartCardStyles = (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n .", " {\n max-width: calc(100% - 20px);\n vertical-align: top;\n word-break: break-all;\n\n .card {\n padding-left: 2px;\n padding-right: 2px;\n padding-top: 0.5em;\n padding-bottom: 0.5em;\n margin-bottom: -0.5em;\n\n .", " > a:focus {\n ", "\n }\n }\n\n &.", "\n .", "\n > a {\n ", "\n }\n .", " > a {\n /* EDM-1717: box-shadow Safari fix start */\n z-index: 1;\n position: relative;\n /* EDM-1717: box-shadow Safari fix end */\n }\n\n &.danger {\n .", " > a {\n box-shadow: 0 0 0 1px\n ", ";\n /* EDM-1717: box-shadow Safari fix start */\n z-index: 2;\n /* EDM-1717: box-shadow Safari fix end */\n }\n }\n }\n\n .", " {\n .", " > div {\n cursor: pointer;\n &:hover {\n background-color: ", ";\n }\n }\n\n &.", "\n .", "\n > div {\n ", "\n }\n\n &.danger {\n .", " > div {\n box-shadow: 0 0 0 1px\n ", " !important;\n }\n }\n }\n\n .", ".", " {\n max-width: 100%;\n display: flex;\n justify-content: center;\n }\n\n .", " {\n .", " > div {\n cursor: pointer;\n &::after {\n transition: box-shadow 0s;\n }\n }\n &.", "\n .", "\n > div {\n ", "\n }\n\n &.", "\n .", "\n > div::after {\n ", "\n }\n\n &.danger {\n .media-card-frame::after {\n box-shadow: 0 0 0 1px\n ", " !important;\n background: ", " !important;\n }\n .richMedia-resize-handle-right::after,\n .richMedia-resize-handle-left::after {\n background: ", ";\n }\n }\n }\n\n .", " {\n padding: 0;\n }\n"])), _styles.SmartCardSharedCssClassName.INLINE_CARD_CONTAINER, _styles.SmartCardSharedCssClassName.LOADER_WRAPPER, (0, _editorSharedStyles.getSelectionStyles)([_editorSharedStyles.SelectionStyle.BoxShadow]), _editorSharedStyles.akEditorSelectedNodeClassName, _styles.SmartCardSharedCssClassName.LOADER_WRAPPER, (0, _editorSharedStyles.getSelectionStyles)([_editorSharedStyles.SelectionStyle.BoxShadow]), _styles.SmartCardSharedCssClassName.LOADER_WRAPPER, _styles.SmartCardSharedCssClassName.LOADER_WRAPPER, "var(--ds-border-danger, ".concat(_editorSharedStyles.akEditorDeleteBorder, ")"), _styles.SmartCardSharedCssClassName.BLOCK_CARD_CONTAINER, _styles.SmartCardSharedCssClassName.LOADER_WRAPPER, "var(--ds-background-neutral-subtle-hovered, ".concat(_colors.N20, ")"), _editorSharedStyles.akEditorSelectedNodeClassName, _styles.SmartCardSharedCssClassName.LOADER_WRAPPER, (0, _editorSharedStyles.getSelectionStyles)([_editorSharedStyles.SelectionStyle.BoxShadow]), _styles.SmartCardSharedCssClassName.LOADER_WRAPPER, "var(--ds-border-danger, ".concat(_editorSharedStyles.akEditorDeleteBorder, ")"), _styles.SmartCardSharedCssClassName.DATASOURCE_CONTAINER, _styles.SmartCardSharedCssClassName.BLOCK_CARD_CONTAINER, _styles.SmartCardSharedCssClassName.EMBED_CARD_CONTAINER, _styles.SmartCardSharedCssClassName.LOADER_WRAPPER, _editorSharedStyles.akEditorSelectedNodeClassName, _styles.SmartCardSharedCssClassName.LOADER_WRAPPER, (0, _editorSharedStyles.getSelectionStyles)([_editorSharedStyles.SelectionStyle.BoxShadow]), _editorSharedStyles.akEditorSelectedNodeClassName, _styles.SmartCardSharedCssClassName.LOADER_WRAPPER, (0, _editorSharedStyles.getSelectionStyles)([_editorSharedStyles.SelectionStyle.BoxShadow]), "var(--ds-border-danger, ".concat(_editorSharedStyles.akEditorDeleteBorder, ")"), "var(--ds-background-danger, ".concat(_editorSharedStyles.akEditorDeleteBackground, ")"), "var(--ds-border-danger, ".concat(_editorSharedStyles.akEditorDeleteBorder, ")"), FLOATING_TOOLBAR_LINKPICKER_CLASSNAME);
17
17
  exports.smartCardStyles = smartCardStyles;
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = exports.LayoutButton = void 0;
9
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _react = _interopRequireWildcard(require("react"));
11
+ var _react2 = require("@emotion/react");
12
+ var _ui = require("@atlaskit/editor-common/ui");
13
+ var _uiMenu = require("@atlaskit/editor-common/ui-menu");
14
+ var _collapse = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/collapse"));
15
+ var _expand = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/expand"));
16
+ var _reactIntlNext = require("react-intl-next");
17
+ var _styled = require("./styled");
18
+ var _utils = require("./utils");
19
+ var _hooks = require("@atlaskit/editor-common/hooks");
20
+ var _actions = require("../../pm-plugins/actions");
21
+ var _utils2 = require("@atlaskit/editor-common/utils");
22
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
24
+ 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; }
25
+ 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; } /** @jsx jsx */
26
+ var LayoutButton = function LayoutButton(_ref) {
27
+ var onLayoutChange = _ref.onLayoutChange,
28
+ _ref$layout = _ref.layout,
29
+ layout = _ref$layout === void 0 ? 'center' : _ref$layout,
30
+ formatMessage = _ref.intl.formatMessage,
31
+ mountPoint = _ref.mountPoint,
32
+ boundariesElement = _ref.boundariesElement,
33
+ scrollableElement = _ref.scrollableElement,
34
+ targetElement = _ref.targetElement,
35
+ _ref$testId = _ref.testId,
36
+ testId = _ref$testId === void 0 ? 'datasource-table-layout-button' : _ref$testId;
37
+ var handleClick = (0, _react.useCallback)(function () {
38
+ onLayoutChange && onLayoutChange((0, _utils2.getNextBreakoutMode)(layout));
39
+ }, [layout, onLayoutChange]);
40
+ var title = (0, _react.useMemo)(function () {
41
+ return formatMessage((0, _utils2.getTitle)(layout));
42
+ }, [formatMessage, layout]);
43
+ if (!targetElement) {
44
+ return null;
45
+ }
46
+ return (0, _react2.jsx)(_ui.Popup, {
47
+ mountTo: mountPoint,
48
+ boundariesElement: boundariesElement,
49
+ scrollableElement: scrollableElement,
50
+ target: targetElement,
51
+ alignY: "start",
52
+ alignX: "end",
53
+ forcePlacement: true,
54
+ stick: true,
55
+ ariaLabel: title
56
+ }, (0, _react2.jsx)(_uiMenu.ToolbarButton, {
57
+ testId: testId,
58
+ css: _styled.toolbarButtonWrapper,
59
+ title: title,
60
+ onClick: handleClick,
61
+ iconBefore: layout === 'full-width' ? (0, _react2.jsx)(_collapse.default, {
62
+ label: title
63
+ }) : (0, _react2.jsx)(_expand.default, {
64
+ label: title
65
+ })
66
+ }));
67
+ };
68
+ exports.LayoutButton = LayoutButton;
69
+ var LayoutButtonWrapper = function LayoutButtonWrapper(_ref2) {
70
+ var _node$attrs, _node$attrs2;
71
+ var editorView = _ref2.editorView,
72
+ mountPoint = _ref2.mountPoint,
73
+ scrollableElement = _ref2.scrollableElement,
74
+ boundariesElement = _ref2.boundariesElement,
75
+ intl = _ref2.intl,
76
+ api = _ref2.api;
77
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['card']),
78
+ cardState = _useSharedPluginState.cardState;
79
+ var _getDatasource = (0, _utils.getDatasource)(editorView),
80
+ node = _getDatasource.node,
81
+ pos = _getDatasource.pos;
82
+ var _ref3 = cardState !== null && cardState !== void 0 ? cardState : {},
83
+ datasourceTableRef = _ref3.datasourceTableRef,
84
+ _ref3$layout = _ref3.layout,
85
+ layout = _ref3$layout === void 0 ? (node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.layout) || 'center' : _ref3$layout;
86
+ var isDatasource = !!(node !== null && node !== void 0 && (_node$attrs2 = node.attrs) !== null && _node$attrs2 !== void 0 && _node$attrs2.datasource);
87
+ var onLayoutChange = function onLayoutChange(layout) {
88
+ if (pos === undefined) {
89
+ return;
90
+ }
91
+ var state = editorView.state,
92
+ dispatch = editorView.dispatch;
93
+ var tr = state.tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, node === null || node === void 0 ? void 0 : node.attrs), {}, {
94
+ layout: layout
95
+ }));
96
+ tr.setMeta('scrollIntoView', false);
97
+ dispatch((0, _actions.setCardLayout)(layout)(tr));
98
+ };
99
+ if (!isDatasource) {
100
+ return null;
101
+ }
102
+ return (0, _react2.jsx)(LayoutButton, {
103
+ mountPoint: mountPoint,
104
+ scrollableElement: scrollableElement,
105
+ boundariesElement: boundariesElement,
106
+ targetElement: datasourceTableRef,
107
+ layout: layout,
108
+ onLayoutChange: onLayoutChange,
109
+ intl: intl
110
+ });
111
+ };
112
+ var _default = (0, _reactIntlNext.injectIntl)(LayoutButtonWrapper);
113
+ exports.default = _default;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.toolbarButtonWrapper = void 0;
7
+ var _react = require("@emotion/react");
8
+ var _colors = require("@atlaskit/theme/colors");
9
+ var toolbarButtonWrapper = (0, _react.css)({
10
+ background: "".concat("var(--ds-background-neutral, ".concat(_colors.N20A, ")")),
11
+ color: "".concat("var(--ds-icon, ".concat(_colors.N300, ")")),
12
+ ':hover': {
13
+ background: "".concat("var(--ds-background-neutral-hovered, ".concat(_colors.B300, ")")),
14
+ color: "var(--ds-icon, white)".concat(" !important")
15
+ }
16
+ });
17
+ exports.toolbarButtonWrapper = toolbarButtonWrapper;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getDatasource = void 0;
7
+ var _prosemirrorUtils = require("prosemirror-utils");
8
+ var getDatasource = function getDatasource(editorView) {
9
+ var _findSelectedNodeOfTy;
10
+ var _editorView$state = editorView.state,
11
+ selection = _editorView$state.selection,
12
+ schema = _editorView$state.schema;
13
+ var blockCard = schema.nodes.blockCard;
14
+ return (_findSelectedNodeOfTy = (0, _prosemirrorUtils.findSelectedNodeOfType)([blockCard])(selection)) !== null && _findSelectedNodeOfTy !== void 0 ? _findSelectedNodeOfTy : {
15
+ node: undefined,
16
+ pos: undefined
17
+ };
18
+ };
19
+ exports.getDatasource = getDatasource;
@@ -452,8 +452,27 @@ var MediaPluginStateImplementation = /*#__PURE__*/function () {
452
452
  var _this$view = _this.view,
453
453
  dispatch = _this$view.dispatch,
454
454
  state = _this$view.state;
455
+ var tr = state.tr,
456
+ selection = state.selection,
457
+ doc = state.doc;
458
+ var _state$schema$nodes = state.schema.nodes,
459
+ media = _state$schema$nodes.media,
460
+ mediaGroup = _state$schema$nodes.mediaGroup;
461
+
462
+ // Workaround for wrong upload position
463
+ // @see https://product-fabric.atlassian.net/browse/MEX-2457
464
+ // If the media node is the last selectable item in the current cursor position and it is located within a mediaGroup,
465
+ // we relocate the cursor to the first child of the mediaGroup.
466
+ var sel = _prosemirrorState.Selection.findFrom(doc.resolve(selection.$from.pos - 1), -1);
467
+ if (sel && (0, _prosemirrorUtils.findSelectedNodeOfType)(media)(sel)) {
468
+ var parent = (0, _prosemirrorUtils.findParentNodeOfType)(mediaGroup)(sel);
469
+ if (parent) {
470
+ tr.setSelection(_prosemirrorState.NodeSelection.create(tr.doc, parent.start));
471
+ }
472
+ }
473
+
455
474
  // Trigger state change to be able to pick it up in the decorations handler
456
- dispatch(state.tr);
475
+ dispatch(tr);
457
476
  });
458
477
  this.options = options;
459
478
  this.mediaOptions = mediaOptions;
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.version = exports.nextMajorVersion = exports.name = void 0;
7
7
  var name = "@atlaskit/editor-core";
8
8
  exports.name = name;
9
- var version = "185.5.2";
9
+ var version = "185.5.5";
10
10
  exports.version = version;
11
11
  var nextMajorVersion = function nextMajorVersion() {
12
12
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "185.5.2",
3
+ "version": "185.5.5",
4
4
  "sideEffects": false
5
5
  }