@atlaskit/editor-plugin-block-controls 2.13.12 → 2.13.13

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.
@@ -9,116 +9,89 @@ import { akEditorCalculatedWideLayoutWidth, akEditorCalculatedWideLayoutWidthSma
9
9
  import { fg } from '@atlaskit/platform-feature-flags';
10
10
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
11
11
  import { DRAG_HANDLE_MAX_WIDTH_PLUS_GAP, DRAG_HANDLE_WIDTH } from './consts';
12
- import { emptyBlockExperimentGlobalStyles } from './empty-block-experiment/global-styles';
12
+
13
+ /**
14
+ * This anchor element selector disregards anchors that are solely utilized for size measurements,
15
+ * including those within table rows and media.
16
+ */
17
+ var dragHandlerAnchorSelector = '[data-drag-handler-anchor-name]:not([data-drag-handler-node-type="tableRow"], [data-drag-handler-node-type="media"])';
13
18
  var extendedHoverZone = function extendedHoverZone() {
14
- return css({
15
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
16
- '.block-ctrl-drag-preview [data-drag-handler-anchor-name]::after': {
17
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
18
- display: 'none !important'
19
- },
20
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
21
- '.ProseMirror': {
22
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
23
- '&& [data-drag-handler-anchor-name]::after': {
24
- content: '""',
25
- position: 'absolute',
26
- top: 0,
27
- left: '-100%',
28
- width: '100%',
29
- height: '100%',
30
- background: 'transparent',
31
- cursor: 'default',
32
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
33
- zIndex: -1
34
- }
35
- },
36
- // TODO - ED-23995 this style override needs to be moved to the Rule styles after FF cleanup - packages/editor/editor-common/src/styles/shared/rule.ts
37
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
38
- 'hr[data-drag-handler-anchor-name]': {
39
- overflow: 'visible'
40
- },
41
- //eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
42
- '[data-blocks-drag-handle-container="true"] + *::after': {
43
- display: 'none'
44
- }
45
- });
19
+ var _css;
20
+ return css((_css = {}, _defineProperty(_css, ".block-ctrl-drag-preview ".concat(dragHandlerAnchorSelector, "::after"), {
21
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
22
+ display: 'none !important'
23
+ }), _defineProperty(_css, '.ProseMirror', _defineProperty({}, "&& ".concat(dragHandlerAnchorSelector, "::after"), {
24
+ content: '""',
25
+ position: 'absolute',
26
+ top: 0,
27
+ left: '-100%',
28
+ width: '100%',
29
+ height: '100%',
30
+ background: 'transparent',
31
+ cursor: 'default',
32
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
33
+ zIndex: -1
34
+ })), _defineProperty(_css, 'hr[data-drag-handler-anchor-name]', {
35
+ overflow: 'visible'
36
+ }), _defineProperty(_css, '[data-blocks-drag-handle-container="true"] + *::after', {
37
+ display: 'none'
38
+ }), _css));
46
39
  };
47
40
  var extendedHoverZoneNested = function extendedHoverZoneNested() {
48
- return css({
49
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
50
- '.block-ctrl-drag-preview [data-drag-handler-anchor-name]::after': {
51
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
52
- display: 'none !important'
53
- },
54
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
55
- '.ProseMirror': {
56
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
57
- '&& [data-drag-handler-anchor-name]::after': {
58
- content: '""',
59
- position: 'absolute',
60
- top: 0,
61
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
62
- left: "-".concat(DRAG_HANDLE_MAX_WIDTH_PLUS_GAP, "px"),
63
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
64
- width: "".concat(DRAG_HANDLE_MAX_WIDTH_PLUS_GAP, "px"),
65
- height: '100%',
66
- cursor: 'default',
67
- zIndex: 1
68
- },
69
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
70
- '&& [data-drag-handler-anchor-depth="0"][data-drag-handler-anchor-name]::after': {
71
- content: '""',
72
- position: 'absolute',
73
- top: 0,
74
- left: '-100%',
75
- width: '100%',
76
- height: '100%',
77
- cursor: 'default',
78
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
79
- zIndex: -1
80
- },
81
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
82
- '&& :is(.pm-table-cell-content-wrap, .pm-table-header-content-wrap) > [data-drag-handler-anchor-name]::after': {
83
- content: '""',
84
- position: 'absolute',
85
- top: 0,
86
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
87
- left: "-".concat(editorExperiment('table-nested-dnd', true) ? DRAG_HANDLE_MAX_WIDTH_PLUS_GAP : 0, "px"),
88
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
89
- width: "".concat(editorExperiment('table-nested-dnd', true) ? DRAG_HANDLE_MAX_WIDTH_PLUS_GAP : 0, "px"),
90
- height: '100%',
91
- cursor: 'default',
92
- zIndex: 1
93
- },
94
- // hover zone for layout column should be placed near the top of the column (where drag handle is)
95
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
96
- '&& [data-drag-handler-anchor-name][data-layout-column]::after': {
97
- content: '""',
98
- position: 'absolute',
99
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
100
- top: "".concat(-DRAG_HANDLE_WIDTH / 2, "px"),
101
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
102
- left: 0,
103
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
104
- width: '100%',
105
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
106
- height: "".concat(DRAG_HANDLE_WIDTH, "px"),
107
- cursor: 'default',
108
- zIndex: 1
109
- }
110
- },
111
- // TODO - ED-23995 this style override needs to be moved to the Rule styles after FF cleanup - packages/editor/editor-common/src/styles/shared/rule.ts
112
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
113
- 'hr[data-drag-handler-anchor-name]': {
114
- overflow: 'visible'
115
- },
116
- //Hide pseudo element at top depth level. Leave for nested depths to prevent mouseover loop.
117
- //eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
118
- '[data-blocks-drag-handle-container="true"] + [data-drag-handler-anchor-depth="0"]::after': {
119
- display: 'none'
120
- }
121
- });
41
+ var _ProseMirror2, _css2;
42
+ return css((_css2 = {}, _defineProperty(_css2, ".block-ctrl-drag-preview ".concat(dragHandlerAnchorSelector, "::after"), {
43
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
44
+ display: 'none !important'
45
+ }), _defineProperty(_css2, '.ProseMirror', (_ProseMirror2 = {}, _defineProperty(_ProseMirror2, "&& ".concat(dragHandlerAnchorSelector, "::after"), {
46
+ content: '""',
47
+ position: 'absolute',
48
+ top: 0,
49
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
50
+ left: "-".concat(DRAG_HANDLE_MAX_WIDTH_PLUS_GAP, "px"),
51
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
52
+ width: "".concat(DRAG_HANDLE_MAX_WIDTH_PLUS_GAP, "px"),
53
+ height: '100%',
54
+ cursor: 'default',
55
+ zIndex: 1
56
+ }), _defineProperty(_ProseMirror2, "&& [data-drag-handler-anchor-depth=\"0\"]".concat(dragHandlerAnchorSelector, "::after"), {
57
+ content: '""',
58
+ position: 'absolute',
59
+ top: 0,
60
+ left: '-100%',
61
+ width: '100%',
62
+ height: '100%',
63
+ cursor: 'default',
64
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
65
+ zIndex: -1
66
+ }), _defineProperty(_ProseMirror2, "&& :is(.pm-table-cell-content-wrap, .pm-table-header-content-wrap) > ".concat(dragHandlerAnchorSelector, "::after"), {
67
+ content: '""',
68
+ position: 'absolute',
69
+ top: 0,
70
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
71
+ left: "-".concat(editorExperiment('table-nested-dnd', true) ? DRAG_HANDLE_MAX_WIDTH_PLUS_GAP : 0, "px"),
72
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
73
+ width: "".concat(editorExperiment('table-nested-dnd', true) ? DRAG_HANDLE_MAX_WIDTH_PLUS_GAP : 0, "px"),
74
+ height: '100%',
75
+ cursor: 'default',
76
+ zIndex: 1
77
+ }), _defineProperty(_ProseMirror2, '&& [data-drag-handler-anchor-name][data-layout-column]::after', {
78
+ content: '""',
79
+ position: 'absolute',
80
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
81
+ top: "".concat(-DRAG_HANDLE_WIDTH / 2, "px"),
82
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
83
+ left: 0,
84
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
85
+ width: '100%',
86
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
87
+ height: "".concat(DRAG_HANDLE_WIDTH, "px"),
88
+ cursor: 'default',
89
+ zIndex: 1
90
+ }), _ProseMirror2)), _defineProperty(_css2, 'hr[data-drag-handler-anchor-name]', {
91
+ overflow: 'visible'
92
+ }), _defineProperty(_css2, '[data-blocks-drag-handle-container="true"] + [data-drag-handler-anchor-depth="0"]::after', {
93
+ display: 'none'
94
+ }), _css2));
122
95
  };
123
96
  var paragraphWithTrailingBreakAsOnlyChild = '+ :is(p, h1, h2, h3, h4, h5, h6) > .ProseMirror-trailingBreak:only-child';
124
97
  var indentatedParagraphWithTrailingBreakAsOnlyChild = '+ div.fabric-editor-indentation-mark > :is(p, h1, h2, h3, h4, h5, h6) > .ProseMirror-trailingBreak:only-child';
@@ -203,21 +176,15 @@ var getTextNodeStyle = function getTextNodeStyle() {
203
176
  };
204
177
  var withRelativePosStyle = css({
205
178
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
206
- '.ProseMirror': {
207
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
208
- '&& [data-drag-handler-anchor-name]': {
209
- position: 'relative'
210
- }
211
- }
179
+ '.ProseMirror': _defineProperty({}, "&& ".concat(dragHandlerAnchorSelector), {
180
+ position: 'relative'
181
+ })
212
182
  });
213
183
  var withAnchorNameZindexStyle = css({
214
184
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
215
- '.ProseMirror': {
216
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
217
- '&& [data-drag-handler-anchor-name]': {
218
- zIndex: 1
219
- }
220
- }
185
+ '.ProseMirror': _defineProperty({}, "&& ".concat(dragHandlerAnchorSelector), {
186
+ zIndex: 1
187
+ })
221
188
  });
222
189
  var withAnchorNameZindexNestedStyle = css({
223
190
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
@@ -230,8 +197,6 @@ var withAnchorNameZindexNestedStyle = css({
230
197
  });
231
198
  export var GlobalStylesWrapper = function GlobalStylesWrapper() {
232
199
  return jsx(Global, {
233
- styles: [globalStyles(), editorExperiment('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), getTextNodeStyle(), withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, editorExperiment('platform_editor_empty_line_prompt', true, {
234
- exposure: false
235
- }) ? emptyBlockExperimentGlobalStyles : undefined, fg('platform_editor_element_dnd_nested_fix_patch_1') ? withDividerInPanelStyleFix : undefined, fg('platform_editor_element_dnd_nested_fix_patch_2') ? withFormatInLayoutStyleFix : undefined, fg('platform_editor_element_dnd_nested_fix_patch_3') ? [withRelativePosStyle, topLevelNodeMarginStyles, editorExperiment('nested-dnd', true) ? withAnchorNameZindexNestedStyle : withAnchorNameZindexStyle] : undefined]
200
+ styles: [globalStyles(), editorExperiment('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), getTextNodeStyle(), withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, fg('platform_editor_element_dnd_nested_fix_patch_1') ? withDividerInPanelStyleFix : undefined, fg('platform_editor_element_dnd_nested_fix_patch_2') ? withFormatInLayoutStyleFix : undefined, fg('platform_editor_element_dnd_nested_fix_patch_3') ? [withRelativePosStyle, topLevelNodeMarginStyles, editorExperiment('nested-dnd', true) ? withAnchorNameZindexNestedStyle : withAnchorNameZindexStyle] : undefined]
236
201
  });
237
202
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "2.13.12",
3
+ "version": "2.13.13",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@atlaskit/adf-schema": "^44.2.0",
34
- "@atlaskit/editor-common": "^94.20.0",
34
+ "@atlaskit/editor-common": "^94.21.0",
35
35
  "@atlaskit/editor-plugin-accessibility-utils": "^1.2.0",
36
36
  "@atlaskit/editor-plugin-analytics": "^1.10.0",
37
37
  "@atlaskit/editor-plugin-editor-disabled": "^1.3.0",
@@ -46,9 +46,9 @@
46
46
  "@atlaskit/pragmatic-drag-and-drop": "^1.4.0",
47
47
  "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^1.4.0",
48
48
  "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^1.1.0",
49
- "@atlaskit/primitives": "^13.1.0",
49
+ "@atlaskit/primitives": "^13.2.0",
50
50
  "@atlaskit/theme": "^14.0.0",
51
- "@atlaskit/tmp-editor-statsig": "^2.14.0",
51
+ "@atlaskit/tmp-editor-statsig": "^2.15.0",
52
52
  "@atlaskit/tokens": "^2.2.0",
53
53
  "@atlaskit/tooltip": "^18.9.0",
54
54
  "@babel/runtime": "^7.0.0",
@@ -130,9 +130,6 @@
130
130
  "platform_editor_element_drag_and_drop_ed_24885": {
131
131
  "type": "boolean"
132
132
  },
133
- "platform_editor_empty_line_prompt_delay": {
134
- "type": "boolean"
135
- },
136
133
  "platform_editor_element_dnd_nested_fix_patch_1": {
137
134
  "type": "boolean"
138
135
  },
@@ -1,46 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.emptyBlockExperimentPluginKey = exports.createEmptyBlockExperimentPlugin = void 0;
7
- var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
8
- var _state = require("@atlaskit/editor-prosemirror/state");
9
- var _view = require("@atlaskit/editor-prosemirror/view");
10
- var _widget = require("../ui/empty-block-experiment/widget");
11
- var emptyBlockExperimentPluginKey = exports.emptyBlockExperimentPluginKey = new _state.PluginKey('emptyBlockExperiment');
12
- var getDecorations = function getDecorations(tr, api, getIntl) {
13
- var _api$editorDisabled;
14
- var isEditorDisabled = api === null || api === void 0 || (_api$editorDisabled = api.editorDisabled) === null || _api$editorDisabled === void 0 || (_api$editorDisabled = _api$editorDisabled.sharedState.currentState()) === null || _api$editorDisabled === void 0 ? void 0 : _api$editorDisabled.editorDisabled;
15
- if (isEditorDisabled) {
16
- return _view.DecorationSet.empty;
17
- }
18
- var widget = (0, _widget.createEmptyBlockWidgetDecoration)(tr.selection, api, getIntl);
19
- if (widget) {
20
- return _view.DecorationSet.create(tr.doc, [widget]);
21
- }
22
- return _view.DecorationSet.empty;
23
- };
24
- var createEmptyBlockExperimentPlugin = exports.createEmptyBlockExperimentPlugin = function createEmptyBlockExperimentPlugin(api, getIntl) {
25
- return new _safePlugin.SafePlugin({
26
- key: emptyBlockExperimentPluginKey,
27
- state: {
28
- init: function init(_, _editorState) {
29
- return {
30
- decorations: _view.DecorationSet.empty
31
- };
32
- },
33
- apply: function apply(tr, _currentState) {
34
- return {
35
- decorations: getDecorations(tr, api, getIntl)
36
- };
37
- }
38
- },
39
- props: {
40
- decorations: function decorations(state) {
41
- var _emptyBlockExperiment;
42
- return (_emptyBlockExperiment = emptyBlockExperimentPluginKey.getState(state)) === null || _emptyBlockExperiment === void 0 ? void 0 : _emptyBlockExperiment.decorations;
43
- }
44
- }
45
- });
46
- };
@@ -1,66 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.emptyBlockExperimentGlobalStyles = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _react = require("@emotion/react");
10
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
11
- /* eslint-disable @atlaskit/ui-styling-standard/no-exported-styles */
12
- /* eslint-disable @atlaskit/ui-styling-standard/no-unsafe-values */
13
- /* eslint-disable @atlaskit/ui-styling-standard/no-nested-selectors */
14
- /* eslint-disable @atlaskit/ui-styling-standard/no-important-styles */
15
- // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled
16
-
17
- var emptyBlockExperimentWidget = '.ProseMirror-widget[data-empty-block-experiment="true"]';
18
- var quickInsertWidget = '.ProseMirror-widget[data-type-ahead="typeaheadDecoration"]';
19
- var formattingElement = 'div.fabric-editor-block-mark';
20
- var markFragment = 'div[data-mark-type="fragment"]';
21
- var breakoutMark = 'div.fabric-editor-breakout-mark';
22
- var breakoutMarkDom = 'div.fabric-editor-breakout-mark-dom';
23
- var elementWithEmptyBlockExperiment = "+ p > ".concat(emptyBlockExperimentWidget, ", + h1 > ").concat(emptyBlockExperimentWidget, ", + h2 > ").concat(emptyBlockExperimentWidget, ", + h3 > ").concat(emptyBlockExperimentWidget, ", + h4 > ").concat(emptyBlockExperimentWidget, ", + h5 > ").concat(emptyBlockExperimentWidget, ", + h6 > ").concat(emptyBlockExperimentWidget);
24
- // Selectors for when contained withing a formatting container mark (eg. indent, centering, right-align)
25
- var elementWithEmptyBlockExperimentFormatted = "+ ".concat(formattingElement, " > p > ").concat(emptyBlockExperimentWidget, ", + ").concat(formattingElement, " > h1 > ").concat(emptyBlockExperimentWidget, ", + ").concat(formattingElement, " > h2 > ").concat(emptyBlockExperimentWidget, ", + ").concat(formattingElement, " > h3 > ").concat(emptyBlockExperimentWidget, ", + ").concat(formattingElement, " > h4 > ").concat(emptyBlockExperimentWidget, ", + ").concat(formattingElement, " > h5 > ").concat(emptyBlockExperimentWidget, ", + ").concat(formattingElement, " > h6 > ").concat(emptyBlockExperimentWidget);
26
- var dragHandleContainer = '.ProseMirror-widget[data-blocks-drag-handle-container="true"]';
27
- var dragHandleSelector = 'button[data-testid="block-ctrl-drag-handle"]';
28
-
29
- // Hides the drag handle when the block contains the empty block experiment
30
- // Override is consistent with how the drag handle is hidden when the block contains a placeholder
31
- var dragHandleWithInlineNodeStyle = (0, _react.css)((0, _defineProperty2.default)({}, "".concat(dragHandleContainer, ":has(").concat(elementWithEmptyBlockExperiment, "),\n\t\t").concat(dragHandleContainer, ":has(").concat(elementWithEmptyBlockExperimentFormatted, "),") + // In certain circumstances - eg. a paragraph after an indent, or after a table fragment, the dragHandleContainer
32
- // is nested in the previous div. These selectors are to handle those cases.
33
- // -------------------
34
- // Empty block in new paragraph after indent
35
- "".concat(formattingElement, ":has(> ").concat(dragHandleContainer, ":last-child):has(").concat(elementWithEmptyBlockExperiment, ") > ").concat(dragHandleContainer, ":last-child,\n\t").concat(formattingElement, ":has(> ").concat(dragHandleContainer, ":last-child):has(").concat(elementWithEmptyBlockExperimentFormatted, ") > ").concat(dragHandleContainer, ":last-child,") + // Empty block in new paragraph after table
36
- "".concat(markFragment, ":has(> ").concat(dragHandleContainer, ":last-child):has(").concat(elementWithEmptyBlockExperiment, ") > ").concat(dragHandleContainer, ":last-child,\n\t\t").concat(markFragment, ":has(> ").concat(dragHandleContainer, ":last-child):has(").concat(elementWithEmptyBlockExperimentFormatted, ") > ").concat(dragHandleContainer, ":last-child,") + // Empty block in new paragraph after breakout mark
37
- "".concat(breakoutMark, ":has(> ").concat(breakoutMarkDom, " > ").concat(dragHandleContainer, ":last-child):has(").concat(elementWithEmptyBlockExperiment, ") > ").concat(breakoutMarkDom, " > ").concat(dragHandleContainer, ":last-child,\n\t").concat(breakoutMark, ":has(> ").concat(breakoutMarkDom, " > ").concat(dragHandleContainer, ":last-child):has(").concat(elementWithEmptyBlockExperimentFormatted, ") > ").concat(breakoutMarkDom, " > ").concat(dragHandleContainer, ":last-child"), {
38
- display: 'none !important'
39
- }));
40
-
41
- // Alternate styling for hiding the drag handle when the block contains the empty block experiment
42
- // Override is consistent with a feature-gated bugfix that hides the drag handle when the block contains a placeholder
43
- /**
44
- * Please do not change change transform to display:none, or visibility:hidden
45
- * Otherwise it might break composition input for Chrome
46
- * https://product-fabric.atlassian.net/browse/ED-24136
47
- */
48
- var dragHandleWithInlineNodeStyleWithChromeFix = (0, _react.css)((0, _defineProperty2.default)({}, "".concat(dragHandleContainer, ":has(").concat(elementWithEmptyBlockExperiment, ") ").concat(dragHandleSelector, ",\n\t\t").concat(dragHandleContainer, ":has(").concat(elementWithEmptyBlockExperimentFormatted, ") ").concat(dragHandleSelector, ",") + // In certain circumstances - eg. a paragraph after an indent, or after a table fragment, the dragHandleContainer
49
- // is nested in the previous div. These selectors are to handle those cases.
50
- // -------------------
51
- // Empty block in new paragraph after indent
52
- "".concat(formattingElement, ":has(> ").concat(dragHandleContainer, ":last-child):has(").concat(elementWithEmptyBlockExperiment, ") > ").concat(dragHandleContainer, ":last-child ").concat(dragHandleSelector, ",\n\t").concat(formattingElement, ":has(> ").concat(dragHandleContainer, ":last-child):has(").concat(elementWithEmptyBlockExperimentFormatted, ") > ").concat(dragHandleContainer, ":last-child ").concat(dragHandleSelector, ",") + // Empty block in new paragraph after table
53
- "".concat(markFragment, ":has(> ").concat(dragHandleContainer, ":last-child):has(").concat(elementWithEmptyBlockExperiment, ") > ").concat(dragHandleContainer, ":last-child ").concat(dragHandleSelector, ",\n\t\t").concat(markFragment, ":has(> ").concat(dragHandleContainer, ":last-child):has(").concat(elementWithEmptyBlockExperimentFormatted, ") > ").concat(dragHandleContainer, ":last-child ").concat(dragHandleSelector, ",") + // Empty block in new paragraph after breakout mark
54
- "".concat(breakoutMark, ":has(> ").concat(breakoutMarkDom, " > ").concat(dragHandleContainer, ":last-child):has(").concat(elementWithEmptyBlockExperiment, ") > ").concat(breakoutMarkDom, " > ").concat(dragHandleContainer, ":last-child ").concat(dragHandleSelector, ",\n\t\t").concat(breakoutMark, ":has(> ").concat(breakoutMarkDom, " > ").concat(dragHandleContainer, ":last-child):has(").concat(elementWithEmptyBlockExperimentFormatted, ") > ").concat(breakoutMarkDom, " > ").concat(dragHandleContainer, ":last-child ").concat(dragHandleSelector), {
55
- transform: 'scale(0)'
56
- }));
57
- var getDragHandleOverrides = function getDragHandleOverrides() {
58
- return (0, _platformFeatureFlags.fg)('platform_editor_element_controls_chrome_input_fix') ? dragHandleWithInlineNodeStyleWithChromeFix : dragHandleWithInlineNodeStyle;
59
- };
60
-
61
- /**
62
- * Hide the experiment button when it has been activated. (contains quick-insert decoration widget)
63
- */
64
- var emptyBlockExperimentGlobalStyles = exports.emptyBlockExperimentGlobalStyles = (0, _react.css)((0, _defineProperty2.default)({}, "".concat(emptyBlockExperimentWidget, ":has(+ ").concat(quickInsertWidget, ") button"), {
65
- transform: 'scale(0)'
66
- }), getDragHandleOverrides());
@@ -1,144 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof = require("@babel/runtime/helpers/typeof");
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.createEmptyBlockWidgetDecoration = exports.TypeAheadControl = void 0;
9
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
10
- var _react = _interopRequireWildcard(require("react"));
11
- var _react2 = require("@emotion/react");
12
- var _reactDom = _interopRequireDefault(require("react-dom"));
13
- var _reactIntlNext = require("react-intl-next");
14
- var _keymaps = require("@atlaskit/editor-common/keymaps");
15
- var _messages = require("@atlaskit/editor-common/messages");
16
- var _whitespace = require("@atlaskit/editor-common/whitespace");
17
- var _state = require("@atlaskit/editor-prosemirror/state");
18
- var _view2 = require("@atlaskit/editor-prosemirror/view");
19
- var _add = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/add"));
20
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
21
- var _primitives = require("@atlaskit/primitives");
22
- var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
23
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
24
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
25
- /* eslint-disable @atlaskit/ui-styling-standard/use-compiled */
26
-
27
- var wrapperStyles = (0, _primitives.xcss)({
28
- position: 'absolute',
29
- top: "calc('50%' - ".concat("var(--ds-space-150, 12px)", ")"),
30
- left: "calc(".concat("var(--ds-space-negative-300, -24px)", " + ", "var(--ds-space-negative-100, -8px)", ")")
31
- });
32
- var appear = (0, _react2.keyframes)({
33
- from: {
34
- visibility: 'hidden'
35
- },
36
- to: {
37
- visibility: 'visible'
38
- }
39
- });
40
- var delayedAppearance = (0, _primitives.xcss)({
41
- visibility: 'hidden',
42
- animation: "".concat(appear, " 0.1s"),
43
- animationDelay: '2s',
44
- animationFillMode: 'forwards'
45
- });
46
- var buttonStyles = (0, _primitives.xcss)({
47
- boxSizing: 'border-box',
48
- display: 'flex',
49
- flexDirection: 'column',
50
- justifyContent: 'center',
51
- alignItems: 'center',
52
- height: "var(--ds-space-300, 24px)",
53
- width: "var(--ds-space-300, 24px)",
54
- border: 'none',
55
- backgroundColor: 'color.background.neutral',
56
- borderRadius: '50%',
57
- color: 'color.text.accent.gray',
58
- zIndex: 'card',
59
- outline: 'none',
60
- ':hover': {
61
- backgroundColor: 'color.background.neutral.hovered'
62
- },
63
- ':active': {
64
- backgroundColor: 'color.background.neutral.pressed'
65
- },
66
- ':focus': {
67
- outline: "2px solid ".concat("var(--ds-border-focused, #388BFF)")
68
- }
69
- });
70
- var TypeAheadControl = exports.TypeAheadControl = function TypeAheadControl(_ref) {
71
- var api = _ref.api,
72
- getPos = _ref.getPos,
73
- formatMessage = _ref.intl.formatMessage;
74
- return /*#__PURE__*/_react.default.createElement(_primitives.Box, {
75
- xcss: [wrapperStyles],
76
- testId: "editor-empty-line-prompt-experiment"
77
- }, /*#__PURE__*/_react.default.createElement(_tooltip.default, {
78
- content: /*#__PURE__*/_react.default.createElement(_keymaps.ToolTipContent, {
79
- description: formatMessage(_messages.blockControlsMessages.insert),
80
- shortcutOverride: "/"
81
- })
82
- }, /*#__PURE__*/_react.default.createElement(_primitives.Pressable, {
83
- type: "button",
84
- "aria-label": formatMessage(_messages.blockControlsMessages.insert),
85
- xcss: [buttonStyles].concat((0, _toConsumableArray2.default)((0, _platformFeatureFlags.fg)('platform_editor_empty_line_prompt_delay') ? [delayedAppearance] : [])),
86
- onClick: function onClick() {
87
- var _api$core, _api$quickInsert;
88
- api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref2) {
89
- var tr = _ref2.tr;
90
- var start = getPos();
91
- if (!start) {
92
- return null;
93
- }
94
- return tr.setSelection(_state.TextSelection.create(tr.doc, start));
95
- });
96
- api === null || api === void 0 || (_api$quickInsert = api.quickInsert) === null || _api$quickInsert === void 0 || _api$quickInsert.actions.openTypeAhead('blockControl');
97
- }
98
- }, /*#__PURE__*/_react.default.createElement(_add.default, {
99
- label: "add",
100
- size: "medium"
101
- }))));
102
- };
103
- var TypeAheadControlWithIntl = (0, _reactIntlNext.injectIntl)(TypeAheadControl);
104
- var toDOM = function toDOM(api, getPos, getIntl) {
105
- var wrapper = document.createElement('span');
106
- wrapper.contentEditable = 'false';
107
- wrapper.setAttribute('data-empty-block-experiment', 'true');
108
- wrapper.setAttribute('class', 'empty-block-experiment');
109
- var element = document.createElement('span');
110
- element.contentEditable = 'false';
111
- element.setAttribute('style', 'position: absolute;');
112
- wrapper.appendChild(element);
113
- _reactDom.default.render( /*#__PURE__*/(0, _react.createElement)(_reactIntlNext.RawIntlProvider, {
114
- value: getIntl()
115
- }, /*#__PURE__*/(0, _react.createElement)(TypeAheadControlWithIntl, {
116
- api: api,
117
- getPos: getPos
118
- })), element);
119
-
120
- // // This is a hack to ensure that the cursor in Chrome does not take on the height of the widget button.
121
- // // Cursor height cannot be controlled via CSS and is handled by the browser.
122
- // // see Prosemirror forum: https://discuss.prosemirror.net/t/chrome-caret-cursor-larger-than-the-text-with-inlined-items/5946
123
- var cursorHack = document.createTextNode(_whitespace.ZERO_WIDTH_SPACE);
124
- wrapper.appendChild(cursorHack);
125
- return wrapper;
126
- };
127
- var createEmptyBlockWidgetDecoration = exports.createEmptyBlockWidgetDecoration = function createEmptyBlockWidgetDecoration(selection, api, getIntl) {
128
- if (selection instanceof _state.TextSelection && selection.$cursor) {
129
- var _$cursor$parent, _$cursor$parent2;
130
- var $cursor = selection.$cursor;
131
- var depth = $cursor.depth;
132
- var cursorAtRoot = depth === 1;
133
- var nodeIsEmpty = ((_$cursor$parent = $cursor.parent) === null || _$cursor$parent === void 0 ? void 0 : _$cursor$parent.nodeSize) === 2;
134
- var supportedNodeTypes = ['paragraph', 'heading'];
135
- if (cursorAtRoot && nodeIsEmpty && supportedNodeTypes.includes((_$cursor$parent2 = $cursor.parent) === null || _$cursor$parent2 === void 0 ? void 0 : _$cursor$parent2.type.name)) {
136
- return _view2.Decoration.widget(selection.$cursor.posAtIndex($cursor.depth - 1), function (_view, getPos) {
137
- return toDOM(api, getPos, getIntl);
138
- }, {
139
- key: 'emptyBlockWidgetDecoration',
140
- side: -1
141
- });
142
- }
143
- }
144
- };
@@ -1,38 +0,0 @@
1
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
- import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
4
- import { createEmptyBlockWidgetDecoration } from '../ui/empty-block-experiment/widget';
5
- export const emptyBlockExperimentPluginKey = new PluginKey('emptyBlockExperiment');
6
- const getDecorations = (tr, api, getIntl) => {
7
- var _api$editorDisabled, _api$editorDisabled$s;
8
- const isEditorDisabled = api === null || api === void 0 ? void 0 : (_api$editorDisabled = api.editorDisabled) === null || _api$editorDisabled === void 0 ? void 0 : (_api$editorDisabled$s = _api$editorDisabled.sharedState.currentState()) === null || _api$editorDisabled$s === void 0 ? void 0 : _api$editorDisabled$s.editorDisabled;
9
- if (isEditorDisabled) {
10
- return DecorationSet.empty;
11
- }
12
- const widget = createEmptyBlockWidgetDecoration(tr.selection, api, getIntl);
13
- if (widget) {
14
- return DecorationSet.create(tr.doc, [widget]);
15
- }
16
- return DecorationSet.empty;
17
- };
18
- export const createEmptyBlockExperimentPlugin = (api, getIntl) => {
19
- return new SafePlugin({
20
- key: emptyBlockExperimentPluginKey,
21
- state: {
22
- init: (_, _editorState) => ({
23
- decorations: DecorationSet.empty
24
- }),
25
- apply: (tr, _currentState) => {
26
- return {
27
- decorations: getDecorations(tr, api, getIntl)
28
- };
29
- }
30
- },
31
- props: {
32
- decorations: state => {
33
- var _emptyBlockExperiment;
34
- return (_emptyBlockExperiment = emptyBlockExperimentPluginKey.getState(state)) === null || _emptyBlockExperiment === void 0 ? void 0 : _emptyBlockExperiment.decorations;
35
- }
36
- }
37
- });
38
- };