@atlaskit/editor-plugin-text-formatting 2.2.10 → 2.2.13

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,29 @@
1
1
  # @atlaskit/editor-plugin-text-formatting
2
2
 
3
+ ## 2.2.13
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 2.2.12
10
+
11
+ ### Patch Changes
12
+
13
+ - [#161143](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/161143)
14
+ [`6247656fbff10`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6247656fbff10) -
15
+ [ED-28106] Fix toolbar pinning from table cell selections breaking the toolbar
16
+ - Updated dependencies
17
+
18
+ ## 2.2.11
19
+
20
+ ### Patch Changes
21
+
22
+ - [#159090](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/159090)
23
+ [`9cbae97c20f84`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9cbae97c20f84) -
24
+ Reduces rerenders of text formatting options and the toolbar when it is docked to top.
25
+ - Updated dependencies
26
+
3
27
  ## 2.2.10
4
28
 
5
29
  ### Patch Changes
@@ -8,6 +8,7 @@ exports.textFormattingPlugin = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _react = _interopRequireDefault(require("react"));
10
10
  var _adfSchema = require("@atlaskit/adf-schema");
11
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
11
12
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
12
13
  var _clearFormatting = require("./pm-plugins/clear-formatting");
13
14
  var _clearFormattingKeymap = _interopRequireDefault(require("./pm-plugins/clear-formatting-keymap"));
@@ -37,6 +38,18 @@ var textFormattingPlugin = exports.textFormattingPlugin = function textFormattin
37
38
  isToolbarReducedSpacing = _ref2.isToolbarReducedSpacing,
38
39
  toolbarSize = _ref2.toolbarSize,
39
40
  disabled = _ref2.disabled;
41
+ if ((0, _platformFeatureFlags.fg)('platform_editor_toolbar_rerender_optimization')) {
42
+ return /*#__PURE__*/_react.default.createElement(_PrimaryToolbarComponent.PrimaryToolbarComponentMemoized, {
43
+ api: api,
44
+ popupsMountPoint: popupsMountPoint,
45
+ popupsScrollableElement: popupsScrollableElement,
46
+ toolbarSize: toolbarSize,
47
+ isReducedSpacing: isToolbarReducedSpacing,
48
+ editorView: editorView,
49
+ disabled: disabled,
50
+ shouldUseResponsiveToolbar: Boolean(options === null || options === void 0 ? void 0 : options.responsiveToolbarMenu)
51
+ });
52
+ }
40
53
  return /*#__PURE__*/_react.default.createElement(_PrimaryToolbarComponent.PrimaryToolbarComponent, {
41
54
  api: api,
42
55
  popupsMountPoint: popupsMountPoint,
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.PrimaryToolbarComponent = PrimaryToolbarComponent;
8
+ exports.PrimaryToolbarComponentMemoized = void 0;
8
9
  var _react = _interopRequireDefault(require("react"));
9
10
  var _hooks = require("@atlaskit/editor-common/hooks");
10
11
  var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
@@ -112,4 +113,5 @@ function PrimaryToolbarComponent(_ref) {
112
113
  api: api,
113
114
  toolbarType: _types.ToolbarType.PRIMARY
114
115
  });
115
- }
116
+ }
117
+ var PrimaryToolbarComponentMemoized = exports.PrimaryToolbarComponentMemoized = /*#__PURE__*/_react.default.memo(PrimaryToolbarComponent);
@@ -32,7 +32,7 @@ var hasMultiplePartsWithFormattingInSelection = exports.hasMultiplePartsWithForm
32
32
  };
33
33
  var getCommonActiveMarks = exports.getCommonActiveMarks = function getCommonActiveMarks(_ref2) {
34
34
  var selectedContent = _ref2.selectedContent;
35
- if (!selectedContent) {
35
+ if (!selectedContent || selectedContent.length === 0) {
36
36
  return [];
37
37
  }
38
38
  // filter out fragment node contains only spaces
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { code, em, strike, strong, subsup, underline } from '@atlaskit/adf-schema';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
3
4
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
4
5
  import { plugin as clearFormattingPlugin, pluginKey as clearFormattingPluginKey } from './pm-plugins/clear-formatting';
5
6
  import clearFormattingKeymapPlugin from './pm-plugins/clear-formatting-keymap';
@@ -11,7 +12,7 @@ import { plugin as pmPlugin } from './pm-plugins/main';
11
12
  import { pluginKey as textFormattingPluginKey } from './pm-plugins/plugin-key';
12
13
  import textFormattingSmartInputRulePlugin from './pm-plugins/smart-input-rule';
13
14
  import { FloatingToolbarTextFormalWithIntl as FloatingToolbarComponent } from './ui/FloatingToolbarComponent';
14
- import { PrimaryToolbarComponent } from './ui/PrimaryToolbarComponent';
15
+ import { PrimaryToolbarComponent, PrimaryToolbarComponentMemoized } from './ui/PrimaryToolbarComponent';
15
16
 
16
17
  /**
17
18
  * Text formatting plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor`
@@ -30,6 +31,18 @@ export const textFormattingPlugin = ({
30
31
  toolbarSize,
31
32
  disabled
32
33
  }) => {
34
+ if (fg('platform_editor_toolbar_rerender_optimization')) {
35
+ return /*#__PURE__*/React.createElement(PrimaryToolbarComponentMemoized, {
36
+ api: api,
37
+ popupsMountPoint: popupsMountPoint,
38
+ popupsScrollableElement: popupsScrollableElement,
39
+ toolbarSize: toolbarSize,
40
+ isReducedSpacing: isToolbarReducedSpacing,
41
+ editorView: editorView,
42
+ disabled: disabled,
43
+ shouldUseResponsiveToolbar: Boolean(options === null || options === void 0 ? void 0 : options.responsiveToolbarMenu)
44
+ });
45
+ }
33
46
  return /*#__PURE__*/React.createElement(PrimaryToolbarComponent, {
34
47
  api: api,
35
48
  popupsMountPoint: popupsMountPoint,
@@ -107,4 +107,5 @@ export function PrimaryToolbarComponent({
107
107
  api: api,
108
108
  toolbarType: ToolbarType.PRIMARY
109
109
  });
110
- }
110
+ }
111
+ export const PrimaryToolbarComponentMemoized = /*#__PURE__*/React.memo(PrimaryToolbarComponent);
@@ -20,7 +20,7 @@ export const hasMultiplePartsWithFormattingInSelection = ({
20
20
  export const getCommonActiveMarks = ({
21
21
  selectedContent
22
22
  }) => {
23
- if (!selectedContent) {
23
+ if (!selectedContent || selectedContent.length === 0) {
24
24
  return [];
25
25
  }
26
26
  // filter out fragment node contains only spaces
@@ -3,6 +3,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
3
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
4
  import React from 'react';
5
5
  import { code, em, strike, strong, subsup, underline } from '@atlaskit/adf-schema';
6
+ import { fg } from '@atlaskit/platform-feature-flags';
6
7
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
7
8
  import { plugin as clearFormattingPlugin, pluginKey as clearFormattingPluginKey } from './pm-plugins/clear-formatting';
8
9
  import clearFormattingKeymapPlugin from './pm-plugins/clear-formatting-keymap';
@@ -14,7 +15,7 @@ import { plugin as pmPlugin } from './pm-plugins/main';
14
15
  import { pluginKey as textFormattingPluginKey } from './pm-plugins/plugin-key';
15
16
  import textFormattingSmartInputRulePlugin from './pm-plugins/smart-input-rule';
16
17
  import { FloatingToolbarTextFormalWithIntl as FloatingToolbarComponent } from './ui/FloatingToolbarComponent';
17
- import { PrimaryToolbarComponent } from './ui/PrimaryToolbarComponent';
18
+ import { PrimaryToolbarComponent, PrimaryToolbarComponentMemoized } from './ui/PrimaryToolbarComponent';
18
19
 
19
20
  /**
20
21
  * Text formatting plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor`
@@ -31,6 +32,18 @@ export var textFormattingPlugin = function textFormattingPlugin(_ref) {
31
32
  isToolbarReducedSpacing = _ref2.isToolbarReducedSpacing,
32
33
  toolbarSize = _ref2.toolbarSize,
33
34
  disabled = _ref2.disabled;
35
+ if (fg('platform_editor_toolbar_rerender_optimization')) {
36
+ return /*#__PURE__*/React.createElement(PrimaryToolbarComponentMemoized, {
37
+ api: api,
38
+ popupsMountPoint: popupsMountPoint,
39
+ popupsScrollableElement: popupsScrollableElement,
40
+ toolbarSize: toolbarSize,
41
+ isReducedSpacing: isToolbarReducedSpacing,
42
+ editorView: editorView,
43
+ disabled: disabled,
44
+ shouldUseResponsiveToolbar: Boolean(options === null || options === void 0 ? void 0 : options.responsiveToolbarMenu)
45
+ });
46
+ }
34
47
  return /*#__PURE__*/React.createElement(PrimaryToolbarComponent, {
35
48
  api: api,
36
49
  popupsMountPoint: popupsMountPoint,
@@ -105,4 +105,5 @@ export function PrimaryToolbarComponent(_ref) {
105
105
  api: api,
106
106
  toolbarType: ToolbarType.PRIMARY
107
107
  });
108
- }
108
+ }
109
+ export var PrimaryToolbarComponentMemoized = /*#__PURE__*/React.memo(PrimaryToolbarComponent);
@@ -26,7 +26,7 @@ export var hasMultiplePartsWithFormattingInSelection = function hasMultipleParts
26
26
  };
27
27
  export var getCommonActiveMarks = function getCommonActiveMarks(_ref2) {
28
28
  var selectedContent = _ref2.selectedContent;
29
- if (!selectedContent) {
29
+ if (!selectedContent || selectedContent.length === 0) {
30
30
  return [];
31
31
  }
32
32
  // filter out fragment node contains only spaces
@@ -13,4 +13,5 @@ interface PrimaryToolbarComponentProps {
13
13
  shouldUseResponsiveToolbar: boolean;
14
14
  }
15
15
  export declare function PrimaryToolbarComponent({ api, popupsMountPoint, popupsScrollableElement, toolbarSize, editorView, disabled, isReducedSpacing, shouldUseResponsiveToolbar, }: PrimaryToolbarComponentProps): React.JSX.Element;
16
+ export declare const PrimaryToolbarComponentMemoized: React.MemoExoticComponent<typeof PrimaryToolbarComponent>;
16
17
  export {};
@@ -13,4 +13,5 @@ interface PrimaryToolbarComponentProps {
13
13
  shouldUseResponsiveToolbar: boolean;
14
14
  }
15
15
  export declare function PrimaryToolbarComponent({ api, popupsMountPoint, popupsScrollableElement, toolbarSize, editorView, disabled, isReducedSpacing, shouldUseResponsiveToolbar, }: PrimaryToolbarComponentProps): React.JSX.Element;
16
+ export declare const PrimaryToolbarComponentMemoized: React.MemoExoticComponent<typeof PrimaryToolbarComponent>;
16
17
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-text-formatting",
3
- "version": "2.2.10",
3
+ "version": "2.2.13",
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": "^105.10.0",
37
+ "@atlaskit/editor-common": "^106.0.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",
@@ -42,10 +42,10 @@
42
42
  "@atlaskit/editor-prosemirror": "7.0.0",
43
43
  "@atlaskit/editor-shared-styles": "^3.4.0",
44
44
  "@atlaskit/editor-tables": "^2.9.0",
45
- "@atlaskit/icon": "^26.3.0",
45
+ "@atlaskit/icon": "^26.4.0",
46
46
  "@atlaskit/platform-feature-flags": "^1.1.0",
47
47
  "@atlaskit/prosemirror-input-rules": "^3.3.0",
48
- "@atlaskit/tmp-editor-statsig": "^5.0.0",
48
+ "@atlaskit/tmp-editor-statsig": "^5.2.0",
49
49
  "@atlaskit/tokens": "^4.9.0",
50
50
  "@babel/runtime": "^7.0.0",
51
51
  "@emotion/react": "^11.7.1",
@@ -124,6 +124,9 @@
124
124
  },
125
125
  "platform_editor_controls_patch_7": {
126
126
  "type": "boolean"
127
+ },
128
+ "platform_editor_toolbar_rerender_optimization": {
129
+ "type": "boolean"
127
130
  }
128
131
  }
129
132
  }