@atlaskit/editor-plugin-block-controls 8.6.4 → 8.7.1
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/block-decoration-utils/package.json +17 -0
- package/dist/cjs/blockControlsPlugin.js +15 -1
- package/dist/cjs/pm-plugins/main.js +56 -29
- package/dist/cjs/ui/block-decoration-utils.js +53 -0
- package/dist/cjs/ui/consts.js +1 -9
- package/dist/es2019/blockControlsPlugin.js +273 -259
- package/dist/es2019/pm-plugins/main.js +25 -29
- package/dist/es2019/ui/block-decoration-utils.js +9 -0
- package/dist/es2019/ui/consts.js +0 -8
- package/dist/esm/blockControlsPlugin.js +15 -1
- package/dist/esm/pm-plugins/main.js +56 -29
- package/dist/esm/ui/block-decoration-utils.js +9 -0
- package/dist/esm/ui/consts.js +0 -8
- package/dist/types/blockControlsPluginType.d.ts +20 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/pm-plugins/main.d.ts +3 -3
- package/dist/types/ui/block-decoration-utils.d.ts +6 -0
- package/dist/types/ui/consts.d.ts +0 -8
- package/dist/types-ts4.5/blockControlsPluginType.d.ts +20 -2
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/main.d.ts +3 -3
- package/dist/types-ts4.5/ui/block-decoration-utils.d.ts +6 -0
- package/dist/types-ts4.5/ui/consts.d.ts +0 -8
- package/package.json +5 -2
- package/dist/cjs/pm-plugins/decorations-remix-button.js +0 -67
- package/dist/cjs/ui/remix-button.js +0 -163
- package/dist/es2019/pm-plugins/decorations-remix-button.js +0 -56
- package/dist/es2019/ui/remix-button.js +0 -144
- package/dist/esm/pm-plugins/decorations-remix-button.js +0 -59
- package/dist/esm/ui/remix-button.js +0 -154
- package/dist/types/pm-plugins/decorations-remix-button.d.ts +0 -21
- package/dist/types/ui/remix-button.d.ts +0 -17
- package/dist/types-ts4.5/pm-plugins/decorations-remix-button.d.ts +0 -21
- package/dist/types-ts4.5/ui/remix-button.d.ts +0 -17
|
@@ -21,299 +21,313 @@ import { selectNode } from './pm-plugins/utils/getSelection';
|
|
|
21
21
|
import { GlobalStylesWrapper } from './ui/global-styles';
|
|
22
22
|
export const blockControlsPlugin = ({
|
|
23
23
|
api
|
|
24
|
-
}) =>
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
name: 'blockControlsInteractionTrackingPlugin',
|
|
37
|
-
plugin: createInteractionTrackingPlugin
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
|
|
41
|
-
pmPlugins.push({
|
|
42
|
-
name: 'blockControlsSelectionPreservationPlugin',
|
|
43
|
-
plugin: createSelectionPreservationPlugin(api)
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// platform_editor_controls note: quick insert rendering fixes
|
|
48
|
-
if (areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar))) {
|
|
49
|
-
pmPlugins.push({
|
|
50
|
-
name: 'firstNodeDec',
|
|
51
|
-
plugin: firstNodeDecPlugin
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
return pmPlugins;
|
|
55
|
-
},
|
|
56
|
-
commands: {
|
|
57
|
-
moveNode: moveNode(api),
|
|
58
|
-
moveToLayout: moveToLayout(api),
|
|
59
|
-
showDragHandleAt: (pos, anchorName, nodeType, handleOptions, rootPos, rootAnchorName, rootNodeType) => ({
|
|
60
|
-
tr
|
|
61
|
-
}) => {
|
|
62
|
-
const currMeta = tr.getMeta(key);
|
|
63
|
-
tr.setMeta(key, {
|
|
64
|
-
...currMeta,
|
|
65
|
-
activeNode: {
|
|
66
|
-
pos,
|
|
67
|
-
anchorName,
|
|
68
|
-
nodeType,
|
|
69
|
-
handleOptions,
|
|
70
|
-
rootPos,
|
|
71
|
-
rootAnchorName,
|
|
72
|
-
rootNodeType
|
|
24
|
+
}) => {
|
|
25
|
+
const nodeDecorationRegistry = [];
|
|
26
|
+
return {
|
|
27
|
+
name: 'blockControls',
|
|
28
|
+
actions: {
|
|
29
|
+
registerNodeDecoration: factory => {
|
|
30
|
+
nodeDecorationRegistry.push(factory);
|
|
31
|
+
},
|
|
32
|
+
unregisterNodeDecoration: type => {
|
|
33
|
+
const idx = nodeDecorationRegistry.findIndex(f => f.type === type);
|
|
34
|
+
if (idx !== -1) {
|
|
35
|
+
nodeDecorationRegistry.splice(idx, 1);
|
|
73
36
|
}
|
|
74
|
-
}
|
|
75
|
-
return tr;
|
|
37
|
+
}
|
|
76
38
|
},
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
39
|
+
pmPlugins() {
|
|
40
|
+
const pmPlugins = [{
|
|
41
|
+
name: 'blockControlsPmPlugin',
|
|
42
|
+
plugin: ({
|
|
43
|
+
getIntl,
|
|
44
|
+
nodeViewPortalProviderAPI
|
|
45
|
+
}) => createPlugin(api, getIntl, nodeViewPortalProviderAPI, nodeDecorationRegistry)
|
|
46
|
+
}];
|
|
47
|
+
if (editorExperiment('platform_editor_controls', 'variant1')) {
|
|
48
|
+
pmPlugins.push({
|
|
49
|
+
name: 'blockControlsInteractionTrackingPlugin',
|
|
50
|
+
plugin: createInteractionTrackingPlugin
|
|
51
|
+
});
|
|
83
52
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
53
|
+
if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
|
|
54
|
+
pmPlugins.push({
|
|
55
|
+
name: 'blockControlsSelectionPreservationPlugin',
|
|
56
|
+
plugin: createSelectionPreservationPlugin(api)
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// platform_editor_controls note: quick insert rendering fixes
|
|
61
|
+
if (areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar))) {
|
|
62
|
+
pmPlugins.push({
|
|
63
|
+
name: 'firstNodeDec',
|
|
64
|
+
plugin: firstNodeDecPlugin
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
return pmPlugins;
|
|
68
|
+
},
|
|
69
|
+
commands: {
|
|
70
|
+
moveNode: moveNode(api),
|
|
71
|
+
moveToLayout: moveToLayout(api),
|
|
72
|
+
showDragHandleAt: (pos, anchorName, nodeType, handleOptions, rootPos, rootAnchorName, rootNodeType) => ({
|
|
73
|
+
tr
|
|
74
|
+
}) => {
|
|
75
|
+
const currMeta = tr.getMeta(key);
|
|
88
76
|
tr.setMeta(key, {
|
|
89
77
|
...currMeta,
|
|
90
|
-
|
|
78
|
+
activeNode: {
|
|
79
|
+
pos,
|
|
80
|
+
anchorName,
|
|
81
|
+
nodeType,
|
|
82
|
+
handleOptions,
|
|
83
|
+
rootPos,
|
|
84
|
+
rootAnchorName,
|
|
85
|
+
rootNodeType
|
|
86
|
+
}
|
|
91
87
|
});
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
88
|
+
return tr;
|
|
89
|
+
},
|
|
90
|
+
toggleBlockMenu: options => ({
|
|
91
|
+
tr
|
|
92
|
+
}) => {
|
|
93
|
+
var _api$userIntent, _api$userIntent$share, _api$blockControls, _api$blockControls$sh, _options$anchorName, _api$blockControls2, _api$blockControls2$s;
|
|
94
|
+
if (!expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
|
|
95
|
+
return tr;
|
|
97
96
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
97
|
+
const currMeta = tr.getMeta(key);
|
|
98
|
+
const currentUserIntent = api === null || api === void 0 ? void 0 : (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 ? void 0 : (_api$userIntent$share = _api$userIntent.sharedState.currentState()) === null || _api$userIntent$share === void 0 ? void 0 : _api$userIntent$share.currentUserIntent;
|
|
99
|
+
const isMenuCurrentlyOpen = api === null || api === void 0 ? void 0 : (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : (_api$blockControls$sh = _api$blockControls.sharedState.currentState()) === null || _api$blockControls$sh === void 0 ? void 0 : _api$blockControls$sh.isMenuOpen;
|
|
100
|
+
if (options !== null && options !== void 0 && options.closeMenu) {
|
|
101
|
+
tr.setMeta(key, {
|
|
102
|
+
...currMeta,
|
|
103
|
+
closeMenu: true
|
|
104
104
|
});
|
|
105
|
+
if (currentUserIntent === 'blockMenuOpen') {
|
|
106
|
+
var _api$userIntent2;
|
|
107
|
+
api === null || api === void 0 ? void 0 : (_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 ? void 0 : _api$userIntent2.commands.setCurrentUserIntent('default')({
|
|
108
|
+
tr
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// When closing the menu, restart the active session timer
|
|
113
|
+
if (isMenuCurrentlyOpen && fg('platform_editor_ease_of_use_metrics')) {
|
|
114
|
+
var _api$metrics;
|
|
115
|
+
api === null || api === void 0 ? void 0 : (_api$metrics = api.metrics) === null || _api$metrics === void 0 ? void 0 : _api$metrics.commands.startActiveSessionTimer()({
|
|
116
|
+
tr
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
return tr;
|
|
105
120
|
}
|
|
106
|
-
return tr;
|
|
107
|
-
}
|
|
108
121
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
122
|
+
// Do not open menu on layoutColumn and close opened menu when layoutColumn drag handle is clicked
|
|
123
|
+
if (options !== null && options !== void 0 && (_options$anchorName = options.anchorName) !== null && _options$anchorName !== void 0 && _options$anchorName.includes('layoutColumn')) {
|
|
124
|
+
if (currentUserIntent === 'blockMenuOpen') {
|
|
125
|
+
var _api$userIntent3;
|
|
126
|
+
api === null || api === void 0 ? void 0 : (_api$userIntent3 = api.userIntent) === null || _api$userIntent3 === void 0 ? void 0 : _api$userIntent3.commands.setCurrentUserIntent('default')({
|
|
127
|
+
tr
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
tr.setMeta(key, {
|
|
131
|
+
...currMeta,
|
|
132
|
+
closeMenu: true
|
|
115
133
|
});
|
|
134
|
+
|
|
135
|
+
// When closing the menu, restart the active session timer
|
|
136
|
+
if (isMenuCurrentlyOpen && fg('platform_editor_ease_of_use_metrics')) {
|
|
137
|
+
var _api$metrics2;
|
|
138
|
+
api === null || api === void 0 ? void 0 : (_api$metrics2 = api.metrics) === null || _api$metrics2 === void 0 ? void 0 : _api$metrics2.commands.startActiveSessionTimer()({
|
|
139
|
+
tr
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
return tr;
|
|
143
|
+
}
|
|
144
|
+
let toggleMenuMeta = {
|
|
145
|
+
anchorName: options === null || options === void 0 ? void 0 : options.anchorName,
|
|
146
|
+
triggerByNode: options === null || options === void 0 ? void 0 : options.triggerByNode
|
|
147
|
+
};
|
|
148
|
+
const menuTriggerBy = api === null || api === void 0 ? void 0 : (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : (_api$blockControls2$s = _api$blockControls2.sharedState.currentState()) === null || _api$blockControls2$s === void 0 ? void 0 : _api$blockControls2$s.menuTriggerBy;
|
|
149
|
+
if (options !== null && options !== void 0 && options.anchorName) {
|
|
150
|
+
const {
|
|
151
|
+
moveUp,
|
|
152
|
+
moveDown
|
|
153
|
+
} = canMoveNodeUpOrDown(tr);
|
|
154
|
+
toggleMenuMeta = {
|
|
155
|
+
...toggleMenuMeta,
|
|
156
|
+
moveUp,
|
|
157
|
+
moveDown,
|
|
158
|
+
openedViaKeyboard: options === null || options === void 0 ? void 0 : options.openedViaKeyboard
|
|
159
|
+
};
|
|
116
160
|
}
|
|
117
161
|
tr.setMeta(key, {
|
|
118
162
|
...currMeta,
|
|
119
|
-
|
|
163
|
+
toggleMenu: toggleMenuMeta
|
|
120
164
|
});
|
|
165
|
+
if ((menuTriggerBy === undefined || !!menuTriggerBy && menuTriggerBy === (options === null || options === void 0 ? void 0 : options.anchorName)) && currentUserIntent === 'blockMenuOpen') {
|
|
166
|
+
const state = api === null || api === void 0 ? void 0 : api.blockControls.sharedState.currentState();
|
|
167
|
+
if (state !== null && state !== void 0 && state.isSelectedViaDragHandle) {
|
|
168
|
+
var _api$userIntent4;
|
|
169
|
+
api === null || api === void 0 ? void 0 : (_api$userIntent4 = api.userIntent) === null || _api$userIntent4 === void 0 ? void 0 : _api$userIntent4.commands.setCurrentUserIntent('dragHandleSelected')({
|
|
170
|
+
tr
|
|
171
|
+
});
|
|
172
|
+
} else {
|
|
173
|
+
var _api$userIntent5;
|
|
174
|
+
// Toggled from drag handle
|
|
175
|
+
api === null || api === void 0 ? void 0 : (_api$userIntent5 = api.userIntent) === null || _api$userIntent5 === void 0 ? void 0 : _api$userIntent5.commands.setCurrentUserIntent('default')({
|
|
176
|
+
tr
|
|
177
|
+
});
|
|
178
|
+
}
|
|
121
179
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
180
|
+
// When closing the menu, restart the active session timer
|
|
181
|
+
if (fg('platform_editor_ease_of_use_metrics')) {
|
|
182
|
+
var _api$metrics3;
|
|
183
|
+
api === null || api === void 0 ? void 0 : (_api$metrics3 = api.metrics) === null || _api$metrics3 === void 0 ? void 0 : _api$metrics3.commands.startActiveSessionTimer()({
|
|
184
|
+
tr
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
} else if (!isMenuCurrentlyOpen) {
|
|
188
|
+
// When opening the menu, pause the active session timer
|
|
189
|
+
if (fg('platform_editor_ease_of_use_metrics')) {
|
|
190
|
+
var _api$metrics4;
|
|
191
|
+
api === null || api === void 0 ? void 0 : (_api$metrics4 = api.metrics) === null || _api$metrics4 === void 0 ? void 0 : _api$metrics4.commands.handleIntentToStartEdit({
|
|
192
|
+
shouldStartTimer: false,
|
|
193
|
+
shouldPersistActiveSession: true
|
|
194
|
+
})({
|
|
195
|
+
tr
|
|
196
|
+
});
|
|
197
|
+
}
|
|
128
198
|
}
|
|
129
199
|
return tr;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
moveUp,
|
|
139
|
-
moveDown
|
|
140
|
-
} = canMoveNodeUpOrDown(tr);
|
|
141
|
-
toggleMenuMeta = {
|
|
142
|
-
...toggleMenuMeta,
|
|
143
|
-
moveUp,
|
|
144
|
-
moveDown,
|
|
145
|
-
openedViaKeyboard: options === null || options === void 0 ? void 0 : options.openedViaKeyboard
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
tr.setMeta(key, {
|
|
149
|
-
...currMeta,
|
|
150
|
-
toggleMenu: toggleMenuMeta
|
|
151
|
-
});
|
|
152
|
-
if ((menuTriggerBy === undefined || !!menuTriggerBy && menuTriggerBy === (options === null || options === void 0 ? void 0 : options.anchorName)) && currentUserIntent === 'blockMenuOpen') {
|
|
153
|
-
const state = api === null || api === void 0 ? void 0 : api.blockControls.sharedState.currentState();
|
|
154
|
-
if (state !== null && state !== void 0 && state.isSelectedViaDragHandle) {
|
|
155
|
-
var _api$userIntent4;
|
|
156
|
-
api === null || api === void 0 ? void 0 : (_api$userIntent4 = api.userIntent) === null || _api$userIntent4 === void 0 ? void 0 : _api$userIntent4.commands.setCurrentUserIntent('dragHandleSelected')({
|
|
157
|
-
tr
|
|
158
|
-
});
|
|
159
|
-
} else {
|
|
160
|
-
var _api$userIntent5;
|
|
161
|
-
// Toggled from drag handle
|
|
162
|
-
api === null || api === void 0 ? void 0 : (_api$userIntent5 = api.userIntent) === null || _api$userIntent5 === void 0 ? void 0 : _api$userIntent5.commands.setCurrentUserIntent('default')({
|
|
163
|
-
tr
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// When closing the menu, restart the active session timer
|
|
168
|
-
if (fg('platform_editor_ease_of_use_metrics')) {
|
|
169
|
-
var _api$metrics3;
|
|
170
|
-
api === null || api === void 0 ? void 0 : (_api$metrics3 = api.metrics) === null || _api$metrics3 === void 0 ? void 0 : _api$metrics3.commands.startActiveSessionTimer()({
|
|
171
|
-
tr
|
|
172
|
-
});
|
|
200
|
+
},
|
|
201
|
+
setNodeDragged: (getPos, anchorName, nodeType) => ({
|
|
202
|
+
tr
|
|
203
|
+
}) => {
|
|
204
|
+
var _api$userIntent6;
|
|
205
|
+
const pos = getPos();
|
|
206
|
+
if (pos === undefined) {
|
|
207
|
+
return tr;
|
|
173
208
|
}
|
|
174
|
-
|
|
175
|
-
|
|
209
|
+
const currMeta = tr.getMeta(key);
|
|
210
|
+
tr.setMeta(key, {
|
|
211
|
+
...currMeta,
|
|
212
|
+
isDragging: true,
|
|
213
|
+
activeNode: {
|
|
214
|
+
pos,
|
|
215
|
+
anchorName,
|
|
216
|
+
nodeType
|
|
217
|
+
}
|
|
218
|
+
});
|
|
176
219
|
if (fg('platform_editor_ease_of_use_metrics')) {
|
|
177
|
-
var _api$
|
|
178
|
-
api === null || api === void 0 ? void 0 : (_api$
|
|
220
|
+
var _api$metrics5;
|
|
221
|
+
api === null || api === void 0 ? void 0 : (_api$metrics5 = api.metrics) === null || _api$metrics5 === void 0 ? void 0 : _api$metrics5.commands.handleIntentToStartEdit({
|
|
179
222
|
shouldStartTimer: false,
|
|
180
223
|
shouldPersistActiveSession: true
|
|
181
224
|
})({
|
|
182
225
|
tr
|
|
183
226
|
});
|
|
184
227
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
setNodeDragged: (getPos, anchorName, nodeType) => ({
|
|
189
|
-
tr
|
|
190
|
-
}) => {
|
|
191
|
-
var _api$userIntent6;
|
|
192
|
-
const pos = getPos();
|
|
193
|
-
if (pos === undefined) {
|
|
228
|
+
api === null || api === void 0 ? void 0 : (_api$userIntent6 = api.userIntent) === null || _api$userIntent6 === void 0 ? void 0 : _api$userIntent6.commands.setCurrentUserIntent('dragging')({
|
|
229
|
+
tr
|
|
230
|
+
});
|
|
194
231
|
return tr;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
232
|
+
},
|
|
233
|
+
setMultiSelectPositions: (anchor, head) => ({
|
|
234
|
+
tr
|
|
235
|
+
}) => {
|
|
236
|
+
var _api$selection, _$to$nodeBefore, _$from$nodeAfter;
|
|
237
|
+
const {
|
|
238
|
+
anchor: userAnchor,
|
|
239
|
+
head: userHead
|
|
240
|
+
} = tr.selection;
|
|
241
|
+
let $expandedAnchor, $expandedHead;
|
|
242
|
+
if (anchor !== undefined && head !== undefined) {
|
|
243
|
+
$expandedAnchor = tr.doc.resolve(anchor);
|
|
244
|
+
$expandedHead = tr.doc.resolve(head);
|
|
245
|
+
} else {
|
|
246
|
+
const expandedSelection = expandSelectionBounds(tr.selection.$anchor, tr.selection.$head);
|
|
247
|
+
$expandedAnchor = expandedSelection.$anchor;
|
|
248
|
+
$expandedHead = expandedSelection.$head;
|
|
204
249
|
}
|
|
205
|
-
|
|
206
|
-
if (fg('platform_editor_ease_of_use_metrics')) {
|
|
207
|
-
var _api$metrics5;
|
|
208
|
-
api === null || api === void 0 ? void 0 : (_api$metrics5 = api.metrics) === null || _api$metrics5 === void 0 ? void 0 : _api$metrics5.commands.handleIntentToStartEdit({
|
|
209
|
-
shouldStartTimer: false,
|
|
210
|
-
shouldPersistActiveSession: true
|
|
211
|
-
})({
|
|
250
|
+
api === null || api === void 0 ? void 0 : (_api$selection = api.selection) === null || _api$selection === void 0 ? void 0 : _api$selection.commands.setManualSelection($expandedAnchor.pos, $expandedHead.pos)({
|
|
212
251
|
tr
|
|
213
252
|
});
|
|
214
|
-
|
|
215
|
-
|
|
253
|
+
const $from = $expandedAnchor.min($expandedHead);
|
|
254
|
+
const $to = $expandedAnchor.max($expandedHead);
|
|
255
|
+
let expandedNormalisedSel;
|
|
256
|
+
if ($from.nodeAfter === $to.nodeBefore) {
|
|
257
|
+
selectNode(tr, $from.pos, $expandedAnchor.node().type.name, api);
|
|
258
|
+
expandedNormalisedSel = tr.selection;
|
|
259
|
+
} else if (((_$to$nodeBefore = $to.nodeBefore) === null || _$to$nodeBefore === void 0 ? void 0 : _$to$nodeBefore.type.name) === 'mediaSingle' || ((_$from$nodeAfter = $from.nodeAfter) === null || _$from$nodeAfter === void 0 ? void 0 : _$from$nodeAfter.type.name) === 'mediaSingle') {
|
|
260
|
+
expandedNormalisedSel = new TextSelection($expandedAnchor, $expandedHead);
|
|
261
|
+
tr.setSelection(expandedNormalisedSel);
|
|
262
|
+
} else {
|
|
263
|
+
// this is to normalise the selection's boundaries to inline positions, preventing it from collapsing
|
|
264
|
+
expandedNormalisedSel = TextSelection.between($expandedAnchor, $expandedHead);
|
|
265
|
+
tr.setSelection(expandedNormalisedSel);
|
|
266
|
+
}
|
|
267
|
+
const multiSelectDnD = {
|
|
268
|
+
anchor: $expandedAnchor.pos,
|
|
269
|
+
head: $expandedHead.pos,
|
|
270
|
+
textAnchor: expandedNormalisedSel.anchor,
|
|
271
|
+
textHead: expandedNormalisedSel.head,
|
|
272
|
+
userAnchor: userAnchor,
|
|
273
|
+
userHead: userHead
|
|
274
|
+
};
|
|
275
|
+
const currMeta = tr.getMeta(key);
|
|
276
|
+
tr.setMeta(key, {
|
|
277
|
+
...currMeta,
|
|
278
|
+
multiSelectDnD
|
|
279
|
+
});
|
|
280
|
+
return tr;
|
|
281
|
+
},
|
|
282
|
+
setSelectedViaDragHandle: isSelectedViaDragHandle => ({
|
|
216
283
|
tr
|
|
217
|
-
})
|
|
218
|
-
|
|
284
|
+
}) => {
|
|
285
|
+
const currMeta = tr.getMeta(key);
|
|
286
|
+
return tr.setMeta(key, {
|
|
287
|
+
...currMeta,
|
|
288
|
+
isSelectedViaDragHandle
|
|
289
|
+
});
|
|
290
|
+
},
|
|
291
|
+
mapPreservedSelection: mapping => mapPreservedSelection(mapping),
|
|
292
|
+
moveNodeWithBlockMenu: direction => moveNodeWithBlockMenu(api, direction),
|
|
293
|
+
handleKeyDownWithPreservedSelection: handleKeyDownWithPreservedSelection(api),
|
|
294
|
+
startPreservingSelection: () => startPreservingSelection,
|
|
295
|
+
stopPreservingSelection: () => stopPreservingSelection
|
|
219
296
|
},
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
const {
|
|
225
|
-
anchor: userAnchor,
|
|
226
|
-
head: userHead
|
|
227
|
-
} = tr.selection;
|
|
228
|
-
let $expandedAnchor, $expandedHead;
|
|
229
|
-
if (anchor !== undefined && head !== undefined) {
|
|
230
|
-
$expandedAnchor = tr.doc.resolve(anchor);
|
|
231
|
-
$expandedHead = tr.doc.resolve(head);
|
|
232
|
-
} else {
|
|
233
|
-
const expandedSelection = expandSelectionBounds(tr.selection.$anchor, tr.selection.$head);
|
|
234
|
-
$expandedAnchor = expandedSelection.$anchor;
|
|
235
|
-
$expandedHead = expandedSelection.$head;
|
|
297
|
+
getSharedState(editorState) {
|
|
298
|
+
var _key$getState$isMenuO, _key$getState, _key$getState$menuTri, _key$getState2, _key$getState$menuTri2, _key$getState3, _key$getState$blockMe, _key$getState4, _key$getState$activeN, _key$getState5, _key$getState$activeD, _key$getState6, _key$getState$isDragg, _key$getState7, _key$getState$isPMDra, _key$getState8, _key$getState$multiSe, _key$getState9, _key$getState$isShift, _key$getState0, _key$getState$lastDra, _key$getState1, _interactionTrackingP, _key$getState$isSelec, _key$getState10;
|
|
299
|
+
if (!editorState) {
|
|
300
|
+
return undefined;
|
|
236
301
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
expandedNormalisedSel = TextSelection.between($expandedAnchor, $expandedHead);
|
|
252
|
-
tr.setSelection(expandedNormalisedSel);
|
|
253
|
-
}
|
|
254
|
-
const multiSelectDnD = {
|
|
255
|
-
anchor: $expandedAnchor.pos,
|
|
256
|
-
head: $expandedHead.pos,
|
|
257
|
-
textAnchor: expandedNormalisedSel.anchor,
|
|
258
|
-
textHead: expandedNormalisedSel.head,
|
|
259
|
-
userAnchor: userAnchor,
|
|
260
|
-
userHead: userHead
|
|
302
|
+
const sharedState = {
|
|
303
|
+
isMenuOpen: (_key$getState$isMenuO = (_key$getState = key.getState(editorState)) === null || _key$getState === void 0 ? void 0 : _key$getState.isMenuOpen) !== null && _key$getState$isMenuO !== void 0 ? _key$getState$isMenuO : false,
|
|
304
|
+
menuTriggerBy: (_key$getState$menuTri = (_key$getState2 = key.getState(editorState)) === null || _key$getState2 === void 0 ? void 0 : _key$getState2.menuTriggerBy) !== null && _key$getState$menuTri !== void 0 ? _key$getState$menuTri : undefined,
|
|
305
|
+
menuTriggerByNode: (_key$getState$menuTri2 = (_key$getState3 = key.getState(editorState)) === null || _key$getState3 === void 0 ? void 0 : _key$getState3.menuTriggerByNode) !== null && _key$getState$menuTri2 !== void 0 ? _key$getState$menuTri2 : undefined,
|
|
306
|
+
blockMenuOptions: (_key$getState$blockMe = (_key$getState4 = key.getState(editorState)) === null || _key$getState4 === void 0 ? void 0 : _key$getState4.blockMenuOptions) !== null && _key$getState$blockMe !== void 0 ? _key$getState$blockMe : undefined,
|
|
307
|
+
activeNode: (_key$getState$activeN = (_key$getState5 = key.getState(editorState)) === null || _key$getState5 === void 0 ? void 0 : _key$getState5.activeNode) !== null && _key$getState$activeN !== void 0 ? _key$getState$activeN : undefined,
|
|
308
|
+
activeDropTargetNode: (_key$getState$activeD = (_key$getState6 = key.getState(editorState)) === null || _key$getState6 === void 0 ? void 0 : _key$getState6.activeDropTargetNode) !== null && _key$getState$activeD !== void 0 ? _key$getState$activeD : undefined,
|
|
309
|
+
isDragging: (_key$getState$isDragg = (_key$getState7 = key.getState(editorState)) === null || _key$getState7 === void 0 ? void 0 : _key$getState7.isDragging) !== null && _key$getState$isDragg !== void 0 ? _key$getState$isDragg : false,
|
|
310
|
+
isPMDragging: (_key$getState$isPMDra = (_key$getState8 = key.getState(editorState)) === null || _key$getState8 === void 0 ? void 0 : _key$getState8.isPMDragging) !== null && _key$getState$isPMDra !== void 0 ? _key$getState$isPMDra : false,
|
|
311
|
+
multiSelectDnD: (_key$getState$multiSe = (_key$getState9 = key.getState(editorState)) === null || _key$getState9 === void 0 ? void 0 : _key$getState9.multiSelectDnD) !== null && _key$getState$multiSe !== void 0 ? _key$getState$multiSe : undefined,
|
|
312
|
+
isShiftDown: (_key$getState$isShift = (_key$getState0 = key.getState(editorState)) === null || _key$getState0 === void 0 ? void 0 : _key$getState0.isShiftDown) !== null && _key$getState$isShift !== void 0 ? _key$getState$isShift : undefined,
|
|
313
|
+
lastDragCancelled: (_key$getState$lastDra = (_key$getState1 = key.getState(editorState)) === null || _key$getState1 === void 0 ? void 0 : _key$getState1.lastDragCancelled) !== null && _key$getState$lastDra !== void 0 ? _key$getState$lastDra : false,
|
|
314
|
+
isEditing: (_interactionTrackingP = interactionTrackingPluginKey.getState(editorState)) === null || _interactionTrackingP === void 0 ? void 0 : _interactionTrackingP.isEditing,
|
|
315
|
+
isSelectedViaDragHandle: (_key$getState$isSelec = (_key$getState10 = key.getState(editorState)) === null || _key$getState10 === void 0 ? void 0 : _key$getState10.isSelectedViaDragHandle) !== null && _key$getState$isSelec !== void 0 ? _key$getState$isSelec : false
|
|
261
316
|
};
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
317
|
+
if (editorExperiment('platform_editor_controls', 'variant1')) {
|
|
318
|
+
var _interactionTrackingP2, _interactionTrackingP3;
|
|
319
|
+
sharedState.isMouseOut = (_interactionTrackingP2 = (_interactionTrackingP3 = interactionTrackingPluginKey.getState(editorState)) === null || _interactionTrackingP3 === void 0 ? void 0 : _interactionTrackingP3.isMouseOut) !== null && _interactionTrackingP2 !== void 0 ? _interactionTrackingP2 : false;
|
|
320
|
+
}
|
|
321
|
+
if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
|
|
322
|
+
var _selectionPreservatio;
|
|
323
|
+
sharedState.preservedSelection = (_selectionPreservatio = selectionPreservationPluginKey.getState(editorState)) === null || _selectionPreservatio === void 0 ? void 0 : _selectionPreservatio.preservedSelection;
|
|
324
|
+
}
|
|
325
|
+
return sharedState;
|
|
268
326
|
},
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
const currMeta = tr.getMeta(key);
|
|
273
|
-
return tr.setMeta(key, {
|
|
274
|
-
...currMeta,
|
|
275
|
-
isSelectedViaDragHandle
|
|
327
|
+
contentComponent() {
|
|
328
|
+
return /*#__PURE__*/React.createElement(GlobalStylesWrapper, {
|
|
329
|
+
api: api
|
|
276
330
|
});
|
|
277
|
-
},
|
|
278
|
-
mapPreservedSelection: mapping => mapPreservedSelection(mapping),
|
|
279
|
-
moveNodeWithBlockMenu: direction => moveNodeWithBlockMenu(api, direction),
|
|
280
|
-
handleKeyDownWithPreservedSelection: handleKeyDownWithPreservedSelection(api),
|
|
281
|
-
startPreservingSelection: () => startPreservingSelection,
|
|
282
|
-
stopPreservingSelection: () => stopPreservingSelection
|
|
283
|
-
},
|
|
284
|
-
getSharedState(editorState) {
|
|
285
|
-
var _key$getState$isMenuO, _key$getState, _key$getState$menuTri, _key$getState2, _key$getState$menuTri2, _key$getState3, _key$getState$blockMe, _key$getState4, _key$getState$activeN, _key$getState5, _key$getState$activeD, _key$getState6, _key$getState$isDragg, _key$getState7, _key$getState$isPMDra, _key$getState8, _key$getState$multiSe, _key$getState9, _key$getState$isShift, _key$getState0, _key$getState$lastDra, _key$getState1, _interactionTrackingP, _key$getState$isSelec, _key$getState10;
|
|
286
|
-
if (!editorState) {
|
|
287
|
-
return undefined;
|
|
288
|
-
}
|
|
289
|
-
const sharedState = {
|
|
290
|
-
isMenuOpen: (_key$getState$isMenuO = (_key$getState = key.getState(editorState)) === null || _key$getState === void 0 ? void 0 : _key$getState.isMenuOpen) !== null && _key$getState$isMenuO !== void 0 ? _key$getState$isMenuO : false,
|
|
291
|
-
menuTriggerBy: (_key$getState$menuTri = (_key$getState2 = key.getState(editorState)) === null || _key$getState2 === void 0 ? void 0 : _key$getState2.menuTriggerBy) !== null && _key$getState$menuTri !== void 0 ? _key$getState$menuTri : undefined,
|
|
292
|
-
menuTriggerByNode: (_key$getState$menuTri2 = (_key$getState3 = key.getState(editorState)) === null || _key$getState3 === void 0 ? void 0 : _key$getState3.menuTriggerByNode) !== null && _key$getState$menuTri2 !== void 0 ? _key$getState$menuTri2 : undefined,
|
|
293
|
-
blockMenuOptions: (_key$getState$blockMe = (_key$getState4 = key.getState(editorState)) === null || _key$getState4 === void 0 ? void 0 : _key$getState4.blockMenuOptions) !== null && _key$getState$blockMe !== void 0 ? _key$getState$blockMe : undefined,
|
|
294
|
-
activeNode: (_key$getState$activeN = (_key$getState5 = key.getState(editorState)) === null || _key$getState5 === void 0 ? void 0 : _key$getState5.activeNode) !== null && _key$getState$activeN !== void 0 ? _key$getState$activeN : undefined,
|
|
295
|
-
activeDropTargetNode: (_key$getState$activeD = (_key$getState6 = key.getState(editorState)) === null || _key$getState6 === void 0 ? void 0 : _key$getState6.activeDropTargetNode) !== null && _key$getState$activeD !== void 0 ? _key$getState$activeD : undefined,
|
|
296
|
-
isDragging: (_key$getState$isDragg = (_key$getState7 = key.getState(editorState)) === null || _key$getState7 === void 0 ? void 0 : _key$getState7.isDragging) !== null && _key$getState$isDragg !== void 0 ? _key$getState$isDragg : false,
|
|
297
|
-
isPMDragging: (_key$getState$isPMDra = (_key$getState8 = key.getState(editorState)) === null || _key$getState8 === void 0 ? void 0 : _key$getState8.isPMDragging) !== null && _key$getState$isPMDra !== void 0 ? _key$getState$isPMDra : false,
|
|
298
|
-
multiSelectDnD: (_key$getState$multiSe = (_key$getState9 = key.getState(editorState)) === null || _key$getState9 === void 0 ? void 0 : _key$getState9.multiSelectDnD) !== null && _key$getState$multiSe !== void 0 ? _key$getState$multiSe : undefined,
|
|
299
|
-
isShiftDown: (_key$getState$isShift = (_key$getState0 = key.getState(editorState)) === null || _key$getState0 === void 0 ? void 0 : _key$getState0.isShiftDown) !== null && _key$getState$isShift !== void 0 ? _key$getState$isShift : undefined,
|
|
300
|
-
lastDragCancelled: (_key$getState$lastDra = (_key$getState1 = key.getState(editorState)) === null || _key$getState1 === void 0 ? void 0 : _key$getState1.lastDragCancelled) !== null && _key$getState$lastDra !== void 0 ? _key$getState$lastDra : false,
|
|
301
|
-
isEditing: (_interactionTrackingP = interactionTrackingPluginKey.getState(editorState)) === null || _interactionTrackingP === void 0 ? void 0 : _interactionTrackingP.isEditing,
|
|
302
|
-
isSelectedViaDragHandle: (_key$getState$isSelec = (_key$getState10 = key.getState(editorState)) === null || _key$getState10 === void 0 ? void 0 : _key$getState10.isSelectedViaDragHandle) !== null && _key$getState$isSelec !== void 0 ? _key$getState$isSelec : false
|
|
303
|
-
};
|
|
304
|
-
if (editorExperiment('platform_editor_controls', 'variant1')) {
|
|
305
|
-
var _interactionTrackingP2, _interactionTrackingP3;
|
|
306
|
-
sharedState.isMouseOut = (_interactionTrackingP2 = (_interactionTrackingP3 = interactionTrackingPluginKey.getState(editorState)) === null || _interactionTrackingP3 === void 0 ? void 0 : _interactionTrackingP3.isMouseOut) !== null && _interactionTrackingP2 !== void 0 ? _interactionTrackingP2 : false;
|
|
307
|
-
}
|
|
308
|
-
if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
|
|
309
|
-
var _selectionPreservatio;
|
|
310
|
-
sharedState.preservedSelection = (_selectionPreservatio = selectionPreservationPluginKey.getState(editorState)) === null || _selectionPreservatio === void 0 ? void 0 : _selectionPreservatio.preservedSelection;
|
|
311
331
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
contentComponent() {
|
|
315
|
-
return /*#__PURE__*/React.createElement(GlobalStylesWrapper, {
|
|
316
|
-
api: api
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
|
-
});
|
|
332
|
+
};
|
|
333
|
+
};
|