@atlaskit/editor-plugin-panel 4.2.4 → 4.2.5

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,13 @@
1
1
  # @atlaskit/editor-plugin-panel
2
2
 
3
+ ## 4.2.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [#123532](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/123532)
8
+ [`ed7bd14b40fef`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ed7bd14b40fef) -
9
+ [ux] ED-26941 Prevent backspace in a new paragraph from deleting extension in panel and blockquote
10
+
3
11
  ## 4.2.4
4
12
 
5
13
  ### Patch Changes
@@ -186,6 +186,8 @@ var panelPlugin = function panelPlugin(_ref) {
186
186
  panelIcon: ':rainbow:',
187
187
  panelIconId: '1f308',
188
188
  panelIconText: '🌈',
189
+ // Ignored via go/ees007
190
+ // eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
189
191
  // TODO: https://product-fabric.atlassian.net/browse/DSP-7268
190
192
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
191
193
  panelColor: _colors.T50
@@ -8,6 +8,7 @@ exports.keymapPlugin = keymapPlugin;
8
8
  var _utils = require("@atlaskit/editor-common/utils");
9
9
  var _keymap = require("@atlaskit/editor-prosemirror/keymap");
10
10
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
11
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
11
12
  function findParentNode(selection, nodeType) {
12
13
  var parentPosition = (0, _utils2.findParentNodeOfType)(nodeType)(selection);
13
14
  if (parentPosition) {
@@ -27,7 +28,7 @@ function keymapPlugin() {
27
28
  };
28
29
  var keymaps = {
29
30
  Backspace: function Backspace(state, dispatch) {
30
- var _nodeBeforePanel$type;
31
+ var _$previousPos$nodeAft, _nodeBeforePanel$type;
31
32
  var selection = state.selection,
32
33
  nodes = state.schema.nodes,
33
34
  tr = state.tr;
@@ -36,7 +37,8 @@ function keymapPlugin() {
36
37
  orderedList = nodes.orderedList,
37
38
  bulletList = nodes.bulletList,
38
39
  mediaSingle = nodes.mediaSingle,
39
- mediaGroup = nodes.mediaGroup;
40
+ mediaGroup = nodes.mediaGroup,
41
+ extension = nodes.extension;
40
42
  var $from = selection.$from,
41
43
  $to = selection.$to;
42
44
  // Don't do anything if selection is a range
@@ -57,10 +59,12 @@ function keymapPlugin() {
57
59
  var isPreviousNodeMedia = previousNodeType === mediaSingle || previousNodeType === mediaGroup;
58
60
  var isPreviousNodeAList = previousNodeType === bulletList || previousNodeType === orderedList;
59
61
 
62
+ // identifies if new position after backspace is at the start of a non-bodied extension node
63
+ var isPreviousPosAtExtension = (0, _platformFeatureFlags.fg)('platform_editor_nbm_backspace_fixes') && ((_$previousPos$nodeAft = $previousPos.nodeAfter) === null || _$previousPos$nodeAft === void 0 ? void 0 : _$previousPos$nodeAft.type) === extension;
64
+
60
65
  // Stops merging panels when deleting empty paragraph in between
61
66
  // Stops merging blockquotes with panels when deleting from start of blockquote
62
-
63
- if (isPreviousNodeAPanel && !isParentNodeAPanel || isInsideAnEmptyNode(selection, panel, state.schema) || (0, _utils2.hasParentNodeOfType)(blockquote)(selection) && !isPreviousNodeAList && !isPreviousNodeMedia ||
67
+ if (isPreviousNodeAPanel && !isParentNodeAPanel && !isPreviousPosAtExtension || isInsideAnEmptyNode(selection, panel, state.schema) || (0, _utils2.hasParentNodeOfType)(blockquote)(selection) && !isPreviousNodeAList && !isPreviousNodeMedia && !isPreviousPosAtExtension ||
64
68
  // Lift line of panel content up and out of the panel, when backspacing
65
69
  // at the start of a panel, if the node before the panel is an 'isolating' node
66
70
  // (for e.g. a table, or an expand), otherwise the default prosemirror backspace
@@ -57,7 +57,7 @@ var panelIconMap = exports.panelIconMap = (0, _defineProperty2.default)((0, _def
57
57
  id: 'atlassian-tip'
58
58
  });
59
59
  var getToolbarItems = exports.getToolbarItems = function getToolbarItems(formatMessage, panelNodeType, isCustomPanelEnabled, isCustomPanelEditable, providerFactory, hoverDecoration, editorAnalyticsAPI, activePanelType, activePanelColor, activePanelIcon, state, api) {
60
- // TODO: ED-14403 investigate why these titles are not getting translated for the tooltips
60
+ // TODO: ED-14403 - investigate why these titles are not getting translated for the tooltips
61
61
  var items = [{
62
62
  id: 'editor.panel.info',
63
63
  type: 'button',
@@ -162,6 +162,8 @@ const panelPlugin = ({
162
162
  panelIcon: ':rainbow:',
163
163
  panelIconId: '1f308',
164
164
  panelIconText: '🌈',
165
+ // Ignored via go/ees007
166
+ // eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
165
167
  // TODO: https://product-fabric.atlassian.net/browse/DSP-7268
166
168
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
167
169
  panelColor: T50
@@ -1,6 +1,7 @@
1
1
  import { isEmptyNode } from '@atlaskit/editor-common/utils';
2
2
  import { keymap } from '@atlaskit/editor-prosemirror/keymap';
3
3
  import { findParentNodeOfType, hasParentNodeOfType, setTextSelection } from '@atlaskit/editor-prosemirror/utils';
4
+ import { fg } from '@atlaskit/platform-feature-flags';
4
5
  function findParentNode(selection, nodeType) {
5
6
  const parentPosition = findParentNodeOfType(nodeType)(selection);
6
7
  if (parentPosition) {
@@ -20,7 +21,7 @@ export function keymapPlugin() {
20
21
  };
21
22
  const keymaps = {
22
23
  Backspace: (state, dispatch) => {
23
- var _nodeBeforePanel$type, _nodeBeforePanel$type2;
24
+ var _$previousPos$nodeAft, _nodeBeforePanel$type, _nodeBeforePanel$type2;
24
25
  const {
25
26
  selection,
26
27
  schema: {
@@ -34,7 +35,8 @@ export function keymapPlugin() {
34
35
  orderedList,
35
36
  bulletList,
36
37
  mediaSingle,
37
- mediaGroup
38
+ mediaGroup,
39
+ extension
38
40
  } = nodes;
39
41
  const {
40
42
  $from,
@@ -58,10 +60,12 @@ export function keymapPlugin() {
58
60
  const isPreviousNodeMedia = previousNodeType === mediaSingle || previousNodeType === mediaGroup;
59
61
  const isPreviousNodeAList = previousNodeType === bulletList || previousNodeType === orderedList;
60
62
 
63
+ // identifies if new position after backspace is at the start of a non-bodied extension node
64
+ const isPreviousPosAtExtension = fg('platform_editor_nbm_backspace_fixes') && ((_$previousPos$nodeAft = $previousPos.nodeAfter) === null || _$previousPos$nodeAft === void 0 ? void 0 : _$previousPos$nodeAft.type) === extension;
65
+
61
66
  // Stops merging panels when deleting empty paragraph in between
62
67
  // Stops merging blockquotes with panels when deleting from start of blockquote
63
-
64
- if (isPreviousNodeAPanel && !isParentNodeAPanel || isInsideAnEmptyNode(selection, panel, state.schema) || hasParentNodeOfType(blockquote)(selection) && !isPreviousNodeAList && !isPreviousNodeMedia ||
68
+ if (isPreviousNodeAPanel && !isParentNodeAPanel && !isPreviousPosAtExtension || isInsideAnEmptyNode(selection, panel, state.schema) || hasParentNodeOfType(blockquote)(selection) && !isPreviousNodeAList && !isPreviousNodeMedia && !isPreviousPosAtExtension ||
65
69
  // Lift line of panel content up and out of the panel, when backspacing
66
70
  // at the start of a panel, if the node before the panel is an 'isolating' node
67
71
  // (for e.g. a table, or an expand), otherwise the default prosemirror backspace
@@ -51,7 +51,7 @@ export const panelIconMap = {
51
51
  }
52
52
  };
53
53
  export const getToolbarItems = (formatMessage, panelNodeType, isCustomPanelEnabled, isCustomPanelEditable, providerFactory, hoverDecoration, editorAnalyticsAPI, activePanelType, activePanelColor, activePanelIcon, state, api) => {
54
- // TODO: ED-14403 investigate why these titles are not getting translated for the tooltips
54
+ // TODO: ED-14403 - investigate why these titles are not getting translated for the tooltips
55
55
  const items = [{
56
56
  id: 'editor.panel.info',
57
57
  type: 'button',
@@ -179,6 +179,8 @@ var panelPlugin = function panelPlugin(_ref) {
179
179
  panelIcon: ':rainbow:',
180
180
  panelIconId: '1f308',
181
181
  panelIconText: '🌈',
182
+ // Ignored via go/ees007
183
+ // eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
182
184
  // TODO: https://product-fabric.atlassian.net/browse/DSP-7268
183
185
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
184
186
  panelColor: T50
@@ -1,6 +1,7 @@
1
1
  import { isEmptyNode } from '@atlaskit/editor-common/utils';
2
2
  import { keymap } from '@atlaskit/editor-prosemirror/keymap';
3
3
  import { findParentNodeOfType, hasParentNodeOfType, setTextSelection } from '@atlaskit/editor-prosemirror/utils';
4
+ import { fg } from '@atlaskit/platform-feature-flags';
4
5
  function findParentNode(selection, nodeType) {
5
6
  var parentPosition = findParentNodeOfType(nodeType)(selection);
6
7
  if (parentPosition) {
@@ -20,7 +21,7 @@ export function keymapPlugin() {
20
21
  };
21
22
  var keymaps = {
22
23
  Backspace: function Backspace(state, dispatch) {
23
- var _nodeBeforePanel$type;
24
+ var _$previousPos$nodeAft, _nodeBeforePanel$type;
24
25
  var selection = state.selection,
25
26
  nodes = state.schema.nodes,
26
27
  tr = state.tr;
@@ -29,7 +30,8 @@ export function keymapPlugin() {
29
30
  orderedList = nodes.orderedList,
30
31
  bulletList = nodes.bulletList,
31
32
  mediaSingle = nodes.mediaSingle,
32
- mediaGroup = nodes.mediaGroup;
33
+ mediaGroup = nodes.mediaGroup,
34
+ extension = nodes.extension;
33
35
  var $from = selection.$from,
34
36
  $to = selection.$to;
35
37
  // Don't do anything if selection is a range
@@ -50,10 +52,12 @@ export function keymapPlugin() {
50
52
  var isPreviousNodeMedia = previousNodeType === mediaSingle || previousNodeType === mediaGroup;
51
53
  var isPreviousNodeAList = previousNodeType === bulletList || previousNodeType === orderedList;
52
54
 
55
+ // identifies if new position after backspace is at the start of a non-bodied extension node
56
+ var isPreviousPosAtExtension = fg('platform_editor_nbm_backspace_fixes') && ((_$previousPos$nodeAft = $previousPos.nodeAfter) === null || _$previousPos$nodeAft === void 0 ? void 0 : _$previousPos$nodeAft.type) === extension;
57
+
53
58
  // Stops merging panels when deleting empty paragraph in between
54
59
  // Stops merging blockquotes with panels when deleting from start of blockquote
55
-
56
- if (isPreviousNodeAPanel && !isParentNodeAPanel || isInsideAnEmptyNode(selection, panel, state.schema) || hasParentNodeOfType(blockquote)(selection) && !isPreviousNodeAList && !isPreviousNodeMedia ||
60
+ if (isPreviousNodeAPanel && !isParentNodeAPanel && !isPreviousPosAtExtension || isInsideAnEmptyNode(selection, panel, state.schema) || hasParentNodeOfType(blockquote)(selection) && !isPreviousNodeAList && !isPreviousNodeMedia && !isPreviousPosAtExtension ||
57
61
  // Lift line of panel content up and out of the panel, when backspacing
58
62
  // at the start of a panel, if the node before the panel is an 'isolating' node
59
63
  // (for e.g. a table, or an expand), otherwise the default prosemirror backspace
@@ -47,7 +47,7 @@ export var panelIconMap = _defineProperty(_defineProperty(_defineProperty(_defin
47
47
  id: 'atlassian-tip'
48
48
  });
49
49
  export var getToolbarItems = function getToolbarItems(formatMessage, panelNodeType, isCustomPanelEnabled, isCustomPanelEditable, providerFactory, hoverDecoration, editorAnalyticsAPI, activePanelType, activePanelColor, activePanelIcon, state, api) {
50
- // TODO: ED-14403 investigate why these titles are not getting translated for the tooltips
50
+ // TODO: ED-14403 - investigate why these titles are not getting translated for the tooltips
51
51
  var items = [{
52
52
  id: 'editor.panel.info',
53
53
  type: 'button',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-panel",
3
- "version": "4.2.4",
3
+ "version": "4.2.5",
4
4
  "description": "Panel plugin for @atlaskit/editor-core.",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -32,11 +32,11 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@atlaskit/adf-schema": "^47.6.0",
35
- "@atlaskit/editor-common": "^102.0.0",
35
+ "@atlaskit/editor-common": "^102.1.0",
36
36
  "@atlaskit/editor-palette": "^2.0.0",
37
37
  "@atlaskit/editor-plugin-analytics": "^2.1.0",
38
38
  "@atlaskit/editor-plugin-decorations": "^2.0.0",
39
- "@atlaskit/editor-plugin-emoji": "^3.1.0",
39
+ "@atlaskit/editor-plugin-emoji": "^3.2.0",
40
40
  "@atlaskit/editor-prosemirror": "7.0.0",
41
41
  "@atlaskit/editor-shared-styles": "^3.4.0",
42
42
  "@atlaskit/emoji": "^68.0.0",
@@ -94,6 +94,9 @@
94
94
  "platform-feature-flags": {
95
95
  "platform_editor_update_panel_icon_aria_label": {
96
96
  "type": "boolean"
97
+ },
98
+ "platform_editor_nbm_backspace_fixes": {
99
+ "type": "boolean"
97
100
  }
98
101
  },
99
102
  "stricter": {