@atlaskit/editor-plugin-block-controls 7.2.11 → 7.3.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.
@@ -24,7 +24,7 @@ const getNodeSelector = (ignoreNodes, ignoreNodeDescendants) => {
24
24
  };
25
25
  const getDefaultNodeSelector = memoizeOne(() => {
26
26
  // we don't show handler for node nested in table
27
- return getNodeSelector([...IGNORE_NODES_NEXT], [...IGNORE_NODE_DESCENDANTS_ADVANCED_LAYOUT, 'table']);
27
+ return getNodeSelector([...IGNORE_NODES_NEXT, 'media'], [...IGNORE_NODE_DESCENDANTS_ADVANCED_LAYOUT, 'table']);
28
28
  });
29
29
  export const handleMouseOver = (view, event, api) => {
30
30
  var _api$blockControls, _api$editorDisabled, _target$classList;
@@ -41,7 +41,7 @@ export const handleMouseOver = (view, event, api) => {
41
41
  };
42
42
 
43
43
  // We shouldn't be firing mouse over transactions when the editor is disabled
44
- if (editorDisabled && fg('platform_editor_ai_rovo_free_gen')) {
44
+ if (editorDisabled && fg('aifc_create_enabled')) {
45
45
  return false;
46
46
  }
47
47
 
@@ -54,24 +54,25 @@ export const handleMouseOver = (view, event, api) => {
54
54
  // Ignored via go/ees005
55
55
  // eslint-disable-next-line @atlaskit/editor/no-as-casting
56
56
  const target = event.target;
57
+ const isNativeAnchorSupported = expValEquals('platform_editor_native_anchor_support', 'isEnabled', true);
57
58
  if (target !== null && target !== void 0 && (_target$classList = target.classList) !== null && _target$classList !== void 0 && _target$classList.contains('ProseMirror')) {
58
59
  return false;
59
60
  }
60
- let rootElement = target === null || target === void 0 ? void 0 : target.closest(expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) ? getDefaultNodeSelector() : `[data-drag-handler-anchor-name]`);
61
+ let rootElement = target === null || target === void 0 ? void 0 : target.closest(isNativeAnchorSupported ? getDefaultNodeSelector() : `[data-drag-handler-anchor-name]`);
61
62
  if (rootElement) {
62
63
  var _rootElement$parentEl;
63
64
  // We want to exlude handles from showing for empty paragraph and heading nodes
64
65
  if (isEmptyNestedParagraphOrHeading(rootElement)) {
65
66
  return false;
66
67
  }
67
- if (rootElement.getAttribute(getTypeNameAttrName()) === 'media' && editorExperiment('advanced_layouts', true)) {
68
+ if (rootElement.getAttribute(getTypeNameAttrName()) === 'media' && editorExperiment('advanced_layouts', true) && !isNativeAnchorSupported) {
68
69
  rootElement = rootElement.closest(`[${getAnchorAttrName()}][${getTypeNameAttrName()}="mediaSingle"]`);
69
70
  if (!rootElement) {
70
71
  return false;
71
72
  }
72
73
  }
73
74
  const parentElement = (_rootElement$parentEl = rootElement.parentElement) === null || _rootElement$parentEl === void 0 ? void 0 : _rootElement$parentEl.closest(`[${getAnchorAttrName()}]`);
74
- const parentElementType = expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) ? getTypeNameFromDom(parentElement) : parentElement === null || parentElement === void 0 ? void 0 : parentElement.getAttribute('data-drag-handler-node-type');
75
+ const parentElementType = isNativeAnchorSupported ? getTypeNameFromDom(parentElement) : parentElement === null || parentElement === void 0 ? void 0 : parentElement.getAttribute('data-drag-handler-node-type');
75
76
  if (editorExperiment('advanced_layouts', true)) {
76
77
  // We want to exclude handles from showing for direct descendant of table nodes (i.e. nodes in cells)
77
78
  if (parentElement && parentElementType === 'table') {
@@ -79,7 +80,7 @@ export const handleMouseOver = (view, event, api) => {
79
80
  } else if (parentElement && parentElementType === 'tableRow') {
80
81
  var _parentElement$parent;
81
82
  const grandparentElement = parentElement === null || parentElement === void 0 ? void 0 : (_parentElement$parent = parentElement.parentElement) === null || _parentElement$parent === void 0 ? void 0 : _parentElement$parent.closest(`[${getAnchorAttrName()}]`);
82
- const grandparentElementType = expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) ? getTypeNameFromDom(grandparentElement) : grandparentElement === null || grandparentElement === void 0 ? void 0 : grandparentElement.getAttribute('data-drag-handler-node-type');
83
+ const grandparentElementType = isNativeAnchorSupported ? getTypeNameFromDom(grandparentElement) : grandparentElement === null || grandparentElement === void 0 ? void 0 : grandparentElement.getAttribute('data-drag-handler-node-type');
83
84
  if (grandparentElement && grandparentElementType === 'table') {
84
85
  rootElement = grandparentElement;
85
86
  }
@@ -146,11 +147,11 @@ export const handleMouseOver = (view, event, api) => {
146
147
  if (rootDOM instanceof HTMLElement) {
147
148
  var _rootDOM$getAttribute;
148
149
  rootAnchorName = (_rootDOM$getAttribute = rootDOM.getAttribute(getAnchorAttrName())) !== null && _rootDOM$getAttribute !== void 0 ? _rootDOM$getAttribute : undefined;
149
- rootNodeType = expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) ? getTypeNameFromDom(rootDOM) : rootDOM.getAttribute('data-drag-handler-node-type');
150
+ rootNodeType = isNativeAnchorSupported ? getTypeNameFromDom(rootDOM) : rootDOM.getAttribute('data-drag-handler-node-type');
150
151
  }
151
152
  }
152
153
  }
153
- const nodeType = expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) ? getTypeNameFromDom(rootElement) : rootElement.getAttribute('data-drag-handler-node-type');
154
+ const nodeType = isNativeAnchorSupported ? getTypeNameFromDom(rootElement) : rootElement.getAttribute('data-drag-handler-node-type');
154
155
  if (nodeType) {
155
156
  if (editorExperiment('platform_editor_controls', 'variant1')) {
156
157
  var _api$core, _api$blockControls2, _rootPos, _rootAnchorName, _rootNodeType;
@@ -1,6 +1,6 @@
1
1
  import rafSchedule from 'raf-schd';
2
2
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
3
- import { browser } from '@atlaskit/editor-common/browser';
3
+ import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-common/browser';
4
4
  import { isMeasuring, startMeasure, stopMeasure } from '@atlaskit/editor-common/performance-measures';
5
5
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
6
6
  import { DRAG_HANDLE_SELECTOR } from '@atlaskit/editor-common/styles';
@@ -295,6 +295,7 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
295
295
  if (activeNode && (meta === null || meta === void 0 ? void 0 : meta.isDragging) !== true) {
296
296
  var _mappedRootPos$pos, _mappedRootPos;
297
297
  let mappedPos;
298
+ const browser = expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) ? getBrowserInfo() : browserLegacy;
298
299
  // In safari, when platform_editor_controls is on,
299
300
  // sometimes the drag handle for the layout disppears after you click on the handle for a few times
300
301
  // Which caused the drag handle onClick event not firing, then block menu wouldn't be opened
@@ -2,7 +2,6 @@ import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
2
2
  import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
3
3
  import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
4
4
  import { selectTableClosestToPos } from '@atlaskit/editor-tables/utils';
5
- import { fg } from '@atlaskit/platform-feature-flags';
6
5
  import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
7
6
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
8
7
  export const getInlineNodePos = (tr, start, nodeSize) => {
@@ -67,7 +66,7 @@ const oldGetSelection = (tr, start) => {
67
66
  // we need a quick way to make all child media nodes appear as selected without the need for a custom selection
68
67
  nodeName === 'mediaGroup') {
69
68
  return new NodeSelection($startPos);
70
- } else if (nodeName === 'taskList' && fg('platform_editor_elements_dnd_multi_select_patch_1')) {
69
+ } else if (nodeName === 'taskList') {
71
70
  return TextSelection.create(tr.doc, start, start + nodeSize);
72
71
  } else {
73
72
  const {
@@ -109,7 +108,7 @@ const newGetSelection = (tr, start) => {
109
108
  const $mediaStartPos = tr.doc.resolve(start + 1);
110
109
  return new NodeSelection($mediaStartPos);
111
110
  }
112
- if (nodeName === 'taskList' && !expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) && fg('platform_editor_elements_dnd_multi_select_patch_1')) {
111
+ if (nodeName === 'taskList' && !expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
113
112
  return TextSelection.create(tr.doc, start, start + nodeSize);
114
113
  }
115
114
  const {
@@ -176,40 +175,22 @@ export const isHandleCorrelatedToSelection = (state, selection, handlePos) => {
176
175
  }
177
176
  let nodeStart;
178
177
  const $selectionFrom = selection.$from;
179
- if (fg('platform_editor_elements_dnd_multi_select_patch_1')) {
180
- nodeStart = $selectionFrom.before($selectionFrom.sharedDepth(selection.to) + 1);
181
- if (nodeStart === $selectionFrom.pos) {
182
- nodeStart = $selectionFrom.depth ? $selectionFrom.before() : $selectionFrom.pos;
183
- }
184
- const $resolvedNodePos = state.doc.resolve(nodeStart);
185
- if (['tableRow', 'tableCell', 'tableHeader'].includes($resolvedNodePos.node().type.name)) {
186
- const parentNodeFindRes = findParentNodeOfType(state.schema.nodes['table'])(selection);
187
- const tablePos = parentNodeFindRes === null || parentNodeFindRes === void 0 ? void 0 : parentNodeFindRes.pos;
188
- nodeStart = typeof tablePos === 'undefined' ? nodeStart : tablePos;
189
- } else if (['listItem'].includes($resolvedNodePos.node().type.name)) {
190
- nodeStart = $resolvedNodePos.before(rootListDepth($resolvedNodePos));
191
- } else if (['taskList'].includes($resolvedNodePos.node().type.name)) {
192
- const listdepth = rootTaskListDepth($resolvedNodePos);
193
- nodeStart = $resolvedNodePos.before(listdepth);
194
- } else if (['blockquote'].includes($resolvedNodePos.node().type.name)) {
195
- nodeStart = $resolvedNodePos.before();
196
- }
197
- } else {
198
- const selectionFrom = $selectionFrom.pos;
199
- nodeStart = $selectionFrom.depth ? $selectionFrom.before() : selectionFrom;
200
- const $resolvedNodePos = state.doc.resolve(nodeStart);
201
- if (['tableRow', 'tableCell', 'tableHeader'].includes($resolvedNodePos.node().type.name)) {
202
- const parentNodeFindRes = findParentNodeOfType(state.schema.nodes['table'])(selection);
203
- const tablePos = parentNodeFindRes === null || parentNodeFindRes === void 0 ? void 0 : parentNodeFindRes.pos;
204
- nodeStart = typeof tablePos === 'undefined' ? nodeStart : tablePos;
205
- } else if (['listItem'].includes($resolvedNodePos.node().type.name)) {
206
- nodeStart = $resolvedNodePos.before(rootListDepth($resolvedNodePos));
207
- } else if (['taskList'].includes($resolvedNodePos.node().type.name)) {
208
- const listdepth = rootTaskListDepth($resolvedNodePos);
209
- nodeStart = $resolvedNodePos.before(listdepth);
210
- } else if (['blockquote'].includes($resolvedNodePos.node().type.name)) {
211
- nodeStart = $resolvedNodePos.before();
212
- }
178
+ nodeStart = $selectionFrom.before($selectionFrom.sharedDepth(selection.to) + 1);
179
+ if (nodeStart === $selectionFrom.pos) {
180
+ nodeStart = $selectionFrom.depth ? $selectionFrom.before() : $selectionFrom.pos;
181
+ }
182
+ const $resolvedNodePos = state.doc.resolve(nodeStart);
183
+ if (['tableRow', 'tableCell', 'tableHeader'].includes($resolvedNodePos.node().type.name)) {
184
+ const parentNodeFindRes = findParentNodeOfType(state.schema.nodes['table'])(selection);
185
+ const tablePos = parentNodeFindRes === null || parentNodeFindRes === void 0 ? void 0 : parentNodeFindRes.pos;
186
+ nodeStart = typeof tablePos === 'undefined' ? nodeStart : tablePos;
187
+ } else if (['listItem'].includes($resolvedNodePos.node().type.name)) {
188
+ nodeStart = $resolvedNodePos.before(rootListDepth($resolvedNodePos));
189
+ } else if (['taskList'].includes($resolvedNodePos.node().type.name)) {
190
+ const listdepth = rootTaskListDepth($resolvedNodePos);
191
+ nodeStart = $resolvedNodePos.before(listdepth);
192
+ } else if (['blockquote'].includes($resolvedNodePos.node().type.name)) {
193
+ nodeStart = $resolvedNodePos.before();
213
194
  }
214
195
  return Boolean(handlePos < selection.$to.pos && handlePos >= nodeStart);
215
196
  };
@@ -164,7 +164,7 @@ export function canMoveSliceToIndex(slice, sliceFromPos, sliceToPos, destParent,
164
164
  }
165
165
 
166
166
  // Multiple layout columns do not drop correctly.
167
- if (((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type.name) === 'layoutColumn' && fg('platform_editor_elements_dnd_multi_select_patch_1')) {
167
+ if (((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type.name) === 'layoutColumn') {
168
168
  return false;
169
169
  }
170
170
  for (let i = 0; i < slice.content.childCount; i++) {
@@ -9,7 +9,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
9
9
  import { css, jsx } from '@emotion/react';
10
10
  import { bind } from 'bind-event-listener';
11
11
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
12
- import { browser } from '@atlaskit/editor-common/browser';
12
+ import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-common/browser';
13
13
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
14
14
  import { dragToMoveDown, dragToMoveLeft, dragToMoveRight, dragToMoveUp, getAriaKeyshortcuts, TooltipContentWithMultipleShortcuts } from '@atlaskit/editor-common/keymaps';
15
15
  import { blockControlsMessages } from '@atlaskit/editor-common/messages';
@@ -17,7 +17,7 @@ import { tableControlsSpacing, DRAG_HANDLE_WIDTH } from '@atlaskit/editor-common
17
17
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
18
18
  import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
19
19
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
20
- import { akEditorTableToolbarSize, akEditorFullPageNarrowBreakout } from '@atlaskit/editor-shared-styles/consts';
20
+ import { akEditorTableToolbarSize, akEditorFullPageNarrowBreakout, akEditorFullPageDefaultFontSize } from '@atlaskit/editor-shared-styles/consts';
21
21
  import DragHandleVerticalIcon from '@atlaskit/icon/core/drag-handle-vertical';
22
22
  import DragHandlerIcon from '@atlaskit/icon/glyph/drag-handler';
23
23
  import { fg } from '@atlaskit/platform-feature-flags';
@@ -127,6 +127,16 @@ const dragHandleButtonStyles = css({
127
127
  backgroundColor: "var(--ds-background-disabled, transparent)"
128
128
  }
129
129
  });
130
+
131
+ // Calculate scaled dimensions based on the base font size using CSS calc()
132
+ // Default font size is 16px, scale proportionally
133
+ // Standard: 16px -> 24h x 12w, Dense: 13px -> 18h x 9w
134
+ const dragHandleButtonDenseModeStyles = css({
135
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
136
+ height: `calc(${DRAG_HANDLE_HEIGHT}px * var(--ak-editor-base-font-size) / ${akEditorFullPageDefaultFontSize}px)`,
137
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
138
+ width: `calc(${DRAG_HANDLE_WIDTH}px * var(--ak-editor-base-font-size) / ${akEditorFullPageDefaultFontSize}px)`
139
+ });
130
140
  const dragHandleButtonSmallScreenStyles = css({
131
141
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-container-queries, @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
132
142
  [`@container editor-area (max-width: ${akEditorFullPageNarrowBreakout}px)`]: {
@@ -243,6 +253,7 @@ const selectedStyles = css({
243
253
  // icon span receives dragStart event, instead of button, and since it is not registered as a draggable element
244
254
  // with pragmatic DnD and pragmatic DnD is not triggered
245
255
  const handleIconDragStart = e => {
256
+ const browser = expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) ? getBrowserInfo() : browserLegacy;
246
257
  if (!browser.chrome) {
247
258
  return;
248
259
  }
@@ -512,9 +523,8 @@ export const DragHandle = ({
512
523
  if (typeof handlePos !== 'number') {
513
524
  return tr;
514
525
  }
515
- const oldHandlePosCheck = handlePos >= tr.selection.$from.start() - 1 && handlePos <= tr.selection.to;
516
526
  const newHandlePosCheck = isHandleCorrelatedToSelection(view.state, tr.selection, handlePos);
517
- if (!tr.selection.empty && (fg('platform_editor_elements_dnd_multi_select_patch_1') ? newHandlePosCheck : oldHandlePosCheck)) {
527
+ if (!tr.selection.empty && newHandlePosCheck) {
518
528
  var _api$blockControls7;
519
529
  api === null || api === void 0 ? void 0 : (_api$blockControls7 = api.blockControls) === null || _api$blockControls7 === void 0 ? void 0 : _api$blockControls7.commands.setMultiSelectPositions()({
520
530
  tr
@@ -713,7 +723,7 @@ export const DragHandle = ({
713
723
  const bottom = editorExperiment('platform_editor_controls', 'variant1') ? getControlBottomCSSValue(safeAnchorName, isSticky, isTopLevelNode, isLayoutColumn) : {};
714
724
  return {
715
725
  left: isEdgeCase ? `calc(anchor(${safeAnchorName} start) + ${getLeftPosition(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType)})` : editorExperiment('advanced_layouts', true) && isLayoutColumn ? `calc((anchor(${safeAnchorName} right) + anchor(${safeAnchorName} left))/2 - ${DRAG_HANDLE_HEIGHT / 2}px)` : `calc(anchor(${safeAnchorName} start) - ${DRAG_HANDLE_WIDTH}px - ${dragHandleGap(nodeType, parentNodeType)}px)`,
716
- top: editorExperiment('advanced_layouts', true) && isLayoutColumn ? `calc(anchor(${safeAnchorName} top) - ${DRAG_HANDLE_WIDTH}px)` : `calc(anchor(${safeAnchorName} start) + ${expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) ? $pos && $pos.nodeAfter && getNodeTypeWithLevel($pos.nodeAfter) || nodeType : nodeType}px)`,
726
+ top: editorExperiment('advanced_layouts', true) && isLayoutColumn ? `calc(anchor(${safeAnchorName} top) - ${DRAG_HANDLE_WIDTH}px)` : `calc(anchor(${safeAnchorName} start)+ ${topPositionAdjustment(expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) ? $pos && $pos.nodeAfter && getNodeTypeWithLevel($pos.nodeAfter) || nodeType : nodeType)}px)`,
717
727
  ...bottom
718
728
  };
719
729
  }
@@ -933,6 +943,7 @@ export const DragHandle = ({
933
943
  editorExperiment('platform_editor_element_drag_and_drop_multiselect', true) && event.stopPropagation();
934
944
  };
935
945
  const hasHadInteraction = interactionState !== 'hasNotHadInteraction';
946
+ const browser = expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) ? getBrowserInfo() : browserLegacy;
936
947
  const renderButton = () =>
937
948
  // eslint-disable-next-line @atlaskit/design-system/no-html-button
938
949
  jsx("button", {
@@ -940,7 +951,7 @@ export const DragHandle = ({
940
951
  css: [editorExperiment('platform_editor_controls', 'variant1') ? dragHandleButtonStyles : dragHandleButtonStylesOld, editorExperiment('platform_editor_controls', 'variant1') && dragHandleColor,
941
952
  // ED-26266: Fixed the drag handle highlight when selecting multiple line in Firefox
942
953
  // See https://product-fabric.atlassian.net/browse/ED-26266
943
- browser.gecko && dragHandleMultiLineSelectionFixFirefox, editorExperiment('advanced_layouts', true) && isLayoutColumn && layoutColumnDragHandleStyles, dragHandleSelected && hasHadInteraction && selectedStyles, editorExperiment('platform_editor_preview_panel_responsiveness', true) && editorExperiment('platform_editor_controls', 'control') && dragHandleButtonSmallScreenStyles, expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) && expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true) && isFocused && keyboardFocusedDragHandleStyles, expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) && expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true) ? focusedStyles : focusedStylesOld],
954
+ browser.gecko && dragHandleMultiLineSelectionFixFirefox, editorExperiment('advanced_layouts', true) && isLayoutColumn && layoutColumnDragHandleStyles, dragHandleSelected && hasHadInteraction && selectedStyles, editorExperiment('platform_editor_preview_panel_responsiveness', true) && editorExperiment('platform_editor_controls', 'control') && dragHandleButtonSmallScreenStyles, expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) && expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true) && isFocused && keyboardFocusedDragHandleStyles, expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) && expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true) ? focusedStyles : focusedStylesOld, expValEquals('cc_editor_ai_content_mode', 'variant', 'test') && fg('platform_editor_content_mode_button_mvp') && dragHandleButtonDenseModeStyles],
944
955
  ref: buttonRef
945
956
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
946
957
  ,
@@ -1,5 +1,6 @@
1
- import { browser } from '@atlaskit/editor-common/browser';
1
+ import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-common/browser';
2
2
  import { N20, N30 } from '@atlaskit/theme/colors';
3
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
3
4
  const previewStyle = {
4
5
  borderColor: `var(--ds-border, ${N30})`,
5
6
  borderStyle: 'solid',
@@ -62,6 +63,7 @@ const createContentPreviewElement = (dom, nodeType, nodeSpacing) => {
62
63
  // Ignored via go/ees005
63
64
  // eslint-disable-next-line @atlaskit/editor/no-as-casting
64
65
  dom.cloneNode(true);
66
+ const browser = expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) ? getBrowserInfo() : browserLegacy;
65
67
  clonedDom.style.marginLeft = '0';
66
68
  clonedDom.style.marginTop = nodeSpacing ? `${nodeSpacing.top}` : '0';
67
69
  clonedDom.style.marginRight = '0';
@@ -90,7 +90,8 @@ export const InlineDropTarget = ({
90
90
  const [isDraggedOver, setIsDraggedOver] = useState(false);
91
91
  const anchorName = useMemo(() => {
92
92
  if (expValEquals('platform_editor_native_anchor_support', 'isEnabled', true)) {
93
- return nextNode ? (api === null || api === void 0 ? void 0 : api.core.actions.getAnchorIdForNode(nextNode, getPos() || -1)) || '' : '';
93
+ var _getPos;
94
+ return nextNode ? (api === null || api === void 0 ? void 0 : api.core.actions.getAnchorIdForNode(nextNode, (_getPos = getPos()) !== null && _getPos !== void 0 ? _getPos : -1)) || '' : '';
94
95
  }
95
96
  return nextNode ? getNodeAnchor(nextNode) : '';
96
97
  }, [api, getPos, nextNode]);
@@ -14,14 +14,17 @@ import { tableControlsSpacing } from '@atlaskit/editor-common/styles';
14
14
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
15
15
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
16
16
  import { findParentNode, findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
17
+ import { akEditorFullPageDefaultFontSize } from '@atlaskit/editor-shared-styles';
17
18
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
18
19
  import AddIcon from '@atlaskit/icon/core/add';
20
+ import { fg } from '@atlaskit/platform-feature-flags';
19
21
  // eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
20
22
  import { Box, Pressable, xcss } from '@atlaskit/primitives';
23
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
21
24
  import Tooltip from '@atlaskit/tooltip';
22
25
  import { getControlBottomCSSValue, getControlHeightCSSValue, getNodeHeight, getTopPosition, shouldBeSticky } from '../pm-plugins/utils/drag-handle-positions';
23
26
  import { getLeftPositionForRootElement } from '../pm-plugins/utils/widget-positions';
24
- import { QUICK_INSERT_DIMENSIONS, QUICK_INSERT_LEFT_OFFSET, rootElementGap, topPositionAdjustment } from './consts';
27
+ import { QUICK_INSERT_DIMENSIONS, QUICK_INSERT_HEIGHT, QUICK_INSERT_LEFT_OFFSET, QUICK_INSERT_WIDTH, rootElementGap, topPositionAdjustment } from './consts';
25
28
  import { refreshAnchorName } from './utils/anchor-name';
26
29
  import { isInTextSelection, isNestedNodeSelected, isNonEditableBlock, isSelectionInNode } from './utils/document-checks';
27
30
  import { getAnchorAttrName } from './utils/dom-attr-name';
@@ -53,6 +56,16 @@ const stickyButtonStyles = xcss({
53
56
  outline: `${"var(--ds-border-width-focused, 2px)"} solid ${"var(--ds-border-focused, #388BFF)"}`
54
57
  }
55
58
  });
59
+
60
+ // Calculate scaled dimensions based on the base font size using CSS calc()
61
+ // Default font size is 16px, scale proportionally
62
+ // Standard: 16px -> 24px x 24px, Dense: 13px -> ~18.5px x ~18.5px
63
+ const stickyButtonDenseModeStyles = xcss({
64
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
65
+ height: `calc(${QUICK_INSERT_HEIGHT}px * var(--ak-editor-base-font-size) / ${akEditorFullPageDefaultFontSize}px)`,
66
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
67
+ width: `calc(${QUICK_INSERT_WIDTH}px * var(--ak-editor-base-font-size) / ${akEditorFullPageDefaultFontSize}px)`
68
+ });
56
69
  const containerStaticStyles = xcss({
57
70
  position: 'absolute',
58
71
  zIndex: 'card'
@@ -273,7 +286,7 @@ export const TypeAheadControl = ({
273
286
  testId: "editor-quick-insert-button",
274
287
  type: "button",
275
288
  "aria-label": formatMessage(messages.insert),
276
- xcss: [stickyButtonStyles],
289
+ xcss: [stickyButtonStyles, expValEquals('cc_editor_ai_content_mode', 'variant', 'test') && fg('platform_editor_content_mode_button_mvp') && stickyButtonDenseModeStyles],
277
290
  onClick: handleQuickInsert,
278
291
  onMouseDown: handleMouseDown
279
292
  }, jsx(AddIcon, {
@@ -34,50 +34,37 @@ import { getPosWhenMoveNodeDown, getPosWhenMoveNodeUp } from './utils/move-node-
34
34
  function transformSourceSlice(nodeCopy, destType) {
35
35
  var srcNode = nodeCopy.content.firstChild;
36
36
  var schema = srcNode === null || srcNode === void 0 ? void 0 : srcNode.type.schema;
37
- if (fg('platform_editor_elements_dnd_multi_select_patch_1')) {
38
- if (!schema) {
39
- return nodeCopy;
40
- }
41
- var _schema$nodes = schema.nodes,
42
- doc = _schema$nodes.doc,
43
- layoutColumn = _schema$nodes.layoutColumn;
44
- var destTypeInTable = isInsideTable(destType);
45
- var destTypeInDocOrLayoutCol = [doc, layoutColumn].includes(destType);
37
+ if (!schema) {
38
+ return nodeCopy;
39
+ }
40
+ var _schema$nodes = schema.nodes,
41
+ doc = _schema$nodes.doc,
42
+ layoutColumn = _schema$nodes.layoutColumn;
43
+ var destTypeInTable = isInsideTable(destType);
44
+ var destTypeInDocOrLayoutCol = [doc, layoutColumn].includes(destType);
46
45
 
47
- // No need to loop over slice content if destination requires no transformations
48
- if (!destTypeInTable && !destTypeInDocOrLayoutCol) {
49
- return nodeCopy;
50
- }
51
- var containsExpand = false;
52
- var containsNestedExpand = false;
53
- for (var i = 0; i < nodeCopy.content.childCount; i++) {
54
- var node = nodeCopy.content.child(i);
55
- if (node.type === schema.nodes.expand) {
56
- containsExpand = true;
57
- } else if (node.type === schema.nodes.nestedExpand) {
58
- containsNestedExpand = true;
59
- }
60
- if (containsExpand && containsNestedExpand) {
61
- break;
62
- }
63
- }
64
- if (containsExpand && destTypeInTable) {
65
- return transformSliceExpandToNestedExpand(nodeCopy);
66
- } else if (containsNestedExpand && destTypeInDocOrLayoutCol) {
67
- return transformSliceNestedExpandToExpand(nodeCopy, schema);
46
+ // No need to loop over slice content if destination requires no transformations
47
+ if (!destTypeInTable && !destTypeInDocOrLayoutCol) {
48
+ return nodeCopy;
49
+ }
50
+ var containsExpand = false;
51
+ var containsNestedExpand = false;
52
+ for (var i = 0; i < nodeCopy.content.childCount; i++) {
53
+ var node = nodeCopy.content.child(i);
54
+ if (node.type === schema.nodes.expand) {
55
+ containsExpand = true;
56
+ } else if (node.type === schema.nodes.nestedExpand) {
57
+ containsNestedExpand = true;
68
58
  }
69
- } else {
70
- if (srcNode && schema) {
71
- var _schema$nodes2 = schema.nodes,
72
- _doc = _schema$nodes2.doc,
73
- _layoutColumn = _schema$nodes2.layoutColumn;
74
- if (srcNode.type === schema.nodes.nestedExpand && [_doc, _layoutColumn].includes(destType)) {
75
- return transformSliceNestedExpandToExpand(nodeCopy, schema);
76
- } else if (srcNode.type === schema.nodes.expand && isInsideTable(destType)) {
77
- return transformSliceExpandToNestedExpand(nodeCopy);
78
- }
59
+ if (containsExpand && containsNestedExpand) {
60
+ break;
79
61
  }
80
62
  }
63
+ if (containsExpand && destTypeInTable) {
64
+ return transformSliceExpandToNestedExpand(nodeCopy);
65
+ } else if (containsNestedExpand && destTypeInDocOrLayoutCol) {
66
+ return transformSliceNestedExpandToExpand(nodeCopy, schema);
67
+ }
81
68
  return nodeCopy;
82
69
  }
83
70
  var nodesSupportDragLayoutColumnInto = ['tableCell', 'tableHeader', 'panel', 'expand', 'nestedExpand'];
@@ -140,7 +127,7 @@ export var moveNodeViaShortcut = function moveNodeViaShortcut(api, direction, fo
140
127
  var hoistedPos;
141
128
  var from = Math.min(expandedAnchor, expandedHead);
142
129
  // Nodes like lists nest within themselves, we need to find the top most position
143
- if (isParentNodeOfTypeLayout && fg('platform_editor_elements_dnd_multi_select_patch_1')) {
130
+ if (isParentNodeOfTypeLayout) {
144
131
  var LAYOUT_COL_DEPTH = 3;
145
132
  hoistedPos = state.doc.resolve(from).before(LAYOUT_COL_DEPTH);
146
133
  }
@@ -282,15 +269,9 @@ export var moveNodeViaShortcut = function moveNodeViaShortcut(api, direction, fo
282
269
  var _api$core7;
283
270
  api === null || api === void 0 || (_api$core7 = api.core) === null || _api$core7 === void 0 || _api$core7.actions.execute(function (_ref4) {
284
271
  var tr = _ref4.tr;
285
- if (fg('platform_editor_elements_dnd_multi_select_patch_1')) {
286
- api === null || api === void 0 || api.blockControls.commands.setMultiSelectPositions($newAnchor.pos, $newHead.pos)({
287
- tr: tr
288
- });
289
- } else {
290
- api === null || api === void 0 || api.blockControls.commands.setMultiSelectPositions(expandedAnchor, expandedHead)({
291
- tr: tr
292
- });
293
- }
272
+ api === null || api === void 0 || api.blockControls.commands.setMultiSelectPositions($newAnchor.pos, $newHead.pos)({
273
+ tr: tr
274
+ });
294
275
  moveNode(api)(currentNodePos, moveToPos, INPUT_METHOD.SHORTCUT, formatMessage)({
295
276
  tr: tr
296
277
  });
@@ -312,15 +293,9 @@ export var moveNodeViaShortcut = function moveNodeViaShortcut(api, direction, fo
312
293
  var _api$core9;
313
294
  api === null || api === void 0 || (_api$core9 = api.core) === null || _api$core9 === void 0 || _api$core9.actions.execute(function (_ref6) {
314
295
  var tr = _ref6.tr;
315
- if (fg('platform_editor_elements_dnd_multi_select_patch_1')) {
316
- api === null || api === void 0 || api.blockControls.commands.setMultiSelectPositions($newAnchor.pos, $newHead.pos)({
317
- tr: tr
318
- });
319
- } else {
320
- api === null || api === void 0 || api.blockControls.commands.setMultiSelectPositions(expandedAnchor, expandedHead)({
321
- tr: tr
322
- });
323
- }
296
+ api === null || api === void 0 || api.blockControls.commands.setMultiSelectPositions($newAnchor.pos, $newHead.pos)({
297
+ tr: tr
298
+ });
324
299
  tr.scrollIntoView();
325
300
  return tr;
326
301
  });
@@ -29,7 +29,7 @@ var getNodeSelector = function getNodeSelector(ignoreNodes, ignoreNodeDescendant
29
29
  };
30
30
  var getDefaultNodeSelector = memoizeOne(function () {
31
31
  // we don't show handler for node nested in table
32
- return getNodeSelector(_toConsumableArray(IGNORE_NODES_NEXT), [].concat(_toConsumableArray(IGNORE_NODE_DESCENDANTS_ADVANCED_LAYOUT), ['table']));
32
+ return getNodeSelector([].concat(_toConsumableArray(IGNORE_NODES_NEXT), ['media']), [].concat(_toConsumableArray(IGNORE_NODE_DESCENDANTS_ADVANCED_LAYOUT), ['table']));
33
33
  });
34
34
  export var handleMouseOver = function handleMouseOver(view, event, api) {
35
35
  var _api$blockControls, _api$editorDisabled, _target$classList;
@@ -44,7 +44,7 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
44
44
  editorDisabled = _ref2.editorDisabled;
45
45
 
46
46
  // We shouldn't be firing mouse over transactions when the editor is disabled
47
- if (editorDisabled && fg('platform_editor_ai_rovo_free_gen')) {
47
+ if (editorDisabled && fg('aifc_create_enabled')) {
48
48
  return false;
49
49
  }
50
50
 
@@ -57,24 +57,25 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
57
57
  // Ignored via go/ees005
58
58
  // eslint-disable-next-line @atlaskit/editor/no-as-casting
59
59
  var target = event.target;
60
+ var isNativeAnchorSupported = expValEquals('platform_editor_native_anchor_support', 'isEnabled', true);
60
61
  if (target !== null && target !== void 0 && (_target$classList = target.classList) !== null && _target$classList !== void 0 && _target$classList.contains('ProseMirror')) {
61
62
  return false;
62
63
  }
63
- var rootElement = target === null || target === void 0 ? void 0 : target.closest(expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) ? getDefaultNodeSelector() : "[data-drag-handler-anchor-name]");
64
+ var rootElement = target === null || target === void 0 ? void 0 : target.closest(isNativeAnchorSupported ? getDefaultNodeSelector() : "[data-drag-handler-anchor-name]");
64
65
  if (rootElement) {
65
66
  var _rootElement$parentEl;
66
67
  // We want to exlude handles from showing for empty paragraph and heading nodes
67
68
  if (isEmptyNestedParagraphOrHeading(rootElement)) {
68
69
  return false;
69
70
  }
70
- if (rootElement.getAttribute(getTypeNameAttrName()) === 'media' && editorExperiment('advanced_layouts', true)) {
71
+ if (rootElement.getAttribute(getTypeNameAttrName()) === 'media' && editorExperiment('advanced_layouts', true) && !isNativeAnchorSupported) {
71
72
  rootElement = rootElement.closest("[".concat(getAnchorAttrName(), "][").concat(getTypeNameAttrName(), "=\"mediaSingle\"]"));
72
73
  if (!rootElement) {
73
74
  return false;
74
75
  }
75
76
  }
76
77
  var parentElement = (_rootElement$parentEl = rootElement.parentElement) === null || _rootElement$parentEl === void 0 ? void 0 : _rootElement$parentEl.closest("[".concat(getAnchorAttrName(), "]"));
77
- var parentElementType = expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) ? getTypeNameFromDom(parentElement) : parentElement === null || parentElement === void 0 ? void 0 : parentElement.getAttribute('data-drag-handler-node-type');
78
+ var parentElementType = isNativeAnchorSupported ? getTypeNameFromDom(parentElement) : parentElement === null || parentElement === void 0 ? void 0 : parentElement.getAttribute('data-drag-handler-node-type');
78
79
  if (editorExperiment('advanced_layouts', true)) {
79
80
  // We want to exclude handles from showing for direct descendant of table nodes (i.e. nodes in cells)
80
81
  if (parentElement && parentElementType === 'table') {
@@ -82,7 +83,7 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
82
83
  } else if (parentElement && parentElementType === 'tableRow') {
83
84
  var _parentElement$parent;
84
85
  var grandparentElement = parentElement === null || parentElement === void 0 || (_parentElement$parent = parentElement.parentElement) === null || _parentElement$parent === void 0 ? void 0 : _parentElement$parent.closest("[".concat(getAnchorAttrName(), "]"));
85
- var grandparentElementType = expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) ? getTypeNameFromDom(grandparentElement) : grandparentElement === null || grandparentElement === void 0 ? void 0 : grandparentElement.getAttribute('data-drag-handler-node-type');
86
+ var grandparentElementType = isNativeAnchorSupported ? getTypeNameFromDom(grandparentElement) : grandparentElement === null || grandparentElement === void 0 ? void 0 : grandparentElement.getAttribute('data-drag-handler-node-type');
86
87
  if (grandparentElement && grandparentElementType === 'table') {
87
88
  rootElement = grandparentElement;
88
89
  }
@@ -149,11 +150,11 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
149
150
  if (rootDOM instanceof HTMLElement) {
150
151
  var _rootDOM$getAttribute;
151
152
  rootAnchorName = (_rootDOM$getAttribute = rootDOM.getAttribute(getAnchorAttrName())) !== null && _rootDOM$getAttribute !== void 0 ? _rootDOM$getAttribute : undefined;
152
- rootNodeType = expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) ? getTypeNameFromDom(rootDOM) : rootDOM.getAttribute('data-drag-handler-node-type');
153
+ rootNodeType = isNativeAnchorSupported ? getTypeNameFromDom(rootDOM) : rootDOM.getAttribute('data-drag-handler-node-type');
153
154
  }
154
155
  }
155
156
  }
156
- var nodeType = expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) ? getTypeNameFromDom(rootElement) : rootElement.getAttribute('data-drag-handler-node-type');
157
+ var nodeType = isNativeAnchorSupported ? getTypeNameFromDom(rootElement) : rootElement.getAttribute('data-drag-handler-node-type');
157
158
  if (nodeType) {
158
159
  if (editorExperiment('platform_editor_controls', 'variant1')) {
159
160
  var _api$core, _api$blockControls2;
@@ -3,7 +3,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
3
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
4
  import rafSchedule from 'raf-schd';
5
5
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
6
- import { browser } from '@atlaskit/editor-common/browser';
6
+ import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-common/browser';
7
7
  import { isMeasuring, startMeasure, stopMeasure } from '@atlaskit/editor-common/performance-measures';
8
8
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
9
9
  import { DRAG_HANDLE_SELECTOR } from '@atlaskit/editor-common/styles';
@@ -289,6 +289,7 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
289
289
  if (activeNode && (meta === null || meta === void 0 ? void 0 : meta.isDragging) !== true) {
290
290
  var _mappedRootPos$pos, _mappedRootPos;
291
291
  var _mappedPos;
292
+ var browser = expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) ? getBrowserInfo() : browserLegacy;
292
293
  // In safari, when platform_editor_controls is on,
293
294
  // sometimes the drag handle for the layout disppears after you click on the handle for a few times
294
295
  // Which caused the drag handle onClick event not firing, then block menu wouldn't be opened