@atlaskit/editor-plugin-block-controls 2.10.0 → 2.11.0

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.
Files changed (36) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/cjs/pm-plugins/decorations-anchor.js +97 -0
  3. package/dist/cjs/pm-plugins/decorations-common.js +49 -0
  4. package/dist/cjs/pm-plugins/decorations-drag-handle.js +88 -0
  5. package/dist/cjs/pm-plugins/{decorations.js → decorations-drop-target.js} +11 -209
  6. package/dist/cjs/pm-plugins/main.js +21 -19
  7. package/dist/cjs/ui/drop-target-v2.js +3 -3
  8. package/dist/cjs/ui/global-styles.js +101 -86
  9. package/dist/cjs/ui/inline-drop-target.js +3 -3
  10. package/dist/es2019/pm-plugins/decorations-anchor.js +89 -0
  11. package/dist/es2019/pm-plugins/decorations-common.js +31 -0
  12. package/dist/es2019/pm-plugins/decorations-drag-handle.js +79 -0
  13. package/dist/es2019/pm-plugins/{decorations.js → decorations-drop-target.js} +6 -193
  14. package/dist/es2019/pm-plugins/main.js +3 -1
  15. package/dist/es2019/ui/drop-target-v2.js +1 -1
  16. package/dist/es2019/ui/global-styles.js +17 -6
  17. package/dist/es2019/ui/inline-drop-target.js +1 -1
  18. package/dist/esm/pm-plugins/decorations-anchor.js +90 -0
  19. package/dist/esm/pm-plugins/decorations-common.js +42 -0
  20. package/dist/esm/pm-plugins/decorations-drag-handle.js +81 -0
  21. package/dist/esm/pm-plugins/{decorations.js → decorations-drop-target.js} +6 -204
  22. package/dist/esm/pm-plugins/main.js +3 -1
  23. package/dist/esm/ui/drop-target-v2.js +1 -1
  24. package/dist/esm/ui/global-styles.js +101 -86
  25. package/dist/esm/ui/inline-drop-target.js +1 -1
  26. package/dist/types/pm-plugins/decorations-anchor.d.ts +13 -0
  27. package/dist/types/pm-plugins/decorations-common.d.ts +7 -0
  28. package/dist/types/pm-plugins/decorations-drag-handle.d.ts +7 -0
  29. package/dist/types/pm-plugins/decorations-drop-target.d.ts +17 -0
  30. package/dist/types-ts4.5/pm-plugins/decorations-anchor.d.ts +13 -0
  31. package/dist/types-ts4.5/pm-plugins/decorations-common.d.ts +7 -0
  32. package/dist/types-ts4.5/pm-plugins/decorations-drag-handle.d.ts +7 -0
  33. package/dist/types-ts4.5/pm-plugins/decorations-drop-target.d.ts +17 -0
  34. package/package.json +4 -4
  35. package/dist/types/pm-plugins/decorations.d.ts +0 -35
  36. package/dist/types-ts4.5/pm-plugins/decorations.d.ts +0 -35
@@ -1,35 +1,26 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
2
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
4
  import { createElement } from 'react';
7
- import { bind } from 'bind-event-listener';
8
5
  import ReactDOM from 'react-dom';
9
- import uuid from 'uuid';
10
6
  import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
11
7
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
12
8
  import { fg } from '@atlaskit/platform-feature-flags';
13
9
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
14
10
  import { nodeMargins } from '../ui/consts';
15
- import { DragHandle } from '../ui/drag-handle';
16
11
  import { DropTarget } from '../ui/drop-target';
17
12
  import { DropTargetV2, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_GAP, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_OFFSET } from '../ui/drop-target-v2';
18
13
  import { isBlocksDragTargetDebug } from '../utils/drag-target-debug';
19
14
  import { canMoveNodeToIndex } from '../utils/validation';
15
+ import { getNestedDepth, TYPE_DROP_TARGET_DEC, unmountDecorations } from './decorations-common';
20
16
  var IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'layoutColumn', 'listItem', 'caption'];
21
- var IGNORE_NODE_DESCENDANTS = ['listItem', 'taskList', 'decisionList', 'mediaSingle'];
22
17
  var PARENT_WITH_END_DROP_TARGET = ['tableCell', 'tableHeader', 'panel', 'layoutColumn', 'expand', 'nestedExpand', 'bodiedExtension'];
23
18
  var DISABLE_CHILD_DROP_TARGET = ['orderedList', 'bulletList'];
24
- export var TYPE_DROP_TARGET_DEC = 'drop-target-decoration';
25
- export var TYPE_HANDLE_DEC = 'drag-handle';
26
- export var TYPE_NODE_DEC = 'node-decoration';
27
- var getNestedDepth = function getNestedDepth() {
28
- return editorExperiment('nested-dnd', true) ? 100 : 0;
29
- };
30
- export var getNodeAnchor = function getNodeAnchor(node) {
31
- var handleId = ObjHash.getForNode(node);
32
- return "--node-anchor-".concat(node.type.name, "-").concat(handleId);
19
+ var shouldDescend = function shouldDescend(node) {
20
+ if (fg('platform_editor_drag_and_drop_target_v2')) {
21
+ return !['mediaSingle', 'paragraph', 'heading'].includes(node.type.name);
22
+ }
23
+ return true;
33
24
  };
34
25
  var getNodeMargins = function getNodeMargins(node) {
35
26
  if (!node) {
@@ -74,12 +65,6 @@ var getGapAndOffset = function getGapAndOffset(prevNode, nextNode, parentNode) {
74
65
  offset: offset
75
66
  };
76
67
  };
77
- var shouldDescend = function shouldDescend(node) {
78
- if (fg('platform_editor_drag_and_drop_target_v2')) {
79
- return !['mediaSingle', 'paragraph', 'heading'].includes(node.type.name);
80
- }
81
- return true;
82
- };
83
68
 
84
69
  /**
85
70
  * Find drop target decorations in the pos range between from and to
@@ -93,41 +78,6 @@ export var findDropTargetDecs = function findDropTargetDecs(decorations, from, t
93
78
  return spec.type === TYPE_DROP_TARGET_DEC;
94
79
  });
95
80
  };
96
- export var findHandleDec = function findHandleDec(decorations, from, to) {
97
- return decorations.find(from, to, function (spec) {
98
- return spec.type === TYPE_HANDLE_DEC;
99
- });
100
- };
101
-
102
- /**
103
- * Find node decorations in the pos range between from and to (non-inclusive)
104
- * @param decorations
105
- * @param from
106
- * @param to
107
- * @returns
108
- */
109
- export var findNodeDecs = function findNodeDecs(decorations, from, to) {
110
- var newfrom = from;
111
- var newTo = to;
112
-
113
- // make it non-inclusive
114
- if (newfrom !== undefined) {
115
- newfrom++;
116
- }
117
-
118
- // make it non-inclusive
119
- if (newTo !== undefined) {
120
- newTo--;
121
- }
122
-
123
- // return empty array if range reversed
124
- if (newfrom !== undefined && newTo !== undefined && newfrom > newTo) {
125
- return new Array();
126
- }
127
- return decorations.find(newfrom, newTo, function (spec) {
128
- return spec.type === TYPE_NODE_DEC;
129
- });
130
- };
131
81
  export var createDropTargetDecoration = function createDropTargetDecoration(pos, props, side, anchorRectCache) {
132
82
  return Decoration.widget(pos, function (_, getPos) {
133
83
  var element = document.createElement('div');
@@ -253,152 +203,4 @@ export var dropTargetDecorations = function dropTargetDecorations(newState, api,
253
203
  }, undefined, anchorRectCache));
254
204
  }
255
205
  return decs;
256
- };
257
- export var emptyParagraphNodeDecorations = function emptyParagraphNodeDecorations() {
258
- var anchorName = "--node-anchor-paragraph-0";
259
- var style = "anchor-name: ".concat(anchorName, "; margin-top: 0px;");
260
- return Decoration.node(0, 2, _defineProperty({
261
- style: style
262
- }, 'data-drag-handler-anchor-name', anchorName), {
263
- type: TYPE_NODE_DEC
264
- });
265
- };
266
- var ObjHash = /*#__PURE__*/function () {
267
- function ObjHash() {
268
- _classCallCheck(this, ObjHash);
269
- }
270
- _createClass(ObjHash, null, [{
271
- key: "getForNode",
272
- value: function getForNode(node) {
273
- if (this.caching.has(node)) {
274
- return this.caching.get(node);
275
- }
276
- var uniqueId = uuid();
277
- this.caching.set(node, uniqueId);
278
- return uniqueId;
279
- }
280
- }]);
281
- return ObjHash;
282
- }();
283
- _defineProperty(ObjHash, "caching", new WeakMap());
284
- var shouldIgnoreNode = function shouldIgnoreNode(node) {
285
- // TODO use isWrappedMedia when clean up the featue flag
286
- if ('mediaSingle' === node.type.name && fg('platform_editor_element_dnd_nested_fix_patch_1')) {
287
- if (['wrap-right', 'wrap-left'].includes(node.attrs.layout)) {
288
- return true;
289
- }
290
- }
291
- return IGNORE_NODES.includes(node.type.name);
292
- };
293
- export var shouldDescendIntoNode = function shouldDescendIntoNode(node) {
294
- // Optimisation to avoid drawing node decorations for empty table cells
295
- if (['tableCell', 'tableHeader'].includes(node.type.name) && !editorExperiment('table-nested-dnd', true) && fg('platform_editor_element_dnd_nested_fix_patch_3')) {
296
- var _node$firstChild;
297
- if (node.childCount === 1 && ((_node$firstChild = node.firstChild) === null || _node$firstChild === void 0 ? void 0 : _node$firstChild.type.name) === 'paragraph') {
298
- return false;
299
- }
300
- }
301
- return !IGNORE_NODE_DESCENDANTS.includes(node.type.name);
302
- };
303
- export var nodeDecorations = function nodeDecorations(newState, from, to) {
304
- var decs = [];
305
- var docFrom = from === undefined || from < 0 ? 0 : from;
306
- var docTo = to === undefined || to > newState.doc.nodeSize - 2 ? newState.doc.nodeSize - 2 : to;
307
- newState.doc.nodesBetween(docFrom, docTo, function (node, pos, _parent, index) {
308
- var _Decoration$node2;
309
- var depth = 0;
310
- var anchorName;
311
- var shouldDescend = shouldDescendIntoNode(node);
312
- var handleId = ObjHash.getForNode(node);
313
- anchorName = "--node-anchor-".concat(node.type.name, "-").concat(handleId);
314
- if (editorExperiment('nested-dnd', true)) {
315
- var _anchorName;
316
- // Doesn't descend into a node
317
- if (node.isInline) {
318
- return false;
319
- }
320
- if (shouldIgnoreNode(node)) {
321
- return shouldDescend; //skip over, don't consider it a valid depth
322
- }
323
- depth = newState.doc.resolve(pos).depth;
324
- anchorName = (_anchorName = anchorName) !== null && _anchorName !== void 0 ? _anchorName : "--node-anchor-".concat(node.type.name, "-").concat(pos);
325
- } else {
326
- var _anchorName2;
327
- anchorName = (_anchorName2 = anchorName) !== null && _anchorName2 !== void 0 ? _anchorName2 : "--node-anchor-".concat(node.type.name, "-").concat(index);
328
- }
329
- decs.push(Decoration.node(pos, pos + node.nodeSize, (_Decoration$node2 = {
330
- style: "anchor-name: ".concat(anchorName, "; ").concat(pos === 0 ? 'margin-top: 0px;' : '', "; position: relative; z-index: 1;")
331
- }, _defineProperty(_Decoration$node2, 'data-drag-handler-anchor-name', anchorName), _defineProperty(_Decoration$node2, 'data-drag-handler-node-type', node.type.name), _defineProperty(_Decoration$node2, 'data-drag-handler-anchor-depth', "".concat(depth)), _Decoration$node2), {
332
- type: TYPE_NODE_DEC,
333
- anchorName: anchorName,
334
- nodeType: node.type.name
335
- }));
336
- return shouldDescend && depth < getNestedDepth();
337
- });
338
- return decs;
339
- };
340
- export var dragHandleDecoration = function dragHandleDecoration(api, formatMessage, pos, anchorName, nodeType, handleOptions) {
341
- unmountDecorations('data-blocks-drag-handle-container');
342
- var unbind;
343
- return Decoration.widget(pos, function (view, getPos) {
344
- var element = document.createElement('span');
345
- // Need to set it to inline to avoid text being split when merging two paragraphs
346
- // platform_editor_element_dnd_nested_fix_patch_2 -> inline decoration causes focus issues when refocusing Editor into first line
347
- element.style.display = fg('platform_editor_element_dnd_nested_fix_patch_2') ? 'block' : 'inline';
348
- element.setAttribute('data-testid', 'block-ctrl-decorator-widget');
349
- element.setAttribute('data-blocks-drag-handle-container', 'true');
350
- var isTopLevelNode = true;
351
- if (editorExperiment('nested-dnd', true)) {
352
- var newPos = fg('platform_editor_element_dnd_nested_fix_patch_3') ? getPos() : pos;
353
- if (typeof newPos === 'number') {
354
- var $pos = view.state.doc.resolve(newPos);
355
- isTopLevelNode = ($pos === null || $pos === void 0 ? void 0 : $pos.parent.type.name) === 'doc';
356
- }
357
- /*
358
- * We disable mouseover event to fix flickering issue on hover
359
- * However, the tooltip for nested drag handle is no long working.
360
- */
361
- if (newPos === undefined || !isTopLevelNode) {
362
- // This will also hide the tooltip.
363
- unbind = bind(element, {
364
- type: 'mouseover',
365
- listener: function listener(e) {
366
- e.stopPropagation();
367
- }
368
- });
369
- }
370
- }
371
-
372
- // There are times when global clear: "both" styles are applied to this decoration causing jumpiness
373
- // due to margins applied to other nodes eg. Headings
374
- element.style.clear = 'unset';
375
- ReactDOM.render( /*#__PURE__*/createElement(DragHandle, {
376
- view: view,
377
- api: api,
378
- formatMessage: formatMessage,
379
- getPos: getPos,
380
- anchorName: anchorName,
381
- nodeType: nodeType,
382
- handleOptions: handleOptions,
383
- isTopLevelNode: isTopLevelNode
384
- }), element);
385
- return element;
386
- }, {
387
- side: -1,
388
- type: TYPE_HANDLE_DEC,
389
- testid: "".concat(TYPE_HANDLE_DEC, "-").concat(uuid()),
390
- destroy: function destroy() {
391
- if (editorExperiment('nested-dnd', true)) {
392
- unbind && unbind();
393
- }
394
- }
395
- });
396
- };
397
- var unmountDecorations = function unmountDecorations(selector) {
398
- // Removing decorations manually instead of using native destroy function in prosemirror API
399
- // as it was more responsive and causes less re-rendering
400
- var decorationsToRemove = document.querySelectorAll("[".concat(selector, "=\"true\"]"));
401
- decorationsToRemove.forEach(function (el) {
402
- ReactDOM.unmountComponentAtNode(el);
403
- });
404
206
  };
@@ -15,7 +15,9 @@ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
15
15
  import { AnchorRectCache, isAnchorSupported } from '../utils/anchor-utils';
16
16
  import { isBlocksDragTargetDebug } from '../utils/drag-target-debug';
17
17
  import { getTrMetadata } from '../utils/transactions';
18
- import { dragHandleDecoration, dropTargetDecorations, emptyParagraphNodeDecorations, findDropTargetDecs, findHandleDec, findNodeDecs, nodeDecorations } from './decorations';
18
+ import { findNodeDecs, nodeDecorations } from './decorations-anchor';
19
+ import { dragHandleDecoration, emptyParagraphNodeDecorations, findHandleDec } from './decorations-drag-handle';
20
+ import { dropTargetDecorations, findDropTargetDecs } from './decorations-drop-target';
19
21
  import { handleMouseOver } from './handle-mouse-over';
20
22
  import { boundKeydownHandler } from './keymap';
21
23
  export var key = new PluginKey('blockControls');
@@ -14,7 +14,7 @@ import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-drop-indi
14
14
  import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
15
15
  import { layers } from '@atlaskit/theme/constants';
16
16
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
17
- import { getNodeAnchor } from '../pm-plugins/decorations';
17
+ import { getNodeAnchor } from '../pm-plugins/decorations-common';
18
18
  import { isAnchorSupported } from '../utils/anchor-utils';
19
19
  import { isBlocksDragTargetDebug } from '../utils/drag-target-debug';
20
20
  import { shouldAllowInlineDropTarget } from '../utils/inline-drop-target';
@@ -9,94 +9,100 @@ import { fg } from '@atlaskit/platform-feature-flags';
9
9
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
10
10
  import { DRAG_HANDLE_MAX_WIDTH_PLUS_GAP } from './consts';
11
11
  import { emptyBlockExperimentGlobalStyles } from './empty-block-experiment/global-styles';
12
- var extendedHoverZone = css({
13
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
14
- '.block-ctrl-drag-preview [data-drag-handler-anchor-name]::after': {
15
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
16
- display: 'none !important'
17
- },
18
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
19
- '.ProseMirror': {
20
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
21
- '&& [data-drag-handler-anchor-name]::after': {
22
- content: '""',
23
- position: 'absolute',
24
- top: 0,
25
- left: '-100%',
26
- width: '100%',
27
- height: '100%',
28
- background: 'transparent',
29
- cursor: 'default',
30
- zIndex: -1
12
+ var extendedHoverZone = function extendedHoverZone() {
13
+ return css({
14
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
15
+ '.block-ctrl-drag-preview [data-drag-handler-anchor-name]::after': {
16
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
17
+ display: 'none !important'
18
+ },
19
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
20
+ '.ProseMirror': {
21
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
22
+ '&& [data-drag-handler-anchor-name]::after': {
23
+ content: '""',
24
+ position: 'absolute',
25
+ top: 0,
26
+ left: '-100%',
27
+ width: '100%',
28
+ height: '100%',
29
+ background: 'transparent',
30
+ cursor: 'default',
31
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
32
+ zIndex: fg('platform_editor_element_dnd_nested_fix_patch_3') ? 1 : -1
33
+ }
34
+ },
35
+ // 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
36
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
37
+ 'hr[data-drag-handler-anchor-name]': {
38
+ overflow: 'visible'
39
+ },
40
+ //eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
41
+ '[data-blocks-drag-handle-container="true"] + *::after': {
42
+ display: 'none'
31
43
  }
32
- },
33
- // 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
34
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
35
- 'hr[data-drag-handler-anchor-name]': {
36
- overflow: 'visible'
37
- },
38
- //eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
39
- '[data-blocks-drag-handle-container="true"] + *::after': {
40
- display: 'none'
41
- }
42
- });
43
- var extendedHoverZoneNested = css({
44
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
45
- '.block-ctrl-drag-preview [data-drag-handler-anchor-name]::after': {
46
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
47
- display: 'none !important'
48
- },
49
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
50
- '.ProseMirror': {
51
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
52
- '&& [data-drag-handler-anchor-name]::after': {
53
- content: '""',
54
- position: 'absolute',
55
- top: 0,
56
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
57
- left: "-".concat(DRAG_HANDLE_MAX_WIDTH_PLUS_GAP, "px"),
58
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
59
- width: "".concat(DRAG_HANDLE_MAX_WIDTH_PLUS_GAP, "px"),
60
- height: '100%',
61
- cursor: 'default',
62
- zIndex: 1
44
+ });
45
+ };
46
+ var extendedHoverZoneNested = function extendedHoverZoneNested() {
47
+ return css({
48
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
49
+ '.block-ctrl-drag-preview [data-drag-handler-anchor-name]::after': {
50
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
51
+ display: 'none !important'
63
52
  },
64
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
65
- '&& [data-drag-handler-anchor-depth="0"][data-drag-handler-anchor-name]::after': {
66
- content: '""',
67
- position: 'absolute',
68
- top: 0,
69
- left: '-100%',
70
- width: '100%',
71
- height: '100%',
72
- cursor: 'default',
73
- zIndex: -1
53
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
54
+ '.ProseMirror': {
55
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
56
+ '&& [data-drag-handler-anchor-name]::after': {
57
+ content: '""',
58
+ position: 'absolute',
59
+ top: 0,
60
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
61
+ left: "-".concat(DRAG_HANDLE_MAX_WIDTH_PLUS_GAP, "px"),
62
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
63
+ width: "".concat(DRAG_HANDLE_MAX_WIDTH_PLUS_GAP, "px"),
64
+ height: '100%',
65
+ cursor: 'default',
66
+ zIndex: 1
67
+ },
68
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
69
+ '&& [data-drag-handler-anchor-depth="0"][data-drag-handler-anchor-name]::after': {
70
+ content: '""',
71
+ position: 'absolute',
72
+ top: 0,
73
+ left: '-100%',
74
+ width: '100%',
75
+ height: '100%',
76
+ cursor: 'default',
77
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
78
+ zIndex: fg('platform_editor_element_dnd_nested_fix_patch_3') ? 1 : -1
79
+ },
80
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
81
+ '&& :is(.pm-table-cell-content-wrap, .pm-table-header-content-wrap) > [data-drag-handler-anchor-name]::after': {
82
+ content: '""',
83
+ position: 'absolute',
84
+ top: 0,
85
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
86
+ left: "-".concat(editorExperiment('table-nested-dnd', true) ? DRAG_HANDLE_MAX_WIDTH_PLUS_GAP : 0, "px"),
87
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
88
+ width: "".concat(editorExperiment('table-nested-dnd', true) ? DRAG_HANDLE_MAX_WIDTH_PLUS_GAP : 0, "px"),
89
+ height: '100%',
90
+ cursor: 'default',
91
+ zIndex: 1
92
+ }
74
93
  },
75
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
76
- '&& :is(.pm-table-cell-content-wrap, .pm-table-header-content-wrap) > [data-drag-handler-anchor-name]::after': {
77
- content: '""',
78
- position: 'absolute',
79
- top: 0,
80
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
81
- left: "-".concat(editorExperiment('table-nested-dnd', true) ? DRAG_HANDLE_MAX_WIDTH_PLUS_GAP : 0, "px"),
82
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
83
- width: "".concat(editorExperiment('table-nested-dnd', true) ? DRAG_HANDLE_MAX_WIDTH_PLUS_GAP : 0, "px"),
84
- height: '100%',
85
- cursor: 'default',
86
- zIndex: 1
94
+ // 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
95
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
96
+ 'hr[data-drag-handler-anchor-name]': {
97
+ overflow: 'visible'
98
+ },
99
+ //Hide pseudo element at top depth level. Leave for nested depths to prevent mouseover loop.
100
+ //eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
101
+ '[data-blocks-drag-handle-container="true"] + [data-drag-handler-anchor-depth="0"]::after': {
102
+ display: 'none'
87
103
  }
88
- },
89
- // 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
90
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
91
- 'hr[data-drag-handler-anchor-name]': {
92
- overflow: 'visible'
93
- },
94
- //Hide pseudo element at top depth level. Leave for nested depths to prevent mouseover loop.
95
- //eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
96
- '[data-blocks-drag-handle-container="true"] + [data-drag-handler-anchor-depth="0"]::after': {
97
- display: 'none'
98
- }
99
- });
104
+ });
105
+ };
100
106
  var paragraphWithTrailingBreakAsOnlyChild = '+ :is(p, h1, h2, h3, h4, h5, h6) > .ProseMirror-trailingBreak:only-child';
101
107
  var indentatedParagraphWithTrailingBreakAsOnlyChild = '+ div.fabric-editor-indentation-mark > :is(p, h1, h2, h3, h4, h5, h6) > .ProseMirror-trailingBreak:only-child';
102
108
  var paragraphWithPlaceholder = '+ p > .placeholder-decoration';
@@ -149,10 +155,19 @@ var withFormatInLayoutStyleFix = css(_defineProperty({}, "".concat(withFormatInL
149
155
  var getTextNodeStyle = function getTextNodeStyle() {
150
156
  return fg('platform_editor_element_controls_chrome_input_fix') ? withInlineNodeStyleWithChromeFix : withInlineNodeStyle;
151
157
  };
158
+ var withRelativePosStyle = css({
159
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
160
+ '.ProseMirror': {
161
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
162
+ '&& [data-drag-handler-anchor-name]': {
163
+ position: 'relative'
164
+ }
165
+ }
166
+ });
152
167
  export var GlobalStylesWrapper = function GlobalStylesWrapper() {
153
168
  return jsx(Global, {
154
- styles: [globalStyles, editorExperiment('nested-dnd', true) ? extendedHoverZoneNested : extendedHoverZone, getTextNodeStyle(), withDeleteLinesStyleFix, withMediaSingleStyleFix, editorExperiment('platform_editor_empty_line_prompt', true, {
169
+ styles: [globalStyles, editorExperiment('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), getTextNodeStyle(), withDeleteLinesStyleFix, withMediaSingleStyleFix, editorExperiment('platform_editor_empty_line_prompt', true, {
155
170
  exposure: false
156
- }) ? emptyBlockExperimentGlobalStyles : undefined, fg('platform_editor_element_dnd_nested_fix_patch_1') ? withDividerInPanelStyleFix : undefined, fg('platform_editor_element_dnd_nested_fix_patch_2') ? withFormatInLayoutStyleFix : undefined]
171
+ }) ? 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 : undefined]
157
172
  });
158
173
  };
@@ -12,7 +12,7 @@ import { css, jsx } from '@emotion/react';
12
12
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
13
13
  import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box';
14
14
  import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
15
- import { getNodeAnchor } from '../pm-plugins/decorations';
15
+ import { getNodeAnchor } from '../pm-plugins/decorations-common';
16
16
  import { isAnchorSupported } from '../utils/anchor-utils';
17
17
  import { isBlocksDragTargetDebug } from '../utils/drag-target-debug';
18
18
  var dropTargetCommonStyle = css({
@@ -0,0 +1,13 @@
1
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
3
+ import { Decoration, type DecorationSet } from '@atlaskit/editor-prosemirror/view';
4
+ export declare const shouldDescendIntoNode: (node: PMNode) => boolean;
5
+ /**
6
+ * Find node decorations in the pos range between from and to (non-inclusive)
7
+ * @param decorations
8
+ * @param from
9
+ * @param to
10
+ * @returns
11
+ */
12
+ export declare const findNodeDecs: (decorations: DecorationSet, from?: number, to?: number) => Decoration[];
13
+ export declare const nodeDecorations: (newState: EditorState, from?: number, to?: number) => Decoration[];
@@ -0,0 +1,7 @@
1
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
+ export declare const TYPE_DROP_TARGET_DEC = "drop-target-decoration";
3
+ export declare const TYPE_HANDLE_DEC = "drag-handle";
4
+ export declare const TYPE_NODE_DEC = "node-decoration";
5
+ export declare const getNestedDepth: () => 0 | 100;
6
+ export declare const getNodeAnchor: (node: PMNode) => string;
7
+ export declare const unmountDecorations: (selector: string) => void;
@@ -0,0 +1,7 @@
1
+ import { type IntlShape } from 'react-intl-next';
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import { Decoration, type DecorationSet } from '@atlaskit/editor-prosemirror/view';
4
+ import type { BlockControlsPlugin, HandleOptions } from '../types';
5
+ export declare const emptyParagraphNodeDecorations: () => Decoration;
6
+ export declare const findHandleDec: (decorations: DecorationSet, from?: number, to?: number) => Decoration[];
7
+ export declare const dragHandleDecoration: (api: ExtractInjectionAPI<BlockControlsPlugin>, formatMessage: IntlShape['formatMessage'], pos: number, anchorName: string, nodeType: string, handleOptions?: HandleOptions) => Decoration;
@@ -0,0 +1,17 @@
1
+ import { type IntlShape } from 'react-intl-next';
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
4
+ import { Decoration, type DecorationSet } from '@atlaskit/editor-prosemirror/view';
5
+ import type { ActiveNode, BlockControlsPlugin } from '../types';
6
+ import { type DropTargetProps } from '../ui/drop-target';
7
+ import { type AnchorRectCache } from '../utils/anchor-utils';
8
+ /**
9
+ * Find drop target decorations in the pos range between from and to
10
+ * @param decorations
11
+ * @param from
12
+ * @param to
13
+ * @returns
14
+ */
15
+ export declare const findDropTargetDecs: (decorations: DecorationSet, from?: number, to?: number) => Decoration[];
16
+ export declare const createDropTargetDecoration: (pos: number, props: Omit<DropTargetProps, 'getPos'>, side?: number, anchorRectCache?: AnchorRectCache) => Decoration;
17
+ export declare const dropTargetDecorations: (newState: EditorState, api: ExtractInjectionAPI<BlockControlsPlugin>, formatMessage: IntlShape['formatMessage'], activeNode?: ActiveNode, anchorRectCache?: AnchorRectCache, from?: number, to?: number) => Decoration[];
@@ -0,0 +1,13 @@
1
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
3
+ import { Decoration, type DecorationSet } from '@atlaskit/editor-prosemirror/view';
4
+ export declare const shouldDescendIntoNode: (node: PMNode) => boolean;
5
+ /**
6
+ * Find node decorations in the pos range between from and to (non-inclusive)
7
+ * @param decorations
8
+ * @param from
9
+ * @param to
10
+ * @returns
11
+ */
12
+ export declare const findNodeDecs: (decorations: DecorationSet, from?: number, to?: number) => Decoration[];
13
+ export declare const nodeDecorations: (newState: EditorState, from?: number, to?: number) => Decoration[];
@@ -0,0 +1,7 @@
1
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
+ export declare const TYPE_DROP_TARGET_DEC = "drop-target-decoration";
3
+ export declare const TYPE_HANDLE_DEC = "drag-handle";
4
+ export declare const TYPE_NODE_DEC = "node-decoration";
5
+ export declare const getNestedDepth: () => 0 | 100;
6
+ export declare const getNodeAnchor: (node: PMNode) => string;
7
+ export declare const unmountDecorations: (selector: string) => void;
@@ -0,0 +1,7 @@
1
+ import { type IntlShape } from 'react-intl-next';
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import { Decoration, type DecorationSet } from '@atlaskit/editor-prosemirror/view';
4
+ import type { BlockControlsPlugin, HandleOptions } from '../types';
5
+ export declare const emptyParagraphNodeDecorations: () => Decoration;
6
+ export declare const findHandleDec: (decorations: DecorationSet, from?: number, to?: number) => Decoration[];
7
+ export declare const dragHandleDecoration: (api: ExtractInjectionAPI<BlockControlsPlugin>, formatMessage: IntlShape['formatMessage'], pos: number, anchorName: string, nodeType: string, handleOptions?: HandleOptions) => Decoration;
@@ -0,0 +1,17 @@
1
+ import { type IntlShape } from 'react-intl-next';
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
4
+ import { Decoration, type DecorationSet } from '@atlaskit/editor-prosemirror/view';
5
+ import type { ActiveNode, BlockControlsPlugin } from '../types';
6
+ import { type DropTargetProps } from '../ui/drop-target';
7
+ import { type AnchorRectCache } from '../utils/anchor-utils';
8
+ /**
9
+ * Find drop target decorations in the pos range between from and to
10
+ * @param decorations
11
+ * @param from
12
+ * @param to
13
+ * @returns
14
+ */
15
+ export declare const findDropTargetDecs: (decorations: DecorationSet, from?: number, to?: number) => Decoration[];
16
+ export declare const createDropTargetDecoration: (pos: number, props: Omit<DropTargetProps, 'getPos'>, side?: number, anchorRectCache?: AnchorRectCache) => Decoration;
17
+ export declare const dropTargetDecorations: (newState: EditorState, api: ExtractInjectionAPI<BlockControlsPlugin>, formatMessage: IntlShape['formatMessage'], activeNode?: ActiveNode, anchorRectCache?: AnchorRectCache, from?: number, to?: number) => Decoration[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "2.10.0",
3
+ "version": "2.11.0",
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": "^42.3.1",
34
- "@atlaskit/editor-common": "^94.2.0",
34
+ "@atlaskit/editor-common": "^94.4.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",
@@ -39,7 +39,7 @@
39
39
  "@atlaskit/editor-plugin-quick-insert": "^1.5.0",
40
40
  "@atlaskit/editor-plugin-width": "^1.3.0",
41
41
  "@atlaskit/editor-prosemirror": "6.0.0",
42
- "@atlaskit/editor-shared-styles": "^3.0.0",
42
+ "@atlaskit/editor-shared-styles": "^3.1.0",
43
43
  "@atlaskit/editor-tables": "^2.8.0",
44
44
  "@atlaskit/icon": "^22.24.0",
45
45
  "@atlaskit/platform-feature-flags": "^0.3.0",
@@ -48,7 +48,7 @@
48
48
  "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^1.1.0",
49
49
  "@atlaskit/primitives": "^12.2.0",
50
50
  "@atlaskit/theme": "^14.0.0",
51
- "@atlaskit/tmp-editor-statsig": "^2.8.0",
51
+ "@atlaskit/tmp-editor-statsig": "^2.9.0",
52
52
  "@atlaskit/tokens": "^2.0.0",
53
53
  "@atlaskit/tooltip": "^18.8.0",
54
54
  "@babel/runtime": "^7.0.0",