@atlaskit/editor-plugin-block-controls 7.18.3 → 7.19.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,12 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 7.19.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`cae218eb0956b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/cae218eb0956b) -
8
+ ED-29725 fix table controls when native anchor enabled
9
+
3
10
  ## 7.18.3
4
11
 
5
12
  ### Patch Changes
@@ -33,50 +33,6 @@ var findHandleDec = exports.findHandleDec = function findHandleDec(decorations,
33
33
  return spec.type === _decorationsCommon.TYPE_HANDLE_DEC;
34
34
  });
35
35
  };
36
- /**
37
- * Fix for widget positioning to ensure it is not placed into a previous mark's DOM structure.
38
- * A ProseMirror widget can appear in the wrong DOM position, specifically being added
39
- * to a previous mark instead of its intended location, which leads to various rendering issues.
40
- * For example, when nodeBefore has an alignment mark but the current node doesn't, ProseMirror may
41
- * incorrectly render the widget inside the previous node's alignment mark wrapper instead.
42
- */
43
- var fixWidgetSide = function fixWidgetSide($pos) {
44
- var defaultSide = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1;
45
- var alignmentMark = $pos.doc.type.schema.marks.alignment;
46
- var indentationMark = $pos.doc.type.schema.marks.indentation;
47
-
48
- // Only apply fix for alignment and indent marks
49
- if (!alignmentMark && !indentationMark) {
50
- return defaultSide;
51
- }
52
- if ($pos.nodeBefore && $pos.nodeAfter) {
53
- var _$pos$nodeBefore, _$pos$nodeAfter;
54
- var beforeMarks = ((_$pos$nodeBefore = $pos.nodeBefore) === null || _$pos$nodeBefore === void 0 ? void 0 : _$pos$nodeBefore.marks.filter(function (mark) {
55
- return mark.type === alignmentMark || mark.type === indentationMark;
56
- })) || [];
57
- var afterMarks = ((_$pos$nodeAfter = $pos.nodeAfter) === null || _$pos$nodeAfter === void 0 ? void 0 : _$pos$nodeAfter.marks.filter(function (mark) {
58
- return mark.type === alignmentMark || mark.type === indentationMark;
59
- })) || [];
60
- if (beforeMarks.length === 0) {
61
- return defaultSide;
62
- } else if (afterMarks.length === 0) {
63
- return 0;
64
- }
65
-
66
- // Check if previous node has marks that current node doesn't have
67
- var hasMissingMark = beforeMarks.some(function (mark) {
68
- return !afterMarks.some(function (nextMark) {
69
- return nextMark.eq(mark);
70
- });
71
- });
72
-
73
- // if we have missing mark, we set side to 0 to render widget outside previous mark DOM
74
- if (hasMissingMark) {
75
- return 0;
76
- }
77
- }
78
- return defaultSide;
79
- };
80
36
  var dragHandleDecoration = exports.dragHandleDecoration = function dragHandleDecoration(_ref) {
81
37
  var api = _ref.api,
82
38
  formatMessage = _ref.formatMessage,
@@ -95,10 +51,8 @@ var dragHandleDecoration = exports.dragHandleDecoration = function dragHandleDec
95
51
  var unbind;
96
52
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
97
53
  var key = (0, _uuid.default)();
98
- var $pos = editorState.doc.resolve(pos);
99
- var side = (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) && (0, _platformFeatureFlags.fg)('platform_editor_native_anchor_patch_1') ? fixWidgetSide($pos) : -1;
100
54
  var widgetSpec = (0, _experiments.editorExperiment)('platform_editor_breakout_resizing', true) ? {
101
- side: side,
55
+ side: -1,
102
56
  type: _decorationsCommon.TYPE_HANDLE_DEC,
103
57
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
104
58
  testid: "".concat(_decorationsCommon.TYPE_HANDLE_DEC, "-").concat((0, _uuid.default)()),
@@ -115,10 +69,11 @@ var dragHandleDecoration = exports.dragHandleDecoration = function dragHandleDec
115
69
  }
116
70
  }
117
71
  } : {
118
- side: side,
72
+ side: -1,
119
73
  type: _decorationsCommon.TYPE_HANDLE_DEC,
120
74
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
121
75
  testid: "".concat(_decorationsCommon.TYPE_HANDLE_DEC, "-").concat((0, _uuid.default)()),
76
+ marks: (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) && (0, _platformFeatureFlags.fg)('platform_editor_native_anchor_patch_1') ? (0, _marks.getActiveBlockMarks)(editorState, pos) : undefined,
122
77
  destroy: function destroy(node) {
123
78
  unbind && unbind();
124
79
  if ((0, _experiments.editorExperiment)('platform_editor_block_control_optimise_render', true) && node instanceof HTMLElement) {
@@ -144,8 +99,8 @@ var dragHandleDecoration = exports.dragHandleDecoration = function dragHandleDec
144
99
  };
145
100
  var newPos = getPos();
146
101
  if (typeof newPos === 'number') {
147
- var _$pos = view.state.doc.resolve(newPos);
148
- isTopLevelNode = (_$pos === null || _$pos === void 0 ? void 0 : _$pos.parent.type.name) === 'doc';
102
+ var $pos = view.state.doc.resolve(newPos);
103
+ isTopLevelNode = ($pos === null || $pos === void 0 ? void 0 : $pos.parent.type.name) === 'doc';
149
104
  }
150
105
  /*
151
106
  * We disable mouseover event to fix flickering issue on hover
@@ -23,43 +23,6 @@ export const emptyParagraphNodeDecorations = () => {
23
23
  export const findHandleDec = (decorations, from, to) => {
24
24
  return decorations.find(from, to, spec => spec.type === TYPE_HANDLE_DEC);
25
25
  };
26
- /**
27
- * Fix for widget positioning to ensure it is not placed into a previous mark's DOM structure.
28
- * A ProseMirror widget can appear in the wrong DOM position, specifically being added
29
- * to a previous mark instead of its intended location, which leads to various rendering issues.
30
- * For example, when nodeBefore has an alignment mark but the current node doesn't, ProseMirror may
31
- * incorrectly render the widget inside the previous node's alignment mark wrapper instead.
32
- */
33
- const fixWidgetSide = ($pos, defaultSide = -1) => {
34
- const alignmentMark = $pos.doc.type.schema.marks.alignment;
35
- const indentationMark = $pos.doc.type.schema.marks.indentation;
36
-
37
- // Only apply fix for alignment and indent marks
38
- if (!alignmentMark && !indentationMark) {
39
- return defaultSide;
40
- }
41
- if ($pos.nodeBefore && $pos.nodeAfter) {
42
- var _$pos$nodeBefore, _$pos$nodeAfter;
43
- const beforeMarks = ((_$pos$nodeBefore = $pos.nodeBefore) === null || _$pos$nodeBefore === void 0 ? void 0 : _$pos$nodeBefore.marks.filter(mark => mark.type === alignmentMark || mark.type === indentationMark)) || [];
44
- const afterMarks = ((_$pos$nodeAfter = $pos.nodeAfter) === null || _$pos$nodeAfter === void 0 ? void 0 : _$pos$nodeAfter.marks.filter(mark => mark.type === alignmentMark || mark.type === indentationMark)) || [];
45
- if (beforeMarks.length === 0) {
46
- return defaultSide;
47
- } else if (afterMarks.length === 0) {
48
- return 0;
49
- }
50
-
51
- // Check if previous node has marks that current node doesn't have
52
- const hasMissingMark = beforeMarks.some(mark => {
53
- return !afterMarks.some(nextMark => nextMark.eq(mark));
54
- });
55
-
56
- // if we have missing mark, we set side to 0 to render widget outside previous mark DOM
57
- if (hasMissingMark) {
58
- return 0;
59
- }
60
- }
61
- return defaultSide;
62
- };
63
26
  export const dragHandleDecoration = ({
64
27
  api,
65
28
  formatMessage,
@@ -79,10 +42,8 @@ export const dragHandleDecoration = ({
79
42
  let unbind;
80
43
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
81
44
  const key = uuid();
82
- const $pos = editorState.doc.resolve(pos);
83
- const side = expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) && fg('platform_editor_native_anchor_patch_1') ? fixWidgetSide($pos) : -1;
84
45
  const widgetSpec = editorExperiment('platform_editor_breakout_resizing', true) ? {
85
- side,
46
+ side: -1,
86
47
  type: TYPE_HANDLE_DEC,
87
48
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
88
49
  testid: `${TYPE_HANDLE_DEC}-${uuid()}`,
@@ -99,10 +60,11 @@ export const dragHandleDecoration = ({
99
60
  }
100
61
  }
101
62
  } : {
102
- side,
63
+ side: -1,
103
64
  type: TYPE_HANDLE_DEC,
104
65
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
105
66
  testid: `${TYPE_HANDLE_DEC}-${uuid()}`,
67
+ marks: expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) && fg('platform_editor_native_anchor_patch_1') ? getActiveBlockMarks(editorState, pos) : undefined,
106
68
  destroy: node => {
107
69
  unbind && unbind();
108
70
  if (editorExperiment('platform_editor_block_control_optimise_render', true) && node instanceof HTMLElement) {
@@ -25,50 +25,6 @@ export var findHandleDec = function findHandleDec(decorations, from, to) {
25
25
  return spec.type === TYPE_HANDLE_DEC;
26
26
  });
27
27
  };
28
- /**
29
- * Fix for widget positioning to ensure it is not placed into a previous mark's DOM structure.
30
- * A ProseMirror widget can appear in the wrong DOM position, specifically being added
31
- * to a previous mark instead of its intended location, which leads to various rendering issues.
32
- * For example, when nodeBefore has an alignment mark but the current node doesn't, ProseMirror may
33
- * incorrectly render the widget inside the previous node's alignment mark wrapper instead.
34
- */
35
- var fixWidgetSide = function fixWidgetSide($pos) {
36
- var defaultSide = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1;
37
- var alignmentMark = $pos.doc.type.schema.marks.alignment;
38
- var indentationMark = $pos.doc.type.schema.marks.indentation;
39
-
40
- // Only apply fix for alignment and indent marks
41
- if (!alignmentMark && !indentationMark) {
42
- return defaultSide;
43
- }
44
- if ($pos.nodeBefore && $pos.nodeAfter) {
45
- var _$pos$nodeBefore, _$pos$nodeAfter;
46
- var beforeMarks = ((_$pos$nodeBefore = $pos.nodeBefore) === null || _$pos$nodeBefore === void 0 ? void 0 : _$pos$nodeBefore.marks.filter(function (mark) {
47
- return mark.type === alignmentMark || mark.type === indentationMark;
48
- })) || [];
49
- var afterMarks = ((_$pos$nodeAfter = $pos.nodeAfter) === null || _$pos$nodeAfter === void 0 ? void 0 : _$pos$nodeAfter.marks.filter(function (mark) {
50
- return mark.type === alignmentMark || mark.type === indentationMark;
51
- })) || [];
52
- if (beforeMarks.length === 0) {
53
- return defaultSide;
54
- } else if (afterMarks.length === 0) {
55
- return 0;
56
- }
57
-
58
- // Check if previous node has marks that current node doesn't have
59
- var hasMissingMark = beforeMarks.some(function (mark) {
60
- return !afterMarks.some(function (nextMark) {
61
- return nextMark.eq(mark);
62
- });
63
- });
64
-
65
- // if we have missing mark, we set side to 0 to render widget outside previous mark DOM
66
- if (hasMissingMark) {
67
- return 0;
68
- }
69
- }
70
- return defaultSide;
71
- };
72
28
  export var dragHandleDecoration = function dragHandleDecoration(_ref) {
73
29
  var api = _ref.api,
74
30
  formatMessage = _ref.formatMessage,
@@ -87,10 +43,8 @@ export var dragHandleDecoration = function dragHandleDecoration(_ref) {
87
43
  var unbind;
88
44
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
89
45
  var key = uuid();
90
- var $pos = editorState.doc.resolve(pos);
91
- var side = expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) && fg('platform_editor_native_anchor_patch_1') ? fixWidgetSide($pos) : -1;
92
46
  var widgetSpec = editorExperiment('platform_editor_breakout_resizing', true) ? {
93
- side: side,
47
+ side: -1,
94
48
  type: TYPE_HANDLE_DEC,
95
49
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
96
50
  testid: "".concat(TYPE_HANDLE_DEC, "-").concat(uuid()),
@@ -107,10 +61,11 @@ export var dragHandleDecoration = function dragHandleDecoration(_ref) {
107
61
  }
108
62
  }
109
63
  } : {
110
- side: side,
64
+ side: -1,
111
65
  type: TYPE_HANDLE_DEC,
112
66
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
113
67
  testid: "".concat(TYPE_HANDLE_DEC, "-").concat(uuid()),
68
+ marks: expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) && fg('platform_editor_native_anchor_patch_1') ? getActiveBlockMarks(editorState, pos) : undefined,
114
69
  destroy: function destroy(node) {
115
70
  unbind && unbind();
116
71
  if (editorExperiment('platform_editor_block_control_optimise_render', true) && node instanceof HTMLElement) {
@@ -136,8 +91,8 @@ export var dragHandleDecoration = function dragHandleDecoration(_ref) {
136
91
  };
137
92
  var newPos = getPos();
138
93
  if (typeof newPos === 'number') {
139
- var _$pos = view.state.doc.resolve(newPos);
140
- isTopLevelNode = (_$pos === null || _$pos === void 0 ? void 0 : _$pos.parent.type.name) === 'doc';
94
+ var $pos = view.state.doc.resolve(newPos);
95
+ isTopLevelNode = ($pos === null || $pos === void 0 ? void 0 : $pos.parent.type.name) === 'doc';
141
96
  }
142
97
  /*
143
98
  * We disable mouseover event to fix flickering issue on hover
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "7.18.3",
3
+ "version": "7.19.0",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -66,7 +66,7 @@
66
66
  "uuid": "^3.1.0"
67
67
  },
68
68
  "peerDependencies": {
69
- "@atlaskit/editor-common": "^110.49.0",
69
+ "@atlaskit/editor-common": "^110.50.0",
70
70
  "react": "^18.2.0",
71
71
  "react-dom": "^18.2.0",
72
72
  "react-intl-next": "npm:react-intl@^5.18.1"