@atlaskit/editor-plugin-block-controls 9.1.7 → 9.1.9

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
+ ## 9.1.9
4
+
5
+ ### Patch Changes
6
+
7
+ - [`840d3970b9d8c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/840d3970b9d8c) -
8
+ Fix paragraph spacing in panels for small font-size block marks
9
+
10
+ Fix drag handle positioning around small text
11
+
12
+ Fix drag handles not appearing on small text in panels
13
+
14
+ - Updated dependencies
15
+
16
+ ## 9.1.8
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies
21
+
3
22
  ## 9.1.7
4
23
 
5
24
  ### Patch Changes
@@ -10,6 +10,8 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
10
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
11
  var _reactDom = _interopRequireDefault(require("react-dom"));
12
12
  var _uuid = _interopRequireDefault(require("uuid"));
13
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
14
+ var _validation = require("./utils/validation");
13
15
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
14
16
 
15
17
  var TYPE_DROP_TARGET_DEC = exports.TYPE_DROP_TARGET_DEC = 'drop-target-decoration';
@@ -20,8 +22,17 @@ var getNodeAnchor = exports.getNodeAnchor = function getNodeAnchor(node) {
20
22
  var handleId = ObjHash.getForNode(node);
21
23
  return "--node-anchor-".concat(node.type.name, "-").concat(handleId);
22
24
  };
25
+ var getSubType = function getSubType(node) {
26
+ if (node.attrs.level) {
27
+ return "-".concat(node.attrs.level);
28
+ }
29
+ if ((0, _validation.isFontSizeMarkActive)(node)) {
30
+ return '-small';
31
+ }
32
+ return '';
33
+ };
23
34
  var getNodeTypeWithLevel = exports.getNodeTypeWithLevel = function getNodeTypeWithLevel(node) {
24
- var subType = node.attrs.level ? "-".concat(node.attrs.level) : '';
35
+ var subType = (0, _expValEquals.expValEquals)('platform_editor_small_font_size', 'isEnabled', true) ? getSubType(node) : node.attrs.level ? "-".concat(node.attrs.level) : '';
25
36
  return node.type.name + subType;
26
37
  };
27
38
  var ObjHash = /*#__PURE__*/function () {
@@ -44,6 +44,16 @@ var getDefaultNodeSelector = (0, _memoizeOne.default)(function () {
44
44
  // we don't show handler for node nested in table
45
45
  return getNodeSelector([].concat((0, _toConsumableArray2.default)(_decorationsAnchor.IGNORE_NODES_NEXT), ['media']), [].concat((0, _toConsumableArray2.default)(_decorationsAnchor.IGNORE_NODE_DESCENDANTS_ADVANCED_LAYOUT), ['table']));
46
46
  });
47
+
48
+ // Block marks (e.g. font-size) wrap paragraphs in an extra div, making parentRootElement
49
+ // the mark wrapper instead of the panel content container. When that happens, recalculate
50
+ // the index relative to the panel content so the first-child check stays accurate.
51
+ var getBlockMarkPanelIndexAdjustment = function getBlockMarkPanelIndexAdjustment(parentRootElement, index) {
52
+ if ((0, _expValEquals.expValEquals)('platform_editor_small_font_size', 'isEnabled', true) && parentRootElement.classList.contains('fabric-editor-block-mark') && parentRootElement.parentElement) {
53
+ return Array.from(parentRootElement.parentElement.childNodes).indexOf(parentRootElement);
54
+ }
55
+ return index;
56
+ };
47
57
  var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, event, api) {
48
58
  var _api$blockControls, _api$editorDisabled, _api$editorViewMode, _api$blockControls$sh, _api$blockControls2, _target$classList;
49
59
  var _ref = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
@@ -164,10 +174,10 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
164
174
  var childNodes = Array.from(parentRootElement.childNodes);
165
175
  var index = childNodes.indexOf(rootElement);
166
176
  pos = view.posAtDOM(parentRootElement, index);
167
-
177
+ var panelIndex = getBlockMarkPanelIndexAdjustment(parentRootElement, index);
168
178
  // We want to exlude handles showing for first element in a Panel, ignoring widgets like gapcursor
169
179
  var firstChildIsWidget = parentRootElement === null || parentRootElement === void 0 || (_parentRootElement$ch = parentRootElement.children[0]) === null || _parentRootElement$ch === void 0 ? void 0 : _parentRootElement$ch.classList.contains('ProseMirror-widget');
170
- if (parentElement && parentElementType === 'panel' && !parentElement.classList.contains('ak-editor-panel__no-icon') && (index === 0 || firstChildIsWidget && index === 1)) {
180
+ if (parentElement && parentElementType === 'panel' && !parentElement.classList.contains('ak-editor-panel__no-icon') && (panelIndex === 0 || firstChildIsWidget && panelIndex === 1)) {
171
181
  return false;
172
182
  }
173
183
  } else {
@@ -32,6 +32,8 @@ var getTopPosition = exports.getTopPosition = function getTopPosition(dom, type)
32
32
  return "".concat(dom.offsetTop - _consts.DRAG_HANDLE_H5_TOP_ADJUSTMENT, "px");
33
33
  } else if (type === 'heading-6') {
34
34
  return "".concat(dom.offsetTop - _consts.DRAG_HANDLE_H6_TOP_ADJUSTMENT, "px");
35
+ } else if (type === 'paragraph-small') {
36
+ return "".concat(dom.offsetTop + _consts.DRAG_HANDLE_PARAGRAPH_SMALL_TOP_ADJUSTMENT, "px");
35
37
  } else if (type === 'paragraph') {
36
38
  return "".concat(dom.offsetTop + _consts.DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT, "px");
37
39
  } else {
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.canCreateNodeWithContentInsideAnotherNode = void 0;
8
8
  exports.canMoveNodeToIndex = canMoveNodeToIndex;
9
9
  exports.canMoveSliceToIndex = canMoveSliceToIndex;
10
- exports.transformSliceExpandToNestedExpand = exports.transformFragmentExpandToNestedExpand = exports.transformExpandToNestedExpand = exports.memoizedTransformExpandToNestedExpand = exports.isNestedExpand = exports.isLayoutColumn = exports.isInsideTable = exports.isInSameLayout = exports.isExpand = exports.isDoc = void 0;
10
+ exports.transformSliceExpandToNestedExpand = exports.transformFragmentExpandToNestedExpand = exports.transformExpandToNestedExpand = exports.memoizedTransformExpandToNestedExpand = exports.isNestedExpand = exports.isLayoutColumn = exports.isInsideTable = exports.isInSameLayout = exports.isFontSizeMarkActive = exports.isExpand = exports.isDoc = void 0;
11
11
  var _memoizeOne = _interopRequireDefault(require("memoize-one"));
12
12
  var _nesting = require("@atlaskit/editor-common/nesting");
13
13
  var _model = require("@atlaskit/editor-prosemirror/model");
@@ -31,6 +31,11 @@ var isExpand = exports.isExpand = function isExpand(nodeType) {
31
31
  var isNestedExpand = exports.isNestedExpand = function isNestedExpand(nodeType) {
32
32
  return nodeType === nodeType.schema.nodes.nestedExpand;
33
33
  };
34
+ var isFontSizeMarkActive = exports.isFontSizeMarkActive = function isFontSizeMarkActive(node) {
35
+ return node.type.name === 'paragraph' && node.marks.some(function (mark) {
36
+ return mark.type.name === 'fontSize';
37
+ });
38
+ };
34
39
  var isInSameLayout = exports.isInSameLayout = function isInSameLayout($from, $to) {
35
40
  var fromNode = $from.nodeAfter;
36
41
  var toNode = $to.nodeAfter;
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.topPositionAdjustment = exports.spacingBetweenNodesForPreview = exports.spaceLookupMap = exports.rootElementGap = exports.nodeMargins = exports.getNestedNodeLeftPaddingMargin = exports.dropTargetMarginMap = exports.dragHandleGap = exports.STICKY_CONTROLS_TOP_MARGIN_FOR_STICKY_HEADER = exports.STICKY_CONTROLS_TOP_MARGIN = exports.QUICK_INSERT_WIDTH = exports.QUICK_INSERT_LEFT_OFFSET = exports.QUICK_INSERT_HEIGHT = exports.QUICK_INSERT_DIMENSIONS = exports.DRAG_HANDLE_ZINDEX = exports.DRAG_HANDLE_SYNCED_BLOCK_GAP = exports.DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT = exports.DRAG_HANDLE_NARROW_GAP = exports.DRAG_HANDLE_MAX_WIDTH_PLUS_GAP = exports.DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH = exports.DRAG_HANDLE_MAX_GAP = exports.DRAG_HANDLE_LAYOUT_SECTION_TOP_ADJUSTMENT = exports.DRAG_HANDLE_HEIGHT = exports.DRAG_HANDLE_H6_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H5_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H4_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H3_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H2_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H1_TOP_ADJUSTMENT = exports.DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT = exports.DRAG_HANDLE_DEFAULT_GAP = exports.DRAG_HANDLE_BORDER_RADIUS = exports.DEFAULT_COLUMN_DISTRIBUTIONS = void 0;
7
+ exports.topPositionAdjustment = exports.spacingBetweenNodesForPreview = exports.spaceLookupMap = exports.rootElementGap = exports.nodeMargins = exports.getNestedNodeLeftPaddingMargin = exports.dropTargetMarginMap = exports.dragHandleGap = exports.STICKY_CONTROLS_TOP_MARGIN_FOR_STICKY_HEADER = exports.STICKY_CONTROLS_TOP_MARGIN = exports.QUICK_INSERT_WIDTH = exports.QUICK_INSERT_LEFT_OFFSET = exports.QUICK_INSERT_HEIGHT = exports.QUICK_INSERT_DIMENSIONS = exports.DRAG_HANDLE_ZINDEX = exports.DRAG_HANDLE_SYNCED_BLOCK_GAP = exports.DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT = exports.DRAG_HANDLE_PARAGRAPH_SMALL_TOP_ADJUSTMENT = exports.DRAG_HANDLE_NARROW_GAP = exports.DRAG_HANDLE_MAX_WIDTH_PLUS_GAP = exports.DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH = exports.DRAG_HANDLE_MAX_GAP = exports.DRAG_HANDLE_LAYOUT_SECTION_TOP_ADJUSTMENT = exports.DRAG_HANDLE_HEIGHT = exports.DRAG_HANDLE_H6_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H5_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H4_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H3_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H2_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H1_TOP_ADJUSTMENT = exports.DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT = exports.DRAG_HANDLE_DEFAULT_GAP = exports.DRAG_HANDLE_BORDER_RADIUS = exports.DEFAULT_COLUMN_DISTRIBUTIONS = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _styles = require("@atlaskit/editor-common/styles");
10
10
  var _utils = require("@atlaskit/editor-common/utils");
@@ -28,6 +28,7 @@ var DRAG_HANDLE_H5_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H5_TOP_ADJUSTMENT = 3;
28
28
  var DRAG_HANDLE_H6_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H6_TOP_ADJUSTMENT = 3;
29
29
  var DRAG_HANDLE_LAYOUT_SECTION_TOP_ADJUSTMENT = exports.DRAG_HANDLE_LAYOUT_SECTION_TOP_ADJUSTMENT = 8;
30
30
  var DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT = exports.DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT = 2;
31
+ var DRAG_HANDLE_PARAGRAPH_SMALL_TOP_ADJUSTMENT = exports.DRAG_HANDLE_PARAGRAPH_SMALL_TOP_ADJUSTMENT = 0;
31
32
 
32
33
  /** We only want to shift-select nodes that are at the top level of a document.
33
34
  * This is because funky things happen when selecting inside of tableCells, but we
@@ -119,6 +120,8 @@ var topPositionAdjustment = exports.topPositionAdjustment = function topPosition
119
120
  return DRAG_HANDLE_HEIGHT;
120
121
  case 'paragraph':
121
122
  return DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT;
123
+ case 'paragraph-small':
124
+ return DRAG_HANDLE_PARAGRAPH_SMALL_TOP_ADJUSTMENT;
122
125
  case 'heading-1':
123
126
  return DRAG_HANDLE_H1_TOP_ADJUSTMENT;
124
127
  case 'heading-2':
@@ -204,7 +204,7 @@ var dragHandleSelector = 'button[data-testid="block-ctrl-drag-handle"]';
204
204
  var dropTargetContainer = '.ProseMirror-widget[data-blocks-drop-target-container="true"]';
205
205
  var dividerBodiedInCustomPanelWithNoIconSelector = '[data-panel-type].ak-editor-panel__no-icon .ProseMirror-widget:first-child + .ProseMirror-widget:nth-child(2) + hr, [data-panel-type] hr:first-child';
206
206
  var withInlineNodeStyleSelectors = ["".concat(dragHandleContainer, ":has(").concat(paragraphWithTrailingBreakAsOnlyChild, ") ").concat(dragHandleSelector), "".concat(dragHandleContainer, ":has(").concat(indentatedParagraphWithTrailingBreakAsOnlyChild, ") ").concat(dragHandleSelector), "".concat(dragHandleContainer, ":has(").concat(paragraphWithPlaceholder, ") ").concat(dragHandleSelector)].join(', ');
207
- var withFormatInLayoutStyleFixSelectors = ["".concat(dragHandleContainer, ":first-child + .fabric-editor-indentation-mark > p:first-child"), "".concat(dragHandleContainer, ":first-child + .fabric-editor-alignment > p:first-child"), "".concat(dragHandleContainer, ":first-child + ").concat(dropTargetContainer, " + .fabric-editor-indentation-mark > p:first-child"), "".concat(dragHandleContainer, ":first-child + ").concat(dropTargetContainer, " + .fabric-editor-alignment > p:first-child"), "".concat(dropTargetContainer, ":first-child + .fabric-editor-alignment > p:first-child"), "".concat(dropTargetContainer, ":first-child + .fabric-editor-indentation-mark > p:first-child"), "".concat(dragHandleContainer, ":first-child + .fabric-editor-indentation-mark > :is(h1, h2, h3, h4, h5, h6):first-child")].join(', ');
207
+ var withFormatInLayoutStyleFixSelectors = ["".concat(dragHandleContainer, ":first-child + .fabric-editor-indentation-mark > p:first-child"), "".concat(dragHandleContainer, ":first-child + .fabric-editor-alignment > p:first-child"), "".concat(dragHandleContainer, ":first-child + .fabric-editor-font-size > p:first-child"), "".concat(dragHandleContainer, ":first-child + ").concat(dropTargetContainer, " + .fabric-editor-indentation-mark > p:first-child"), "".concat(dragHandleContainer, ":first-child + ").concat(dropTargetContainer, " + .fabric-editor-alignment > p:first-child"), "".concat(dragHandleContainer, ":first-child + ").concat(dropTargetContainer, " + .fabric-editor-font-size > p:first-child"), "".concat(dropTargetContainer, ":first-child + .fabric-editor-alignment > p:first-child"), "".concat(dropTargetContainer, ":first-child + .fabric-editor-indentation-mark > p:first-child"), "".concat(dropTargetContainer, ":first-child + .fabric-editor-font-size > p:first-child"), "".concat(dragHandleContainer, ":first-child + .fabric-editor-indentation-mark > :is(h1, h2, h3, h4, h5, h6):first-child"), "".concat(dragHandleContainer, ":first-child + .fabric-editor-font-size > :is(h1, h2, h3, h4, h5, h6):first-child")].join(', ');
208
208
 
209
209
  /**
210
210
  * Please do not change change transform to display:none, or visibility:hidden
@@ -240,6 +240,12 @@ var globalStyles = function globalStyles() {
240
240
  '.ProseMirror-widget:first-child + *:not([data-panel-type], .code-block, [data-node-type="nestedExpand"], [data-node-type="expand"], [data-layout-section="true"], [data-prosemirror-node-name="bodiedSyncBlock"])': {
241
241
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles -- Ignored via go/DSP-18766
242
242
  marginTop: '0 !important'
243
+ },
244
+ // Font-size wrapper is a div with no inherent margin — reach through to the content node inside.
245
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
246
+ '.ProseMirror-widget:first-child + .fabric-editor-font-size > :is(p, h1, h2, h3, h4, h5, h6):first-child, .ProseMirror-widget:first-child + .ProseMirror-widget + .fabric-editor-font-size > :is(p, h1, h2, h3, h4, h5, h6):first-child': {
247
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
248
+ marginTop: '0 !important'
243
249
  }
244
250
  });
245
251
  };
@@ -333,6 +339,13 @@ var topLevelNodeMarginStyles = (0, _react.css)({
333
339
  '> .ProseMirror-widget:first-child + .ProseMirror-gapcursor + *:not([data-layout-section="true"], [data-prosemirror-node-name="bodiedSyncBlock"]), > .ProseMirror-widget:first-child + *:not([data-layout-section="true"], [data-prosemirror-node-name="bodiedSyncBlock"])': {
334
340
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles -- Ignored via go/DSP-18766
335
341
  marginTop: '0 !important'
342
+ },
343
+ // When a drop target widget is inserted during drag, the font-size wrapper is no longer
344
+ // adjacent to the first widget. Reach through the wrapper to zero the inner content margin.
345
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
346
+ '> .ProseMirror-widget:first-child + .ProseMirror-widget + .fabric-editor-font-size > :is(p, h1, h2, h3, h4, h5, h6):first-child, > .ProseMirror-widget:first-child + .ProseMirror-gapcursor + .fabric-editor-font-size > :is(p, h1, h2, h3, h4, h5, h6):first-child': {
347
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
348
+ marginTop: '0 !important'
336
349
  }
337
350
  }
338
351
  });
@@ -24,6 +24,7 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
24
24
  var _primitives = require("@atlaskit/primitives");
25
25
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
26
26
  var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
27
+ var _decorationsCommon = require("../pm-plugins/decorations-common");
27
28
  var _dragHandlePositions = require("../pm-plugins/utils/drag-handle-positions");
28
29
  var _widgetPositions = require("../pm-plugins/utils/widget-positions");
29
30
  var _consts = require("./consts");
@@ -181,6 +182,8 @@ var TypeAheadControl = exports.TypeAheadControl = function TypeAheadControl(_ref
181
182
  // CHANGES - `removed editorExperiment('advanced_layouts', true) && isLayoutColumn` checks as quick insert button will not be positioned for layout column
182
183
  var calculatePosition = (0, _react.useCallback)(function () {
183
184
  var supportsAnchor = CSS.supports('top', "anchor(".concat(rootAnchorName, " start)")) && CSS.supports('left', "anchor(".concat(rootAnchorName, " start)"));
185
+ var pos = getPos();
186
+ var node = pos !== undefined ? view.state.doc.nodeAt(pos) : undefined;
184
187
  var safeAnchorName = (0, _anchorName.refreshAnchorName)({
185
188
  getPos: getPos,
186
189
  view: view,
@@ -211,7 +214,8 @@ var TypeAheadControl = exports.TypeAheadControl = function TypeAheadControl(_ref
211
214
  if (supportsAnchor) {
212
215
  return _objectSpread({
213
216
  left: isEdgeCase ? "calc(anchor(".concat(safeAnchorName, " start) + ").concat((0, _widgetPositions.getLeftPositionForRootElement)(dom, rootNodeType, _consts.QUICK_INSERT_DIMENSIONS, innerContainer, isMacroInteractionUpdates), " + -").concat(_consts.QUICK_INSERT_LEFT_OFFSET, "px)") : "calc(anchor(".concat(safeAnchorName, " start) - ").concat(_consts.QUICK_INSERT_DIMENSIONS.width, "px - ").concat((0, _consts.rootElementGap)(rootNodeType), "px + -").concat(_consts.QUICK_INSERT_LEFT_OFFSET, "px)"),
214
- top: "calc(anchor(".concat(safeAnchorName, " start) + ").concat((0, _consts.topPositionAdjustment)(rootNodeType), "px)")
217
+ // small text requires further tweaking to positioning, re-using existing methods to calculate to keep it unified with drag handle
218
+ top: "calc(anchor(".concat(safeAnchorName, " start) + ").concat((0, _consts.topPositionAdjustment)(node && node.type.name === 'paragraph' && (0, _expValEquals.expValEquals)('platform_editor_small_font_size', 'isEnabled', true) ? (0, _decorationsCommon.getNodeTypeWithLevel)(node) : rootNodeType), "px)")
215
219
  }, bottom);
216
220
  }
217
221
 
@@ -2,6 +2,8 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import ReactDOM from 'react-dom';
3
3
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
4
4
  import uuid from 'uuid';
5
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
6
+ import { isFontSizeMarkActive } from './utils/validation';
5
7
  export const TYPE_DROP_TARGET_DEC = 'drop-target-decoration';
6
8
  export const TYPE_HANDLE_DEC = 'drag-handle';
7
9
  export const TYPE_NODE_DEC = 'node-decoration';
@@ -10,8 +12,17 @@ export const getNodeAnchor = node => {
10
12
  const handleId = ObjHash.getForNode(node);
11
13
  return `--node-anchor-${node.type.name}-${handleId}`;
12
14
  };
15
+ const getSubType = node => {
16
+ if (node.attrs.level) {
17
+ return `-${node.attrs.level}`;
18
+ }
19
+ if (isFontSizeMarkActive(node)) {
20
+ return '-small';
21
+ }
22
+ return '';
23
+ };
13
24
  export const getNodeTypeWithLevel = node => {
14
- const subType = node.attrs.level ? `-${node.attrs.level}` : '';
25
+ const subType = expValEquals('platform_editor_small_font_size', 'isEnabled', true) ? getSubType(node) : node.attrs.level ? `-${node.attrs.level}` : '';
15
26
  return node.type.name + subType;
16
27
  };
17
28
  class ObjHash {
@@ -34,6 +34,16 @@ const getDefaultNodeSelector = memoizeOne(() => {
34
34
  // we don't show handler for node nested in table
35
35
  return getNodeSelector([...IGNORE_NODES_NEXT, 'media'], [...IGNORE_NODE_DESCENDANTS_ADVANCED_LAYOUT, 'table']);
36
36
  });
37
+
38
+ // Block marks (e.g. font-size) wrap paragraphs in an extra div, making parentRootElement
39
+ // the mark wrapper instead of the panel content container. When that happens, recalculate
40
+ // the index relative to the panel content so the first-child check stays accurate.
41
+ const getBlockMarkPanelIndexAdjustment = (parentRootElement, index) => {
42
+ if (expValEquals('platform_editor_small_font_size', 'isEnabled', true) && parentRootElement.classList.contains('fabric-editor-block-mark') && parentRootElement.parentElement) {
43
+ return Array.from(parentRootElement.parentElement.childNodes).indexOf(parentRootElement);
44
+ }
45
+ return index;
46
+ };
37
47
  export const handleMouseOver = (view, event, api) => {
38
48
  var _api$blockControls, _api$editorDisabled, _api$editorViewMode, _api$editorViewMode$s, _api$blockControls$sh, _api$blockControls2, _api$blockControls2$s, _target$classList;
39
49
  const {
@@ -156,10 +166,10 @@ export const handleMouseOver = (view, event, api) => {
156
166
  const childNodes = Array.from(parentRootElement.childNodes);
157
167
  const index = childNodes.indexOf(rootElement);
158
168
  pos = view.posAtDOM(parentRootElement, index);
159
-
169
+ const panelIndex = getBlockMarkPanelIndexAdjustment(parentRootElement, index);
160
170
  // We want to exlude handles showing for first element in a Panel, ignoring widgets like gapcursor
161
171
  const firstChildIsWidget = parentRootElement === null || parentRootElement === void 0 ? void 0 : (_parentRootElement$ch = parentRootElement.children[0]) === null || _parentRootElement$ch === void 0 ? void 0 : _parentRootElement$ch.classList.contains('ProseMirror-widget');
162
- if (parentElement && parentElementType === 'panel' && !parentElement.classList.contains('ak-editor-panel__no-icon') && (index === 0 || firstChildIsWidget && index === 1)) {
172
+ if (parentElement && parentElementType === 'panel' && !parentElement.classList.contains('ak-editor-panel__no-icon') && (panelIndex === 0 || firstChildIsWidget && panelIndex === 1)) {
163
173
  return false;
164
174
  }
165
175
  } else {
@@ -1,6 +1,6 @@
1
1
  import { DRAG_HANDLE_WIDTH } from '@atlaskit/editor-common/styles';
2
2
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
3
- import { DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT, DRAG_HANDLE_H1_TOP_ADJUSTMENT, DRAG_HANDLE_H2_TOP_ADJUSTMENT, DRAG_HANDLE_H4_TOP_ADJUSTMENT, DRAG_HANDLE_H5_TOP_ADJUSTMENT, DRAG_HANDLE_H6_TOP_ADJUSTMENT, DRAG_HANDLE_HEIGHT, DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT, dragHandleGap } from '../../ui/consts';
3
+ import { DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT, DRAG_HANDLE_H1_TOP_ADJUSTMENT, DRAG_HANDLE_H2_TOP_ADJUSTMENT, DRAG_HANDLE_H4_TOP_ADJUSTMENT, DRAG_HANDLE_H5_TOP_ADJUSTMENT, DRAG_HANDLE_H6_TOP_ADJUSTMENT, DRAG_HANDLE_HEIGHT, DRAG_HANDLE_PARAGRAPH_SMALL_TOP_ADJUSTMENT, DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT, dragHandleGap } from '../../ui/consts';
4
4
  const STICKY_NODES = ['panel', 'table', 'expand', 'layoutSection', 'bodiedExtension'];
5
5
  export const getTopPosition = (dom, type) => {
6
6
  if (!dom) {
@@ -26,6 +26,8 @@ export const getTopPosition = (dom, type) => {
26
26
  return `${dom.offsetTop - DRAG_HANDLE_H5_TOP_ADJUSTMENT}px`;
27
27
  } else if (type === 'heading-6') {
28
28
  return `${dom.offsetTop - DRAG_HANDLE_H6_TOP_ADJUSTMENT}px`;
29
+ } else if (type === 'paragraph-small') {
30
+ return `${dom.offsetTop + DRAG_HANDLE_PARAGRAPH_SMALL_TOP_ADJUSTMENT}px`;
29
31
  } else if (type === 'paragraph') {
30
32
  return `${dom.offsetTop + DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT}px`;
31
33
  } else {
@@ -22,6 +22,9 @@ export const isExpand = nodeType => {
22
22
  export const isNestedExpand = nodeType => {
23
23
  return nodeType === nodeType.schema.nodes.nestedExpand;
24
24
  };
25
+ export const isFontSizeMarkActive = node => {
26
+ return node.type.name === 'paragraph' && node.marks.some(mark => mark.type.name === 'fontSize');
27
+ };
25
28
  export const isInSameLayout = ($from, $to) => {
26
29
  const fromNode = $from.nodeAfter;
27
30
  const toNode = $to.nodeAfter;
@@ -19,6 +19,7 @@ export const DRAG_HANDLE_H5_TOP_ADJUSTMENT = 3;
19
19
  export const DRAG_HANDLE_H6_TOP_ADJUSTMENT = 3;
20
20
  export const DRAG_HANDLE_LAYOUT_SECTION_TOP_ADJUSTMENT = 8;
21
21
  export const DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT = 2;
22
+ export const DRAG_HANDLE_PARAGRAPH_SMALL_TOP_ADJUSTMENT = 0;
22
23
 
23
24
  /** We only want to shift-select nodes that are at the top level of a document.
24
25
  * This is because funky things happen when selecting inside of tableCells, but we
@@ -110,6 +111,8 @@ export const topPositionAdjustment = nodeType => {
110
111
  return DRAG_HANDLE_HEIGHT;
111
112
  case 'paragraph':
112
113
  return DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT;
114
+ case 'paragraph-small':
115
+ return DRAG_HANDLE_PARAGRAPH_SMALL_TOP_ADJUSTMENT;
113
116
  case 'heading-1':
114
117
  return DRAG_HANDLE_H1_TOP_ADJUSTMENT;
115
118
  case 'heading-2':
@@ -255,7 +255,7 @@ const dragHandleSelector = 'button[data-testid="block-ctrl-drag-handle"]';
255
255
  const dropTargetContainer = '.ProseMirror-widget[data-blocks-drop-target-container="true"]';
256
256
  const dividerBodiedInCustomPanelWithNoIconSelector = '[data-panel-type].ak-editor-panel__no-icon .ProseMirror-widget:first-child + .ProseMirror-widget:nth-child(2) + hr, [data-panel-type] hr:first-child';
257
257
  const withInlineNodeStyleSelectors = [`${dragHandleContainer}:has(${paragraphWithTrailingBreakAsOnlyChild}) ${dragHandleSelector}`, `${dragHandleContainer}:has(${indentatedParagraphWithTrailingBreakAsOnlyChild}) ${dragHandleSelector}`, `${dragHandleContainer}:has(${paragraphWithPlaceholder}) ${dragHandleSelector}`].join(', ');
258
- const withFormatInLayoutStyleFixSelectors = [`${dragHandleContainer}:first-child + .fabric-editor-indentation-mark > p:first-child`, `${dragHandleContainer}:first-child + .fabric-editor-alignment > p:first-child`, `${dragHandleContainer}:first-child + ${dropTargetContainer} + .fabric-editor-indentation-mark > p:first-child`, `${dragHandleContainer}:first-child + ${dropTargetContainer} + .fabric-editor-alignment > p:first-child`, `${dropTargetContainer}:first-child + .fabric-editor-alignment > p:first-child`, `${dropTargetContainer}:first-child + .fabric-editor-indentation-mark > p:first-child`, `${dragHandleContainer}:first-child + .fabric-editor-indentation-mark > :is(h1, h2, h3, h4, h5, h6):first-child`].join(', ');
258
+ const withFormatInLayoutStyleFixSelectors = [`${dragHandleContainer}:first-child + .fabric-editor-indentation-mark > p:first-child`, `${dragHandleContainer}:first-child + .fabric-editor-alignment > p:first-child`, `${dragHandleContainer}:first-child + .fabric-editor-font-size > p:first-child`, `${dragHandleContainer}:first-child + ${dropTargetContainer} + .fabric-editor-indentation-mark > p:first-child`, `${dragHandleContainer}:first-child + ${dropTargetContainer} + .fabric-editor-alignment > p:first-child`, `${dragHandleContainer}:first-child + ${dropTargetContainer} + .fabric-editor-font-size > p:first-child`, `${dropTargetContainer}:first-child + .fabric-editor-alignment > p:first-child`, `${dropTargetContainer}:first-child + .fabric-editor-indentation-mark > p:first-child`, `${dropTargetContainer}:first-child + .fabric-editor-font-size > p:first-child`, `${dragHandleContainer}:first-child + .fabric-editor-indentation-mark > :is(h1, h2, h3, h4, h5, h6):first-child`, `${dragHandleContainer}:first-child + .fabric-editor-font-size > :is(h1, h2, h3, h4, h5, h6):first-child`].join(', ');
259
259
 
260
260
  /**
261
261
  * Please do not change change transform to display:none, or visibility:hidden
@@ -293,6 +293,12 @@ const globalStyles = () => css({
293
293
  '.ProseMirror-widget:first-child + *:not([data-panel-type], .code-block, [data-node-type="nestedExpand"], [data-node-type="expand"], [data-layout-section="true"], [data-prosemirror-node-name="bodiedSyncBlock"])': {
294
294
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles -- Ignored via go/DSP-18766
295
295
  marginTop: '0 !important'
296
+ },
297
+ // Font-size wrapper is a div with no inherent margin — reach through to the content node inside.
298
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
299
+ '.ProseMirror-widget:first-child + .fabric-editor-font-size > :is(p, h1, h2, h3, h4, h5, h6):first-child, .ProseMirror-widget:first-child + .ProseMirror-widget + .fabric-editor-font-size > :is(p, h1, h2, h3, h4, h5, h6):first-child': {
300
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
301
+ marginTop: '0 !important'
296
302
  }
297
303
  });
298
304
  const quickInsertStyles = () => css({
@@ -383,6 +389,13 @@ const topLevelNodeMarginStyles = css({
383
389
  '> .ProseMirror-widget:first-child + .ProseMirror-gapcursor + *:not([data-layout-section="true"], [data-prosemirror-node-name="bodiedSyncBlock"]), > .ProseMirror-widget:first-child + *:not([data-layout-section="true"], [data-prosemirror-node-name="bodiedSyncBlock"])': {
384
390
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles -- Ignored via go/DSP-18766
385
391
  marginTop: '0 !important'
392
+ },
393
+ // When a drop target widget is inserted during drag, the font-size wrapper is no longer
394
+ // adjacent to the first widget. Reach through the wrapper to zero the inner content margin.
395
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
396
+ '> .ProseMirror-widget:first-child + .ProseMirror-widget + .fabric-editor-font-size > :is(p, h1, h2, h3, h4, h5, h6):first-child, > .ProseMirror-widget:first-child + .ProseMirror-gapcursor + .fabric-editor-font-size > :is(p, h1, h2, h3, h4, h5, h6):first-child': {
397
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
398
+ marginTop: '0 !important'
386
399
  }
387
400
  }
388
401
  });
@@ -21,6 +21,7 @@ import { fg } from '@atlaskit/platform-feature-flags';
21
21
  import { Box, Pressable, xcss } from '@atlaskit/primitives';
22
22
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
23
23
  import Tooltip from '@atlaskit/tooltip';
24
+ import { getNodeTypeWithLevel } from '../pm-plugins/decorations-common';
24
25
  import { getControlBottomCSSValue, getControlHeightCSSValue, getNodeHeight, getTopPosition, shouldBeSticky } from '../pm-plugins/utils/drag-handle-positions';
25
26
  import { getLeftPositionForRootElement } from '../pm-plugins/utils/widget-positions';
26
27
  import { QUICK_INSERT_DIMENSIONS, QUICK_INSERT_HEIGHT, QUICK_INSERT_LEFT_OFFSET, QUICK_INSERT_WIDTH, rootElementGap, STICKY_CONTROLS_TOP_MARGIN_FOR_STICKY_HEADER, topPositionAdjustment } from './consts';
@@ -170,6 +171,8 @@ export const TypeAheadControl = ({
170
171
  // CHANGES - `removed editorExperiment('advanced_layouts', true) && isLayoutColumn` checks as quick insert button will not be positioned for layout column
171
172
  const calculatePosition = useCallback(() => {
172
173
  const supportsAnchor = CSS.supports('top', `anchor(${rootAnchorName} start)`) && CSS.supports('left', `anchor(${rootAnchorName} start)`);
174
+ const pos = getPos();
175
+ const node = pos !== undefined ? view.state.doc.nodeAt(pos) : undefined;
173
176
  const safeAnchorName = refreshAnchorName({
174
177
  getPos,
175
178
  view,
@@ -200,7 +203,8 @@ export const TypeAheadControl = ({
200
203
  if (supportsAnchor) {
201
204
  return {
202
205
  left: isEdgeCase ? `calc(anchor(${safeAnchorName} start) + ${getLeftPositionForRootElement(dom, rootNodeType, QUICK_INSERT_DIMENSIONS, innerContainer, isMacroInteractionUpdates)} + -${QUICK_INSERT_LEFT_OFFSET}px)` : `calc(anchor(${safeAnchorName} start) - ${QUICK_INSERT_DIMENSIONS.width}px - ${rootElementGap(rootNodeType)}px + -${QUICK_INSERT_LEFT_OFFSET}px)`,
203
- top: `calc(anchor(${safeAnchorName} start) + ${topPositionAdjustment(rootNodeType)}px)`,
206
+ // small text requires further tweaking to positioning, re-using existing methods to calculate to keep it unified with drag handle
207
+ top: `calc(anchor(${safeAnchorName} start) + ${topPositionAdjustment(node && node.type.name === 'paragraph' && expValEquals('platform_editor_small_font_size', 'isEnabled', true) ? getNodeTypeWithLevel(node) : rootNodeType)}px)`,
204
208
  ...bottom
205
209
  };
206
210
  }
@@ -4,6 +4,8 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
4
  import ReactDOM from 'react-dom';
5
5
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
6
6
  import uuid from 'uuid';
7
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
8
+ import { isFontSizeMarkActive } from './utils/validation';
7
9
  export var TYPE_DROP_TARGET_DEC = 'drop-target-decoration';
8
10
  export var TYPE_HANDLE_DEC = 'drag-handle';
9
11
  export var TYPE_NODE_DEC = 'node-decoration';
@@ -12,8 +14,17 @@ export var getNodeAnchor = function getNodeAnchor(node) {
12
14
  var handleId = ObjHash.getForNode(node);
13
15
  return "--node-anchor-".concat(node.type.name, "-").concat(handleId);
14
16
  };
17
+ var getSubType = function getSubType(node) {
18
+ if (node.attrs.level) {
19
+ return "-".concat(node.attrs.level);
20
+ }
21
+ if (isFontSizeMarkActive(node)) {
22
+ return '-small';
23
+ }
24
+ return '';
25
+ };
15
26
  export var getNodeTypeWithLevel = function getNodeTypeWithLevel(node) {
16
- var subType = node.attrs.level ? "-".concat(node.attrs.level) : '';
27
+ var subType = expValEquals('platform_editor_small_font_size', 'isEnabled', true) ? getSubType(node) : node.attrs.level ? "-".concat(node.attrs.level) : '';
17
28
  return node.type.name + subType;
18
29
  };
19
30
  var ObjHash = /*#__PURE__*/function () {
@@ -37,6 +37,16 @@ var getDefaultNodeSelector = memoizeOne(function () {
37
37
  // we don't show handler for node nested in table
38
38
  return getNodeSelector([].concat(_toConsumableArray(IGNORE_NODES_NEXT), ['media']), [].concat(_toConsumableArray(IGNORE_NODE_DESCENDANTS_ADVANCED_LAYOUT), ['table']));
39
39
  });
40
+
41
+ // Block marks (e.g. font-size) wrap paragraphs in an extra div, making parentRootElement
42
+ // the mark wrapper instead of the panel content container. When that happens, recalculate
43
+ // the index relative to the panel content so the first-child check stays accurate.
44
+ var getBlockMarkPanelIndexAdjustment = function getBlockMarkPanelIndexAdjustment(parentRootElement, index) {
45
+ if (expValEquals('platform_editor_small_font_size', 'isEnabled', true) && parentRootElement.classList.contains('fabric-editor-block-mark') && parentRootElement.parentElement) {
46
+ return Array.from(parentRootElement.parentElement.childNodes).indexOf(parentRootElement);
47
+ }
48
+ return index;
49
+ };
40
50
  export var handleMouseOver = function handleMouseOver(view, event, api) {
41
51
  var _api$blockControls, _api$editorDisabled, _api$editorViewMode, _api$blockControls$sh, _api$blockControls2, _target$classList;
42
52
  var _ref = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
@@ -157,10 +167,10 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
157
167
  var childNodes = Array.from(parentRootElement.childNodes);
158
168
  var index = childNodes.indexOf(rootElement);
159
169
  pos = view.posAtDOM(parentRootElement, index);
160
-
170
+ var panelIndex = getBlockMarkPanelIndexAdjustment(parentRootElement, index);
161
171
  // We want to exlude handles showing for first element in a Panel, ignoring widgets like gapcursor
162
172
  var firstChildIsWidget = parentRootElement === null || parentRootElement === void 0 || (_parentRootElement$ch = parentRootElement.children[0]) === null || _parentRootElement$ch === void 0 ? void 0 : _parentRootElement$ch.classList.contains('ProseMirror-widget');
163
- if (parentElement && parentElementType === 'panel' && !parentElement.classList.contains('ak-editor-panel__no-icon') && (index === 0 || firstChildIsWidget && index === 1)) {
173
+ if (parentElement && parentElementType === 'panel' && !parentElement.classList.contains('ak-editor-panel__no-icon') && (panelIndex === 0 || firstChildIsWidget && panelIndex === 1)) {
164
174
  return false;
165
175
  }
166
176
  } else {
@@ -1,6 +1,6 @@
1
1
  import { DRAG_HANDLE_WIDTH } from '@atlaskit/editor-common/styles';
2
2
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
3
- import { DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT, DRAG_HANDLE_H1_TOP_ADJUSTMENT, DRAG_HANDLE_H2_TOP_ADJUSTMENT, DRAG_HANDLE_H4_TOP_ADJUSTMENT, DRAG_HANDLE_H5_TOP_ADJUSTMENT, DRAG_HANDLE_H6_TOP_ADJUSTMENT, DRAG_HANDLE_HEIGHT, DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT, dragHandleGap } from '../../ui/consts';
3
+ import { DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT, DRAG_HANDLE_H1_TOP_ADJUSTMENT, DRAG_HANDLE_H2_TOP_ADJUSTMENT, DRAG_HANDLE_H4_TOP_ADJUSTMENT, DRAG_HANDLE_H5_TOP_ADJUSTMENT, DRAG_HANDLE_H6_TOP_ADJUSTMENT, DRAG_HANDLE_HEIGHT, DRAG_HANDLE_PARAGRAPH_SMALL_TOP_ADJUSTMENT, DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT, dragHandleGap } from '../../ui/consts';
4
4
  var STICKY_NODES = ['panel', 'table', 'expand', 'layoutSection', 'bodiedExtension'];
5
5
  export var getTopPosition = function getTopPosition(dom, type) {
6
6
  if (!dom) {
@@ -26,6 +26,8 @@ export var getTopPosition = function getTopPosition(dom, type) {
26
26
  return "".concat(dom.offsetTop - DRAG_HANDLE_H5_TOP_ADJUSTMENT, "px");
27
27
  } else if (type === 'heading-6') {
28
28
  return "".concat(dom.offsetTop - DRAG_HANDLE_H6_TOP_ADJUSTMENT, "px");
29
+ } else if (type === 'paragraph-small') {
30
+ return "".concat(dom.offsetTop + DRAG_HANDLE_PARAGRAPH_SMALL_TOP_ADJUSTMENT, "px");
29
31
  } else if (type === 'paragraph') {
30
32
  return "".concat(dom.offsetTop + DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT, "px");
31
33
  } else {
@@ -21,6 +21,11 @@ export var isExpand = function isExpand(nodeType) {
21
21
  export var isNestedExpand = function isNestedExpand(nodeType) {
22
22
  return nodeType === nodeType.schema.nodes.nestedExpand;
23
23
  };
24
+ export var isFontSizeMarkActive = function isFontSizeMarkActive(node) {
25
+ return node.type.name === 'paragraph' && node.marks.some(function (mark) {
26
+ return mark.type.name === 'fontSize';
27
+ });
28
+ };
24
29
  export var isInSameLayout = function isInSameLayout($from, $to) {
25
30
  var fromNode = $from.nodeAfter;
26
31
  var toNode = $to.nodeAfter;
@@ -21,6 +21,7 @@ export var DRAG_HANDLE_H5_TOP_ADJUSTMENT = 3;
21
21
  export var DRAG_HANDLE_H6_TOP_ADJUSTMENT = 3;
22
22
  export var DRAG_HANDLE_LAYOUT_SECTION_TOP_ADJUSTMENT = 8;
23
23
  export var DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT = 2;
24
+ export var DRAG_HANDLE_PARAGRAPH_SMALL_TOP_ADJUSTMENT = 0;
24
25
 
25
26
  /** We only want to shift-select nodes that are at the top level of a document.
26
27
  * This is because funky things happen when selecting inside of tableCells, but we
@@ -112,6 +113,8 @@ export var topPositionAdjustment = function topPositionAdjustment(nodeType) {
112
113
  return DRAG_HANDLE_HEIGHT;
113
114
  case 'paragraph':
114
115
  return DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT;
116
+ case 'paragraph-small':
117
+ return DRAG_HANDLE_PARAGRAPH_SMALL_TOP_ADJUSTMENT;
115
118
  case 'heading-1':
116
119
  return DRAG_HANDLE_H1_TOP_ADJUSTMENT;
117
120
  case 'heading-2':
@@ -197,7 +197,7 @@ var dragHandleSelector = 'button[data-testid="block-ctrl-drag-handle"]';
197
197
  var dropTargetContainer = '.ProseMirror-widget[data-blocks-drop-target-container="true"]';
198
198
  var dividerBodiedInCustomPanelWithNoIconSelector = '[data-panel-type].ak-editor-panel__no-icon .ProseMirror-widget:first-child + .ProseMirror-widget:nth-child(2) + hr, [data-panel-type] hr:first-child';
199
199
  var withInlineNodeStyleSelectors = ["".concat(dragHandleContainer, ":has(").concat(paragraphWithTrailingBreakAsOnlyChild, ") ").concat(dragHandleSelector), "".concat(dragHandleContainer, ":has(").concat(indentatedParagraphWithTrailingBreakAsOnlyChild, ") ").concat(dragHandleSelector), "".concat(dragHandleContainer, ":has(").concat(paragraphWithPlaceholder, ") ").concat(dragHandleSelector)].join(', ');
200
- var withFormatInLayoutStyleFixSelectors = ["".concat(dragHandleContainer, ":first-child + .fabric-editor-indentation-mark > p:first-child"), "".concat(dragHandleContainer, ":first-child + .fabric-editor-alignment > p:first-child"), "".concat(dragHandleContainer, ":first-child + ").concat(dropTargetContainer, " + .fabric-editor-indentation-mark > p:first-child"), "".concat(dragHandleContainer, ":first-child + ").concat(dropTargetContainer, " + .fabric-editor-alignment > p:first-child"), "".concat(dropTargetContainer, ":first-child + .fabric-editor-alignment > p:first-child"), "".concat(dropTargetContainer, ":first-child + .fabric-editor-indentation-mark > p:first-child"), "".concat(dragHandleContainer, ":first-child + .fabric-editor-indentation-mark > :is(h1, h2, h3, h4, h5, h6):first-child")].join(', ');
200
+ var withFormatInLayoutStyleFixSelectors = ["".concat(dragHandleContainer, ":first-child + .fabric-editor-indentation-mark > p:first-child"), "".concat(dragHandleContainer, ":first-child + .fabric-editor-alignment > p:first-child"), "".concat(dragHandleContainer, ":first-child + .fabric-editor-font-size > p:first-child"), "".concat(dragHandleContainer, ":first-child + ").concat(dropTargetContainer, " + .fabric-editor-indentation-mark > p:first-child"), "".concat(dragHandleContainer, ":first-child + ").concat(dropTargetContainer, " + .fabric-editor-alignment > p:first-child"), "".concat(dragHandleContainer, ":first-child + ").concat(dropTargetContainer, " + .fabric-editor-font-size > p:first-child"), "".concat(dropTargetContainer, ":first-child + .fabric-editor-alignment > p:first-child"), "".concat(dropTargetContainer, ":first-child + .fabric-editor-indentation-mark > p:first-child"), "".concat(dropTargetContainer, ":first-child + .fabric-editor-font-size > p:first-child"), "".concat(dragHandleContainer, ":first-child + .fabric-editor-indentation-mark > :is(h1, h2, h3, h4, h5, h6):first-child"), "".concat(dragHandleContainer, ":first-child + .fabric-editor-font-size > :is(h1, h2, h3, h4, h5, h6):first-child")].join(', ');
201
201
 
202
202
  /**
203
203
  * Please do not change change transform to display:none, or visibility:hidden
@@ -233,6 +233,12 @@ var globalStyles = function globalStyles() {
233
233
  '.ProseMirror-widget:first-child + *:not([data-panel-type], .code-block, [data-node-type="nestedExpand"], [data-node-type="expand"], [data-layout-section="true"], [data-prosemirror-node-name="bodiedSyncBlock"])': {
234
234
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles -- Ignored via go/DSP-18766
235
235
  marginTop: '0 !important'
236
+ },
237
+ // Font-size wrapper is a div with no inherent margin — reach through to the content node inside.
238
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
239
+ '.ProseMirror-widget:first-child + .fabric-editor-font-size > :is(p, h1, h2, h3, h4, h5, h6):first-child, .ProseMirror-widget:first-child + .ProseMirror-widget + .fabric-editor-font-size > :is(p, h1, h2, h3, h4, h5, h6):first-child': {
240
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
241
+ marginTop: '0 !important'
236
242
  }
237
243
  });
238
244
  };
@@ -326,6 +332,13 @@ var topLevelNodeMarginStyles = css({
326
332
  '> .ProseMirror-widget:first-child + .ProseMirror-gapcursor + *:not([data-layout-section="true"], [data-prosemirror-node-name="bodiedSyncBlock"]), > .ProseMirror-widget:first-child + *:not([data-layout-section="true"], [data-prosemirror-node-name="bodiedSyncBlock"])': {
327
333
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles -- Ignored via go/DSP-18766
328
334
  marginTop: '0 !important'
335
+ },
336
+ // When a drop target widget is inserted during drag, the font-size wrapper is no longer
337
+ // adjacent to the first widget. Reach through the wrapper to zero the inner content margin.
338
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
339
+ '> .ProseMirror-widget:first-child + .ProseMirror-widget + .fabric-editor-font-size > :is(p, h1, h2, h3, h4, h5, h6):first-child, > .ProseMirror-widget:first-child + .ProseMirror-gapcursor + .fabric-editor-font-size > :is(p, h1, h2, h3, h4, h5, h6):first-child': {
340
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
341
+ marginTop: '0 !important'
329
342
  }
330
343
  }
331
344
  });
@@ -25,6 +25,7 @@ import { fg } from '@atlaskit/platform-feature-flags';
25
25
  import { Box, Pressable, xcss } from '@atlaskit/primitives';
26
26
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
27
27
  import Tooltip from '@atlaskit/tooltip';
28
+ import { getNodeTypeWithLevel } from '../pm-plugins/decorations-common';
28
29
  import { getControlBottomCSSValue, getControlHeightCSSValue, getNodeHeight, getTopPosition, shouldBeSticky } from '../pm-plugins/utils/drag-handle-positions';
29
30
  import { getLeftPositionForRootElement } from '../pm-plugins/utils/widget-positions';
30
31
  import { QUICK_INSERT_DIMENSIONS, QUICK_INSERT_HEIGHT, QUICK_INSERT_LEFT_OFFSET, QUICK_INSERT_WIDTH, rootElementGap, STICKY_CONTROLS_TOP_MARGIN_FOR_STICKY_HEADER, topPositionAdjustment } from './consts';
@@ -175,6 +176,8 @@ export var TypeAheadControl = function TypeAheadControl(_ref) {
175
176
  // CHANGES - `removed editorExperiment('advanced_layouts', true) && isLayoutColumn` checks as quick insert button will not be positioned for layout column
176
177
  var calculatePosition = useCallback(function () {
177
178
  var supportsAnchor = CSS.supports('top', "anchor(".concat(rootAnchorName, " start)")) && CSS.supports('left', "anchor(".concat(rootAnchorName, " start)"));
179
+ var pos = getPos();
180
+ var node = pos !== undefined ? view.state.doc.nodeAt(pos) : undefined;
178
181
  var safeAnchorName = refreshAnchorName({
179
182
  getPos: getPos,
180
183
  view: view,
@@ -205,7 +208,8 @@ export var TypeAheadControl = function TypeAheadControl(_ref) {
205
208
  if (supportsAnchor) {
206
209
  return _objectSpread({
207
210
  left: isEdgeCase ? "calc(anchor(".concat(safeAnchorName, " start) + ").concat(getLeftPositionForRootElement(dom, rootNodeType, QUICK_INSERT_DIMENSIONS, innerContainer, isMacroInteractionUpdates), " + -").concat(QUICK_INSERT_LEFT_OFFSET, "px)") : "calc(anchor(".concat(safeAnchorName, " start) - ").concat(QUICK_INSERT_DIMENSIONS.width, "px - ").concat(rootElementGap(rootNodeType), "px + -").concat(QUICK_INSERT_LEFT_OFFSET, "px)"),
208
- top: "calc(anchor(".concat(safeAnchorName, " start) + ").concat(topPositionAdjustment(rootNodeType), "px)")
211
+ // small text requires further tweaking to positioning, re-using existing methods to calculate to keep it unified with drag handle
212
+ top: "calc(anchor(".concat(safeAnchorName, " start) + ").concat(topPositionAdjustment(node && node.type.name === 'paragraph' && expValEquals('platform_editor_small_font_size', 'isEnabled', true) ? getNodeTypeWithLevel(node) : rootNodeType), "px)")
209
213
  }, bottom);
210
214
  }
211
215
 
@@ -6,6 +6,7 @@ export declare const isLayoutColumn: (nodeType: NodeType) => Boolean;
6
6
  export declare const isDoc: (nodeType: NodeType) => Boolean;
7
7
  export declare const isExpand: (nodeType: NodeType) => Boolean;
8
8
  export declare const isNestedExpand: (nodeType: NodeType) => Boolean;
9
+ export declare const isFontSizeMarkActive: (node: PMNode) => boolean;
9
10
  export declare const isInSameLayout: ($from: ResolvedPos, $to: ResolvedPos) => boolean;
10
11
  /**
11
12
  * This function converts an expand into a nested expand,
@@ -15,6 +15,7 @@ export declare const DRAG_HANDLE_H5_TOP_ADJUSTMENT = 3;
15
15
  export declare const DRAG_HANDLE_H6_TOP_ADJUSTMENT = 3;
16
16
  export declare const DRAG_HANDLE_LAYOUT_SECTION_TOP_ADJUSTMENT = 8;
17
17
  export declare const DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT = 2;
18
+ export declare const DRAG_HANDLE_PARAGRAPH_SMALL_TOP_ADJUSTMENT = 0;
18
19
  /** We only want to shift-select nodes that are at the top level of a document.
19
20
  * This is because funky things happen when selecting inside of tableCells, but we
20
21
  * also want to avoid heavily nested cases to descope potential corner cases.
@@ -6,6 +6,7 @@ export declare const isLayoutColumn: (nodeType: NodeType) => Boolean;
6
6
  export declare const isDoc: (nodeType: NodeType) => Boolean;
7
7
  export declare const isExpand: (nodeType: NodeType) => Boolean;
8
8
  export declare const isNestedExpand: (nodeType: NodeType) => Boolean;
9
+ export declare const isFontSizeMarkActive: (node: PMNode) => boolean;
9
10
  export declare const isInSameLayout: ($from: ResolvedPos, $to: ResolvedPos) => boolean;
10
11
  /**
11
12
  * This function converts an expand into a nested expand,
@@ -15,6 +15,7 @@ export declare const DRAG_HANDLE_H5_TOP_ADJUSTMENT = 3;
15
15
  export declare const DRAG_HANDLE_H6_TOP_ADJUSTMENT = 3;
16
16
  export declare const DRAG_HANDLE_LAYOUT_SECTION_TOP_ADJUSTMENT = 8;
17
17
  export declare const DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT = 2;
18
+ export declare const DRAG_HANDLE_PARAGRAPH_SMALL_TOP_ADJUSTMENT = 0;
18
19
  /** We only want to shift-select nodes that are at the top level of a document.
19
20
  * This is because funky things happen when selecting inside of tableCells, but we
20
21
  * also want to avoid heavily nested cases to descope potential corner cases.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "9.1.7",
3
+ "version": "9.1.9",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -41,7 +41,7 @@
41
41
  "@atlaskit/editor-plugin-quick-insert": "^8.0.0",
42
42
  "@atlaskit/editor-plugin-selection": "^8.0.0",
43
43
  "@atlaskit/editor-plugin-toolbar": "^5.1.0",
44
- "@atlaskit/editor-plugin-type-ahead": "^8.1.0",
44
+ "@atlaskit/editor-plugin-type-ahead": "^8.2.0",
45
45
  "@atlaskit/editor-plugin-user-intent": "^6.0.0",
46
46
  "@atlaskit/editor-plugin-width": "^9.0.0",
47
47
  "@atlaskit/editor-prosemirror": "^7.3.0",
@@ -56,7 +56,7 @@
56
56
  "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^3.2.0",
57
57
  "@atlaskit/primitives": "^18.1.0",
58
58
  "@atlaskit/theme": "^23.0.0",
59
- "@atlaskit/tmp-editor-statsig": "^55.2.0",
59
+ "@atlaskit/tmp-editor-statsig": "^56.2.0",
60
60
  "@atlaskit/tokens": "^12.0.0",
61
61
  "@atlaskit/tooltip": "^21.1.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": "^112.18.0",
70
+ "@atlaskit/editor-common": "^112.19.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"