@atlaskit/editor-plugin-block-controls 3.2.1 → 3.3.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 +24 -0
- package/dist/cjs/blockControlsPlugin.js +10 -0
- package/dist/cjs/editor-commands/move-node.js +58 -29
- package/dist/cjs/editor-commands/move-to-layout.js +6 -0
- package/dist/cjs/pm-plugins/main.js +34 -15
- package/dist/cjs/pm-plugins/utils/getSelection.js +38 -14
- package/dist/cjs/ui/drag-handle.js +1 -1
- package/dist/es2019/blockControlsPlugin.js +10 -0
- package/dist/es2019/editor-commands/move-node.js +59 -29
- package/dist/es2019/editor-commands/move-to-layout.js +6 -0
- package/dist/es2019/pm-plugins/main.js +34 -15
- package/dist/es2019/pm-plugins/utils/getSelection.js +38 -14
- package/dist/es2019/ui/drag-handle.js +1 -1
- package/dist/esm/blockControlsPlugin.js +10 -0
- package/dist/esm/editor-commands/move-node.js +58 -29
- package/dist/esm/editor-commands/move-to-layout.js +6 -0
- package/dist/esm/pm-plugins/main.js +34 -15
- package/dist/esm/pm-plugins/utils/getSelection.js +38 -14
- package/dist/esm/ui/drag-handle.js +1 -1
- package/dist/types/blockControlsPluginType.d.ts +3 -1
- package/dist/types/ui/block-menu.d.ts +1 -1
- package/dist/types-ts4.5/blockControlsPluginType.d.ts +3 -1
- package/dist/types-ts4.5/ui/block-menu.d.ts +1 -1
- package/package.json +6 -2
|
@@ -131,6 +131,12 @@ var destroyFn = function destroyFn(api, editorView) {
|
|
|
131
131
|
})
|
|
132
132
|
})(tr);
|
|
133
133
|
}
|
|
134
|
+
if (fg('platform_editor_ease_of_use_metrics')) {
|
|
135
|
+
var _api$metrics;
|
|
136
|
+
api === null || api === void 0 || (_api$metrics = api.metrics) === null || _api$metrics === void 0 || _api$metrics.commands.startActiveSessionTimer()({
|
|
137
|
+
tr: tr
|
|
138
|
+
});
|
|
139
|
+
}
|
|
134
140
|
return tr.setMeta(key, _objectSpread(_objectSpread({}, tr.getMeta(key)), {}, {
|
|
135
141
|
isDragging: false,
|
|
136
142
|
isPMDragging: false,
|
|
@@ -306,24 +312,23 @@ export var newApply = function newApply(api, formatMessage, tr, currentState, ne
|
|
|
306
312
|
var oldHandle = findHandleDec(decorations, (_activeNode3 = activeNode) === null || _activeNode3 === void 0 ? void 0 : _activeNode3.pos, (_activeNode4 = activeNode) === null || _activeNode4 === void 0 ? void 0 : _activeNode4.pos);
|
|
307
313
|
decorations = decorations.remove(oldHandle);
|
|
308
314
|
if (editorExperiment('platform_editor_controls', 'variant1')) {
|
|
309
|
-
var
|
|
310
|
-
var oldQuickInsertButton = findQuickInsertInsertButtonDecoration(decorations, (_activeNode5 = activeNode) === null || _activeNode5 === void 0 ? void 0 : _activeNode5.rootPos, (_activeNode6 = activeNode) === null || _activeNode6 === void 0 ? void 0 : _activeNode6.rootPos);
|
|
315
|
+
var oldQuickInsertButton = findQuickInsertInsertButtonDecoration(decorations);
|
|
311
316
|
decorations = decorations.remove(oldQuickInsertButton);
|
|
312
317
|
}
|
|
313
318
|
} else if (api && shouldRecreateHandle) {
|
|
314
|
-
var
|
|
315
|
-
var _oldHandle = findHandleDec(decorations, (
|
|
319
|
+
var _activeNode5, _activeNode6;
|
|
320
|
+
var _oldHandle = findHandleDec(decorations, (_activeNode5 = activeNode) === null || _activeNode5 === void 0 ? void 0 : _activeNode5.pos, (_activeNode6 = activeNode) === null || _activeNode6 === void 0 ? void 0 : _activeNode6.pos);
|
|
316
321
|
decorations = decorations.remove(_oldHandle);
|
|
317
322
|
var handleDec = dragHandleDecoration(api, formatMessage, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.pos, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.anchorName, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.nodeType, nodeViewPortalProviderAPI, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.handleOptions);
|
|
318
323
|
if (editorExperiment('platform_editor_controls', 'variant1')) {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
decorations = decorations.add(newState.doc, [handleDec]);
|
|
324
|
+
if ((latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.rootPos) !== undefined) {
|
|
325
|
+
var _oldQuickInsertButton = findQuickInsertInsertButtonDecoration(decorations);
|
|
326
|
+
decorations = decorations.remove(_oldQuickInsertButton);
|
|
327
|
+
var quickInsertButton = quickInsertButtonDecoration(api, formatMessage, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.rootPos, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.anchorName, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.nodeType, nodeViewPortalProviderAPI, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.rootAnchorName, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.rootNodeType);
|
|
328
|
+
decorations = decorations.add(newState.doc, [quickInsertButton]);
|
|
329
|
+
}
|
|
326
330
|
}
|
|
331
|
+
decorations = decorations.add(newState.doc, [handleDec]);
|
|
327
332
|
}
|
|
328
333
|
|
|
329
334
|
// Drop targets may be missing when the node count is being changed during a drag
|
|
@@ -584,7 +589,7 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
584
589
|
},
|
|
585
590
|
handleDOMEvents: {
|
|
586
591
|
drop: function drop(view, event) {
|
|
587
|
-
var _pluginState, _pluginState2, _pluginState3, _event$target;
|
|
592
|
+
var _pluginState, _pluginState2, _pluginState3, _event$target, _event$target$closest;
|
|
588
593
|
// Prevent native DnD from triggering if we are in drag
|
|
589
594
|
var dispatch = view.dispatch,
|
|
590
595
|
dragging = view.dragging,
|
|
@@ -593,6 +598,12 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
593
598
|
var pluginState = key.getState(state);
|
|
594
599
|
var dndDragCancelled = (_pluginState = pluginState) === null || _pluginState === void 0 ? void 0 : _pluginState.lastDragCancelled;
|
|
595
600
|
if ((_pluginState2 = pluginState) !== null && _pluginState2 !== void 0 && _pluginState2.isPMDragging || dndDragCancelled && isMultiSelectEnabled) {
|
|
601
|
+
if (fg('platform_editor_ease_of_use_metrics')) {
|
|
602
|
+
var _api$metrics2;
|
|
603
|
+
api === null || api === void 0 || (_api$metrics2 = api.metrics) === null || _api$metrics2 === void 0 || _api$metrics2.commands.startActiveSessionTimer()({
|
|
604
|
+
tr: tr
|
|
605
|
+
});
|
|
606
|
+
}
|
|
596
607
|
dispatch(tr.setMeta(key, _objectSpread(_objectSpread({}, tr.getMeta(key)), {}, {
|
|
597
608
|
isPMDragging: false,
|
|
598
609
|
lastDragCancelled: false
|
|
@@ -610,7 +621,7 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
610
621
|
event.preventDefault();
|
|
611
622
|
return false;
|
|
612
623
|
}
|
|
613
|
-
var nodeElement = (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.
|
|
624
|
+
var nodeElement = (_event$target = event.target) === null || _event$target === void 0 || (_event$target$closest = _event$target.closest) === null || _event$target$closest === void 0 ? void 0 : _event$target$closest.call(_event$target, '[data-drag-handler-anchor-name]');
|
|
614
625
|
if (!nodeElement) {
|
|
615
626
|
return false;
|
|
616
627
|
}
|
|
@@ -656,9 +667,17 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
656
667
|
var state = view.state,
|
|
657
668
|
dispatch = view.dispatch;
|
|
658
669
|
if ((_key$getState3 = key.getState(state)) !== null && _key$getState3 !== void 0 && _key$getState3.isPMDragging) {
|
|
659
|
-
|
|
670
|
+
var tr = state.tr;
|
|
671
|
+
tr.setMeta(key, _objectSpread(_objectSpread({}, state.tr.getMeta(key)), {}, {
|
|
660
672
|
isPMDragging: false
|
|
661
|
-
}))
|
|
673
|
+
}));
|
|
674
|
+
if (fg('platform_editor_ease_of_use_metrics')) {
|
|
675
|
+
var _api$metrics3;
|
|
676
|
+
api === null || api === void 0 || (_api$metrics3 = api.metrics) === null || _api$metrics3 === void 0 || _api$metrics3.commands.startActiveSessionTimer()({
|
|
677
|
+
tr: tr
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
dispatch(tr);
|
|
662
681
|
}
|
|
663
682
|
},
|
|
664
683
|
mouseover: function mouseover(view, event) {
|
|
@@ -2,6 +2,7 @@ import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
|
|
|
2
2
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
4
4
|
import { selectTableClosestToPos } from '@atlaskit/editor-tables/utils';
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
6
|
export var getInlineNodePos = function getInlineNodePos(tr, start, nodeSize) {
|
|
6
7
|
var $startPos = tr.doc.resolve(start);
|
|
7
8
|
// To trigger the annotation floating toolbar for non-selectable node, we need to select inline nodes
|
|
@@ -53,6 +54,8 @@ export var getSelection = function getSelection(tr, start) {
|
|
|
53
54
|
// we need a quick way to make all child media nodes appear as selected without the need for a custom selection
|
|
54
55
|
nodeName === 'mediaGroup') {
|
|
55
56
|
return new NodeSelection($startPos);
|
|
57
|
+
} else if (nodeName === 'taskList' && fg('platform_editor_elements_dnd_multi_select_patch_1')) {
|
|
58
|
+
return TextSelection.create(tr.doc, start, start + nodeSize);
|
|
56
59
|
} else {
|
|
57
60
|
var _getInlineNodePos = getInlineNodePos(tr, start, nodeSize),
|
|
58
61
|
inlineNodePos = _getInlineNodePos.inlineNodePos,
|
|
@@ -98,21 +101,42 @@ export var isHandleCorrelatedToSelection = function isHandleCorrelatedToSelectio
|
|
|
98
101
|
if (selection.empty) {
|
|
99
102
|
return false;
|
|
100
103
|
}
|
|
104
|
+
var nodeStart;
|
|
101
105
|
var $selectionFrom = selection.$from;
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
var
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
106
|
+
if (fg('platform_editor_elements_dnd_multi_select_patch_1')) {
|
|
107
|
+
nodeStart = $selectionFrom.before($selectionFrom.sharedDepth(selection.to) + 1);
|
|
108
|
+
if (nodeStart === $selectionFrom.pos) {
|
|
109
|
+
nodeStart = $selectionFrom.depth ? $selectionFrom.before() : $selectionFrom.pos;
|
|
110
|
+
}
|
|
111
|
+
var $resolvedNodePos = state.doc.resolve(nodeStart);
|
|
112
|
+
if (['tableRow', 'tableCell', 'tableHeader'].includes($resolvedNodePos.node().type.name)) {
|
|
113
|
+
var parentNodeFindRes = findParentNodeOfType(state.schema.nodes['table'])(selection);
|
|
114
|
+
var tablePos = parentNodeFindRes === null || parentNodeFindRes === void 0 ? void 0 : parentNodeFindRes.pos;
|
|
115
|
+
nodeStart = typeof tablePos === 'undefined' ? nodeStart : tablePos;
|
|
116
|
+
} else if (['listItem'].includes($resolvedNodePos.node().type.name)) {
|
|
117
|
+
nodeStart = $resolvedNodePos.before(rootListDepth($resolvedNodePos));
|
|
118
|
+
} else if (['taskList'].includes($resolvedNodePos.node().type.name)) {
|
|
119
|
+
var listdepth = rootTaskListDepth($resolvedNodePos);
|
|
120
|
+
nodeStart = $resolvedNodePos.before(listdepth);
|
|
121
|
+
} else if (['blockquote'].includes($resolvedNodePos.node().type.name)) {
|
|
122
|
+
nodeStart = $resolvedNodePos.before();
|
|
123
|
+
}
|
|
124
|
+
} else {
|
|
125
|
+
var selectionFrom = $selectionFrom.pos;
|
|
126
|
+
nodeStart = $selectionFrom.depth ? $selectionFrom.before() : selectionFrom;
|
|
127
|
+
var _$resolvedNodePos = state.doc.resolve(nodeStart);
|
|
128
|
+
if (['tableRow', 'tableCell', 'tableHeader'].includes(_$resolvedNodePos.node().type.name)) {
|
|
129
|
+
var _parentNodeFindRes = findParentNodeOfType(state.schema.nodes['table'])(selection);
|
|
130
|
+
var _tablePos = _parentNodeFindRes === null || _parentNodeFindRes === void 0 ? void 0 : _parentNodeFindRes.pos;
|
|
131
|
+
nodeStart = typeof _tablePos === 'undefined' ? nodeStart : _tablePos;
|
|
132
|
+
} else if (['listItem'].includes(_$resolvedNodePos.node().type.name)) {
|
|
133
|
+
nodeStart = _$resolvedNodePos.before(rootListDepth(_$resolvedNodePos));
|
|
134
|
+
} else if (['taskList'].includes(_$resolvedNodePos.node().type.name)) {
|
|
135
|
+
var _listdepth = rootTaskListDepth(_$resolvedNodePos);
|
|
136
|
+
nodeStart = _$resolvedNodePos.before(_listdepth);
|
|
137
|
+
} else if (['blockquote'].includes(_$resolvedNodePos.node().type.name)) {
|
|
138
|
+
nodeStart = _$resolvedNodePos.before();
|
|
139
|
+
}
|
|
116
140
|
}
|
|
117
141
|
return Boolean(handlePos < selection.$to.pos && handlePos >= nodeStart);
|
|
118
142
|
};
|
|
@@ -303,7 +303,7 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
303
303
|
return tr;
|
|
304
304
|
}
|
|
305
305
|
var oldHandlePosCheck = handlePos >= tr.selection.$from.start() - 1 && handlePos <= tr.selection.to;
|
|
306
|
-
var newHandlePosCheck =
|
|
306
|
+
var newHandlePosCheck = isHandleCorrelatedToSelection(view.state, tr.selection, handlePos);
|
|
307
307
|
if (!tr.selection.empty && (fg('platform_editor_elements_dnd_multi_select_patch_1') ? newHandlePosCheck : oldHandlePosCheck)) {
|
|
308
308
|
var _api$blockControls4;
|
|
309
309
|
api === null || api === void 0 || (_api$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 || _api$blockControls4.commands.setMultiSelectPositions()({
|
|
@@ -5,6 +5,7 @@ import type { AccessibilityUtilsPlugin } from '@atlaskit/editor-plugin-accessibi
|
|
|
5
5
|
import { type AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
6
6
|
import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
|
|
7
7
|
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
8
|
+
import type { MetricsPlugin } from '@atlaskit/editor-plugin-metrics';
|
|
8
9
|
import type { QuickInsertPlugin } from '@atlaskit/editor-plugin-quick-insert';
|
|
9
10
|
import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
|
|
10
11
|
import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
|
|
@@ -74,7 +75,8 @@ export type BlockControlsPluginDependencies = [
|
|
|
74
75
|
* Clean up ticket ED-24824
|
|
75
76
|
*/
|
|
76
77
|
OptionalPlugin<QuickInsertPlugin>,
|
|
77
|
-
OptionalPlugin<SelectionPlugin
|
|
78
|
+
OptionalPlugin<SelectionPlugin>,
|
|
79
|
+
OptionalPlugin<MetricsPlugin>
|
|
78
80
|
];
|
|
79
81
|
export type BlockControlsPlugin = NextEditorPlugin<'blockControls', {
|
|
80
82
|
dependencies: BlockControlsPluginDependencies;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { WrappedComponentProps } from 'react-intl-next';
|
|
3
3
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/
|
|
4
|
+
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
5
|
import type { BlockControlsPlugin } from '../blockControlsPluginType';
|
|
6
6
|
type BlockMenuProps = {
|
|
7
7
|
editorView: EditorView | undefined;
|
|
@@ -5,6 +5,7 @@ import type { AccessibilityUtilsPlugin } from '@atlaskit/editor-plugin-accessibi
|
|
|
5
5
|
import { type AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
6
6
|
import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
|
|
7
7
|
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
8
|
+
import type { MetricsPlugin } from '@atlaskit/editor-plugin-metrics';
|
|
8
9
|
import type { QuickInsertPlugin } from '@atlaskit/editor-plugin-quick-insert';
|
|
9
10
|
import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
|
|
10
11
|
import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
|
|
@@ -74,7 +75,8 @@ export type BlockControlsPluginDependencies = [
|
|
|
74
75
|
* Clean up ticket ED-24824
|
|
75
76
|
*/
|
|
76
77
|
OptionalPlugin<QuickInsertPlugin>,
|
|
77
|
-
OptionalPlugin<SelectionPlugin
|
|
78
|
+
OptionalPlugin<SelectionPlugin>,
|
|
79
|
+
OptionalPlugin<MetricsPlugin>
|
|
78
80
|
];
|
|
79
81
|
export type BlockControlsPlugin = NextEditorPlugin<'blockControls', {
|
|
80
82
|
dependencies: BlockControlsPluginDependencies;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { WrappedComponentProps } from 'react-intl-next';
|
|
3
3
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/
|
|
4
|
+
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
5
|
import type { BlockControlsPlugin } from '../blockControlsPluginType';
|
|
6
6
|
type BlockMenuProps = {
|
|
7
7
|
editorView: EditorView | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.1",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,11 +33,12 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@atlaskit/adf-schema": "^47.6.0",
|
|
36
|
-
"@atlaskit/editor-common": "^101.
|
|
36
|
+
"@atlaskit/editor-common": "^101.1.0",
|
|
37
37
|
"@atlaskit/editor-plugin-accessibility-utils": "^2.0.0",
|
|
38
38
|
"@atlaskit/editor-plugin-analytics": "^2.1.0",
|
|
39
39
|
"@atlaskit/editor-plugin-editor-disabled": "^2.0.0",
|
|
40
40
|
"@atlaskit/editor-plugin-feature-flags": "^1.3.0",
|
|
41
|
+
"@atlaskit/editor-plugin-metrics": "^3.4.0",
|
|
41
42
|
"@atlaskit/editor-plugin-quick-insert": "^2.0.0",
|
|
42
43
|
"@atlaskit/editor-plugin-selection": "^2.0.0",
|
|
43
44
|
"@atlaskit/editor-plugin-width": "^3.0.0",
|
|
@@ -162,6 +163,9 @@
|
|
|
162
163
|
},
|
|
163
164
|
"platform_editor_elements_dnd_select_node_on_drag": {
|
|
164
165
|
"type": "boolean"
|
|
166
|
+
},
|
|
167
|
+
"platform_editor_ease_of_use_metrics": {
|
|
168
|
+
"type": "boolean"
|
|
165
169
|
}
|
|
166
170
|
}
|
|
167
171
|
}
|