@atlaskit/editor-common 93.4.3 → 93.4.4
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 +8 -0
- package/UNSAFE_do_not_use_editor_context/package.json +15 -0
- package/dist/cjs/monitoring/error.js +1 -1
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/cjs/ui/EditorContext/index.js +9 -0
- package/dist/cjs/with-plugin-state/index.js +273 -18
- package/dist/es2019/monitoring/error.js +1 -1
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/es2019/ui/EditorContext/index.js +2 -0
- package/dist/es2019/with-plugin-state/index.js +217 -5
- package/dist/esm/monitoring/error.js +1 -1
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/esm/ui/EditorContext/index.js +2 -0
- package/dist/esm/with-plugin-state/index.js +272 -17
- package/dist/types/ui/EditorContext/index.d.ts +2 -0
- package/dist/types/with-plugin-state/index.d.ts +35 -1
- package/dist/types-ts4.5/ui/EditorContext/index.d.ts +2 -0
- package/dist/types-ts4.5/with-plugin-state/index.d.ts +35 -1
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-common
|
|
2
2
|
|
|
3
|
+
## 93.4.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#151676](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/151676)
|
|
8
|
+
[`ed6d01983b0da`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ed6d01983b0da) -
|
|
9
|
+
ED-25183: Remediate WithEditorActions, WithPluginState & LegacyEditorContext context type
|
|
10
|
+
|
|
3
11
|
## 93.4.3
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atlaskit/editor-common/UNSAFE_do_not_use_editor_context",
|
|
3
|
+
"main": "../dist/cjs/ui/EditorContext/index.js",
|
|
4
|
+
"module": "../dist/esm/ui/EditorContext/index.js",
|
|
5
|
+
"module:es2019": "../dist/es2019/ui/EditorContext/index.js",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"types": "../dist/types/ui/EditorContext/index.d.ts",
|
|
8
|
+
"typesVersions": {
|
|
9
|
+
">=4.5 <5.4": {
|
|
10
|
+
"*": [
|
|
11
|
+
"../dist/types-ts4.5/ui/EditorContext/index.d.ts"
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -17,7 +17,7 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
17
17
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
18
18
|
var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
19
19
|
var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
20
|
-
var packageVersion = "93.4.
|
|
20
|
+
var packageVersion = "93.4.4";
|
|
21
21
|
var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
|
|
22
22
|
// Remove URL as it has UGC
|
|
23
23
|
// TODO: Sanitise the URL instead of just removing it
|
|
@@ -24,7 +24,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
24
24
|
* @jsx jsx
|
|
25
25
|
*/ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
26
26
|
var packageName = "@atlaskit/editor-common";
|
|
27
|
-
var packageVersion = "93.4.
|
|
27
|
+
var packageVersion = "93.4.4";
|
|
28
28
|
var halfFocusRing = 1;
|
|
29
29
|
var dropOffset = '0, 8';
|
|
30
30
|
var DropList = /*#__PURE__*/function (_Component) {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.EditorContext = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var EditorContext = exports.EditorContext = /*#__PURE__*/_react.default.createContext({});
|
|
@@ -4,19 +4,22 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.WithPluginState = void 0;
|
|
7
|
+
exports.WithPluginStateOld = exports.WithPluginStateInner = exports.WithPluginState = void 0;
|
|
8
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
8
11
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
12
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
11
13
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
12
14
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
13
15
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
14
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
16
|
var _react = _interopRequireDefault(require("react"));
|
|
16
17
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
18
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
17
19
|
var _analytics = require("../analytics");
|
|
18
20
|
var _eventDispatcher = require("../event-dispatcher");
|
|
19
21
|
var _performanceMeasures = require("../performance-measures");
|
|
22
|
+
var _EditorContext = require("../ui/EditorContext");
|
|
20
23
|
var _utils = require("../utils");
|
|
21
24
|
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; }
|
|
22
25
|
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) { (0, _defineProperty2.default)(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; }
|
|
@@ -68,10 +71,34 @@ var DEFAULT_SLOW_THRESHOLD = 4;
|
|
|
68
71
|
var WithPluginState = exports.WithPluginState = /*#__PURE__*/function (_React$Component) {
|
|
69
72
|
(0, _inherits2.default)(WithPluginState, _React$Component);
|
|
70
73
|
var _super = _createSuper(WithPluginState);
|
|
71
|
-
function WithPluginState(props
|
|
72
|
-
var _this;
|
|
74
|
+
function WithPluginState(props) {
|
|
73
75
|
(0, _classCallCheck2.default)(this, WithPluginState);
|
|
74
|
-
|
|
76
|
+
return _super.call(this, props);
|
|
77
|
+
}
|
|
78
|
+
(0, _createClass2.default)(WithPluginState, [{
|
|
79
|
+
key: "render",
|
|
80
|
+
value: function render() {
|
|
81
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_react18_phase2')) {
|
|
82
|
+
return /*#__PURE__*/_react.default.createElement(WithPluginStateNew, this.props);
|
|
83
|
+
}
|
|
84
|
+
return /*#__PURE__*/_react.default.createElement(WithPluginStateOld, this.props);
|
|
85
|
+
}
|
|
86
|
+
}]);
|
|
87
|
+
return WithPluginState;
|
|
88
|
+
}(_react.default.Component);
|
|
89
|
+
function WithPluginStateNew(props) {
|
|
90
|
+
var context = _react.default.useContext(_EditorContext.EditorContext);
|
|
91
|
+
return /*#__PURE__*/_react.default.createElement(WithPluginStateInner, (0, _extends2.default)({}, props, {
|
|
92
|
+
editorActions: context === null || context === void 0 ? void 0 : context.editorActions
|
|
93
|
+
}));
|
|
94
|
+
}
|
|
95
|
+
var WithPluginStateInner = exports.WithPluginStateInner = /*#__PURE__*/function (_React$Component2) {
|
|
96
|
+
(0, _inherits2.default)(WithPluginStateInner, _React$Component2);
|
|
97
|
+
var _super2 = _createSuper(WithPluginStateInner);
|
|
98
|
+
function WithPluginStateInner(props) {
|
|
99
|
+
var _this;
|
|
100
|
+
(0, _classCallCheck2.default)(this, WithPluginStateInner);
|
|
101
|
+
_this = _super2.call(this, props);
|
|
75
102
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "listeners", {});
|
|
76
103
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "debounce", null);
|
|
77
104
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "notAppliedState", {});
|
|
@@ -137,24 +164,22 @@ var WithPluginState = exports.WithPluginState = /*#__PURE__*/function (_React$Co
|
|
|
137
164
|
});
|
|
138
165
|
}
|
|
139
166
|
});
|
|
140
|
-
|
|
141
|
-
_this.subscribe(_this.props);
|
|
142
|
-
});
|
|
143
|
-
_this.state = _this.getPluginsStates(_this.props.plugins, _this.getEditorView(props, context));
|
|
167
|
+
_this.state = _this.getPluginsStates(_this.props.plugins, _this.getEditorView(props));
|
|
144
168
|
return _this;
|
|
145
169
|
}
|
|
146
|
-
(0, _createClass2.default)(
|
|
170
|
+
(0, _createClass2.default)(WithPluginStateInner, [{
|
|
147
171
|
key: "getEditorView",
|
|
148
|
-
value: function getEditorView(maybeProps
|
|
172
|
+
value: function getEditorView(maybeProps) {
|
|
149
173
|
var props = maybeProps || this.props;
|
|
150
|
-
var
|
|
151
|
-
return props.editorView ||
|
|
174
|
+
var editorActions = props.editorActions;
|
|
175
|
+
return props.editorView || (editorActions === null || editorActions === void 0 ? void 0 : editorActions._privateGetEditorView());
|
|
152
176
|
}
|
|
153
177
|
}, {
|
|
154
178
|
key: "getEventDispatcher",
|
|
155
179
|
value: function getEventDispatcher(maybeProps) {
|
|
180
|
+
var _props$editorActions;
|
|
156
181
|
var props = maybeProps || this.props;
|
|
157
|
-
return props.eventDispatcher ||
|
|
182
|
+
return props.eventDispatcher || ((_props$editorActions = props.editorActions) === null || _props$editorActions === void 0 ? void 0 : _props$editorActions._privateGetEventDispatcher());
|
|
158
183
|
}
|
|
159
184
|
}, {
|
|
160
185
|
key: "getPluginsStates",
|
|
@@ -245,6 +270,236 @@ var WithPluginState = exports.WithPluginState = /*#__PURE__*/function (_React$Co
|
|
|
245
270
|
});
|
|
246
271
|
this.listeners = [];
|
|
247
272
|
}
|
|
273
|
+
}, {
|
|
274
|
+
key: "subscribeToContextUpdates",
|
|
275
|
+
value: function subscribeToContextUpdates() {
|
|
276
|
+
var _this$props$editorAct,
|
|
277
|
+
_this4 = this;
|
|
278
|
+
(_this$props$editorAct = this.props.editorActions) === null || _this$props$editorAct === void 0 || _this$props$editorAct._privateSubscribe(function () {
|
|
279
|
+
return _this4.subscribe(_this4.props);
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
}, {
|
|
283
|
+
key: "unsubscribeFromContextUpdates",
|
|
284
|
+
value: function unsubscribeFromContextUpdates() {
|
|
285
|
+
var _this$props$editorAct2,
|
|
286
|
+
_this5 = this;
|
|
287
|
+
(_this$props$editorAct2 = this.props.editorActions) === null || _this$props$editorAct2 === void 0 || _this$props$editorAct2._privateUnsubscribe(function () {
|
|
288
|
+
return _this5.subscribe(_this5.props);
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
}, {
|
|
292
|
+
key: "componentDidMount",
|
|
293
|
+
value: function componentDidMount() {
|
|
294
|
+
this.subscribe(this.props);
|
|
295
|
+
this.subscribeToContextUpdates();
|
|
296
|
+
}
|
|
297
|
+
}, {
|
|
298
|
+
key: "UNSAFE_componentWillReceiveProps",
|
|
299
|
+
value: function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
300
|
+
if (!this.isSubscribed) {
|
|
301
|
+
this.subscribe(nextProps);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}, {
|
|
305
|
+
key: "componentWillUnmount",
|
|
306
|
+
value: function componentWillUnmount() {
|
|
307
|
+
if (this.debounce) {
|
|
308
|
+
window.clearTimeout(this.debounce);
|
|
309
|
+
}
|
|
310
|
+
this.unsubscribeFromContextUpdates();
|
|
311
|
+
this.unsubscribe();
|
|
312
|
+
}
|
|
313
|
+
}, {
|
|
314
|
+
key: "render",
|
|
315
|
+
value: function render() {
|
|
316
|
+
var render = this.props.render;
|
|
317
|
+
return render(this.state);
|
|
318
|
+
}
|
|
319
|
+
}]);
|
|
320
|
+
return WithPluginStateInner;
|
|
321
|
+
}(_react.default.Component);
|
|
322
|
+
(0, _defineProperty2.default)(WithPluginStateInner, "displayName", 'WithPluginState');
|
|
323
|
+
var WithPluginStateOld = exports.WithPluginStateOld = /*#__PURE__*/function (_React$Component3) {
|
|
324
|
+
(0, _inherits2.default)(WithPluginStateOld, _React$Component3);
|
|
325
|
+
var _super3 = _createSuper(WithPluginStateOld);
|
|
326
|
+
function WithPluginStateOld(props, context) {
|
|
327
|
+
var _this6;
|
|
328
|
+
(0, _classCallCheck2.default)(this, WithPluginStateOld);
|
|
329
|
+
_this6 = _super3.call(this, props, context);
|
|
330
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this6), "listeners", {});
|
|
331
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this6), "debounce", null);
|
|
332
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this6), "notAppliedState", {});
|
|
333
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this6), "isSubscribed", false);
|
|
334
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this6), "callsCount", 0);
|
|
335
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this6), "handlePluginStateChange", function (propName, pluginName, performanceOptions, skipEqualityCheck) {
|
|
336
|
+
return function (pluginState) {
|
|
337
|
+
// skipEqualityCheck is being used for old plugins since they are mutating plugin state instead of creating a new one
|
|
338
|
+
if (_this6.state[propName] !== pluginState || skipEqualityCheck) {
|
|
339
|
+
_this6.updateState({
|
|
340
|
+
stateSubset: (0, _defineProperty2.default)({}, propName, pluginState),
|
|
341
|
+
pluginName: pluginName,
|
|
342
|
+
performanceOptions: performanceOptions
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
});
|
|
347
|
+
/**
|
|
348
|
+
* Debounces setState calls in order to reduce number of re-renders caused by several plugin state changes.
|
|
349
|
+
*/
|
|
350
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this6), "updateState", function (_ref2) {
|
|
351
|
+
var stateSubset = _ref2.stateSubset,
|
|
352
|
+
pluginName = _ref2.pluginName,
|
|
353
|
+
performanceOptions = _ref2.performanceOptions;
|
|
354
|
+
_this6.notAppliedState = _objectSpread(_objectSpread({}, _this6.notAppliedState), stateSubset);
|
|
355
|
+
if (_this6.debounce) {
|
|
356
|
+
window.clearTimeout(_this6.debounce);
|
|
357
|
+
}
|
|
358
|
+
var debounce = _this6.props.debounce !== false ? function (fn) {
|
|
359
|
+
return window.setTimeout(fn, 0);
|
|
360
|
+
} : function (fn) {
|
|
361
|
+
return fn();
|
|
362
|
+
};
|
|
363
|
+
_this6.debounce = debounce(function () {
|
|
364
|
+
var measure = "\uD83E\uDD89".concat(pluginName, "::WithPluginState");
|
|
365
|
+
performanceOptions.trackingEnabled && (0, _performanceMeasures.startMeasure)(measure);
|
|
366
|
+
_this6.setState(_this6.notAppliedState, function () {
|
|
367
|
+
performanceOptions.trackingEnabled && (0, _performanceMeasures.stopMeasure)(measure, function (duration) {
|
|
368
|
+
// Each WithPluginState component will fire analytics event no more than once every `samplingLimit` times
|
|
369
|
+
if (++_this6.callsCount % performanceOptions.samplingRate === 0 && duration > performanceOptions.slowThreshold) {
|
|
370
|
+
_this6.dispatchAnalyticsEvent({
|
|
371
|
+
action: _analytics.ACTION.WITH_PLUGIN_STATE_CALLED,
|
|
372
|
+
actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
|
|
373
|
+
eventType: _analytics.EVENT_TYPE.OPERATIONAL,
|
|
374
|
+
attributes: {
|
|
375
|
+
plugin: pluginName,
|
|
376
|
+
duration: duration
|
|
377
|
+
}
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
});
|
|
382
|
+
_this6.debounce = null;
|
|
383
|
+
_this6.notAppliedState = {};
|
|
384
|
+
});
|
|
385
|
+
});
|
|
386
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this6), "dispatchAnalyticsEvent", function (payload) {
|
|
387
|
+
var eventDispatcher = _this6.getEventDispatcher();
|
|
388
|
+
if (eventDispatcher) {
|
|
389
|
+
var dispatch = (0, _eventDispatcher.createDispatch)(eventDispatcher);
|
|
390
|
+
dispatch(_utils.analyticsEventKey, {
|
|
391
|
+
payload: payload
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this6), "onContextUpdate", function () {
|
|
396
|
+
_this6.subscribe(_this6.props);
|
|
397
|
+
});
|
|
398
|
+
_this6.state = _this6.getPluginsStates(_this6.props.plugins, _this6.getEditorView(props, context));
|
|
399
|
+
return _this6;
|
|
400
|
+
}
|
|
401
|
+
(0, _createClass2.default)(WithPluginStateOld, [{
|
|
402
|
+
key: "getEditorView",
|
|
403
|
+
value: function getEditorView(maybeProps, maybeContext) {
|
|
404
|
+
var props = maybeProps || this.props;
|
|
405
|
+
var context = maybeContext || this.context;
|
|
406
|
+
return props.editorView || context && context.editorActions && context.editorActions._privateGetEditorView() || context && context.editorSharedConfig && context.editorSharedConfig.editorView;
|
|
407
|
+
}
|
|
408
|
+
}, {
|
|
409
|
+
key: "getEventDispatcher",
|
|
410
|
+
value: function getEventDispatcher(maybeProps) {
|
|
411
|
+
var props = maybeProps || this.props;
|
|
412
|
+
return props.eventDispatcher || this.context && this.context.editorActions && this.context.editorActions._privateGetEventDispatcher() || this.context && this.context.editorSharedConfig && this.context.editorSharedConfig.eventDispatcher;
|
|
413
|
+
}
|
|
414
|
+
}, {
|
|
415
|
+
key: "getPluginsStates",
|
|
416
|
+
value: function getPluginsStates(plugins, editorView) {
|
|
417
|
+
if (!editorView || !plugins) {
|
|
418
|
+
return {};
|
|
419
|
+
}
|
|
420
|
+
var keys = Object.keys(plugins);
|
|
421
|
+
return keys.reduce(function (acc, propName) {
|
|
422
|
+
var pluginKey = plugins[propName];
|
|
423
|
+
if (!pluginKey) {
|
|
424
|
+
return acc;
|
|
425
|
+
}
|
|
426
|
+
acc[propName] = pluginKey.getState(editorView.state);
|
|
427
|
+
return acc;
|
|
428
|
+
}, {});
|
|
429
|
+
}
|
|
430
|
+
}, {
|
|
431
|
+
key: "subscribe",
|
|
432
|
+
value: function subscribe(props) {
|
|
433
|
+
var _uiTracking$samplingR2,
|
|
434
|
+
_uiTracking$slowThres2,
|
|
435
|
+
_this7 = this;
|
|
436
|
+
var plugins = props.plugins;
|
|
437
|
+
var eventDispatcher = this.getEventDispatcher(props);
|
|
438
|
+
var editorView = this.getEditorView(props);
|
|
439
|
+
if (!eventDispatcher || !editorView || this.isSubscribed) {
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
// TODO: ED-15663
|
|
444
|
+
// Please, do not copy or use this kind of code below
|
|
445
|
+
// @ts-ignore
|
|
446
|
+
var fakePluginKey = {
|
|
447
|
+
key: 'analyticsPlugin$',
|
|
448
|
+
getState: function getState(state) {
|
|
449
|
+
return state['analyticsPlugin$'];
|
|
450
|
+
}
|
|
451
|
+
};
|
|
452
|
+
var analyticsPlugin = fakePluginKey.getState(editorView.state);
|
|
453
|
+
var uiTracking = analyticsPlugin && analyticsPlugin.performanceTracking ? analyticsPlugin.performanceTracking.uiTracking || {} : {};
|
|
454
|
+
var trackingEnabled = uiTracking.enabled === true;
|
|
455
|
+
var samplingRate = (_uiTracking$samplingR2 = uiTracking.samplingRate) !== null && _uiTracking$samplingR2 !== void 0 ? _uiTracking$samplingR2 : DEFAULT_SAMPLING_RATE;
|
|
456
|
+
var slowThreshold = (_uiTracking$slowThres2 = uiTracking.slowThreshold) !== null && _uiTracking$slowThres2 !== void 0 ? _uiTracking$slowThres2 : DEFAULT_SLOW_THRESHOLD;
|
|
457
|
+
this.isSubscribed = true;
|
|
458
|
+
var pluginsStates = this.getPluginsStates(plugins, editorView);
|
|
459
|
+
this.setState(pluginsStates);
|
|
460
|
+
Object.keys(plugins).forEach(function (propName) {
|
|
461
|
+
var pluginKey = plugins[propName];
|
|
462
|
+
if (!pluginKey) {
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
var pluginName = pluginKey.key;
|
|
466
|
+
var pluginState = pluginsStates[propName];
|
|
467
|
+
var isPluginWithSubscribe = pluginState && pluginState.subscribe;
|
|
468
|
+
var handler = _this7.handlePluginStateChange(propName, pluginName, {
|
|
469
|
+
samplingRate: samplingRate,
|
|
470
|
+
slowThreshold: slowThreshold,
|
|
471
|
+
trackingEnabled: trackingEnabled
|
|
472
|
+
}, isPluginWithSubscribe);
|
|
473
|
+
if (isPluginWithSubscribe) {
|
|
474
|
+
pluginState.subscribe(handler);
|
|
475
|
+
} else {
|
|
476
|
+
eventDispatcher.on(pluginKey.key, handler);
|
|
477
|
+
}
|
|
478
|
+
_this7.listeners[pluginKey.key] = {
|
|
479
|
+
handler: handler,
|
|
480
|
+
pluginKey: pluginKey
|
|
481
|
+
};
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
}, {
|
|
485
|
+
key: "unsubscribe",
|
|
486
|
+
value: function unsubscribe() {
|
|
487
|
+
var _this8 = this;
|
|
488
|
+
var eventDispatcher = this.getEventDispatcher();
|
|
489
|
+
var editorView = this.getEditorView();
|
|
490
|
+
if (!eventDispatcher || !editorView || !this.isSubscribed) {
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
Object.keys(this.listeners).forEach(function (key) {
|
|
494
|
+
var pluginState = _this8.listeners[key].pluginKey.getState(editorView.state);
|
|
495
|
+
if (pluginState && pluginState.unsubscribe) {
|
|
496
|
+
pluginState.unsubscribe(_this8.listeners[key].handler);
|
|
497
|
+
} else {
|
|
498
|
+
eventDispatcher.off(key, _this8.listeners[key].handler);
|
|
499
|
+
}
|
|
500
|
+
});
|
|
501
|
+
this.listeners = [];
|
|
502
|
+
}
|
|
248
503
|
}, {
|
|
249
504
|
key: "subscribeToContextUpdates",
|
|
250
505
|
value: function subscribeToContextUpdates(context) {
|
|
@@ -288,10 +543,10 @@ var WithPluginState = exports.WithPluginState = /*#__PURE__*/function (_React$Co
|
|
|
288
543
|
return render(this.state);
|
|
289
544
|
}
|
|
290
545
|
}]);
|
|
291
|
-
return
|
|
546
|
+
return WithPluginStateOld;
|
|
292
547
|
}(_react.default.Component);
|
|
293
|
-
(0, _defineProperty2.default)(
|
|
294
|
-
(0, _defineProperty2.default)(
|
|
548
|
+
(0, _defineProperty2.default)(WithPluginStateOld, "displayName", 'WithPluginState');
|
|
549
|
+
(0, _defineProperty2.default)(WithPluginStateOld, "contextTypes", {
|
|
295
550
|
editorActions: _propTypes.default.object,
|
|
296
551
|
editorSharedConfig: _propTypes.default.object
|
|
297
552
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isFedRamp } from './environment';
|
|
2
2
|
const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
3
3
|
const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
4
|
-
const packageVersion = "93.4.
|
|
4
|
+
const packageVersion = "93.4.4";
|
|
5
5
|
const sanitiseSentryEvents = (data, _hint) => {
|
|
6
6
|
// Remove URL as it has UGC
|
|
7
7
|
// TODO: Sanitise the URL instead of just removing it
|
|
@@ -13,7 +13,7 @@ import withAnalyticsContext from '@atlaskit/analytics-next/withAnalyticsContext'
|
|
|
13
13
|
import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
|
|
14
14
|
import Layer from '../Layer';
|
|
15
15
|
const packageName = "@atlaskit/editor-common";
|
|
16
|
-
const packageVersion = "93.4.
|
|
16
|
+
const packageVersion = "93.4.4";
|
|
17
17
|
const halfFocusRing = 1;
|
|
18
18
|
const dropOffset = '0, 8';
|
|
19
19
|
class DropList extends Component {
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
3
|
import React from 'react';
|
|
3
4
|
import PropTypes from 'prop-types';
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
6
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '../analytics';
|
|
5
7
|
import { createDispatch } from '../event-dispatcher';
|
|
6
8
|
import { startMeasure, stopMeasure } from '../performance-measures';
|
|
9
|
+
import { EditorContext } from '../ui/EditorContext';
|
|
7
10
|
import { analyticsEventKey } from '../utils';
|
|
8
11
|
const DEFAULT_SAMPLING_RATE = 100;
|
|
9
12
|
const DEFAULT_SLOW_THRESHOLD = 4;
|
|
@@ -50,6 +53,215 @@ const DEFAULT_SLOW_THRESHOLD = 4;
|
|
|
50
53
|
*
|
|
51
54
|
*/
|
|
52
55
|
class WithPluginState extends React.Component {
|
|
56
|
+
constructor(props) {
|
|
57
|
+
super(props);
|
|
58
|
+
}
|
|
59
|
+
render() {
|
|
60
|
+
if (fg('platform_editor_react18_phase2')) {
|
|
61
|
+
return /*#__PURE__*/React.createElement(WithPluginStateNew, this.props);
|
|
62
|
+
}
|
|
63
|
+
return /*#__PURE__*/React.createElement(WithPluginStateOld, this.props);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function WithPluginStateNew(props) {
|
|
67
|
+
const context = React.useContext(EditorContext);
|
|
68
|
+
return /*#__PURE__*/React.createElement(WithPluginStateInner, _extends({}, props, {
|
|
69
|
+
editorActions: context === null || context === void 0 ? void 0 : context.editorActions
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
export class WithPluginStateInner extends React.Component {
|
|
73
|
+
constructor(props) {
|
|
74
|
+
super(props);
|
|
75
|
+
_defineProperty(this, "listeners", {});
|
|
76
|
+
_defineProperty(this, "debounce", null);
|
|
77
|
+
_defineProperty(this, "notAppliedState", {});
|
|
78
|
+
_defineProperty(this, "isSubscribed", false);
|
|
79
|
+
_defineProperty(this, "callsCount", 0);
|
|
80
|
+
_defineProperty(this, "handlePluginStateChange", (propName, pluginName, performanceOptions, skipEqualityCheck) => pluginState => {
|
|
81
|
+
// skipEqualityCheck is being used for old plugins since they are mutating plugin state instead of creating a new one
|
|
82
|
+
if (this.state[propName] !== pluginState || skipEqualityCheck) {
|
|
83
|
+
this.updateState({
|
|
84
|
+
stateSubset: {
|
|
85
|
+
[propName]: pluginState
|
|
86
|
+
},
|
|
87
|
+
pluginName,
|
|
88
|
+
performanceOptions
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
/**
|
|
93
|
+
* Debounces setState calls in order to reduce number of re-renders caused by several plugin state changes.
|
|
94
|
+
*/
|
|
95
|
+
_defineProperty(this, "updateState", ({
|
|
96
|
+
stateSubset,
|
|
97
|
+
pluginName,
|
|
98
|
+
performanceOptions
|
|
99
|
+
}) => {
|
|
100
|
+
this.notAppliedState = {
|
|
101
|
+
...this.notAppliedState,
|
|
102
|
+
...stateSubset
|
|
103
|
+
};
|
|
104
|
+
if (this.debounce) {
|
|
105
|
+
window.clearTimeout(this.debounce);
|
|
106
|
+
}
|
|
107
|
+
const debounce = this.props.debounce !== false ? fn => window.setTimeout(fn, 0) : fn => fn();
|
|
108
|
+
this.debounce = debounce(() => {
|
|
109
|
+
const measure = `🦉${pluginName}::WithPluginState`;
|
|
110
|
+
performanceOptions.trackingEnabled && startMeasure(measure);
|
|
111
|
+
this.setState(this.notAppliedState, () => {
|
|
112
|
+
performanceOptions.trackingEnabled && stopMeasure(measure, duration => {
|
|
113
|
+
// Each WithPluginState component will fire analytics event no more than once every `samplingLimit` times
|
|
114
|
+
if (++this.callsCount % performanceOptions.samplingRate === 0 && duration > performanceOptions.slowThreshold) {
|
|
115
|
+
this.dispatchAnalyticsEvent({
|
|
116
|
+
action: ACTION.WITH_PLUGIN_STATE_CALLED,
|
|
117
|
+
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
118
|
+
eventType: EVENT_TYPE.OPERATIONAL,
|
|
119
|
+
attributes: {
|
|
120
|
+
plugin: pluginName,
|
|
121
|
+
duration
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
this.debounce = null;
|
|
128
|
+
this.notAppliedState = {};
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
_defineProperty(this, "dispatchAnalyticsEvent", payload => {
|
|
132
|
+
const eventDispatcher = this.getEventDispatcher();
|
|
133
|
+
if (eventDispatcher) {
|
|
134
|
+
const dispatch = createDispatch(eventDispatcher);
|
|
135
|
+
dispatch(analyticsEventKey, {
|
|
136
|
+
payload
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
this.state = this.getPluginsStates(this.props.plugins, this.getEditorView(props));
|
|
141
|
+
}
|
|
142
|
+
getEditorView(maybeProps) {
|
|
143
|
+
const props = maybeProps || this.props;
|
|
144
|
+
const editorActions = props.editorActions;
|
|
145
|
+
return props.editorView || (editorActions === null || editorActions === void 0 ? void 0 : editorActions._privateGetEditorView());
|
|
146
|
+
}
|
|
147
|
+
getEventDispatcher(maybeProps) {
|
|
148
|
+
var _props$editorActions;
|
|
149
|
+
const props = maybeProps || this.props;
|
|
150
|
+
return props.eventDispatcher || ((_props$editorActions = props.editorActions) === null || _props$editorActions === void 0 ? void 0 : _props$editorActions._privateGetEventDispatcher());
|
|
151
|
+
}
|
|
152
|
+
getPluginsStates(plugins, editorView) {
|
|
153
|
+
if (!editorView || !plugins) {
|
|
154
|
+
return {};
|
|
155
|
+
}
|
|
156
|
+
const keys = Object.keys(plugins);
|
|
157
|
+
return keys.reduce((acc, propName) => {
|
|
158
|
+
const pluginKey = plugins[propName];
|
|
159
|
+
if (!pluginKey) {
|
|
160
|
+
return acc;
|
|
161
|
+
}
|
|
162
|
+
acc[propName] = pluginKey.getState(editorView.state);
|
|
163
|
+
return acc;
|
|
164
|
+
}, {});
|
|
165
|
+
}
|
|
166
|
+
subscribe(props) {
|
|
167
|
+
var _uiTracking$samplingR, _uiTracking$slowThres;
|
|
168
|
+
const plugins = props.plugins;
|
|
169
|
+
const eventDispatcher = this.getEventDispatcher(props);
|
|
170
|
+
const editorView = this.getEditorView(props);
|
|
171
|
+
if (!eventDispatcher || !editorView || this.isSubscribed) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// TODO: ED-15663
|
|
176
|
+
// Please, do not copy or use this kind of code below
|
|
177
|
+
// @ts-ignore
|
|
178
|
+
const fakePluginKey = {
|
|
179
|
+
key: 'analyticsPlugin$',
|
|
180
|
+
getState: state => {
|
|
181
|
+
return state['analyticsPlugin$'];
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
const analyticsPlugin = fakePluginKey.getState(editorView.state);
|
|
185
|
+
const uiTracking = analyticsPlugin && analyticsPlugin.performanceTracking ? analyticsPlugin.performanceTracking.uiTracking || {} : {};
|
|
186
|
+
const trackingEnabled = uiTracking.enabled === true;
|
|
187
|
+
const samplingRate = (_uiTracking$samplingR = uiTracking.samplingRate) !== null && _uiTracking$samplingR !== void 0 ? _uiTracking$samplingR : DEFAULT_SAMPLING_RATE;
|
|
188
|
+
const slowThreshold = (_uiTracking$slowThres = uiTracking.slowThreshold) !== null && _uiTracking$slowThres !== void 0 ? _uiTracking$slowThres : DEFAULT_SLOW_THRESHOLD;
|
|
189
|
+
this.isSubscribed = true;
|
|
190
|
+
const pluginsStates = this.getPluginsStates(plugins, editorView);
|
|
191
|
+
this.setState(pluginsStates);
|
|
192
|
+
Object.keys(plugins).forEach(propName => {
|
|
193
|
+
const pluginKey = plugins[propName];
|
|
194
|
+
if (!pluginKey) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
const pluginName = pluginKey.key;
|
|
198
|
+
const pluginState = pluginsStates[propName];
|
|
199
|
+
const isPluginWithSubscribe = pluginState && pluginState.subscribe;
|
|
200
|
+
const handler = this.handlePluginStateChange(propName, pluginName, {
|
|
201
|
+
samplingRate,
|
|
202
|
+
slowThreshold,
|
|
203
|
+
trackingEnabled
|
|
204
|
+
}, isPluginWithSubscribe);
|
|
205
|
+
if (isPluginWithSubscribe) {
|
|
206
|
+
pluginState.subscribe(handler);
|
|
207
|
+
} else {
|
|
208
|
+
eventDispatcher.on(pluginKey.key, handler);
|
|
209
|
+
}
|
|
210
|
+
this.listeners[pluginKey.key] = {
|
|
211
|
+
handler,
|
|
212
|
+
pluginKey
|
|
213
|
+
};
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
unsubscribe() {
|
|
217
|
+
const eventDispatcher = this.getEventDispatcher();
|
|
218
|
+
const editorView = this.getEditorView();
|
|
219
|
+
if (!eventDispatcher || !editorView || !this.isSubscribed) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
Object.keys(this.listeners).forEach(key => {
|
|
223
|
+
const pluginState = this.listeners[key].pluginKey.getState(editorView.state);
|
|
224
|
+
if (pluginState && pluginState.unsubscribe) {
|
|
225
|
+
pluginState.unsubscribe(this.listeners[key].handler);
|
|
226
|
+
} else {
|
|
227
|
+
eventDispatcher.off(key, this.listeners[key].handler);
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
this.listeners = [];
|
|
231
|
+
}
|
|
232
|
+
subscribeToContextUpdates() {
|
|
233
|
+
var _this$props$editorAct;
|
|
234
|
+
(_this$props$editorAct = this.props.editorActions) === null || _this$props$editorAct === void 0 ? void 0 : _this$props$editorAct._privateSubscribe(() => this.subscribe(this.props));
|
|
235
|
+
}
|
|
236
|
+
unsubscribeFromContextUpdates() {
|
|
237
|
+
var _this$props$editorAct2;
|
|
238
|
+
(_this$props$editorAct2 = this.props.editorActions) === null || _this$props$editorAct2 === void 0 ? void 0 : _this$props$editorAct2._privateUnsubscribe(() => this.subscribe(this.props));
|
|
239
|
+
}
|
|
240
|
+
componentDidMount() {
|
|
241
|
+
this.subscribe(this.props);
|
|
242
|
+
this.subscribeToContextUpdates();
|
|
243
|
+
}
|
|
244
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
245
|
+
if (!this.isSubscribed) {
|
|
246
|
+
this.subscribe(nextProps);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
componentWillUnmount() {
|
|
250
|
+
if (this.debounce) {
|
|
251
|
+
window.clearTimeout(this.debounce);
|
|
252
|
+
}
|
|
253
|
+
this.unsubscribeFromContextUpdates();
|
|
254
|
+
this.unsubscribe();
|
|
255
|
+
}
|
|
256
|
+
render() {
|
|
257
|
+
const {
|
|
258
|
+
render
|
|
259
|
+
} = this.props;
|
|
260
|
+
return render(this.state);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
_defineProperty(WithPluginStateInner, "displayName", 'WithPluginState');
|
|
264
|
+
export class WithPluginStateOld extends React.Component {
|
|
53
265
|
constructor(props, context) {
|
|
54
266
|
super(props, context);
|
|
55
267
|
_defineProperty(this, "listeners", {});
|
|
@@ -146,7 +358,7 @@ class WithPluginState extends React.Component {
|
|
|
146
358
|
}, {});
|
|
147
359
|
}
|
|
148
360
|
subscribe(props) {
|
|
149
|
-
var _uiTracking$
|
|
361
|
+
var _uiTracking$samplingR2, _uiTracking$slowThres2;
|
|
150
362
|
const plugins = props.plugins;
|
|
151
363
|
const eventDispatcher = this.getEventDispatcher(props);
|
|
152
364
|
const editorView = this.getEditorView(props);
|
|
@@ -166,8 +378,8 @@ class WithPluginState extends React.Component {
|
|
|
166
378
|
const analyticsPlugin = fakePluginKey.getState(editorView.state);
|
|
167
379
|
const uiTracking = analyticsPlugin && analyticsPlugin.performanceTracking ? analyticsPlugin.performanceTracking.uiTracking || {} : {};
|
|
168
380
|
const trackingEnabled = uiTracking.enabled === true;
|
|
169
|
-
const samplingRate = (_uiTracking$
|
|
170
|
-
const slowThreshold = (_uiTracking$
|
|
381
|
+
const samplingRate = (_uiTracking$samplingR2 = uiTracking.samplingRate) !== null && _uiTracking$samplingR2 !== void 0 ? _uiTracking$samplingR2 : DEFAULT_SAMPLING_RATE;
|
|
382
|
+
const slowThreshold = (_uiTracking$slowThres2 = uiTracking.slowThreshold) !== null && _uiTracking$slowThres2 !== void 0 ? _uiTracking$slowThres2 : DEFAULT_SLOW_THRESHOLD;
|
|
171
383
|
this.isSubscribed = true;
|
|
172
384
|
const pluginsStates = this.getPluginsStates(plugins, editorView);
|
|
173
385
|
this.setState(pluginsStates);
|
|
@@ -244,8 +456,8 @@ class WithPluginState extends React.Component {
|
|
|
244
456
|
return render(this.state);
|
|
245
457
|
}
|
|
246
458
|
}
|
|
247
|
-
_defineProperty(
|
|
248
|
-
_defineProperty(
|
|
459
|
+
_defineProperty(WithPluginStateOld, "displayName", 'WithPluginState');
|
|
460
|
+
_defineProperty(WithPluginStateOld, "contextTypes", {
|
|
249
461
|
editorActions: PropTypes.object,
|
|
250
462
|
editorSharedConfig: PropTypes.object
|
|
251
463
|
});
|
|
@@ -7,7 +7,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
7
7
|
import { isFedRamp } from './environment';
|
|
8
8
|
var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
9
9
|
var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
10
|
-
var packageVersion = "93.4.
|
|
10
|
+
var packageVersion = "93.4.4";
|
|
11
11
|
var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
|
|
12
12
|
// Remove URL as it has UGC
|
|
13
13
|
// TODO: Sanitise the URL instead of just removing it
|
|
@@ -21,7 +21,7 @@ import withAnalyticsContext from '@atlaskit/analytics-next/withAnalyticsContext'
|
|
|
21
21
|
import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
|
|
22
22
|
import Layer from '../Layer';
|
|
23
23
|
var packageName = "@atlaskit/editor-common";
|
|
24
|
-
var packageVersion = "93.4.
|
|
24
|
+
var packageVersion = "93.4.4";
|
|
25
25
|
var halfFocusRing = 1;
|
|
26
26
|
var dropOffset = '0, 8';
|
|
27
27
|
var DropList = /*#__PURE__*/function (_Component) {
|
|
@@ -1,19 +1,22 @@
|
|
|
1
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
1
4
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
5
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
6
|
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
7
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
8
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
9
|
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; }
|
|
9
10
|
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; }
|
|
10
11
|
function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
|
|
11
12
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
12
13
|
import React from 'react';
|
|
13
14
|
import PropTypes from 'prop-types';
|
|
15
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
14
16
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '../analytics';
|
|
15
17
|
import { createDispatch } from '../event-dispatcher';
|
|
16
18
|
import { startMeasure, stopMeasure } from '../performance-measures';
|
|
19
|
+
import { EditorContext } from '../ui/EditorContext';
|
|
17
20
|
import { analyticsEventKey } from '../utils';
|
|
18
21
|
var DEFAULT_SAMPLING_RATE = 100;
|
|
19
22
|
var DEFAULT_SLOW_THRESHOLD = 4;
|
|
@@ -61,10 +64,34 @@ var DEFAULT_SLOW_THRESHOLD = 4;
|
|
|
61
64
|
var WithPluginState = /*#__PURE__*/function (_React$Component) {
|
|
62
65
|
_inherits(WithPluginState, _React$Component);
|
|
63
66
|
var _super = _createSuper(WithPluginState);
|
|
64
|
-
function WithPluginState(props
|
|
65
|
-
var _this;
|
|
67
|
+
function WithPluginState(props) {
|
|
66
68
|
_classCallCheck(this, WithPluginState);
|
|
67
|
-
|
|
69
|
+
return _super.call(this, props);
|
|
70
|
+
}
|
|
71
|
+
_createClass(WithPluginState, [{
|
|
72
|
+
key: "render",
|
|
73
|
+
value: function render() {
|
|
74
|
+
if (fg('platform_editor_react18_phase2')) {
|
|
75
|
+
return /*#__PURE__*/React.createElement(WithPluginStateNew, this.props);
|
|
76
|
+
}
|
|
77
|
+
return /*#__PURE__*/React.createElement(WithPluginStateOld, this.props);
|
|
78
|
+
}
|
|
79
|
+
}]);
|
|
80
|
+
return WithPluginState;
|
|
81
|
+
}(React.Component);
|
|
82
|
+
function WithPluginStateNew(props) {
|
|
83
|
+
var context = React.useContext(EditorContext);
|
|
84
|
+
return /*#__PURE__*/React.createElement(WithPluginStateInner, _extends({}, props, {
|
|
85
|
+
editorActions: context === null || context === void 0 ? void 0 : context.editorActions
|
|
86
|
+
}));
|
|
87
|
+
}
|
|
88
|
+
export var WithPluginStateInner = /*#__PURE__*/function (_React$Component2) {
|
|
89
|
+
_inherits(WithPluginStateInner, _React$Component2);
|
|
90
|
+
var _super2 = _createSuper(WithPluginStateInner);
|
|
91
|
+
function WithPluginStateInner(props) {
|
|
92
|
+
var _this;
|
|
93
|
+
_classCallCheck(this, WithPluginStateInner);
|
|
94
|
+
_this = _super2.call(this, props);
|
|
68
95
|
_defineProperty(_assertThisInitialized(_this), "listeners", {});
|
|
69
96
|
_defineProperty(_assertThisInitialized(_this), "debounce", null);
|
|
70
97
|
_defineProperty(_assertThisInitialized(_this), "notAppliedState", {});
|
|
@@ -130,24 +157,22 @@ var WithPluginState = /*#__PURE__*/function (_React$Component) {
|
|
|
130
157
|
});
|
|
131
158
|
}
|
|
132
159
|
});
|
|
133
|
-
|
|
134
|
-
_this.subscribe(_this.props);
|
|
135
|
-
});
|
|
136
|
-
_this.state = _this.getPluginsStates(_this.props.plugins, _this.getEditorView(props, context));
|
|
160
|
+
_this.state = _this.getPluginsStates(_this.props.plugins, _this.getEditorView(props));
|
|
137
161
|
return _this;
|
|
138
162
|
}
|
|
139
|
-
_createClass(
|
|
163
|
+
_createClass(WithPluginStateInner, [{
|
|
140
164
|
key: "getEditorView",
|
|
141
|
-
value: function getEditorView(maybeProps
|
|
165
|
+
value: function getEditorView(maybeProps) {
|
|
142
166
|
var props = maybeProps || this.props;
|
|
143
|
-
var
|
|
144
|
-
return props.editorView ||
|
|
167
|
+
var editorActions = props.editorActions;
|
|
168
|
+
return props.editorView || (editorActions === null || editorActions === void 0 ? void 0 : editorActions._privateGetEditorView());
|
|
145
169
|
}
|
|
146
170
|
}, {
|
|
147
171
|
key: "getEventDispatcher",
|
|
148
172
|
value: function getEventDispatcher(maybeProps) {
|
|
173
|
+
var _props$editorActions;
|
|
149
174
|
var props = maybeProps || this.props;
|
|
150
|
-
return props.eventDispatcher ||
|
|
175
|
+
return props.eventDispatcher || ((_props$editorActions = props.editorActions) === null || _props$editorActions === void 0 ? void 0 : _props$editorActions._privateGetEventDispatcher());
|
|
151
176
|
}
|
|
152
177
|
}, {
|
|
153
178
|
key: "getPluginsStates",
|
|
@@ -238,6 +263,236 @@ var WithPluginState = /*#__PURE__*/function (_React$Component) {
|
|
|
238
263
|
});
|
|
239
264
|
this.listeners = [];
|
|
240
265
|
}
|
|
266
|
+
}, {
|
|
267
|
+
key: "subscribeToContextUpdates",
|
|
268
|
+
value: function subscribeToContextUpdates() {
|
|
269
|
+
var _this$props$editorAct,
|
|
270
|
+
_this4 = this;
|
|
271
|
+
(_this$props$editorAct = this.props.editorActions) === null || _this$props$editorAct === void 0 || _this$props$editorAct._privateSubscribe(function () {
|
|
272
|
+
return _this4.subscribe(_this4.props);
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
}, {
|
|
276
|
+
key: "unsubscribeFromContextUpdates",
|
|
277
|
+
value: function unsubscribeFromContextUpdates() {
|
|
278
|
+
var _this$props$editorAct2,
|
|
279
|
+
_this5 = this;
|
|
280
|
+
(_this$props$editorAct2 = this.props.editorActions) === null || _this$props$editorAct2 === void 0 || _this$props$editorAct2._privateUnsubscribe(function () {
|
|
281
|
+
return _this5.subscribe(_this5.props);
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
}, {
|
|
285
|
+
key: "componentDidMount",
|
|
286
|
+
value: function componentDidMount() {
|
|
287
|
+
this.subscribe(this.props);
|
|
288
|
+
this.subscribeToContextUpdates();
|
|
289
|
+
}
|
|
290
|
+
}, {
|
|
291
|
+
key: "UNSAFE_componentWillReceiveProps",
|
|
292
|
+
value: function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
293
|
+
if (!this.isSubscribed) {
|
|
294
|
+
this.subscribe(nextProps);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}, {
|
|
298
|
+
key: "componentWillUnmount",
|
|
299
|
+
value: function componentWillUnmount() {
|
|
300
|
+
if (this.debounce) {
|
|
301
|
+
window.clearTimeout(this.debounce);
|
|
302
|
+
}
|
|
303
|
+
this.unsubscribeFromContextUpdates();
|
|
304
|
+
this.unsubscribe();
|
|
305
|
+
}
|
|
306
|
+
}, {
|
|
307
|
+
key: "render",
|
|
308
|
+
value: function render() {
|
|
309
|
+
var render = this.props.render;
|
|
310
|
+
return render(this.state);
|
|
311
|
+
}
|
|
312
|
+
}]);
|
|
313
|
+
return WithPluginStateInner;
|
|
314
|
+
}(React.Component);
|
|
315
|
+
_defineProperty(WithPluginStateInner, "displayName", 'WithPluginState');
|
|
316
|
+
export var WithPluginStateOld = /*#__PURE__*/function (_React$Component3) {
|
|
317
|
+
_inherits(WithPluginStateOld, _React$Component3);
|
|
318
|
+
var _super3 = _createSuper(WithPluginStateOld);
|
|
319
|
+
function WithPluginStateOld(props, context) {
|
|
320
|
+
var _this6;
|
|
321
|
+
_classCallCheck(this, WithPluginStateOld);
|
|
322
|
+
_this6 = _super3.call(this, props, context);
|
|
323
|
+
_defineProperty(_assertThisInitialized(_this6), "listeners", {});
|
|
324
|
+
_defineProperty(_assertThisInitialized(_this6), "debounce", null);
|
|
325
|
+
_defineProperty(_assertThisInitialized(_this6), "notAppliedState", {});
|
|
326
|
+
_defineProperty(_assertThisInitialized(_this6), "isSubscribed", false);
|
|
327
|
+
_defineProperty(_assertThisInitialized(_this6), "callsCount", 0);
|
|
328
|
+
_defineProperty(_assertThisInitialized(_this6), "handlePluginStateChange", function (propName, pluginName, performanceOptions, skipEqualityCheck) {
|
|
329
|
+
return function (pluginState) {
|
|
330
|
+
// skipEqualityCheck is being used for old plugins since they are mutating plugin state instead of creating a new one
|
|
331
|
+
if (_this6.state[propName] !== pluginState || skipEqualityCheck) {
|
|
332
|
+
_this6.updateState({
|
|
333
|
+
stateSubset: _defineProperty({}, propName, pluginState),
|
|
334
|
+
pluginName: pluginName,
|
|
335
|
+
performanceOptions: performanceOptions
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
});
|
|
340
|
+
/**
|
|
341
|
+
* Debounces setState calls in order to reduce number of re-renders caused by several plugin state changes.
|
|
342
|
+
*/
|
|
343
|
+
_defineProperty(_assertThisInitialized(_this6), "updateState", function (_ref2) {
|
|
344
|
+
var stateSubset = _ref2.stateSubset,
|
|
345
|
+
pluginName = _ref2.pluginName,
|
|
346
|
+
performanceOptions = _ref2.performanceOptions;
|
|
347
|
+
_this6.notAppliedState = _objectSpread(_objectSpread({}, _this6.notAppliedState), stateSubset);
|
|
348
|
+
if (_this6.debounce) {
|
|
349
|
+
window.clearTimeout(_this6.debounce);
|
|
350
|
+
}
|
|
351
|
+
var debounce = _this6.props.debounce !== false ? function (fn) {
|
|
352
|
+
return window.setTimeout(fn, 0);
|
|
353
|
+
} : function (fn) {
|
|
354
|
+
return fn();
|
|
355
|
+
};
|
|
356
|
+
_this6.debounce = debounce(function () {
|
|
357
|
+
var measure = "\uD83E\uDD89".concat(pluginName, "::WithPluginState");
|
|
358
|
+
performanceOptions.trackingEnabled && startMeasure(measure);
|
|
359
|
+
_this6.setState(_this6.notAppliedState, function () {
|
|
360
|
+
performanceOptions.trackingEnabled && stopMeasure(measure, function (duration) {
|
|
361
|
+
// Each WithPluginState component will fire analytics event no more than once every `samplingLimit` times
|
|
362
|
+
if (++_this6.callsCount % performanceOptions.samplingRate === 0 && duration > performanceOptions.slowThreshold) {
|
|
363
|
+
_this6.dispatchAnalyticsEvent({
|
|
364
|
+
action: ACTION.WITH_PLUGIN_STATE_CALLED,
|
|
365
|
+
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
366
|
+
eventType: EVENT_TYPE.OPERATIONAL,
|
|
367
|
+
attributes: {
|
|
368
|
+
plugin: pluginName,
|
|
369
|
+
duration: duration
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
});
|
|
375
|
+
_this6.debounce = null;
|
|
376
|
+
_this6.notAppliedState = {};
|
|
377
|
+
});
|
|
378
|
+
});
|
|
379
|
+
_defineProperty(_assertThisInitialized(_this6), "dispatchAnalyticsEvent", function (payload) {
|
|
380
|
+
var eventDispatcher = _this6.getEventDispatcher();
|
|
381
|
+
if (eventDispatcher) {
|
|
382
|
+
var dispatch = createDispatch(eventDispatcher);
|
|
383
|
+
dispatch(analyticsEventKey, {
|
|
384
|
+
payload: payload
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
});
|
|
388
|
+
_defineProperty(_assertThisInitialized(_this6), "onContextUpdate", function () {
|
|
389
|
+
_this6.subscribe(_this6.props);
|
|
390
|
+
});
|
|
391
|
+
_this6.state = _this6.getPluginsStates(_this6.props.plugins, _this6.getEditorView(props, context));
|
|
392
|
+
return _this6;
|
|
393
|
+
}
|
|
394
|
+
_createClass(WithPluginStateOld, [{
|
|
395
|
+
key: "getEditorView",
|
|
396
|
+
value: function getEditorView(maybeProps, maybeContext) {
|
|
397
|
+
var props = maybeProps || this.props;
|
|
398
|
+
var context = maybeContext || this.context;
|
|
399
|
+
return props.editorView || context && context.editorActions && context.editorActions._privateGetEditorView() || context && context.editorSharedConfig && context.editorSharedConfig.editorView;
|
|
400
|
+
}
|
|
401
|
+
}, {
|
|
402
|
+
key: "getEventDispatcher",
|
|
403
|
+
value: function getEventDispatcher(maybeProps) {
|
|
404
|
+
var props = maybeProps || this.props;
|
|
405
|
+
return props.eventDispatcher || this.context && this.context.editorActions && this.context.editorActions._privateGetEventDispatcher() || this.context && this.context.editorSharedConfig && this.context.editorSharedConfig.eventDispatcher;
|
|
406
|
+
}
|
|
407
|
+
}, {
|
|
408
|
+
key: "getPluginsStates",
|
|
409
|
+
value: function getPluginsStates(plugins, editorView) {
|
|
410
|
+
if (!editorView || !plugins) {
|
|
411
|
+
return {};
|
|
412
|
+
}
|
|
413
|
+
var keys = Object.keys(plugins);
|
|
414
|
+
return keys.reduce(function (acc, propName) {
|
|
415
|
+
var pluginKey = plugins[propName];
|
|
416
|
+
if (!pluginKey) {
|
|
417
|
+
return acc;
|
|
418
|
+
}
|
|
419
|
+
acc[propName] = pluginKey.getState(editorView.state);
|
|
420
|
+
return acc;
|
|
421
|
+
}, {});
|
|
422
|
+
}
|
|
423
|
+
}, {
|
|
424
|
+
key: "subscribe",
|
|
425
|
+
value: function subscribe(props) {
|
|
426
|
+
var _uiTracking$samplingR2,
|
|
427
|
+
_uiTracking$slowThres2,
|
|
428
|
+
_this7 = this;
|
|
429
|
+
var plugins = props.plugins;
|
|
430
|
+
var eventDispatcher = this.getEventDispatcher(props);
|
|
431
|
+
var editorView = this.getEditorView(props);
|
|
432
|
+
if (!eventDispatcher || !editorView || this.isSubscribed) {
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
// TODO: ED-15663
|
|
437
|
+
// Please, do not copy or use this kind of code below
|
|
438
|
+
// @ts-ignore
|
|
439
|
+
var fakePluginKey = {
|
|
440
|
+
key: 'analyticsPlugin$',
|
|
441
|
+
getState: function getState(state) {
|
|
442
|
+
return state['analyticsPlugin$'];
|
|
443
|
+
}
|
|
444
|
+
};
|
|
445
|
+
var analyticsPlugin = fakePluginKey.getState(editorView.state);
|
|
446
|
+
var uiTracking = analyticsPlugin && analyticsPlugin.performanceTracking ? analyticsPlugin.performanceTracking.uiTracking || {} : {};
|
|
447
|
+
var trackingEnabled = uiTracking.enabled === true;
|
|
448
|
+
var samplingRate = (_uiTracking$samplingR2 = uiTracking.samplingRate) !== null && _uiTracking$samplingR2 !== void 0 ? _uiTracking$samplingR2 : DEFAULT_SAMPLING_RATE;
|
|
449
|
+
var slowThreshold = (_uiTracking$slowThres2 = uiTracking.slowThreshold) !== null && _uiTracking$slowThres2 !== void 0 ? _uiTracking$slowThres2 : DEFAULT_SLOW_THRESHOLD;
|
|
450
|
+
this.isSubscribed = true;
|
|
451
|
+
var pluginsStates = this.getPluginsStates(plugins, editorView);
|
|
452
|
+
this.setState(pluginsStates);
|
|
453
|
+
Object.keys(plugins).forEach(function (propName) {
|
|
454
|
+
var pluginKey = plugins[propName];
|
|
455
|
+
if (!pluginKey) {
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
var pluginName = pluginKey.key;
|
|
459
|
+
var pluginState = pluginsStates[propName];
|
|
460
|
+
var isPluginWithSubscribe = pluginState && pluginState.subscribe;
|
|
461
|
+
var handler = _this7.handlePluginStateChange(propName, pluginName, {
|
|
462
|
+
samplingRate: samplingRate,
|
|
463
|
+
slowThreshold: slowThreshold,
|
|
464
|
+
trackingEnabled: trackingEnabled
|
|
465
|
+
}, isPluginWithSubscribe);
|
|
466
|
+
if (isPluginWithSubscribe) {
|
|
467
|
+
pluginState.subscribe(handler);
|
|
468
|
+
} else {
|
|
469
|
+
eventDispatcher.on(pluginKey.key, handler);
|
|
470
|
+
}
|
|
471
|
+
_this7.listeners[pluginKey.key] = {
|
|
472
|
+
handler: handler,
|
|
473
|
+
pluginKey: pluginKey
|
|
474
|
+
};
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
}, {
|
|
478
|
+
key: "unsubscribe",
|
|
479
|
+
value: function unsubscribe() {
|
|
480
|
+
var _this8 = this;
|
|
481
|
+
var eventDispatcher = this.getEventDispatcher();
|
|
482
|
+
var editorView = this.getEditorView();
|
|
483
|
+
if (!eventDispatcher || !editorView || !this.isSubscribed) {
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
Object.keys(this.listeners).forEach(function (key) {
|
|
487
|
+
var pluginState = _this8.listeners[key].pluginKey.getState(editorView.state);
|
|
488
|
+
if (pluginState && pluginState.unsubscribe) {
|
|
489
|
+
pluginState.unsubscribe(_this8.listeners[key].handler);
|
|
490
|
+
} else {
|
|
491
|
+
eventDispatcher.off(key, _this8.listeners[key].handler);
|
|
492
|
+
}
|
|
493
|
+
});
|
|
494
|
+
this.listeners = [];
|
|
495
|
+
}
|
|
241
496
|
}, {
|
|
242
497
|
key: "subscribeToContextUpdates",
|
|
243
498
|
value: function subscribeToContextUpdates(context) {
|
|
@@ -281,10 +536,10 @@ var WithPluginState = /*#__PURE__*/function (_React$Component) {
|
|
|
281
536
|
return render(this.state);
|
|
282
537
|
}
|
|
283
538
|
}]);
|
|
284
|
-
return
|
|
539
|
+
return WithPluginStateOld;
|
|
285
540
|
}(React.Component);
|
|
286
|
-
_defineProperty(
|
|
287
|
-
_defineProperty(
|
|
541
|
+
_defineProperty(WithPluginStateOld, "displayName", 'WithPluginState');
|
|
542
|
+
_defineProperty(WithPluginStateOld, "contextTypes", {
|
|
288
543
|
editorActions: PropTypes.object,
|
|
289
544
|
editorSharedConfig: PropTypes.object
|
|
290
545
|
});
|
|
@@ -73,7 +73,41 @@ export interface Props<P extends NamedPluginKeys> {
|
|
|
73
73
|
* ```
|
|
74
74
|
*
|
|
75
75
|
*/
|
|
76
|
-
declare class WithPluginState<P extends NamedPluginKeys> extends React.Component<
|
|
76
|
+
declare class WithPluginState<P extends NamedPluginKeys> extends React.Component<WithPluginStateInnerProps<P>, State> {
|
|
77
|
+
constructor(props: WithPluginStateInnerProps<P>);
|
|
78
|
+
render(): JSX.Element;
|
|
79
|
+
}
|
|
80
|
+
type WithPluginStateInnerProps<P extends NamedPluginKeys> = Props<P> & {
|
|
81
|
+
editorActions?: EditorActionsPrivateAccess;
|
|
82
|
+
};
|
|
83
|
+
export declare class WithPluginStateInner<P extends NamedPluginKeys> extends React.Component<WithPluginStateInnerProps<P>, State> {
|
|
84
|
+
static displayName: string;
|
|
85
|
+
private listeners;
|
|
86
|
+
private debounce;
|
|
87
|
+
private notAppliedState;
|
|
88
|
+
private isSubscribed;
|
|
89
|
+
private callsCount;
|
|
90
|
+
state: NamedPluginStates<P>;
|
|
91
|
+
constructor(props: Props<P>);
|
|
92
|
+
private getEditorView;
|
|
93
|
+
private getEventDispatcher;
|
|
94
|
+
private handlePluginStateChange;
|
|
95
|
+
/**
|
|
96
|
+
* Debounces setState calls in order to reduce number of re-renders caused by several plugin state changes.
|
|
97
|
+
*/
|
|
98
|
+
private updateState;
|
|
99
|
+
private dispatchAnalyticsEvent;
|
|
100
|
+
private getPluginsStates;
|
|
101
|
+
private subscribe;
|
|
102
|
+
private unsubscribe;
|
|
103
|
+
private subscribeToContextUpdates;
|
|
104
|
+
private unsubscribeFromContextUpdates;
|
|
105
|
+
componentDidMount(): void;
|
|
106
|
+
UNSAFE_componentWillReceiveProps(nextProps: Props<P>): void;
|
|
107
|
+
componentWillUnmount(): void;
|
|
108
|
+
render(): React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
|
|
109
|
+
}
|
|
110
|
+
export declare class WithPluginStateOld<P extends NamedPluginKeys> extends React.Component<Props<P>, State> {
|
|
77
111
|
static displayName: string;
|
|
78
112
|
private listeners;
|
|
79
113
|
private debounce;
|
|
@@ -73,7 +73,41 @@ export interface Props<P extends NamedPluginKeys> {
|
|
|
73
73
|
* ```
|
|
74
74
|
*
|
|
75
75
|
*/
|
|
76
|
-
declare class WithPluginState<P extends NamedPluginKeys> extends React.Component<
|
|
76
|
+
declare class WithPluginState<P extends NamedPluginKeys> extends React.Component<WithPluginStateInnerProps<P>, State> {
|
|
77
|
+
constructor(props: WithPluginStateInnerProps<P>);
|
|
78
|
+
render(): JSX.Element;
|
|
79
|
+
}
|
|
80
|
+
type WithPluginStateInnerProps<P extends NamedPluginKeys> = Props<P> & {
|
|
81
|
+
editorActions?: EditorActionsPrivateAccess;
|
|
82
|
+
};
|
|
83
|
+
export declare class WithPluginStateInner<P extends NamedPluginKeys> extends React.Component<WithPluginStateInnerProps<P>, State> {
|
|
84
|
+
static displayName: string;
|
|
85
|
+
private listeners;
|
|
86
|
+
private debounce;
|
|
87
|
+
private notAppliedState;
|
|
88
|
+
private isSubscribed;
|
|
89
|
+
private callsCount;
|
|
90
|
+
state: NamedPluginStates<P>;
|
|
91
|
+
constructor(props: Props<P>);
|
|
92
|
+
private getEditorView;
|
|
93
|
+
private getEventDispatcher;
|
|
94
|
+
private handlePluginStateChange;
|
|
95
|
+
/**
|
|
96
|
+
* Debounces setState calls in order to reduce number of re-renders caused by several plugin state changes.
|
|
97
|
+
*/
|
|
98
|
+
private updateState;
|
|
99
|
+
private dispatchAnalyticsEvent;
|
|
100
|
+
private getPluginsStates;
|
|
101
|
+
private subscribe;
|
|
102
|
+
private unsubscribe;
|
|
103
|
+
private subscribeToContextUpdates;
|
|
104
|
+
private unsubscribeFromContextUpdates;
|
|
105
|
+
componentDidMount(): void;
|
|
106
|
+
UNSAFE_componentWillReceiveProps(nextProps: Props<P>): void;
|
|
107
|
+
componentWillUnmount(): void;
|
|
108
|
+
render(): React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
|
|
109
|
+
}
|
|
110
|
+
export declare class WithPluginStateOld<P extends NamedPluginKeys> extends React.Component<Props<P>, State> {
|
|
77
111
|
static displayName: string;
|
|
78
112
|
private listeners;
|
|
79
113
|
private debounce;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-common",
|
|
3
|
-
"version": "93.4.
|
|
3
|
+
"version": "93.4.4",
|
|
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/"
|
|
@@ -105,7 +105,8 @@
|
|
|
105
105
|
"./intl-error-boundary": "./src/ui/IntlErrorBoundary/index.tsx",
|
|
106
106
|
"./code-block": "./src/code-block/index.ts",
|
|
107
107
|
"./table": "./src/table/index.ts",
|
|
108
|
-
"./lazy-node-view": "./src/lazy-node-view/index.ts"
|
|
108
|
+
"./lazy-node-view": "./src/lazy-node-view/index.ts",
|
|
109
|
+
"./UNSAFE_do_not_use_editor_context": "./src/ui/EditorContext/index.ts"
|
|
109
110
|
},
|
|
110
111
|
"dependencies": {
|
|
111
112
|
"@atlaskit/activity-provider": "^2.4.0",
|