@atlaskit/editor-plugin-block-controls 1.4.33 → 1.4.34
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 +14 -0
- package/dist/cjs/pm-plugins/main.js +27 -13
- package/dist/es2019/pm-plugins/main.js +27 -13
- package/dist/esm/pm-plugins/main.js +27 -13
- package/dist/types/types.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 1.4.34
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#115110](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/115110)
|
|
8
|
+
[`cc8cc2bbe88f8`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/cc8cc2bbe88f8) -
|
|
9
|
+
Fix a regression where drag and drop a node at itself duplicates the node
|
|
10
|
+
- [#114841](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/114841)
|
|
11
|
+
[`2ea1a74c41971`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/2ea1a74c41971) -
|
|
12
|
+
Fix drag handle position when change from paragraph to blockQuote
|
|
13
|
+
- [#115110](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/115110)
|
|
14
|
+
[`bfa2f902f0cb3`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/bfa2f902f0cb3) -
|
|
15
|
+
change doc size limit to child count
|
|
16
|
+
|
|
3
17
|
## 1.4.33
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -78,13 +78,10 @@ var initialState = {
|
|
|
78
78
|
isMenuOpen: false,
|
|
79
79
|
editorHeight: 0,
|
|
80
80
|
isResizerResizing: false,
|
|
81
|
-
isDocSizeLimitEnabled:
|
|
81
|
+
isDocSizeLimitEnabled: null,
|
|
82
82
|
isPMDragging: false
|
|
83
83
|
};
|
|
84
|
-
|
|
85
|
-
initialState.isDocSizeLimitEnabled = true;
|
|
86
|
-
}
|
|
87
|
-
var DRAG_AND_DROP_DOC_SIZE_LIMIT = 20000;
|
|
84
|
+
var DRAG_AND_DROP_DOC_SIZE_LIMIT = 50;
|
|
88
85
|
var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
89
86
|
return new _safePlugin.SafePlugin({
|
|
90
87
|
key: key,
|
|
@@ -94,7 +91,14 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
94
91
|
},
|
|
95
92
|
apply: function apply(tr, currentState, oldState, newState) {
|
|
96
93
|
var _meta$activeNode, _meta$activeNode2, _meta$isDragging, _meta$editorHeight, _meta$isPMDragging;
|
|
97
|
-
if (initialState.isDocSizeLimitEnabled
|
|
94
|
+
if (initialState.isDocSizeLimitEnabled === null) {
|
|
95
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.elements.drag-and-drop-doc-size-limit_7k4vq')) {
|
|
96
|
+
initialState.isDocSizeLimitEnabled = true;
|
|
97
|
+
} else {
|
|
98
|
+
initialState.isDocSizeLimitEnabled = false;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (initialState.isDocSizeLimitEnabled && newState.doc.childCount > DRAG_AND_DROP_DOC_SIZE_LIMIT) {
|
|
98
102
|
return initialState;
|
|
99
103
|
}
|
|
100
104
|
var activeNode = currentState.activeNode,
|
|
@@ -166,10 +170,18 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
166
170
|
// Note: Quite often the handle is not in the right position after a node is moved
|
|
167
171
|
// it is safer for now to not show it when a node is moved
|
|
168
172
|
if (activeNode && !(meta !== null && meta !== void 0 && meta.nodeMoved) && !isDecsMissing) {
|
|
169
|
-
var
|
|
173
|
+
var mappedPosisiton = tr.mapping.map(activeNode.pos);
|
|
174
|
+
var prevMappedPos = oldState.tr.mapping.map(activeNode.pos);
|
|
175
|
+
|
|
176
|
+
// When a node type changed to be nested inside another node, the position of the active node is off by 1
|
|
177
|
+
// This is a workaround to fix the position of the active node when it is nested
|
|
178
|
+
if (mappedPosisiton === prevMappedPos + 1) {
|
|
179
|
+
mappedPosisiton = prevMappedPos;
|
|
180
|
+
}
|
|
181
|
+
var newActiveNode = tr.doc.nodeAt(mappedPosisiton);
|
|
170
182
|
var nodeType = activeNode.nodeType;
|
|
171
183
|
var anchorName = activeNode.anchorName;
|
|
172
|
-
if (newActiveNode && (newActiveNode === null || newActiveNode === void 0 ? void 0 : newActiveNode.type.name) !== activeNode.nodeType
|
|
184
|
+
if (newActiveNode && (newActiveNode === null || newActiveNode === void 0 ? void 0 : newActiveNode.type.name) !== activeNode.nodeType) {
|
|
173
185
|
nodeType = newActiveNode.type.name;
|
|
174
186
|
anchorName = activeNode.anchorName.replace(activeNode.nodeType, nodeType);
|
|
175
187
|
}
|
|
@@ -256,12 +268,12 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
256
268
|
},
|
|
257
269
|
handleDOMEvents: {
|
|
258
270
|
drop: function drop(view, event) {
|
|
259
|
-
var _pluginState$activeNo;
|
|
260
271
|
// prosemirror has sends a default transaction on drop (meta where uiEvent is 'drop'),
|
|
261
272
|
// this duplicates the an empty version of the node it was dropping,
|
|
262
273
|
// Adding some check here to prevent that if drop position is within activeNode
|
|
263
274
|
var state = view.state,
|
|
264
|
-
dispatch = view.dispatch
|
|
275
|
+
dispatch = view.dispatch,
|
|
276
|
+
dragging = view.dragging;
|
|
265
277
|
var pluginState = key.getState(state);
|
|
266
278
|
if (pluginState !== null && pluginState !== void 0 && pluginState.isPMDragging) {
|
|
267
279
|
dispatch(state.tr.setMeta(key, {
|
|
@@ -271,9 +283,11 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
271
283
|
if (!(event.target instanceof HTMLElement) || !(pluginState !== null && pluginState !== void 0 && pluginState.activeNode)) {
|
|
272
284
|
return false;
|
|
273
285
|
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
286
|
+
// Currently we can only drag one node at a time
|
|
287
|
+
// so we only need to check first child
|
|
288
|
+
var draggable = dragging === null || dragging === void 0 ? void 0 : dragging.slice.content.firstChild;
|
|
289
|
+
var activeNode = state.tr.doc.nodeAt(pluginState.activeNode.pos);
|
|
290
|
+
if (draggable === activeNode) {
|
|
277
291
|
// Prevent the default drop behavior if the position is within the activeNode
|
|
278
292
|
event.preventDefault();
|
|
279
293
|
return true;
|
|
@@ -72,13 +72,10 @@ const initialState = {
|
|
|
72
72
|
isMenuOpen: false,
|
|
73
73
|
editorHeight: 0,
|
|
74
74
|
isResizerResizing: false,
|
|
75
|
-
isDocSizeLimitEnabled:
|
|
75
|
+
isDocSizeLimitEnabled: null,
|
|
76
76
|
isPMDragging: false
|
|
77
77
|
};
|
|
78
|
-
|
|
79
|
-
initialState.isDocSizeLimitEnabled = true;
|
|
80
|
-
}
|
|
81
|
-
const DRAG_AND_DROP_DOC_SIZE_LIMIT = 20000;
|
|
78
|
+
const DRAG_AND_DROP_DOC_SIZE_LIMIT = 50;
|
|
82
79
|
export const createPlugin = api => {
|
|
83
80
|
return new SafePlugin({
|
|
84
81
|
key,
|
|
@@ -88,7 +85,14 @@ export const createPlugin = api => {
|
|
|
88
85
|
},
|
|
89
86
|
apply(tr, currentState, oldState, newState) {
|
|
90
87
|
var _meta$activeNode, _meta$activeNode2, _meta$isDragging, _meta$editorHeight, _meta$isPMDragging;
|
|
91
|
-
if (initialState.isDocSizeLimitEnabled
|
|
88
|
+
if (initialState.isDocSizeLimitEnabled === null) {
|
|
89
|
+
if (getBooleanFF('platform.editor.elements.drag-and-drop-doc-size-limit_7k4vq')) {
|
|
90
|
+
initialState.isDocSizeLimitEnabled = true;
|
|
91
|
+
} else {
|
|
92
|
+
initialState.isDocSizeLimitEnabled = false;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (initialState.isDocSizeLimitEnabled && newState.doc.childCount > DRAG_AND_DROP_DOC_SIZE_LIMIT) {
|
|
92
96
|
return initialState;
|
|
93
97
|
}
|
|
94
98
|
let {
|
|
@@ -157,10 +161,18 @@ export const createPlugin = api => {
|
|
|
157
161
|
// Note: Quite often the handle is not in the right position after a node is moved
|
|
158
162
|
// it is safer for now to not show it when a node is moved
|
|
159
163
|
if (activeNode && !(meta !== null && meta !== void 0 && meta.nodeMoved) && !isDecsMissing) {
|
|
160
|
-
|
|
164
|
+
let mappedPosisiton = tr.mapping.map(activeNode.pos);
|
|
165
|
+
const prevMappedPos = oldState.tr.mapping.map(activeNode.pos);
|
|
166
|
+
|
|
167
|
+
// When a node type changed to be nested inside another node, the position of the active node is off by 1
|
|
168
|
+
// This is a workaround to fix the position of the active node when it is nested
|
|
169
|
+
if (mappedPosisiton === prevMappedPos + 1) {
|
|
170
|
+
mappedPosisiton = prevMappedPos;
|
|
171
|
+
}
|
|
172
|
+
const newActiveNode = tr.doc.nodeAt(mappedPosisiton);
|
|
161
173
|
let nodeType = activeNode.nodeType;
|
|
162
174
|
let anchorName = activeNode.anchorName;
|
|
163
|
-
if (newActiveNode && (newActiveNode === null || newActiveNode === void 0 ? void 0 : newActiveNode.type.name) !== activeNode.nodeType
|
|
175
|
+
if (newActiveNode && (newActiveNode === null || newActiveNode === void 0 ? void 0 : newActiveNode.type.name) !== activeNode.nodeType) {
|
|
164
176
|
nodeType = newActiveNode.type.name;
|
|
165
177
|
anchorName = activeNode.anchorName.replace(activeNode.nodeType, nodeType);
|
|
166
178
|
}
|
|
@@ -247,13 +259,13 @@ export const createPlugin = api => {
|
|
|
247
259
|
},
|
|
248
260
|
handleDOMEvents: {
|
|
249
261
|
drop(view, event) {
|
|
250
|
-
var _pluginState$activeNo;
|
|
251
262
|
// prosemirror has sends a default transaction on drop (meta where uiEvent is 'drop'),
|
|
252
263
|
// this duplicates the an empty version of the node it was dropping,
|
|
253
264
|
// Adding some check here to prevent that if drop position is within activeNode
|
|
254
265
|
const {
|
|
255
266
|
state,
|
|
256
|
-
dispatch
|
|
267
|
+
dispatch,
|
|
268
|
+
dragging
|
|
257
269
|
} = view;
|
|
258
270
|
const pluginState = key.getState(state);
|
|
259
271
|
if (pluginState !== null && pluginState !== void 0 && pluginState.isPMDragging) {
|
|
@@ -264,9 +276,11 @@ export const createPlugin = api => {
|
|
|
264
276
|
if (!(event.target instanceof HTMLElement) || !(pluginState !== null && pluginState !== void 0 && pluginState.activeNode)) {
|
|
265
277
|
return false;
|
|
266
278
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
279
|
+
// Currently we can only drag one node at a time
|
|
280
|
+
// so we only need to check first child
|
|
281
|
+
const draggable = dragging === null || dragging === void 0 ? void 0 : dragging.slice.content.firstChild;
|
|
282
|
+
const activeNode = state.tr.doc.nodeAt(pluginState.activeNode.pos);
|
|
283
|
+
if (draggable === activeNode) {
|
|
270
284
|
// Prevent the default drop behavior if the position is within the activeNode
|
|
271
285
|
event.preventDefault();
|
|
272
286
|
return true;
|
|
@@ -71,13 +71,10 @@ var initialState = {
|
|
|
71
71
|
isMenuOpen: false,
|
|
72
72
|
editorHeight: 0,
|
|
73
73
|
isResizerResizing: false,
|
|
74
|
-
isDocSizeLimitEnabled:
|
|
74
|
+
isDocSizeLimitEnabled: null,
|
|
75
75
|
isPMDragging: false
|
|
76
76
|
};
|
|
77
|
-
|
|
78
|
-
initialState.isDocSizeLimitEnabled = true;
|
|
79
|
-
}
|
|
80
|
-
var DRAG_AND_DROP_DOC_SIZE_LIMIT = 20000;
|
|
77
|
+
var DRAG_AND_DROP_DOC_SIZE_LIMIT = 50;
|
|
81
78
|
export var createPlugin = function createPlugin(api) {
|
|
82
79
|
return new SafePlugin({
|
|
83
80
|
key: key,
|
|
@@ -87,7 +84,14 @@ export var createPlugin = function createPlugin(api) {
|
|
|
87
84
|
},
|
|
88
85
|
apply: function apply(tr, currentState, oldState, newState) {
|
|
89
86
|
var _meta$activeNode, _meta$activeNode2, _meta$isDragging, _meta$editorHeight, _meta$isPMDragging;
|
|
90
|
-
if (initialState.isDocSizeLimitEnabled
|
|
87
|
+
if (initialState.isDocSizeLimitEnabled === null) {
|
|
88
|
+
if (getBooleanFF('platform.editor.elements.drag-and-drop-doc-size-limit_7k4vq')) {
|
|
89
|
+
initialState.isDocSizeLimitEnabled = true;
|
|
90
|
+
} else {
|
|
91
|
+
initialState.isDocSizeLimitEnabled = false;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (initialState.isDocSizeLimitEnabled && newState.doc.childCount > DRAG_AND_DROP_DOC_SIZE_LIMIT) {
|
|
91
95
|
return initialState;
|
|
92
96
|
}
|
|
93
97
|
var activeNode = currentState.activeNode,
|
|
@@ -159,10 +163,18 @@ export var createPlugin = function createPlugin(api) {
|
|
|
159
163
|
// Note: Quite often the handle is not in the right position after a node is moved
|
|
160
164
|
// it is safer for now to not show it when a node is moved
|
|
161
165
|
if (activeNode && !(meta !== null && meta !== void 0 && meta.nodeMoved) && !isDecsMissing) {
|
|
162
|
-
var
|
|
166
|
+
var mappedPosisiton = tr.mapping.map(activeNode.pos);
|
|
167
|
+
var prevMappedPos = oldState.tr.mapping.map(activeNode.pos);
|
|
168
|
+
|
|
169
|
+
// When a node type changed to be nested inside another node, the position of the active node is off by 1
|
|
170
|
+
// This is a workaround to fix the position of the active node when it is nested
|
|
171
|
+
if (mappedPosisiton === prevMappedPos + 1) {
|
|
172
|
+
mappedPosisiton = prevMappedPos;
|
|
173
|
+
}
|
|
174
|
+
var newActiveNode = tr.doc.nodeAt(mappedPosisiton);
|
|
163
175
|
var nodeType = activeNode.nodeType;
|
|
164
176
|
var anchorName = activeNode.anchorName;
|
|
165
|
-
if (newActiveNode && (newActiveNode === null || newActiveNode === void 0 ? void 0 : newActiveNode.type.name) !== activeNode.nodeType
|
|
177
|
+
if (newActiveNode && (newActiveNode === null || newActiveNode === void 0 ? void 0 : newActiveNode.type.name) !== activeNode.nodeType) {
|
|
166
178
|
nodeType = newActiveNode.type.name;
|
|
167
179
|
anchorName = activeNode.anchorName.replace(activeNode.nodeType, nodeType);
|
|
168
180
|
}
|
|
@@ -249,12 +261,12 @@ export var createPlugin = function createPlugin(api) {
|
|
|
249
261
|
},
|
|
250
262
|
handleDOMEvents: {
|
|
251
263
|
drop: function drop(view, event) {
|
|
252
|
-
var _pluginState$activeNo;
|
|
253
264
|
// prosemirror has sends a default transaction on drop (meta where uiEvent is 'drop'),
|
|
254
265
|
// this duplicates the an empty version of the node it was dropping,
|
|
255
266
|
// Adding some check here to prevent that if drop position is within activeNode
|
|
256
267
|
var state = view.state,
|
|
257
|
-
dispatch = view.dispatch
|
|
268
|
+
dispatch = view.dispatch,
|
|
269
|
+
dragging = view.dragging;
|
|
258
270
|
var pluginState = key.getState(state);
|
|
259
271
|
if (pluginState !== null && pluginState !== void 0 && pluginState.isPMDragging) {
|
|
260
272
|
dispatch(state.tr.setMeta(key, {
|
|
@@ -264,9 +276,11 @@ export var createPlugin = function createPlugin(api) {
|
|
|
264
276
|
if (!(event.target instanceof HTMLElement) || !(pluginState !== null && pluginState !== void 0 && pluginState.activeNode)) {
|
|
265
277
|
return false;
|
|
266
278
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
279
|
+
// Currently we can only drag one node at a time
|
|
280
|
+
// so we only need to check first child
|
|
281
|
+
var draggable = dragging === null || dragging === void 0 ? void 0 : dragging.slice.content.firstChild;
|
|
282
|
+
var activeNode = state.tr.doc.nodeAt(pluginState.activeNode.pos);
|
|
283
|
+
if (draggable === activeNode) {
|
|
270
284
|
// Prevent the default drop behavior if the position is within the activeNode
|
|
271
285
|
event.preventDefault();
|
|
272
286
|
return true;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export interface PluginState {
|
|
|
16
16
|
nodeType: string;
|
|
17
17
|
} | null;
|
|
18
18
|
isResizerResizing: boolean;
|
|
19
|
-
isDocSizeLimitEnabled: boolean;
|
|
19
|
+
isDocSizeLimitEnabled: boolean | null;
|
|
20
20
|
/**
|
|
21
21
|
* is dragging the node without using drag handle, i,e, native prosemirror DnD
|
|
22
22
|
*/
|
|
@@ -16,7 +16,7 @@ export interface PluginState {
|
|
|
16
16
|
nodeType: string;
|
|
17
17
|
} | null;
|
|
18
18
|
isResizerResizing: boolean;
|
|
19
|
-
isDocSizeLimitEnabled: boolean;
|
|
19
|
+
isDocSizeLimitEnabled: boolean | null;
|
|
20
20
|
/**
|
|
21
21
|
* is dragging the node without using drag handle, i,e, native prosemirror DnD
|
|
22
22
|
*/
|