@atlaskit/editor-plugin-block-controls 2.13.11 → 2.13.13
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 +20 -0
- package/dist/cjs/commands/move-to-layout.js +50 -32
- package/dist/cjs/consts.js +3 -2
- package/dist/cjs/plugin.js +5 -16
- package/dist/cjs/pm-plugins/decorations-anchor.js +4 -3
- package/dist/cjs/ui/global-styles.js +86 -122
- package/dist/es2019/commands/move-to-layout.js +42 -23
- package/dist/es2019/consts.js +2 -1
- package/dist/es2019/plugin.js +1 -10
- package/dist/es2019/pm-plugins/decorations-anchor.js +4 -3
- package/dist/es2019/ui/global-styles.js +23 -20
- package/dist/esm/commands/move-to-layout.js +51 -33
- package/dist/esm/consts.js +2 -1
- package/dist/esm/plugin.js +5 -16
- package/dist/esm/pm-plugins/decorations-anchor.js +4 -3
- package/dist/esm/ui/global-styles.js +87 -122
- package/dist/types/consts.d.ts +1 -0
- package/dist/types-ts4.5/consts.d.ts +1 -0
- package/package.json +4 -7
- package/dist/cjs/pm-plugins/empty-block-experiment.js +0 -46
- package/dist/cjs/ui/empty-block-experiment/global-styles.js +0 -66
- package/dist/cjs/ui/empty-block-experiment/widget.js +0 -144
- package/dist/es2019/pm-plugins/empty-block-experiment.js +0 -38
- package/dist/es2019/ui/empty-block-experiment/global-styles.js +0 -77
- package/dist/es2019/ui/empty-block-experiment/widget.js +0 -138
- package/dist/esm/pm-plugins/empty-block-experiment.js +0 -40
- package/dist/esm/ui/empty-block-experiment/global-styles.js +0 -58
- package/dist/esm/ui/empty-block-experiment/widget.js +0 -133
- package/dist/types/pm-plugins/empty-block-experiment.d.ts +0 -13
- package/dist/types/ui/empty-block-experiment/global-styles.d.ts +0 -4
- package/dist/types/ui/empty-block-experiment/widget.d.ts +0 -13
- package/dist/types-ts4.5/pm-plugins/empty-block-experiment.d.ts +0 -13
- package/dist/types-ts4.5/ui/empty-block-experiment/global-styles.d.ts +0 -4
- package/dist/types-ts4.5/ui/empty-block-experiment/widget.d.ts +0 -13
|
@@ -25,8 +25,8 @@ const shouldIgnoreNode = (node, ignore_nodes, depth, parent) => {
|
|
|
25
25
|
|
|
26
26
|
// TODO use isWrappedMedia when clean up the feature flag
|
|
27
27
|
const isMediaSingle = 'mediaSingle' === node.type.name && fg('platform_editor_element_dnd_nested_fix_patch_1');
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
28
|
+
const isFirstTableRow = (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'table' && depth === 1 && node === parent.firstChild && 'tableRow' === node.type.name && isPreRelease1();
|
|
29
|
+
if (isFirstTableRow) {
|
|
30
30
|
return false;
|
|
31
31
|
}
|
|
32
32
|
return (isEmbedCard || isMediaSingle) && ['wrap-right', 'wrap-left'].includes(node.attrs.layout) ? true : ignore_nodes.includes(node.type.name);
|
|
@@ -84,8 +84,9 @@ export const nodeDecorations = (newState, from, to) => {
|
|
|
84
84
|
var _anchorName2;
|
|
85
85
|
anchorName = (_anchorName2 = anchorName) !== null && _anchorName2 !== void 0 ? _anchorName2 : `--node-anchor-${node.type.name}-${index}`;
|
|
86
86
|
}
|
|
87
|
+
const anchorStyles = ['tableRow', 'media'].includes(node.type.name) ? `anchor-name: ${anchorName};` : `anchor-name: ${anchorName}; ${pos === 0 && !fg('platform_editor_element_dnd_nested_fix_patch_3') ? 'margin-top: 0px;' : ''} ${fg('platform_editor_element_dnd_nested_fix_patch_3') ? '' : 'position: relative; z-index: 1;'}`;
|
|
87
88
|
decs.push(Decoration.node(pos, pos + node.nodeSize, {
|
|
88
|
-
style:
|
|
89
|
+
style: anchorStyles,
|
|
89
90
|
['data-drag-handler-anchor-name']: anchorName,
|
|
90
91
|
['data-drag-handler-node-type']: node.type.name,
|
|
91
92
|
['data-drag-handler-anchor-depth']: `${depth}`
|
|
@@ -8,17 +8,22 @@ import { akEditorCalculatedWideLayoutWidth, akEditorCalculatedWideLayoutWidthSma
|
|
|
8
8
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
9
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
10
10
|
import { DRAG_HANDLE_MAX_WIDTH_PLUS_GAP, DRAG_HANDLE_WIDTH } from './consts';
|
|
11
|
-
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* This anchor element selector disregards anchors that are solely utilized for size measurements,
|
|
14
|
+
* including those within table rows and media.
|
|
15
|
+
*/
|
|
16
|
+
const dragHandlerAnchorSelector = '[data-drag-handler-anchor-name]:not([data-drag-handler-node-type="tableRow"], [data-drag-handler-node-type="media"])';
|
|
12
17
|
const extendedHoverZone = () => css({
|
|
13
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
14
|
-
|
|
18
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
19
|
+
[`.block-ctrl-drag-preview ${dragHandlerAnchorSelector}::after`]: {
|
|
15
20
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
|
|
16
21
|
display: 'none !important'
|
|
17
22
|
},
|
|
18
23
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
19
24
|
'.ProseMirror': {
|
|
20
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
21
|
-
|
|
25
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
26
|
+
[`&& ${dragHandlerAnchorSelector}::after`]: {
|
|
22
27
|
content: '""',
|
|
23
28
|
position: 'absolute',
|
|
24
29
|
top: 0,
|
|
@@ -42,15 +47,15 @@ const extendedHoverZone = () => css({
|
|
|
42
47
|
}
|
|
43
48
|
});
|
|
44
49
|
const extendedHoverZoneNested = () => css({
|
|
45
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
46
|
-
|
|
50
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
51
|
+
[`.block-ctrl-drag-preview ${dragHandlerAnchorSelector}::after`]: {
|
|
47
52
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
|
|
48
53
|
display: 'none !important'
|
|
49
54
|
},
|
|
50
55
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
51
56
|
'.ProseMirror': {
|
|
52
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
53
|
-
|
|
57
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
58
|
+
[`&& ${dragHandlerAnchorSelector}::after`]: {
|
|
54
59
|
content: '""',
|
|
55
60
|
position: 'absolute',
|
|
56
61
|
top: 0,
|
|
@@ -62,8 +67,8 @@ const extendedHoverZoneNested = () => css({
|
|
|
62
67
|
cursor: 'default',
|
|
63
68
|
zIndex: 1
|
|
64
69
|
},
|
|
65
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
66
|
-
|
|
70
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
71
|
+
[`&& [data-drag-handler-anchor-depth="0"]${dragHandlerAnchorSelector}::after`]: {
|
|
67
72
|
content: '""',
|
|
68
73
|
position: 'absolute',
|
|
69
74
|
top: 0,
|
|
@@ -74,8 +79,8 @@ const extendedHoverZoneNested = () => css({
|
|
|
74
79
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
75
80
|
zIndex: -1
|
|
76
81
|
},
|
|
77
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
78
|
-
|
|
82
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
83
|
+
[`&& :is(.pm-table-cell-content-wrap, .pm-table-header-content-wrap) > ${dragHandlerAnchorSelector}::after`]: {
|
|
79
84
|
content: '""',
|
|
80
85
|
position: 'absolute',
|
|
81
86
|
top: 0,
|
|
@@ -215,8 +220,8 @@ const getTextNodeStyle = () => {
|
|
|
215
220
|
const withRelativePosStyle = css({
|
|
216
221
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
217
222
|
'.ProseMirror': {
|
|
218
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
219
|
-
|
|
223
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
224
|
+
[`&& ${dragHandlerAnchorSelector}`]: {
|
|
220
225
|
position: 'relative'
|
|
221
226
|
}
|
|
222
227
|
}
|
|
@@ -224,8 +229,8 @@ const withRelativePosStyle = css({
|
|
|
224
229
|
const withAnchorNameZindexStyle = css({
|
|
225
230
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
226
231
|
'.ProseMirror': {
|
|
227
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
228
|
-
|
|
232
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
233
|
+
[`&& ${dragHandlerAnchorSelector}`]: {
|
|
229
234
|
zIndex: 1
|
|
230
235
|
}
|
|
231
236
|
}
|
|
@@ -241,8 +246,6 @@ const withAnchorNameZindexNestedStyle = css({
|
|
|
241
246
|
});
|
|
242
247
|
export const GlobalStylesWrapper = () => {
|
|
243
248
|
return jsx(Global, {
|
|
244
|
-
styles: [globalStyles(), editorExperiment('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), getTextNodeStyle(), withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, editorExperiment('
|
|
245
|
-
exposure: false
|
|
246
|
-
}) ? emptyBlockExperimentGlobalStyles : undefined, fg('platform_editor_element_dnd_nested_fix_patch_1') ? withDividerInPanelStyleFix : undefined, 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]
|
|
249
|
+
styles: [globalStyles(), editorExperiment('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), getTextNodeStyle(), withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, fg('platform_editor_element_dnd_nested_fix_patch_1') ? withDividerInPanelStyleFix : undefined, 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]
|
|
247
250
|
});
|
|
248
251
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import { maxLayoutColumnSupported } from '../consts';
|
|
3
|
+
import { maxLayoutColumnSupported, MIN_LAYOUT_COLUMN } from '../consts';
|
|
4
4
|
import { DEFAULT_COLUMN_DISTRIBUTIONS } from '../ui/consts';
|
|
5
5
|
import { isInSameLayout } from '../utils/validation';
|
|
6
6
|
var createNewLayout = function createNewLayout(schema, layoutContents) {
|
|
@@ -27,26 +27,19 @@ var createNewLayout = function createNewLayout(schema, layoutContents) {
|
|
|
27
27
|
}
|
|
28
28
|
return null;
|
|
29
29
|
};
|
|
30
|
-
var updateColumnWidths = function updateColumnWidths(tr, layoutNode, layoutNodePos,
|
|
30
|
+
var updateColumnWidths = function updateColumnWidths(tr, layoutNode, layoutNodePos, childCount) {
|
|
31
|
+
var newColumnWidth = DEFAULT_COLUMN_DISTRIBUTIONS[childCount];
|
|
31
32
|
if (newColumnWidth) {
|
|
32
33
|
layoutNode.content.forEach(function (node, offset) {
|
|
33
34
|
if (node.type.name === 'layoutColumn') {
|
|
34
|
-
tr
|
|
35
|
+
tr.setNodeAttribute(layoutNodePos + offset + 1, 'width', newColumnWidth);
|
|
35
36
|
}
|
|
36
37
|
});
|
|
37
38
|
}
|
|
38
|
-
return
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
* Insert a node into an existing layout at position `to` and delete the node
|
|
43
|
-
*/
|
|
44
|
-
var moveNode = function moveNode(from, to, newNode, sourceNodeSize, tr) {
|
|
45
|
-
tr.insert(to, newNode).setSelection(new NodeSelection(tr.doc.resolve(to))).scrollIntoView();
|
|
46
|
-
var mappedFrom = tr.mapping.map(from);
|
|
47
|
-
var mappedFromEnd = mappedFrom + sourceNodeSize;
|
|
48
|
-
tr.delete(mappedFrom, mappedFromEnd);
|
|
49
|
-
return tr;
|
|
39
|
+
return {
|
|
40
|
+
newColumnWidth: newColumnWidth,
|
|
41
|
+
tr: tr
|
|
42
|
+
};
|
|
50
43
|
};
|
|
51
44
|
var moveToExistingLayout = function moveToExistingLayout(toLayout, toLayoutPos, sourceNode, from, to, tr, isSameLayout) {
|
|
52
45
|
if (isSameLayout) {
|
|
@@ -55,16 +48,41 @@ var moveToExistingLayout = function moveToExistingLayout(toLayout, toLayoutPos,
|
|
|
55
48
|
var mappedTo = tr.mapping.map(to);
|
|
56
49
|
tr.insert(mappedTo, sourceNode).setSelection(new NodeSelection(tr.doc.resolve(mappedTo))).scrollIntoView();
|
|
57
50
|
} else if (toLayout.childCount < maxLayoutColumnSupported()) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
layoutColumn = _ref2.layoutColumn;
|
|
62
|
-
moveNode(from, to, layoutColumn.create({
|
|
63
|
-
width: newColumnWidth
|
|
64
|
-
}, sourceNode), sourceNode.nodeSize, tr);
|
|
51
|
+
insertToDestination(tr, to, sourceNode, toLayout, toLayoutPos);
|
|
52
|
+
var mappedFrom = tr.mapping.map(from);
|
|
53
|
+
removeFromSource(tr, tr.doc.resolve(mappedFrom));
|
|
65
54
|
}
|
|
66
55
|
return tr;
|
|
67
56
|
};
|
|
57
|
+
var removeFromSource = function removeFromSource(tr, $from) {
|
|
58
|
+
var sourceNode = $from.nodeAfter;
|
|
59
|
+
var sourceParent = $from.parent;
|
|
60
|
+
if (!sourceNode) {
|
|
61
|
+
return tr;
|
|
62
|
+
}
|
|
63
|
+
var sourceNodeEndPos = $from.pos + sourceNode.nodeSize;
|
|
64
|
+
if (sourceNode.type.name === 'layoutColumn') {
|
|
65
|
+
if (sourceParent.childCount === MIN_LAYOUT_COLUMN) {
|
|
66
|
+
tr.delete($from.pos + 1, sourceNodeEndPos - 1);
|
|
67
|
+
return tr;
|
|
68
|
+
} else {
|
|
69
|
+
updateColumnWidths(tr, $from.parent, $from.before($from.depth), sourceParent.childCount - 1);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
tr.delete($from.pos, sourceNodeEndPos);
|
|
73
|
+
return tr;
|
|
74
|
+
};
|
|
75
|
+
var insertToDestination = function insertToDestination(tr, to, sourceNode, toLayout, toLayoutPos) {
|
|
76
|
+
var _ref2 = updateColumnWidths(tr, toLayout, toLayoutPos, toLayout.childCount + 1) || {},
|
|
77
|
+
newColumnWidth = _ref2.newColumnWidth;
|
|
78
|
+
var _ref3 = tr.doc.type.schema.nodes || {},
|
|
79
|
+
layoutColumn = _ref3.layoutColumn;
|
|
80
|
+
var content = layoutColumn.createChecked({
|
|
81
|
+
width: newColumnWidth
|
|
82
|
+
}, sourceNode.type.name === 'layoutColumn' ? sourceNode.content : sourceNode);
|
|
83
|
+
tr.insert(to, content).setSelection(new NodeSelection(tr.doc.resolve(to))).scrollIntoView();
|
|
84
|
+
return tr;
|
|
85
|
+
};
|
|
68
86
|
|
|
69
87
|
/**
|
|
70
88
|
* Check if the node at `from` can be moved to node at `to` to create/expand a layout.
|
|
@@ -74,10 +92,10 @@ var canMoveToLayout = function canMoveToLayout(from, to, tr) {
|
|
|
74
92
|
if (from === to) {
|
|
75
93
|
return;
|
|
76
94
|
}
|
|
77
|
-
var
|
|
78
|
-
layoutSection =
|
|
79
|
-
layoutColumn =
|
|
80
|
-
doc =
|
|
95
|
+
var _ref4 = tr.doc.type.schema.nodes || {},
|
|
96
|
+
layoutSection = _ref4.layoutSection,
|
|
97
|
+
layoutColumn = _ref4.layoutColumn,
|
|
98
|
+
doc = _ref4.doc;
|
|
81
99
|
|
|
82
100
|
// layout plugin does not exist
|
|
83
101
|
if (!layoutSection || !layoutColumn) {
|
|
@@ -106,8 +124,8 @@ var canMoveToLayout = function canMoveToLayout(from, to, tr) {
|
|
|
106
124
|
};
|
|
107
125
|
export var moveToLayout = function moveToLayout(api) {
|
|
108
126
|
return function (from, to, options) {
|
|
109
|
-
return function (
|
|
110
|
-
var tr =
|
|
127
|
+
return function (_ref5) {
|
|
128
|
+
var tr = _ref5.tr;
|
|
111
129
|
var canMove = canMoveToLayout(from, to, tr);
|
|
112
130
|
if (!canMove) {
|
|
113
131
|
return tr;
|
|
@@ -116,11 +134,11 @@ export var moveToLayout = function moveToLayout(api) {
|
|
|
116
134
|
fromNode = canMove.fromNode,
|
|
117
135
|
$from = canMove.$from,
|
|
118
136
|
$to = canMove.$to;
|
|
119
|
-
var
|
|
120
|
-
layoutSection =
|
|
121
|
-
layoutColumn =
|
|
122
|
-
var
|
|
123
|
-
breakout =
|
|
137
|
+
var _ref6 = tr.doc.type.schema.nodes || {},
|
|
138
|
+
layoutSection = _ref6.layoutSection,
|
|
139
|
+
layoutColumn = _ref6.layoutColumn;
|
|
140
|
+
var _ref7 = tr.doc.type.schema.marks || {},
|
|
141
|
+
breakout = _ref7.breakout;
|
|
124
142
|
var fromNodeWithoutBreakout = fromNode;
|
|
125
143
|
|
|
126
144
|
// remove breakout from node;
|
package/dist/esm/consts.js
CHANGED
package/dist/esm/plugin.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
3
|
import { moveNode } from './commands/move-node';
|
|
6
4
|
import { moveToLayout } from './commands/move-to-layout';
|
|
7
|
-
import { createEmptyBlockExperimentPlugin } from './pm-plugins/empty-block-experiment';
|
|
8
5
|
import { createPlugin, key } from './pm-plugins/main';
|
|
9
6
|
import { DragHandleMenu } from './ui/drag-handle-menu';
|
|
10
7
|
import { GlobalStylesWrapper } from './ui/global-styles';
|
|
@@ -20,22 +17,14 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
20
17
|
var getIntl = _ref2.getIntl;
|
|
21
18
|
return createPlugin(api, getIntl);
|
|
22
19
|
}
|
|
23
|
-
}]
|
|
24
|
-
exposure: true
|
|
25
|
-
}) ? [{
|
|
26
|
-
name: 'emptyBlockExperimentPlugin',
|
|
27
|
-
plugin: function plugin(_ref3) {
|
|
28
|
-
var getIntl = _ref3.getIntl;
|
|
29
|
-
return createEmptyBlockExperimentPlugin(api, getIntl);
|
|
30
|
-
}
|
|
31
|
-
}] : []));
|
|
20
|
+
}];
|
|
32
21
|
},
|
|
33
22
|
commands: {
|
|
34
23
|
moveNode: moveNode(api),
|
|
35
24
|
moveToLayout: moveToLayout(api),
|
|
36
25
|
showDragHandleAt: function showDragHandleAt(pos, anchorName, nodeType, handleOptions) {
|
|
37
|
-
return function (
|
|
38
|
-
var tr =
|
|
26
|
+
return function (_ref3) {
|
|
27
|
+
var tr = _ref3.tr;
|
|
39
28
|
tr.setMeta(key, {
|
|
40
29
|
activeNode: {
|
|
41
30
|
pos: pos,
|
|
@@ -48,8 +37,8 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
48
37
|
};
|
|
49
38
|
},
|
|
50
39
|
setNodeDragged: function setNodeDragged(getPos, anchorName, nodeType) {
|
|
51
|
-
return function (
|
|
52
|
-
var tr =
|
|
40
|
+
return function (_ref4) {
|
|
41
|
+
var tr = _ref4.tr;
|
|
53
42
|
var pos = getPos();
|
|
54
43
|
if (pos === undefined) {
|
|
55
44
|
return tr;
|
|
@@ -26,8 +26,8 @@ var shouldIgnoreNode = function shouldIgnoreNode(node, ignore_nodes, depth, pare
|
|
|
26
26
|
|
|
27
27
|
// TODO use isWrappedMedia when clean up the feature flag
|
|
28
28
|
var isMediaSingle = 'mediaSingle' === node.type.name && fg('platform_editor_element_dnd_nested_fix_patch_1');
|
|
29
|
-
var
|
|
30
|
-
if (
|
|
29
|
+
var isFirstTableRow = (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'table' && depth === 1 && node === parent.firstChild && 'tableRow' === node.type.name && isPreRelease1();
|
|
30
|
+
if (isFirstTableRow) {
|
|
31
31
|
return false;
|
|
32
32
|
}
|
|
33
33
|
return (isEmbedCard || isMediaSingle) && ['wrap-right', 'wrap-left'].includes(node.attrs.layout) ? true : ignore_nodes.includes(node.type.name);
|
|
@@ -88,8 +88,9 @@ export var nodeDecorations = function nodeDecorations(newState, from, to) {
|
|
|
88
88
|
var _anchorName2;
|
|
89
89
|
anchorName = (_anchorName2 = anchorName) !== null && _anchorName2 !== void 0 ? _anchorName2 : "--node-anchor-".concat(node.type.name, "-").concat(index);
|
|
90
90
|
}
|
|
91
|
+
var anchorStyles = ['tableRow', 'media'].includes(node.type.name) ? "anchor-name: ".concat(anchorName, ";") : "anchor-name: ".concat(anchorName, "; ").concat(pos === 0 && !fg('platform_editor_element_dnd_nested_fix_patch_3') ? 'margin-top: 0px;' : '', " ").concat(fg('platform_editor_element_dnd_nested_fix_patch_3') ? '' : 'position: relative; z-index: 1;');
|
|
91
92
|
decs.push(Decoration.node(pos, pos + node.nodeSize, (_Decoration$node = {
|
|
92
|
-
style:
|
|
93
|
+
style: anchorStyles
|
|
93
94
|
}, _defineProperty(_Decoration$node, 'data-drag-handler-anchor-name', anchorName), _defineProperty(_Decoration$node, 'data-drag-handler-node-type', node.type.name), _defineProperty(_Decoration$node, 'data-drag-handler-anchor-depth', "".concat(depth)), _Decoration$node), {
|
|
94
95
|
type: TYPE_NODE_DEC,
|
|
95
96
|
anchorName: anchorName,
|
|
@@ -9,116 +9,89 @@ import { akEditorCalculatedWideLayoutWidth, akEditorCalculatedWideLayoutWidthSma
|
|
|
9
9
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
10
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
11
11
|
import { DRAG_HANDLE_MAX_WIDTH_PLUS_GAP, DRAG_HANDLE_WIDTH } from './consts';
|
|
12
|
-
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* This anchor element selector disregards anchors that are solely utilized for size measurements,
|
|
15
|
+
* including those within table rows and media.
|
|
16
|
+
*/
|
|
17
|
+
var dragHandlerAnchorSelector = '[data-drag-handler-anchor-name]:not([data-drag-handler-node-type="tableRow"], [data-drag-handler-node-type="media"])';
|
|
13
18
|
var extendedHoverZone = function extendedHoverZone() {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
// TODO - ED-23995 this style override needs to be moved to the Rule styles after FF cleanup - packages/editor/editor-common/src/styles/shared/rule.ts
|
|
37
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
38
|
-
'hr[data-drag-handler-anchor-name]': {
|
|
39
|
-
overflow: 'visible'
|
|
40
|
-
},
|
|
41
|
-
//eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
42
|
-
'[data-blocks-drag-handle-container="true"] + *::after': {
|
|
43
|
-
display: 'none'
|
|
44
|
-
}
|
|
45
|
-
});
|
|
19
|
+
var _css;
|
|
20
|
+
return css((_css = {}, _defineProperty(_css, ".block-ctrl-drag-preview ".concat(dragHandlerAnchorSelector, "::after"), {
|
|
21
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
|
|
22
|
+
display: 'none !important'
|
|
23
|
+
}), _defineProperty(_css, '.ProseMirror', _defineProperty({}, "&& ".concat(dragHandlerAnchorSelector, "::after"), {
|
|
24
|
+
content: '""',
|
|
25
|
+
position: 'absolute',
|
|
26
|
+
top: 0,
|
|
27
|
+
left: '-100%',
|
|
28
|
+
width: '100%',
|
|
29
|
+
height: '100%',
|
|
30
|
+
background: 'transparent',
|
|
31
|
+
cursor: 'default',
|
|
32
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
33
|
+
zIndex: -1
|
|
34
|
+
})), _defineProperty(_css, 'hr[data-drag-handler-anchor-name]', {
|
|
35
|
+
overflow: 'visible'
|
|
36
|
+
}), _defineProperty(_css, '[data-blocks-drag-handle-container="true"] + *::after', {
|
|
37
|
+
display: 'none'
|
|
38
|
+
}), _css));
|
|
46
39
|
};
|
|
47
40
|
var extendedHoverZoneNested = function extendedHoverZoneNested() {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
left: 0,
|
|
103
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
104
|
-
width: '100%',
|
|
105
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
106
|
-
height: "".concat(DRAG_HANDLE_WIDTH, "px"),
|
|
107
|
-
cursor: 'default',
|
|
108
|
-
zIndex: 1
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
// TODO - ED-23995 this style override needs to be moved to the Rule styles after FF cleanup - packages/editor/editor-common/src/styles/shared/rule.ts
|
|
112
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
113
|
-
'hr[data-drag-handler-anchor-name]': {
|
|
114
|
-
overflow: 'visible'
|
|
115
|
-
},
|
|
116
|
-
//Hide pseudo element at top depth level. Leave for nested depths to prevent mouseover loop.
|
|
117
|
-
//eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
118
|
-
'[data-blocks-drag-handle-container="true"] + [data-drag-handler-anchor-depth="0"]::after': {
|
|
119
|
-
display: 'none'
|
|
120
|
-
}
|
|
121
|
-
});
|
|
41
|
+
var _ProseMirror2, _css2;
|
|
42
|
+
return css((_css2 = {}, _defineProperty(_css2, ".block-ctrl-drag-preview ".concat(dragHandlerAnchorSelector, "::after"), {
|
|
43
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
|
|
44
|
+
display: 'none !important'
|
|
45
|
+
}), _defineProperty(_css2, '.ProseMirror', (_ProseMirror2 = {}, _defineProperty(_ProseMirror2, "&& ".concat(dragHandlerAnchorSelector, "::after"), {
|
|
46
|
+
content: '""',
|
|
47
|
+
position: 'absolute',
|
|
48
|
+
top: 0,
|
|
49
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
50
|
+
left: "-".concat(DRAG_HANDLE_MAX_WIDTH_PLUS_GAP, "px"),
|
|
51
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
52
|
+
width: "".concat(DRAG_HANDLE_MAX_WIDTH_PLUS_GAP, "px"),
|
|
53
|
+
height: '100%',
|
|
54
|
+
cursor: 'default',
|
|
55
|
+
zIndex: 1
|
|
56
|
+
}), _defineProperty(_ProseMirror2, "&& [data-drag-handler-anchor-depth=\"0\"]".concat(dragHandlerAnchorSelector, "::after"), {
|
|
57
|
+
content: '""',
|
|
58
|
+
position: 'absolute',
|
|
59
|
+
top: 0,
|
|
60
|
+
left: '-100%',
|
|
61
|
+
width: '100%',
|
|
62
|
+
height: '100%',
|
|
63
|
+
cursor: 'default',
|
|
64
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
65
|
+
zIndex: -1
|
|
66
|
+
}), _defineProperty(_ProseMirror2, "&& :is(.pm-table-cell-content-wrap, .pm-table-header-content-wrap) > ".concat(dragHandlerAnchorSelector, "::after"), {
|
|
67
|
+
content: '""',
|
|
68
|
+
position: 'absolute',
|
|
69
|
+
top: 0,
|
|
70
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
71
|
+
left: "-".concat(editorExperiment('table-nested-dnd', true) ? DRAG_HANDLE_MAX_WIDTH_PLUS_GAP : 0, "px"),
|
|
72
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
73
|
+
width: "".concat(editorExperiment('table-nested-dnd', true) ? DRAG_HANDLE_MAX_WIDTH_PLUS_GAP : 0, "px"),
|
|
74
|
+
height: '100%',
|
|
75
|
+
cursor: 'default',
|
|
76
|
+
zIndex: 1
|
|
77
|
+
}), _defineProperty(_ProseMirror2, '&& [data-drag-handler-anchor-name][data-layout-column]::after', {
|
|
78
|
+
content: '""',
|
|
79
|
+
position: 'absolute',
|
|
80
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
81
|
+
top: "".concat(-DRAG_HANDLE_WIDTH / 2, "px"),
|
|
82
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
83
|
+
left: 0,
|
|
84
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
85
|
+
width: '100%',
|
|
86
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
87
|
+
height: "".concat(DRAG_HANDLE_WIDTH, "px"),
|
|
88
|
+
cursor: 'default',
|
|
89
|
+
zIndex: 1
|
|
90
|
+
}), _ProseMirror2)), _defineProperty(_css2, 'hr[data-drag-handler-anchor-name]', {
|
|
91
|
+
overflow: 'visible'
|
|
92
|
+
}), _defineProperty(_css2, '[data-blocks-drag-handle-container="true"] + [data-drag-handler-anchor-depth="0"]::after', {
|
|
93
|
+
display: 'none'
|
|
94
|
+
}), _css2));
|
|
122
95
|
};
|
|
123
96
|
var paragraphWithTrailingBreakAsOnlyChild = '+ :is(p, h1, h2, h3, h4, h5, h6) > .ProseMirror-trailingBreak:only-child';
|
|
124
97
|
var indentatedParagraphWithTrailingBreakAsOnlyChild = '+ div.fabric-editor-indentation-mark > :is(p, h1, h2, h3, h4, h5, h6) > .ProseMirror-trailingBreak:only-child';
|
|
@@ -203,21 +176,15 @@ var getTextNodeStyle = function getTextNodeStyle() {
|
|
|
203
176
|
};
|
|
204
177
|
var withRelativePosStyle = css({
|
|
205
178
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
206
|
-
'.ProseMirror': {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
position: 'relative'
|
|
210
|
-
}
|
|
211
|
-
}
|
|
179
|
+
'.ProseMirror': _defineProperty({}, "&& ".concat(dragHandlerAnchorSelector), {
|
|
180
|
+
position: 'relative'
|
|
181
|
+
})
|
|
212
182
|
});
|
|
213
183
|
var withAnchorNameZindexStyle = css({
|
|
214
184
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
215
|
-
'.ProseMirror': {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
zIndex: 1
|
|
219
|
-
}
|
|
220
|
-
}
|
|
185
|
+
'.ProseMirror': _defineProperty({}, "&& ".concat(dragHandlerAnchorSelector), {
|
|
186
|
+
zIndex: 1
|
|
187
|
+
})
|
|
221
188
|
});
|
|
222
189
|
var withAnchorNameZindexNestedStyle = css({
|
|
223
190
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
@@ -230,8 +197,6 @@ var withAnchorNameZindexNestedStyle = css({
|
|
|
230
197
|
});
|
|
231
198
|
export var GlobalStylesWrapper = function GlobalStylesWrapper() {
|
|
232
199
|
return jsx(Global, {
|
|
233
|
-
styles: [globalStyles(), editorExperiment('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), getTextNodeStyle(), withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, editorExperiment('
|
|
234
|
-
exposure: false
|
|
235
|
-
}) ? emptyBlockExperimentGlobalStyles : undefined, fg('platform_editor_element_dnd_nested_fix_patch_1') ? withDividerInPanelStyleFix : undefined, 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]
|
|
200
|
+
styles: [globalStyles(), editorExperiment('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), getTextNodeStyle(), withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, fg('platform_editor_element_dnd_nested_fix_patch_1') ? withDividerInPanelStyleFix : undefined, 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]
|
|
236
201
|
});
|
|
237
202
|
};
|
package/dist/types/consts.d.ts
CHANGED