@atlaskit/editor-plugin-text-formatting 2.3.2 → 2.4.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,23 @@
1
1
  # @atlaskit/editor-plugin-text-formatting
2
2
 
3
+ ## 2.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#173138](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/173138)
8
+ [`62d4e3ae11127`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/62d4e3ae11127) -
9
+ [ux] [ED-27997] Change text formatting state to only consider whole selections active for marks
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
15
+ ## 2.3.3
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies
20
+
3
21
  ## 2.3.2
4
22
 
5
23
  ### Patch Changes
@@ -8,7 +8,6 @@ var _analytics = require("@atlaskit/editor-common/analytics");
8
8
  var _keymaps = require("@atlaskit/editor-common/keymaps");
9
9
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
10
10
  var _keymap = require("@atlaskit/editor-prosemirror/keymap");
11
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
12
11
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
13
12
  var _commands = require("./commands");
14
13
  var _pluginKey = require("./plugin-key");
@@ -107,7 +106,7 @@ function keymapPlugin(schema, editorAnalyticsAPI) {
107
106
  props: {
108
107
  handleKeyDown: function handleKeyDown(view, event) {
109
108
  var keyboardEvent = (0, _keymaps.isCapsLockOnAndModifyKeyboardEvent)(event);
110
- var keymapList = (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_8') ? getEnabledKeylist(view) : list;
109
+ var keymapList = (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? getEnabledKeylist(view) : list;
111
110
  return (0, _keymap.keydownHandler)(keymapList)(view, keyboardEvent);
112
111
  }
113
112
  }
@@ -1,28 +1,32 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  var _typeof = require("@babel/runtime/helpers/typeof");
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.plugin = void 0;
9
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
8
10
  var _keymaps = require("@atlaskit/editor-common/keymaps");
9
11
  var _mark = require("@atlaskit/editor-common/mark");
10
12
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
11
13
  var _utils = require("@atlaskit/editor-common/utils");
12
14
  var _commands = require("@atlaskit/editor-prosemirror/commands");
15
+ var _model = require("@atlaskit/editor-prosemirror/model");
13
16
  var _state = require("@atlaskit/editor-prosemirror/state");
14
17
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
18
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
15
19
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
16
20
  var _textFormatting = _interopRequireWildcard(require("../editor-commands/text-formatting"));
17
21
  var commands = _textFormatting;
18
22
  var _pluginKey = require("./plugin-key");
19
23
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
20
- // TODO: ED-26962 - Ideally this should use the custom toggleMark function from @atlaskit/editor-common so we also disable the options when selecting inline nodes but it disables the marks when the selection is empty at this point in time which is undesirable
24
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
25
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
26
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } // TODO: ED-26962 - Ideally this should use the custom toggleMark function from @atlaskit/editor-common so we also disable the options when selecting inline nodes but it disables the marks when the selection is empty at this point in time which is undesirable
21
27
  // import { toggleMark } from '@atlaskit/editor-common/mark';
22
-
23
28
  // Ignored via go/ees005
24
29
  // eslint-disable-next-line import/no-namespace
25
-
26
30
  var isSelectionInlineCursor = function isSelectionInlineCursor(selection) {
27
31
  if (selection instanceof _state.NodeSelection) {
28
32
  return true;
@@ -34,12 +38,9 @@ var checkNodeSelection = function checkNodeSelection(mark, editorState, type) {
34
38
  if (isSelectionInlineCursor(selection)) {
35
39
  return false;
36
40
  }
37
- if (type !== null || type !== undefined) {
38
- return (0, _commands.toggleMark)(mark, {
39
- type: type
40
- })(editorState);
41
- }
42
- return (0, _commands.toggleMark)(mark)(editorState);
41
+ return (0, _commands.toggleMark)(mark, {
42
+ type: type
43
+ })(editorState);
43
44
  };
44
45
  var getTextFormattingState = function getTextFormattingState(editorState, editorAnalyticsAPI) {
45
46
  var _editorState$schema$m = editorState.schema.marks,
@@ -52,6 +53,49 @@ var getTextFormattingState = function getTextFormattingState(editorState, editor
52
53
  var state = {
53
54
  isInitialised: true
54
55
  };
56
+ var showOnlyCommonMarks = (0, _expValEquals.expValEquals)('platform_editor_controls', 'cohort', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_common_marks');
57
+ if (showOnlyCommonMarks) {
58
+ // Code marks will disable all other formatting options when they are included in a
59
+ // selection but (for now) we do not want to make it behave differently in regards to which
60
+ // toolbar items are highlighted on selection. We need to track code in selection seperately
61
+ // to ensure all other formatting options are disabled appropriately.
62
+ if (code) {
63
+ state.codeInSelection = (0, _mark.anyMarkActive)(editorState, code.create());
64
+ }
65
+ var marks = [[code, 'code'], [em, 'em'], [strike, 'strike'], [strong, 'strong'], [underline, 'underline'], [subsup === null || subsup === void 0 ? void 0 : subsup.create({
66
+ type: 'sub'
67
+ }), 'subscript'], [subsup === null || subsup === void 0 ? void 0 : subsup.create({
68
+ type: 'sup'
69
+ }), 'superscript']].filter(function (_ref) {
70
+ var _ref2 = (0, _slicedToArray2.default)(_ref, 1),
71
+ mark = _ref2[0];
72
+ return mark;
73
+ });
74
+ var marksToName = new Map(marks);
75
+ var activeMarks = (0, _mark.wholeSelectionHasMarks)(editorState, Array.from(marksToName.keys()));
76
+ var _iterator = _createForOfIteratorHelper(marks),
77
+ _step;
78
+ try {
79
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
80
+ var _step$value = (0, _slicedToArray2.default)(_step.value, 2),
81
+ mark = _step$value[0],
82
+ markName = _step$value[1];
83
+ var active = activeMarks.get(mark);
84
+ if (active !== undefined) {
85
+ state["".concat(markName, "Active")] = active;
86
+ }
87
+ state["".concat(markName, "Disabled")] =
88
+ // Disable when code is active, except for code itself which should not be disabled
89
+ // when code is in selection 😅
90
+ state.codeInSelection && markName !== 'code' ? true : !checkNodeSelection(mark instanceof _model.MarkType ? mark : mark.type, editorState);
91
+ }
92
+ } catch (err) {
93
+ _iterator.e(err);
94
+ } finally {
95
+ _iterator.f();
96
+ }
97
+ return state;
98
+ }
55
99
  if (code) {
56
100
  state.codeActive = (0, _mark.anyMarkActive)(editorState, code.create());
57
101
  state.codeDisabled = !checkNodeSelection(code, editorState);
@@ -76,8 +120,8 @@ var getTextFormattingState = function getTextFormattingState(editorState, editor
76
120
  type: 'sup'
77
121
  });
78
122
  state.subscriptActive = (0, _mark.anyMarkActive)(editorState, subMark);
79
- state.subscriptDisabled = state.codeActive ? true : !checkNodeSelection(subsup, editorState, 'sub');
80
123
  state.superscriptActive = (0, _mark.anyMarkActive)(editorState, supMark);
124
+ state.subscriptDisabled = state.codeActive ? true : !checkNodeSelection(subsup, editorState, 'sub');
81
125
  state.superscriptDisabled = state.codeActive ? true : !checkNodeSelection(subsup, editorState, 'sup');
82
126
  }
83
127
  if (underline) {
@@ -127,16 +127,16 @@ var FloatingToolbarTextFormat = function FloatingToolbarTextFormat(_ref) {
127
127
  var formattingIsPresent = textFormattingState.formattingIsPresent,
128
128
  formattingIconState = (0, _objectWithoutProperties2.default)(textFormattingState, _excluded);
129
129
  var hasMultiplePartsWithFormattingSelected;
130
- var commonActiveMarks = [];
131
- if ((0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_7')) {
130
+ var commonActiveMarks;
131
+ if ((0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
132
132
  var selection = editorView.state.selection;
133
133
  var from = selection.from,
134
134
  to = selection.to;
135
135
  var selectedContent = selection instanceof _state.TextSelection ? editorView.state.doc.slice(from, to).content.content.slice() : undefined;
136
- hasMultiplePartsWithFormattingSelected = (0, _formattingInSelectionUtils.hasMultiplePartsWithFormattingInSelection)({
136
+ hasMultiplePartsWithFormattingSelected = (0, _platformFeatureFlags.fg)('platform_editor_common_marks') ? false : (0, _formattingInSelectionUtils.hasMultiplePartsWithFormattingInSelection)({
137
137
  selectedContent: selectedContent
138
138
  });
139
- if ((0, _platformFeatureFlags.fg)('platform_editor_controls_patch_10')) {
139
+ if (!(0, _platformFeatureFlags.fg)('platform_editor_common_marks')) {
140
140
  commonActiveMarks = (0, _formattingInSelectionUtils.getCommonActiveMarks)({
141
141
  selectedContent: selectedContent
142
142
  });
@@ -149,8 +149,8 @@ var FloatingToolbarTextFormat = function FloatingToolbarTextFormat(_ref) {
149
149
  editorAnalyticsAPI: editorAnalyticsAPI,
150
150
  textFormattingState: formattingIconState,
151
151
  toolbarType: FloatingToolbarSettings.toolbarType,
152
- hasMultiplePartsWithFormattingSelected: (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_10') ? hasMultiplePartsWithFormattingSelected : undefined,
153
- commonActiveMarks: (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_10') ? commonActiveMarks : undefined
152
+ hasMultiplePartsWithFormattingSelected: (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? hasMultiplePartsWithFormattingSelected : undefined,
153
+ commonActiveMarks: (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? commonActiveMarks : undefined
154
154
  });
155
155
  var _useIconList = (0, _useIconList2.useIconList)({
156
156
  icons: defaultIcons,
@@ -59,7 +59,7 @@ var FormattingTextDropdownMenu = exports.FormattingTextDropdownMenu = /*#__PURE_
59
59
  var defaultIconName = (_items$0$items$2 = items[0].items[0]) === null || _items$0$items$2 === void 0 ? void 0 : _items$0$items$2.value.name;
60
60
  var iconBefore;
61
61
  var activeIconName = defaultIconName;
62
- if (hasMultiplePartsWithFormattingSelected && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_7')) {
62
+ if (hasMultiplePartsWithFormattingSelected && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
63
63
  iconBefore = defaultIcon;
64
64
  } else {
65
65
  iconBefore = activeItem ? activeItem === null || activeItem === void 0 ? void 0 : activeItem.elemBefore : defaultIcon;
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.hasMultiplePartsWithFormattingInSelection = exports.getCommonActiveMarks = void 0;
7
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
8
7
  var _types = require("./types");
9
8
  var isMarkInIconTypes = function isMarkInIconTypes(node) {
10
9
  return node.marks.some(function (mark) {
@@ -16,20 +15,17 @@ var hasMultiplePartsWithFormattingInSelection = exports.hasMultiplePartsWithForm
16
15
  if (!selectedContent) {
17
16
  return false;
18
17
  }
19
- if ((0, _platformFeatureFlags.fg)('platform_editor_controls_patch_8')) {
20
- // Check if there are multiple parts with formatting or if only one part has formatting and the rest have none
21
- var contentWithMarks = selectedContent.filter(function (child) {
22
- return isMarkInIconTypes(child);
23
- });
24
- var hasFormatting = contentWithMarks.length > 0;
25
- var allPartsHaveFormatting = contentWithMarks.length === selectedContent.length;
26
- return hasFormatting && (!allPartsHaveFormatting || contentWithMarks.length > 1);
27
- }
28
- var marks = selectedContent.map(function (child) {
29
- return isMarkInIconTypes(child) ? child.marks : undefined;
30
- }).filter(Boolean);
31
- return marks.length > 1;
18
+
19
+ // Check if there are multiple parts with formatting or if only one part has formatting and the rest have none
20
+ var contentWithMarks = selectedContent.filter(function (child) {
21
+ return isMarkInIconTypes(child);
22
+ });
23
+ var hasFormatting = contentWithMarks.length > 0;
24
+ var allPartsHaveFormatting = contentWithMarks.length === selectedContent.length;
25
+ return hasFormatting && (!allPartsHaveFormatting || contentWithMarks.length > 1);
32
26
  };
27
+
28
+ // Clean up when platform_editor_common_marks is removed
33
29
  var getCommonActiveMarks = exports.getCommonActiveMarks = function getCommonActiveMarks(_ref2) {
34
30
  var selectedContent = _ref2.selectedContent;
35
31
  if (!selectedContent || selectedContent.length === 0) {
@@ -40,12 +36,10 @@ var getCommonActiveMarks = exports.getCommonActiveMarks = function getCommonActi
40
36
  var _child$text;
41
37
  return ((_child$text = child.text) === null || _child$text === void 0 ? void 0 : _child$text.trim()) !== '';
42
38
  });
43
-
44
39
  // find the active mark type in first part
45
40
  var firstPartMarks = selectedContent[0].marks.map(function (mark) {
46
41
  return mark.type.name;
47
42
  });
48
-
49
43
  // check if all other parts have the same mark type as the first part and return the common mark types
50
44
  var commonMarkTypes = firstPartMarks.filter(function (mark) {
51
45
  return filteredSelectedContent.every(function (child) {
@@ -20,7 +20,7 @@ var useIconList = exports.useIconList = function useIconList(_ref) {
20
20
  }
21
21
  if (
22
22
  // eslint-disable-next-line @atlaskit/platform/no-preconditioning
23
- shouldUnselect && icon.isActive && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_7') && !(0, _platformFeatureFlags.fg)('platform_editor_controls_patch_10')) {
23
+ shouldUnselect && icon.isActive && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && !(0, _platformFeatureFlags.fg)('platform_editor_controls_patch_10')) {
24
24
  icon.isActive = false;
25
25
  }
26
26
  var isIconSingleButton = iconTypeList.includes(icon.iconMark);
@@ -50,13 +50,13 @@ var SingleToolbarButtons = exports.SingleToolbarButtons = /*#__PURE__*/_react.de
50
50
  onClick: onClick(item.command),
51
51
  selected:
52
52
  // eslint-disable-next-line @atlaskit/platform/no-preconditioning
53
- hasMultiplePartsWithFormattingSelected && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_7') && !(0, _platformFeatureFlags.fg)('platform_editor_controls_patch_10') ? false : item.isActive,
53
+ hasMultiplePartsWithFormattingSelected && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && !(0, _platformFeatureFlags.fg)('platform_editor_controls_patch_10') ? false : item.isActive,
54
54
  disabled: item.isDisabled,
55
55
  title: item.tooltipElement,
56
56
  iconBefore: item.iconElement,
57
57
  "aria-pressed":
58
58
  // eslint-disable-next-line @atlaskit/platform/no-preconditioning
59
- hasMultiplePartsWithFormattingSelected && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_7') && !(0, _platformFeatureFlags.fg)('platform_editor_controls_patch_10') ? false : item.isActive,
59
+ hasMultiplePartsWithFormattingSelected && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && !(0, _platformFeatureFlags.fg)('platform_editor_controls_patch_10') ? false : item.isActive,
60
60
  "aria-label": (_item$ariaLabel = item['aria-label']) !== null && _item$ariaLabel !== void 0 ? _item$ariaLabel : String(item.content),
61
61
  "aria-keyshortcuts": item['aria-keyshortcuts']
62
62
  });
@@ -2,7 +2,6 @@ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
2
  import { bindKeymapWithEditorCommand, isCapsLockOnAndModifyKeyboardEvent, toggleBold, toggleCode, toggleItalic, toggleStrikethrough, toggleSubscript, toggleSuperscript, toggleUnderline } from '@atlaskit/editor-common/keymaps';
3
3
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
4
  import { keydownHandler } from '@atlaskit/editor-prosemirror/keymap';
5
- import { fg } from '@atlaskit/platform-feature-flags';
6
5
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
7
6
  import { toggleCodeWithAnalytics, toggleEmWithAnalytics, toggleStrikeWithAnalytics, toggleStrongWithAnalytics, toggleSubscriptWithAnalytics, toggleSuperscriptWithAnalytics, toggleUnderlineWithAnalytics } from './commands';
8
7
  import { pluginKey } from './plugin-key';
@@ -101,7 +100,7 @@ export default function keymapPlugin(schema, editorAnalyticsAPI) {
101
100
  props: {
102
101
  handleKeyDown(view, event) {
103
102
  const keyboardEvent = isCapsLockOnAndModifyKeyboardEvent(event);
104
- const keymapList = editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_8') ? getEnabledKeylist(view) : list;
103
+ const keymapList = editorExperiment('platform_editor_controls', 'variant1') ? getEnabledKeylist(view) : list;
105
104
  return keydownHandler(keymapList)(view, keyboardEvent);
106
105
  }
107
106
  }
@@ -2,12 +2,14 @@
2
2
  // import { toggleMark } from '@atlaskit/editor-common/mark';
3
3
 
4
4
  import { moveLeft as keymapMoveLeft, moveRight as keymapMoveRight } from '@atlaskit/editor-common/keymaps';
5
- import { anyMarkActive } from '@atlaskit/editor-common/mark';
5
+ import { anyMarkActive, wholeSelectionHasMarks } from '@atlaskit/editor-common/mark';
6
6
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
7
7
  import { shallowEqual } from '@atlaskit/editor-common/utils';
8
8
  import { toggleMark } from '@atlaskit/editor-prosemirror/commands';
9
+ import { MarkType } from '@atlaskit/editor-prosemirror/model';
9
10
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
10
11
  import { fg } from '@atlaskit/platform-feature-flags';
12
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
11
13
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
12
14
  import { createInlineCodeFromTextInputWithAnalytics } from '../editor-commands/text-formatting';
13
15
  // Ignored via go/ees005
@@ -25,12 +27,9 @@ const checkNodeSelection = (mark, editorState, type) => {
25
27
  if (isSelectionInlineCursor(selection)) {
26
28
  return false;
27
29
  }
28
- if (type !== null || type !== undefined) {
29
- return toggleMark(mark, {
30
- type: type
31
- })(editorState);
32
- }
33
- return toggleMark(mark)(editorState);
30
+ return toggleMark(mark, {
31
+ type: type
32
+ })(editorState);
34
33
  };
35
34
  const getTextFormattingState = (editorState, editorAnalyticsAPI) => {
36
35
  const {
@@ -44,6 +43,34 @@ const getTextFormattingState = (editorState, editorAnalyticsAPI) => {
44
43
  const state = {
45
44
  isInitialised: true
46
45
  };
46
+ const showOnlyCommonMarks = expValEquals('platform_editor_controls', 'cohort', 'variant1') && fg('platform_editor_common_marks');
47
+ if (showOnlyCommonMarks) {
48
+ // Code marks will disable all other formatting options when they are included in a
49
+ // selection but (for now) we do not want to make it behave differently in regards to which
50
+ // toolbar items are highlighted on selection. We need to track code in selection seperately
51
+ // to ensure all other formatting options are disabled appropriately.
52
+ if (code) {
53
+ state.codeInSelection = anyMarkActive(editorState, code.create());
54
+ }
55
+ const marks = [[code, 'code'], [em, 'em'], [strike, 'strike'], [strong, 'strong'], [underline, 'underline'], [subsup === null || subsup === void 0 ? void 0 : subsup.create({
56
+ type: 'sub'
57
+ }), 'subscript'], [subsup === null || subsup === void 0 ? void 0 : subsup.create({
58
+ type: 'sup'
59
+ }), 'superscript']].filter(([mark]) => mark);
60
+ const marksToName = new Map(marks);
61
+ const activeMarks = wholeSelectionHasMarks(editorState, Array.from(marksToName.keys()));
62
+ for (const [mark, markName] of marks) {
63
+ const active = activeMarks.get(mark);
64
+ if (active !== undefined) {
65
+ state[`${markName}Active`] = active;
66
+ }
67
+ state[`${markName}Disabled`] =
68
+ // Disable when code is active, except for code itself which should not be disabled
69
+ // when code is in selection 😅
70
+ state.codeInSelection && markName !== 'code' ? true : !checkNodeSelection(mark instanceof MarkType ? mark : mark.type, editorState);
71
+ }
72
+ return state;
73
+ }
47
74
  if (code) {
48
75
  state.codeActive = anyMarkActive(editorState, code.create());
49
76
  state.codeDisabled = !checkNodeSelection(code, editorState);
@@ -68,8 +95,8 @@ const getTextFormattingState = (editorState, editorAnalyticsAPI) => {
68
95
  type: 'sup'
69
96
  });
70
97
  state.subscriptActive = anyMarkActive(editorState, subMark);
71
- state.subscriptDisabled = state.codeActive ? true : !checkNodeSelection(subsup, editorState, 'sub');
72
98
  state.superscriptActive = anyMarkActive(editorState, supMark);
99
+ state.subscriptDisabled = state.codeActive ? true : !checkNodeSelection(subsup, editorState, 'sub');
73
100
  state.superscriptDisabled = state.codeActive ? true : !checkNodeSelection(subsup, editorState, 'sup');
74
101
  }
75
102
  if (underline) {
@@ -121,8 +121,8 @@ const FloatingToolbarTextFormat = ({
121
121
  ...formattingIconState
122
122
  } = textFormattingState;
123
123
  let hasMultiplePartsWithFormattingSelected;
124
- let commonActiveMarks = [];
125
- if (editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_7')) {
124
+ let commonActiveMarks;
125
+ if (editorExperiment('platform_editor_controls', 'variant1')) {
126
126
  const {
127
127
  selection
128
128
  } = editorView.state;
@@ -131,10 +131,10 @@ const FloatingToolbarTextFormat = ({
131
131
  to
132
132
  } = selection;
133
133
  const selectedContent = selection instanceof TextSelection ? editorView.state.doc.slice(from, to).content.content.slice() : undefined;
134
- hasMultiplePartsWithFormattingSelected = hasMultiplePartsWithFormattingInSelection({
134
+ hasMultiplePartsWithFormattingSelected = fg('platform_editor_common_marks') ? false : hasMultiplePartsWithFormattingInSelection({
135
135
  selectedContent
136
136
  });
137
- if (fg('platform_editor_controls_patch_10')) {
137
+ if (!fg('platform_editor_common_marks')) {
138
138
  commonActiveMarks = getCommonActiveMarks({
139
139
  selectedContent
140
140
  });
@@ -147,8 +147,8 @@ const FloatingToolbarTextFormat = ({
147
147
  editorAnalyticsAPI,
148
148
  textFormattingState: formattingIconState,
149
149
  toolbarType: FloatingToolbarSettings.toolbarType,
150
- hasMultiplePartsWithFormattingSelected: editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_10') ? hasMultiplePartsWithFormattingSelected : undefined,
151
- commonActiveMarks: editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_10') ? commonActiveMarks : undefined
150
+ hasMultiplePartsWithFormattingSelected: editorExperiment('platform_editor_controls', 'variant1') ? hasMultiplePartsWithFormattingSelected : undefined,
151
+ commonActiveMarks: editorExperiment('platform_editor_controls', 'variant1') ? commonActiveMarks : undefined
152
152
  });
153
153
  const {
154
154
  dropdownItems,
@@ -41,7 +41,7 @@ export const FormattingTextDropdownMenu = /*#__PURE__*/React.memo(({
41
41
  const defaultIconName = (_items$0$items$2 = items[0].items[0]) === null || _items$0$items$2 === void 0 ? void 0 : _items$0$items$2.value.name;
42
42
  let iconBefore;
43
43
  let activeIconName = defaultIconName;
44
- if (hasMultiplePartsWithFormattingSelected && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_7')) {
44
+ if (hasMultiplePartsWithFormattingSelected && editorExperiment('platform_editor_controls', 'variant1')) {
45
45
  iconBefore = defaultIcon;
46
46
  } else {
47
47
  iconBefore = activeItem ? activeItem === null || activeItem === void 0 ? void 0 : activeItem.elemBefore : defaultIcon;
@@ -1,4 +1,3 @@
1
- import { fg } from '@atlaskit/platform-feature-flags';
2
1
  import { IconTypes } from './types';
3
2
  const isMarkInIconTypes = node => node.marks.some(mark => Object.values(IconTypes).includes(mark.type.name));
4
3
  export const hasMultiplePartsWithFormattingInSelection = ({
@@ -7,16 +6,15 @@ export const hasMultiplePartsWithFormattingInSelection = ({
7
6
  if (!selectedContent) {
8
7
  return false;
9
8
  }
10
- if (fg('platform_editor_controls_patch_8')) {
11
- // Check if there are multiple parts with formatting or if only one part has formatting and the rest have none
12
- const contentWithMarks = selectedContent.filter(child => isMarkInIconTypes(child));
13
- const hasFormatting = contentWithMarks.length > 0;
14
- const allPartsHaveFormatting = contentWithMarks.length === selectedContent.length;
15
- return hasFormatting && (!allPartsHaveFormatting || contentWithMarks.length > 1);
16
- }
17
- const marks = selectedContent.map(child => isMarkInIconTypes(child) ? child.marks : undefined).filter(Boolean);
18
- return marks.length > 1;
9
+
10
+ // Check if there are multiple parts with formatting or if only one part has formatting and the rest have none
11
+ const contentWithMarks = selectedContent.filter(child => isMarkInIconTypes(child));
12
+ const hasFormatting = contentWithMarks.length > 0;
13
+ const allPartsHaveFormatting = contentWithMarks.length === selectedContent.length;
14
+ return hasFormatting && (!allPartsHaveFormatting || contentWithMarks.length > 1);
19
15
  };
16
+
17
+ // Clean up when platform_editor_common_marks is removed
20
18
  export const getCommonActiveMarks = ({
21
19
  selectedContent
22
20
  }) => {
@@ -28,10 +26,8 @@ export const getCommonActiveMarks = ({
28
26
  var _child$text;
29
27
  return ((_child$text = child.text) === null || _child$text === void 0 ? void 0 : _child$text.trim()) !== '';
30
28
  });
31
-
32
29
  // find the active mark type in first part
33
30
  const firstPartMarks = selectedContent[0].marks.map(mark => mark.type.name);
34
-
35
31
  // check if all other parts have the same mark type as the first part and return the common mark types
36
32
  const commonMarkTypes = firstPartMarks.filter(mark => filteredSelectedContent.every(child => child.marks.some(m => m.type.name === mark)));
37
33
  return commonMarkTypes;
@@ -13,7 +13,7 @@ export const useIconList = ({
13
13
  }
14
14
  if (
15
15
  // eslint-disable-next-line @atlaskit/platform/no-preconditioning
16
- shouldUnselect && icon.isActive && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_7') && !fg('platform_editor_controls_patch_10')) {
16
+ shouldUnselect && icon.isActive && editorExperiment('platform_editor_controls', 'variant1') && !fg('platform_editor_controls_patch_10')) {
17
17
  icon.isActive = false;
18
18
  }
19
19
  const isIconSingleButton = iconTypeList.includes(icon.iconMark);
@@ -42,13 +42,13 @@ export const SingleToolbarButtons = /*#__PURE__*/React.memo(({
42
42
  onClick: onClick(item.command),
43
43
  selected:
44
44
  // eslint-disable-next-line @atlaskit/platform/no-preconditioning
45
- hasMultiplePartsWithFormattingSelected && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_7') && !fg('platform_editor_controls_patch_10') ? false : item.isActive,
45
+ hasMultiplePartsWithFormattingSelected && editorExperiment('platform_editor_controls', 'variant1') && !fg('platform_editor_controls_patch_10') ? false : item.isActive,
46
46
  disabled: item.isDisabled,
47
47
  title: item.tooltipElement,
48
48
  iconBefore: item.iconElement,
49
49
  "aria-pressed":
50
50
  // eslint-disable-next-line @atlaskit/platform/no-preconditioning
51
- hasMultiplePartsWithFormattingSelected && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_7') && !fg('platform_editor_controls_patch_10') ? false : item.isActive,
51
+ hasMultiplePartsWithFormattingSelected && editorExperiment('platform_editor_controls', 'variant1') && !fg('platform_editor_controls_patch_10') ? false : item.isActive,
52
52
  "aria-label": (_item$ariaLabel = item['aria-label']) !== null && _item$ariaLabel !== void 0 ? _item$ariaLabel : String(item.content),
53
53
  "aria-keyshortcuts": item['aria-keyshortcuts']
54
54
  });
@@ -2,7 +2,6 @@ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
2
  import { bindKeymapWithEditorCommand, isCapsLockOnAndModifyKeyboardEvent, toggleBold, toggleCode, toggleItalic, toggleStrikethrough, toggleSubscript, toggleSuperscript, toggleUnderline } from '@atlaskit/editor-common/keymaps';
3
3
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
4
  import { keydownHandler } from '@atlaskit/editor-prosemirror/keymap';
5
- import { fg } from '@atlaskit/platform-feature-flags';
6
5
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
7
6
  import { toggleCodeWithAnalytics, toggleEmWithAnalytics, toggleStrikeWithAnalytics, toggleStrongWithAnalytics, toggleSubscriptWithAnalytics, toggleSuperscriptWithAnalytics, toggleUnderlineWithAnalytics } from './commands';
8
7
  import { pluginKey } from './plugin-key';
@@ -101,7 +100,7 @@ export default function keymapPlugin(schema, editorAnalyticsAPI) {
101
100
  props: {
102
101
  handleKeyDown: function handleKeyDown(view, event) {
103
102
  var keyboardEvent = isCapsLockOnAndModifyKeyboardEvent(event);
104
- var keymapList = editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_8') ? getEnabledKeylist(view) : list;
103
+ var keymapList = editorExperiment('platform_editor_controls', 'variant1') ? getEnabledKeylist(view) : list;
105
104
  return keydownHandler(keymapList)(view, keyboardEvent);
106
105
  }
107
106
  }
@@ -1,13 +1,19 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
3
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
4
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
1
5
  // TODO: ED-26962 - Ideally this should use the custom toggleMark function from @atlaskit/editor-common so we also disable the options when selecting inline nodes but it disables the marks when the selection is empty at this point in time which is undesirable
2
6
  // import { toggleMark } from '@atlaskit/editor-common/mark';
3
7
 
4
8
  import { moveLeft as keymapMoveLeft, moveRight as keymapMoveRight } from '@atlaskit/editor-common/keymaps';
5
- import { anyMarkActive } from '@atlaskit/editor-common/mark';
9
+ import { anyMarkActive, wholeSelectionHasMarks } from '@atlaskit/editor-common/mark';
6
10
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
7
11
  import { shallowEqual } from '@atlaskit/editor-common/utils';
8
12
  import { toggleMark } from '@atlaskit/editor-prosemirror/commands';
13
+ import { MarkType } from '@atlaskit/editor-prosemirror/model';
9
14
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
10
15
  import { fg } from '@atlaskit/platform-feature-flags';
16
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
11
17
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
12
18
  import { createInlineCodeFromTextInputWithAnalytics } from '../editor-commands/text-formatting';
13
19
  // Ignored via go/ees005
@@ -25,12 +31,9 @@ var checkNodeSelection = function checkNodeSelection(mark, editorState, type) {
25
31
  if (isSelectionInlineCursor(selection)) {
26
32
  return false;
27
33
  }
28
- if (type !== null || type !== undefined) {
29
- return toggleMark(mark, {
30
- type: type
31
- })(editorState);
32
- }
33
- return toggleMark(mark)(editorState);
34
+ return toggleMark(mark, {
35
+ type: type
36
+ })(editorState);
34
37
  };
35
38
  var getTextFormattingState = function getTextFormattingState(editorState, editorAnalyticsAPI) {
36
39
  var _editorState$schema$m = editorState.schema.marks,
@@ -43,6 +46,49 @@ var getTextFormattingState = function getTextFormattingState(editorState, editor
43
46
  var state = {
44
47
  isInitialised: true
45
48
  };
49
+ var showOnlyCommonMarks = expValEquals('platform_editor_controls', 'cohort', 'variant1') && fg('platform_editor_common_marks');
50
+ if (showOnlyCommonMarks) {
51
+ // Code marks will disable all other formatting options when they are included in a
52
+ // selection but (for now) we do not want to make it behave differently in regards to which
53
+ // toolbar items are highlighted on selection. We need to track code in selection seperately
54
+ // to ensure all other formatting options are disabled appropriately.
55
+ if (code) {
56
+ state.codeInSelection = anyMarkActive(editorState, code.create());
57
+ }
58
+ var marks = [[code, 'code'], [em, 'em'], [strike, 'strike'], [strong, 'strong'], [underline, 'underline'], [subsup === null || subsup === void 0 ? void 0 : subsup.create({
59
+ type: 'sub'
60
+ }), 'subscript'], [subsup === null || subsup === void 0 ? void 0 : subsup.create({
61
+ type: 'sup'
62
+ }), 'superscript']].filter(function (_ref) {
63
+ var _ref2 = _slicedToArray(_ref, 1),
64
+ mark = _ref2[0];
65
+ return mark;
66
+ });
67
+ var marksToName = new Map(marks);
68
+ var activeMarks = wholeSelectionHasMarks(editorState, Array.from(marksToName.keys()));
69
+ var _iterator = _createForOfIteratorHelper(marks),
70
+ _step;
71
+ try {
72
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
73
+ var _step$value = _slicedToArray(_step.value, 2),
74
+ mark = _step$value[0],
75
+ markName = _step$value[1];
76
+ var active = activeMarks.get(mark);
77
+ if (active !== undefined) {
78
+ state["".concat(markName, "Active")] = active;
79
+ }
80
+ state["".concat(markName, "Disabled")] =
81
+ // Disable when code is active, except for code itself which should not be disabled
82
+ // when code is in selection 😅
83
+ state.codeInSelection && markName !== 'code' ? true : !checkNodeSelection(mark instanceof MarkType ? mark : mark.type, editorState);
84
+ }
85
+ } catch (err) {
86
+ _iterator.e(err);
87
+ } finally {
88
+ _iterator.f();
89
+ }
90
+ return state;
91
+ }
46
92
  if (code) {
47
93
  state.codeActive = anyMarkActive(editorState, code.create());
48
94
  state.codeDisabled = !checkNodeSelection(code, editorState);
@@ -67,8 +113,8 @@ var getTextFormattingState = function getTextFormattingState(editorState, editor
67
113
  type: 'sup'
68
114
  });
69
115
  state.subscriptActive = anyMarkActive(editorState, subMark);
70
- state.subscriptDisabled = state.codeActive ? true : !checkNodeSelection(subsup, editorState, 'sub');
71
116
  state.superscriptActive = anyMarkActive(editorState, supMark);
117
+ state.subscriptDisabled = state.codeActive ? true : !checkNodeSelection(subsup, editorState, 'sub');
72
118
  state.superscriptDisabled = state.codeActive ? true : !checkNodeSelection(subsup, editorState, 'sup');
73
119
  }
74
120
  if (underline) {
@@ -119,16 +119,16 @@ var FloatingToolbarTextFormat = function FloatingToolbarTextFormat(_ref) {
119
119
  var formattingIsPresent = textFormattingState.formattingIsPresent,
120
120
  formattingIconState = _objectWithoutProperties(textFormattingState, _excluded);
121
121
  var hasMultiplePartsWithFormattingSelected;
122
- var commonActiveMarks = [];
123
- if (editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_7')) {
122
+ var commonActiveMarks;
123
+ if (editorExperiment('platform_editor_controls', 'variant1')) {
124
124
  var selection = editorView.state.selection;
125
125
  var from = selection.from,
126
126
  to = selection.to;
127
127
  var selectedContent = selection instanceof TextSelection ? editorView.state.doc.slice(from, to).content.content.slice() : undefined;
128
- hasMultiplePartsWithFormattingSelected = hasMultiplePartsWithFormattingInSelection({
128
+ hasMultiplePartsWithFormattingSelected = fg('platform_editor_common_marks') ? false : hasMultiplePartsWithFormattingInSelection({
129
129
  selectedContent: selectedContent
130
130
  });
131
- if (fg('platform_editor_controls_patch_10')) {
131
+ if (!fg('platform_editor_common_marks')) {
132
132
  commonActiveMarks = getCommonActiveMarks({
133
133
  selectedContent: selectedContent
134
134
  });
@@ -141,8 +141,8 @@ var FloatingToolbarTextFormat = function FloatingToolbarTextFormat(_ref) {
141
141
  editorAnalyticsAPI: editorAnalyticsAPI,
142
142
  textFormattingState: formattingIconState,
143
143
  toolbarType: FloatingToolbarSettings.toolbarType,
144
- hasMultiplePartsWithFormattingSelected: editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_10') ? hasMultiplePartsWithFormattingSelected : undefined,
145
- commonActiveMarks: editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_10') ? commonActiveMarks : undefined
144
+ hasMultiplePartsWithFormattingSelected: editorExperiment('platform_editor_controls', 'variant1') ? hasMultiplePartsWithFormattingSelected : undefined,
145
+ commonActiveMarks: editorExperiment('platform_editor_controls', 'variant1') ? commonActiveMarks : undefined
146
146
  });
147
147
  var _useIconList = useIconList({
148
148
  icons: defaultIcons,
@@ -50,7 +50,7 @@ export var FormattingTextDropdownMenu = /*#__PURE__*/React.memo(function (_ref)
50
50
  var defaultIconName = (_items$0$items$2 = items[0].items[0]) === null || _items$0$items$2 === void 0 ? void 0 : _items$0$items$2.value.name;
51
51
  var iconBefore;
52
52
  var activeIconName = defaultIconName;
53
- if (hasMultiplePartsWithFormattingSelected && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_7')) {
53
+ if (hasMultiplePartsWithFormattingSelected && editorExperiment('platform_editor_controls', 'variant1')) {
54
54
  iconBefore = defaultIcon;
55
55
  } else {
56
56
  iconBefore = activeItem ? activeItem === null || activeItem === void 0 ? void 0 : activeItem.elemBefore : defaultIcon;
@@ -1,4 +1,3 @@
1
- import { fg } from '@atlaskit/platform-feature-flags';
2
1
  import { IconTypes } from './types';
3
2
  var isMarkInIconTypes = function isMarkInIconTypes(node) {
4
3
  return node.marks.some(function (mark) {
@@ -10,20 +9,17 @@ export var hasMultiplePartsWithFormattingInSelection = function hasMultipleParts
10
9
  if (!selectedContent) {
11
10
  return false;
12
11
  }
13
- if (fg('platform_editor_controls_patch_8')) {
14
- // Check if there are multiple parts with formatting or if only one part has formatting and the rest have none
15
- var contentWithMarks = selectedContent.filter(function (child) {
16
- return isMarkInIconTypes(child);
17
- });
18
- var hasFormatting = contentWithMarks.length > 0;
19
- var allPartsHaveFormatting = contentWithMarks.length === selectedContent.length;
20
- return hasFormatting && (!allPartsHaveFormatting || contentWithMarks.length > 1);
21
- }
22
- var marks = selectedContent.map(function (child) {
23
- return isMarkInIconTypes(child) ? child.marks : undefined;
24
- }).filter(Boolean);
25
- return marks.length > 1;
12
+
13
+ // Check if there are multiple parts with formatting or if only one part has formatting and the rest have none
14
+ var contentWithMarks = selectedContent.filter(function (child) {
15
+ return isMarkInIconTypes(child);
16
+ });
17
+ var hasFormatting = contentWithMarks.length > 0;
18
+ var allPartsHaveFormatting = contentWithMarks.length === selectedContent.length;
19
+ return hasFormatting && (!allPartsHaveFormatting || contentWithMarks.length > 1);
26
20
  };
21
+
22
+ // Clean up when platform_editor_common_marks is removed
27
23
  export var getCommonActiveMarks = function getCommonActiveMarks(_ref2) {
28
24
  var selectedContent = _ref2.selectedContent;
29
25
  if (!selectedContent || selectedContent.length === 0) {
@@ -34,12 +30,10 @@ export var getCommonActiveMarks = function getCommonActiveMarks(_ref2) {
34
30
  var _child$text;
35
31
  return ((_child$text = child.text) === null || _child$text === void 0 ? void 0 : _child$text.trim()) !== '';
36
32
  });
37
-
38
33
  // find the active mark type in first part
39
34
  var firstPartMarks = selectedContent[0].marks.map(function (mark) {
40
35
  return mark.type.name;
41
36
  });
42
-
43
37
  // check if all other parts have the same mark type as the first part and return the common mark types
44
38
  var commonMarkTypes = firstPartMarks.filter(function (mark) {
45
39
  return filteredSelectedContent.every(function (child) {
@@ -13,7 +13,7 @@ export var useIconList = function useIconList(_ref) {
13
13
  }
14
14
  if (
15
15
  // eslint-disable-next-line @atlaskit/platform/no-preconditioning
16
- shouldUnselect && icon.isActive && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_7') && !fg('platform_editor_controls_patch_10')) {
16
+ shouldUnselect && icon.isActive && editorExperiment('platform_editor_controls', 'variant1') && !fg('platform_editor_controls_patch_10')) {
17
17
  icon.isActive = false;
18
18
  }
19
19
  var isIconSingleButton = iconTypeList.includes(icon.iconMark);
@@ -41,13 +41,13 @@ export var SingleToolbarButtons = /*#__PURE__*/React.memo(function (_ref) {
41
41
  onClick: onClick(item.command),
42
42
  selected:
43
43
  // eslint-disable-next-line @atlaskit/platform/no-preconditioning
44
- hasMultiplePartsWithFormattingSelected && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_7') && !fg('platform_editor_controls_patch_10') ? false : item.isActive,
44
+ hasMultiplePartsWithFormattingSelected && editorExperiment('platform_editor_controls', 'variant1') && !fg('platform_editor_controls_patch_10') ? false : item.isActive,
45
45
  disabled: item.isDisabled,
46
46
  title: item.tooltipElement,
47
47
  iconBefore: item.iconElement,
48
48
  "aria-pressed":
49
49
  // eslint-disable-next-line @atlaskit/platform/no-preconditioning
50
- hasMultiplePartsWithFormattingSelected && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_7') && !fg('platform_editor_controls_patch_10') ? false : item.isActive,
50
+ hasMultiplePartsWithFormattingSelected && editorExperiment('platform_editor_controls', 'variant1') && !fg('platform_editor_controls_patch_10') ? false : item.isActive,
51
51
  "aria-label": (_item$ariaLabel = item['aria-label']) !== null && _item$ariaLabel !== void 0 ? _item$ariaLabel : String(item.content),
52
52
  "aria-keyshortcuts": item['aria-keyshortcuts']
53
53
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-text-formatting",
3
- "version": "2.3.2",
3
+ "version": "2.4.0",
4
4
  "description": "Text-formatting plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@atlaskit/adf-schema": "^47.6.0",
37
- "@atlaskit/editor-common": "^107.0.0",
37
+ "@atlaskit/editor-common": "^107.1.0",
38
38
  "@atlaskit/editor-plugin-analytics": "^2.3.0",
39
39
  "@atlaskit/editor-plugin-base": "^3.0.0",
40
40
  "@atlaskit/editor-plugin-primary-toolbar": "^3.2.0",
@@ -45,8 +45,8 @@
45
45
  "@atlaskit/icon": "^27.0.0",
46
46
  "@atlaskit/platform-feature-flags": "^1.1.0",
47
47
  "@atlaskit/prosemirror-input-rules": "^3.3.0",
48
- "@atlaskit/tmp-editor-statsig": "^7.1.0",
49
- "@atlaskit/tokens": "^5.2.0",
48
+ "@atlaskit/tmp-editor-statsig": "^8.0.0",
49
+ "@atlaskit/tokens": "^5.4.0",
50
50
  "@babel/runtime": "^7.0.0",
51
51
  "@emotion/react": "^11.7.1",
52
52
  "react-intl-next": "npm:react-intl@^5.18.1"
@@ -107,9 +107,6 @@
107
107
  "platform_editor_resolve_marks": {
108
108
  "type": "boolean"
109
109
  },
110
- "platform_editor_controls_patch_8": {
111
- "type": "boolean"
112
- },
113
110
  "platform_editor_controls_patch_9": {
114
111
  "type": "boolean"
115
112
  },
@@ -128,7 +125,7 @@
128
125
  "platform_editor_use_preferences_plugin": {
129
126
  "type": "boolean"
130
127
  },
131
- "platform_editor_controls_patch_7": {
128
+ "platform_editor_common_marks": {
132
129
  "type": "boolean"
133
130
  }
134
131
  }