@atlaskit/editor-plugin-block-controls 1.4.34 → 1.5.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 1.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#115247](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/115247)
8
+ [`251d23ff9e6c8`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/251d23ff9e6c8) -
9
+ upgrade adf-schema version to 38.0.0
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
15
+ ## 1.4.35
16
+
17
+ ### Patch Changes
18
+
19
+ - [#115170](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/115170)
20
+ [`d3d39a486f0d9`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/d3d39a486f0d9) -
21
+ Fix drag handle position when deleting a paragraph
22
+ - [#115170](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/115170)
23
+ [`108a85e557e41`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/108a85e557e41) -
24
+ Hide drag handle on empty paragraph
25
+
3
26
  ## 1.4.34
4
27
 
5
28
  ### Patch Changes
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.nodeDecorations = exports.mouseMoveWrapperDecorations = exports.dropTargetDecorations = exports.dragHandleDecoration = void 0;
7
+ exports.nodeDecorations = exports.mouseMoveWrapperDecorations = exports.emptyParagraphNodeDecorations = exports.dropTargetDecorations = exports.dragHandleDecoration = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _react = require("react");
10
10
  var _reactDom = _interopRequireDefault(require("react-dom"));
@@ -69,10 +69,19 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
69
69
  decorationState: decorationState
70
70
  };
71
71
  };
72
+ var emptyParagraphNodeDecorations = exports.emptyParagraphNodeDecorations = function emptyParagraphNodeDecorations() {
73
+ var anchorName = "--node-anchor-paragraph-0";
74
+ var style = "anchor-name: ".concat(anchorName, "; margin-top: 0px;");
75
+ return _view.Decoration.node(0, 2, (0, _defineProperty2.default)({
76
+ style: style
77
+ }, 'data-drag-handler-anchor-name', anchorName), {
78
+ type: 'node-decoration'
79
+ });
80
+ };
72
81
  var nodeDecorations = exports.nodeDecorations = function nodeDecorations(newState) {
73
82
  var decs = [];
74
83
  newState.doc.descendants(function (node, pos, _parent, index) {
75
- var _Decoration$node;
84
+ var _Decoration$node2;
76
85
  var anchorName = "--node-anchor-".concat(node.type.name, "-").concat(index);
77
86
  var style;
78
87
  if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
@@ -80,9 +89,11 @@ var nodeDecorations = exports.nodeDecorations = function nodeDecorations(newStat
80
89
  } else {
81
90
  style = "anchor-name: ".concat(anchorName, "; ").concat(pos === 0 ? 'margin-top: 0px;' : '');
82
91
  }
83
- decs.push(_view.Decoration.node(pos, pos + node.nodeSize, (_Decoration$node = {
92
+ decs.push(_view.Decoration.node(pos, pos + node.nodeSize, (_Decoration$node2 = {
84
93
  style: style
85
- }, (0, _defineProperty2.default)(_Decoration$node, 'data-drag-handler-anchor-name', anchorName), (0, _defineProperty2.default)(_Decoration$node, 'data-drag-handler-node-type', node.type.name), _Decoration$node)));
94
+ }, (0, _defineProperty2.default)(_Decoration$node2, 'data-drag-handler-anchor-name', anchorName), (0, _defineProperty2.default)(_Decoration$node2, 'data-drag-handler-node-type', node.type.name), _Decoration$node2), {
95
+ type: 'node-decoration'
96
+ }));
86
97
  return false;
87
98
  });
88
99
  return decs;
@@ -236,6 +236,14 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
236
236
  if (tr.docChanged && !redrawDecorations) {
237
237
  decorations = decorations.map(tr.mapping, tr.doc);
238
238
  }
239
+ var isEmptyDoc = newState.doc.childCount === 1 && newState.doc.nodeSize <= 4;
240
+ var hasNodeDecoration = decorations.find().some(function (_ref11) {
241
+ var spec = _ref11.spec;
242
+ return spec.type === 'node-decoration';
243
+ });
244
+ if (!hasNodeDecoration && isEmptyDoc) {
245
+ decorations = decorations.add(newState.doc, [(0, _decorations.emptyParagraphNodeDecorations)()]);
246
+ }
239
247
 
240
248
  // Map active node position when the document changes
241
249
  var mappedActiveNodePos = tr.docChanged && activeNode ? {
@@ -243,7 +251,6 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
243
251
  anchorName: activeNode.anchorName,
244
252
  nodeType: activeNode.nodeType
245
253
  } : activeNode;
246
- var isEmptyDoc = newState.doc.childCount === 1 && newState.doc.nodeSize <= 4;
247
254
  return {
248
255
  decorations: decorations,
249
256
  decorationState: decorationState,
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.GlobalStylesWrapper = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
7
9
  var _react = require("@emotion/react");
8
10
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
9
11
  /** @jsx jsx */
@@ -32,13 +34,18 @@ var extendedHoverZone = (0, _react.css)({
32
34
  display: 'none'
33
35
  }
34
36
  });
35
- var globalStyles = (0, _react.css)({
37
+ var paragraphWithTrailingBreak = '+ p > .ProseMirror-trailingBreak';
38
+ var paragraphWithCursorTarget = '+ p > .cursor-target';
39
+ var globalStyles = (0, _react.css)((0, _defineProperty2.default)({
36
40
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
37
41
  '.ProseMirror-widget:first-child + *': {
38
42
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles -- Ignored via go/DSP-18766
39
43
  marginTop: '0 !important'
40
44
  }
41
- });
45
+ }, ".ProseMirror-widget[data-blocks-drag-handle-container=\"true\"]:has(".concat(paragraphWithTrailingBreak, "):not(:has(").concat(paragraphWithCursorTarget, "))"), {
46
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
47
+ display: 'none !important'
48
+ }));
42
49
  var GlobalStylesWrapper = exports.GlobalStylesWrapper = function GlobalStylesWrapper() {
43
50
  return (0, _react.jsx)(_react.Global, {
44
51
  styles: [globalStyles, (0, _platformFeatureFlags.getBooleanFF)('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2') && extendedHoverZone]
@@ -61,6 +61,16 @@ export const dropTargetDecorations = (oldState, newState, api) => {
61
61
  decorationState
62
62
  };
63
63
  };
64
+ export const emptyParagraphNodeDecorations = () => {
65
+ const anchorName = `--node-anchor-paragraph-0`;
66
+ const style = `anchor-name: ${anchorName}; margin-top: 0px;`;
67
+ return Decoration.node(0, 2, {
68
+ style,
69
+ ['data-drag-handler-anchor-name']: anchorName
70
+ }, {
71
+ type: 'node-decoration'
72
+ });
73
+ };
64
74
  export const nodeDecorations = newState => {
65
75
  const decs = [];
66
76
  newState.doc.descendants((node, pos, _parent, index) => {
@@ -75,6 +85,8 @@ export const nodeDecorations = newState => {
75
85
  style,
76
86
  ['data-drag-handler-anchor-name']: anchorName,
77
87
  ['data-drag-handler-node-type']: node.type.name
88
+ }, {
89
+ type: 'node-decoration'
78
90
  }));
79
91
  return false;
80
92
  });
@@ -9,7 +9,7 @@ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
9
9
  import { autoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-scroll/element';
10
10
  import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
11
11
  import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
12
- import { dragHandleDecoration, dropTargetDecorations, mouseMoveWrapperDecorations, nodeDecorations } from './decorations';
12
+ import { dragHandleDecoration, dropTargetDecorations, emptyParagraphNodeDecorations, mouseMoveWrapperDecorations, nodeDecorations } from './decorations';
13
13
  import { handleMouseOver } from './handle-mouse-over';
14
14
  export const key = new PluginKey('blockControls');
15
15
  const destroyFn = api => {
@@ -227,6 +227,13 @@ export const createPlugin = api => {
227
227
  if (tr.docChanged && !redrawDecorations) {
228
228
  decorations = decorations.map(tr.mapping, tr.doc);
229
229
  }
230
+ const isEmptyDoc = newState.doc.childCount === 1 && newState.doc.nodeSize <= 4;
231
+ const hasNodeDecoration = decorations.find().some(({
232
+ spec
233
+ }) => spec.type === 'node-decoration');
234
+ if (!hasNodeDecoration && isEmptyDoc) {
235
+ decorations = decorations.add(newState.doc, [emptyParagraphNodeDecorations()]);
236
+ }
230
237
 
231
238
  // Map active node position when the document changes
232
239
  const mappedActiveNodePos = tr.docChanged && activeNode ? {
@@ -234,7 +241,6 @@ export const createPlugin = api => {
234
241
  anchorName: activeNode.anchorName,
235
242
  nodeType: activeNode.nodeType
236
243
  } : activeNode;
237
- const isEmptyDoc = newState.doc.childCount === 1 && newState.doc.nodeSize <= 4;
238
244
  return {
239
245
  decorations,
240
246
  decorationState,
@@ -25,11 +25,20 @@ const extendedHoverZone = css({
25
25
  display: 'none'
26
26
  }
27
27
  });
28
+ const paragraphWithTrailingBreak = '+ p > .ProseMirror-trailingBreak';
29
+ const paragraphWithCursorTarget = '+ p > .cursor-target';
28
30
  const globalStyles = css({
29
31
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
30
32
  '.ProseMirror-widget:first-child + *': {
31
33
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles -- Ignored via go/DSP-18766
32
34
  marginTop: '0 !important'
35
+ },
36
+ // Currently, we are hiding the drag handle container by checking if the paragraph has a trailing break and no cursor target
37
+ // TODO ED-23827 add a classname to empty paragraphs for easier targeting
38
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-values
39
+ [`.ProseMirror-widget[data-blocks-drag-handle-container="true"]:has(${paragraphWithTrailingBreak}):not(:has(${paragraphWithCursorTarget}))`]: {
40
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
41
+ display: 'none !important'
33
42
  }
34
43
  });
35
44
  export const GlobalStylesWrapper = () => {
@@ -62,10 +62,19 @@ export var dropTargetDecorations = function dropTargetDecorations(oldState, newS
62
62
  decorationState: decorationState
63
63
  };
64
64
  };
65
+ export var emptyParagraphNodeDecorations = function emptyParagraphNodeDecorations() {
66
+ var anchorName = "--node-anchor-paragraph-0";
67
+ var style = "anchor-name: ".concat(anchorName, "; margin-top: 0px;");
68
+ return Decoration.node(0, 2, _defineProperty({
69
+ style: style
70
+ }, 'data-drag-handler-anchor-name', anchorName), {
71
+ type: 'node-decoration'
72
+ });
73
+ };
65
74
  export var nodeDecorations = function nodeDecorations(newState) {
66
75
  var decs = [];
67
76
  newState.doc.descendants(function (node, pos, _parent, index) {
68
- var _Decoration$node;
77
+ var _Decoration$node2;
69
78
  var anchorName = "--node-anchor-".concat(node.type.name, "-").concat(index);
70
79
  var style;
71
80
  if (getBooleanFF('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
@@ -73,9 +82,11 @@ export var nodeDecorations = function nodeDecorations(newState) {
73
82
  } else {
74
83
  style = "anchor-name: ".concat(anchorName, "; ").concat(pos === 0 ? 'margin-top: 0px;' : '');
75
84
  }
76
- decs.push(Decoration.node(pos, pos + node.nodeSize, (_Decoration$node = {
85
+ decs.push(Decoration.node(pos, pos + node.nodeSize, (_Decoration$node2 = {
77
86
  style: style
78
- }, _defineProperty(_Decoration$node, 'data-drag-handler-anchor-name', anchorName), _defineProperty(_Decoration$node, 'data-drag-handler-node-type', node.type.name), _Decoration$node)));
87
+ }, _defineProperty(_Decoration$node2, 'data-drag-handler-anchor-name', anchorName), _defineProperty(_Decoration$node2, 'data-drag-handler-node-type', node.type.name), _Decoration$node2), {
88
+ type: 'node-decoration'
89
+ }));
79
90
  return false;
80
91
  });
81
92
  return decs;
@@ -10,7 +10,7 @@ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
10
10
  import { autoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-scroll/element';
11
11
  import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
12
12
  import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
13
- import { dragHandleDecoration, dropTargetDecorations, mouseMoveWrapperDecorations, nodeDecorations } from './decorations';
13
+ import { dragHandleDecoration, dropTargetDecorations, emptyParagraphNodeDecorations, mouseMoveWrapperDecorations, nodeDecorations } from './decorations';
14
14
  import { handleMouseOver } from './handle-mouse-over';
15
15
  export var key = new PluginKey('blockControls');
16
16
  var destroyFn = function destroyFn(api) {
@@ -229,6 +229,14 @@ export var createPlugin = function createPlugin(api) {
229
229
  if (tr.docChanged && !redrawDecorations) {
230
230
  decorations = decorations.map(tr.mapping, tr.doc);
231
231
  }
232
+ var isEmptyDoc = newState.doc.childCount === 1 && newState.doc.nodeSize <= 4;
233
+ var hasNodeDecoration = decorations.find().some(function (_ref11) {
234
+ var spec = _ref11.spec;
235
+ return spec.type === 'node-decoration';
236
+ });
237
+ if (!hasNodeDecoration && isEmptyDoc) {
238
+ decorations = decorations.add(newState.doc, [emptyParagraphNodeDecorations()]);
239
+ }
232
240
 
233
241
  // Map active node position when the document changes
234
242
  var mappedActiveNodePos = tr.docChanged && activeNode ? {
@@ -236,7 +244,6 @@ export var createPlugin = function createPlugin(api) {
236
244
  anchorName: activeNode.anchorName,
237
245
  nodeType: activeNode.nodeType
238
246
  } : activeNode;
239
- var isEmptyDoc = newState.doc.childCount === 1 && newState.doc.nodeSize <= 4;
240
247
  return {
241
248
  decorations: decorations,
242
249
  decorationState: decorationState,
@@ -1,3 +1,4 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
1
2
  /** @jsx jsx */
2
3
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles, @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
3
4
  import { css, Global, jsx } from '@emotion/react';
@@ -25,13 +26,18 @@ var extendedHoverZone = css({
25
26
  display: 'none'
26
27
  }
27
28
  });
28
- var globalStyles = css({
29
+ var paragraphWithTrailingBreak = '+ p > .ProseMirror-trailingBreak';
30
+ var paragraphWithCursorTarget = '+ p > .cursor-target';
31
+ var globalStyles = css(_defineProperty({
29
32
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
30
33
  '.ProseMirror-widget:first-child + *': {
31
34
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles -- Ignored via go/DSP-18766
32
35
  marginTop: '0 !important'
33
36
  }
34
- });
37
+ }, ".ProseMirror-widget[data-blocks-drag-handle-container=\"true\"]:has(".concat(paragraphWithTrailingBreak, "):not(:has(").concat(paragraphWithCursorTarget, "))"), {
38
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
39
+ display: 'none !important'
40
+ }));
35
41
  export var GlobalStylesWrapper = function GlobalStylesWrapper() {
36
42
  return jsx(Global, {
37
43
  styles: [globalStyles, getBooleanFF('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2') && extendedHoverZone]
@@ -9,6 +9,7 @@ export declare const dropTargetDecorations: (oldState: EditorState, newState: Ed
9
9
  pos: number;
10
10
  }[];
11
11
  };
12
+ export declare const emptyParagraphNodeDecorations: () => Decoration;
12
13
  export declare const nodeDecorations: (newState: EditorState) => Decoration[];
13
14
  /**
14
15
  * Setting up decorations around each node to track mousemove events into each node
@@ -9,6 +9,7 @@ export declare const dropTargetDecorations: (oldState: EditorState, newState: Ed
9
9
  pos: number;
10
10
  }[];
11
11
  };
12
+ export declare const emptyParagraphNodeDecorations: () => Decoration;
12
13
  export declare const nodeDecorations: (newState: EditorState) => Decoration[];
13
14
  /**
14
15
  * Setting up decorations around each node to track mousemove events into each node
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "1.4.34",
3
+ "version": "1.5.0",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -31,9 +31,9 @@
31
31
  ".": "./src/index.ts"
32
32
  },
33
33
  "dependencies": {
34
- "@atlaskit/adf-schema": "^37.0.0",
35
- "@atlaskit/editor-common": "^83.0.0",
36
- "@atlaskit/editor-plugin-analytics": "^1.3.0",
34
+ "@atlaskit/adf-schema": "^38.0.0",
35
+ "@atlaskit/editor-common": "^83.3.0",
36
+ "@atlaskit/editor-plugin-analytics": "^1.4.0",
37
37
  "@atlaskit/editor-plugin-editor-disabled": "^1.1.5",
38
38
  "@atlaskit/editor-plugin-feature-flags": "^1.1.0",
39
39
  "@atlaskit/editor-plugin-width": "^1.1.0",