@atlaskit/editor-plugin-block-controls 3.18.0 → 3.19.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
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 3.19.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#170348](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/170348)
|
|
8
|
+
[`8f9510a71c843`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8f9510a71c843) -
|
|
9
|
+
ED-28158 implement active advanced layout drop targets
|
|
10
|
+
|
|
3
11
|
## 3.18.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
|
@@ -11,6 +11,7 @@ var _decorationsCommon = require("./decorations-common");
|
|
|
11
11
|
var _decorationsDropTarget = require("./decorations-drop-target");
|
|
12
12
|
var _decorationsFindSurroundingNodes = require("./decorations-find-surrounding-nodes");
|
|
13
13
|
var _activeAnchorTracker = require("./utils/active-anchor-tracker");
|
|
14
|
+
var _consts = require("./utils/consts");
|
|
14
15
|
var _validation = require("./utils/validation");
|
|
15
16
|
/**
|
|
16
17
|
* List of parent node types that can have child nodes
|
|
@@ -134,6 +135,10 @@ var getActiveDropTargetDecorations = exports.getActiveDropTargetDecorations = fu
|
|
|
134
135
|
}, nodeViewPortalProviderAPI, -1, undefined, isSameLayout));
|
|
135
136
|
}
|
|
136
137
|
}
|
|
138
|
+
var rootNodeWithPos = {
|
|
139
|
+
node: node,
|
|
140
|
+
pos: pos
|
|
141
|
+
};
|
|
137
142
|
|
|
138
143
|
// if the current node is not a top level node, we create one for advanced layout drop targets
|
|
139
144
|
if (depth > 1) {
|
|
@@ -146,9 +151,30 @@ var getActiveDropTargetDecorations = exports.getActiveDropTargetDecorations = fu
|
|
|
146
151
|
formatMessage: formatMessage,
|
|
147
152
|
dropTargetStyle: 'default'
|
|
148
153
|
}, nodeViewPortalProviderAPI, 0, undefined, false));
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
154
|
+
rootNodeWithPos = {
|
|
155
|
+
node: root.node,
|
|
156
|
+
pos: root.pos
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
if ((0, _experiments.editorExperiment)('advanced_layouts', true)) {
|
|
160
|
+
var _isSameLayout = $activeNodePos && (0, _validation.isInSameLayout)($activeNodePos, state.doc.resolve(rootNodeWithPos.pos));
|
|
161
|
+
if (rootNodeWithPos.node.type.name === 'layoutSection') {
|
|
162
|
+
var layoutSectionNode = rootNodeWithPos.node;
|
|
163
|
+
if (layoutSectionNode.childCount < (0, _consts.maxLayoutColumnSupported)() || _isSameLayout) {
|
|
164
|
+
layoutSectionNode.descendants(function (childNode, childPos, parent, index) {
|
|
165
|
+
if (childNode.type.name === 'layoutColumn' && (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'layoutSection' && index !== 0 // Not the first node
|
|
166
|
+
) {
|
|
167
|
+
decs.push((0, _decorationsDropTarget.createLayoutDropTargetDecoration)(rootNodeWithPos.pos + childPos + 1, {
|
|
168
|
+
api: api,
|
|
169
|
+
parent: parent,
|
|
170
|
+
formatMessage: formatMessage
|
|
171
|
+
}, nodeViewPortalProviderAPI, undefined));
|
|
172
|
+
}
|
|
173
|
+
return false;
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
152
177
|
}
|
|
178
|
+
_activeAnchorTracker.defaultActiveAnchorTracker.emit((0, _decorationsCommon.getNodeAnchor)(rootNodeWithPos.node));
|
|
153
179
|
return decs;
|
|
154
180
|
};
|
|
@@ -2,9 +2,10 @@ import { expandSelectionBounds } from '@atlaskit/editor-common/selection';
|
|
|
2
2
|
import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
3
3
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
4
4
|
import { getNodeAnchor, unmountDecorations } from './decorations-common';
|
|
5
|
-
import { createDropTargetDecoration } from './decorations-drop-target';
|
|
5
|
+
import { createDropTargetDecoration, createLayoutDropTargetDecoration } from './decorations-drop-target';
|
|
6
6
|
import { findSurroundingNodes } from './decorations-find-surrounding-nodes';
|
|
7
7
|
import { defaultActiveAnchorTracker } from './utils/active-anchor-tracker';
|
|
8
|
+
import { maxLayoutColumnSupported } from './utils/consts';
|
|
8
9
|
import { canMoveNodeToIndex, canMoveSliceToIndex, isInSameLayout } from './utils/validation';
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -131,6 +132,10 @@ export const getActiveDropTargetDecorations = (activeDropTargetNode, state, api,
|
|
|
131
132
|
}, nodeViewPortalProviderAPI, -1, undefined, isSameLayout));
|
|
132
133
|
}
|
|
133
134
|
}
|
|
135
|
+
let rootNodeWithPos = {
|
|
136
|
+
node,
|
|
137
|
+
pos
|
|
138
|
+
};
|
|
134
139
|
|
|
135
140
|
// if the current node is not a top level node, we create one for advanced layout drop targets
|
|
136
141
|
if (depth > 1) {
|
|
@@ -143,9 +148,30 @@ export const getActiveDropTargetDecorations = (activeDropTargetNode, state, api,
|
|
|
143
148
|
formatMessage,
|
|
144
149
|
dropTargetStyle: 'default'
|
|
145
150
|
}, nodeViewPortalProviderAPI, 0, undefined, false));
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
151
|
+
rootNodeWithPos = {
|
|
152
|
+
node: root.node,
|
|
153
|
+
pos: root.pos
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
if (editorExperiment('advanced_layouts', true)) {
|
|
157
|
+
const isSameLayout = $activeNodePos && isInSameLayout($activeNodePos, state.doc.resolve(rootNodeWithPos.pos));
|
|
158
|
+
if (rootNodeWithPos.node.type.name === 'layoutSection') {
|
|
159
|
+
const layoutSectionNode = rootNodeWithPos.node;
|
|
160
|
+
if (layoutSectionNode.childCount < maxLayoutColumnSupported() || isSameLayout) {
|
|
161
|
+
layoutSectionNode.descendants((childNode, childPos, parent, index) => {
|
|
162
|
+
if (childNode.type.name === 'layoutColumn' && (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'layoutSection' && index !== 0 // Not the first node
|
|
163
|
+
) {
|
|
164
|
+
decs.push(createLayoutDropTargetDecoration(rootNodeWithPos.pos + childPos + 1, {
|
|
165
|
+
api,
|
|
166
|
+
parent,
|
|
167
|
+
formatMessage
|
|
168
|
+
}, nodeViewPortalProviderAPI, undefined));
|
|
169
|
+
}
|
|
170
|
+
return false;
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
149
174
|
}
|
|
175
|
+
defaultActiveAnchorTracker.emit(getNodeAnchor(rootNodeWithPos.node));
|
|
150
176
|
return decs;
|
|
151
177
|
};
|
|
@@ -2,9 +2,10 @@ import { expandSelectionBounds } from '@atlaskit/editor-common/selection';
|
|
|
2
2
|
import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
3
3
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
4
4
|
import { getNodeAnchor, unmountDecorations } from './decorations-common';
|
|
5
|
-
import { createDropTargetDecoration } from './decorations-drop-target';
|
|
5
|
+
import { createDropTargetDecoration, createLayoutDropTargetDecoration } from './decorations-drop-target';
|
|
6
6
|
import { findSurroundingNodes } from './decorations-find-surrounding-nodes';
|
|
7
7
|
import { defaultActiveAnchorTracker } from './utils/active-anchor-tracker';
|
|
8
|
+
import { maxLayoutColumnSupported } from './utils/consts';
|
|
8
9
|
import { canMoveNodeToIndex, canMoveSliceToIndex, isInSameLayout } from './utils/validation';
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -129,6 +130,10 @@ export var getActiveDropTargetDecorations = function getActiveDropTargetDecorati
|
|
|
129
130
|
}, nodeViewPortalProviderAPI, -1, undefined, isSameLayout));
|
|
130
131
|
}
|
|
131
132
|
}
|
|
133
|
+
var rootNodeWithPos = {
|
|
134
|
+
node: node,
|
|
135
|
+
pos: pos
|
|
136
|
+
};
|
|
132
137
|
|
|
133
138
|
// if the current node is not a top level node, we create one for advanced layout drop targets
|
|
134
139
|
if (depth > 1) {
|
|
@@ -141,9 +146,30 @@ export var getActiveDropTargetDecorations = function getActiveDropTargetDecorati
|
|
|
141
146
|
formatMessage: formatMessage,
|
|
142
147
|
dropTargetStyle: 'default'
|
|
143
148
|
}, nodeViewPortalProviderAPI, 0, undefined, false));
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
149
|
+
rootNodeWithPos = {
|
|
150
|
+
node: root.node,
|
|
151
|
+
pos: root.pos
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
if (editorExperiment('advanced_layouts', true)) {
|
|
155
|
+
var _isSameLayout = $activeNodePos && isInSameLayout($activeNodePos, state.doc.resolve(rootNodeWithPos.pos));
|
|
156
|
+
if (rootNodeWithPos.node.type.name === 'layoutSection') {
|
|
157
|
+
var layoutSectionNode = rootNodeWithPos.node;
|
|
158
|
+
if (layoutSectionNode.childCount < maxLayoutColumnSupported() || _isSameLayout) {
|
|
159
|
+
layoutSectionNode.descendants(function (childNode, childPos, parent, index) {
|
|
160
|
+
if (childNode.type.name === 'layoutColumn' && (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'layoutSection' && index !== 0 // Not the first node
|
|
161
|
+
) {
|
|
162
|
+
decs.push(createLayoutDropTargetDecoration(rootNodeWithPos.pos + childPos + 1, {
|
|
163
|
+
api: api,
|
|
164
|
+
parent: parent,
|
|
165
|
+
formatMessage: formatMessage
|
|
166
|
+
}, nodeViewPortalProviderAPI, undefined));
|
|
167
|
+
}
|
|
168
|
+
return false;
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}
|
|
147
172
|
}
|
|
173
|
+
defaultActiveAnchorTracker.emit(getNodeAnchor(rootNodeWithPos.node));
|
|
148
174
|
return decs;
|
|
149
175
|
};
|