@atlaskit/editor-plugin-block-controls 7.7.8 → 7.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/dist/cjs/editor-commands/move-node.js +19 -3
- package/dist/cjs/ui/global-styles.js +28 -1
- package/dist/es2019/editor-commands/move-node.js +19 -5
- package/dist/es2019/ui/global-styles.js +30 -3
- package/dist/esm/editor-commands/move-node.js +20 -4
- package/dist/esm/ui/global-styles.js +30 -3
- package/package.json +8 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 7.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`54f21810515c4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/54f21810515c4) -
|
|
8
|
+
ED-29642 use native anchor global css style instead of inline style
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
14
|
+
## 7.7.9
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [`ae4f9cd8ff5f7`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ae4f9cd8ff5f7) -
|
|
19
|
+
[ux] [EDITOR-2757] Remove breakout mark when drag and drop node in bodiedSyncBlock
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
|
|
3
22
|
## 7.7.8
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
|
@@ -18,6 +18,7 @@ var _state = require("@atlaskit/editor-prosemirror/state");
|
|
|
18
18
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
19
19
|
var _utils3 = require("@atlaskit/editor-tables/utils");
|
|
20
20
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
21
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
21
22
|
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
22
23
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
23
24
|
var _main = require("../pm-plugins/main");
|
|
@@ -313,7 +314,7 @@ var moveNode = exports.moveNode = function moveNode(api) {
|
|
|
313
314
|
var inputMethod = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _analytics.INPUT_METHOD.DRAG_AND_DROP;
|
|
314
315
|
var formatMessage = arguments.length > 3 ? arguments[3] : undefined;
|
|
315
316
|
return function (_ref7) {
|
|
316
|
-
var _api$blockControls$co, _api$accessibilityUti;
|
|
317
|
+
var _convertedNodeSlice, _api$blockControls$co, _api$accessibilityUti;
|
|
317
318
|
var tr = _ref7.tr;
|
|
318
319
|
if (!api || start < 0 || to < 0) {
|
|
319
320
|
return tr;
|
|
@@ -350,7 +351,8 @@ var moveNode = exports.moveNode = function moveNode(api) {
|
|
|
350
351
|
var $to = tr.doc.resolve(to);
|
|
351
352
|
var $handlePos = tr.doc.resolve(start);
|
|
352
353
|
var nodeCopy = tr.doc.slice(sliceFrom, sliceTo, false); // cut the content
|
|
353
|
-
var
|
|
354
|
+
var destNode = $to.node();
|
|
355
|
+
var destType = destNode.type;
|
|
354
356
|
var destParent = $to.node($to.depth);
|
|
355
357
|
var sourceNode = $handlePos.nodeAfter;
|
|
356
358
|
|
|
@@ -379,7 +381,7 @@ var moveNode = exports.moveNode = function moveNode(api) {
|
|
|
379
381
|
return tr;
|
|
380
382
|
}
|
|
381
383
|
var convertedNodeSlice = transformSourceSlice(nodeCopy, destType);
|
|
382
|
-
var convertedNode = convertedNodeSlice === null ||
|
|
384
|
+
var convertedNode = (_convertedNodeSlice = convertedNodeSlice) === null || _convertedNodeSlice === void 0 ? void 0 : _convertedNodeSlice.content;
|
|
383
385
|
if (!convertedNode) {
|
|
384
386
|
return tr;
|
|
385
387
|
}
|
|
@@ -387,6 +389,20 @@ var moveNode = exports.moveNode = function moveNode(api) {
|
|
|
387
389
|
sliceFrom = sliceFrom - 1;
|
|
388
390
|
}
|
|
389
391
|
|
|
392
|
+
// Currently we don't support breakout mark for children nodes of bodiedSyncBlock node
|
|
393
|
+
// Hence strip out the mark for now
|
|
394
|
+
if (destNode.type.name === 'bodiedSyncBlock' && (0, _expValEquals.expValEquals)('platform_synced_block', 'isEnabled', true)) {
|
|
395
|
+
var _convertedNodeSlice2;
|
|
396
|
+
var nodes = [];
|
|
397
|
+
(_convertedNodeSlice2 = convertedNodeSlice) === null || _convertedNodeSlice2 === void 0 || _convertedNodeSlice2.content.forEach(function (node) {
|
|
398
|
+
nodes.push(node.mark(node.marks.filter(function (mark) {
|
|
399
|
+
return mark.type.name !== 'breakout';
|
|
400
|
+
})));
|
|
401
|
+
});
|
|
402
|
+
convertedNodeSlice = new _model.Slice(_model.Fragment.from(nodes), 0, 0);
|
|
403
|
+
convertedNode = convertedNodeSlice.content;
|
|
404
|
+
}
|
|
405
|
+
|
|
390
406
|
// delete the content from the original position
|
|
391
407
|
tr.delete(sliceFrom, sliceTo);
|
|
392
408
|
var mappedTo = tr.mapping.map(to);
|
|
@@ -12,6 +12,7 @@ var _toolbarFlagCheck = require("@atlaskit/editor-common/toolbar-flag-check");
|
|
|
12
12
|
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
13
13
|
var _whitespace = require("@atlaskit/editor-common/whitespace");
|
|
14
14
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
15
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
16
|
var _constants = require("@atlaskit/theme/constants");
|
|
16
17
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
17
18
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
@@ -405,17 +406,43 @@ var blockCardWithoutLayout = (0, _react.css)({
|
|
|
405
406
|
'--ak-editor-block-card-width': 'max(var(--ak-editor--legacy-breakout-wide-layout-width), var(--ak-editor--line-length))'
|
|
406
407
|
}
|
|
407
408
|
});
|
|
409
|
+
var dragHandlerAnchorStyles = (0, _react.css)({
|
|
410
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
411
|
+
'.ProseMirror': {
|
|
412
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
413
|
+
'[data-testid="block-ctrl-decorator-widget"] + * [data-node-anchor]': {
|
|
414
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
415
|
+
anchorName: "var(".concat(_styles.ANCHOR_VARIABLE_NAME, ", attr(data-node-anchor type(<custom-ident>)))")
|
|
416
|
+
},
|
|
417
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
418
|
+
'[data-testid="block-ctrl-quick-insert-button"] + * [data-node-anchor]': {
|
|
419
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
420
|
+
anchorName: "var(".concat(_styles.ANCHOR_VARIABLE_NAME, ", attr(data-node-anchor type(<custom-ident>)))")
|
|
421
|
+
},
|
|
422
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
423
|
+
'[data-testid="block-ctrl-decorator-widget"] + [data-node-anchor]': {
|
|
424
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
425
|
+
anchorName: "var(".concat(_styles.ANCHOR_VARIABLE_NAME, ", attr(data-node-anchor type(<custom-ident>)))")
|
|
426
|
+
},
|
|
427
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
428
|
+
'[data-testid="block-ctrl-quick-insert-button"] + [data-node-anchor]': {
|
|
429
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
430
|
+
anchorName: "var(".concat(_styles.ANCHOR_VARIABLE_NAME, ", attr(data-node-anchor type(<custom-ident>)))")
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
});
|
|
408
434
|
var GlobalStylesWrapper = exports.GlobalStylesWrapper = function GlobalStylesWrapper(_ref) {
|
|
409
435
|
var api = _ref.api;
|
|
410
436
|
var isDragging = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockControls.isDragging', {
|
|
411
437
|
disabled: !(0, _expValEquals.expValEquals)('platform_editor_block_controls_perf_optimization', 'isEnabled', true)
|
|
412
438
|
});
|
|
439
|
+
var shouldRenderAnchors = (0, _styles.isCSSAnchorSupported)() && (0, _expValEquals.expValEquals)('platform_editor_native_anchor_support', 'isEnabled', true) && (0, _platformFeatureFlags.fg)('platform_native_anchor_use_css_style');
|
|
413
440
|
var toolbarFlagsEnabled = (0, _toolbarFlagCheck.areToolbarFlagsEnabled)(Boolean(api === null || api === void 0 ? void 0 : api.toolbar));
|
|
414
441
|
return (0, _react.jsx)(_react.Global, {
|
|
415
442
|
styles: [globalStyles(), globalDnDStyle, (0, _expValEquals.expValEquals)('platform_editor_native_anchor_support', 'isEnabled', true) ? extendedHoverZoneNext() : extendedHoverZone(), isDragging && ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_support', 'isEnabled', true) ? extendedDragZoneNext : extendedDragZone), (0, _experiments.editorExperiment)('platform_editor_preview_panel_responsiveness', true, {
|
|
416
443
|
exposure: true
|
|
417
444
|
}) ? (0, _expValEquals.expValEquals)('platform_editor_native_anchor_support', 'isEnabled', true) ? extendHoverZoneReducedNext : extendHoverZoneReduced : undefined,
|
|
418
445
|
// platform_editor_controls note: this allows drag handles to render on empty lines
|
|
419
|
-
toolbarFlagsEnabled ? undefined : withInlineNodeStyle, (0, _experiments.editorExperiment)('platform_editor_block_control_optimise_render', true) ? quickInsertStyles : undefined, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, (0, _experiments.editorExperiment)('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, (0, _expValEquals.expValEquals)('platform_editor_native_anchor_support', 'isEnabled', true) ? withRelativePosStyleNext : withRelativePosStyle, topLevelNodeMarginStyles, (0, _expValEquals.expValEquals)('platform_editor_native_anchor_support', 'isEnabled', true) ? withAnchorNameZindexStyleNext : withAnchorNameZindexStyle, (0, _expValEquals.expValEquals)('platform_editor_native_anchor_support', 'isEnabled', true) && (0, _expValEquals.expValEquals)('advanced_layouts', 'isEnabled', true) ? layoutColumnExtendedHoverZone : layoutColumnWithoutHoverZone]
|
|
446
|
+
toolbarFlagsEnabled ? undefined : withInlineNodeStyle, (0, _experiments.editorExperiment)('platform_editor_block_control_optimise_render', true) ? quickInsertStyles : undefined, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, (0, _experiments.editorExperiment)('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, (0, _expValEquals.expValEquals)('platform_editor_native_anchor_support', 'isEnabled', true) ? withRelativePosStyleNext : withRelativePosStyle, topLevelNodeMarginStyles, (0, _expValEquals.expValEquals)('platform_editor_native_anchor_support', 'isEnabled', true) ? withAnchorNameZindexStyleNext : withAnchorNameZindexStyle, (0, _expValEquals.expValEquals)('platform_editor_native_anchor_support', 'isEnabled', true) && (0, _expValEquals.expValEquals)('advanced_layouts', 'isEnabled', true) ? layoutColumnExtendedHoverZone : layoutColumnWithoutHoverZone, shouldRenderAnchors && (isDragging ? _styles.nativeAnchorStyles : dragHandlerAnchorStyles)]
|
|
420
447
|
});
|
|
421
448
|
};
|
|
@@ -5,11 +5,12 @@ import { expandSelectionBounds, GapCursorSelection } from '@atlaskit/editor-comm
|
|
|
5
5
|
import { transformSliceNestedExpandToExpand } from '@atlaskit/editor-common/transforms';
|
|
6
6
|
import { DIRECTION } from '@atlaskit/editor-common/types';
|
|
7
7
|
import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
8
|
-
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
8
|
+
import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
9
9
|
import { Selection, NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
10
10
|
import { findChildrenByType, findParentNodeOfType, findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
11
11
|
import { findTable, isInTable, isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
12
12
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
13
14
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
14
15
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
15
16
|
import { key } from '../pm-plugins/main';
|
|
@@ -315,7 +316,7 @@ export const moveNodeViaShortcut = (api, direction, formatMessage) => {
|
|
|
315
316
|
export const moveNode = api => (start, to, inputMethod = INPUT_METHOD.DRAG_AND_DROP, formatMessage) => ({
|
|
316
317
|
tr
|
|
317
318
|
}) => {
|
|
318
|
-
var _api$blockControls$co2, _api$accessibilityUti;
|
|
319
|
+
var _convertedNodeSlice, _api$blockControls$co2, _api$accessibilityUti;
|
|
319
320
|
if (!api || start < 0 || to < 0) {
|
|
320
321
|
return tr;
|
|
321
322
|
}
|
|
@@ -352,7 +353,8 @@ export const moveNode = api => (start, to, inputMethod = INPUT_METHOD.DRAG_AND_D
|
|
|
352
353
|
const $to = tr.doc.resolve(to);
|
|
353
354
|
const $handlePos = tr.doc.resolve(start);
|
|
354
355
|
const nodeCopy = tr.doc.slice(sliceFrom, sliceTo, false); // cut the content
|
|
355
|
-
const
|
|
356
|
+
const destNode = $to.node();
|
|
357
|
+
const destType = destNode.type;
|
|
356
358
|
const destParent = $to.node($to.depth);
|
|
357
359
|
const sourceNode = $handlePos.nodeAfter;
|
|
358
360
|
|
|
@@ -380,8 +382,8 @@ export const moveNode = api => (start, to, inputMethod = INPUT_METHOD.DRAG_AND_D
|
|
|
380
382
|
if (!canMoveNodeToIndex(destParent, $to.index(), $handlePos.node().child($handlePos.index()), $to)) {
|
|
381
383
|
return tr;
|
|
382
384
|
}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
+
let convertedNodeSlice = transformSourceSlice(nodeCopy, destType);
|
|
386
|
+
let convertedNode = (_convertedNodeSlice = convertedNodeSlice) === null || _convertedNodeSlice === void 0 ? void 0 : _convertedNodeSlice.content;
|
|
385
387
|
if (!convertedNode) {
|
|
386
388
|
return tr;
|
|
387
389
|
}
|
|
@@ -389,6 +391,18 @@ export const moveNode = api => (start, to, inputMethod = INPUT_METHOD.DRAG_AND_D
|
|
|
389
391
|
sliceFrom = sliceFrom - 1;
|
|
390
392
|
}
|
|
391
393
|
|
|
394
|
+
// Currently we don't support breakout mark for children nodes of bodiedSyncBlock node
|
|
395
|
+
// Hence strip out the mark for now
|
|
396
|
+
if (destNode.type.name === 'bodiedSyncBlock' && expValEquals('platform_synced_block', 'isEnabled', true)) {
|
|
397
|
+
var _convertedNodeSlice2;
|
|
398
|
+
const nodes = [];
|
|
399
|
+
(_convertedNodeSlice2 = convertedNodeSlice) === null || _convertedNodeSlice2 === void 0 ? void 0 : _convertedNodeSlice2.content.forEach(node => {
|
|
400
|
+
nodes.push(node.mark(node.marks.filter(mark => mark.type.name !== 'breakout')));
|
|
401
|
+
});
|
|
402
|
+
convertedNodeSlice = new Slice(Fragment.from(nodes), 0, 0);
|
|
403
|
+
convertedNode = convertedNodeSlice.content;
|
|
404
|
+
}
|
|
405
|
+
|
|
392
406
|
// delete the content from the original position
|
|
393
407
|
tr.delete(sliceFrom, sliceTo);
|
|
394
408
|
const mappedTo = tr.mapping.map(to);
|
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
*/
|
|
5
5
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles, @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
6
6
|
import { css, Global, jsx } from '@emotion/react';
|
|
7
|
-
import {
|
|
7
|
+
import { ANCHOR_VARIABLE_NAME, DRAG_HANDLE_WIDTH, isCSSAnchorSupported, nativeAnchorStyles, tableControlsSpacing } from '@atlaskit/editor-common/styles';
|
|
8
8
|
import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
|
|
9
9
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
10
10
|
import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/whitespace';
|
|
11
|
-
import { akEditorBreakoutPadding, akEditorCalculatedWideLayoutWidth, akEditorCalculatedWideLayoutWidthSmallViewport, akEditorGutterPaddingDynamic, akEditorGutterPaddingReduced
|
|
11
|
+
import { akEditorBreakoutPadding, akEditorCalculatedWideLayoutWidth, akEditorCalculatedWideLayoutWidthSmallViewport, akEditorFullPageNarrowBreakout, akEditorGutterPaddingDynamic, akEditorGutterPaddingReduced } from '@atlaskit/editor-shared-styles';
|
|
12
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
13
|
import { layers } from '@atlaskit/theme/constants';
|
|
13
14
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
14
15
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
@@ -483,18 +484,44 @@ const blockCardWithoutLayout = css({
|
|
|
483
484
|
'--ak-editor-block-card-width': 'max(var(--ak-editor--legacy-breakout-wide-layout-width), var(--ak-editor--line-length))'
|
|
484
485
|
}
|
|
485
486
|
});
|
|
487
|
+
const dragHandlerAnchorStyles = css({
|
|
488
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
489
|
+
'.ProseMirror': {
|
|
490
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
491
|
+
'[data-testid="block-ctrl-decorator-widget"] + * [data-node-anchor]': {
|
|
492
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
493
|
+
anchorName: `var(${ANCHOR_VARIABLE_NAME}, attr(data-node-anchor type(<custom-ident>)))`
|
|
494
|
+
},
|
|
495
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
496
|
+
'[data-testid="block-ctrl-quick-insert-button"] + * [data-node-anchor]': {
|
|
497
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
498
|
+
anchorName: `var(${ANCHOR_VARIABLE_NAME}, attr(data-node-anchor type(<custom-ident>)))`
|
|
499
|
+
},
|
|
500
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
501
|
+
'[data-testid="block-ctrl-decorator-widget"] + [data-node-anchor]': {
|
|
502
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
503
|
+
anchorName: `var(${ANCHOR_VARIABLE_NAME}, attr(data-node-anchor type(<custom-ident>)))`
|
|
504
|
+
},
|
|
505
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
506
|
+
'[data-testid="block-ctrl-quick-insert-button"] + [data-node-anchor]': {
|
|
507
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
508
|
+
anchorName: `var(${ANCHOR_VARIABLE_NAME}, attr(data-node-anchor type(<custom-ident>)))`
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
});
|
|
486
512
|
export const GlobalStylesWrapper = ({
|
|
487
513
|
api
|
|
488
514
|
}) => {
|
|
489
515
|
const isDragging = useSharedPluginStateSelector(api, 'blockControls.isDragging', {
|
|
490
516
|
disabled: !expValEquals('platform_editor_block_controls_perf_optimization', 'isEnabled', true)
|
|
491
517
|
});
|
|
518
|
+
const shouldRenderAnchors = isCSSAnchorSupported() && expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) && fg('platform_native_anchor_use_css_style');
|
|
492
519
|
const toolbarFlagsEnabled = areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar));
|
|
493
520
|
return jsx(Global, {
|
|
494
521
|
styles: [globalStyles(), globalDnDStyle, expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) ? extendedHoverZoneNext() : extendedHoverZone(), isDragging && (expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) ? extendedDragZoneNext : extendedDragZone), editorExperiment('platform_editor_preview_panel_responsiveness', true, {
|
|
495
522
|
exposure: true
|
|
496
523
|
}) ? expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) ? extendHoverZoneReducedNext : extendHoverZoneReduced : undefined,
|
|
497
524
|
// platform_editor_controls note: this allows drag handles to render on empty lines
|
|
498
|
-
toolbarFlagsEnabled ? undefined : withInlineNodeStyle, editorExperiment('platform_editor_block_control_optimise_render', true) ? quickInsertStyles : undefined, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) ? withRelativePosStyleNext : withRelativePosStyle, topLevelNodeMarginStyles, expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) ? withAnchorNameZindexStyleNext : withAnchorNameZindexStyle, expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) && expValEquals('advanced_layouts', 'isEnabled', true) ? layoutColumnExtendedHoverZone : layoutColumnWithoutHoverZone]
|
|
525
|
+
toolbarFlagsEnabled ? undefined : withInlineNodeStyle, editorExperiment('platform_editor_block_control_optimise_render', true) ? quickInsertStyles : undefined, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) ? withRelativePosStyleNext : withRelativePosStyle, topLevelNodeMarginStyles, expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) ? withAnchorNameZindexStyleNext : withAnchorNameZindexStyle, expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) && expValEquals('advanced_layouts', 'isEnabled', true) ? layoutColumnExtendedHoverZone : layoutColumnWithoutHoverZone, shouldRenderAnchors && (isDragging ? nativeAnchorStyles : dragHandlerAnchorStyles)]
|
|
499
526
|
});
|
|
500
527
|
};
|
|
@@ -8,11 +8,12 @@ import { expandSelectionBounds, GapCursorSelection } from '@atlaskit/editor-comm
|
|
|
8
8
|
import { transformSliceNestedExpandToExpand } from '@atlaskit/editor-common/transforms';
|
|
9
9
|
import { DIRECTION } from '@atlaskit/editor-common/types';
|
|
10
10
|
import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
11
|
-
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
11
|
+
import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
12
12
|
import { Selection, NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
13
13
|
import { findChildrenByType, findParentNodeOfType, findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
14
14
|
import { findTable, isInTable, isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
15
15
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
16
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
16
17
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
17
18
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
18
19
|
import { key } from '../pm-plugins/main';
|
|
@@ -307,7 +308,7 @@ export var moveNode = function moveNode(api) {
|
|
|
307
308
|
var inputMethod = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : INPUT_METHOD.DRAG_AND_DROP;
|
|
308
309
|
var formatMessage = arguments.length > 3 ? arguments[3] : undefined;
|
|
309
310
|
return function (_ref7) {
|
|
310
|
-
var _api$blockControls$co, _api$accessibilityUti;
|
|
311
|
+
var _convertedNodeSlice, _api$blockControls$co, _api$accessibilityUti;
|
|
311
312
|
var tr = _ref7.tr;
|
|
312
313
|
if (!api || start < 0 || to < 0) {
|
|
313
314
|
return tr;
|
|
@@ -344,7 +345,8 @@ export var moveNode = function moveNode(api) {
|
|
|
344
345
|
var $to = tr.doc.resolve(to);
|
|
345
346
|
var $handlePos = tr.doc.resolve(start);
|
|
346
347
|
var nodeCopy = tr.doc.slice(sliceFrom, sliceTo, false); // cut the content
|
|
347
|
-
var
|
|
348
|
+
var destNode = $to.node();
|
|
349
|
+
var destType = destNode.type;
|
|
348
350
|
var destParent = $to.node($to.depth);
|
|
349
351
|
var sourceNode = $handlePos.nodeAfter;
|
|
350
352
|
|
|
@@ -373,7 +375,7 @@ export var moveNode = function moveNode(api) {
|
|
|
373
375
|
return tr;
|
|
374
376
|
}
|
|
375
377
|
var convertedNodeSlice = transformSourceSlice(nodeCopy, destType);
|
|
376
|
-
var convertedNode = convertedNodeSlice === null ||
|
|
378
|
+
var convertedNode = (_convertedNodeSlice = convertedNodeSlice) === null || _convertedNodeSlice === void 0 ? void 0 : _convertedNodeSlice.content;
|
|
377
379
|
if (!convertedNode) {
|
|
378
380
|
return tr;
|
|
379
381
|
}
|
|
@@ -381,6 +383,20 @@ export var moveNode = function moveNode(api) {
|
|
|
381
383
|
sliceFrom = sliceFrom - 1;
|
|
382
384
|
}
|
|
383
385
|
|
|
386
|
+
// Currently we don't support breakout mark for children nodes of bodiedSyncBlock node
|
|
387
|
+
// Hence strip out the mark for now
|
|
388
|
+
if (destNode.type.name === 'bodiedSyncBlock' && expValEquals('platform_synced_block', 'isEnabled', true)) {
|
|
389
|
+
var _convertedNodeSlice2;
|
|
390
|
+
var nodes = [];
|
|
391
|
+
(_convertedNodeSlice2 = convertedNodeSlice) === null || _convertedNodeSlice2 === void 0 || _convertedNodeSlice2.content.forEach(function (node) {
|
|
392
|
+
nodes.push(node.mark(node.marks.filter(function (mark) {
|
|
393
|
+
return mark.type.name !== 'breakout';
|
|
394
|
+
})));
|
|
395
|
+
});
|
|
396
|
+
convertedNodeSlice = new Slice(Fragment.from(nodes), 0, 0);
|
|
397
|
+
convertedNode = convertedNodeSlice.content;
|
|
398
|
+
}
|
|
399
|
+
|
|
384
400
|
// delete the content from the original position
|
|
385
401
|
tr.delete(sliceFrom, sliceTo);
|
|
386
402
|
var mappedTo = tr.mapping.map(to);
|
|
@@ -5,11 +5,12 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
5
5
|
*/
|
|
6
6
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles, @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
7
7
|
import { css, Global, jsx } from '@emotion/react';
|
|
8
|
-
import {
|
|
8
|
+
import { ANCHOR_VARIABLE_NAME, DRAG_HANDLE_WIDTH, isCSSAnchorSupported, nativeAnchorStyles, tableControlsSpacing } from '@atlaskit/editor-common/styles';
|
|
9
9
|
import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
|
|
10
10
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
11
11
|
import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/whitespace';
|
|
12
|
-
import { akEditorBreakoutPadding, akEditorCalculatedWideLayoutWidth, akEditorCalculatedWideLayoutWidthSmallViewport, akEditorGutterPaddingDynamic, akEditorGutterPaddingReduced
|
|
12
|
+
import { akEditorBreakoutPadding, akEditorCalculatedWideLayoutWidth, akEditorCalculatedWideLayoutWidthSmallViewport, akEditorFullPageNarrowBreakout, akEditorGutterPaddingDynamic, akEditorGutterPaddingReduced } from '@atlaskit/editor-shared-styles';
|
|
13
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
14
|
import { layers } from '@atlaskit/theme/constants';
|
|
14
15
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
15
16
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
@@ -398,17 +399,43 @@ var blockCardWithoutLayout = css({
|
|
|
398
399
|
'--ak-editor-block-card-width': 'max(var(--ak-editor--legacy-breakout-wide-layout-width), var(--ak-editor--line-length))'
|
|
399
400
|
}
|
|
400
401
|
});
|
|
402
|
+
var dragHandlerAnchorStyles = css({
|
|
403
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
404
|
+
'.ProseMirror': {
|
|
405
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
406
|
+
'[data-testid="block-ctrl-decorator-widget"] + * [data-node-anchor]': {
|
|
407
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
408
|
+
anchorName: "var(".concat(ANCHOR_VARIABLE_NAME, ", attr(data-node-anchor type(<custom-ident>)))")
|
|
409
|
+
},
|
|
410
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
411
|
+
'[data-testid="block-ctrl-quick-insert-button"] + * [data-node-anchor]': {
|
|
412
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
413
|
+
anchorName: "var(".concat(ANCHOR_VARIABLE_NAME, ", attr(data-node-anchor type(<custom-ident>)))")
|
|
414
|
+
},
|
|
415
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
416
|
+
'[data-testid="block-ctrl-decorator-widget"] + [data-node-anchor]': {
|
|
417
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
418
|
+
anchorName: "var(".concat(ANCHOR_VARIABLE_NAME, ", attr(data-node-anchor type(<custom-ident>)))")
|
|
419
|
+
},
|
|
420
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
421
|
+
'[data-testid="block-ctrl-quick-insert-button"] + [data-node-anchor]': {
|
|
422
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
423
|
+
anchorName: "var(".concat(ANCHOR_VARIABLE_NAME, ", attr(data-node-anchor type(<custom-ident>)))")
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
});
|
|
401
427
|
export var GlobalStylesWrapper = function GlobalStylesWrapper(_ref) {
|
|
402
428
|
var api = _ref.api;
|
|
403
429
|
var isDragging = useSharedPluginStateSelector(api, 'blockControls.isDragging', {
|
|
404
430
|
disabled: !expValEquals('platform_editor_block_controls_perf_optimization', 'isEnabled', true)
|
|
405
431
|
});
|
|
432
|
+
var shouldRenderAnchors = isCSSAnchorSupported() && expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) && fg('platform_native_anchor_use_css_style');
|
|
406
433
|
var toolbarFlagsEnabled = areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar));
|
|
407
434
|
return jsx(Global, {
|
|
408
435
|
styles: [globalStyles(), globalDnDStyle, expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) ? extendedHoverZoneNext() : extendedHoverZone(), isDragging && (expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) ? extendedDragZoneNext : extendedDragZone), editorExperiment('platform_editor_preview_panel_responsiveness', true, {
|
|
409
436
|
exposure: true
|
|
410
437
|
}) ? expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) ? extendHoverZoneReducedNext : extendHoverZoneReduced : undefined,
|
|
411
438
|
// platform_editor_controls note: this allows drag handles to render on empty lines
|
|
412
|
-
toolbarFlagsEnabled ? undefined : withInlineNodeStyle, editorExperiment('platform_editor_block_control_optimise_render', true) ? quickInsertStyles : undefined, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) ? withRelativePosStyleNext : withRelativePosStyle, topLevelNodeMarginStyles, expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) ? withAnchorNameZindexStyleNext : withAnchorNameZindexStyle, expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) && expValEquals('advanced_layouts', 'isEnabled', true) ? layoutColumnExtendedHoverZone : layoutColumnWithoutHoverZone]
|
|
439
|
+
toolbarFlagsEnabled ? undefined : withInlineNodeStyle, editorExperiment('platform_editor_block_control_optimise_render', true) ? quickInsertStyles : undefined, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) ? withRelativePosStyleNext : withRelativePosStyle, topLevelNodeMarginStyles, expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) ? withAnchorNameZindexStyleNext : withAnchorNameZindexStyle, expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) && expValEquals('advanced_layouts', 'isEnabled', true) ? layoutColumnExtendedHoverZone : layoutColumnWithoutHoverZone, shouldRenderAnchors && (isDragging ? nativeAnchorStyles : dragHandlerAnchorStyles)]
|
|
413
440
|
});
|
|
414
441
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.8.0",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -52,10 +52,10 @@
|
|
|
52
52
|
"@atlaskit/pragmatic-drag-and-drop": "^1.7.0",
|
|
53
53
|
"@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^2.1.0",
|
|
54
54
|
"@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^3.2.0",
|
|
55
|
-
"@atlaskit/primitives": "^16.
|
|
55
|
+
"@atlaskit/primitives": "^16.4.0",
|
|
56
56
|
"@atlaskit/theme": "^21.0.0",
|
|
57
|
-
"@atlaskit/tmp-editor-statsig": "^13.
|
|
58
|
-
"@atlaskit/tokens": "^8.
|
|
57
|
+
"@atlaskit/tmp-editor-statsig": "^13.43.0",
|
|
58
|
+
"@atlaskit/tokens": "^8.3.0",
|
|
59
59
|
"@atlaskit/tooltip": "^20.10.0",
|
|
60
60
|
"@babel/runtime": "^7.0.0",
|
|
61
61
|
"@emotion/react": "^11.7.1",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"uuid": "^3.1.0"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"@atlaskit/editor-common": "^110.
|
|
69
|
+
"@atlaskit/editor-common": "^110.35.0",
|
|
70
70
|
"react": "^18.2.0",
|
|
71
71
|
"react-dom": "^18.2.0",
|
|
72
72
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
@@ -143,6 +143,9 @@
|
|
|
143
143
|
"dst-a11y__replace-anchor-with-link__editor-jenga": {
|
|
144
144
|
"type": "boolean"
|
|
145
145
|
},
|
|
146
|
+
"platform_native_anchor_use_css_style": {
|
|
147
|
+
"type": "boolean"
|
|
148
|
+
},
|
|
146
149
|
"editor_native_anchor_remove_decoration_in_apply": {
|
|
147
150
|
"type": "boolean"
|
|
148
151
|
},
|