@atlaskit/editor-plugin-block-controls 2.16.3 → 2.16.4
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 +11 -0
- package/dist/cjs/pm-plugins/handle-mouse-over.js +4 -0
- package/dist/cjs/pm-plugins/main.js +27 -4
- package/dist/es2019/pm-plugins/handle-mouse-over.js +4 -0
- package/dist/es2019/pm-plugins/main.js +29 -4
- package/dist/esm/pm-plugins/handle-mouse-over.js +4 -0
- package/dist/esm/pm-plugins/main.js +27 -4
- package/package.json +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 2.16.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#97978](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/97978)
|
|
8
|
+
[`ea88bd7273c73`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ea88bd7273c73) -
|
|
9
|
+
Added Blocks Drag Init measurement analytics event
|
|
10
|
+
- [#99482](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/99482)
|
|
11
|
+
[`5fdd98e19255d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5fdd98e19255d) -
|
|
12
|
+
ED-26122 disable drag layout column for single column layout
|
|
13
|
+
|
|
3
14
|
## 2.16.3
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -92,6 +92,10 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
|
|
|
92
92
|
} else {
|
|
93
93
|
pos = view.posAtDOM(rootElement, 0);
|
|
94
94
|
}
|
|
95
|
+
if (parentRootElement && parentRootElement.getAttribute('data-layout-section') === 'true' && parentRootElement.querySelectorAll('[data-layout-column]').length === 1 && (0, _experiments.editorExperiment)('advanced_layouts', true) && (0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_3')) {
|
|
96
|
+
// Don't show drag handle for layout column in a single column layout
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
95
99
|
var rootPos;
|
|
96
100
|
if ((0, _experiments.editorExperiment)('nested-dnd', true)) {
|
|
97
101
|
rootPos = view.state.doc.resolve(pos).pos;
|
|
@@ -10,6 +10,7 @@ var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
|
10
10
|
var _steps = require("@atlaskit/adf-schema/steps");
|
|
11
11
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
12
12
|
var _browser = require("@atlaskit/editor-common/browser");
|
|
13
|
+
var _performanceMeasures = require("@atlaskit/editor-common/performance-measures");
|
|
13
14
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
14
15
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
15
16
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
@@ -29,10 +30,11 @@ var _anchorUtils = require("./utils/anchor-utils");
|
|
|
29
30
|
var _dragTargetDebug = require("./utils/drag-target-debug");
|
|
30
31
|
var _transactions = require("./utils/transactions");
|
|
31
32
|
var key = exports.key = new _state.PluginKey('blockControls');
|
|
33
|
+
var EDITOR_BLOCKS_DRAG_INIT = 'Editor Blocks Drag Initialization Time';
|
|
32
34
|
var isHTMLElement = function isHTMLElement(element) {
|
|
33
35
|
return element instanceof HTMLElement;
|
|
34
36
|
};
|
|
35
|
-
var destroyFn = function destroyFn(api) {
|
|
37
|
+
var destroyFn = function destroyFn(api, editorView) {
|
|
36
38
|
var scrollable = document.querySelector('.fabric-editor-popup-scroll-parent');
|
|
37
39
|
var cleanupFn = [];
|
|
38
40
|
if (scrollable) {
|
|
@@ -45,6 +47,24 @@ var destroyFn = function destroyFn(api) {
|
|
|
45
47
|
var source = _ref.source;
|
|
46
48
|
return source.data.type === 'element';
|
|
47
49
|
},
|
|
50
|
+
onDrag: function onDrag() {
|
|
51
|
+
if ((0, _performanceMeasures.isMeasuring)(EDITOR_BLOCKS_DRAG_INIT) && (0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_3')) {
|
|
52
|
+
(0, _performanceMeasures.stopMeasure)(EDITOR_BLOCKS_DRAG_INIT, function (duration, startTime) {
|
|
53
|
+
var _api$analytics;
|
|
54
|
+
var state = editorView.state;
|
|
55
|
+
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.fireAnalyticsEvent({
|
|
56
|
+
action: _analytics.ACTION.BLOCKS_DRAG_INIT,
|
|
57
|
+
actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
|
|
58
|
+
eventType: _analytics.EVENT_TYPE.OPERATIONAL,
|
|
59
|
+
attributes: {
|
|
60
|
+
duration: duration,
|
|
61
|
+
startTime: startTime,
|
|
62
|
+
nodesCount: state.doc.nodeSize
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
},
|
|
48
68
|
onDragStart: function onDragStart() {
|
|
49
69
|
if (isHTMLElement(scrollable)) {
|
|
50
70
|
scrollable.style.setProperty('scroll-behavior', 'unset');
|
|
@@ -63,10 +83,10 @@ var destroyFn = function destroyFn(api) {
|
|
|
63
83
|
start = _ref4.start;
|
|
64
84
|
// if no drop targets are rendered, assume that drop is invalid
|
|
65
85
|
if (location.current.dropTargets.length === 0) {
|
|
66
|
-
var _api$
|
|
86
|
+
var _api$analytics2;
|
|
67
87
|
var resolvedMovingNode = tr.doc.resolve(start);
|
|
68
88
|
var maybeNode = resolvedMovingNode.nodeAfter;
|
|
69
|
-
api === null || api === void 0 || (_api$
|
|
89
|
+
api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || _api$analytics2.actions.attachAnalyticsEvent({
|
|
70
90
|
eventType: _analytics.EVENT_TYPE.UI,
|
|
71
91
|
action: _analytics.ACTION.CANCELLED,
|
|
72
92
|
actionSubject: _analytics.ACTION_SUBJECT.DRAG,
|
|
@@ -524,6 +544,9 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
|
|
|
524
544
|
},
|
|
525
545
|
dragstart: function dragstart(view) {
|
|
526
546
|
var _anchorRectCache;
|
|
547
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_3')) {
|
|
548
|
+
(0, _performanceMeasures.startMeasure)(EDITOR_BLOCKS_DRAG_INIT);
|
|
549
|
+
}
|
|
527
550
|
if (isAdvancedLayoutEnabled) {
|
|
528
551
|
_activeAnchorTracker.defaultActiveAnchorTracker.reset();
|
|
529
552
|
}
|
|
@@ -605,7 +628,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
|
|
|
605
628
|
}
|
|
606
629
|
|
|
607
630
|
// Start pragmatic monitors
|
|
608
|
-
var pragmaticCleanup = destroyFn(api);
|
|
631
|
+
var pragmaticCleanup = destroyFn(api, editorView);
|
|
609
632
|
return {
|
|
610
633
|
destroy: function destroy() {
|
|
611
634
|
if (editorContentArea) {
|
|
@@ -87,6 +87,10 @@ export const handleMouseOver = (view, event, api) => {
|
|
|
87
87
|
} else {
|
|
88
88
|
pos = view.posAtDOM(rootElement, 0);
|
|
89
89
|
}
|
|
90
|
+
if (parentRootElement && parentRootElement.getAttribute('data-layout-section') === 'true' && parentRootElement.querySelectorAll('[data-layout-column]').length === 1 && editorExperiment('advanced_layouts', true) && fg('platform_editor_advanced_layouts_post_fix_patch_3')) {
|
|
91
|
+
// Don't show drag handle for layout column in a single column layout
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
90
94
|
let rootPos;
|
|
91
95
|
if (editorExperiment('nested-dnd', true)) {
|
|
92
96
|
rootPos = view.state.doc.resolve(pos).pos;
|
|
@@ -2,6 +2,7 @@ import rafSchedule from 'raf-schd';
|
|
|
2
2
|
import { AnalyticsStep } from '@atlaskit/adf-schema/steps';
|
|
3
3
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import { browser } from '@atlaskit/editor-common/browser';
|
|
5
|
+
import { isMeasuring, startMeasure, stopMeasure } from '@atlaskit/editor-common/performance-measures';
|
|
5
6
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
6
7
|
import { isEmptyDocument, isTextInput } from '@atlaskit/editor-common/utils';
|
|
7
8
|
import { NodeSelection, PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -21,10 +22,11 @@ import { AnchorRectCache, isAnchorSupported } from './utils/anchor-utils';
|
|
|
21
22
|
import { isBlocksDragTargetDebug } from './utils/drag-target-debug';
|
|
22
23
|
import { getTrMetadata } from './utils/transactions';
|
|
23
24
|
export const key = new PluginKey('blockControls');
|
|
25
|
+
const EDITOR_BLOCKS_DRAG_INIT = 'Editor Blocks Drag Initialization Time';
|
|
24
26
|
const isHTMLElement = element => {
|
|
25
27
|
return element instanceof HTMLElement;
|
|
26
28
|
};
|
|
27
|
-
const destroyFn = api => {
|
|
29
|
+
const destroyFn = (api, editorView) => {
|
|
28
30
|
const scrollable = document.querySelector('.fabric-editor-popup-scroll-parent');
|
|
29
31
|
const cleanupFn = [];
|
|
30
32
|
if (scrollable) {
|
|
@@ -36,6 +38,26 @@ const destroyFn = api => {
|
|
|
36
38
|
canMonitor: ({
|
|
37
39
|
source
|
|
38
40
|
}) => source.data.type === 'element',
|
|
41
|
+
onDrag: () => {
|
|
42
|
+
if (isMeasuring(EDITOR_BLOCKS_DRAG_INIT) && fg('platform_editor_advanced_layouts_post_fix_patch_3')) {
|
|
43
|
+
stopMeasure(EDITOR_BLOCKS_DRAG_INIT, (duration, startTime) => {
|
|
44
|
+
var _api$analytics;
|
|
45
|
+
const {
|
|
46
|
+
state
|
|
47
|
+
} = editorView;
|
|
48
|
+
api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.fireAnalyticsEvent({
|
|
49
|
+
action: ACTION.BLOCKS_DRAG_INIT,
|
|
50
|
+
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
51
|
+
eventType: EVENT_TYPE.OPERATIONAL,
|
|
52
|
+
attributes: {
|
|
53
|
+
duration,
|
|
54
|
+
startTime,
|
|
55
|
+
nodesCount: state.doc.nodeSize
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
},
|
|
39
61
|
onDragStart: () => {
|
|
40
62
|
if (isHTMLElement(scrollable)) {
|
|
41
63
|
scrollable.style.setProperty('scroll-behavior', 'unset');
|
|
@@ -57,10 +79,10 @@ const destroyFn = api => {
|
|
|
57
79
|
} = source.data;
|
|
58
80
|
// if no drop targets are rendered, assume that drop is invalid
|
|
59
81
|
if (location.current.dropTargets.length === 0) {
|
|
60
|
-
var _api$
|
|
82
|
+
var _api$analytics2;
|
|
61
83
|
const resolvedMovingNode = tr.doc.resolve(start);
|
|
62
84
|
const maybeNode = resolvedMovingNode.nodeAfter;
|
|
63
|
-
api === null || api === void 0 ? void 0 : (_api$
|
|
85
|
+
api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions.attachAnalyticsEvent({
|
|
64
86
|
eventType: EVENT_TYPE.UI,
|
|
65
87
|
action: ACTION.CANCELLED,
|
|
66
88
|
actionSubject: ACTION_SUBJECT.DRAG,
|
|
@@ -504,6 +526,9 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI) => {
|
|
|
504
526
|
},
|
|
505
527
|
dragstart(view) {
|
|
506
528
|
var _anchorRectCache;
|
|
529
|
+
if (fg('platform_editor_advanced_layouts_post_fix_patch_3')) {
|
|
530
|
+
startMeasure(EDITOR_BLOCKS_DRAG_INIT);
|
|
531
|
+
}
|
|
507
532
|
if (isAdvancedLayoutEnabled) {
|
|
508
533
|
defaultActiveAnchorTracker.reset();
|
|
509
534
|
}
|
|
@@ -588,7 +613,7 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI) => {
|
|
|
588
613
|
}
|
|
589
614
|
|
|
590
615
|
// Start pragmatic monitors
|
|
591
|
-
const pragmaticCleanup = destroyFn(api);
|
|
616
|
+
const pragmaticCleanup = destroyFn(api, editorView);
|
|
592
617
|
return {
|
|
593
618
|
destroy() {
|
|
594
619
|
if (editorContentArea) {
|
|
@@ -86,6 +86,10 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
|
|
|
86
86
|
} else {
|
|
87
87
|
pos = view.posAtDOM(rootElement, 0);
|
|
88
88
|
}
|
|
89
|
+
if (parentRootElement && parentRootElement.getAttribute('data-layout-section') === 'true' && parentRootElement.querySelectorAll('[data-layout-column]').length === 1 && editorExperiment('advanced_layouts', true) && fg('platform_editor_advanced_layouts_post_fix_patch_3')) {
|
|
90
|
+
// Don't show drag handle for layout column in a single column layout
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
89
93
|
var rootPos;
|
|
90
94
|
if (editorExperiment('nested-dnd', true)) {
|
|
91
95
|
rootPos = view.state.doc.resolve(pos).pos;
|
|
@@ -3,6 +3,7 @@ import rafSchedule from 'raf-schd';
|
|
|
3
3
|
import { AnalyticsStep } from '@atlaskit/adf-schema/steps';
|
|
4
4
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
5
5
|
import { browser } from '@atlaskit/editor-common/browser';
|
|
6
|
+
import { isMeasuring, startMeasure, stopMeasure } from '@atlaskit/editor-common/performance-measures';
|
|
6
7
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
7
8
|
import { isEmptyDocument, isTextInput } from '@atlaskit/editor-common/utils';
|
|
8
9
|
import { NodeSelection, PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -22,10 +23,11 @@ import { AnchorRectCache, isAnchorSupported } from './utils/anchor-utils';
|
|
|
22
23
|
import { isBlocksDragTargetDebug } from './utils/drag-target-debug';
|
|
23
24
|
import { getTrMetadata } from './utils/transactions';
|
|
24
25
|
export var key = new PluginKey('blockControls');
|
|
26
|
+
var EDITOR_BLOCKS_DRAG_INIT = 'Editor Blocks Drag Initialization Time';
|
|
25
27
|
var isHTMLElement = function isHTMLElement(element) {
|
|
26
28
|
return element instanceof HTMLElement;
|
|
27
29
|
};
|
|
28
|
-
var destroyFn = function destroyFn(api) {
|
|
30
|
+
var destroyFn = function destroyFn(api, editorView) {
|
|
29
31
|
var scrollable = document.querySelector('.fabric-editor-popup-scroll-parent');
|
|
30
32
|
var cleanupFn = [];
|
|
31
33
|
if (scrollable) {
|
|
@@ -38,6 +40,24 @@ var destroyFn = function destroyFn(api) {
|
|
|
38
40
|
var source = _ref.source;
|
|
39
41
|
return source.data.type === 'element';
|
|
40
42
|
},
|
|
43
|
+
onDrag: function onDrag() {
|
|
44
|
+
if (isMeasuring(EDITOR_BLOCKS_DRAG_INIT) && fg('platform_editor_advanced_layouts_post_fix_patch_3')) {
|
|
45
|
+
stopMeasure(EDITOR_BLOCKS_DRAG_INIT, function (duration, startTime) {
|
|
46
|
+
var _api$analytics;
|
|
47
|
+
var state = editorView.state;
|
|
48
|
+
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.fireAnalyticsEvent({
|
|
49
|
+
action: ACTION.BLOCKS_DRAG_INIT,
|
|
50
|
+
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
51
|
+
eventType: EVENT_TYPE.OPERATIONAL,
|
|
52
|
+
attributes: {
|
|
53
|
+
duration: duration,
|
|
54
|
+
startTime: startTime,
|
|
55
|
+
nodesCount: state.doc.nodeSize
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
},
|
|
41
61
|
onDragStart: function onDragStart() {
|
|
42
62
|
if (isHTMLElement(scrollable)) {
|
|
43
63
|
scrollable.style.setProperty('scroll-behavior', 'unset');
|
|
@@ -56,10 +76,10 @@ var destroyFn = function destroyFn(api) {
|
|
|
56
76
|
start = _ref4.start;
|
|
57
77
|
// if no drop targets are rendered, assume that drop is invalid
|
|
58
78
|
if (location.current.dropTargets.length === 0) {
|
|
59
|
-
var _api$
|
|
79
|
+
var _api$analytics2;
|
|
60
80
|
var resolvedMovingNode = tr.doc.resolve(start);
|
|
61
81
|
var maybeNode = resolvedMovingNode.nodeAfter;
|
|
62
|
-
api === null || api === void 0 || (_api$
|
|
82
|
+
api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || _api$analytics2.actions.attachAnalyticsEvent({
|
|
63
83
|
eventType: EVENT_TYPE.UI,
|
|
64
84
|
action: ACTION.CANCELLED,
|
|
65
85
|
actionSubject: ACTION_SUBJECT.DRAG,
|
|
@@ -517,6 +537,9 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
517
537
|
},
|
|
518
538
|
dragstart: function dragstart(view) {
|
|
519
539
|
var _anchorRectCache;
|
|
540
|
+
if (fg('platform_editor_advanced_layouts_post_fix_patch_3')) {
|
|
541
|
+
startMeasure(EDITOR_BLOCKS_DRAG_INIT);
|
|
542
|
+
}
|
|
520
543
|
if (isAdvancedLayoutEnabled) {
|
|
521
544
|
defaultActiveAnchorTracker.reset();
|
|
522
545
|
}
|
|
@@ -598,7 +621,7 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
598
621
|
}
|
|
599
622
|
|
|
600
623
|
// Start pragmatic monitors
|
|
601
|
-
var pragmaticCleanup = destroyFn(api);
|
|
624
|
+
var pragmaticCleanup = destroyFn(api, editorView);
|
|
602
625
|
return {
|
|
603
626
|
destroy: function destroy() {
|
|
604
627
|
if (editorContentArea) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "2.16.
|
|
3
|
+
"version": "2.16.4",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -168,6 +168,9 @@
|
|
|
168
168
|
},
|
|
169
169
|
"platform_editor_advanced_layouts_post_fix_patch_2": {
|
|
170
170
|
"type": "boolean"
|
|
171
|
+
},
|
|
172
|
+
"platform_editor_advanced_layouts_post_fix_patch_3": {
|
|
173
|
+
"type": "boolean"
|
|
171
174
|
}
|
|
172
175
|
}
|
|
173
176
|
}
|