@atlaskit/editor-plugin-block-controls 2.16.4 → 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 +15 -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 +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
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
|
+
|
|
3
18
|
## 2.16.4
|
|
4
19
|
|
|
5
20
|
### 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,7 +86,7 @@ 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 {
|
|
@@ -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,7 +81,7 @@ 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 {
|
|
@@ -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,7 +80,7 @@ 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 {
|
|
@@ -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
|
},
|
|
@@ -171,6 +168,9 @@
|
|
|
171
168
|
},
|
|
172
169
|
"platform_editor_advanced_layouts_post_fix_patch_3": {
|
|
173
170
|
"type": "boolean"
|
|
171
|
+
},
|
|
172
|
+
"platform_editor_advanced_layouts_DnD_remove_layout": {
|
|
173
|
+
"type": "boolean"
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
}
|