@atlaskit/editor-plugin-floating-toolbar 31.0.2 → 31.0.3

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,15 @@
1
1
  # @atlaskit/editor-plugin-floating-toolbar
2
2
 
3
+ ## 31.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`f268dee2526f7`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f268dee2526f7) -
8
+ Migrate Smart Card registration and removal from transactions to editor actions behind
9
+ `platform_editor_reduce_forced_layout_2`. Remove unused card overlay registration behind
10
+ `platform_editor_reduce_forced_layout_2`.
11
+ - Updated dependencies
12
+
3
13
  ## 31.0.2
4
14
 
5
15
  ### Patch Changes
@@ -24,6 +24,7 @@ var _useSharedPluginState2 = require("@atlaskit/editor-common/useSharedPluginSta
24
24
  var _state = require("@atlaskit/editor-prosemirror/state");
25
25
  var _utils = require("@atlaskit/editor-prosemirror/utils");
26
26
  var _fg = require("@atlaskit/platform-feature-flags/fg");
27
+ var _useToolbarExternalStore = require("./hooks/useToolbarExternalStore");
27
28
  var _commands = require("./pm-plugins/commands");
28
29
  var _forceFocus = _interopRequireWildcard(require("./pm-plugins/force-focus"));
29
30
  var _commands2 = require("./pm-plugins/toolbar-data/commands");
@@ -235,7 +236,7 @@ var floatingToolbarPlugin = exports.floatingToolbarPlugin = function floatingToo
235
236
  * @returns JSX element representing the floating toolbar or null if not visible
236
237
  */
237
238
  function ContentComponent(_ref5) {
238
- var _configWithNodeInfo$c, _configWithNodeInfo$c2, _items, _pluginInjectionApi$c, _pluginInjectionApi$d, _confirmButtonItem, _confirmButtonItem2, _confirmButtonItem3;
239
+ var _configWithNodeInfo, _configWithNodeInfo$c, _configWithNodeInfo$c2, _items, _pluginInjectionApi$c, _pluginInjectionApi$d, _confirmButtonItem, _confirmButtonItem2, _confirmButtonItem3;
239
240
  var pluginInjectionApi = _ref5.pluginInjectionApi,
240
241
  editorView = _ref5.editorView,
241
242
  popupsMountPoint = _ref5.popupsMountPoint,
@@ -259,6 +260,9 @@ function ContentComponent(_ref5) {
259
260
  // for example, trigger remix on panel will not hide the floating toolbar
260
261
  configWithNodeInfo = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$f = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f === void 0 || (_pluginInjectionApi$f = _pluginInjectionApi$f.sharedState.currentState()) === null || _pluginInjectionApi$f === void 0 ? void 0 : _pluginInjectionApi$f.configWithNodeInfo;
261
262
  }
263
+
264
+ // Subscribe to an external store for rerenders. Used by editor-plugin-card for card registration via editor actions
265
+ (0, _useToolbarExternalStore.useToolbarExternalStore)((_configWithNodeInfo = configWithNodeInfo) === null || _configWithNodeInfo === void 0 || (_configWithNodeInfo = _configWithNodeInfo.config) === null || _configWithNodeInfo === void 0 ? void 0 : _configWithNodeInfo.externalStore);
262
266
  if ((0, _isSsr.isSSR)()) {
263
267
  return null;
264
268
  }
@@ -268,9 +272,9 @@ function ContentComponent(_ref5) {
268
272
  if (userIntentState !== null && userIntentState !== void 0 && userIntentState.currentUserIntent && SUPPRESS_TOOLBAR_USER_INTENTS.includes(userIntentState === null || userIntentState === void 0 ? void 0 : userIntentState.currentUserIntent)) {
269
273
  return null;
270
274
  }
271
- var _configWithNodeInfo = configWithNodeInfo,
272
- config = _configWithNodeInfo.config,
273
- node = _configWithNodeInfo.node;
275
+ var _configWithNodeInfo2 = configWithNodeInfo,
276
+ config = _configWithNodeInfo2.config,
277
+ node = _configWithNodeInfo2.node;
274
278
 
275
279
  // When the new inline editor-toolbar is enabled, suppress floating toolbar for text selections.
276
280
  if (Boolean(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.toolbar)) {
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useToolbarExternalStore = void 0;
7
+ var _react = require("react");
8
+ var emptySnapshot = function emptySnapshot() {
9
+ return 0;
10
+ };
11
+ var emptySubscription = function emptySubscription() {
12
+ return function () {};
13
+ };
14
+
15
+ /** Refresh toolbar content when its optional external store changes. */
16
+ var useToolbarExternalStore = exports.useToolbarExternalStore = function useToolbarExternalStore(store) {
17
+ var _store$subscribe, _store$getSnapshot;
18
+ (0, _react.useSyncExternalStore)((_store$subscribe = store === null || store === void 0 ? void 0 : store.subscribe) !== null && _store$subscribe !== void 0 ? _store$subscribe : emptySubscription, (_store$getSnapshot = store === null || store === void 0 ? void 0 : store.getSnapshot) !== null && _store$getSnapshot !== void 0 ? _store$getSnapshot : emptySnapshot, emptySnapshot);
19
+ };
@@ -11,6 +11,7 @@ import { useSharedPluginState } from '@atlaskit/editor-common/useSharedPluginSta
11
11
  import { AllSelection, PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
12
12
  import { findDomRefAtPos, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
13
13
  import { fg } from '@atlaskit/platform-feature-flags/fg';
14
+ import { useToolbarExternalStore } from './hooks/useToolbarExternalStore';
14
15
  import { copyNode } from './pm-plugins/commands';
15
16
  import forceFocusPlugin, { forceFocusSelector } from './pm-plugins/force-focus';
16
17
  import { hideConfirmDialog } from './pm-plugins/toolbar-data/commands';
@@ -226,7 +227,7 @@ export function ContentComponent({
226
227
  providerFactory,
227
228
  dispatchAnalyticsEvent
228
229
  }) {
229
- var _configWithNodeInfo$c, _configWithNodeInfo$c2, _items, _pluginInjectionApi$c, _pluginInjectionApi$d, _confirmButtonItem, _confirmButtonItem2, _confirmButtonItem3;
230
+ var _configWithNodeInfo, _configWithNodeInfo$c, _configWithNodeInfo$c2, _configWithNodeInfo$c3, _items, _pluginInjectionApi$c, _pluginInjectionApi$d, _confirmButtonItem, _confirmButtonItem2, _confirmButtonItem3;
230
231
  const {
231
232
  floatingToolbarState,
232
233
  editorDisabledState,
@@ -245,10 +246,13 @@ export function ContentComponent({
245
246
  // for example, trigger remix on panel will not hide the floating toolbar
246
247
  configWithNodeInfo = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$f = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f === void 0 ? void 0 : (_pluginInjectionApi$f2 = _pluginInjectionApi$f.sharedState.currentState()) === null || _pluginInjectionApi$f2 === void 0 ? void 0 : _pluginInjectionApi$f2.configWithNodeInfo;
247
248
  }
249
+
250
+ // Subscribe to an external store for rerenders. Used by editor-plugin-card for card registration via editor actions
251
+ useToolbarExternalStore((_configWithNodeInfo = configWithNodeInfo) === null || _configWithNodeInfo === void 0 ? void 0 : (_configWithNodeInfo$c = _configWithNodeInfo.config) === null || _configWithNodeInfo$c === void 0 ? void 0 : _configWithNodeInfo$c.externalStore);
248
252
  if (isSSR()) {
249
253
  return null;
250
254
  }
251
- if (!configWithNodeInfo || !configWithNodeInfo.config || typeof ((_configWithNodeInfo$c = configWithNodeInfo.config) === null || _configWithNodeInfo$c === void 0 ? void 0 : _configWithNodeInfo$c.visible) !== 'undefined' && !((_configWithNodeInfo$c2 = configWithNodeInfo.config) !== null && _configWithNodeInfo$c2 !== void 0 && _configWithNodeInfo$c2.visible)) {
255
+ if (!configWithNodeInfo || !configWithNodeInfo.config || typeof ((_configWithNodeInfo$c2 = configWithNodeInfo.config) === null || _configWithNodeInfo$c2 === void 0 ? void 0 : _configWithNodeInfo$c2.visible) !== 'undefined' && !((_configWithNodeInfo$c3 = configWithNodeInfo.config) !== null && _configWithNodeInfo$c3 !== void 0 && _configWithNodeInfo$c3.visible)) {
252
256
  return null;
253
257
  }
254
258
  if (userIntentState !== null && userIntentState !== void 0 && userIntentState.currentUserIntent && SUPPRESS_TOOLBAR_USER_INTENTS.includes(userIntentState === null || userIntentState === void 0 ? void 0 : userIntentState.currentUserIntent)) {
@@ -0,0 +1,9 @@
1
+ import { useSyncExternalStore } from 'react';
2
+ const emptySnapshot = () => 0;
3
+ const emptySubscription = () => () => {};
4
+
5
+ /** Refresh toolbar content when its optional external store changes. */
6
+ export const useToolbarExternalStore = store => {
7
+ var _store$subscribe, _store$getSnapshot;
8
+ useSyncExternalStore((_store$subscribe = store === null || store === void 0 ? void 0 : store.subscribe) !== null && _store$subscribe !== void 0 ? _store$subscribe : emptySubscription, (_store$getSnapshot = store === null || store === void 0 ? void 0 : store.getSnapshot) !== null && _store$getSnapshot !== void 0 ? _store$getSnapshot : emptySnapshot, emptySnapshot);
9
+ };
@@ -15,6 +15,7 @@ import { useSharedPluginState } from '@atlaskit/editor-common/useSharedPluginSta
15
15
  import { AllSelection, PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
16
16
  import { findDomRefAtPos, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
17
17
  import { fg } from '@atlaskit/platform-feature-flags/fg';
18
+ import { useToolbarExternalStore } from './hooks/useToolbarExternalStore';
18
19
  import { copyNode as _copyNode } from './pm-plugins/commands';
19
20
  import forceFocusPlugin, { forceFocusSelector } from './pm-plugins/force-focus';
20
21
  import { hideConfirmDialog } from './pm-plugins/toolbar-data/commands';
@@ -223,7 +224,7 @@ export var floatingToolbarPlugin = function floatingToolbarPlugin(_ref) {
223
224
  * @returns JSX element representing the floating toolbar or null if not visible
224
225
  */
225
226
  export function ContentComponent(_ref5) {
226
- var _configWithNodeInfo$c, _configWithNodeInfo$c2, _items, _pluginInjectionApi$c, _pluginInjectionApi$d, _confirmButtonItem, _confirmButtonItem2, _confirmButtonItem3;
227
+ var _configWithNodeInfo, _configWithNodeInfo$c, _configWithNodeInfo$c2, _items, _pluginInjectionApi$c, _pluginInjectionApi$d, _confirmButtonItem, _confirmButtonItem2, _confirmButtonItem3;
227
228
  var pluginInjectionApi = _ref5.pluginInjectionApi,
228
229
  editorView = _ref5.editorView,
229
230
  popupsMountPoint = _ref5.popupsMountPoint,
@@ -247,6 +248,9 @@ export function ContentComponent(_ref5) {
247
248
  // for example, trigger remix on panel will not hide the floating toolbar
248
249
  configWithNodeInfo = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$f = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f === void 0 || (_pluginInjectionApi$f = _pluginInjectionApi$f.sharedState.currentState()) === null || _pluginInjectionApi$f === void 0 ? void 0 : _pluginInjectionApi$f.configWithNodeInfo;
249
250
  }
251
+
252
+ // Subscribe to an external store for rerenders. Used by editor-plugin-card for card registration via editor actions
253
+ useToolbarExternalStore((_configWithNodeInfo = configWithNodeInfo) === null || _configWithNodeInfo === void 0 || (_configWithNodeInfo = _configWithNodeInfo.config) === null || _configWithNodeInfo === void 0 ? void 0 : _configWithNodeInfo.externalStore);
250
254
  if (isSSR()) {
251
255
  return null;
252
256
  }
@@ -256,9 +260,9 @@ export function ContentComponent(_ref5) {
256
260
  if (userIntentState !== null && userIntentState !== void 0 && userIntentState.currentUserIntent && SUPPRESS_TOOLBAR_USER_INTENTS.includes(userIntentState === null || userIntentState === void 0 ? void 0 : userIntentState.currentUserIntent)) {
257
261
  return null;
258
262
  }
259
- var _configWithNodeInfo = configWithNodeInfo,
260
- config = _configWithNodeInfo.config,
261
- node = _configWithNodeInfo.node;
263
+ var _configWithNodeInfo2 = configWithNodeInfo,
264
+ config = _configWithNodeInfo2.config,
265
+ node = _configWithNodeInfo2.node;
262
266
 
263
267
  // When the new inline editor-toolbar is enabled, suppress floating toolbar for text selections.
264
268
  if (Boolean(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.toolbar)) {
@@ -0,0 +1,13 @@
1
+ import { useSyncExternalStore } from 'react';
2
+ var emptySnapshot = function emptySnapshot() {
3
+ return 0;
4
+ };
5
+ var emptySubscription = function emptySubscription() {
6
+ return function () {};
7
+ };
8
+
9
+ /** Refresh toolbar content when its optional external store changes. */
10
+ export var useToolbarExternalStore = function useToolbarExternalStore(store) {
11
+ var _store$subscribe, _store$getSnapshot;
12
+ useSyncExternalStore((_store$subscribe = store === null || store === void 0 ? void 0 : store.subscribe) !== null && _store$subscribe !== void 0 ? _store$subscribe : emptySubscription, (_store$getSnapshot = store === null || store === void 0 ? void 0 : store.getSnapshot) !== null && _store$getSnapshot !== void 0 ? _store$getSnapshot : emptySnapshot, emptySnapshot);
13
+ };
@@ -0,0 +1,3 @@
1
+ import type { FloatingToolbarConfig } from '@atlaskit/editor-common/types/floating-toolbar';
2
+ /** Refresh toolbar content when its optional external store changes. */
3
+ export declare const useToolbarExternalStore: (store: FloatingToolbarConfig['externalStore']) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-floating-toolbar",
3
- "version": "31.0.2",
3
+ "version": "31.0.3",
4
4
  "description": "Floating toolbar plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -22,7 +22,7 @@
22
22
  "atlaskit:src": "src/index.ts",
23
23
  "dependencies": {
24
24
  "@atlaskit/adf-utils": "^20.9.0",
25
- "@atlaskit/button": "^25.5.0",
25
+ "@atlaskit/button": "^25.6.0",
26
26
  "@atlaskit/checkbox": "^19.3.0",
27
27
  "@atlaskit/editor-palette": "^3.5.0",
28
28
  "@atlaskit/editor-plugin-analytics": "^29.0.0",
@@ -56,7 +56,7 @@
56
56
  "react-loosely-lazy": "^1.0.0"
57
57
  },
58
58
  "peerDependencies": {
59
- "@atlaskit/editor-common": "^133.1.0",
59
+ "@atlaskit/editor-common": "^133.4.0",
60
60
  "react": "^18.2.0 || ^19.2.0",
61
61
  "react-dom": "^18.2.0 || ^19.2.0",
62
62
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"