@atlaskit/editor-plugin-layout 13.4.0 → 13.5.0

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,16 @@
1
1
  # @atlaskit/editor-plugin-layout
2
2
 
3
+ ## 13.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`9425f3fa081e4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9425f3fa081e4) -
8
+ Fix nested content selection inside layouts
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies
13
+
3
14
  ## 13.4.0
4
15
 
5
16
  ### Minor Changes
@@ -8,6 +8,7 @@ var _selection = require("@atlaskit/editor-common/selection");
8
8
  var _state = require("@atlaskit/editor-prosemirror/state");
9
9
  var _utils = require("@atlaskit/editor-prosemirror/utils");
10
10
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
11
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
11
12
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
12
13
  // eslint-disable-next-line @typescript-eslint/consistent-type-imports
13
14
 
@@ -58,6 +59,14 @@ var selectIntoLayout = exports.selectIntoLayout = function selectIntoLayout(view
58
59
  return tr;
59
60
  }
60
61
  };
62
+ /**
63
+ * These node views can fill a layout column while leaving visually blank space that ProseMirror
64
+ * cannot map to a document position. Interactive atomic nodes must receive clicks normally.
65
+ */
66
+ var supportsBlankSpaceGapCursorFallback = function supportsBlankSpaceGapCursorFallback(node) {
67
+ return (node === null || node === void 0 ? void 0 : node.type.name) === 'mediaSingle' || (node === null || node === void 0 ? void 0 : node.type.name) === 'expand';
68
+ };
69
+
61
70
  /**
62
71
  * For a blank-space click inside a layout column — above the first child (middle/bottom-aligned
63
72
  * columns) or below the last child (any alignment) — return the ProseMirror position and side
@@ -152,10 +161,8 @@ var getGapCursorTargetForBlankSpaceClick = exports.getGapCursorTargetForBlankSpa
152
161
  // so the above/below checks never fired.
153
162
  if (columnNode.childCount === 1) {
154
163
  var onlyChild = columnNode.firstChild;
155
- // Exclude `panel`: its wrapper makes `view.nodeDOM` non-null and intercepts clicks, so the
156
- // guard below would wrongly fire for in-panel blank-space clicks (which have their own
157
- // native gap cursor).
158
- if (onlyChild && onlyChild.type.name !== 'paragraph' && onlyChild.type.name !== 'panel') {
164
+ var shouldHandleAtomicChild = (0, _expValEquals.expValEquals)('platform_editor_layout_column_selection_fix', 'isEnabled', true) ? supportsBlankSpaceGapCursorFallback(onlyChild) : (onlyChild === null || onlyChild === void 0 ? void 0 : onlyChild.type.name) !== 'paragraph' && (onlyChild === null || onlyChild === void 0 ? void 0 : onlyChild.type.name) !== 'panel';
165
+ if (onlyChild && shouldHandleAtomicChild) {
159
166
  // Bail when the click is on the child's own content. For media the wrapper is full-width
160
167
  // so test against the <img> rect; resolve it only for a direct mediaSingle child (else
161
168
  // getContentRect could grab an image nested in an expand and break its toggle).
@@ -3,6 +3,7 @@ import { GapCursorSelection } from '@atlaskit/editor-common/selection';
3
3
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
4
4
  import { findParentNodeOfType, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
5
5
  import { fg } from '@atlaskit/platform-feature-flags';
6
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
6
7
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
7
8
  export const getMaybeLayoutSection = state => {
8
9
  const {
@@ -55,6 +56,12 @@ export const selectIntoLayout = (view, posOfLayout, childIndex = 0) => {
55
56
  return tr;
56
57
  }
57
58
  };
59
+ /**
60
+ * These node views can fill a layout column while leaving visually blank space that ProseMirror
61
+ * cannot map to a document position. Interactive atomic nodes must receive clicks normally.
62
+ */
63
+ const supportsBlankSpaceGapCursorFallback = node => (node === null || node === void 0 ? void 0 : node.type.name) === 'mediaSingle' || (node === null || node === void 0 ? void 0 : node.type.name) === 'expand';
64
+
58
65
  /**
59
66
  * For a blank-space click inside a layout column — above the first child (middle/bottom-aligned
60
67
  * columns) or below the last child (any alignment) — return the ProseMirror position and side
@@ -149,10 +156,8 @@ export const getGapCursorTargetForBlankSpaceClick = (view, event) => {
149
156
  // so the above/below checks never fired.
150
157
  if (columnNode.childCount === 1) {
151
158
  const onlyChild = columnNode.firstChild;
152
- // Exclude `panel`: its wrapper makes `view.nodeDOM` non-null and intercepts clicks, so the
153
- // guard below would wrongly fire for in-panel blank-space clicks (which have their own
154
- // native gap cursor).
155
- if (onlyChild && onlyChild.type.name !== 'paragraph' && onlyChild.type.name !== 'panel') {
159
+ const shouldHandleAtomicChild = expValEquals('platform_editor_layout_column_selection_fix', 'isEnabled', true) ? supportsBlankSpaceGapCursorFallback(onlyChild) : (onlyChild === null || onlyChild === void 0 ? void 0 : onlyChild.type.name) !== 'paragraph' && (onlyChild === null || onlyChild === void 0 ? void 0 : onlyChild.type.name) !== 'panel';
160
+ if (onlyChild && shouldHandleAtomicChild) {
156
161
  // Bail when the click is on the child's own content. For media the wrapper is full-width
157
162
  // so test against the <img> rect; resolve it only for a direct mediaSingle child (else
158
163
  // getContentRect could grab an image nested in an expand and break its toggle).
@@ -3,6 +3,7 @@ import { GapCursorSelection } from '@atlaskit/editor-common/selection';
3
3
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
4
4
  import { findParentNodeOfType, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
5
5
  import { fg } from '@atlaskit/platform-feature-flags';
6
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
6
7
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
7
8
  export var getMaybeLayoutSection = function getMaybeLayoutSection(state) {
8
9
  var _state$schema$nodes = state.schema.nodes,
@@ -51,6 +52,14 @@ export var selectIntoLayout = function selectIntoLayout(view, posOfLayout) {
51
52
  return tr;
52
53
  }
53
54
  };
55
+ /**
56
+ * These node views can fill a layout column while leaving visually blank space that ProseMirror
57
+ * cannot map to a document position. Interactive atomic nodes must receive clicks normally.
58
+ */
59
+ var supportsBlankSpaceGapCursorFallback = function supportsBlankSpaceGapCursorFallback(node) {
60
+ return (node === null || node === void 0 ? void 0 : node.type.name) === 'mediaSingle' || (node === null || node === void 0 ? void 0 : node.type.name) === 'expand';
61
+ };
62
+
54
63
  /**
55
64
  * For a blank-space click inside a layout column — above the first child (middle/bottom-aligned
56
65
  * columns) or below the last child (any alignment) — return the ProseMirror position and side
@@ -145,10 +154,8 @@ export var getGapCursorTargetForBlankSpaceClick = function getGapCursorTargetFor
145
154
  // so the above/below checks never fired.
146
155
  if (columnNode.childCount === 1) {
147
156
  var onlyChild = columnNode.firstChild;
148
- // Exclude `panel`: its wrapper makes `view.nodeDOM` non-null and intercepts clicks, so the
149
- // guard below would wrongly fire for in-panel blank-space clicks (which have their own
150
- // native gap cursor).
151
- if (onlyChild && onlyChild.type.name !== 'paragraph' && onlyChild.type.name !== 'panel') {
157
+ var shouldHandleAtomicChild = expValEquals('platform_editor_layout_column_selection_fix', 'isEnabled', true) ? supportsBlankSpaceGapCursorFallback(onlyChild) : (onlyChild === null || onlyChild === void 0 ? void 0 : onlyChild.type.name) !== 'paragraph' && (onlyChild === null || onlyChild === void 0 ? void 0 : onlyChild.type.name) !== 'panel';
158
+ if (onlyChild && shouldHandleAtomicChild) {
152
159
  // Bail when the click is on the child's own content. For media the wrapper is full-width
153
160
  // so test against the <img> rect; resolve it only for a direct mediaSingle child (else
154
161
  // getContentRect could grab an image nested in an expand and break its toggle).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-layout",
3
- "version": "13.4.0",
3
+ "version": "13.5.0",
4
4
  "description": "Layout plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -21,7 +21,7 @@
21
21
  ],
22
22
  "atlaskit:src": "src/index.ts",
23
23
  "dependencies": {
24
- "@atlaskit/adf-schema": "^56.2.0",
24
+ "@atlaskit/adf-schema": "^56.3.0",
25
25
  "@atlaskit/css": "^1.0.0",
26
26
  "@atlaskit/editor-plugin-analytics": "^12.1.0",
27
27
  "@atlaskit/editor-plugin-block-controls": "^13.4.0",
@@ -42,14 +42,14 @@
42
42
  "@atlaskit/icon": "^37.2.0",
43
43
  "@atlaskit/icon-lab": "^7.4.0",
44
44
  "@atlaskit/platform-feature-flags": "^2.1.0",
45
- "@atlaskit/tmp-editor-statsig": "^135.7.0",
45
+ "@atlaskit/tmp-editor-statsig": "^135.8.0",
46
46
  "@atlaskit/tokens": "^16.3.0",
47
47
  "@babel/runtime": "^7.0.0",
48
48
  "@emotion/react": "^11.7.1",
49
49
  "bind-event-listener": "^3.0.0"
50
50
  },
51
51
  "peerDependencies": {
52
- "@atlaskit/editor-common": "^116.45.0",
52
+ "@atlaskit/editor-common": "^116.46.0",
53
53
  "react": "^18.2.0 || ^19.2.0",
54
54
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
55
55
  },