@atlaskit/editor-plugin-block-controls 2.16.3 → 2.17.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 +26 -0
- package/dist/cjs/editor-commands/move-node.js +1 -1
- package/dist/cjs/editor-commands/move-to-layout.js +2 -2
- package/dist/cjs/pm-plugins/decorations-anchor.js +1 -3
- package/dist/cjs/pm-plugins/handle-mouse-over.js +5 -1
- package/dist/cjs/pm-plugins/main.js +27 -4
- package/dist/cjs/pm-plugins/utils/fire-analytics.js +2 -2
- package/dist/cjs/pm-plugins/utils/remove-from-source.js +20 -0
- package/dist/cjs/ui/global-styles.js +1 -1
- package/dist/es2019/editor-commands/move-node.js +2 -2
- package/dist/es2019/editor-commands/move-to-layout.js +3 -3
- package/dist/es2019/pm-plugins/decorations-anchor.js +1 -3
- package/dist/es2019/pm-plugins/handle-mouse-over.js +5 -1
- package/dist/es2019/pm-plugins/main.js +29 -4
- package/dist/es2019/pm-plugins/utils/fire-analytics.js +1 -1
- package/dist/es2019/pm-plugins/utils/remove-from-source.js +20 -0
- package/dist/es2019/ui/global-styles.js +1 -1
- package/dist/esm/editor-commands/move-node.js +2 -2
- package/dist/esm/editor-commands/move-to-layout.js +3 -3
- package/dist/esm/pm-plugins/decorations-anchor.js +1 -3
- package/dist/esm/pm-plugins/handle-mouse-over.js +5 -1
- package/dist/esm/pm-plugins/main.js +27 -4
- package/dist/esm/pm-plugins/utils/fire-analytics.js +1 -1
- package/dist/esm/pm-plugins/utils/remove-from-source.js +20 -0
- package/dist/esm/ui/global-styles.js +1 -1
- package/dist/types/pm-plugins/utils/fire-analytics.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/utils/fire-analytics.d.ts +1 -1
- package/package.json +10 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 2.17.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#100498](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/100498)
|
|
8
|
+
[`b913a28923b5d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b913a28923b5d) -
|
|
9
|
+
ED-25931 Remove a 2 column layout via drag and drop
|
|
10
|
+
- [#100935](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/100935)
|
|
11
|
+
[`44dcbb7e1884c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/44dcbb7e1884c) -
|
|
12
|
+
clean up platform_editor_element_dnd_nested_fix_patch_1 feature gate
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
18
|
+
## 2.16.4
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- [#97978](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/97978)
|
|
23
|
+
[`ea88bd7273c73`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ea88bd7273c73) -
|
|
24
|
+
Added Blocks Drag Init measurement analytics event
|
|
25
|
+
- [#99482](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/99482)
|
|
26
|
+
[`5fdd98e19255d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5fdd98e19255d) -
|
|
27
|
+
ED-26122 disable drag layout column for single column layout
|
|
28
|
+
|
|
3
29
|
## 2.16.3
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
|
@@ -222,7 +222,7 @@ var moveNode = exports.moveNode = function moveNode(api) {
|
|
|
222
222
|
api === null || api === void 0 || api.core.actions.focus();
|
|
223
223
|
var $mappedTo = tr.doc.resolve(mappedTo);
|
|
224
224
|
if ((0, _experiments.editorExperiment)('advanced_layouts', true)) {
|
|
225
|
-
(0, _fireAnalytics.
|
|
225
|
+
(0, _fireAnalytics.attachMoveNodeAnalytics)(tr, inputMethod, resolvedNode.depth, node.type.name, $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.depth, $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.parent.type.name, $from.sameParent($mappedTo), api);
|
|
226
226
|
} else {
|
|
227
227
|
var _api$analytics;
|
|
228
228
|
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
|
|
@@ -52,7 +52,7 @@ var moveToExistingLayout = function moveToExistingLayout(toLayout, toLayoutPos,
|
|
|
52
52
|
if (!(0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
53
53
|
tr.setSelection(new _state.NodeSelection(tr.doc.resolve(mappedTo))).scrollIntoView();
|
|
54
54
|
}
|
|
55
|
-
(0, _fireAnalytics.
|
|
55
|
+
(0, _fireAnalytics.attachMoveNodeAnalytics)(tr, _analytics.INPUT_METHOD.DRAG_AND_DROP, $originalFrom.depth, ((_$originalFrom$nodeAf = $originalFrom.nodeAfter) === null || _$originalFrom$nodeAf === void 0 ? void 0 : _$originalFrom$nodeAf.type.name) || '', 1, 'layoutSection', true, api);
|
|
56
56
|
} else if (toLayout.childCount < (0, _consts.maxLayoutColumnSupported)()) {
|
|
57
57
|
var _$originalFrom$nodeAf2;
|
|
58
58
|
if ((0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
@@ -63,7 +63,7 @@ var moveToExistingLayout = function moveToExistingLayout(toLayout, toLayoutPos,
|
|
|
63
63
|
var mappedFrom = tr.mapping.map(from);
|
|
64
64
|
(0, _removeFromSource.removeFromSource)(tr, tr.doc.resolve(mappedFrom));
|
|
65
65
|
}
|
|
66
|
-
(0, _fireAnalytics.
|
|
66
|
+
(0, _fireAnalytics.attachMoveNodeAnalytics)(tr, _analytics.INPUT_METHOD.DRAG_AND_DROP, $originalFrom.depth, ((_$originalFrom$nodeAf2 = $originalFrom.nodeAfter) === null || _$originalFrom$nodeAf2 === void 0 ? void 0 : _$originalFrom$nodeAf2.type.name) || '', 1, 'layoutSection', false, api);
|
|
67
67
|
}
|
|
68
68
|
return tr;
|
|
69
69
|
};
|
|
@@ -32,9 +32,7 @@ var shouldIgnoreNode = function shouldIgnoreNode(node, ignore_nodes, depth, pare
|
|
|
32
32
|
// eslint-disable-next-line @typescript-eslint/max-params
|
|
33
33
|
) {
|
|
34
34
|
var isEmbedCard = 'embedCard' === node.type.name && (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_3');
|
|
35
|
-
|
|
36
|
-
// TODO use isWrappedMedia when clean up the feature flag
|
|
37
|
-
var isMediaSingle = 'mediaSingle' === node.type.name && (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_1');
|
|
35
|
+
var isMediaSingle = node.type.name === 'mediaSingle';
|
|
38
36
|
var isFirstTableRow = (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'table' && depth === 1 && node === parent.firstChild && 'tableRow' === node.type.name && (0, _experiments.editorExperiment)('advanced_layouts', true);
|
|
39
37
|
if (isFirstTableRow) {
|
|
40
38
|
return false;
|
|
@@ -86,12 +86,16 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
|
|
|
86
86
|
|
|
87
87
|
// We want to exlude handles showing for first element in a Panel, ignoring widgets like gapcursor
|
|
88
88
|
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');
|
|
89
|
-
if (parentElement && parentElementType === 'panel' &&
|
|
89
|
+
if (parentElement && parentElementType === 'panel' && !parentElement.classList.contains('ak-editor-panel__no-icon') && (index === 0 || firstChildIsWidget && index === 1)) {
|
|
90
90
|
return false;
|
|
91
91
|
}
|
|
92
92
|
} else {
|
|
93
93
|
pos = view.posAtDOM(rootElement, 0);
|
|
94
94
|
}
|
|
95
|
+
if (parentRootElement && parentRootElement.getAttribute('data-layout-section') === 'true' && parentRootElement.querySelectorAll('[data-layout-column]').length === 1 && (0, _experiments.editorExperiment)('advanced_layouts', true) && (0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_3')) {
|
|
96
|
+
// Don't show drag handle for layout column in a single column layout
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
95
99
|
var rootPos;
|
|
96
100
|
if ((0, _experiments.editorExperiment)('nested-dnd', true)) {
|
|
97
101
|
rootPos = view.state.doc.resolve(pos).pos;
|
|
@@ -10,6 +10,7 @@ var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
|
10
10
|
var _steps = require("@atlaskit/adf-schema/steps");
|
|
11
11
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
12
12
|
var _browser = require("@atlaskit/editor-common/browser");
|
|
13
|
+
var _performanceMeasures = require("@atlaskit/editor-common/performance-measures");
|
|
13
14
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
14
15
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
15
16
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
@@ -29,10 +30,11 @@ var _anchorUtils = require("./utils/anchor-utils");
|
|
|
29
30
|
var _dragTargetDebug = require("./utils/drag-target-debug");
|
|
30
31
|
var _transactions = require("./utils/transactions");
|
|
31
32
|
var key = exports.key = new _state.PluginKey('blockControls');
|
|
33
|
+
var EDITOR_BLOCKS_DRAG_INIT = 'Editor Blocks Drag Initialization Time';
|
|
32
34
|
var isHTMLElement = function isHTMLElement(element) {
|
|
33
35
|
return element instanceof HTMLElement;
|
|
34
36
|
};
|
|
35
|
-
var destroyFn = function destroyFn(api) {
|
|
37
|
+
var destroyFn = function destroyFn(api, editorView) {
|
|
36
38
|
var scrollable = document.querySelector('.fabric-editor-popup-scroll-parent');
|
|
37
39
|
var cleanupFn = [];
|
|
38
40
|
if (scrollable) {
|
|
@@ -45,6 +47,24 @@ var destroyFn = function destroyFn(api) {
|
|
|
45
47
|
var source = _ref.source;
|
|
46
48
|
return source.data.type === 'element';
|
|
47
49
|
},
|
|
50
|
+
onDrag: function onDrag() {
|
|
51
|
+
if ((0, _performanceMeasures.isMeasuring)(EDITOR_BLOCKS_DRAG_INIT) && (0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_3')) {
|
|
52
|
+
(0, _performanceMeasures.stopMeasure)(EDITOR_BLOCKS_DRAG_INIT, function (duration, startTime) {
|
|
53
|
+
var _api$analytics;
|
|
54
|
+
var state = editorView.state;
|
|
55
|
+
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.fireAnalyticsEvent({
|
|
56
|
+
action: _analytics.ACTION.BLOCKS_DRAG_INIT,
|
|
57
|
+
actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
|
|
58
|
+
eventType: _analytics.EVENT_TYPE.OPERATIONAL,
|
|
59
|
+
attributes: {
|
|
60
|
+
duration: duration,
|
|
61
|
+
startTime: startTime,
|
|
62
|
+
nodesCount: state.doc.nodeSize
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
},
|
|
48
68
|
onDragStart: function onDragStart() {
|
|
49
69
|
if (isHTMLElement(scrollable)) {
|
|
50
70
|
scrollable.style.setProperty('scroll-behavior', 'unset');
|
|
@@ -63,10 +83,10 @@ var destroyFn = function destroyFn(api) {
|
|
|
63
83
|
start = _ref4.start;
|
|
64
84
|
// if no drop targets are rendered, assume that drop is invalid
|
|
65
85
|
if (location.current.dropTargets.length === 0) {
|
|
66
|
-
var _api$
|
|
86
|
+
var _api$analytics2;
|
|
67
87
|
var resolvedMovingNode = tr.doc.resolve(start);
|
|
68
88
|
var maybeNode = resolvedMovingNode.nodeAfter;
|
|
69
|
-
api === null || api === void 0 || (_api$
|
|
89
|
+
api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || _api$analytics2.actions.attachAnalyticsEvent({
|
|
70
90
|
eventType: _analytics.EVENT_TYPE.UI,
|
|
71
91
|
action: _analytics.ACTION.CANCELLED,
|
|
72
92
|
actionSubject: _analytics.ACTION_SUBJECT.DRAG,
|
|
@@ -524,6 +544,9 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
|
|
|
524
544
|
},
|
|
525
545
|
dragstart: function dragstart(view) {
|
|
526
546
|
var _anchorRectCache;
|
|
547
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_3')) {
|
|
548
|
+
(0, _performanceMeasures.startMeasure)(EDITOR_BLOCKS_DRAG_INIT);
|
|
549
|
+
}
|
|
527
550
|
if (isAdvancedLayoutEnabled) {
|
|
528
551
|
_activeAnchorTracker.defaultActiveAnchorTracker.reset();
|
|
529
552
|
}
|
|
@@ -605,7 +628,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
|
|
|
605
628
|
}
|
|
606
629
|
|
|
607
630
|
// Start pragmatic monitors
|
|
608
|
-
var pragmaticCleanup = destroyFn(api);
|
|
631
|
+
var pragmaticCleanup = destroyFn(api, editorView);
|
|
609
632
|
return {
|
|
610
633
|
destroy: function destroy() {
|
|
611
634
|
if (editorContentArea) {
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.fireInsertLayoutAnalytics = exports.attachMoveNodeAnalytics = void 0;
|
|
7
7
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
8
|
-
var
|
|
8
|
+
var attachMoveNodeAnalytics = exports.attachMoveNodeAnalytics = function attachMoveNodeAnalytics(tr, inputMethod, fromDepth, fromNodeType, toDepth, toNodeType, isSameParent, api
|
|
9
9
|
// Ignored via go/ees005
|
|
10
10
|
// eslint-disable-next-line @typescript-eslint/max-params
|
|
11
11
|
) {
|
|
@@ -4,6 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.removeFromSource = void 0;
|
|
7
|
+
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
8
|
+
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
9
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
7
10
|
var _consts = require("./consts");
|
|
8
11
|
var _updateColumnWidths = require("./update-column-widths");
|
|
9
12
|
var removeFromSource = exports.removeFromSource = function removeFromSource(tr, $from) {
|
|
@@ -16,6 +19,23 @@ var removeFromSource = exports.removeFromSource = function removeFromSource(tr,
|
|
|
16
19
|
if (sourceNode.type.name === 'layoutColumn') {
|
|
17
20
|
if (sourceParent.childCount === _consts.MIN_LAYOUT_COLUMN) {
|
|
18
21
|
tr.delete($from.pos + 1, sourceNodeEndPos - 1);
|
|
22
|
+
|
|
23
|
+
// Currently, we assume that the MIN_LAYOUT_COLUMN is set to 2.
|
|
24
|
+
// This value may require an update when we introduce support for a single-column layout.
|
|
25
|
+
if (sourceParent.childCount === 2 && (0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_DnD_remove_layout')) {
|
|
26
|
+
var _$from$parent$lastChi, _$from$parent$firstCh;
|
|
27
|
+
var layoutContentFragment = $from.parentOffset === 0 ? _model.Fragment.from((_$from$parent$lastChi = $from.parent.lastChild) === null || _$from$parent$lastChi === void 0 ? void 0 : _$from$parent$lastChi.content) : _model.Fragment.from((_$from$parent$firstCh = $from.parent.firstChild) === null || _$from$parent$firstCh === void 0 ? void 0 : _$from$parent$firstCh.content);
|
|
28
|
+
var parent = (0, _utils.findParentNodeClosestToPos)($from, function (node) {
|
|
29
|
+
return node.type.name === 'layoutSection';
|
|
30
|
+
});
|
|
31
|
+
if (parent && layoutContentFragment) {
|
|
32
|
+
var _tr$doc$resolve$nodeA;
|
|
33
|
+
var layoutSectionPos = tr.mapping.map(parent.pos);
|
|
34
|
+
// get the updated layout node size
|
|
35
|
+
var layoutSectionNodeSize = ((_tr$doc$resolve$nodeA = tr.doc.resolve(layoutSectionPos).nodeAfter) === null || _tr$doc$resolve$nodeA === void 0 ? void 0 : _tr$doc$resolve$nodeA.nodeSize) || 0;
|
|
36
|
+
tr.replaceWith(layoutSectionPos, layoutSectionPos + layoutSectionNodeSize, layoutContentFragment);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
19
39
|
return tr;
|
|
20
40
|
} else {
|
|
21
41
|
(0, _updateColumnWidths.updateColumnWidths)(tr, $from.parent, $from.before($from.depth), sourceParent.childCount - 1);
|
|
@@ -230,6 +230,6 @@ var blockCardWithoutLayout = (0, _react.css)({
|
|
|
230
230
|
});
|
|
231
231
|
var GlobalStylesWrapper = exports.GlobalStylesWrapper = function GlobalStylesWrapper() {
|
|
232
232
|
return (0, _react.jsx)(_react.Global, {
|
|
233
|
-
styles: [globalStyles(), (0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_1') && globalDnDStyle, (0, _experiments.editorExperiment)('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), getTextNodeStyle(), withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, (0, _experiments.editorExperiment)('advanced_layouts', true) ? blockCardWithoutLayout : undefined,
|
|
233
|
+
styles: [globalStyles(), (0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_1') && globalDnDStyle, (0, _experiments.editorExperiment)('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), getTextNodeStyle(), withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, (0, _experiments.editorExperiment)('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_2') ? withFormatInLayoutStyleFix : undefined, (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_3') ? [withRelativePosStyle, topLevelNodeMarginStyles, (0, _experiments.editorExperiment)('nested-dnd', true) ? withAnchorNameZindexNestedStyle : withAnchorNameZindexStyle] : undefined]
|
|
234
234
|
});
|
|
235
235
|
};
|
|
@@ -11,7 +11,7 @@ import { fg } from '@atlaskit/platform-feature-flags';
|
|
|
11
11
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
12
12
|
import { key } from '../pm-plugins/main';
|
|
13
13
|
import { DIRECTION } from '../pm-plugins/utils/consts';
|
|
14
|
-
import {
|
|
14
|
+
import { attachMoveNodeAnalytics } from '../pm-plugins/utils/fire-analytics';
|
|
15
15
|
import { getNestedNodePosition } from '../pm-plugins/utils/getNestedNodePosition';
|
|
16
16
|
import { selectNode, setCursorPositionAtMovedNode } from '../pm-plugins/utils/getSelection';
|
|
17
17
|
import { removeFromSource } from '../pm-plugins/utils/remove-from-source';
|
|
@@ -216,7 +216,7 @@ export const moveNode = api => (start, to, inputMethod = INPUT_METHOD.DRAG_AND_D
|
|
|
216
216
|
api === null || api === void 0 ? void 0 : api.core.actions.focus();
|
|
217
217
|
const $mappedTo = tr.doc.resolve(mappedTo);
|
|
218
218
|
if (editorExperiment('advanced_layouts', true)) {
|
|
219
|
-
|
|
219
|
+
attachMoveNodeAnalytics(tr, inputMethod, resolvedNode.depth, node.type.name, $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.depth, $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.parent.type.name, $from.sameParent($mappedTo), api);
|
|
220
220
|
} else {
|
|
221
221
|
var _api$analytics;
|
|
222
222
|
api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.attachAnalyticsEvent({
|
|
@@ -3,7 +3,7 @@ import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
|
3
3
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
5
|
import { maxLayoutColumnSupported } from '../pm-plugins/utils/consts';
|
|
6
|
-
import { fireInsertLayoutAnalytics,
|
|
6
|
+
import { fireInsertLayoutAnalytics, attachMoveNodeAnalytics } from '../pm-plugins/utils/fire-analytics';
|
|
7
7
|
import { removeFromSource } from '../pm-plugins/utils/remove-from-source';
|
|
8
8
|
import { updateColumnWidths } from '../pm-plugins/utils/update-column-widths';
|
|
9
9
|
import { isInSameLayout } from '../pm-plugins/utils/validation';
|
|
@@ -47,7 +47,7 @@ const moveToExistingLayout = (toLayout, toLayoutPos, sourceNode, from, to, tr, $
|
|
|
47
47
|
if (!fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
48
48
|
tr.setSelection(new NodeSelection(tr.doc.resolve(mappedTo))).scrollIntoView();
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
attachMoveNodeAnalytics(tr, INPUT_METHOD.DRAG_AND_DROP, $originalFrom.depth, ((_$originalFrom$nodeAf = $originalFrom.nodeAfter) === null || _$originalFrom$nodeAf === void 0 ? void 0 : _$originalFrom$nodeAf.type.name) || '', 1, 'layoutSection', true, api);
|
|
51
51
|
} else if (toLayout.childCount < maxLayoutColumnSupported()) {
|
|
52
52
|
var _$originalFrom$nodeAf2;
|
|
53
53
|
if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
@@ -58,7 +58,7 @@ const moveToExistingLayout = (toLayout, toLayoutPos, sourceNode, from, to, tr, $
|
|
|
58
58
|
const mappedFrom = tr.mapping.map(from);
|
|
59
59
|
removeFromSource(tr, tr.doc.resolve(mappedFrom));
|
|
60
60
|
}
|
|
61
|
-
|
|
61
|
+
attachMoveNodeAnalytics(tr, INPUT_METHOD.DRAG_AND_DROP, $originalFrom.depth, ((_$originalFrom$nodeAf2 = $originalFrom.nodeAfter) === null || _$originalFrom$nodeAf2 === void 0 ? void 0 : _$originalFrom$nodeAf2.type.name) || '', 1, 'layoutSection', false, api);
|
|
62
62
|
}
|
|
63
63
|
return tr;
|
|
64
64
|
};
|
|
@@ -24,9 +24,7 @@ const shouldIgnoreNode = (node, ignore_nodes, depth, parent
|
|
|
24
24
|
// eslint-disable-next-line @typescript-eslint/max-params
|
|
25
25
|
) => {
|
|
26
26
|
const isEmbedCard = 'embedCard' === node.type.name && fg('platform_editor_element_dnd_nested_fix_patch_3');
|
|
27
|
-
|
|
28
|
-
// TODO use isWrappedMedia when clean up the feature flag
|
|
29
|
-
const isMediaSingle = 'mediaSingle' === node.type.name && fg('platform_editor_element_dnd_nested_fix_patch_1');
|
|
27
|
+
const isMediaSingle = node.type.name === 'mediaSingle';
|
|
30
28
|
const isFirstTableRow = (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'table' && depth === 1 && node === parent.firstChild && 'tableRow' === node.type.name && editorExperiment('advanced_layouts', true);
|
|
31
29
|
if (isFirstTableRow) {
|
|
32
30
|
return false;
|
|
@@ -81,12 +81,16 @@ export const handleMouseOver = (view, event, api) => {
|
|
|
81
81
|
|
|
82
82
|
// We want to exlude handles showing for first element in a Panel, ignoring widgets like gapcursor
|
|
83
83
|
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');
|
|
84
|
-
if (parentElement && parentElementType === 'panel' &&
|
|
84
|
+
if (parentElement && parentElementType === 'panel' && !parentElement.classList.contains('ak-editor-panel__no-icon') && (index === 0 || firstChildIsWidget && index === 1)) {
|
|
85
85
|
return false;
|
|
86
86
|
}
|
|
87
87
|
} else {
|
|
88
88
|
pos = view.posAtDOM(rootElement, 0);
|
|
89
89
|
}
|
|
90
|
+
if (parentRootElement && parentRootElement.getAttribute('data-layout-section') === 'true' && parentRootElement.querySelectorAll('[data-layout-column]').length === 1 && editorExperiment('advanced_layouts', true) && fg('platform_editor_advanced_layouts_post_fix_patch_3')) {
|
|
91
|
+
// Don't show drag handle for layout column in a single column layout
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
90
94
|
let rootPos;
|
|
91
95
|
if (editorExperiment('nested-dnd', true)) {
|
|
92
96
|
rootPos = view.state.doc.resolve(pos).pos;
|
|
@@ -2,6 +2,7 @@ import rafSchedule from 'raf-schd';
|
|
|
2
2
|
import { AnalyticsStep } from '@atlaskit/adf-schema/steps';
|
|
3
3
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import { browser } from '@atlaskit/editor-common/browser';
|
|
5
|
+
import { isMeasuring, startMeasure, stopMeasure } from '@atlaskit/editor-common/performance-measures';
|
|
5
6
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
6
7
|
import { isEmptyDocument, isTextInput } from '@atlaskit/editor-common/utils';
|
|
7
8
|
import { NodeSelection, PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -21,10 +22,11 @@ import { AnchorRectCache, isAnchorSupported } from './utils/anchor-utils';
|
|
|
21
22
|
import { isBlocksDragTargetDebug } from './utils/drag-target-debug';
|
|
22
23
|
import { getTrMetadata } from './utils/transactions';
|
|
23
24
|
export const key = new PluginKey('blockControls');
|
|
25
|
+
const EDITOR_BLOCKS_DRAG_INIT = 'Editor Blocks Drag Initialization Time';
|
|
24
26
|
const isHTMLElement = element => {
|
|
25
27
|
return element instanceof HTMLElement;
|
|
26
28
|
};
|
|
27
|
-
const destroyFn = api => {
|
|
29
|
+
const destroyFn = (api, editorView) => {
|
|
28
30
|
const scrollable = document.querySelector('.fabric-editor-popup-scroll-parent');
|
|
29
31
|
const cleanupFn = [];
|
|
30
32
|
if (scrollable) {
|
|
@@ -36,6 +38,26 @@ const destroyFn = api => {
|
|
|
36
38
|
canMonitor: ({
|
|
37
39
|
source
|
|
38
40
|
}) => source.data.type === 'element',
|
|
41
|
+
onDrag: () => {
|
|
42
|
+
if (isMeasuring(EDITOR_BLOCKS_DRAG_INIT) && fg('platform_editor_advanced_layouts_post_fix_patch_3')) {
|
|
43
|
+
stopMeasure(EDITOR_BLOCKS_DRAG_INIT, (duration, startTime) => {
|
|
44
|
+
var _api$analytics;
|
|
45
|
+
const {
|
|
46
|
+
state
|
|
47
|
+
} = editorView;
|
|
48
|
+
api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.fireAnalyticsEvent({
|
|
49
|
+
action: ACTION.BLOCKS_DRAG_INIT,
|
|
50
|
+
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
51
|
+
eventType: EVENT_TYPE.OPERATIONAL,
|
|
52
|
+
attributes: {
|
|
53
|
+
duration,
|
|
54
|
+
startTime,
|
|
55
|
+
nodesCount: state.doc.nodeSize
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
},
|
|
39
61
|
onDragStart: () => {
|
|
40
62
|
if (isHTMLElement(scrollable)) {
|
|
41
63
|
scrollable.style.setProperty('scroll-behavior', 'unset');
|
|
@@ -57,10 +79,10 @@ const destroyFn = api => {
|
|
|
57
79
|
} = source.data;
|
|
58
80
|
// if no drop targets are rendered, assume that drop is invalid
|
|
59
81
|
if (location.current.dropTargets.length === 0) {
|
|
60
|
-
var _api$
|
|
82
|
+
var _api$analytics2;
|
|
61
83
|
const resolvedMovingNode = tr.doc.resolve(start);
|
|
62
84
|
const maybeNode = resolvedMovingNode.nodeAfter;
|
|
63
|
-
api === null || api === void 0 ? void 0 : (_api$
|
|
85
|
+
api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions.attachAnalyticsEvent({
|
|
64
86
|
eventType: EVENT_TYPE.UI,
|
|
65
87
|
action: ACTION.CANCELLED,
|
|
66
88
|
actionSubject: ACTION_SUBJECT.DRAG,
|
|
@@ -504,6 +526,9 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI) => {
|
|
|
504
526
|
},
|
|
505
527
|
dragstart(view) {
|
|
506
528
|
var _anchorRectCache;
|
|
529
|
+
if (fg('platform_editor_advanced_layouts_post_fix_patch_3')) {
|
|
530
|
+
startMeasure(EDITOR_BLOCKS_DRAG_INIT);
|
|
531
|
+
}
|
|
507
532
|
if (isAdvancedLayoutEnabled) {
|
|
508
533
|
defaultActiveAnchorTracker.reset();
|
|
509
534
|
}
|
|
@@ -588,7 +613,7 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI) => {
|
|
|
588
613
|
}
|
|
589
614
|
|
|
590
615
|
// Start pragmatic monitors
|
|
591
|
-
const pragmaticCleanup = destroyFn(api);
|
|
616
|
+
const pragmaticCleanup = destroyFn(api, editorView);
|
|
592
617
|
return {
|
|
593
618
|
destroy() {
|
|
594
619
|
if (editorContentArea) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
export const
|
|
2
|
+
export const attachMoveNodeAnalytics = (tr, inputMethod, fromDepth, fromNodeType, toDepth, toNodeType, isSameParent, api
|
|
3
3
|
// Ignored via go/ees005
|
|
4
4
|
// eslint-disable-next-line @typescript-eslint/max-params
|
|
5
5
|
) => {
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import { findParentNodeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
3
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
1
4
|
import { MIN_LAYOUT_COLUMN } from './consts';
|
|
2
5
|
import { updateColumnWidths } from './update-column-widths';
|
|
3
6
|
export const removeFromSource = (tr, $from) => {
|
|
@@ -10,6 +13,23 @@ export const removeFromSource = (tr, $from) => {
|
|
|
10
13
|
if (sourceNode.type.name === 'layoutColumn') {
|
|
11
14
|
if (sourceParent.childCount === MIN_LAYOUT_COLUMN) {
|
|
12
15
|
tr.delete($from.pos + 1, sourceNodeEndPos - 1);
|
|
16
|
+
|
|
17
|
+
// Currently, we assume that the MIN_LAYOUT_COLUMN is set to 2.
|
|
18
|
+
// This value may require an update when we introduce support for a single-column layout.
|
|
19
|
+
if (sourceParent.childCount === 2 && fg('platform_editor_advanced_layouts_DnD_remove_layout')) {
|
|
20
|
+
var _$from$parent$lastChi, _$from$parent$firstCh;
|
|
21
|
+
const layoutContentFragment = $from.parentOffset === 0 ? Fragment.from((_$from$parent$lastChi = $from.parent.lastChild) === null || _$from$parent$lastChi === void 0 ? void 0 : _$from$parent$lastChi.content) : Fragment.from((_$from$parent$firstCh = $from.parent.firstChild) === null || _$from$parent$firstCh === void 0 ? void 0 : _$from$parent$firstCh.content);
|
|
22
|
+
const parent = findParentNodeClosestToPos($from, node => {
|
|
23
|
+
return node.type.name === 'layoutSection';
|
|
24
|
+
});
|
|
25
|
+
if (parent && layoutContentFragment) {
|
|
26
|
+
var _tr$doc$resolve$nodeA;
|
|
27
|
+
const layoutSectionPos = tr.mapping.map(parent.pos);
|
|
28
|
+
// get the updated layout node size
|
|
29
|
+
const layoutSectionNodeSize = ((_tr$doc$resolve$nodeA = tr.doc.resolve(layoutSectionPos).nodeAfter) === null || _tr$doc$resolve$nodeA === void 0 ? void 0 : _tr$doc$resolve$nodeA.nodeSize) || 0;
|
|
30
|
+
tr.replaceWith(layoutSectionPos, layoutSectionPos + layoutSectionNodeSize, layoutContentFragment);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
13
33
|
return tr;
|
|
14
34
|
} else {
|
|
15
35
|
updateColumnWidths(tr, $from.parent, $from.before($from.depth), sourceParent.childCount - 1);
|
|
@@ -277,6 +277,6 @@ const blockCardWithoutLayout = css({
|
|
|
277
277
|
});
|
|
278
278
|
export const GlobalStylesWrapper = () => {
|
|
279
279
|
return jsx(Global, {
|
|
280
|
-
styles: [globalStyles(), fg('platform_editor_advanced_layouts_post_fix_patch_1') && globalDnDStyle, editorExperiment('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), getTextNodeStyle(), withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined,
|
|
280
|
+
styles: [globalStyles(), fg('platform_editor_advanced_layouts_post_fix_patch_1') && globalDnDStyle, editorExperiment('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), getTextNodeStyle(), withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, fg('platform_editor_element_dnd_nested_fix_patch_2') ? withFormatInLayoutStyleFix : undefined, fg('platform_editor_element_dnd_nested_fix_patch_3') ? [withRelativePosStyle, topLevelNodeMarginStyles, editorExperiment('nested-dnd', true) ? withAnchorNameZindexNestedStyle : withAnchorNameZindexStyle] : undefined]
|
|
281
281
|
});
|
|
282
282
|
};
|
|
@@ -14,7 +14,7 @@ import { fg } from '@atlaskit/platform-feature-flags';
|
|
|
14
14
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
15
15
|
import { key } from '../pm-plugins/main';
|
|
16
16
|
import { DIRECTION } from '../pm-plugins/utils/consts';
|
|
17
|
-
import {
|
|
17
|
+
import { attachMoveNodeAnalytics } from '../pm-plugins/utils/fire-analytics';
|
|
18
18
|
import { getNestedNodePosition } from '../pm-plugins/utils/getNestedNodePosition';
|
|
19
19
|
import { selectNode, setCursorPositionAtMovedNode } from '../pm-plugins/utils/getSelection';
|
|
20
20
|
import { removeFromSource } from '../pm-plugins/utils/remove-from-source';
|
|
@@ -216,7 +216,7 @@ export var moveNode = function moveNode(api) {
|
|
|
216
216
|
api === null || api === void 0 || api.core.actions.focus();
|
|
217
217
|
var $mappedTo = tr.doc.resolve(mappedTo);
|
|
218
218
|
if (editorExperiment('advanced_layouts', true)) {
|
|
219
|
-
|
|
219
|
+
attachMoveNodeAnalytics(tr, inputMethod, resolvedNode.depth, node.type.name, $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.depth, $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.parent.type.name, $from.sameParent($mappedTo), api);
|
|
220
220
|
} else {
|
|
221
221
|
var _api$analytics;
|
|
222
222
|
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
|
|
@@ -3,7 +3,7 @@ import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
|
3
3
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
5
|
import { maxLayoutColumnSupported } from '../pm-plugins/utils/consts';
|
|
6
|
-
import { fireInsertLayoutAnalytics,
|
|
6
|
+
import { fireInsertLayoutAnalytics, attachMoveNodeAnalytics } from '../pm-plugins/utils/fire-analytics';
|
|
7
7
|
import { removeFromSource } from '../pm-plugins/utils/remove-from-source';
|
|
8
8
|
import { updateColumnWidths } from '../pm-plugins/utils/update-column-widths';
|
|
9
9
|
import { isInSameLayout } from '../pm-plugins/utils/validation';
|
|
@@ -46,7 +46,7 @@ var moveToExistingLayout = function moveToExistingLayout(toLayout, toLayoutPos,
|
|
|
46
46
|
if (!fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
47
47
|
tr.setSelection(new NodeSelection(tr.doc.resolve(mappedTo))).scrollIntoView();
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
attachMoveNodeAnalytics(tr, INPUT_METHOD.DRAG_AND_DROP, $originalFrom.depth, ((_$originalFrom$nodeAf = $originalFrom.nodeAfter) === null || _$originalFrom$nodeAf === void 0 ? void 0 : _$originalFrom$nodeAf.type.name) || '', 1, 'layoutSection', true, api);
|
|
50
50
|
} else if (toLayout.childCount < maxLayoutColumnSupported()) {
|
|
51
51
|
var _$originalFrom$nodeAf2;
|
|
52
52
|
if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
@@ -57,7 +57,7 @@ var moveToExistingLayout = function moveToExistingLayout(toLayout, toLayoutPos,
|
|
|
57
57
|
var mappedFrom = tr.mapping.map(from);
|
|
58
58
|
removeFromSource(tr, tr.doc.resolve(mappedFrom));
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
attachMoveNodeAnalytics(tr, INPUT_METHOD.DRAG_AND_DROP, $originalFrom.depth, ((_$originalFrom$nodeAf2 = $originalFrom.nodeAfter) === null || _$originalFrom$nodeAf2 === void 0 ? void 0 : _$originalFrom$nodeAf2.type.name) || '', 1, 'layoutSection', false, api);
|
|
61
61
|
}
|
|
62
62
|
return tr;
|
|
63
63
|
};
|
|
@@ -25,9 +25,7 @@ var shouldIgnoreNode = function shouldIgnoreNode(node, ignore_nodes, depth, pare
|
|
|
25
25
|
// eslint-disable-next-line @typescript-eslint/max-params
|
|
26
26
|
) {
|
|
27
27
|
var isEmbedCard = 'embedCard' === node.type.name && fg('platform_editor_element_dnd_nested_fix_patch_3');
|
|
28
|
-
|
|
29
|
-
// TODO use isWrappedMedia when clean up the feature flag
|
|
30
|
-
var isMediaSingle = 'mediaSingle' === node.type.name && fg('platform_editor_element_dnd_nested_fix_patch_1');
|
|
28
|
+
var isMediaSingle = node.type.name === 'mediaSingle';
|
|
31
29
|
var isFirstTableRow = (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'table' && depth === 1 && node === parent.firstChild && 'tableRow' === node.type.name && editorExperiment('advanced_layouts', true);
|
|
32
30
|
if (isFirstTableRow) {
|
|
33
31
|
return false;
|
|
@@ -80,12 +80,16 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
|
|
|
80
80
|
|
|
81
81
|
// We want to exlude handles showing for first element in a Panel, ignoring widgets like gapcursor
|
|
82
82
|
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');
|
|
83
|
-
if (parentElement && parentElementType === 'panel' &&
|
|
83
|
+
if (parentElement && parentElementType === 'panel' && !parentElement.classList.contains('ak-editor-panel__no-icon') && (index === 0 || firstChildIsWidget && index === 1)) {
|
|
84
84
|
return false;
|
|
85
85
|
}
|
|
86
86
|
} else {
|
|
87
87
|
pos = view.posAtDOM(rootElement, 0);
|
|
88
88
|
}
|
|
89
|
+
if (parentRootElement && parentRootElement.getAttribute('data-layout-section') === 'true' && parentRootElement.querySelectorAll('[data-layout-column]').length === 1 && editorExperiment('advanced_layouts', true) && fg('platform_editor_advanced_layouts_post_fix_patch_3')) {
|
|
90
|
+
// Don't show drag handle for layout column in a single column layout
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
89
93
|
var rootPos;
|
|
90
94
|
if (editorExperiment('nested-dnd', true)) {
|
|
91
95
|
rootPos = view.state.doc.resolve(pos).pos;
|
|
@@ -3,6 +3,7 @@ import rafSchedule from 'raf-schd';
|
|
|
3
3
|
import { AnalyticsStep } from '@atlaskit/adf-schema/steps';
|
|
4
4
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
5
5
|
import { browser } from '@atlaskit/editor-common/browser';
|
|
6
|
+
import { isMeasuring, startMeasure, stopMeasure } from '@atlaskit/editor-common/performance-measures';
|
|
6
7
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
7
8
|
import { isEmptyDocument, isTextInput } from '@atlaskit/editor-common/utils';
|
|
8
9
|
import { NodeSelection, PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -22,10 +23,11 @@ import { AnchorRectCache, isAnchorSupported } from './utils/anchor-utils';
|
|
|
22
23
|
import { isBlocksDragTargetDebug } from './utils/drag-target-debug';
|
|
23
24
|
import { getTrMetadata } from './utils/transactions';
|
|
24
25
|
export var key = new PluginKey('blockControls');
|
|
26
|
+
var EDITOR_BLOCKS_DRAG_INIT = 'Editor Blocks Drag Initialization Time';
|
|
25
27
|
var isHTMLElement = function isHTMLElement(element) {
|
|
26
28
|
return element instanceof HTMLElement;
|
|
27
29
|
};
|
|
28
|
-
var destroyFn = function destroyFn(api) {
|
|
30
|
+
var destroyFn = function destroyFn(api, editorView) {
|
|
29
31
|
var scrollable = document.querySelector('.fabric-editor-popup-scroll-parent');
|
|
30
32
|
var cleanupFn = [];
|
|
31
33
|
if (scrollable) {
|
|
@@ -38,6 +40,24 @@ var destroyFn = function destroyFn(api) {
|
|
|
38
40
|
var source = _ref.source;
|
|
39
41
|
return source.data.type === 'element';
|
|
40
42
|
},
|
|
43
|
+
onDrag: function onDrag() {
|
|
44
|
+
if (isMeasuring(EDITOR_BLOCKS_DRAG_INIT) && fg('platform_editor_advanced_layouts_post_fix_patch_3')) {
|
|
45
|
+
stopMeasure(EDITOR_BLOCKS_DRAG_INIT, function (duration, startTime) {
|
|
46
|
+
var _api$analytics;
|
|
47
|
+
var state = editorView.state;
|
|
48
|
+
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.fireAnalyticsEvent({
|
|
49
|
+
action: ACTION.BLOCKS_DRAG_INIT,
|
|
50
|
+
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
51
|
+
eventType: EVENT_TYPE.OPERATIONAL,
|
|
52
|
+
attributes: {
|
|
53
|
+
duration: duration,
|
|
54
|
+
startTime: startTime,
|
|
55
|
+
nodesCount: state.doc.nodeSize
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
},
|
|
41
61
|
onDragStart: function onDragStart() {
|
|
42
62
|
if (isHTMLElement(scrollable)) {
|
|
43
63
|
scrollable.style.setProperty('scroll-behavior', 'unset');
|
|
@@ -56,10 +76,10 @@ var destroyFn = function destroyFn(api) {
|
|
|
56
76
|
start = _ref4.start;
|
|
57
77
|
// if no drop targets are rendered, assume that drop is invalid
|
|
58
78
|
if (location.current.dropTargets.length === 0) {
|
|
59
|
-
var _api$
|
|
79
|
+
var _api$analytics2;
|
|
60
80
|
var resolvedMovingNode = tr.doc.resolve(start);
|
|
61
81
|
var maybeNode = resolvedMovingNode.nodeAfter;
|
|
62
|
-
api === null || api === void 0 || (_api$
|
|
82
|
+
api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || _api$analytics2.actions.attachAnalyticsEvent({
|
|
63
83
|
eventType: EVENT_TYPE.UI,
|
|
64
84
|
action: ACTION.CANCELLED,
|
|
65
85
|
actionSubject: ACTION_SUBJECT.DRAG,
|
|
@@ -517,6 +537,9 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
517
537
|
},
|
|
518
538
|
dragstart: function dragstart(view) {
|
|
519
539
|
var _anchorRectCache;
|
|
540
|
+
if (fg('platform_editor_advanced_layouts_post_fix_patch_3')) {
|
|
541
|
+
startMeasure(EDITOR_BLOCKS_DRAG_INIT);
|
|
542
|
+
}
|
|
520
543
|
if (isAdvancedLayoutEnabled) {
|
|
521
544
|
defaultActiveAnchorTracker.reset();
|
|
522
545
|
}
|
|
@@ -598,7 +621,7 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
598
621
|
}
|
|
599
622
|
|
|
600
623
|
// Start pragmatic monitors
|
|
601
|
-
var pragmaticCleanup = destroyFn(api);
|
|
624
|
+
var pragmaticCleanup = destroyFn(api, editorView);
|
|
602
625
|
return {
|
|
603
626
|
destroy: function destroy() {
|
|
604
627
|
if (editorContentArea) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
export var
|
|
2
|
+
export var attachMoveNodeAnalytics = function attachMoveNodeAnalytics(tr, inputMethod, fromDepth, fromNodeType, toDepth, toNodeType, isSameParent, api
|
|
3
3
|
// Ignored via go/ees005
|
|
4
4
|
// eslint-disable-next-line @typescript-eslint/max-params
|
|
5
5
|
) {
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import { findParentNodeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
3
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
1
4
|
import { MIN_LAYOUT_COLUMN } from './consts';
|
|
2
5
|
import { updateColumnWidths } from './update-column-widths';
|
|
3
6
|
export var removeFromSource = function removeFromSource(tr, $from) {
|
|
@@ -10,6 +13,23 @@ export var removeFromSource = function removeFromSource(tr, $from) {
|
|
|
10
13
|
if (sourceNode.type.name === 'layoutColumn') {
|
|
11
14
|
if (sourceParent.childCount === MIN_LAYOUT_COLUMN) {
|
|
12
15
|
tr.delete($from.pos + 1, sourceNodeEndPos - 1);
|
|
16
|
+
|
|
17
|
+
// Currently, we assume that the MIN_LAYOUT_COLUMN is set to 2.
|
|
18
|
+
// This value may require an update when we introduce support for a single-column layout.
|
|
19
|
+
if (sourceParent.childCount === 2 && fg('platform_editor_advanced_layouts_DnD_remove_layout')) {
|
|
20
|
+
var _$from$parent$lastChi, _$from$parent$firstCh;
|
|
21
|
+
var layoutContentFragment = $from.parentOffset === 0 ? Fragment.from((_$from$parent$lastChi = $from.parent.lastChild) === null || _$from$parent$lastChi === void 0 ? void 0 : _$from$parent$lastChi.content) : Fragment.from((_$from$parent$firstCh = $from.parent.firstChild) === null || _$from$parent$firstCh === void 0 ? void 0 : _$from$parent$firstCh.content);
|
|
22
|
+
var parent = findParentNodeClosestToPos($from, function (node) {
|
|
23
|
+
return node.type.name === 'layoutSection';
|
|
24
|
+
});
|
|
25
|
+
if (parent && layoutContentFragment) {
|
|
26
|
+
var _tr$doc$resolve$nodeA;
|
|
27
|
+
var layoutSectionPos = tr.mapping.map(parent.pos);
|
|
28
|
+
// get the updated layout node size
|
|
29
|
+
var layoutSectionNodeSize = ((_tr$doc$resolve$nodeA = tr.doc.resolve(layoutSectionPos).nodeAfter) === null || _tr$doc$resolve$nodeA === void 0 ? void 0 : _tr$doc$resolve$nodeA.nodeSize) || 0;
|
|
30
|
+
tr.replaceWith(layoutSectionPos, layoutSectionPos + layoutSectionNodeSize, layoutContentFragment);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
13
33
|
return tr;
|
|
14
34
|
} else {
|
|
15
35
|
updateColumnWidths(tr, $from.parent, $from.before($from.depth), sourceParent.childCount - 1);
|
|
@@ -223,6 +223,6 @@ var blockCardWithoutLayout = css({
|
|
|
223
223
|
});
|
|
224
224
|
export var GlobalStylesWrapper = function GlobalStylesWrapper() {
|
|
225
225
|
return jsx(Global, {
|
|
226
|
-
styles: [globalStyles(), fg('platform_editor_advanced_layouts_post_fix_patch_1') && globalDnDStyle, editorExperiment('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), getTextNodeStyle(), withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined,
|
|
226
|
+
styles: [globalStyles(), fg('platform_editor_advanced_layouts_post_fix_patch_1') && globalDnDStyle, editorExperiment('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), getTextNodeStyle(), withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, fg('platform_editor_element_dnd_nested_fix_patch_2') ? withFormatInLayoutStyleFix : undefined, fg('platform_editor_element_dnd_nested_fix_patch_3') ? [withRelativePosStyle, topLevelNodeMarginStyles, editorExperiment('nested-dnd', true) ? withAnchorNameZindexNestedStyle : withAnchorNameZindexStyle] : undefined]
|
|
227
227
|
});
|
|
228
228
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
2
|
import { type Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import { type BlockControlsPlugin } from '../../blockControlsPluginType';
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const attachMoveNodeAnalytics: (tr: Transaction, inputMethod: string, fromDepth: number, fromNodeType: string, toDepth?: number, toNodeType?: string, isSameParent?: boolean, api?: ExtractInjectionAPI<BlockControlsPlugin>) => boolean | undefined;
|
|
5
5
|
export declare const fireInsertLayoutAnalytics: (tr: Transaction, api?: ExtractInjectionAPI<BlockControlsPlugin>) => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
2
|
import { type Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import { type BlockControlsPlugin } from '../../blockControlsPluginType';
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const attachMoveNodeAnalytics: (tr: Transaction, inputMethod: string, fromDepth: number, fromNodeType: string, toDepth?: number, toNodeType?: string, isSameParent?: boolean, api?: ExtractInjectionAPI<BlockControlsPlugin>) => boolean | undefined;
|
|
5
5
|
export declare const fireInsertLayoutAnalytics: (tr: Transaction, api?: ExtractInjectionAPI<BlockControlsPlugin>) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.17.0",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@atlaskit/adf-schema": "^46.1.0",
|
|
34
|
-
"@atlaskit/editor-common": "^98.
|
|
34
|
+
"@atlaskit/editor-common": "^98.2.0",
|
|
35
35
|
"@atlaskit/editor-plugin-accessibility-utils": "^1.2.0",
|
|
36
36
|
"@atlaskit/editor-plugin-analytics": "^1.10.0",
|
|
37
37
|
"@atlaskit/editor-plugin-editor-disabled": "^1.3.0",
|
|
@@ -41,14 +41,14 @@
|
|
|
41
41
|
"@atlaskit/editor-prosemirror": "6.2.1",
|
|
42
42
|
"@atlaskit/editor-shared-styles": "^3.2.0",
|
|
43
43
|
"@atlaskit/editor-tables": "^2.8.0",
|
|
44
|
-
"@atlaskit/icon": "^23.
|
|
44
|
+
"@atlaskit/icon": "^23.2.0",
|
|
45
45
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
46
46
|
"@atlaskit/pragmatic-drag-and-drop": "^1.4.0",
|
|
47
47
|
"@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^2.1.0",
|
|
48
48
|
"@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^1.1.0",
|
|
49
49
|
"@atlaskit/primitives": "^13.3.0",
|
|
50
50
|
"@atlaskit/theme": "^14.0.0",
|
|
51
|
-
"@atlaskit/tmp-editor-statsig": "^2.
|
|
51
|
+
"@atlaskit/tmp-editor-statsig": "^2.32.0",
|
|
52
52
|
"@atlaskit/tokens": "^2.5.0",
|
|
53
53
|
"@atlaskit/tooltip": "^19.0.0",
|
|
54
54
|
"@babel/runtime": "^7.0.0",
|
|
@@ -130,9 +130,6 @@
|
|
|
130
130
|
"platform_editor_element_drag_and_drop_ed_24885": {
|
|
131
131
|
"type": "boolean"
|
|
132
132
|
},
|
|
133
|
-
"platform_editor_element_dnd_nested_fix_patch_1": {
|
|
134
|
-
"type": "boolean"
|
|
135
|
-
},
|
|
136
133
|
"platform_editor_element_dnd_nested_fix_patch_2": {
|
|
137
134
|
"type": "boolean"
|
|
138
135
|
},
|
|
@@ -168,6 +165,12 @@
|
|
|
168
165
|
},
|
|
169
166
|
"platform_editor_advanced_layouts_post_fix_patch_2": {
|
|
170
167
|
"type": "boolean"
|
|
168
|
+
},
|
|
169
|
+
"platform_editor_advanced_layouts_post_fix_patch_3": {
|
|
170
|
+
"type": "boolean"
|
|
171
|
+
},
|
|
172
|
+
"platform_editor_advanced_layouts_DnD_remove_layout": {
|
|
173
|
+
"type": "boolean"
|
|
171
174
|
}
|
|
172
175
|
}
|
|
173
176
|
}
|