@atlaskit/editor-plugin-block-controls 8.10.2 → 8.11.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,24 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 8.11.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`b5390019c2609`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b5390019c2609) -
8
+ Optimizations for node visibility for remix button checks
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies
13
+
14
+ ## 8.10.3
15
+
16
+ ### Patch Changes
17
+
18
+ - [`5d27d5dc155ff`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5d27d5dc155ff) -
19
+ Editor-5020: Fix the column drop hint not visible inside sync block
20
+ - Updated dependencies
21
+
3
22
  ## 8.10.2
4
23
 
5
24
  ### Patch Changes
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.getActiveDropTargetDecorations = exports.canMoveNodeOrSliceToPos = void 0;
7
7
  var _selection = require("@atlaskit/editor-common/selection");
8
8
  var _utils = require("@atlaskit/editor-common/utils");
9
+ var _utils2 = require("@atlaskit/editor-prosemirror/utils");
9
10
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
10
11
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
11
12
  var _decorationsCommon = require("./decorations-common");
@@ -211,23 +212,45 @@ var getActiveDropTargetDecorations = exports.getActiveDropTargetDecorations = fu
211
212
  pos: root.pos
212
213
  };
213
214
  }
215
+ var anchorEmitNodeWithPos = rootNodeWithPos;
214
216
  if ((0, _experiments.editorExperiment)('advanced_layouts', true)) {
215
- var _isSameLayout = $activeNodePos && (0, _validation.isInSameLayout)($activeNodePos, state.doc.resolve(rootNodeWithPos.pos));
217
+ if ((0, _expValEquals.expValEquals)('platform_synced_block', 'isEnabled', true) && (0, _expValEquals.expValEquals)('platform_synced_block_patch_6', 'isEnabled', true)) {
218
+ var schema = rootNodeWithPos.node.type.schema;
219
+ var layoutSection = schema.nodes.layoutSection;
220
+ var isLayoutSectionChildOfRoot = (0, _utils2.findChildrenByType)(rootNodeWithPos.node, layoutSection, false).length > 0;
221
+ if (isLayoutSectionChildOfRoot) {
222
+ // if node has layoutSection as a child, get the layoutSection node and pos
223
+ for (var ancestorDepth = $toPos.depth; ancestorDepth >= 1; ancestorDepth--) {
224
+ if ($toPos.node(ancestorDepth).type.name === 'layoutSection') {
225
+ anchorEmitNodeWithPos = {
226
+ node: $toPos.node(ancestorDepth),
227
+ pos: $toPos.before(ancestorDepth)
228
+ };
229
+ break;
230
+ }
231
+ }
232
+ } else {
233
+ anchorEmitNodeWithPos = rootNodeWithPos;
234
+ }
235
+ } else {
236
+ anchorEmitNodeWithPos = rootNodeWithPos;
237
+ }
238
+ var _isSameLayout = $activeNodePos && (0, _validation.isInSameLayout)($activeNodePos, state.doc.resolve(anchorEmitNodeWithPos.pos));
216
239
  var hasUnsupportedContent = UNSUPPORTED_LAYOUT_CONTENT.includes((activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) || '') && (0, _experiments.editorExperiment)('platform_synced_block', true);
217
- if (rootNodeWithPos.node.type.name === 'layoutSection' && !hasUnsupportedContent) {
218
- var layoutSectionNode = rootNodeWithPos.node;
240
+ if (anchorEmitNodeWithPos.node.type.name === 'layoutSection' && !hasUnsupportedContent) {
241
+ var layoutSectionNode = anchorEmitNodeWithPos.node;
219
242
  if (layoutSectionNode.childCount < (0, _consts.maxLayoutColumnSupported)() || _isSameLayout) {
220
243
  layoutSectionNode.descendants(function (childNode, childPos, parent, index) {
221
244
  if (childNode.type.name === 'layoutColumn' && (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'layoutSection' && index !== 0 // Not the first node
222
245
  ) {
223
- var currentPos = rootNodeWithPos.pos + childPos + 1;
246
+ var currentPos = anchorEmitNodeWithPos.pos + childPos + 1;
224
247
  if (existingDecsPos.includes(currentPos)) {
225
248
  // if the decoration already exists, we don't add it again.
226
249
  decsToRemove = decsToRemove.filter(function (dec) {
227
250
  return dec.from !== currentPos;
228
251
  });
229
252
  } else {
230
- decsToAdd.push((0, _decorationsDropTarget.createLayoutDropTargetDecoration)(rootNodeWithPos.pos + childPos + 1, {
253
+ decsToAdd.push((0, _decorationsDropTarget.createLayoutDropTargetDecoration)(anchorEmitNodeWithPos.pos + childPos + 1, {
231
254
  api: api,
232
255
  parent: parent,
233
256
  formatMessage: formatMessage
@@ -239,7 +262,7 @@ var getActiveDropTargetDecorations = exports.getActiveDropTargetDecorations = fu
239
262
  }
240
263
  }
241
264
  }
242
- _activeAnchorTracker.defaultActiveAnchorTracker.emit((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? api.core.actions.getAnchorIdForNode(rootNodeWithPos.node, rootNodeWithPos.pos) || '' : (0, _decorationsCommon.getNodeAnchor)(rootNodeWithPos.node));
265
+ _activeAnchorTracker.defaultActiveAnchorTracker.emit((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? api.core.actions.getAnchorIdForNode(anchorEmitNodeWithPos.node, anchorEmitNodeWithPos.pos) || '' : (0, _decorationsCommon.getNodeAnchor)(anchorEmitNodeWithPos.node));
243
266
  return {
244
267
  decsToAdd: decsToAdd,
245
268
  decsToRemove: decsToRemove
@@ -1,5 +1,6 @@
1
1
  import { expandSelectionBounds } from '@atlaskit/editor-common/selection';
2
2
  import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
3
+ import { findChildrenByType } from '@atlaskit/editor-prosemirror/utils';
3
4
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
4
5
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
5
6
  import { getNodeAnchor } from './decorations-common';
@@ -194,21 +195,45 @@ export const getActiveDropTargetDecorations = (activeDropTargetNode, state, api,
194
195
  pos: root.pos
195
196
  };
196
197
  }
198
+ let anchorEmitNodeWithPos = rootNodeWithPos;
197
199
  if (editorExperiment('advanced_layouts', true)) {
198
- const isSameLayout = $activeNodePos && isInSameLayout($activeNodePos, state.doc.resolve(rootNodeWithPos.pos));
200
+ if (expValEquals('platform_synced_block', 'isEnabled', true) && expValEquals('platform_synced_block_patch_6', 'isEnabled', true)) {
201
+ const schema = rootNodeWithPos.node.type.schema;
202
+ const {
203
+ layoutSection
204
+ } = schema.nodes;
205
+ const isLayoutSectionChildOfRoot = findChildrenByType(rootNodeWithPos.node, layoutSection, false).length > 0;
206
+ if (isLayoutSectionChildOfRoot) {
207
+ // if node has layoutSection as a child, get the layoutSection node and pos
208
+ for (let ancestorDepth = $toPos.depth; ancestorDepth >= 1; ancestorDepth--) {
209
+ if ($toPos.node(ancestorDepth).type.name === 'layoutSection') {
210
+ anchorEmitNodeWithPos = {
211
+ node: $toPos.node(ancestorDepth),
212
+ pos: $toPos.before(ancestorDepth)
213
+ };
214
+ break;
215
+ }
216
+ }
217
+ } else {
218
+ anchorEmitNodeWithPos = rootNodeWithPos;
219
+ }
220
+ } else {
221
+ anchorEmitNodeWithPos = rootNodeWithPos;
222
+ }
223
+ const isSameLayout = $activeNodePos && isInSameLayout($activeNodePos, state.doc.resolve(anchorEmitNodeWithPos.pos));
199
224
  const hasUnsupportedContent = UNSUPPORTED_LAYOUT_CONTENT.includes((activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) || '') && editorExperiment('platform_synced_block', true);
200
- if (rootNodeWithPos.node.type.name === 'layoutSection' && !hasUnsupportedContent) {
201
- const layoutSectionNode = rootNodeWithPos.node;
225
+ if (anchorEmitNodeWithPos.node.type.name === 'layoutSection' && !hasUnsupportedContent) {
226
+ const layoutSectionNode = anchorEmitNodeWithPos.node;
202
227
  if (layoutSectionNode.childCount < maxLayoutColumnSupported() || isSameLayout) {
203
228
  layoutSectionNode.descendants((childNode, childPos, parent, index) => {
204
229
  if (childNode.type.name === 'layoutColumn' && (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'layoutSection' && index !== 0 // Not the first node
205
230
  ) {
206
- const currentPos = rootNodeWithPos.pos + childPos + 1;
231
+ const currentPos = anchorEmitNodeWithPos.pos + childPos + 1;
207
232
  if (existingDecsPos.includes(currentPos)) {
208
233
  // if the decoration already exists, we don't add it again.
209
234
  decsToRemove = decsToRemove.filter(dec => dec.from !== currentPos);
210
235
  } else {
211
- decsToAdd.push(createLayoutDropTargetDecoration(rootNodeWithPos.pos + childPos + 1, {
236
+ decsToAdd.push(createLayoutDropTargetDecoration(anchorEmitNodeWithPos.pos + childPos + 1, {
212
237
  api,
213
238
  parent,
214
239
  formatMessage
@@ -220,7 +245,7 @@ export const getActiveDropTargetDecorations = (activeDropTargetNode, state, api,
220
245
  }
221
246
  }
222
247
  }
223
- defaultActiveAnchorTracker.emit(expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? api.core.actions.getAnchorIdForNode(rootNodeWithPos.node, rootNodeWithPos.pos) || '' : getNodeAnchor(rootNodeWithPos.node));
248
+ defaultActiveAnchorTracker.emit(expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? api.core.actions.getAnchorIdForNode(anchorEmitNodeWithPos.node, anchorEmitNodeWithPos.pos) || '' : getNodeAnchor(anchorEmitNodeWithPos.node));
224
249
  return {
225
250
  decsToAdd,
226
251
  decsToRemove
@@ -1,5 +1,6 @@
1
1
  import { expandSelectionBounds } from '@atlaskit/editor-common/selection';
2
2
  import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
3
+ import { findChildrenByType } from '@atlaskit/editor-prosemirror/utils';
3
4
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
4
5
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
5
6
  import { getNodeAnchor } from './decorations-common';
@@ -206,23 +207,45 @@ export var getActiveDropTargetDecorations = function getActiveDropTargetDecorati
206
207
  pos: root.pos
207
208
  };
208
209
  }
210
+ var anchorEmitNodeWithPos = rootNodeWithPos;
209
211
  if (editorExperiment('advanced_layouts', true)) {
210
- var _isSameLayout = $activeNodePos && isInSameLayout($activeNodePos, state.doc.resolve(rootNodeWithPos.pos));
212
+ if (expValEquals('platform_synced_block', 'isEnabled', true) && expValEquals('platform_synced_block_patch_6', 'isEnabled', true)) {
213
+ var schema = rootNodeWithPos.node.type.schema;
214
+ var layoutSection = schema.nodes.layoutSection;
215
+ var isLayoutSectionChildOfRoot = findChildrenByType(rootNodeWithPos.node, layoutSection, false).length > 0;
216
+ if (isLayoutSectionChildOfRoot) {
217
+ // if node has layoutSection as a child, get the layoutSection node and pos
218
+ for (var ancestorDepth = $toPos.depth; ancestorDepth >= 1; ancestorDepth--) {
219
+ if ($toPos.node(ancestorDepth).type.name === 'layoutSection') {
220
+ anchorEmitNodeWithPos = {
221
+ node: $toPos.node(ancestorDepth),
222
+ pos: $toPos.before(ancestorDepth)
223
+ };
224
+ break;
225
+ }
226
+ }
227
+ } else {
228
+ anchorEmitNodeWithPos = rootNodeWithPos;
229
+ }
230
+ } else {
231
+ anchorEmitNodeWithPos = rootNodeWithPos;
232
+ }
233
+ var _isSameLayout = $activeNodePos && isInSameLayout($activeNodePos, state.doc.resolve(anchorEmitNodeWithPos.pos));
211
234
  var hasUnsupportedContent = UNSUPPORTED_LAYOUT_CONTENT.includes((activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) || '') && editorExperiment('platform_synced_block', true);
212
- if (rootNodeWithPos.node.type.name === 'layoutSection' && !hasUnsupportedContent) {
213
- var layoutSectionNode = rootNodeWithPos.node;
235
+ if (anchorEmitNodeWithPos.node.type.name === 'layoutSection' && !hasUnsupportedContent) {
236
+ var layoutSectionNode = anchorEmitNodeWithPos.node;
214
237
  if (layoutSectionNode.childCount < maxLayoutColumnSupported() || _isSameLayout) {
215
238
  layoutSectionNode.descendants(function (childNode, childPos, parent, index) {
216
239
  if (childNode.type.name === 'layoutColumn' && (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'layoutSection' && index !== 0 // Not the first node
217
240
  ) {
218
- var currentPos = rootNodeWithPos.pos + childPos + 1;
241
+ var currentPos = anchorEmitNodeWithPos.pos + childPos + 1;
219
242
  if (existingDecsPos.includes(currentPos)) {
220
243
  // if the decoration already exists, we don't add it again.
221
244
  decsToRemove = decsToRemove.filter(function (dec) {
222
245
  return dec.from !== currentPos;
223
246
  });
224
247
  } else {
225
- decsToAdd.push(createLayoutDropTargetDecoration(rootNodeWithPos.pos + childPos + 1, {
248
+ decsToAdd.push(createLayoutDropTargetDecoration(anchorEmitNodeWithPos.pos + childPos + 1, {
226
249
  api: api,
227
250
  parent: parent,
228
251
  formatMessage: formatMessage
@@ -234,7 +257,7 @@ export var getActiveDropTargetDecorations = function getActiveDropTargetDecorati
234
257
  }
235
258
  }
236
259
  }
237
- defaultActiveAnchorTracker.emit(expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? api.core.actions.getAnchorIdForNode(rootNodeWithPos.node, rootNodeWithPos.pos) || '' : getNodeAnchor(rootNodeWithPos.node));
260
+ defaultActiveAnchorTracker.emit(expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? api.core.actions.getAnchorIdForNode(anchorEmitNodeWithPos.node, anchorEmitNodeWithPos.pos) || '' : getNodeAnchor(anchorEmitNodeWithPos.node));
238
261
  return {
239
262
  decsToAdd: decsToAdd,
240
263
  decsToRemove: decsToRemove
@@ -111,7 +111,6 @@ export type HandleOptions = {
111
111
  } | undefined;
112
112
  /**
113
113
  * Props passed to custom right-edge button components (e.g. config.rightEdgeButton).
114
- * Used by malleable-ui for BlockRemixButton when rendered via node decoration.
115
114
  */
116
115
  export type RightEdgeButtonProps = {
117
116
  api: PublicPluginAPI<[BlockControlsPlugin]>;
@@ -132,13 +131,13 @@ export type NodeDecorationFactoryParams = {
132
131
  */
133
132
  export type NodeDecorationFactory = {
134
133
  create: (params: NodeDecorationFactoryParams) => Decoration;
135
- /** Show this decoration in view mode when hovering over a block */
136
- showInViewMode?: boolean;
137
134
  /**
138
135
  * Optional filter: when false, the decoration is not created.
139
136
  * Use for node-type-specific visibility (e.g. Remix button only on remixable blocks).
140
137
  */
141
138
  shouldCreate?: (params: NodeDecorationFactoryParams) => boolean;
139
+ /** Show this decoration in view mode when hovering over a block */
140
+ showInViewMode?: boolean;
142
141
  type: string;
143
142
  };
144
143
  export type MoveNode = (start: number, to: number, inputMethod?: MoveNodeMethod, formatMessage?: IntlShape['formatMessage']) => EditorCommand;
@@ -111,7 +111,6 @@ export type HandleOptions = {
111
111
  } | undefined;
112
112
  /**
113
113
  * Props passed to custom right-edge button components (e.g. config.rightEdgeButton).
114
- * Used by malleable-ui for BlockRemixButton when rendered via node decoration.
115
114
  */
116
115
  export type RightEdgeButtonProps = {
117
116
  api: PublicPluginAPI<[
@@ -134,13 +133,13 @@ export type NodeDecorationFactoryParams = {
134
133
  */
135
134
  export type NodeDecorationFactory = {
136
135
  create: (params: NodeDecorationFactoryParams) => Decoration;
137
- /** Show this decoration in view mode when hovering over a block */
138
- showInViewMode?: boolean;
139
136
  /**
140
137
  * Optional filter: when false, the decoration is not created.
141
138
  * Use for node-type-specific visibility (e.g. Remix button only on remixable blocks).
142
139
  */
143
140
  shouldCreate?: (params: NodeDecorationFactoryParams) => boolean;
141
+ /** Show this decoration in view mode when hovering over a block */
142
+ showInViewMode?: boolean;
144
143
  type: string;
145
144
  };
146
145
  export type MoveNode = (start: number, to: number, inputMethod?: MoveNodeMethod, formatMessage?: IntlShape['formatMessage']) => EditorCommand;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "8.10.2",
3
+ "version": "8.11.0",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -56,7 +56,7 @@
56
56
  "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^3.2.0",
57
57
  "@atlaskit/primitives": "^18.0.0",
58
58
  "@atlaskit/theme": "^22.0.0",
59
- "@atlaskit/tmp-editor-statsig": "^35.0.0",
59
+ "@atlaskit/tmp-editor-statsig": "^35.4.0",
60
60
  "@atlaskit/tokens": "^11.0.0",
61
61
  "@atlaskit/tooltip": "^20.14.0",
62
62
  "@babel/runtime": "^7.0.0",
@@ -67,7 +67,7 @@
67
67
  "uuid": "^3.1.0"
68
68
  },
69
69
  "peerDependencies": {
70
- "@atlaskit/editor-common": "^111.30.0",
70
+ "@atlaskit/editor-common": "^111.31.0",
71
71
  "react": "^18.2.0",
72
72
  "react-dom": "^18.2.0",
73
73
  "react-intl-next": "npm:react-intl@^5.18.1"