@atlaskit/editor-plugin-block-controls 2.15.6 → 2.15.8
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 +17 -0
- package/dist/cjs/editor-commands/move-to-layout.js +34 -16
- package/dist/cjs/pm-plugins/main.js +2 -6
- package/dist/es2019/editor-commands/move-to-layout.js +20 -1
- package/dist/es2019/pm-plugins/main.js +2 -6
- package/dist/esm/editor-commands/move-to-layout.js +34 -16
- package/dist/esm/pm-plugins/main.js +2 -6
- package/dist/types/pm-plugins/main.d.ts +0 -1
- package/dist/types-ts4.5/pm-plugins/main.d.ts +0 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 2.15.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#177496](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/177496)
|
|
8
|
+
[`dfb96360f8958`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/dfb96360f8958) -
|
|
9
|
+
Remove optimise-apply-dnd experiment
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 2.15.7
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#178258](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/178258)
|
|
17
|
+
[`89f4f17d79f0e`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/89f4f17d79f0e) -
|
|
18
|
+
ED-26037 fix insert nested node to layout
|
|
19
|
+
|
|
3
20
|
## 2.15.6
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -54,7 +54,7 @@ var moveToExistingLayout = function moveToExistingLayout(toLayout, toLayoutPos,
|
|
|
54
54
|
var _$originalFrom$nodeAf2;
|
|
55
55
|
if ((0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
56
56
|
(0, _removeFromSource.removeFromSource)(tr, tr.doc.resolve(from));
|
|
57
|
-
|
|
57
|
+
insertToDestinationNoWidthUpdate(tr, tr.mapping.map(to), sourceNode);
|
|
58
58
|
} else {
|
|
59
59
|
insertToDestination(tr, to, sourceNode, toLayout, toLayoutPos);
|
|
60
60
|
var mappedFrom = tr.mapping.map(from);
|
|
@@ -64,11 +64,29 @@ var moveToExistingLayout = function moveToExistingLayout(toLayout, toLayoutPos,
|
|
|
64
64
|
}
|
|
65
65
|
return tr;
|
|
66
66
|
};
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* This function is similar to insertToDestination
|
|
70
|
+
* But without update width step, mainly rely on the append transaction from layout.
|
|
71
|
+
* @param tr
|
|
72
|
+
* @param to
|
|
73
|
+
* @param sourceNode
|
|
74
|
+
* @returns
|
|
75
|
+
*/
|
|
76
|
+
var insertToDestinationNoWidthUpdate = function insertToDestinationNoWidthUpdate(tr, to, sourceNode) {
|
|
77
|
+
var _ref2 = tr.doc.type.schema.nodes || {},
|
|
78
|
+
layoutColumn = _ref2.layoutColumn;
|
|
79
|
+
var content = layoutColumn.createChecked({
|
|
80
|
+
width: 0
|
|
81
|
+
}, sourceNode.type.name === 'layoutColumn' ? sourceNode.content : sourceNode);
|
|
82
|
+
tr.insert(to, content);
|
|
83
|
+
return tr;
|
|
84
|
+
};
|
|
67
85
|
var insertToDestination = function insertToDestination(tr, to, sourceNode, toLayout, toLayoutPos) {
|
|
68
|
-
var
|
|
69
|
-
newColumnWidth =
|
|
70
|
-
var
|
|
71
|
-
layoutColumn =
|
|
86
|
+
var _ref3 = (0, _updateColumnWidths.updateColumnWidths)(tr, toLayout, toLayoutPos, toLayout.childCount + 1) || {},
|
|
87
|
+
newColumnWidth = _ref3.newColumnWidth;
|
|
88
|
+
var _ref4 = tr.doc.type.schema.nodes || {},
|
|
89
|
+
layoutColumn = _ref4.layoutColumn;
|
|
72
90
|
var content = layoutColumn.createChecked({
|
|
73
91
|
width: newColumnWidth
|
|
74
92
|
}, sourceNode.type.name === 'layoutColumn' ? sourceNode.content : sourceNode);
|
|
@@ -87,10 +105,10 @@ var canMoveToLayout = function canMoveToLayout(from, to, tr) {
|
|
|
87
105
|
if (from === to) {
|
|
88
106
|
return;
|
|
89
107
|
}
|
|
90
|
-
var
|
|
91
|
-
layoutSection =
|
|
92
|
-
layoutColumn =
|
|
93
|
-
doc =
|
|
108
|
+
var _ref5 = tr.doc.type.schema.nodes || {},
|
|
109
|
+
layoutSection = _ref5.layoutSection,
|
|
110
|
+
layoutColumn = _ref5.layoutColumn,
|
|
111
|
+
doc = _ref5.doc;
|
|
94
112
|
|
|
95
113
|
// layout plugin does not exist
|
|
96
114
|
if (!layoutSection || !layoutColumn) {
|
|
@@ -119,8 +137,8 @@ var canMoveToLayout = function canMoveToLayout(from, to, tr) {
|
|
|
119
137
|
};
|
|
120
138
|
var moveToLayout = exports.moveToLayout = function moveToLayout(api) {
|
|
121
139
|
return function (from, to, options) {
|
|
122
|
-
return function (
|
|
123
|
-
var tr =
|
|
140
|
+
return function (_ref6) {
|
|
141
|
+
var tr = _ref6.tr;
|
|
124
142
|
var canMove = canMoveToLayout(from, to, tr);
|
|
125
143
|
if (!canMove) {
|
|
126
144
|
return tr;
|
|
@@ -129,11 +147,11 @@ var moveToLayout = exports.moveToLayout = function moveToLayout(api) {
|
|
|
129
147
|
fromNode = canMove.fromNode,
|
|
130
148
|
$from = canMove.$from,
|
|
131
149
|
$to = canMove.$to;
|
|
132
|
-
var
|
|
133
|
-
layoutSection =
|
|
134
|
-
layoutColumn =
|
|
135
|
-
var
|
|
136
|
-
breakout =
|
|
150
|
+
var _ref7 = tr.doc.type.schema.nodes || {},
|
|
151
|
+
layoutSection = _ref7.layoutSection,
|
|
152
|
+
layoutColumn = _ref7.layoutColumn;
|
|
153
|
+
var _ref8 = tr.doc.type.schema.marks || {},
|
|
154
|
+
breakout = _ref8.breakout;
|
|
137
155
|
var fromNodeWithoutBreakout = fromNode;
|
|
138
156
|
var getBreakoutMode = function getBreakoutMode(node) {
|
|
139
157
|
var _node$marks$find;
|
|
@@ -430,12 +430,8 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
|
|
|
430
430
|
var isAdvancedLayoutEnabled = (0, _experiments.editorExperiment)('advanced_layouts', true, {
|
|
431
431
|
exposure: true
|
|
432
432
|
});
|
|
433
|
-
var isOptimisedApply = isNestedEnabled && (0, _experiments.editorExperiment)('optimised-apply-dnd', true, {
|
|
434
|
-
exposure: true
|
|
435
|
-
});
|
|
436
433
|
var flags = {
|
|
437
|
-
isNestedEnabled: isNestedEnabled
|
|
438
|
-
isOptimisedApply: isOptimisedApply
|
|
434
|
+
isNestedEnabled: isNestedEnabled
|
|
439
435
|
};
|
|
440
436
|
var anchorRectCache;
|
|
441
437
|
if (!(0, _anchorUtils.isAnchorSupported)() && (0, _platformFeatureFlags.fg)('platform_editor_drag_and_drop_target_v2')) {
|
|
@@ -448,7 +444,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
|
|
|
448
444
|
return initialState;
|
|
449
445
|
},
|
|
450
446
|
apply: function apply(tr, currentState, oldState, newState) {
|
|
451
|
-
if (
|
|
447
|
+
if (isNestedEnabled) {
|
|
452
448
|
return newApply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, anchorRectCache);
|
|
453
449
|
}
|
|
454
450
|
return oldApply(api, formatMessage, tr, currentState, oldState, newState, flags, nodeViewPortalProviderAPI, anchorRectCache);
|
|
@@ -49,7 +49,7 @@ const moveToExistingLayout = (toLayout, toLayoutPos, sourceNode, from, to, tr, $
|
|
|
49
49
|
var _$originalFrom$nodeAf2;
|
|
50
50
|
if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
51
51
|
removeFromSource(tr, tr.doc.resolve(from));
|
|
52
|
-
|
|
52
|
+
insertToDestinationNoWidthUpdate(tr, tr.mapping.map(to), sourceNode);
|
|
53
53
|
} else {
|
|
54
54
|
insertToDestination(tr, to, sourceNode, toLayout, toLayoutPos);
|
|
55
55
|
const mappedFrom = tr.mapping.map(from);
|
|
@@ -59,6 +59,25 @@ const moveToExistingLayout = (toLayout, toLayoutPos, sourceNode, from, to, tr, $
|
|
|
59
59
|
}
|
|
60
60
|
return tr;
|
|
61
61
|
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* This function is similar to insertToDestination
|
|
65
|
+
* But without update width step, mainly rely on the append transaction from layout.
|
|
66
|
+
* @param tr
|
|
67
|
+
* @param to
|
|
68
|
+
* @param sourceNode
|
|
69
|
+
* @returns
|
|
70
|
+
*/
|
|
71
|
+
const insertToDestinationNoWidthUpdate = (tr, to, sourceNode) => {
|
|
72
|
+
const {
|
|
73
|
+
layoutColumn
|
|
74
|
+
} = tr.doc.type.schema.nodes || {};
|
|
75
|
+
const content = layoutColumn.createChecked({
|
|
76
|
+
width: 0
|
|
77
|
+
}, sourceNode.type.name === 'layoutColumn' ? sourceNode.content : sourceNode);
|
|
78
|
+
tr.insert(to, content);
|
|
79
|
+
return tr;
|
|
80
|
+
};
|
|
62
81
|
const insertToDestination = (tr, to, sourceNode, toLayout, toLayoutPos) => {
|
|
63
82
|
const {
|
|
64
83
|
newColumnWidth
|
|
@@ -405,12 +405,8 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI) => {
|
|
|
405
405
|
const isAdvancedLayoutEnabled = editorExperiment('advanced_layouts', true, {
|
|
406
406
|
exposure: true
|
|
407
407
|
});
|
|
408
|
-
const isOptimisedApply = isNestedEnabled && editorExperiment('optimised-apply-dnd', true, {
|
|
409
|
-
exposure: true
|
|
410
|
-
});
|
|
411
408
|
const flags = {
|
|
412
|
-
isNestedEnabled
|
|
413
|
-
isOptimisedApply
|
|
409
|
+
isNestedEnabled
|
|
414
410
|
};
|
|
415
411
|
let anchorRectCache;
|
|
416
412
|
if (!isAnchorSupported() && fg('platform_editor_drag_and_drop_target_v2')) {
|
|
@@ -423,7 +419,7 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI) => {
|
|
|
423
419
|
return initialState;
|
|
424
420
|
},
|
|
425
421
|
apply(tr, currentState, oldState, newState) {
|
|
426
|
-
if (
|
|
422
|
+
if (isNestedEnabled) {
|
|
427
423
|
return newApply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, anchorRectCache);
|
|
428
424
|
}
|
|
429
425
|
return oldApply(api, formatMessage, tr, currentState, oldState, newState, flags, nodeViewPortalProviderAPI, anchorRectCache);
|
|
@@ -48,7 +48,7 @@ var moveToExistingLayout = function moveToExistingLayout(toLayout, toLayoutPos,
|
|
|
48
48
|
var _$originalFrom$nodeAf2;
|
|
49
49
|
if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
50
50
|
removeFromSource(tr, tr.doc.resolve(from));
|
|
51
|
-
|
|
51
|
+
insertToDestinationNoWidthUpdate(tr, tr.mapping.map(to), sourceNode);
|
|
52
52
|
} else {
|
|
53
53
|
insertToDestination(tr, to, sourceNode, toLayout, toLayoutPos);
|
|
54
54
|
var mappedFrom = tr.mapping.map(from);
|
|
@@ -58,11 +58,29 @@ var moveToExistingLayout = function moveToExistingLayout(toLayout, toLayoutPos,
|
|
|
58
58
|
}
|
|
59
59
|
return tr;
|
|
60
60
|
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* This function is similar to insertToDestination
|
|
64
|
+
* But without update width step, mainly rely on the append transaction from layout.
|
|
65
|
+
* @param tr
|
|
66
|
+
* @param to
|
|
67
|
+
* @param sourceNode
|
|
68
|
+
* @returns
|
|
69
|
+
*/
|
|
70
|
+
var insertToDestinationNoWidthUpdate = function insertToDestinationNoWidthUpdate(tr, to, sourceNode) {
|
|
71
|
+
var _ref2 = tr.doc.type.schema.nodes || {},
|
|
72
|
+
layoutColumn = _ref2.layoutColumn;
|
|
73
|
+
var content = layoutColumn.createChecked({
|
|
74
|
+
width: 0
|
|
75
|
+
}, sourceNode.type.name === 'layoutColumn' ? sourceNode.content : sourceNode);
|
|
76
|
+
tr.insert(to, content);
|
|
77
|
+
return tr;
|
|
78
|
+
};
|
|
61
79
|
var insertToDestination = function insertToDestination(tr, to, sourceNode, toLayout, toLayoutPos) {
|
|
62
|
-
var
|
|
63
|
-
newColumnWidth =
|
|
64
|
-
var
|
|
65
|
-
layoutColumn =
|
|
80
|
+
var _ref3 = updateColumnWidths(tr, toLayout, toLayoutPos, toLayout.childCount + 1) || {},
|
|
81
|
+
newColumnWidth = _ref3.newColumnWidth;
|
|
82
|
+
var _ref4 = tr.doc.type.schema.nodes || {},
|
|
83
|
+
layoutColumn = _ref4.layoutColumn;
|
|
66
84
|
var content = layoutColumn.createChecked({
|
|
67
85
|
width: newColumnWidth
|
|
68
86
|
}, sourceNode.type.name === 'layoutColumn' ? sourceNode.content : sourceNode);
|
|
@@ -81,10 +99,10 @@ var canMoveToLayout = function canMoveToLayout(from, to, tr) {
|
|
|
81
99
|
if (from === to) {
|
|
82
100
|
return;
|
|
83
101
|
}
|
|
84
|
-
var
|
|
85
|
-
layoutSection =
|
|
86
|
-
layoutColumn =
|
|
87
|
-
doc =
|
|
102
|
+
var _ref5 = tr.doc.type.schema.nodes || {},
|
|
103
|
+
layoutSection = _ref5.layoutSection,
|
|
104
|
+
layoutColumn = _ref5.layoutColumn,
|
|
105
|
+
doc = _ref5.doc;
|
|
88
106
|
|
|
89
107
|
// layout plugin does not exist
|
|
90
108
|
if (!layoutSection || !layoutColumn) {
|
|
@@ -113,8 +131,8 @@ var canMoveToLayout = function canMoveToLayout(from, to, tr) {
|
|
|
113
131
|
};
|
|
114
132
|
export var moveToLayout = function moveToLayout(api) {
|
|
115
133
|
return function (from, to, options) {
|
|
116
|
-
return function (
|
|
117
|
-
var tr =
|
|
134
|
+
return function (_ref6) {
|
|
135
|
+
var tr = _ref6.tr;
|
|
118
136
|
var canMove = canMoveToLayout(from, to, tr);
|
|
119
137
|
if (!canMove) {
|
|
120
138
|
return tr;
|
|
@@ -123,11 +141,11 @@ export var moveToLayout = function moveToLayout(api) {
|
|
|
123
141
|
fromNode = canMove.fromNode,
|
|
124
142
|
$from = canMove.$from,
|
|
125
143
|
$to = canMove.$to;
|
|
126
|
-
var
|
|
127
|
-
layoutSection =
|
|
128
|
-
layoutColumn =
|
|
129
|
-
var
|
|
130
|
-
breakout =
|
|
144
|
+
var _ref7 = tr.doc.type.schema.nodes || {},
|
|
145
|
+
layoutSection = _ref7.layoutSection,
|
|
146
|
+
layoutColumn = _ref7.layoutColumn;
|
|
147
|
+
var _ref8 = tr.doc.type.schema.marks || {},
|
|
148
|
+
breakout = _ref8.breakout;
|
|
131
149
|
var fromNodeWithoutBreakout = fromNode;
|
|
132
150
|
var getBreakoutMode = function getBreakoutMode(node) {
|
|
133
151
|
var _node$marks$find;
|
|
@@ -423,12 +423,8 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
423
423
|
var isAdvancedLayoutEnabled = editorExperiment('advanced_layouts', true, {
|
|
424
424
|
exposure: true
|
|
425
425
|
});
|
|
426
|
-
var isOptimisedApply = isNestedEnabled && editorExperiment('optimised-apply-dnd', true, {
|
|
427
|
-
exposure: true
|
|
428
|
-
});
|
|
429
426
|
var flags = {
|
|
430
|
-
isNestedEnabled: isNestedEnabled
|
|
431
|
-
isOptimisedApply: isOptimisedApply
|
|
427
|
+
isNestedEnabled: isNestedEnabled
|
|
432
428
|
};
|
|
433
429
|
var anchorRectCache;
|
|
434
430
|
if (!isAnchorSupported() && fg('platform_editor_drag_and_drop_target_v2')) {
|
|
@@ -441,7 +437,7 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
441
437
|
return initialState;
|
|
442
438
|
},
|
|
443
439
|
apply: function apply(tr, currentState, oldState, newState) {
|
|
444
|
-
if (
|
|
440
|
+
if (isNestedEnabled) {
|
|
445
441
|
return newApply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, anchorRectCache);
|
|
446
442
|
}
|
|
447
443
|
return oldApply(api, formatMessage, tr, currentState, oldState, newState, flags, nodeViewPortalProviderAPI, anchorRectCache);
|
|
@@ -10,7 +10,6 @@ import { AnchorRectCache } from './utils/anchor-utils';
|
|
|
10
10
|
export declare const key: PluginKey<PluginState>;
|
|
11
11
|
export interface FlagType {
|
|
12
12
|
isNestedEnabled: boolean;
|
|
13
|
-
isOptimisedApply: boolean;
|
|
14
13
|
}
|
|
15
14
|
export declare const newApply: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, formatMessage: IntlShape['formatMessage'], tr: ReadonlyTransaction, currentState: PluginState, newState: EditorState, flags: FlagType, nodeViewPortalProviderAPI: PortalProviderAPI, anchorRectCache?: AnchorRectCache) => {
|
|
16
15
|
decorations: DecorationSet;
|
|
@@ -10,7 +10,6 @@ import { AnchorRectCache } from './utils/anchor-utils';
|
|
|
10
10
|
export declare const key: PluginKey<PluginState>;
|
|
11
11
|
export interface FlagType {
|
|
12
12
|
isNestedEnabled: boolean;
|
|
13
|
-
isOptimisedApply: boolean;
|
|
14
13
|
}
|
|
15
14
|
export declare const newApply: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, formatMessage: IntlShape['formatMessage'], tr: ReadonlyTransaction, currentState: PluginState, newState: EditorState, flags: FlagType, nodeViewPortalProviderAPI: PortalProviderAPI, anchorRectCache?: AnchorRectCache) => {
|
|
16
15
|
decorations: DecorationSet;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "2.15.
|
|
3
|
+
"version": "2.15.8",
|
|
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": "^96.
|
|
34
|
+
"@atlaskit/editor-common": "^96.5.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",
|
|
@@ -48,7 +48,7 @@
|
|
|
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.27.0",
|
|
52
52
|
"@atlaskit/tokens": "^2.4.0",
|
|
53
53
|
"@atlaskit/tooltip": "^19.0.0",
|
|
54
54
|
"@babel/runtime": "^7.0.0",
|