@atlaskit/editor-plugin-layout 1.12.13 → 1.12.14

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,14 @@
1
1
  # @atlaskit/editor-plugin-layout
2
2
 
3
+ ## 1.12.14
4
+
5
+ ### Patch Changes
6
+
7
+ - [#176299](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/176299)
8
+ [`798c7904ad3ff`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/798c7904ad3ff) -
9
+ ED-25926 improve placeholder and seperator apperance
10
+ - Updated dependencies
11
+
3
12
  ## 1.12.13
4
13
 
5
14
  ### Patch Changes
@@ -1,22 +1,47 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.LayoutSectionView = void 0;
8
9
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
10
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
11
11
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
12
12
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
13
- var _react = _interopRequireDefault(require("react"));
13
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
14
+ var _react = _interopRequireWildcard(require("react"));
14
15
  var _hooks = require("@atlaskit/editor-common/hooks");
15
16
  var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/react-node-view"));
16
17
  var _resizer = require("@atlaskit/editor-common/resizer");
17
18
  var _model = require("@atlaskit/editor-prosemirror/model");
18
- function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = (0, _getPrototypeOf2.default)(t); if (r) { var s = (0, _getPrototypeOf2.default)(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return (0, _possibleConstructorReturn2.default)(this, e); }; }
19
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
20
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
21
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
22
+ function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
19
23
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
24
+ var isEmptyParagraph = function isEmptyParagraph(node) {
25
+ return !!node && node.type.name === 'paragraph' && !node.childCount;
26
+ };
27
+ var isEmptyLayout = function isEmptyLayout(node) {
28
+ if (!node) {
29
+ return false;
30
+ }
31
+ // fast check
32
+ // each column should have size 2 from layoutcolumn and 2 from empty paragraph
33
+ if (node.content.size / node.childCount !== 4) {
34
+ return false;
35
+ }
36
+ var isEmpty = true;
37
+ node.content.forEach(function (maybelayoutColumn) {
38
+ if (maybelayoutColumn.type.name !== 'layoutColumn' || maybelayoutColumn.childCount > 1 || !isEmptyParagraph(maybelayoutColumn.firstChild)) {
39
+ isEmpty = false;
40
+ return;
41
+ }
42
+ });
43
+ return isEmpty;
44
+ };
20
45
  var LayoutBreakoutResizer = function LayoutBreakoutResizer(_ref) {
21
46
  var _pluginInjectionApi$a;
22
47
  var pluginInjectionApi = _ref.pluginInjectionApi,
@@ -30,6 +55,10 @@ var LayoutBreakoutResizer = function LayoutBreakoutResizer(_ref) {
30
55
  var _pluginInjectionApi$w;
31
56
  return pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$w = pluginInjectionApi.width) === null || _pluginInjectionApi$w === void 0 ? void 0 : _pluginInjectionApi$w.sharedState.currentState();
32
57
  };
58
+ var displayGapCursor = (0, _react.useCallback)(function (toggle) {
59
+ var _pluginInjectionApi$c, _pluginInjectionApi$c2, _pluginInjectionApi$s;
60
+ return (_pluginInjectionApi$c = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c2 = pluginInjectionApi.core) === null || _pluginInjectionApi$c2 === void 0 ? void 0 : _pluginInjectionApi$c2.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$s = pluginInjectionApi.selection) === null || _pluginInjectionApi$s === void 0 ? void 0 : _pluginInjectionApi$s.commands.displayGapCursor(toggle))) !== null && _pluginInjectionApi$c !== void 0 ? _pluginInjectionApi$c : false;
61
+ }, [pluginInjectionApi]);
33
62
  return /*#__PURE__*/_react.default.createElement(_resizer.BreakoutResizer, {
34
63
  getRef: forwardRef,
35
64
  getPos: getPos,
@@ -38,7 +67,8 @@ var LayoutBreakoutResizer = function LayoutBreakoutResizer(_ref) {
38
67
  getEditorWidth: getEditorWidth,
39
68
  disabled: (editorDisabledState === null || editorDisabledState === void 0 ? void 0 : editorDisabledState.editorDisabled) === true,
40
69
  parentRef: parentRef,
41
- editorAnalyticsApi: pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions
70
+ editorAnalyticsApi: pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions,
71
+ displayGapCursor: displayGapCursor
42
72
  });
43
73
  };
44
74
  var toDOM = function toDOM() {
@@ -49,16 +79,18 @@ var toDOM = function toDOM() {
49
79
  }, 0]];
50
80
  };
51
81
  var LayoutSectionView = exports.LayoutSectionView = /*#__PURE__*/function (_ReactNodeView) {
52
- (0, _inherits2.default)(LayoutSectionView, _ReactNodeView);
53
- var _super = _createSuper(LayoutSectionView);
54
82
  function LayoutSectionView(props) {
55
83
  var _this;
56
84
  (0, _classCallCheck2.default)(this, LayoutSectionView);
57
- _this = _super.call(this, props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props);
85
+ _this = _callSuper(this, LayoutSectionView, [props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props]);
86
+ if ((0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_1')) {
87
+ _this.isEmpty = isEmptyLayout(_this.node);
88
+ }
58
89
  _this.options = props.options;
59
90
  return _this;
60
91
  }
61
- (0, _createClass2.default)(LayoutSectionView, [{
92
+ (0, _inherits2.default)(LayoutSectionView, _ReactNodeView);
93
+ return (0, _createClass2.default)(LayoutSectionView, [{
62
94
  key: "getContentDOM",
63
95
  value: function getContentDOM() {
64
96
  var _ref2 = _model.DOMSerializer.renderSpec(document, toDOM()),
@@ -66,6 +98,9 @@ var LayoutSectionView = exports.LayoutSectionView = /*#__PURE__*/function (_Reac
66
98
  contentDOM = _ref2.contentDOM;
67
99
  this.layoutDOM = container.querySelector('[data-layout-section]');
68
100
  this.layoutDOM.setAttribute('data-column-rule-style', this.node.attrs.columnRuleStyle);
101
+ if ((0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_1')) {
102
+ this.layoutDOM.setAttribute('data-empty-layout', Boolean(this.isEmpty).toString());
103
+ }
69
104
  return {
70
105
  dom: container,
71
106
  contentDOM: contentDOM
@@ -81,6 +116,12 @@ var LayoutSectionView = exports.LayoutSectionView = /*#__PURE__*/function (_Reac
81
116
  }, {
82
117
  key: "render",
83
118
  value: function render(props, forwardRef) {
119
+ if ((0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_1')) {
120
+ this.isEmpty = isEmptyLayout(this.node);
121
+ if (this.layoutDOM) {
122
+ this.layoutDOM.setAttribute('data-empty-layout', Boolean(this.isEmpty).toString());
123
+ }
124
+ }
84
125
  return /*#__PURE__*/_react.default.createElement(LayoutBreakoutResizer, {
85
126
  pluginInjectionApi: props.pluginInjectionApi,
86
127
  forwardRef: forwardRef,
@@ -95,5 +136,4 @@ var LayoutSectionView = exports.LayoutSectionView = /*#__PURE__*/function (_Reac
95
136
  return (0, _resizer.ignoreResizerMutations)(mutation);
96
137
  }
97
138
  }]);
98
- return LayoutSectionView;
99
139
  }(_reactNodeView.default);
@@ -14,6 +14,7 @@ var _utils = require("@atlaskit/editor-common/utils");
14
14
  var _model = require("@atlaskit/editor-prosemirror/model");
15
15
  var _state = require("@atlaskit/editor-prosemirror/state");
16
16
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
17
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
17
18
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
18
19
  var _consts = require("./consts");
19
20
  var _pluginKey = require("./plugin-key");
@@ -382,7 +383,9 @@ function layoutNeedChanges(node) {
382
383
  var getDefaultPresetLayout = function getDefaultPresetLayout(layoutNode) {
383
384
  var layoutColumnCount = layoutNode.childCount;
384
385
  if (layoutColumnCount <= 1) {
385
- return 'single';
386
+ // This prevents the creation of a single column layout
387
+ // once we support single column layout, we can return 'single'
388
+ return (0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_1') ? 'two_equal' : 'single';
386
389
  }
387
390
  switch (layoutColumnCount) {
388
391
  case 2:
@@ -8,6 +8,7 @@ var _react = require("react");
8
8
  var _react2 = require("@emotion/react");
9
9
  var _reactIntlNext = require("react-intl-next");
10
10
  var _messages = require("@atlaskit/editor-common/messages");
11
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
11
12
  /**
12
13
  * @jsxRuntime classic
13
14
  * @jsx jsx
@@ -16,6 +17,23 @@ var _messages = require("@atlaskit/editor-common/messages");
16
17
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles, @atlaskit/ui-styling-standard/use-compiled
17
18
 
18
19
  var getPlaceholderStyle = function getPlaceholderStyle(message) {
20
+ if ((0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_1')) {
21
+ return (0, _react2.css)({
22
+ // when paragraph is the only child, and it only has a trailingBreak.
23
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
24
+ '.ProseMirror .layoutSectionView-content-wrap.selected [data-layout-column] > [data-layout-content] > p:only-child:has(.ProseMirror-trailingBreak:only-child)': {
25
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles -- Ignored via go/DSP-18766
26
+ '&::before': {
27
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values
28
+ content: "\"".concat(message, "\""),
29
+ position: 'absolute',
30
+ color: "var(--ds-text-disabled, #A5ADBA)",
31
+ font: "var(--ds-font-body, normal 400 14px/20px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
32
+ marginTop: "var(--ds-space-050, 4px)"
33
+ }
34
+ }
35
+ });
36
+ }
19
37
  return (0, _react2.css)({
20
38
  // when paragraph is the only child, and it only has a trailingBreak.
21
39
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
@@ -1,8 +1,30 @@
1
- import React from 'react';
1
+ import React, { useCallback } from 'react';
2
2
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
3
3
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
4
4
  import { BreakoutResizer, ignoreResizerMutations } from '@atlaskit/editor-common/resizer';
5
5
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
6
+ import { fg } from '@atlaskit/platform-feature-flags';
7
+ const isEmptyParagraph = node => {
8
+ return !!node && node.type.name === 'paragraph' && !node.childCount;
9
+ };
10
+ const isEmptyLayout = node => {
11
+ if (!node) {
12
+ return false;
13
+ }
14
+ // fast check
15
+ // each column should have size 2 from layoutcolumn and 2 from empty paragraph
16
+ if (node.content.size / node.childCount !== 4) {
17
+ return false;
18
+ }
19
+ let isEmpty = true;
20
+ node.content.forEach(maybelayoutColumn => {
21
+ if (maybelayoutColumn.type.name !== 'layoutColumn' || maybelayoutColumn.childCount > 1 || !isEmptyParagraph(maybelayoutColumn.firstChild)) {
22
+ isEmpty = false;
23
+ return;
24
+ }
25
+ });
26
+ return isEmpty;
27
+ };
6
28
  const LayoutBreakoutResizer = ({
7
29
  pluginInjectionApi,
8
30
  forwardRef,
@@ -18,6 +40,10 @@ const LayoutBreakoutResizer = ({
18
40
  var _pluginInjectionApi$w;
19
41
  return pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$w = pluginInjectionApi.width) === null || _pluginInjectionApi$w === void 0 ? void 0 : _pluginInjectionApi$w.sharedState.currentState();
20
42
  };
43
+ const displayGapCursor = useCallback(toggle => {
44
+ var _pluginInjectionApi$c, _pluginInjectionApi$c2, _pluginInjectionApi$s;
45
+ return (_pluginInjectionApi$c = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c2 = pluginInjectionApi.core) === null || _pluginInjectionApi$c2 === void 0 ? void 0 : _pluginInjectionApi$c2.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$s = pluginInjectionApi.selection) === null || _pluginInjectionApi$s === void 0 ? void 0 : _pluginInjectionApi$s.commands.displayGapCursor(toggle))) !== null && _pluginInjectionApi$c !== void 0 ? _pluginInjectionApi$c : false;
46
+ }, [pluginInjectionApi]);
21
47
  return /*#__PURE__*/React.createElement(BreakoutResizer, {
22
48
  getRef: forwardRef,
23
49
  getPos: getPos,
@@ -26,7 +52,8 @@ const LayoutBreakoutResizer = ({
26
52
  getEditorWidth: getEditorWidth,
27
53
  disabled: (editorDisabledState === null || editorDisabledState === void 0 ? void 0 : editorDisabledState.editorDisabled) === true,
28
54
  parentRef: parentRef,
29
- editorAnalyticsApi: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions
55
+ editorAnalyticsApi: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions,
56
+ displayGapCursor: displayGapCursor
30
57
  });
31
58
  };
32
59
  const toDOM = () => ['div', {
@@ -37,6 +64,9 @@ const toDOM = () => ['div', {
37
64
  export class LayoutSectionView extends ReactNodeView {
38
65
  constructor(props) {
39
66
  super(props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props);
67
+ if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
68
+ this.isEmpty = isEmptyLayout(this.node);
69
+ }
40
70
  this.options = props.options;
41
71
  }
42
72
  getContentDOM() {
@@ -46,6 +76,9 @@ export class LayoutSectionView extends ReactNodeView {
46
76
  } = DOMSerializer.renderSpec(document, toDOM());
47
77
  this.layoutDOM = container.querySelector('[data-layout-section]');
48
78
  this.layoutDOM.setAttribute('data-column-rule-style', this.node.attrs.columnRuleStyle);
79
+ if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
80
+ this.layoutDOM.setAttribute('data-empty-layout', Boolean(this.isEmpty).toString());
81
+ }
49
82
  return {
50
83
  dom: container,
51
84
  contentDOM
@@ -57,6 +90,12 @@ export class LayoutSectionView extends ReactNodeView {
57
90
  }
58
91
  }
59
92
  render(props, forwardRef) {
93
+ if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
94
+ this.isEmpty = isEmptyLayout(this.node);
95
+ if (this.layoutDOM) {
96
+ this.layoutDOM.setAttribute('data-empty-layout', Boolean(this.isEmpty).toString());
97
+ }
98
+ }
60
99
  return /*#__PURE__*/React.createElement(LayoutBreakoutResizer, {
61
100
  pluginInjectionApi: props.pluginInjectionApi,
62
101
  forwardRef: forwardRef,
@@ -4,6 +4,7 @@ import { flatmap, getStepRange, isEmptyDocument, mapChildren } from '@atlaskit/e
4
4
  import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
5
5
  import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
6
6
  import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
7
+ import { fg } from '@atlaskit/platform-feature-flags';
7
8
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
8
9
  import { EVEN_DISTRIBUTED_COL_WIDTHS } from './consts';
9
10
  import { pluginKey } from './plugin-key';
@@ -357,7 +358,9 @@ function layoutNeedChanges(node) {
357
358
  const getDefaultPresetLayout = layoutNode => {
358
359
  const layoutColumnCount = layoutNode.childCount;
359
360
  if (layoutColumnCount <= 1) {
360
- return 'single';
361
+ // This prevents the creation of a single column layout
362
+ // once we support single column layout, we can return 'single'
363
+ return fg('platform_editor_advanced_layouts_post_fix_patch_1') ? 'two_equal' : 'single';
361
364
  }
362
365
  switch (layoutColumnCount) {
363
366
  case 2:
@@ -8,21 +8,41 @@ import { useMemo } from 'react';
8
8
  import { css, Global, jsx } from '@emotion/react';
9
9
  import { useIntl } from 'react-intl-next';
10
10
  import { layoutMessages as messages } from '@atlaskit/editor-common/messages';
11
- const getPlaceholderStyle = message => css({
12
- // when paragraph is the only child, and it only has a trailingBreak.
13
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
14
- '.ProseMirror [data-layout-column] > [data-layout-content] > p:only-child:has(.ProseMirror-trailingBreak:only-child)': {
15
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles -- Ignored via go/DSP-18766
16
- '&::before': {
17
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values
18
- content: `"${message}"`,
19
- position: 'absolute',
20
- color: "var(--ds-text-disabled, #A5ADBA)",
21
- font: "var(--ds-font-body, normal 400 14px/20px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
22
- marginTop: "var(--ds-space-050, 4px)"
23
- }
11
+ import { fg } from '@atlaskit/platform-feature-flags';
12
+ const getPlaceholderStyle = message => {
13
+ if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
14
+ return css({
15
+ // when paragraph is the only child, and it only has a trailingBreak.
16
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
17
+ '.ProseMirror .layoutSectionView-content-wrap.selected [data-layout-column] > [data-layout-content] > p:only-child:has(.ProseMirror-trailingBreak:only-child)': {
18
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles -- Ignored via go/DSP-18766
19
+ '&::before': {
20
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values
21
+ content: `"${message}"`,
22
+ position: 'absolute',
23
+ color: "var(--ds-text-disabled, #A5ADBA)",
24
+ font: "var(--ds-font-body, normal 400 14px/20px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
25
+ marginTop: "var(--ds-space-050, 4px)"
26
+ }
27
+ }
28
+ });
24
29
  }
25
- });
30
+ return css({
31
+ // when paragraph is the only child, and it only has a trailingBreak.
32
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
33
+ '.ProseMirror [data-layout-column] > [data-layout-content] > p:only-child:has(.ProseMirror-trailingBreak:only-child)': {
34
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles -- Ignored via go/DSP-18766
35
+ '&::before': {
36
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values
37
+ content: `"${message}"`,
38
+ position: 'absolute',
39
+ color: "var(--ds-text-disabled, #A5ADBA)",
40
+ font: "var(--ds-font-body, normal 400 14px/20px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
41
+ marginTop: "var(--ds-space-050, 4px)"
42
+ }
43
+ }
44
+ });
45
+ };
26
46
  export const GlobalStylesWrapper = () => {
27
47
  const {
28
48
  formatMessage
@@ -1,15 +1,37 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/createClass";
3
- import _inherits from "@babel/runtime/helpers/inherits";
4
3
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
4
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
- function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
5
+ import _inherits from "@babel/runtime/helpers/inherits";
6
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
7
7
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
8
- import React from 'react';
8
+ import React, { useCallback } from 'react';
9
9
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
10
10
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
11
11
  import { BreakoutResizer, ignoreResizerMutations } from '@atlaskit/editor-common/resizer';
12
12
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
13
+ import { fg } from '@atlaskit/platform-feature-flags';
14
+ var isEmptyParagraph = function isEmptyParagraph(node) {
15
+ return !!node && node.type.name === 'paragraph' && !node.childCount;
16
+ };
17
+ var isEmptyLayout = function isEmptyLayout(node) {
18
+ if (!node) {
19
+ return false;
20
+ }
21
+ // fast check
22
+ // each column should have size 2 from layoutcolumn and 2 from empty paragraph
23
+ if (node.content.size / node.childCount !== 4) {
24
+ return false;
25
+ }
26
+ var isEmpty = true;
27
+ node.content.forEach(function (maybelayoutColumn) {
28
+ if (maybelayoutColumn.type.name !== 'layoutColumn' || maybelayoutColumn.childCount > 1 || !isEmptyParagraph(maybelayoutColumn.firstChild)) {
29
+ isEmpty = false;
30
+ return;
31
+ }
32
+ });
33
+ return isEmpty;
34
+ };
13
35
  var LayoutBreakoutResizer = function LayoutBreakoutResizer(_ref) {
14
36
  var _pluginInjectionApi$a;
15
37
  var pluginInjectionApi = _ref.pluginInjectionApi,
@@ -23,6 +45,10 @@ var LayoutBreakoutResizer = function LayoutBreakoutResizer(_ref) {
23
45
  var _pluginInjectionApi$w;
24
46
  return pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$w = pluginInjectionApi.width) === null || _pluginInjectionApi$w === void 0 ? void 0 : _pluginInjectionApi$w.sharedState.currentState();
25
47
  };
48
+ var displayGapCursor = useCallback(function (toggle) {
49
+ var _pluginInjectionApi$c, _pluginInjectionApi$c2, _pluginInjectionApi$s;
50
+ return (_pluginInjectionApi$c = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c2 = pluginInjectionApi.core) === null || _pluginInjectionApi$c2 === void 0 ? void 0 : _pluginInjectionApi$c2.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$s = pluginInjectionApi.selection) === null || _pluginInjectionApi$s === void 0 ? void 0 : _pluginInjectionApi$s.commands.displayGapCursor(toggle))) !== null && _pluginInjectionApi$c !== void 0 ? _pluginInjectionApi$c : false;
51
+ }, [pluginInjectionApi]);
26
52
  return /*#__PURE__*/React.createElement(BreakoutResizer, {
27
53
  getRef: forwardRef,
28
54
  getPos: getPos,
@@ -31,7 +57,8 @@ var LayoutBreakoutResizer = function LayoutBreakoutResizer(_ref) {
31
57
  getEditorWidth: getEditorWidth,
32
58
  disabled: (editorDisabledState === null || editorDisabledState === void 0 ? void 0 : editorDisabledState.editorDisabled) === true,
33
59
  parentRef: parentRef,
34
- editorAnalyticsApi: pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions
60
+ editorAnalyticsApi: pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions,
61
+ displayGapCursor: displayGapCursor
35
62
  });
36
63
  };
37
64
  var toDOM = function toDOM() {
@@ -42,16 +69,18 @@ var toDOM = function toDOM() {
42
69
  }, 0]];
43
70
  };
44
71
  export var LayoutSectionView = /*#__PURE__*/function (_ReactNodeView) {
45
- _inherits(LayoutSectionView, _ReactNodeView);
46
- var _super = _createSuper(LayoutSectionView);
47
72
  function LayoutSectionView(props) {
48
73
  var _this;
49
74
  _classCallCheck(this, LayoutSectionView);
50
- _this = _super.call(this, props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props);
75
+ _this = _callSuper(this, LayoutSectionView, [props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props]);
76
+ if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
77
+ _this.isEmpty = isEmptyLayout(_this.node);
78
+ }
51
79
  _this.options = props.options;
52
80
  return _this;
53
81
  }
54
- _createClass(LayoutSectionView, [{
82
+ _inherits(LayoutSectionView, _ReactNodeView);
83
+ return _createClass(LayoutSectionView, [{
55
84
  key: "getContentDOM",
56
85
  value: function getContentDOM() {
57
86
  var _ref2 = DOMSerializer.renderSpec(document, toDOM()),
@@ -59,6 +88,9 @@ export var LayoutSectionView = /*#__PURE__*/function (_ReactNodeView) {
59
88
  contentDOM = _ref2.contentDOM;
60
89
  this.layoutDOM = container.querySelector('[data-layout-section]');
61
90
  this.layoutDOM.setAttribute('data-column-rule-style', this.node.attrs.columnRuleStyle);
91
+ if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
92
+ this.layoutDOM.setAttribute('data-empty-layout', Boolean(this.isEmpty).toString());
93
+ }
62
94
  return {
63
95
  dom: container,
64
96
  contentDOM: contentDOM
@@ -74,6 +106,12 @@ export var LayoutSectionView = /*#__PURE__*/function (_ReactNodeView) {
74
106
  }, {
75
107
  key: "render",
76
108
  value: function render(props, forwardRef) {
109
+ if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
110
+ this.isEmpty = isEmptyLayout(this.node);
111
+ if (this.layoutDOM) {
112
+ this.layoutDOM.setAttribute('data-empty-layout', Boolean(this.isEmpty).toString());
113
+ }
114
+ }
77
115
  return /*#__PURE__*/React.createElement(LayoutBreakoutResizer, {
78
116
  pluginInjectionApi: props.pluginInjectionApi,
79
117
  forwardRef: forwardRef,
@@ -88,5 +126,4 @@ export var LayoutSectionView = /*#__PURE__*/function (_ReactNodeView) {
88
126
  return ignoreResizerMutations(mutation);
89
127
  }
90
128
  }]);
91
- return LayoutSectionView;
92
129
  }(ReactNodeView);
@@ -7,6 +7,7 @@ import { flatmap, getStepRange, isEmptyDocument, mapChildren } from '@atlaskit/e
7
7
  import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
8
8
  import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
9
9
  import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
10
+ import { fg } from '@atlaskit/platform-feature-flags';
10
11
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
11
12
  import { EVEN_DISTRIBUTED_COL_WIDTHS } from './consts';
12
13
  import { pluginKey } from './plugin-key';
@@ -373,7 +374,9 @@ function layoutNeedChanges(node) {
373
374
  var getDefaultPresetLayout = function getDefaultPresetLayout(layoutNode) {
374
375
  var layoutColumnCount = layoutNode.childCount;
375
376
  if (layoutColumnCount <= 1) {
376
- return 'single';
377
+ // This prevents the creation of a single column layout
378
+ // once we support single column layout, we can return 'single'
379
+ return fg('platform_editor_advanced_layouts_post_fix_patch_1') ? 'two_equal' : 'single';
377
380
  }
378
381
  switch (layoutColumnCount) {
379
382
  case 2:
@@ -8,7 +8,25 @@ import { useMemo } from 'react';
8
8
  import { css, Global, jsx } from '@emotion/react';
9
9
  import { useIntl } from 'react-intl-next';
10
10
  import { layoutMessages as messages } from '@atlaskit/editor-common/messages';
11
+ import { fg } from '@atlaskit/platform-feature-flags';
11
12
  var getPlaceholderStyle = function getPlaceholderStyle(message) {
13
+ if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
14
+ return css({
15
+ // when paragraph is the only child, and it only has a trailingBreak.
16
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
17
+ '.ProseMirror .layoutSectionView-content-wrap.selected [data-layout-column] > [data-layout-content] > p:only-child:has(.ProseMirror-trailingBreak:only-child)': {
18
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles -- Ignored via go/DSP-18766
19
+ '&::before': {
20
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values
21
+ content: "\"".concat(message, "\""),
22
+ position: 'absolute',
23
+ color: "var(--ds-text-disabled, #A5ADBA)",
24
+ font: "var(--ds-font-body, normal 400 14px/20px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
25
+ marginTop: "var(--ds-space-050, 4px)"
26
+ }
27
+ }
28
+ });
29
+ }
12
30
  return css({
13
31
  // when paragraph is the only child, and it only has a trailingBreak.
14
32
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
@@ -2,6 +2,7 @@ import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/t
2
2
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
3
  import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
4
4
  import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
5
+ import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
5
6
  import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
6
7
  import type { insertLayoutColumnsWithAnalytics } from './pm-plugins/actions';
7
8
  import { pluginKey } from './pm-plugins/plugin-key';
@@ -11,6 +12,7 @@ export type LayoutPlugin = NextEditorPlugin<'layout', {
11
12
  pluginConfiguration: LayoutPluginOptions | undefined;
12
13
  dependencies: [
13
14
  DecorationsPlugin,
15
+ SelectionPlugin,
14
16
  OptionalPlugin<AnalyticsPlugin>,
15
17
  OptionalPlugin<WidthPlugin>,
16
18
  OptionalPlugin<EditorDisabledPlugin>
@@ -20,6 +20,7 @@ type ForwardRef = (ref: HTMLElement | null) => void;
20
20
  export declare class LayoutSectionView extends ReactNodeView<LayoutSectionViewProps> {
21
21
  options: LayoutPluginOptions;
22
22
  layoutDOM?: HTMLElement;
23
+ isEmpty?: boolean;
23
24
  constructor(props: {
24
25
  node: PMNode;
25
26
  view: EditorView;
@@ -2,6 +2,7 @@ import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/t
2
2
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
3
  import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
4
4
  import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
5
+ import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
5
6
  import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
6
7
  import type { insertLayoutColumnsWithAnalytics } from './pm-plugins/actions';
7
8
  import { pluginKey } from './pm-plugins/plugin-key';
@@ -11,6 +12,7 @@ export type LayoutPlugin = NextEditorPlugin<'layout', {
11
12
  pluginConfiguration: LayoutPluginOptions | undefined;
12
13
  dependencies: [
13
14
  DecorationsPlugin,
15
+ SelectionPlugin,
14
16
  OptionalPlugin<AnalyticsPlugin>,
15
17
  OptionalPlugin<WidthPlugin>,
16
18
  OptionalPlugin<EditorDisabledPlugin>
@@ -20,6 +20,7 @@ type ForwardRef = (ref: HTMLElement | null) => void;
20
20
  export declare class LayoutSectionView extends ReactNodeView<LayoutSectionViewProps> {
21
21
  options: LayoutPluginOptions;
22
22
  layoutDOM?: HTMLElement;
23
+ isEmpty?: boolean;
23
24
  constructor(props: {
24
25
  node: PMNode;
25
26
  view: EditorView;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-layout",
3
- "version": "1.12.13",
3
+ "version": "1.12.14",
4
4
  "description": "Layout plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -32,15 +32,16 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@atlaskit/adf-schema": "^46.1.0",
35
- "@atlaskit/editor-common": "^96.1.0",
35
+ "@atlaskit/editor-common": "^96.4.0",
36
36
  "@atlaskit/editor-plugin-analytics": "^1.10.0",
37
37
  "@atlaskit/editor-plugin-decorations": "^1.3.0",
38
38
  "@atlaskit/editor-plugin-editor-disabled": "^1.3.0",
39
+ "@atlaskit/editor-plugin-selection": "^1.6.0",
39
40
  "@atlaskit/editor-plugin-width": "^1.3.0",
40
41
  "@atlaskit/editor-prosemirror": "6.2.1",
41
- "@atlaskit/icon": "^23.0.0",
42
+ "@atlaskit/icon": "^23.1.0",
42
43
  "@atlaskit/platform-feature-flags": "^0.3.0",
43
- "@atlaskit/tmp-editor-statsig": "^2.22.0",
44
+ "@atlaskit/tmp-editor-statsig": "^2.26.0",
44
45
  "@atlaskit/tokens": "^2.4.0",
45
46
  "@babel/runtime": "^7.0.0",
46
47
  "@emotion/react": "^11.7.1"
@@ -99,6 +100,9 @@
99
100
  },
100
101
  "platform-visual-refresh-icons": {
101
102
  "type": "boolean"
103
+ },
104
+ "platform_editor_advanced_layouts_post_fix_patch_1": {
105
+ "type": "boolean"
102
106
  }
103
107
  }
104
108
  }