@atlaskit/editor-plugin-expand 2.6.2 → 2.6.3
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 +10 -0
- package/dist/cjs/legacyExpand/pm-plugins/main.js +57 -2
- package/dist/cjs/singlePlayerExpand/pm-plugins/main.js +60 -3
- package/dist/es2019/legacyExpand/pm-plugins/main.js +63 -3
- package/dist/es2019/singlePlayerExpand/pm-plugins/main.js +63 -2
- package/dist/esm/legacyExpand/pm-plugins/main.js +57 -3
- package/dist/esm/singlePlayerExpand/pm-plugins/main.js +57 -2
- package/dist/types/legacyExpand/pm-plugins/main.d.ts +6 -0
- package/dist/types/singlePlayerExpand/pm-plugins/main.d.ts +6 -0
- package/dist/types-ts4.5/legacyExpand/pm-plugins/main.d.ts +6 -0
- package/dist/types-ts4.5/singlePlayerExpand/pm-plugins/main.d.ts +6 -0
- package/package.json +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-expand
|
|
2
2
|
|
|
3
|
+
## 2.6.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#139631](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/139631)
|
|
8
|
+
[`0c5d47f791446`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0c5d47f791446) -
|
|
9
|
+
ED-24839 - Added logic to handleDrop for the expand plugin so nested expands are converted to
|
|
10
|
+
expand nodes when dragged outside of an expand. Prosemirror was automatically wrapping them in an
|
|
11
|
+
empty parent expand.
|
|
12
|
+
|
|
3
13
|
## 2.6.2
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -6,10 +6,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.containsClass = containsClass;
|
|
8
8
|
exports.createPlugin = void 0;
|
|
9
|
+
exports.handleDraggingOfNestedExpand = handleDraggingOfNestedExpand;
|
|
9
10
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
10
11
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
11
12
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
12
13
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
14
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
15
|
var _commands = require("../commands");
|
|
14
16
|
var _nodeviews = _interopRequireDefault(require("../nodeviews"));
|
|
15
17
|
var _utils2 = require("../utils");
|
|
@@ -59,7 +61,13 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, getInt
|
|
|
59
61
|
return target.classList.contains(_styles.expandClassNames.prefix);
|
|
60
62
|
}, {
|
|
61
63
|
useLongPressSelection: useLongPressSelection
|
|
62
|
-
})
|
|
64
|
+
}),
|
|
65
|
+
handleDrop: function handleDrop(view, event, slice, moved) {
|
|
66
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_nest_nested_expand_drag_fix')) {
|
|
67
|
+
return handleDraggingOfNestedExpand(view, event, slice);
|
|
68
|
+
}
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
63
71
|
},
|
|
64
72
|
// @see ED-8027 to follow up on this work-around
|
|
65
73
|
filterTransaction: function filterTransaction(tr) {
|
|
@@ -85,4 +93,51 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, getInt
|
|
|
85
93
|
};
|
|
86
94
|
}
|
|
87
95
|
});
|
|
88
|
-
};
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* As the nestedExpand node is not supported outside of the expand node, it must be converted to an expand node when dragged outside of the expand node.
|
|
100
|
+
*/
|
|
101
|
+
function handleDraggingOfNestedExpand(view, event, slice) {
|
|
102
|
+
var _slice$content$firstC;
|
|
103
|
+
var state = view.state,
|
|
104
|
+
dispatch = view.dispatch;
|
|
105
|
+
var tr = state.tr;
|
|
106
|
+
var selection = state.selection;
|
|
107
|
+
var from = selection.from,
|
|
108
|
+
to = selection.to;
|
|
109
|
+
var supportedDropLocations = [state.schema.nodes.doc, state.schema.nodes.layoutSection, state.schema.nodes.layoutColumn];
|
|
110
|
+
|
|
111
|
+
// Check if the contents of the dragged slice contain a nested expand node.
|
|
112
|
+
if (((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type) !== state.schema.nodes.nestedExpand) {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
var dropPos = view.posAtCoords({
|
|
116
|
+
left: event.clientX,
|
|
117
|
+
top: event.clientY
|
|
118
|
+
});
|
|
119
|
+
if (!dropPos) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
var resolvedPos = state.doc.resolve(dropPos.pos);
|
|
123
|
+
|
|
124
|
+
// If not dropping into the root of the document, check if the parent node type of the drop location is supported.
|
|
125
|
+
if (resolvedPos.depth > 1) {
|
|
126
|
+
var parentNodeType = resolvedPos.node(resolvedPos.depth - 1).type;
|
|
127
|
+
// If you're not dropping into a doc or layoutSection, don't transform the nested expand, return false and allow default behaviour.
|
|
128
|
+
if (!supportedDropLocations.includes(parentNodeType)) {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
var updatedSlice = (0, _utils2.transformSliceNestedExpandToExpand)(slice, state.schema);
|
|
133
|
+
if (updatedSlice.eq(slice)) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// The drop position will be affected when the original slice is deleted from the document.
|
|
138
|
+
var updatedDropPos = dropPos.pos > from ? dropPos.pos - updatedSlice.content.size : dropPos.pos;
|
|
139
|
+
tr.delete(from, to);
|
|
140
|
+
tr.insert(updatedDropPos, updatedSlice.content);
|
|
141
|
+
dispatch(tr);
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
@@ -5,12 +5,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.containsClass = containsClass;
|
|
8
|
-
exports.
|
|
8
|
+
exports.createPlugin = void 0;
|
|
9
|
+
exports.handleDraggingOfNestedExpand = handleDraggingOfNestedExpand;
|
|
10
|
+
exports.pluginKey = void 0;
|
|
9
11
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
10
12
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
11
13
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
12
14
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
15
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
16
|
var _nodeViews = _interopRequireDefault(require("../node-views"));
|
|
17
|
+
var _utils = require("../utils");
|
|
14
18
|
var pluginKey = exports.pluginKey = new _state.PluginKey('expandPlugin');
|
|
15
19
|
function containsClass(element, className) {
|
|
16
20
|
var _element$classList;
|
|
@@ -55,7 +59,13 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, getInt
|
|
|
55
59
|
return target.classList.contains(_styles.expandClassNames.prefix);
|
|
56
60
|
}, {
|
|
57
61
|
useLongPressSelection: useLongPressSelection
|
|
58
|
-
})
|
|
62
|
+
}),
|
|
63
|
+
handleDrop: function handleDrop(view, event, slice, moved) {
|
|
64
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_nest_nested_expand_drag_fix')) {
|
|
65
|
+
return handleDraggingOfNestedExpand(view, event, slice);
|
|
66
|
+
}
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
59
69
|
},
|
|
60
70
|
// @see ED-8027 to follow up on this work-around
|
|
61
71
|
filterTransaction: function filterTransaction(tr) {
|
|
@@ -65,4 +75,51 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, getInt
|
|
|
65
75
|
return true;
|
|
66
76
|
}
|
|
67
77
|
});
|
|
68
|
-
};
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* As the nestedExpand node is not supported outside of the expand node, it must be converted to an expand node when dragged outside of the expand node.
|
|
82
|
+
*/
|
|
83
|
+
function handleDraggingOfNestedExpand(view, event, slice) {
|
|
84
|
+
var _slice$content$firstC;
|
|
85
|
+
var state = view.state,
|
|
86
|
+
dispatch = view.dispatch;
|
|
87
|
+
var tr = state.tr;
|
|
88
|
+
var selection = state.selection;
|
|
89
|
+
var from = selection.from,
|
|
90
|
+
to = selection.to;
|
|
91
|
+
var supportedDropLocations = [state.schema.nodes.doc, state.schema.nodes.layoutSection, state.schema.nodes.layoutColumn];
|
|
92
|
+
|
|
93
|
+
// Check if the contents of the dragged slice contain a nested expand node.
|
|
94
|
+
if (((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type) !== state.schema.nodes.nestedExpand) {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
var dropPos = view.posAtCoords({
|
|
98
|
+
left: event.clientX,
|
|
99
|
+
top: event.clientY
|
|
100
|
+
});
|
|
101
|
+
if (!dropPos) {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
var resolvedPos = state.doc.resolve(dropPos.pos);
|
|
105
|
+
|
|
106
|
+
// If not dropping into the root of the document, check if the parent node type of the drop location is supported.
|
|
107
|
+
if (resolvedPos.depth > 1) {
|
|
108
|
+
var parentNodeType = resolvedPos.node(resolvedPos.depth - 1).type;
|
|
109
|
+
// If you're not dropping into a doc or layoutSection, don't transform the nested expand, return false and allow default behaviour.
|
|
110
|
+
if (!supportedDropLocations.includes(parentNodeType)) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
var updatedSlice = (0, _utils.transformSliceNestedExpandToExpand)(slice, state.schema);
|
|
115
|
+
if (updatedSlice.eq(slice)) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// The drop position will be affected when the original slice is deleted from the document.
|
|
120
|
+
var updatedDropPos = dropPos.pos > from ? dropPos.pos - updatedSlice.content.size : dropPos.pos;
|
|
121
|
+
tr.delete(from, to);
|
|
122
|
+
tr.insert(updatedDropPos, updatedSlice.content);
|
|
123
|
+
dispatch(tr);
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
@@ -2,9 +2,10 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
2
2
|
import { createSelectionClickHandler } from '@atlaskit/editor-common/selection';
|
|
3
3
|
import { expandClassNames } from '@atlaskit/editor-common/styles';
|
|
4
4
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
6
|
import { setExpandRef } from '../commands';
|
|
6
7
|
import ExpandNodeView from '../nodeviews';
|
|
7
|
-
import { findExpand } from '../utils';
|
|
8
|
+
import { findExpand, transformSliceNestedExpandToExpand } from '../utils';
|
|
8
9
|
import { createPluginState, getPluginState, pluginKey } from './plugin-factory';
|
|
9
10
|
export function containsClass(element, className) {
|
|
10
11
|
var _element$classList;
|
|
@@ -44,7 +45,13 @@ export const createPlugin = (dispatch, getIntl, appearance = 'full-page', useLon
|
|
|
44
45
|
},
|
|
45
46
|
handleClickOn: createSelectionClickHandler(['expand', 'nestedExpand'], target => target.classList.contains(expandClassNames.prefix), {
|
|
46
47
|
useLongPressSelection
|
|
47
|
-
})
|
|
48
|
+
}),
|
|
49
|
+
handleDrop(view, event, slice, moved) {
|
|
50
|
+
if (fg('platform_editor_nest_nested_expand_drag_fix')) {
|
|
51
|
+
return handleDraggingOfNestedExpand(view, event, slice);
|
|
52
|
+
}
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
48
55
|
},
|
|
49
56
|
// @see ED-8027 to follow up on this work-around
|
|
50
57
|
filterTransaction(tr) {
|
|
@@ -72,4 +79,57 @@ export const createPlugin = (dispatch, getIntl, appearance = 'full-page', useLon
|
|
|
72
79
|
};
|
|
73
80
|
}
|
|
74
81
|
});
|
|
75
|
-
};
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* As the nestedExpand node is not supported outside of the expand node, it must be converted to an expand node when dragged outside of the expand node.
|
|
86
|
+
*/
|
|
87
|
+
export function handleDraggingOfNestedExpand(view, event, slice) {
|
|
88
|
+
var _slice$content$firstC;
|
|
89
|
+
const {
|
|
90
|
+
state,
|
|
91
|
+
dispatch
|
|
92
|
+
} = view;
|
|
93
|
+
const tr = state.tr;
|
|
94
|
+
const {
|
|
95
|
+
selection
|
|
96
|
+
} = state;
|
|
97
|
+
const {
|
|
98
|
+
from,
|
|
99
|
+
to
|
|
100
|
+
} = selection;
|
|
101
|
+
const supportedDropLocations = [state.schema.nodes.doc, state.schema.nodes.layoutSection, state.schema.nodes.layoutColumn];
|
|
102
|
+
|
|
103
|
+
// Check if the contents of the dragged slice contain a nested expand node.
|
|
104
|
+
if (((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type) !== state.schema.nodes.nestedExpand) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
const dropPos = view.posAtCoords({
|
|
108
|
+
left: event.clientX,
|
|
109
|
+
top: event.clientY
|
|
110
|
+
});
|
|
111
|
+
if (!dropPos) {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
const resolvedPos = state.doc.resolve(dropPos.pos);
|
|
115
|
+
|
|
116
|
+
// If not dropping into the root of the document, check if the parent node type of the drop location is supported.
|
|
117
|
+
if (resolvedPos.depth > 1) {
|
|
118
|
+
const parentNodeType = resolvedPos.node(resolvedPos.depth - 1).type;
|
|
119
|
+
// If you're not dropping into a doc or layoutSection, don't transform the nested expand, return false and allow default behaviour.
|
|
120
|
+
if (!supportedDropLocations.includes(parentNodeType)) {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
const updatedSlice = transformSliceNestedExpandToExpand(slice, state.schema);
|
|
125
|
+
if (updatedSlice.eq(slice)) {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// The drop position will be affected when the original slice is deleted from the document.
|
|
130
|
+
const updatedDropPos = dropPos.pos > from ? dropPos.pos - updatedSlice.content.size : dropPos.pos;
|
|
131
|
+
tr.delete(from, to);
|
|
132
|
+
tr.insert(updatedDropPos, updatedSlice.content);
|
|
133
|
+
dispatch(tr);
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
@@ -2,7 +2,9 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
2
2
|
import { createSelectionClickHandler } from '@atlaskit/editor-common/selection';
|
|
3
3
|
import { expandClassNames } from '@atlaskit/editor-common/styles';
|
|
4
4
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
6
|
import ExpandNodeView from '../node-views';
|
|
7
|
+
import { transformSliceNestedExpandToExpand } from '../utils';
|
|
6
8
|
export const pluginKey = new PluginKey('expandPlugin');
|
|
7
9
|
export function containsClass(element, className) {
|
|
8
10
|
var _element$classList;
|
|
@@ -40,7 +42,13 @@ export const createPlugin = (dispatch, getIntl, appearance = 'full-page', useLon
|
|
|
40
42
|
},
|
|
41
43
|
handleClickOn: createSelectionClickHandler(['expand', 'nestedExpand'], target => target.classList.contains(expandClassNames.prefix), {
|
|
42
44
|
useLongPressSelection
|
|
43
|
-
})
|
|
45
|
+
}),
|
|
46
|
+
handleDrop(view, event, slice, moved) {
|
|
47
|
+
if (fg('platform_editor_nest_nested_expand_drag_fix')) {
|
|
48
|
+
return handleDraggingOfNestedExpand(view, event, slice);
|
|
49
|
+
}
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
44
52
|
},
|
|
45
53
|
// @see ED-8027 to follow up on this work-around
|
|
46
54
|
filterTransaction(tr) {
|
|
@@ -50,4 +58,57 @@ export const createPlugin = (dispatch, getIntl, appearance = 'full-page', useLon
|
|
|
50
58
|
return true;
|
|
51
59
|
}
|
|
52
60
|
});
|
|
53
|
-
};
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* As the nestedExpand node is not supported outside of the expand node, it must be converted to an expand node when dragged outside of the expand node.
|
|
65
|
+
*/
|
|
66
|
+
export function handleDraggingOfNestedExpand(view, event, slice) {
|
|
67
|
+
var _slice$content$firstC;
|
|
68
|
+
const {
|
|
69
|
+
state,
|
|
70
|
+
dispatch
|
|
71
|
+
} = view;
|
|
72
|
+
const tr = state.tr;
|
|
73
|
+
const {
|
|
74
|
+
selection
|
|
75
|
+
} = state;
|
|
76
|
+
const {
|
|
77
|
+
from,
|
|
78
|
+
to
|
|
79
|
+
} = selection;
|
|
80
|
+
const supportedDropLocations = [state.schema.nodes.doc, state.schema.nodes.layoutSection, state.schema.nodes.layoutColumn];
|
|
81
|
+
|
|
82
|
+
// Check if the contents of the dragged slice contain a nested expand node.
|
|
83
|
+
if (((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type) !== state.schema.nodes.nestedExpand) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
const dropPos = view.posAtCoords({
|
|
87
|
+
left: event.clientX,
|
|
88
|
+
top: event.clientY
|
|
89
|
+
});
|
|
90
|
+
if (!dropPos) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
const resolvedPos = state.doc.resolve(dropPos.pos);
|
|
94
|
+
|
|
95
|
+
// If not dropping into the root of the document, check if the parent node type of the drop location is supported.
|
|
96
|
+
if (resolvedPos.depth > 1) {
|
|
97
|
+
const parentNodeType = resolvedPos.node(resolvedPos.depth - 1).type;
|
|
98
|
+
// If you're not dropping into a doc or layoutSection, don't transform the nested expand, return false and allow default behaviour.
|
|
99
|
+
if (!supportedDropLocations.includes(parentNodeType)) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
const updatedSlice = transformSliceNestedExpandToExpand(slice, state.schema);
|
|
104
|
+
if (updatedSlice.eq(slice)) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// The drop position will be affected when the original slice is deleted from the document.
|
|
109
|
+
const updatedDropPos = dropPos.pos > from ? dropPos.pos - updatedSlice.content.size : dropPos.pos;
|
|
110
|
+
tr.delete(from, to);
|
|
111
|
+
tr.insert(updatedDropPos, updatedSlice.content);
|
|
112
|
+
dispatch(tr);
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
@@ -2,9 +2,10 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
2
2
|
import { createSelectionClickHandler } from '@atlaskit/editor-common/selection';
|
|
3
3
|
import { expandClassNames } from '@atlaskit/editor-common/styles';
|
|
4
4
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
6
|
import { setExpandRef } from '../commands';
|
|
6
7
|
import ExpandNodeView from '../nodeviews';
|
|
7
|
-
import { findExpand } from '../utils';
|
|
8
|
+
import { findExpand, transformSliceNestedExpandToExpand } from '../utils';
|
|
8
9
|
import { createPluginState, getPluginState, pluginKey } from './plugin-factory';
|
|
9
10
|
export function containsClass(element, className) {
|
|
10
11
|
var _element$classList;
|
|
@@ -51,7 +52,13 @@ export var createPlugin = function createPlugin(dispatch, getIntl) {
|
|
|
51
52
|
return target.classList.contains(expandClassNames.prefix);
|
|
52
53
|
}, {
|
|
53
54
|
useLongPressSelection: useLongPressSelection
|
|
54
|
-
})
|
|
55
|
+
}),
|
|
56
|
+
handleDrop: function handleDrop(view, event, slice, moved) {
|
|
57
|
+
if (fg('platform_editor_nest_nested_expand_drag_fix')) {
|
|
58
|
+
return handleDraggingOfNestedExpand(view, event, slice);
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
55
62
|
},
|
|
56
63
|
// @see ED-8027 to follow up on this work-around
|
|
57
64
|
filterTransaction: function filterTransaction(tr) {
|
|
@@ -77,4 +84,51 @@ export var createPlugin = function createPlugin(dispatch, getIntl) {
|
|
|
77
84
|
};
|
|
78
85
|
}
|
|
79
86
|
});
|
|
80
|
-
};
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* As the nestedExpand node is not supported outside of the expand node, it must be converted to an expand node when dragged outside of the expand node.
|
|
91
|
+
*/
|
|
92
|
+
export function handleDraggingOfNestedExpand(view, event, slice) {
|
|
93
|
+
var _slice$content$firstC;
|
|
94
|
+
var state = view.state,
|
|
95
|
+
dispatch = view.dispatch;
|
|
96
|
+
var tr = state.tr;
|
|
97
|
+
var selection = state.selection;
|
|
98
|
+
var from = selection.from,
|
|
99
|
+
to = selection.to;
|
|
100
|
+
var supportedDropLocations = [state.schema.nodes.doc, state.schema.nodes.layoutSection, state.schema.nodes.layoutColumn];
|
|
101
|
+
|
|
102
|
+
// Check if the contents of the dragged slice contain a nested expand node.
|
|
103
|
+
if (((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type) !== state.schema.nodes.nestedExpand) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
var dropPos = view.posAtCoords({
|
|
107
|
+
left: event.clientX,
|
|
108
|
+
top: event.clientY
|
|
109
|
+
});
|
|
110
|
+
if (!dropPos) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
var resolvedPos = state.doc.resolve(dropPos.pos);
|
|
114
|
+
|
|
115
|
+
// If not dropping into the root of the document, check if the parent node type of the drop location is supported.
|
|
116
|
+
if (resolvedPos.depth > 1) {
|
|
117
|
+
var parentNodeType = resolvedPos.node(resolvedPos.depth - 1).type;
|
|
118
|
+
// If you're not dropping into a doc or layoutSection, don't transform the nested expand, return false and allow default behaviour.
|
|
119
|
+
if (!supportedDropLocations.includes(parentNodeType)) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
var updatedSlice = transformSliceNestedExpandToExpand(slice, state.schema);
|
|
124
|
+
if (updatedSlice.eq(slice)) {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// The drop position will be affected when the original slice is deleted from the document.
|
|
129
|
+
var updatedDropPos = dropPos.pos > from ? dropPos.pos - updatedSlice.content.size : dropPos.pos;
|
|
130
|
+
tr.delete(from, to);
|
|
131
|
+
tr.insert(updatedDropPos, updatedSlice.content);
|
|
132
|
+
dispatch(tr);
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
@@ -2,7 +2,9 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
2
2
|
import { createSelectionClickHandler } from '@atlaskit/editor-common/selection';
|
|
3
3
|
import { expandClassNames } from '@atlaskit/editor-common/styles';
|
|
4
4
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
6
|
import ExpandNodeView from '../node-views';
|
|
7
|
+
import { transformSliceNestedExpandToExpand } from '../utils';
|
|
6
8
|
export var pluginKey = new PluginKey('expandPlugin');
|
|
7
9
|
export function containsClass(element, className) {
|
|
8
10
|
var _element$classList;
|
|
@@ -47,7 +49,13 @@ export var createPlugin = function createPlugin(dispatch, getIntl) {
|
|
|
47
49
|
return target.classList.contains(expandClassNames.prefix);
|
|
48
50
|
}, {
|
|
49
51
|
useLongPressSelection: useLongPressSelection
|
|
50
|
-
})
|
|
52
|
+
}),
|
|
53
|
+
handleDrop: function handleDrop(view, event, slice, moved) {
|
|
54
|
+
if (fg('platform_editor_nest_nested_expand_drag_fix')) {
|
|
55
|
+
return handleDraggingOfNestedExpand(view, event, slice);
|
|
56
|
+
}
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
51
59
|
},
|
|
52
60
|
// @see ED-8027 to follow up on this work-around
|
|
53
61
|
filterTransaction: function filterTransaction(tr) {
|
|
@@ -57,4 +65,51 @@ export var createPlugin = function createPlugin(dispatch, getIntl) {
|
|
|
57
65
|
return true;
|
|
58
66
|
}
|
|
59
67
|
});
|
|
60
|
-
};
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* As the nestedExpand node is not supported outside of the expand node, it must be converted to an expand node when dragged outside of the expand node.
|
|
72
|
+
*/
|
|
73
|
+
export function handleDraggingOfNestedExpand(view, event, slice) {
|
|
74
|
+
var _slice$content$firstC;
|
|
75
|
+
var state = view.state,
|
|
76
|
+
dispatch = view.dispatch;
|
|
77
|
+
var tr = state.tr;
|
|
78
|
+
var selection = state.selection;
|
|
79
|
+
var from = selection.from,
|
|
80
|
+
to = selection.to;
|
|
81
|
+
var supportedDropLocations = [state.schema.nodes.doc, state.schema.nodes.layoutSection, state.schema.nodes.layoutColumn];
|
|
82
|
+
|
|
83
|
+
// Check if the contents of the dragged slice contain a nested expand node.
|
|
84
|
+
if (((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type) !== state.schema.nodes.nestedExpand) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
var dropPos = view.posAtCoords({
|
|
88
|
+
left: event.clientX,
|
|
89
|
+
top: event.clientY
|
|
90
|
+
});
|
|
91
|
+
if (!dropPos) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
var resolvedPos = state.doc.resolve(dropPos.pos);
|
|
95
|
+
|
|
96
|
+
// If not dropping into the root of the document, check if the parent node type of the drop location is supported.
|
|
97
|
+
if (resolvedPos.depth > 1) {
|
|
98
|
+
var parentNodeType = resolvedPos.node(resolvedPos.depth - 1).type;
|
|
99
|
+
// If you're not dropping into a doc or layoutSection, don't transform the nested expand, return false and allow default behaviour.
|
|
100
|
+
if (!supportedDropLocations.includes(parentNodeType)) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
var updatedSlice = transformSliceNestedExpandToExpand(slice, state.schema);
|
|
105
|
+
if (updatedSlice.eq(slice)) {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// The drop position will be affected when the original slice is deleted from the document.
|
|
110
|
+
var updatedDropPos = dropPos.pos > from ? dropPos.pos - updatedSlice.content.size : dropPos.pos;
|
|
111
|
+
tr.delete(from, to);
|
|
112
|
+
tr.insert(updatedDropPos, updatedSlice.content);
|
|
113
|
+
dispatch(tr);
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
@@ -2,6 +2,12 @@ import type { IntlShape } from 'react-intl-next';
|
|
|
2
2
|
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
3
3
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
4
|
import type { EditorAppearance, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
5
|
+
import { type Slice } from '@atlaskit/editor-prosemirror/model';
|
|
6
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
7
|
import type { ExpandPlugin } from '../../types';
|
|
6
8
|
export declare function containsClass(element: Element | null, className: string): boolean;
|
|
7
9
|
export declare const createPlugin: (dispatch: Dispatch, getIntl: () => IntlShape, appearance: EditorAppearance | undefined, useLongPressSelection: boolean | undefined, api: ExtractInjectionAPI<ExpandPlugin> | undefined, allowInteractiveExpand?: boolean, __livePage?: boolean) => SafePlugin<import("../../types").ExpandPluginState>;
|
|
10
|
+
/**
|
|
11
|
+
* As the nestedExpand node is not supported outside of the expand node, it must be converted to an expand node when dragged outside of the expand node.
|
|
12
|
+
*/
|
|
13
|
+
export declare function handleDraggingOfNestedExpand(view: EditorView, event: DragEvent, slice: Slice): boolean;
|
|
@@ -2,8 +2,14 @@ import type { IntlShape } from 'react-intl-next';
|
|
|
2
2
|
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
3
3
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
4
|
import type { EditorAppearance, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
5
|
+
import { type Slice } from '@atlaskit/editor-prosemirror/model';
|
|
5
6
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
+
import { type EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
8
|
import type { ExpandPlugin } from '../../types';
|
|
7
9
|
export declare const pluginKey: PluginKey<any>;
|
|
8
10
|
export declare function containsClass(element: Element | null, className: string): boolean;
|
|
9
11
|
export declare const createPlugin: (dispatch: Dispatch, getIntl: () => IntlShape, appearance: EditorAppearance | undefined, useLongPressSelection: boolean | undefined, api: ExtractInjectionAPI<ExpandPlugin> | undefined, allowInteractiveExpand?: boolean, __livePage?: boolean) => SafePlugin<any>;
|
|
12
|
+
/**
|
|
13
|
+
* As the nestedExpand node is not supported outside of the expand node, it must be converted to an expand node when dragged outside of the expand node.
|
|
14
|
+
*/
|
|
15
|
+
export declare function handleDraggingOfNestedExpand(view: EditorView, event: DragEvent, slice: Slice): boolean;
|
|
@@ -2,6 +2,12 @@ import type { IntlShape } from 'react-intl-next';
|
|
|
2
2
|
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
3
3
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
4
|
import type { EditorAppearance, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
5
|
+
import { type Slice } from '@atlaskit/editor-prosemirror/model';
|
|
6
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
7
|
import type { ExpandPlugin } from '../../types';
|
|
6
8
|
export declare function containsClass(element: Element | null, className: string): boolean;
|
|
7
9
|
export declare const createPlugin: (dispatch: Dispatch, getIntl: () => IntlShape, appearance: EditorAppearance | undefined, useLongPressSelection: boolean | undefined, api: ExtractInjectionAPI<ExpandPlugin> | undefined, allowInteractiveExpand?: boolean, __livePage?: boolean) => SafePlugin<import("../../types").ExpandPluginState>;
|
|
10
|
+
/**
|
|
11
|
+
* As the nestedExpand node is not supported outside of the expand node, it must be converted to an expand node when dragged outside of the expand node.
|
|
12
|
+
*/
|
|
13
|
+
export declare function handleDraggingOfNestedExpand(view: EditorView, event: DragEvent, slice: Slice): boolean;
|
|
@@ -2,8 +2,14 @@ import type { IntlShape } from 'react-intl-next';
|
|
|
2
2
|
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
3
3
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
4
|
import type { EditorAppearance, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
5
|
+
import { type Slice } from '@atlaskit/editor-prosemirror/model';
|
|
5
6
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
+
import { type EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
8
|
import type { ExpandPlugin } from '../../types';
|
|
7
9
|
export declare const pluginKey: PluginKey<any>;
|
|
8
10
|
export declare function containsClass(element: Element | null, className: string): boolean;
|
|
9
11
|
export declare const createPlugin: (dispatch: Dispatch, getIntl: () => IntlShape, appearance: EditorAppearance | undefined, useLongPressSelection: boolean | undefined, api: ExtractInjectionAPI<ExpandPlugin> | undefined, allowInteractiveExpand?: boolean, __livePage?: boolean) => SafePlugin<any>;
|
|
12
|
+
/**
|
|
13
|
+
* As the nestedExpand node is not supported outside of the expand node, it must be converted to an expand node when dragged outside of the expand node.
|
|
14
|
+
*/
|
|
15
|
+
export declare function handleDraggingOfNestedExpand(view: EditorView, event: DragEvent, slice: Slice): boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-expand",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.3",
|
|
4
4
|
"description": "Expand plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -117,6 +117,9 @@
|
|
|
117
117
|
},
|
|
118
118
|
"platform_editor_nested_expand_in_expand_adf_change": {
|
|
119
119
|
"type": "boolean"
|
|
120
|
+
},
|
|
121
|
+
"platform_editor_nest_nested_expand_drag_fix": {
|
|
122
|
+
"type": "boolean"
|
|
120
123
|
}
|
|
121
124
|
}
|
|
122
125
|
}
|