@atlaskit/editor-common 76.17.0 → 76.17.1

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,12 @@
1
1
  # @atlaskit/editor-common
2
2
 
3
+ ## 76.17.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#42323](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/42323) [`a4cb1c16536`](https://bitbucket.org/atlassian/atlassian-frontend/commits/a4cb1c16536) - Fix useSharedPluginState if the editor API changes to ensure that the state updates.
8
+ - Updated dependencies
9
+
3
10
  ## 76.17.0
4
11
 
5
12
  ### Minor Changes
@@ -119,12 +119,23 @@ function useSharedPluginStateInternal(externalPlugins) {
119
119
  pluginStates = _useState2[0],
120
120
  setPluginState = _useState2[1];
121
121
  var refStates = (0, _react.useRef)({});
122
+ var mounted = (0, _react.useRef)(false);
122
123
  (0, _react.useLayoutEffect)(function () {
123
124
  var debouncedPluginStateUpdate = (0, _debounce.default)(function () {
124
125
  setPluginState(function (currentPluginStates) {
125
126
  return _objectSpread(_objectSpread({}, currentPluginStates), refStates.current);
126
127
  });
127
128
  });
129
+
130
+ // If we re-render this hook due to a change in the external
131
+ // plugins we need to push a state update to ensure we have
132
+ // the most current state.
133
+ if (mounted.current) {
134
+ refStates.current = mapValues(externalPlugins, function (value) {
135
+ return value === null || value === void 0 ? void 0 : value.sharedState.currentState();
136
+ });
137
+ debouncedPluginStateUpdate();
138
+ }
128
139
  var unsubs = Object.entries(externalPlugins).map(function (_ref3) {
129
140
  var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
130
141
  pluginKey = _ref4[0],
@@ -139,6 +150,7 @@ function useSharedPluginStateInternal(externalPlugins) {
139
150
  debouncedPluginStateUpdate();
140
151
  });
141
152
  });
153
+ mounted.current = true;
142
154
  return function () {
143
155
  refStates.current = {};
144
156
  unsubs.forEach(function (cb) {
@@ -16,7 +16,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
16
16
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
17
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
18
18
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
19
- var packageVersion = "76.17.0";
19
+ var packageVersion = "76.17.1";
20
20
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
21
21
  // Remove URL as it has UGC
22
22
  // TODO: Sanitise the URL instead of just removing it
@@ -24,7 +24,7 @@ var _templateObject, _templateObject2, _templateObject3;
24
24
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
25
25
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } /** @jsx jsx */
26
26
  var packageName = "@atlaskit/editor-common";
27
- var packageVersion = "76.17.0";
27
+ var packageVersion = "76.17.1";
28
28
  var halfFocusRing = 1;
29
29
  var dropOffset = '0, 8';
30
30
  var DropList = /*#__PURE__*/function (_Component) {
@@ -98,6 +98,7 @@ export function useSharedPluginState(injectionApi, plugins) {
98
98
  function useSharedPluginStateInternal(externalPlugins) {
99
99
  const [pluginStates, setPluginState] = useState(mapValues(externalPlugins, value => value === null || value === void 0 ? void 0 : value.sharedState.currentState()));
100
100
  const refStates = useRef({});
101
+ const mounted = useRef(false);
101
102
  useLayoutEffect(() => {
102
103
  const debouncedPluginStateUpdate = debounce(() => {
103
104
  setPluginState(currentPluginStates => ({
@@ -105,6 +106,14 @@ function useSharedPluginStateInternal(externalPlugins) {
105
106
  ...refStates.current
106
107
  }));
107
108
  });
109
+
110
+ // If we re-render this hook due to a change in the external
111
+ // plugins we need to push a state update to ensure we have
112
+ // the most current state.
113
+ if (mounted.current) {
114
+ refStates.current = mapValues(externalPlugins, value => value === null || value === void 0 ? void 0 : value.sharedState.currentState());
115
+ debouncedPluginStateUpdate();
116
+ }
108
117
  const unsubs = Object.entries(externalPlugins).map(([pluginKey, externalPlugin]) => {
109
118
  return externalPlugin === null || externalPlugin === void 0 ? void 0 : externalPlugin.sharedState.onChange(({
110
119
  nextSharedState,
@@ -117,6 +126,7 @@ function useSharedPluginStateInternal(externalPlugins) {
117
126
  debouncedPluginStateUpdate();
118
127
  });
119
128
  });
129
+ mounted.current = true;
120
130
  return () => {
121
131
  refStates.current = {};
122
132
  unsubs.forEach(cb => cb === null || cb === void 0 ? void 0 : cb());
@@ -1,6 +1,6 @@
1
1
  const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
2
2
  const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
3
- const packageVersion = "76.17.0";
3
+ const packageVersion = "76.17.1";
4
4
  const sanitiseSentryEvents = (data, _hint) => {
5
5
  // Remove URL as it has UGC
6
6
  // TODO: Sanitise the URL instead of just removing it
@@ -9,7 +9,7 @@ import { themed } from '@atlaskit/theme/components';
9
9
  import { borderRadius } from '@atlaskit/theme/constants';
10
10
  import Layer from '../Layer';
11
11
  const packageName = "@atlaskit/editor-common";
12
- const packageVersion = "76.17.0";
12
+ const packageVersion = "76.17.1";
13
13
  const halfFocusRing = 1;
14
14
  const dropOffset = '0, 8';
15
15
  class DropList extends Component {
@@ -112,12 +112,23 @@ function useSharedPluginStateInternal(externalPlugins) {
112
112
  pluginStates = _useState2[0],
113
113
  setPluginState = _useState2[1];
114
114
  var refStates = useRef({});
115
+ var mounted = useRef(false);
115
116
  useLayoutEffect(function () {
116
117
  var debouncedPluginStateUpdate = debounce(function () {
117
118
  setPluginState(function (currentPluginStates) {
118
119
  return _objectSpread(_objectSpread({}, currentPluginStates), refStates.current);
119
120
  });
120
121
  });
122
+
123
+ // If we re-render this hook due to a change in the external
124
+ // plugins we need to push a state update to ensure we have
125
+ // the most current state.
126
+ if (mounted.current) {
127
+ refStates.current = mapValues(externalPlugins, function (value) {
128
+ return value === null || value === void 0 ? void 0 : value.sharedState.currentState();
129
+ });
130
+ debouncedPluginStateUpdate();
131
+ }
121
132
  var unsubs = Object.entries(externalPlugins).map(function (_ref3) {
122
133
  var _ref4 = _slicedToArray(_ref3, 2),
123
134
  pluginKey = _ref4[0],
@@ -132,6 +143,7 @@ function useSharedPluginStateInternal(externalPlugins) {
132
143
  debouncedPluginStateUpdate();
133
144
  });
134
145
  });
146
+ mounted.current = true;
135
147
  return function () {
136
148
  refStates.current = {};
137
149
  unsubs.forEach(function (cb) {
@@ -6,7 +6,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
6
6
  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; }
7
7
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
8
8
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
9
- var packageVersion = "76.17.0";
9
+ var packageVersion = "76.17.1";
10
10
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
11
11
  // Remove URL as it has UGC
12
12
  // TODO: Sanitise the URL instead of just removing it
@@ -19,7 +19,7 @@ import { themed } from '@atlaskit/theme/components';
19
19
  import { borderRadius } from '@atlaskit/theme/constants';
20
20
  import Layer from '../Layer';
21
21
  var packageName = "@atlaskit/editor-common";
22
- var packageVersion = "76.17.0";
22
+ var packageVersion = "76.17.1";
23
23
  var halfFocusRing = 1;
24
24
  var dropOffset = '0, 8';
25
25
  var DropList = /*#__PURE__*/function (_Component) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "76.17.0",
3
+ "version": "76.17.1",
4
4
  "description": "A package that contains common classes and components for editor and renderer",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -92,7 +92,7 @@
92
92
  "@atlaskit/analytics-namespaced-context": "^6.7.0",
93
93
  "@atlaskit/analytics-next": "^9.1.0",
94
94
  "@atlaskit/analytics-next-stable-react-context": "1.0.1",
95
- "@atlaskit/button": "^16.11.0",
95
+ "@atlaskit/button": "^16.12.0",
96
96
  "@atlaskit/code": "^14.6.0",
97
97
  "@atlaskit/codemod-utils": "^4.2.0",
98
98
  "@atlaskit/editor-json-transformer": "^8.10.0",