@atlaskit/editor-plugin-selection-toolbar 1.3.2 → 1.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-selection-toolbar
2
2
 
3
+ ## 1.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#172933](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/172933)
8
+ [`8323af2381d00`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8323af2381d00) -
9
+ Adds optional pluginName to the Selection group
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
15
+ ## 1.3.3
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies
20
+
3
21
  ## 1.3.2
4
22
 
5
23
  ### Patch Changes
@@ -12,6 +12,7 @@ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
12
12
  var _utils = require("@atlaskit/editor-common/utils");
13
13
  var _state = require("@atlaskit/editor-prosemirror/state");
14
14
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
15
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
15
16
  var _commands = require("./commands");
16
17
  var _pluginKey = require("./plugin-key");
17
18
  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; }
@@ -146,10 +147,23 @@ var selectionToolbarPlugin = exports.selectionToolbarPlugin = function selection
146
147
  for (var i = 0; i < resolved.length; i++) {
147
148
  // add a seperator icon after each group except the last
148
149
  items.push.apply(items, (0, _toConsumableArray2.default)(resolved[i].items));
149
- if (i !== resolved.length - 1) {
150
- items.push({
151
- type: 'separator'
152
- });
150
+ if ((0, _experiments.editorExperiment)('contextual_formatting_toolbar', true)) {
151
+ var shouldNotAddSeparator = false;
152
+ if (resolved[i] && resolved[i + 1]) {
153
+ var _resolved$i, _resolved, _resolved$i2, _resolved2;
154
+ shouldNotAddSeparator = ((_resolved$i = resolved[i]) === null || _resolved$i === void 0 ? void 0 : _resolved$i.pluginName) === 'textColor' && ((_resolved = resolved[i + 1]) === null || _resolved === void 0 ? void 0 : _resolved.pluginName) === 'highlight' || ((_resolved$i2 = resolved[i]) === null || _resolved$i2 === void 0 ? void 0 : _resolved$i2.pluginName) === 'alignment' && ((_resolved2 = resolved[i + 1]) === null || _resolved2 === void 0 ? void 0 : _resolved2.pluginName) === 'toolbarListsIndentation';
155
+ }
156
+ if (i !== resolved.length - 1 && !shouldNotAddSeparator) {
157
+ items.push({
158
+ type: 'separator'
159
+ });
160
+ }
161
+ } else {
162
+ if (i !== resolved.length - 1) {
163
+ items.push({
164
+ type: 'separator'
165
+ });
166
+ }
153
167
  }
154
168
  }
155
169
  var calcToolbarPosition = options.config.preferenceToolbarAboveSelection ? _utils.calculateToolbarPositionAboveSelection : _utils.calculateToolbarPositionTrackHead;
@@ -3,6 +3,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
3
  import { calculateToolbarPositionAboveSelection, calculateToolbarPositionTrackHead } from '@atlaskit/editor-common/utils';
4
4
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
5
5
  import { fg } from '@atlaskit/platform-feature-flags';
6
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
6
7
  import { toggleToolbar } from './commands';
7
8
  import { selectionToolbarPluginKey } from './plugin-key';
8
9
  export const selectionToolbarPlugin = options => {
@@ -135,10 +136,23 @@ export const selectionToolbarPlugin = options => {
135
136
  for (let i = 0; i < resolved.length; i++) {
136
137
  // add a seperator icon after each group except the last
137
138
  items.push(...resolved[i].items);
138
- if (i !== resolved.length - 1) {
139
- items.push({
140
- type: 'separator'
141
- });
139
+ if (editorExperiment('contextual_formatting_toolbar', true)) {
140
+ let shouldNotAddSeparator = false;
141
+ if (resolved[i] && resolved[i + 1]) {
142
+ var _resolved$i, _resolved, _resolved$i2, _resolved2;
143
+ shouldNotAddSeparator = ((_resolved$i = resolved[i]) === null || _resolved$i === void 0 ? void 0 : _resolved$i.pluginName) === 'textColor' && ((_resolved = resolved[i + 1]) === null || _resolved === void 0 ? void 0 : _resolved.pluginName) === 'highlight' || ((_resolved$i2 = resolved[i]) === null || _resolved$i2 === void 0 ? void 0 : _resolved$i2.pluginName) === 'alignment' && ((_resolved2 = resolved[i + 1]) === null || _resolved2 === void 0 ? void 0 : _resolved2.pluginName) === 'toolbarListsIndentation';
144
+ }
145
+ if (i !== resolved.length - 1 && !shouldNotAddSeparator) {
146
+ items.push({
147
+ type: 'separator'
148
+ });
149
+ }
150
+ } else {
151
+ if (i !== resolved.length - 1) {
152
+ items.push({
153
+ type: 'separator'
154
+ });
155
+ }
142
156
  }
143
157
  }
144
158
  const calcToolbarPosition = options.config.preferenceToolbarAboveSelection ? calculateToolbarPositionAboveSelection : calculateToolbarPositionTrackHead;
@@ -7,6 +7,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
7
7
  import { calculateToolbarPositionAboveSelection, calculateToolbarPositionTrackHead } from '@atlaskit/editor-common/utils';
8
8
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
9
9
  import { fg } from '@atlaskit/platform-feature-flags';
10
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
10
11
  import { toggleToolbar } from './commands';
11
12
  import { selectionToolbarPluginKey } from './plugin-key';
12
13
  export var selectionToolbarPlugin = function selectionToolbarPlugin(options) {
@@ -139,10 +140,23 @@ export var selectionToolbarPlugin = function selectionToolbarPlugin(options) {
139
140
  for (var i = 0; i < resolved.length; i++) {
140
141
  // add a seperator icon after each group except the last
141
142
  items.push.apply(items, _toConsumableArray(resolved[i].items));
142
- if (i !== resolved.length - 1) {
143
- items.push({
144
- type: 'separator'
145
- });
143
+ if (editorExperiment('contextual_formatting_toolbar', true)) {
144
+ var shouldNotAddSeparator = false;
145
+ if (resolved[i] && resolved[i + 1]) {
146
+ var _resolved$i, _resolved, _resolved$i2, _resolved2;
147
+ shouldNotAddSeparator = ((_resolved$i = resolved[i]) === null || _resolved$i === void 0 ? void 0 : _resolved$i.pluginName) === 'textColor' && ((_resolved = resolved[i + 1]) === null || _resolved === void 0 ? void 0 : _resolved.pluginName) === 'highlight' || ((_resolved$i2 = resolved[i]) === null || _resolved$i2 === void 0 ? void 0 : _resolved$i2.pluginName) === 'alignment' && ((_resolved2 = resolved[i + 1]) === null || _resolved2 === void 0 ? void 0 : _resolved2.pluginName) === 'toolbarListsIndentation';
148
+ }
149
+ if (i !== resolved.length - 1 && !shouldNotAddSeparator) {
150
+ items.push({
151
+ type: 'separator'
152
+ });
153
+ }
154
+ } else {
155
+ if (i !== resolved.length - 1) {
156
+ items.push({
157
+ type: 'separator'
158
+ });
159
+ }
146
160
  }
147
161
  }
148
162
  var calcToolbarPosition = options.config.preferenceToolbarAboveSelection ? calculateToolbarPositionAboveSelection : calculateToolbarPositionTrackHead;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-selection-toolbar",
3
- "version": "1.3.2",
3
+ "version": "1.4.0",
4
4
  "description": "@atlaskit/editor-plugin-selection-toolbar for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -36,11 +36,11 @@
36
36
  }
37
37
  },
38
38
  "dependencies": {
39
- "@atlaskit/editor-common": "^95.0.0",
39
+ "@atlaskit/editor-common": "^96.1.0",
40
40
  "@atlaskit/editor-plugin-editor-viewmode": "^2.1.0",
41
- "@atlaskit/editor-prosemirror": "6.0.0",
41
+ "@atlaskit/editor-prosemirror": "6.2.1",
42
42
  "@atlaskit/platform-feature-flags": "^0.3.0",
43
- "@atlaskit/tmp-editor-statsig": "^2.19.0",
43
+ "@atlaskit/tmp-editor-statsig": "^2.22.0",
44
44
  "@babel/runtime": "^7.0.0",
45
45
  "bind-event-listener": "^3.0.0"
46
46
  },