@atlaskit/editor-plugin-panel 4.2.4 → 4.2.6

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,22 @@
1
1
  # @atlaskit/editor-plugin-panel
2
2
 
3
+ ## 4.2.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [#123966](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/123966)
8
+ [`980562a51a41f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/980562a51a41f) -
9
+ [ux] ED-26796 Change panel type buttons into dropdown
10
+ - Updated dependencies
11
+
12
+ ## 4.2.5
13
+
14
+ ### Patch Changes
15
+
16
+ - [#123532](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/123532)
17
+ [`ed7bd14b40fef`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ed7bd14b40fef) -
18
+ [ux] ED-26941 Prevent backspace in a new paragraph from deleting extension in panel and blockquote
19
+
3
20
  ## 4.2.4
4
21
 
5
22
  ### 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
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.panelTypeDropdown = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _adfSchema = require("@atlaskit/adf-schema");
10
+ var _messages = require("@atlaskit/editor-common/messages");
11
+ var _crossCircle = _interopRequireDefault(require("@atlaskit/icon/core/cross-circle"));
12
+ var _customize = _interopRequireDefault(require("@atlaskit/icon/core/customize"));
13
+ var _discovery = _interopRequireDefault(require("@atlaskit/icon/core/discovery"));
14
+ var _information = _interopRequireDefault(require("@atlaskit/icon/core/information"));
15
+ var _success = _interopRequireDefault(require("@atlaskit/icon/core/success"));
16
+ var _warning = _interopRequireDefault(require("@atlaskit/icon/core/warning"));
17
+ var _actions = require("../editor-actions/actions");
18
+ var panelTitleAndIcon = (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _adfSchema.PanelType.INFO, {
19
+ title: _messages.panelMessages.info,
20
+ icon: (0, _information.default)({
21
+ label: 'info-icon',
22
+ color: "var(--ds-icon-information, #1D7AFC)"
23
+ })
24
+ }), _adfSchema.PanelType.NOTE, {
25
+ title: _messages.panelMessages.note,
26
+ icon: (0, _discovery.default)({
27
+ label: 'note-icon',
28
+ color: "var(--ds-icon-discovery, #8270DB)"
29
+ })
30
+ }), _adfSchema.PanelType.SUCCESS, {
31
+ title: _messages.panelMessages.success,
32
+ icon: (0, _success.default)({
33
+ label: 'success-icon',
34
+ color: "var(--ds-icon-success, #22A06B)"
35
+ })
36
+ }), _adfSchema.PanelType.WARNING, {
37
+ title: _messages.panelMessages.warning,
38
+ icon: (0, _warning.default)({
39
+ label: 'warning-icon',
40
+ color: "var(--ds-icon-warning, #E56910)"
41
+ })
42
+ }), _adfSchema.PanelType.ERROR, {
43
+ title: _messages.panelMessages.error,
44
+ icon: (0, _crossCircle.default)({
45
+ label: 'error-icon',
46
+ color: "var(--ds-icon-danger, #C9372C)"
47
+ })
48
+ }), _adfSchema.PanelType.CUSTOM, {
49
+ title: _messages.panelMessages.custom,
50
+ icon: (0, _customize.default)({
51
+ label: 'custom-icon'
52
+ })
53
+ });
54
+ var panelTypeDropdown = exports.panelTypeDropdown = function panelTypeDropdown(_ref) {
55
+ var activePanelType = _ref.activePanelType,
56
+ editorAnalyticsAPI = _ref.editorAnalyticsAPI,
57
+ formatMessage = _ref.formatMessage;
58
+ var dropdownOptions = [{
59
+ id: 'editor.panel.info',
60
+ icon: panelTitleAndIcon[_adfSchema.PanelType.INFO].icon,
61
+ onClick: (0, _actions.changePanelType)(editorAnalyticsAPI)(_adfSchema.PanelType.INFO),
62
+ selected: activePanelType === _adfSchema.PanelType.INFO,
63
+ title: formatMessage(panelTitleAndIcon[_adfSchema.PanelType.INFO].title)
64
+ }, {
65
+ id: 'editor.panel.note',
66
+ icon: panelTitleAndIcon[_adfSchema.PanelType.NOTE].icon,
67
+ onClick: (0, _actions.changePanelType)(editorAnalyticsAPI)(_adfSchema.PanelType.NOTE),
68
+ selected: activePanelType === _adfSchema.PanelType.NOTE,
69
+ title: formatMessage(panelTitleAndIcon[_adfSchema.PanelType.NOTE].title)
70
+ }, {
71
+ id: 'editor.panel.success',
72
+ icon: panelTitleAndIcon[_adfSchema.PanelType.SUCCESS].icon,
73
+ onClick: (0, _actions.changePanelType)(editorAnalyticsAPI)(_adfSchema.PanelType.SUCCESS),
74
+ selected: activePanelType === _adfSchema.PanelType.SUCCESS,
75
+ title: formatMessage(panelTitleAndIcon[_adfSchema.PanelType.SUCCESS].title)
76
+ }, {
77
+ id: 'editor.panel.warning',
78
+ icon: panelTitleAndIcon[_adfSchema.PanelType.WARNING].icon,
79
+ onClick: (0, _actions.changePanelType)(editorAnalyticsAPI)(_adfSchema.PanelType.WARNING),
80
+ selected: activePanelType === _adfSchema.PanelType.WARNING,
81
+ title: formatMessage(panelTitleAndIcon[_adfSchema.PanelType.WARNING].title)
82
+ }, {
83
+ id: 'editor.panel.error',
84
+ icon: panelTitleAndIcon[_adfSchema.PanelType.ERROR].icon,
85
+ onClick: (0, _actions.changePanelType)(editorAnalyticsAPI)(_adfSchema.PanelType.ERROR),
86
+ selected: activePanelType === _adfSchema.PanelType.ERROR,
87
+ title: formatMessage(panelTitleAndIcon[_adfSchema.PanelType.ERROR].title)
88
+ }];
89
+ var selectedPanelType = activePanelType || _adfSchema.PanelType.INFO;
90
+ var selectedTitleAndIcon = panelTitleAndIcon[selectedPanelType];
91
+ return {
92
+ id: 'panel-type-dropdown',
93
+ testId: 'panel-type-dropdown-trigger',
94
+ type: 'dropdown',
95
+ options: dropdownOptions,
96
+ showSelected: true,
97
+ iconBefore: function iconBefore() {
98
+ return selectedTitleAndIcon.icon;
99
+ },
100
+ title: formatMessage(selectedTitleAndIcon.title)
101
+ };
102
+ };
@@ -33,6 +33,7 @@ var _warning2 = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/warn
33
33
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
34
34
  var _actions = require("../editor-actions/actions");
35
35
  var _utils2 = require("../pm-plugins/utils/utils");
36
+ var _panelTypeDropdown = require("./panelTypeDropdown");
36
37
  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); }
37
38
  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; }
38
39
  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; }
@@ -57,8 +58,8 @@ var panelIconMap = exports.panelIconMap = (0, _defineProperty2.default)((0, _def
57
58
  id: 'atlassian-tip'
58
59
  });
59
60
  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
61
- var items = [{
61
+ // TODO: ED-14403 - investigate why these titles are not getting translated for the tooltips
62
+ var items = (0, _experiments.editorExperiment)('platform_editor_controls', 'control') ? [{
62
63
  id: 'editor.panel.info',
63
64
  type: 'button',
64
65
  icon: _information.default,
@@ -103,6 +104,12 @@ var getToolbarItems = exports.getToolbarItems = function getToolbarItems(formatM
103
104
  selected: activePanelType === _adfSchema.PanelType.ERROR,
104
105
  title: formatMessage(_messages.panelMessages.error),
105
106
  tabIndex: null
107
+ }] : [(0, _panelTypeDropdown.panelTypeDropdown)({
108
+ activePanelType: activePanelType,
109
+ editorAnalyticsAPI: editorAnalyticsAPI,
110
+ formatMessage: formatMessage
111
+ }), {
112
+ type: 'separator'
106
113
  }];
107
114
  if (isCustomPanelEnabled) {
108
115
  var changeColor = function changeColor(color) {
@@ -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
@@ -0,0 +1,100 @@
1
+ import { PanelType } from '@atlaskit/adf-schema';
2
+ import { panelMessages as messages } from '@atlaskit/editor-common/messages';
3
+ import CrossCircleIcon from '@atlaskit/icon/core/cross-circle';
4
+ import CustomizeIcon from '@atlaskit/icon/core/customize';
5
+ import DiscoveryIcon from '@atlaskit/icon/core/discovery';
6
+ import InformationIcon from '@atlaskit/icon/core/information';
7
+ import SuccessIcon from '@atlaskit/icon/core/success';
8
+ import WarningIcon from '@atlaskit/icon/core/warning';
9
+ import { changePanelType } from '../editor-actions/actions';
10
+ const panelTitleAndIcon = {
11
+ [PanelType.INFO]: {
12
+ title: messages.info,
13
+ icon: InformationIcon({
14
+ label: 'info-icon',
15
+ color: "var(--ds-icon-information, #1D7AFC)"
16
+ })
17
+ },
18
+ [PanelType.NOTE]: {
19
+ title: messages.note,
20
+ icon: DiscoveryIcon({
21
+ label: 'note-icon',
22
+ color: "var(--ds-icon-discovery, #8270DB)"
23
+ })
24
+ },
25
+ [PanelType.SUCCESS]: {
26
+ title: messages.success,
27
+ icon: SuccessIcon({
28
+ label: 'success-icon',
29
+ color: "var(--ds-icon-success, #22A06B)"
30
+ })
31
+ },
32
+ [PanelType.WARNING]: {
33
+ title: messages.warning,
34
+ icon: WarningIcon({
35
+ label: 'warning-icon',
36
+ color: "var(--ds-icon-warning, #E56910)"
37
+ })
38
+ },
39
+ [PanelType.ERROR]: {
40
+ title: messages.error,
41
+ icon: CrossCircleIcon({
42
+ label: 'error-icon',
43
+ color: "var(--ds-icon-danger, #C9372C)"
44
+ })
45
+ },
46
+ [PanelType.CUSTOM]: {
47
+ title: messages.custom,
48
+ icon: CustomizeIcon({
49
+ label: 'custom-icon'
50
+ })
51
+ }
52
+ };
53
+ export const panelTypeDropdown = ({
54
+ activePanelType,
55
+ editorAnalyticsAPI,
56
+ formatMessage
57
+ }) => {
58
+ const dropdownOptions = [{
59
+ id: 'editor.panel.info',
60
+ icon: panelTitleAndIcon[PanelType.INFO].icon,
61
+ onClick: changePanelType(editorAnalyticsAPI)(PanelType.INFO),
62
+ selected: activePanelType === PanelType.INFO,
63
+ title: formatMessage(panelTitleAndIcon[PanelType.INFO].title)
64
+ }, {
65
+ id: 'editor.panel.note',
66
+ icon: panelTitleAndIcon[PanelType.NOTE].icon,
67
+ onClick: changePanelType(editorAnalyticsAPI)(PanelType.NOTE),
68
+ selected: activePanelType === PanelType.NOTE,
69
+ title: formatMessage(panelTitleAndIcon[PanelType.NOTE].title)
70
+ }, {
71
+ id: 'editor.panel.success',
72
+ icon: panelTitleAndIcon[PanelType.SUCCESS].icon,
73
+ onClick: changePanelType(editorAnalyticsAPI)(PanelType.SUCCESS),
74
+ selected: activePanelType === PanelType.SUCCESS,
75
+ title: formatMessage(panelTitleAndIcon[PanelType.SUCCESS].title)
76
+ }, {
77
+ id: 'editor.panel.warning',
78
+ icon: panelTitleAndIcon[PanelType.WARNING].icon,
79
+ onClick: changePanelType(editorAnalyticsAPI)(PanelType.WARNING),
80
+ selected: activePanelType === PanelType.WARNING,
81
+ title: formatMessage(panelTitleAndIcon[PanelType.WARNING].title)
82
+ }, {
83
+ id: 'editor.panel.error',
84
+ icon: panelTitleAndIcon[PanelType.ERROR].icon,
85
+ onClick: changePanelType(editorAnalyticsAPI)(PanelType.ERROR),
86
+ selected: activePanelType === PanelType.ERROR,
87
+ title: formatMessage(panelTitleAndIcon[PanelType.ERROR].title)
88
+ }];
89
+ const selectedPanelType = activePanelType || PanelType.INFO;
90
+ const selectedTitleAndIcon = panelTitleAndIcon[selectedPanelType];
91
+ return {
92
+ id: 'panel-type-dropdown',
93
+ testId: 'panel-type-dropdown-trigger',
94
+ type: 'dropdown',
95
+ options: dropdownOptions,
96
+ showSelected: true,
97
+ iconBefore: () => selectedTitleAndIcon.icon,
98
+ title: formatMessage(selectedTitleAndIcon.title)
99
+ };
100
+ };
@@ -24,6 +24,7 @@ import LegacyWarningIcon from '@atlaskit/icon/glyph/editor/warning';
24
24
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
25
25
  import { changePanelType, removePanel } from '../editor-actions/actions';
26
26
  import { findPanel } from '../pm-plugins/utils/utils';
27
+ import { panelTypeDropdown } from './panelTypeDropdown';
27
28
  export const panelIconMap = {
28
29
  [PanelType.INFO]: {
29
30
  shortName: ':info:',
@@ -51,8 +52,8 @@ export const panelIconMap = {
51
52
  }
52
53
  };
53
54
  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
55
- const items = [{
55
+ // TODO: ED-14403 - investigate why these titles are not getting translated for the tooltips
56
+ const items = editorExperiment('platform_editor_controls', 'control') ? [{
56
57
  id: 'editor.panel.info',
57
58
  type: 'button',
58
59
  icon: InformationIcon,
@@ -97,6 +98,12 @@ export const getToolbarItems = (formatMessage, panelNodeType, isCustomPanelEnabl
97
98
  selected: activePanelType === PanelType.ERROR,
98
99
  title: formatMessage(messages.error),
99
100
  tabIndex: null
101
+ }] : [panelTypeDropdown({
102
+ activePanelType,
103
+ editorAnalyticsAPI,
104
+ formatMessage
105
+ }), {
106
+ type: 'separator'
100
107
  }];
101
108
  if (isCustomPanelEnabled) {
102
109
  const changeColor = color => (state, dispatch) => {
@@ -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
@@ -0,0 +1,95 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import { PanelType } from '@atlaskit/adf-schema';
3
+ import { panelMessages as messages } from '@atlaskit/editor-common/messages';
4
+ import CrossCircleIcon from '@atlaskit/icon/core/cross-circle';
5
+ import CustomizeIcon from '@atlaskit/icon/core/customize';
6
+ import DiscoveryIcon from '@atlaskit/icon/core/discovery';
7
+ import InformationIcon from '@atlaskit/icon/core/information';
8
+ import SuccessIcon from '@atlaskit/icon/core/success';
9
+ import WarningIcon from '@atlaskit/icon/core/warning';
10
+ import { changePanelType } from '../editor-actions/actions';
11
+ var panelTitleAndIcon = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, PanelType.INFO, {
12
+ title: messages.info,
13
+ icon: InformationIcon({
14
+ label: 'info-icon',
15
+ color: "var(--ds-icon-information, #1D7AFC)"
16
+ })
17
+ }), PanelType.NOTE, {
18
+ title: messages.note,
19
+ icon: DiscoveryIcon({
20
+ label: 'note-icon',
21
+ color: "var(--ds-icon-discovery, #8270DB)"
22
+ })
23
+ }), PanelType.SUCCESS, {
24
+ title: messages.success,
25
+ icon: SuccessIcon({
26
+ label: 'success-icon',
27
+ color: "var(--ds-icon-success, #22A06B)"
28
+ })
29
+ }), PanelType.WARNING, {
30
+ title: messages.warning,
31
+ icon: WarningIcon({
32
+ label: 'warning-icon',
33
+ color: "var(--ds-icon-warning, #E56910)"
34
+ })
35
+ }), PanelType.ERROR, {
36
+ title: messages.error,
37
+ icon: CrossCircleIcon({
38
+ label: 'error-icon',
39
+ color: "var(--ds-icon-danger, #C9372C)"
40
+ })
41
+ }), PanelType.CUSTOM, {
42
+ title: messages.custom,
43
+ icon: CustomizeIcon({
44
+ label: 'custom-icon'
45
+ })
46
+ });
47
+ export var panelTypeDropdown = function panelTypeDropdown(_ref) {
48
+ var activePanelType = _ref.activePanelType,
49
+ editorAnalyticsAPI = _ref.editorAnalyticsAPI,
50
+ formatMessage = _ref.formatMessage;
51
+ var dropdownOptions = [{
52
+ id: 'editor.panel.info',
53
+ icon: panelTitleAndIcon[PanelType.INFO].icon,
54
+ onClick: changePanelType(editorAnalyticsAPI)(PanelType.INFO),
55
+ selected: activePanelType === PanelType.INFO,
56
+ title: formatMessage(panelTitleAndIcon[PanelType.INFO].title)
57
+ }, {
58
+ id: 'editor.panel.note',
59
+ icon: panelTitleAndIcon[PanelType.NOTE].icon,
60
+ onClick: changePanelType(editorAnalyticsAPI)(PanelType.NOTE),
61
+ selected: activePanelType === PanelType.NOTE,
62
+ title: formatMessage(panelTitleAndIcon[PanelType.NOTE].title)
63
+ }, {
64
+ id: 'editor.panel.success',
65
+ icon: panelTitleAndIcon[PanelType.SUCCESS].icon,
66
+ onClick: changePanelType(editorAnalyticsAPI)(PanelType.SUCCESS),
67
+ selected: activePanelType === PanelType.SUCCESS,
68
+ title: formatMessage(panelTitleAndIcon[PanelType.SUCCESS].title)
69
+ }, {
70
+ id: 'editor.panel.warning',
71
+ icon: panelTitleAndIcon[PanelType.WARNING].icon,
72
+ onClick: changePanelType(editorAnalyticsAPI)(PanelType.WARNING),
73
+ selected: activePanelType === PanelType.WARNING,
74
+ title: formatMessage(panelTitleAndIcon[PanelType.WARNING].title)
75
+ }, {
76
+ id: 'editor.panel.error',
77
+ icon: panelTitleAndIcon[PanelType.ERROR].icon,
78
+ onClick: changePanelType(editorAnalyticsAPI)(PanelType.ERROR),
79
+ selected: activePanelType === PanelType.ERROR,
80
+ title: formatMessage(panelTitleAndIcon[PanelType.ERROR].title)
81
+ }];
82
+ var selectedPanelType = activePanelType || PanelType.INFO;
83
+ var selectedTitleAndIcon = panelTitleAndIcon[selectedPanelType];
84
+ return {
85
+ id: 'panel-type-dropdown',
86
+ testId: 'panel-type-dropdown-trigger',
87
+ type: 'dropdown',
88
+ options: dropdownOptions,
89
+ showSelected: true,
90
+ iconBefore: function iconBefore() {
91
+ return selectedTitleAndIcon.icon;
92
+ },
93
+ title: formatMessage(selectedTitleAndIcon.title)
94
+ };
95
+ };
@@ -27,6 +27,7 @@ import LegacyWarningIcon from '@atlaskit/icon/glyph/editor/warning';
27
27
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
28
28
  import { changePanelType, removePanel } from '../editor-actions/actions';
29
29
  import { findPanel } from '../pm-plugins/utils/utils';
30
+ import { panelTypeDropdown } from './panelTypeDropdown';
30
31
  export var panelIconMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, PanelType.INFO, {
31
32
  shortName: ':info:',
32
33
  id: 'atlassian-info'
@@ -47,8 +48,8 @@ export var panelIconMap = _defineProperty(_defineProperty(_defineProperty(_defin
47
48
  id: 'atlassian-tip'
48
49
  });
49
50
  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
51
- var items = [{
51
+ // TODO: ED-14403 - investigate why these titles are not getting translated for the tooltips
52
+ var items = editorExperiment('platform_editor_controls', 'control') ? [{
52
53
  id: 'editor.panel.info',
53
54
  type: 'button',
54
55
  icon: InformationIcon,
@@ -93,6 +94,12 @@ export var getToolbarItems = function getToolbarItems(formatMessage, panelNodeTy
93
94
  selected: activePanelType === PanelType.ERROR,
94
95
  title: formatMessage(messages.error),
95
96
  tabIndex: null
97
+ }] : [panelTypeDropdown({
98
+ activePanelType: activePanelType,
99
+ editorAnalyticsAPI: editorAnalyticsAPI,
100
+ formatMessage: formatMessage
101
+ }), {
102
+ type: 'separator'
96
103
  }];
97
104
  if (isCustomPanelEnabled) {
98
105
  var changeColor = function changeColor(color) {
@@ -0,0 +1,10 @@
1
+ import type { IntlShape } from 'react-intl-next';
2
+ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
+ import type { Command, FloatingToolbarDropdown } from '@atlaskit/editor-common/types';
4
+ type Props = {
5
+ activePanelType?: string;
6
+ editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
7
+ formatMessage: IntlShape['formatMessage'];
8
+ };
9
+ export declare const panelTypeDropdown: ({ activePanelType, editorAnalyticsAPI, formatMessage, }: Props) => FloatingToolbarDropdown<Command>;
10
+ export {};
@@ -0,0 +1,10 @@
1
+ import type { IntlShape } from 'react-intl-next';
2
+ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
+ import type { Command, FloatingToolbarDropdown } from '@atlaskit/editor-common/types';
4
+ type Props = {
5
+ activePanelType?: string;
6
+ editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
7
+ formatMessage: IntlShape['formatMessage'];
8
+ };
9
+ export declare const panelTypeDropdown: ({ activePanelType, editorAnalyticsAPI, formatMessage, }: Props) => FloatingToolbarDropdown<Command>;
10
+ export {};
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.6",
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.2.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",
@@ -44,6 +44,7 @@
44
44
  "@atlaskit/platform-feature-flags": "^1.1.0",
45
45
  "@atlaskit/theme": "^18.0.0",
46
46
  "@atlaskit/tmp-editor-statsig": "^3.4.0",
47
+ "@atlaskit/tokens": "^4.3.0",
47
48
  "@babel/runtime": "^7.0.0",
48
49
  "uuid": "^3.1.0"
49
50
  },
@@ -94,6 +95,9 @@
94
95
  "platform-feature-flags": {
95
96
  "platform_editor_update_panel_icon_aria_label": {
96
97
  "type": "boolean"
98
+ },
99
+ "platform_editor_nbm_backspace_fixes": {
100
+ "type": "boolean"
97
101
  }
98
102
  },
99
103
  "stricter": {