@atlaskit/editor-core 198.4.5 → 198.4.7
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 +23 -0
- package/dist/cjs/create-editor/ReactEditorView.js +0 -4
- package/dist/cjs/create-editor/create-editor.js +4 -26
- package/dist/cjs/create-editor/safe-apply-plugin.js +51 -0
- package/dist/cjs/ui/Appearance/FullPage/FullPageToolbar.js +0 -6
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/create-editor/ReactEditorView.js +0 -4
- package/dist/es2019/create-editor/create-editor.js +3 -22
- package/dist/es2019/create-editor/safe-apply-plugin.js +29 -0
- package/dist/es2019/ui/Appearance/FullPage/FullPageToolbar.js +0 -6
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/create-editor/ReactEditorView.js +0 -4
- package/dist/esm/create-editor/create-editor.js +4 -26
- package/dist/esm/create-editor/safe-apply-plugin.js +44 -0
- package/dist/esm/ui/Appearance/FullPage/FullPageToolbar.js +0 -6
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/create-editor/safe-apply-plugin.d.ts +15 -0
- package/dist/types/types/pm-plugin-list.d.ts +0 -4
- package/dist/types-ts4.5/create-editor/safe-apply-plugin.d.ts +15 -0
- package/dist/types-ts4.5/types/pm-plugin-list.d.ts +0 -4
- package/package.json +10 -11
- package/dist/cjs/utils/performance/instrumented-plugin.js +0 -98
- package/dist/es2019/utils/performance/instrumented-plugin.js +0 -75
- package/dist/esm/utils/performance/instrumented-plugin.js +0 -91
- package/dist/types/utils/performance/instrumented-plugin.d.ts +0 -13
- package/dist/types-ts4.5/utils/performance/instrumented-plugin.d.ts +0 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @atlaskit/editor-core
|
|
2
2
|
|
|
3
|
+
## 198.4.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#150241](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/150241)
|
|
8
|
+
[`11814f141483a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/11814f141483a) -
|
|
9
|
+
ED-24117: remediates extension component for react 18
|
|
10
|
+
- [#150201](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/150201)
|
|
11
|
+
[`b105a16989e99`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b105a16989e99) -
|
|
12
|
+
Cleanup unused instrumentation in core editor
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
15
|
+
## 198.4.6
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [#150606](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/150606)
|
|
20
|
+
[`7680d21f5d481`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/7680d21f5d481) -
|
|
21
|
+
[ED-24257] This change cleans up the feature gate for the main toolbar navigation escape fix.
|
|
22
|
+
- [#150606](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/150606)
|
|
23
|
+
[`d4d1f4dc8f6dc`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/d4d1f4dc8f6dc) -
|
|
24
|
+
ED-24117: upgrades mention with provider to fc for react 18 migration
|
|
25
|
+
|
|
3
26
|
## 198.4.5
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
|
@@ -208,8 +208,6 @@ var ReactEditorView = exports.ReactEditorView = /*#__PURE__*/function (_React$Co
|
|
|
208
208
|
providerFactory: options.props.providerFactory,
|
|
209
209
|
portalProviderAPI: _this.props.portalProviderAPI,
|
|
210
210
|
dispatchAnalyticsEvent: _this.dispatchAnalyticsEvent,
|
|
211
|
-
performanceTracking: _this.props.editorProps.performanceTracking,
|
|
212
|
-
transactionTracker: _this.transactionTracker,
|
|
213
211
|
featureFlags: _this.featureFlags,
|
|
214
212
|
getIntl: function getIntl() {
|
|
215
213
|
return _this.props.intl;
|
|
@@ -692,8 +690,6 @@ var ReactEditorView = exports.ReactEditorView = /*#__PURE__*/function (_React$Co
|
|
|
692
690
|
providerFactory: props.providerFactory,
|
|
693
691
|
portalProviderAPI: props.portalProviderAPI,
|
|
694
692
|
dispatchAnalyticsEvent: this.dispatchAnalyticsEvent,
|
|
695
|
-
performanceTracking: props.editorProps.performanceTracking,
|
|
696
|
-
transactionTracker: this.transactionTracker,
|
|
697
693
|
featureFlags: (0, _featureFlagsFromProps.createFeatureFlagsFromProps)(props.editorProps),
|
|
698
694
|
getIntl: function getIntl() {
|
|
699
695
|
return _this2.props.intl;
|
|
@@ -11,8 +11,7 @@ exports.processPluginsList = processPluginsList;
|
|
|
11
11
|
exports.sortByRank = sortByRank;
|
|
12
12
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
13
|
var _errorReporter = require("@atlaskit/editor-common/error-reporter");
|
|
14
|
-
var
|
|
15
|
-
var _instrumentedPlugin = require("../utils/performance/instrumented-plugin");
|
|
14
|
+
var _safeApplyPlugin = require("./safe-apply-plugin");
|
|
16
15
|
var _sortByOrder = require("./sort-by-order");
|
|
17
16
|
function sortByRank(a, b) {
|
|
18
17
|
return a.rank - b.rank;
|
|
@@ -94,34 +93,13 @@ function processPluginsList(plugins) {
|
|
|
94
93
|
onEditorViewStateUpdatedCallbacks: []
|
|
95
94
|
});
|
|
96
95
|
}
|
|
97
|
-
var TRACKING_DEFAULT = {
|
|
98
|
-
enabled: false
|
|
99
|
-
};
|
|
100
96
|
function createPMPlugins(config) {
|
|
101
97
|
var editorConfig = config.editorConfig,
|
|
102
|
-
_config$performanceTr = config.performanceTracking,
|
|
103
|
-
performanceTracking = _config$performanceTr === void 0 ? {} : _config$performanceTr,
|
|
104
|
-
transactionTracker = config.transactionTracker,
|
|
105
98
|
dispatchAnalyticsEvent = config.dispatchAnalyticsEvent;
|
|
106
|
-
var
|
|
107
|
-
|
|
108
|
-
_performanceTracking$2 = performanceTracking.transactionTracking,
|
|
109
|
-
transactionTracking = _performanceTracking$2 === void 0 ? TRACKING_DEFAULT : _performanceTracking$2;
|
|
110
|
-
|
|
111
|
-
// TO-DO need to question editor team about this condition true here
|
|
112
|
-
var useInstrumentedPlugin = uiTracking.enabled || transactionTracking.enabled || true;
|
|
113
|
-
if (process.env.NODE_ENV === 'development' && transactionTracking.enabled && !transactionTracker) {
|
|
114
|
-
// eslint-disable-next-line no-console
|
|
115
|
-
console.warn('createPMPlugins(): tracking is turned on but transactionTracker not defined! Transaction tracking has been disabled');
|
|
116
|
-
}
|
|
117
|
-
var instrumentPlugin = !(0, _platformFeatureFlags.fg)('platform_editor_disable_instrumented_plugin') && useInstrumentedPlugin ? function (plugin) {
|
|
118
|
-
return _instrumentedPlugin.InstrumentedPlugin.fromPlugin(plugin, {
|
|
119
|
-
uiTracking: uiTracking,
|
|
120
|
-
transactionTracking: transactionTracking,
|
|
99
|
+
var instrumentPlugin = function instrumentPlugin(plugin) {
|
|
100
|
+
return _safeApplyPlugin.SafeApplyPlugin.fromPlugin(plugin, {
|
|
121
101
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent
|
|
122
|
-
}
|
|
123
|
-
} : function (plugin) {
|
|
124
|
-
return plugin;
|
|
102
|
+
});
|
|
125
103
|
};
|
|
126
104
|
return editorConfig.pmPlugins.sort((0, _sortByOrder.sortByOrder)('plugins')).map(function (_ref) {
|
|
127
105
|
var plugin = _ref.plugin;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.SafeApplyPlugin = void 0;
|
|
8
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
11
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
12
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
13
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
14
|
+
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
15
|
+
var _saferTransactions = require("../utils/performance/safer-transactions");
|
|
16
|
+
function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = (0, _getPrototypeOf2.default)(t); if (r) { var s = (0, _getPrototypeOf2.default)(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return (0, _possibleConstructorReturn2.default)(this, e); }; }
|
|
17
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
18
|
+
/**
|
|
19
|
+
* This is for safety in case someone is trying to mutate
|
|
20
|
+
* the transaction in the apply which should never be done.
|
|
21
|
+
*/
|
|
22
|
+
var SafeApplyPlugin = exports.SafeApplyPlugin = /*#__PURE__*/function (_SafePlugin) {
|
|
23
|
+
(0, _inherits2.default)(SafeApplyPlugin, _SafePlugin);
|
|
24
|
+
var _super = _createSuper(SafeApplyPlugin);
|
|
25
|
+
function SafeApplyPlugin(spec) {
|
|
26
|
+
var _this;
|
|
27
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
28
|
+
(0, _classCallCheck2.default)(this, SafeApplyPlugin);
|
|
29
|
+
var dispatchAnalyticsEvent = options.dispatchAnalyticsEvent;
|
|
30
|
+
if (spec.state) {
|
|
31
|
+
var originalApply = spec.state.apply.bind(spec.state);
|
|
32
|
+
spec.state.apply = function (aTr, value, oldState, newState) {
|
|
33
|
+
var self = (0, _assertThisInitialized2.default)(_this);
|
|
34
|
+
var pluginKey = self === null || self === void 0 ? void 0 : self.key;
|
|
35
|
+
var tr = new Proxy(aTr, (0, _saferTransactions.freezeUnsafeTransactionProperties)({
|
|
36
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
37
|
+
pluginKey: typeof pluginKey === 'string' ? pluginKey : undefined
|
|
38
|
+
}));
|
|
39
|
+
return originalApply(tr, value, oldState, newState);
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return _this = _super.call(this, spec);
|
|
43
|
+
}
|
|
44
|
+
(0, _createClass2.default)(SafeApplyPlugin, null, [{
|
|
45
|
+
key: "fromPlugin",
|
|
46
|
+
value: function fromPlugin(plugin, options) {
|
|
47
|
+
return new SafeApplyPlugin(plugin.spec, options);
|
|
48
|
+
}
|
|
49
|
+
}]);
|
|
50
|
+
return SafeApplyPlugin;
|
|
51
|
+
}(_safePlugin.SafePlugin);
|
|
@@ -13,7 +13,6 @@ var _reactIntlNext = require("react-intl-next");
|
|
|
13
13
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
14
14
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
15
15
|
var _uiMenu = require("@atlaskit/editor-common/ui-menu");
|
|
16
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
17
16
|
var _Toolbar = _interopRequireDefault(require("../../Toolbar"));
|
|
18
17
|
var _BeforeWrapper = require("./BeforeWrapper");
|
|
19
18
|
var _MainToolbar = require("./MainToolbar");
|
|
@@ -90,11 +89,6 @@ var EditorToolbar = exports.EditorToolbar = /*#__PURE__*/_react.default.memo(fun
|
|
|
90
89
|
};
|
|
91
90
|
var handleEscape = function handleEscape(event) {
|
|
92
91
|
var _props$editorView;
|
|
93
|
-
if (!(0, _platformFeatureFlags.fg)('editor-fix-esc-main-toolbar-navigation')) {
|
|
94
|
-
if (!props.popupsMountPoint) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
92
|
if (!((_props$editorView = props.editorView) !== null && _props$editorView !== void 0 && _props$editorView.hasFocus())) {
|
|
99
93
|
var _props$editorView2;
|
|
100
94
|
(_props$editorView2 = props.editorView) === null || _props$editorView2 === void 0 || _props$editorView2.focus();
|
|
@@ -208,8 +208,6 @@ export class ReactEditorView extends React.Component {
|
|
|
208
208
|
providerFactory: options.props.providerFactory,
|
|
209
209
|
portalProviderAPI: this.props.portalProviderAPI,
|
|
210
210
|
dispatchAnalyticsEvent: this.dispatchAnalyticsEvent,
|
|
211
|
-
performanceTracking: this.props.editorProps.performanceTracking,
|
|
212
|
-
transactionTracker: this.transactionTracker,
|
|
213
211
|
featureFlags: this.featureFlags,
|
|
214
212
|
getIntl: () => this.props.intl
|
|
215
213
|
});
|
|
@@ -646,8 +644,6 @@ export class ReactEditorView extends React.Component {
|
|
|
646
644
|
providerFactory: props.providerFactory,
|
|
647
645
|
portalProviderAPI: props.portalProviderAPI,
|
|
648
646
|
dispatchAnalyticsEvent: this.dispatchAnalyticsEvent,
|
|
649
|
-
performanceTracking: props.editorProps.performanceTracking,
|
|
650
|
-
transactionTracker: this.transactionTracker,
|
|
651
647
|
featureFlags: createFeatureFlagsFromProps(props.editorProps),
|
|
652
648
|
getIntl: () => this.props.intl
|
|
653
649
|
});
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ErrorReporter } from '@atlaskit/editor-common/error-reporter';
|
|
2
|
-
import {
|
|
3
|
-
import { InstrumentedPlugin } from '../utils/performance/instrumented-plugin';
|
|
2
|
+
import { SafeApplyPlugin } from './safe-apply-plugin';
|
|
4
3
|
import { sortByOrder } from './sort-by-order';
|
|
5
4
|
export function sortByRank(a, b) {
|
|
6
5
|
return a.rank - b.rank;
|
|
@@ -75,32 +74,14 @@ export function processPluginsList(plugins) {
|
|
|
75
74
|
onEditorViewStateUpdatedCallbacks: []
|
|
76
75
|
});
|
|
77
76
|
}
|
|
78
|
-
const TRACKING_DEFAULT = {
|
|
79
|
-
enabled: false
|
|
80
|
-
};
|
|
81
77
|
export function createPMPlugins(config) {
|
|
82
78
|
const {
|
|
83
79
|
editorConfig,
|
|
84
|
-
performanceTracking = {},
|
|
85
|
-
transactionTracker,
|
|
86
80
|
dispatchAnalyticsEvent
|
|
87
81
|
} = config;
|
|
88
|
-
const {
|
|
89
|
-
uiTracking = TRACKING_DEFAULT,
|
|
90
|
-
transactionTracking = TRACKING_DEFAULT
|
|
91
|
-
} = performanceTracking;
|
|
92
|
-
|
|
93
|
-
// TO-DO need to question editor team about this condition true here
|
|
94
|
-
const useInstrumentedPlugin = uiTracking.enabled || transactionTracking.enabled || true;
|
|
95
|
-
if (process.env.NODE_ENV === 'development' && transactionTracking.enabled && !transactionTracker) {
|
|
96
|
-
// eslint-disable-next-line no-console
|
|
97
|
-
console.warn('createPMPlugins(): tracking is turned on but transactionTracker not defined! Transaction tracking has been disabled');
|
|
98
|
-
}
|
|
99
|
-
const instrumentPlugin = !fg('platform_editor_disable_instrumented_plugin') && useInstrumentedPlugin ? plugin => InstrumentedPlugin.fromPlugin(plugin, {
|
|
100
|
-
uiTracking,
|
|
101
|
-
transactionTracking,
|
|
82
|
+
const instrumentPlugin = plugin => SafeApplyPlugin.fromPlugin(plugin, {
|
|
102
83
|
dispatchAnalyticsEvent
|
|
103
|
-
}
|
|
84
|
+
});
|
|
104
85
|
return editorConfig.pmPlugins.sort(sortByOrder('plugins')).map(({
|
|
105
86
|
plugin
|
|
106
87
|
}) => plugin({
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
+
import { freezeUnsafeTransactionProperties } from '../utils/performance/safer-transactions';
|
|
3
|
+
/**
|
|
4
|
+
* This is for safety in case someone is trying to mutate
|
|
5
|
+
* the transaction in the apply which should never be done.
|
|
6
|
+
*/
|
|
7
|
+
export class SafeApplyPlugin extends SafePlugin {
|
|
8
|
+
constructor(spec, options = {}) {
|
|
9
|
+
const {
|
|
10
|
+
dispatchAnalyticsEvent
|
|
11
|
+
} = options;
|
|
12
|
+
if (spec.state) {
|
|
13
|
+
const originalApply = spec.state.apply.bind(spec.state);
|
|
14
|
+
spec.state.apply = (aTr, value, oldState, newState) => {
|
|
15
|
+
const self = this;
|
|
16
|
+
const pluginKey = self === null || self === void 0 ? void 0 : self.key;
|
|
17
|
+
const tr = new Proxy(aTr, freezeUnsafeTransactionProperties({
|
|
18
|
+
dispatchAnalyticsEvent,
|
|
19
|
+
pluginKey: typeof pluginKey === 'string' ? pluginKey : undefined
|
|
20
|
+
}));
|
|
21
|
+
return originalApply(tr, value, oldState, newState);
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
super(spec);
|
|
25
|
+
}
|
|
26
|
+
static fromPlugin(plugin, options) {
|
|
27
|
+
return new SafeApplyPlugin(plugin.spec, options);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -11,7 +11,6 @@ import { injectIntl } from 'react-intl-next';
|
|
|
11
11
|
import { fullPageMessages as messages } from '@atlaskit/editor-common/messages';
|
|
12
12
|
import { ContextPanelConsumer } from '@atlaskit/editor-common/ui';
|
|
13
13
|
import { ToolbarArrowKeyNavigationProvider } from '@atlaskit/editor-common/ui-menu';
|
|
14
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
15
14
|
import Toolbar from '../../Toolbar';
|
|
16
15
|
import { BeforePrimaryToolbarWrapper } from './BeforeWrapper';
|
|
17
16
|
import { customToolbarWrapperStyle, mainToolbarFirstChildStyle, mainToolbarIconBeforeStyle, mainToolbarSecondChildStyle, mainToolbarStyle, MAXIMUM_TWO_LINE_TOOLBAR_BREAKPOINT, nonCustomToolbarWrapperStyle } from './MainToolbar';
|
|
@@ -76,11 +75,6 @@ export const EditorToolbar = /*#__PURE__*/React.memo(props => {
|
|
|
76
75
|
};
|
|
77
76
|
const handleEscape = event => {
|
|
78
77
|
var _props$editorView;
|
|
79
|
-
if (!fg('editor-fix-esc-main-toolbar-navigation')) {
|
|
80
|
-
if (!props.popupsMountPoint) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
78
|
if (!((_props$editorView = props.editorView) !== null && _props$editorView !== void 0 && _props$editorView.hasFocus())) {
|
|
85
79
|
var _props$editorView2;
|
|
86
80
|
(_props$editorView2 = props.editorView) === null || _props$editorView2 === void 0 ? void 0 : _props$editorView2.focus();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = "@atlaskit/editor-core";
|
|
2
|
-
export const version = "198.4.
|
|
2
|
+
export const version = "198.4.7";
|
|
@@ -201,8 +201,6 @@ export var ReactEditorView = /*#__PURE__*/function (_React$Component) {
|
|
|
201
201
|
providerFactory: options.props.providerFactory,
|
|
202
202
|
portalProviderAPI: _this.props.portalProviderAPI,
|
|
203
203
|
dispatchAnalyticsEvent: _this.dispatchAnalyticsEvent,
|
|
204
|
-
performanceTracking: _this.props.editorProps.performanceTracking,
|
|
205
|
-
transactionTracker: _this.transactionTracker,
|
|
206
204
|
featureFlags: _this.featureFlags,
|
|
207
205
|
getIntl: function getIntl() {
|
|
208
206
|
return _this.props.intl;
|
|
@@ -685,8 +683,6 @@ export var ReactEditorView = /*#__PURE__*/function (_React$Component) {
|
|
|
685
683
|
providerFactory: props.providerFactory,
|
|
686
684
|
portalProviderAPI: props.portalProviderAPI,
|
|
687
685
|
dispatchAnalyticsEvent: this.dispatchAnalyticsEvent,
|
|
688
|
-
performanceTracking: props.editorProps.performanceTracking,
|
|
689
|
-
transactionTracker: this.transactionTracker,
|
|
690
686
|
featureFlags: createFeatureFlagsFromProps(props.editorProps),
|
|
691
687
|
getIntl: function getIntl() {
|
|
692
688
|
return _this2.props.intl;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import { ErrorReporter } from '@atlaskit/editor-common/error-reporter';
|
|
3
|
-
import {
|
|
4
|
-
import { InstrumentedPlugin } from '../utils/performance/instrumented-plugin';
|
|
3
|
+
import { SafeApplyPlugin } from './safe-apply-plugin';
|
|
5
4
|
import { sortByOrder } from './sort-by-order';
|
|
6
5
|
export function sortByRank(a, b) {
|
|
7
6
|
return a.rank - b.rank;
|
|
@@ -83,34 +82,13 @@ export function processPluginsList(plugins) {
|
|
|
83
82
|
onEditorViewStateUpdatedCallbacks: []
|
|
84
83
|
});
|
|
85
84
|
}
|
|
86
|
-
var TRACKING_DEFAULT = {
|
|
87
|
-
enabled: false
|
|
88
|
-
};
|
|
89
85
|
export function createPMPlugins(config) {
|
|
90
86
|
var editorConfig = config.editorConfig,
|
|
91
|
-
_config$performanceTr = config.performanceTracking,
|
|
92
|
-
performanceTracking = _config$performanceTr === void 0 ? {} : _config$performanceTr,
|
|
93
|
-
transactionTracker = config.transactionTracker,
|
|
94
87
|
dispatchAnalyticsEvent = config.dispatchAnalyticsEvent;
|
|
95
|
-
var
|
|
96
|
-
|
|
97
|
-
_performanceTracking$2 = performanceTracking.transactionTracking,
|
|
98
|
-
transactionTracking = _performanceTracking$2 === void 0 ? TRACKING_DEFAULT : _performanceTracking$2;
|
|
99
|
-
|
|
100
|
-
// TO-DO need to question editor team about this condition true here
|
|
101
|
-
var useInstrumentedPlugin = uiTracking.enabled || transactionTracking.enabled || true;
|
|
102
|
-
if (process.env.NODE_ENV === 'development' && transactionTracking.enabled && !transactionTracker) {
|
|
103
|
-
// eslint-disable-next-line no-console
|
|
104
|
-
console.warn('createPMPlugins(): tracking is turned on but transactionTracker not defined! Transaction tracking has been disabled');
|
|
105
|
-
}
|
|
106
|
-
var instrumentPlugin = !fg('platform_editor_disable_instrumented_plugin') && useInstrumentedPlugin ? function (plugin) {
|
|
107
|
-
return InstrumentedPlugin.fromPlugin(plugin, {
|
|
108
|
-
uiTracking: uiTracking,
|
|
109
|
-
transactionTracking: transactionTracking,
|
|
88
|
+
var instrumentPlugin = function instrumentPlugin(plugin) {
|
|
89
|
+
return SafeApplyPlugin.fromPlugin(plugin, {
|
|
110
90
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent
|
|
111
|
-
}
|
|
112
|
-
} : function (plugin) {
|
|
113
|
-
return plugin;
|
|
91
|
+
});
|
|
114
92
|
};
|
|
115
93
|
return editorConfig.pmPlugins.sort(sortByOrder('plugins')).map(function (_ref) {
|
|
116
94
|
var plugin = _ref.plugin;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
+
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); }; }
|
|
8
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
9
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
10
|
+
import { freezeUnsafeTransactionProperties } from '../utils/performance/safer-transactions';
|
|
11
|
+
/**
|
|
12
|
+
* This is for safety in case someone is trying to mutate
|
|
13
|
+
* the transaction in the apply which should never be done.
|
|
14
|
+
*/
|
|
15
|
+
export var SafeApplyPlugin = /*#__PURE__*/function (_SafePlugin) {
|
|
16
|
+
_inherits(SafeApplyPlugin, _SafePlugin);
|
|
17
|
+
var _super = _createSuper(SafeApplyPlugin);
|
|
18
|
+
function SafeApplyPlugin(spec) {
|
|
19
|
+
var _this;
|
|
20
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
21
|
+
_classCallCheck(this, SafeApplyPlugin);
|
|
22
|
+
var dispatchAnalyticsEvent = options.dispatchAnalyticsEvent;
|
|
23
|
+
if (spec.state) {
|
|
24
|
+
var originalApply = spec.state.apply.bind(spec.state);
|
|
25
|
+
spec.state.apply = function (aTr, value, oldState, newState) {
|
|
26
|
+
var self = _assertThisInitialized(_this);
|
|
27
|
+
var pluginKey = self === null || self === void 0 ? void 0 : self.key;
|
|
28
|
+
var tr = new Proxy(aTr, freezeUnsafeTransactionProperties({
|
|
29
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
30
|
+
pluginKey: typeof pluginKey === 'string' ? pluginKey : undefined
|
|
31
|
+
}));
|
|
32
|
+
return originalApply(tr, value, oldState, newState);
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return _this = _super.call(this, spec);
|
|
36
|
+
}
|
|
37
|
+
_createClass(SafeApplyPlugin, null, [{
|
|
38
|
+
key: "fromPlugin",
|
|
39
|
+
value: function fromPlugin(plugin, options) {
|
|
40
|
+
return new SafeApplyPlugin(plugin.spec, options);
|
|
41
|
+
}
|
|
42
|
+
}]);
|
|
43
|
+
return SafeApplyPlugin;
|
|
44
|
+
}(SafePlugin);
|
|
@@ -12,7 +12,6 @@ import { injectIntl } from 'react-intl-next';
|
|
|
12
12
|
import { fullPageMessages as messages } from '@atlaskit/editor-common/messages';
|
|
13
13
|
import { ContextPanelConsumer } from '@atlaskit/editor-common/ui';
|
|
14
14
|
import { ToolbarArrowKeyNavigationProvider } from '@atlaskit/editor-common/ui-menu';
|
|
15
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
16
15
|
import Toolbar from '../../Toolbar';
|
|
17
16
|
import { BeforePrimaryToolbarWrapper } from './BeforeWrapper';
|
|
18
17
|
import { customToolbarWrapperStyle, mainToolbarFirstChildStyle, mainToolbarIconBeforeStyle, mainToolbarSecondChildStyle, mainToolbarStyle, MAXIMUM_TWO_LINE_TOOLBAR_BREAKPOINT, nonCustomToolbarWrapperStyle } from './MainToolbar';
|
|
@@ -80,11 +79,6 @@ export var EditorToolbar = /*#__PURE__*/React.memo(function (props) {
|
|
|
80
79
|
};
|
|
81
80
|
var handleEscape = function handleEscape(event) {
|
|
82
81
|
var _props$editorView;
|
|
83
|
-
if (!fg('editor-fix-esc-main-toolbar-navigation')) {
|
|
84
|
-
if (!props.popupsMountPoint) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
82
|
if (!((_props$editorView = props.editorView) !== null && _props$editorView !== void 0 && _props$editorView.hasFocus())) {
|
|
89
83
|
var _props$editorView2;
|
|
90
84
|
(_props$editorView2 = props.editorView) === null || _props$editorView2 === void 0 || _props$editorView2.focus();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export var name = "@atlaskit/editor-core";
|
|
2
|
-
export var version = "198.4.
|
|
2
|
+
export var version = "198.4.7";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
+
import type { SafePluginSpec } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
+
type SafeApplyPluginOptions = {
|
|
5
|
+
dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* This is for safety in case someone is trying to mutate
|
|
9
|
+
* the transaction in the apply which should never be done.
|
|
10
|
+
*/
|
|
11
|
+
export declare class SafeApplyPlugin<PluginState> extends SafePlugin<PluginState> {
|
|
12
|
+
constructor(spec: SafePluginSpec, options?: SafeApplyPluginOptions);
|
|
13
|
+
static fromPlugin<T>(plugin: SafePlugin<T>, options: SafeApplyPluginOptions): SafeApplyPlugin<T>;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import type { TransactionTracker } from '../utils/performance/track-transactions';
|
|
2
1
|
import type { EditorConfig } from './editor-config';
|
|
3
|
-
import type { PerformanceTracking } from './performance-tracking';
|
|
4
2
|
import type { PMPluginFactoryParams } from './pm-plugin';
|
|
5
3
|
export type PMPluginCreateConfig = PMPluginFactoryParams & {
|
|
6
4
|
editorConfig: EditorConfig;
|
|
7
|
-
performanceTracking?: PerformanceTracking;
|
|
8
|
-
transactionTracker?: TransactionTracker;
|
|
9
5
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
+
import type { SafePluginSpec } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
+
type SafeApplyPluginOptions = {
|
|
5
|
+
dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* This is for safety in case someone is trying to mutate
|
|
9
|
+
* the transaction in the apply which should never be done.
|
|
10
|
+
*/
|
|
11
|
+
export declare class SafeApplyPlugin<PluginState> extends SafePlugin<PluginState> {
|
|
12
|
+
constructor(spec: SafePluginSpec, options?: SafeApplyPluginOptions);
|
|
13
|
+
static fromPlugin<T>(plugin: SafePlugin<T>, options: SafeApplyPluginOptions): SafeApplyPlugin<T>;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import type { TransactionTracker } from '../utils/performance/track-transactions';
|
|
2
1
|
import type { EditorConfig } from './editor-config';
|
|
3
|
-
import type { PerformanceTracking } from './performance-tracking';
|
|
4
2
|
import type { PMPluginFactoryParams } from './pm-plugin';
|
|
5
3
|
export type PMPluginCreateConfig = PMPluginFactoryParams & {
|
|
6
4
|
editorConfig: EditorConfig;
|
|
7
|
-
performanceTracking?: PerformanceTracking;
|
|
8
|
-
transactionTracker?: TransactionTracker;
|
|
9
5
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-core",
|
|
3
|
-
"version": "198.4.
|
|
3
|
+
"version": "198.4.7",
|
|
4
4
|
"description": "A package contains Atlassian editor core functionality",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@atlaskit/analytics-next": "^10.1.0",
|
|
44
44
|
"@atlaskit/analytics-next-stable-react-context": "1.0.1",
|
|
45
45
|
"@atlaskit/button": "^20.2.0",
|
|
46
|
-
"@atlaskit/editor-common": "^93.
|
|
46
|
+
"@atlaskit/editor-common": "^93.2.0",
|
|
47
47
|
"@atlaskit/editor-json-transformer": "^8.18.0",
|
|
48
48
|
"@atlaskit/editor-plugin-quick-insert": "1.4.5",
|
|
49
49
|
"@atlaskit/editor-plugins": "^5.5.0",
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"@atlaskit/analytics-listeners": "^8.11.0",
|
|
86
86
|
"@atlaskit/collab-provider": "9.42.5",
|
|
87
87
|
"@atlaskit/editor-plugin-annotation": "1.19.11",
|
|
88
|
-
"@atlaskit/editor-plugin-card": "^4.
|
|
88
|
+
"@atlaskit/editor-plugin-card": "^4.2.0",
|
|
89
89
|
"@atlaskit/editor-plugin-list": "^3.8.0",
|
|
90
90
|
"@atlaskit/editor-plugin-paste": "^1.13.0",
|
|
91
91
|
"@atlaskit/link-provider": "^1.16.0",
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"@atlaskit/modal-dialog": "^12.17.0",
|
|
97
97
|
"@atlaskit/primitives": "^12.2.0",
|
|
98
98
|
"@atlaskit/renderer": "^111.1.0",
|
|
99
|
-
"@atlaskit/smart-card": "^29.
|
|
99
|
+
"@atlaskit/smart-card": "^29.2.0",
|
|
100
100
|
"@atlaskit/synchrony-test-helpers": "^2.5.0",
|
|
101
101
|
"@atlaskit/toggle": "^13.4.0",
|
|
102
102
|
"@atlaskit/util-data-test": "^17.9.0",
|
|
@@ -164,10 +164,6 @@
|
|
|
164
164
|
"type": "boolean",
|
|
165
165
|
"referenceOnly": "true"
|
|
166
166
|
},
|
|
167
|
-
"platform.linking-platform.datasource-word_wrap": {
|
|
168
|
-
"type": "boolean",
|
|
169
|
-
"referenceOnly": "true"
|
|
170
|
-
},
|
|
171
167
|
"platform.editor.inline_extension.extended_lcqdn": {
|
|
172
168
|
"type": "boolean",
|
|
173
169
|
"referenceOnly": "true"
|
|
@@ -201,9 +197,6 @@
|
|
|
201
197
|
"type": "boolean",
|
|
202
198
|
"referenceOnly": true
|
|
203
199
|
},
|
|
204
|
-
"editor-fix-esc-main-toolbar-navigation": {
|
|
205
|
-
"type": "boolean"
|
|
206
|
-
},
|
|
207
200
|
"editor_support_code_block_wrapping": {
|
|
208
201
|
"type": "boolean",
|
|
209
202
|
"referenceOnly": true
|
|
@@ -261,6 +254,9 @@
|
|
|
261
254
|
"platform_editor_ssr_fix_block_controls": {
|
|
262
255
|
"type": "boolean"
|
|
263
256
|
},
|
|
257
|
+
"platform_editor_react18_mention_with_provider": {
|
|
258
|
+
"type": "boolean"
|
|
259
|
+
},
|
|
264
260
|
"platform_editor_remove_use_preset_context": {
|
|
265
261
|
"type": "boolean"
|
|
266
262
|
},
|
|
@@ -268,6 +264,9 @@
|
|
|
268
264
|
"type": "boolean",
|
|
269
265
|
"referenceOnly": true
|
|
270
266
|
},
|
|
267
|
+
"platform_editor_react18_extension_component": {
|
|
268
|
+
"type": "boolean"
|
|
269
|
+
},
|
|
271
270
|
"platform_editor_context_panel_support_multiple": {
|
|
272
271
|
"type": "boolean",
|
|
273
272
|
"referenceOnly": true
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.InstrumentedPlugin = void 0;
|
|
8
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
11
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
12
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
13
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
14
|
-
var _performanceMeasures = require("@atlaskit/editor-common/performance-measures");
|
|
15
|
-
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
16
|
-
var _saferTransactions = require("./safer-transactions");
|
|
17
|
-
function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = (0, _getPrototypeOf2.default)(t); if (r) { var s = (0, _getPrototypeOf2.default)(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return (0, _possibleConstructorReturn2.default)(this, e); }; }
|
|
18
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
19
|
-
var InstrumentedPlugin = exports.InstrumentedPlugin = /*#__PURE__*/function (_SafePlugin) {
|
|
20
|
-
(0, _inherits2.default)(InstrumentedPlugin, _SafePlugin);
|
|
21
|
-
var _super = _createSuper(InstrumentedPlugin);
|
|
22
|
-
function InstrumentedPlugin(spec) {
|
|
23
|
-
var _this;
|
|
24
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
25
|
-
var transactionTracker = arguments.length > 2 ? arguments[2] : undefined;
|
|
26
|
-
(0, _classCallCheck2.default)(this, InstrumentedPlugin);
|
|
27
|
-
var _options$transactionT = options.transactionTracking,
|
|
28
|
-
transactionTracking = _options$transactionT === void 0 ? {
|
|
29
|
-
enabled: false
|
|
30
|
-
} : _options$transactionT,
|
|
31
|
-
_options$uiTracking = options.uiTracking,
|
|
32
|
-
uiTracking = _options$uiTracking === void 0 ? {
|
|
33
|
-
enabled: false
|
|
34
|
-
} : _options$uiTracking,
|
|
35
|
-
dispatchAnalyticsEvent = options.dispatchAnalyticsEvent;
|
|
36
|
-
if (spec.state) {
|
|
37
|
-
var originalApply = spec.state.apply.bind(spec.state);
|
|
38
|
-
spec.state.apply = function (aTr, value, oldState, newState) {
|
|
39
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
40
|
-
var self = (0, _assertThisInitialized2.default)(_this);
|
|
41
|
-
var tr = new Proxy(aTr, (0, _saferTransactions.freezeUnsafeTransactionProperties)({
|
|
42
|
-
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
43
|
-
pluginKey: self.key
|
|
44
|
-
}));
|
|
45
|
-
var shouldTrackTransactions = transactionTracker === null || transactionTracker === void 0 ? void 0 : transactionTracker.shouldTrackTransaction(transactionTracking);
|
|
46
|
-
if (!shouldTrackTransactions || !transactionTracker) {
|
|
47
|
-
return originalApply(tr, value, oldState, newState);
|
|
48
|
-
}
|
|
49
|
-
var _transactionTracker$g = transactionTracker.getMeasureHelpers(transactionTracking),
|
|
50
|
-
startMeasure = _transactionTracker$g.startMeasure,
|
|
51
|
-
stopMeasure = _transactionTracker$g.stopMeasure;
|
|
52
|
-
var measure = "\uD83E\uDD89".concat(self.key, "::apply");
|
|
53
|
-
startMeasure(measure);
|
|
54
|
-
var result = originalApply(tr, value, oldState, newState);
|
|
55
|
-
stopMeasure(measure);
|
|
56
|
-
return result;
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
var _uiTracking$samplingR = uiTracking.samplingRate,
|
|
60
|
-
uiTrackingSamplingRate = _uiTracking$samplingR === void 0 ? 100 : _uiTracking$samplingR;
|
|
61
|
-
if (uiTracking.enabled && spec.view) {
|
|
62
|
-
var originalView = spec.view.bind(spec);
|
|
63
|
-
spec.view = function (editorView) {
|
|
64
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
65
|
-
var self = (0, _assertThisInitialized2.default)(_this);
|
|
66
|
-
var measure = "\uD83E\uDD89".concat(self.key, "::view::update");
|
|
67
|
-
var view = originalView(editorView);
|
|
68
|
-
var uiTrackingSamplingCounter = 0;
|
|
69
|
-
if (view.update) {
|
|
70
|
-
var originalUpdate = view.update;
|
|
71
|
-
view.update = function (view, state) {
|
|
72
|
-
var shouldTrack = uiTrackingSamplingRate && uiTrackingSamplingCounter === 0;
|
|
73
|
-
if (shouldTrack) {
|
|
74
|
-
(0, _performanceMeasures.startMeasure)(measure);
|
|
75
|
-
}
|
|
76
|
-
originalUpdate(view, state);
|
|
77
|
-
if (shouldTrack) {
|
|
78
|
-
(0, _performanceMeasures.stopMeasure)(measure, function () {});
|
|
79
|
-
}
|
|
80
|
-
uiTrackingSamplingCounter++;
|
|
81
|
-
if (uiTrackingSamplingRate && uiTrackingSamplingCounter >= uiTrackingSamplingRate) {
|
|
82
|
-
uiTrackingSamplingCounter = 0;
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
return view;
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
return _this = _super.call(this, spec);
|
|
90
|
-
}
|
|
91
|
-
(0, _createClass2.default)(InstrumentedPlugin, null, [{
|
|
92
|
-
key: "fromPlugin",
|
|
93
|
-
value: function fromPlugin(plugin, options, transactionTracker) {
|
|
94
|
-
return new InstrumentedPlugin(plugin.spec, options, transactionTracker);
|
|
95
|
-
}
|
|
96
|
-
}]);
|
|
97
|
-
return InstrumentedPlugin;
|
|
98
|
-
}(_safePlugin.SafePlugin);
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { startMeasure, stopMeasure } from '@atlaskit/editor-common/performance-measures';
|
|
2
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
-
import { freezeUnsafeTransactionProperties } from './safer-transactions';
|
|
4
|
-
export class InstrumentedPlugin extends SafePlugin {
|
|
5
|
-
constructor(spec, options = {}, transactionTracker) {
|
|
6
|
-
const {
|
|
7
|
-
transactionTracking = {
|
|
8
|
-
enabled: false
|
|
9
|
-
},
|
|
10
|
-
uiTracking = {
|
|
11
|
-
enabled: false
|
|
12
|
-
},
|
|
13
|
-
dispatchAnalyticsEvent
|
|
14
|
-
} = options;
|
|
15
|
-
if (spec.state) {
|
|
16
|
-
const originalApply = spec.state.apply.bind(spec.state);
|
|
17
|
-
spec.state.apply = (aTr, value, oldState, newState) => {
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
|
-
const self = this;
|
|
20
|
-
const tr = new Proxy(aTr, freezeUnsafeTransactionProperties({
|
|
21
|
-
dispatchAnalyticsEvent,
|
|
22
|
-
pluginKey: self.key
|
|
23
|
-
}));
|
|
24
|
-
const shouldTrackTransactions = transactionTracker === null || transactionTracker === void 0 ? void 0 : transactionTracker.shouldTrackTransaction(transactionTracking);
|
|
25
|
-
if (!shouldTrackTransactions || !transactionTracker) {
|
|
26
|
-
return originalApply(tr, value, oldState, newState);
|
|
27
|
-
}
|
|
28
|
-
const {
|
|
29
|
-
startMeasure,
|
|
30
|
-
stopMeasure
|
|
31
|
-
} = transactionTracker.getMeasureHelpers(transactionTracking);
|
|
32
|
-
const measure = `🦉${self.key}::apply`;
|
|
33
|
-
startMeasure(measure);
|
|
34
|
-
const result = originalApply(tr, value, oldState, newState);
|
|
35
|
-
stopMeasure(measure);
|
|
36
|
-
return result;
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
const {
|
|
40
|
-
samplingRate: uiTrackingSamplingRate = 100
|
|
41
|
-
} = uiTracking;
|
|
42
|
-
if (uiTracking.enabled && spec.view) {
|
|
43
|
-
const originalView = spec.view.bind(spec);
|
|
44
|
-
spec.view = editorView => {
|
|
45
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
46
|
-
const self = this;
|
|
47
|
-
const measure = `🦉${self.key}::view::update`;
|
|
48
|
-
const view = originalView(editorView);
|
|
49
|
-
let uiTrackingSamplingCounter = 0;
|
|
50
|
-
if (view.update) {
|
|
51
|
-
const originalUpdate = view.update;
|
|
52
|
-
view.update = (view, state) => {
|
|
53
|
-
const shouldTrack = uiTrackingSamplingRate && uiTrackingSamplingCounter === 0;
|
|
54
|
-
if (shouldTrack) {
|
|
55
|
-
startMeasure(measure);
|
|
56
|
-
}
|
|
57
|
-
originalUpdate(view, state);
|
|
58
|
-
if (shouldTrack) {
|
|
59
|
-
stopMeasure(measure, () => {});
|
|
60
|
-
}
|
|
61
|
-
uiTrackingSamplingCounter++;
|
|
62
|
-
if (uiTrackingSamplingRate && uiTrackingSamplingCounter >= uiTrackingSamplingRate) {
|
|
63
|
-
uiTrackingSamplingCounter = 0;
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
return view;
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
super(spec);
|
|
71
|
-
}
|
|
72
|
-
static fromPlugin(plugin, options, transactionTracker) {
|
|
73
|
-
return new InstrumentedPlugin(plugin.spec, options, transactionTracker);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
-
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); }; }
|
|
8
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
9
|
-
import { startMeasure, stopMeasure } from '@atlaskit/editor-common/performance-measures';
|
|
10
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
11
|
-
import { freezeUnsafeTransactionProperties } from './safer-transactions';
|
|
12
|
-
export var InstrumentedPlugin = /*#__PURE__*/function (_SafePlugin) {
|
|
13
|
-
_inherits(InstrumentedPlugin, _SafePlugin);
|
|
14
|
-
var _super = _createSuper(InstrumentedPlugin);
|
|
15
|
-
function InstrumentedPlugin(spec) {
|
|
16
|
-
var _this;
|
|
17
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
18
|
-
var transactionTracker = arguments.length > 2 ? arguments[2] : undefined;
|
|
19
|
-
_classCallCheck(this, InstrumentedPlugin);
|
|
20
|
-
var _options$transactionT = options.transactionTracking,
|
|
21
|
-
transactionTracking = _options$transactionT === void 0 ? {
|
|
22
|
-
enabled: false
|
|
23
|
-
} : _options$transactionT,
|
|
24
|
-
_options$uiTracking = options.uiTracking,
|
|
25
|
-
uiTracking = _options$uiTracking === void 0 ? {
|
|
26
|
-
enabled: false
|
|
27
|
-
} : _options$uiTracking,
|
|
28
|
-
dispatchAnalyticsEvent = options.dispatchAnalyticsEvent;
|
|
29
|
-
if (spec.state) {
|
|
30
|
-
var originalApply = spec.state.apply.bind(spec.state);
|
|
31
|
-
spec.state.apply = function (aTr, value, oldState, newState) {
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
|
-
var self = _assertThisInitialized(_this);
|
|
34
|
-
var tr = new Proxy(aTr, freezeUnsafeTransactionProperties({
|
|
35
|
-
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
36
|
-
pluginKey: self.key
|
|
37
|
-
}));
|
|
38
|
-
var shouldTrackTransactions = transactionTracker === null || transactionTracker === void 0 ? void 0 : transactionTracker.shouldTrackTransaction(transactionTracking);
|
|
39
|
-
if (!shouldTrackTransactions || !transactionTracker) {
|
|
40
|
-
return originalApply(tr, value, oldState, newState);
|
|
41
|
-
}
|
|
42
|
-
var _transactionTracker$g = transactionTracker.getMeasureHelpers(transactionTracking),
|
|
43
|
-
startMeasure = _transactionTracker$g.startMeasure,
|
|
44
|
-
stopMeasure = _transactionTracker$g.stopMeasure;
|
|
45
|
-
var measure = "\uD83E\uDD89".concat(self.key, "::apply");
|
|
46
|
-
startMeasure(measure);
|
|
47
|
-
var result = originalApply(tr, value, oldState, newState);
|
|
48
|
-
stopMeasure(measure);
|
|
49
|
-
return result;
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
var _uiTracking$samplingR = uiTracking.samplingRate,
|
|
53
|
-
uiTrackingSamplingRate = _uiTracking$samplingR === void 0 ? 100 : _uiTracking$samplingR;
|
|
54
|
-
if (uiTracking.enabled && spec.view) {
|
|
55
|
-
var originalView = spec.view.bind(spec);
|
|
56
|
-
spec.view = function (editorView) {
|
|
57
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
58
|
-
var self = _assertThisInitialized(_this);
|
|
59
|
-
var measure = "\uD83E\uDD89".concat(self.key, "::view::update");
|
|
60
|
-
var view = originalView(editorView);
|
|
61
|
-
var uiTrackingSamplingCounter = 0;
|
|
62
|
-
if (view.update) {
|
|
63
|
-
var originalUpdate = view.update;
|
|
64
|
-
view.update = function (view, state) {
|
|
65
|
-
var shouldTrack = uiTrackingSamplingRate && uiTrackingSamplingCounter === 0;
|
|
66
|
-
if (shouldTrack) {
|
|
67
|
-
startMeasure(measure);
|
|
68
|
-
}
|
|
69
|
-
originalUpdate(view, state);
|
|
70
|
-
if (shouldTrack) {
|
|
71
|
-
stopMeasure(measure, function () {});
|
|
72
|
-
}
|
|
73
|
-
uiTrackingSamplingCounter++;
|
|
74
|
-
if (uiTrackingSamplingRate && uiTrackingSamplingCounter >= uiTrackingSamplingRate) {
|
|
75
|
-
uiTrackingSamplingCounter = 0;
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
return view;
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
return _this = _super.call(this, spec);
|
|
83
|
-
}
|
|
84
|
-
_createClass(InstrumentedPlugin, null, [{
|
|
85
|
-
key: "fromPlugin",
|
|
86
|
-
value: function fromPlugin(plugin, options, transactionTracker) {
|
|
87
|
-
return new InstrumentedPlugin(plugin.spec, options, transactionTracker);
|
|
88
|
-
}
|
|
89
|
-
}]);
|
|
90
|
-
return InstrumentedPlugin;
|
|
91
|
-
}(SafePlugin);
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
-
import type { SafePluginSpec } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
-
import type { EditorProps } from '../../types/editor-props';
|
|
5
|
-
import type { TransactionTracker } from './track-transactions';
|
|
6
|
-
type InstrumentedPluginOptions = EditorProps['performanceTracking'] & {
|
|
7
|
-
dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
|
|
8
|
-
};
|
|
9
|
-
export declare class InstrumentedPlugin<PluginState> extends SafePlugin<PluginState> {
|
|
10
|
-
constructor(spec: SafePluginSpec, options?: InstrumentedPluginOptions, transactionTracker?: TransactionTracker);
|
|
11
|
-
static fromPlugin<T>(plugin: SafePlugin<T>, options: InstrumentedPluginOptions, transactionTracker?: TransactionTracker): InstrumentedPlugin<T>;
|
|
12
|
-
}
|
|
13
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
-
import type { SafePluginSpec } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
-
import type { EditorProps } from '../../types/editor-props';
|
|
5
|
-
import type { TransactionTracker } from './track-transactions';
|
|
6
|
-
type InstrumentedPluginOptions = EditorProps['performanceTracking'] & {
|
|
7
|
-
dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
|
|
8
|
-
};
|
|
9
|
-
export declare class InstrumentedPlugin<PluginState> extends SafePlugin<PluginState> {
|
|
10
|
-
constructor(spec: SafePluginSpec, options?: InstrumentedPluginOptions, transactionTracker?: TransactionTracker);
|
|
11
|
-
static fromPlugin<T>(plugin: SafePlugin<T>, options: InstrumentedPluginOptions, transactionTracker?: TransactionTracker): InstrumentedPlugin<T>;
|
|
12
|
-
}
|
|
13
|
-
export {};
|