@atlaskit/editor-core 201.1.5 → 201.1.6
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 +12 -0
- package/dist/cjs/composable-editor/editor-internal.js +57 -1
- package/dist/cjs/create-editor/ReactEditorView/formatFullWidthAppearance.js +13 -0
- package/dist/cjs/create-editor/ReactEditorView/getUAPrefix.js +19 -0
- package/dist/cjs/create-editor/ReactEditorView/handleEditorFocus.js +44 -0
- package/dist/cjs/create-editor/ReactEditorView/useDispatchTransaction.js +90 -0
- package/dist/cjs/create-editor/ReactEditorView/useFireFullWidthEvent.js +28 -0
- package/dist/cjs/create-editor/ReactEditorView/usePluginPerformanceObserver.js +48 -0
- package/dist/cjs/create-editor/ReactEditorViewNext.js +538 -0
- package/dist/cjs/presets/universal.js +2 -1
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/composable-editor/editor-internal.js +58 -1
- package/dist/es2019/create-editor/ReactEditorView/formatFullWidthAppearance.js +7 -0
- package/dist/es2019/create-editor/ReactEditorView/getUAPrefix.js +13 -0
- package/dist/es2019/create-editor/ReactEditorView/handleEditorFocus.js +38 -0
- package/dist/es2019/create-editor/ReactEditorView/useDispatchTransaction.js +82 -0
- package/dist/es2019/create-editor/ReactEditorView/useFireFullWidthEvent.js +22 -0
- package/dist/es2019/create-editor/ReactEditorView/usePluginPerformanceObserver.js +32 -0
- package/dist/es2019/create-editor/ReactEditorViewNext.js +515 -0
- package/dist/es2019/presets/universal.js +2 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/composable-editor/editor-internal.js +57 -1
- package/dist/esm/create-editor/ReactEditorView/formatFullWidthAppearance.js +7 -0
- package/dist/esm/create-editor/ReactEditorView/getUAPrefix.js +13 -0
- package/dist/esm/create-editor/ReactEditorView/handleEditorFocus.js +38 -0
- package/dist/esm/create-editor/ReactEditorView/useDispatchTransaction.js +84 -0
- package/dist/esm/create-editor/ReactEditorView/useFireFullWidthEvent.js +22 -0
- package/dist/esm/create-editor/ReactEditorView/usePluginPerformanceObserver.js +42 -0
- package/dist/esm/create-editor/ReactEditorViewNext.js +528 -0
- package/dist/esm/presets/universal.js +2 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/create-editor/ReactEditorView/formatFullWidthAppearance.d.ts +3 -0
- package/dist/types/create-editor/ReactEditorView/getUAPrefix.d.ts +1 -0
- package/dist/types/create-editor/ReactEditorView/handleEditorFocus.d.ts +2 -0
- package/dist/types/create-editor/ReactEditorView/useDispatchTransaction.d.ts +12 -0
- package/dist/types/create-editor/ReactEditorView/useFireFullWidthEvent.d.ts +3 -0
- package/dist/types/create-editor/ReactEditorView/usePluginPerformanceObserver.d.ts +5 -0
- package/dist/types/create-editor/ReactEditorViewNext.d.ts +48 -0
- package/dist/types/create-editor/create-universal-preset.d.ts +8 -2
- package/dist/types/presets/universal.d.ts +8 -2
- package/dist/types/presets/useUniversalPreset.d.ts +8 -2
- package/dist/types/types/editor-config.d.ts +1 -2
- package/dist/types-ts4.5/create-editor/ReactEditorView/formatFullWidthAppearance.d.ts +3 -0
- package/dist/types-ts4.5/create-editor/ReactEditorView/getUAPrefix.d.ts +1 -0
- package/dist/types-ts4.5/create-editor/ReactEditorView/handleEditorFocus.d.ts +2 -0
- package/dist/types-ts4.5/create-editor/ReactEditorView/useDispatchTransaction.d.ts +12 -0
- package/dist/types-ts4.5/create-editor/ReactEditorView/useFireFullWidthEvent.d.ts +3 -0
- package/dist/types-ts4.5/create-editor/ReactEditorView/usePluginPerformanceObserver.d.ts +5 -0
- package/dist/types-ts4.5/create-editor/ReactEditorViewNext.d.ts +48 -0
- package/dist/types-ts4.5/create-editor/create-universal-preset.d.ts +11 -2
- package/dist/types-ts4.5/presets/universal.d.ts +11 -2
- package/dist/types-ts4.5/presets/useUniversalPreset.d.ts +11 -2
- package/dist/types-ts4.5/types/editor-config.d.ts +1 -2
- package/package.json +11 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-core
|
|
2
2
|
|
|
3
|
+
## 201.1.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#158291](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/158291)
|
|
8
|
+
[`f485597c02e9a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/f485597c02e9a) -
|
|
9
|
+
Refactoring the core editor component to remove unsafe methods for React 18.
|
|
10
|
+
- [#158691](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/158691)
|
|
11
|
+
[`70ef661bbbb4d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/70ef661bbbb4d) -
|
|
12
|
+
Update feature flag to gate
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
3
15
|
## 201.1.5
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -12,9 +12,11 @@ var _react = require("react");
|
|
|
12
12
|
var _react2 = require("@emotion/react");
|
|
13
13
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
14
14
|
var _portal = require("@atlaskit/editor-common/portal");
|
|
15
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
16
|
var _ErrorBoundary = _interopRequireDefault(require("../create-editor/ErrorBoundary"));
|
|
16
17
|
var _featureFlagsFromProps = require("../create-editor/feature-flags-from-props");
|
|
17
18
|
var _ReactEditorView = _interopRequireDefault(require("../create-editor/ReactEditorView"));
|
|
19
|
+
var _ReactEditorViewNext = _interopRequireDefault(require("../create-editor/ReactEditorViewNext"));
|
|
18
20
|
var _contextAdapter = require("../nodeviews/context-adapter");
|
|
19
21
|
var _EditorContext = _interopRequireDefault(require("../ui/EditorContext"));
|
|
20
22
|
var _IntlProviderIfMissingWrapper = require("../ui/IntlProviderIfMissingWrapper/IntlProviderIfMissingWrapper");
|
|
@@ -76,7 +78,7 @@ var EditorInternal = exports.EditorInternal = /*#__PURE__*/(0, _react.memo)(func
|
|
|
76
78
|
css: editorContainerStyles
|
|
77
79
|
}, (0, _react2.jsx)(_EditorContext.default, {
|
|
78
80
|
editorActions: editorActions
|
|
79
|
-
}, (0, _react2.jsx)(_contextAdapter.ContextAdapter, null, (0, _react2.jsx)(_IntlProviderIfMissingWrapper.IntlProviderIfMissingWrapper, null, (0, _react2.jsx)(_react.Fragment, null, (0, _react2.jsx)(
|
|
81
|
+
}, (0, _react2.jsx)(_contextAdapter.ContextAdapter, null, (0, _react2.jsx)(_IntlProviderIfMissingWrapper.IntlProviderIfMissingWrapper, null, (0, _react2.jsx)(_react.Fragment, null, (0, _platformFeatureFlags.fg)('platform_editor_react_editor_view_react_18') ? (0, _react2.jsx)(_ReactEditorViewNext.default, {
|
|
80
82
|
editorProps: overriddenEditorProps,
|
|
81
83
|
createAnalyticsEvent: createAnalyticsEvent,
|
|
82
84
|
portalProviderAPI: portalProviderAPI,
|
|
@@ -130,6 +132,60 @@ var EditorInternal = exports.EditorInternal = /*#__PURE__*/(0, _react.memo)(func
|
|
|
130
132
|
pluginHooks: config.pluginHooks
|
|
131
133
|
}));
|
|
132
134
|
}
|
|
135
|
+
}) : (0, _react2.jsx)(ReactEditorViewContextWrapper, {
|
|
136
|
+
editorProps: overriddenEditorProps,
|
|
137
|
+
createAnalyticsEvent: createAnalyticsEvent,
|
|
138
|
+
portalProviderAPI: portalProviderAPI,
|
|
139
|
+
providerFactory: providerFactory,
|
|
140
|
+
onEditorCreated: onEditorCreated,
|
|
141
|
+
onEditorDestroyed: onEditorDestroyed,
|
|
142
|
+
disabled: props.disabled,
|
|
143
|
+
preset: preset,
|
|
144
|
+
render: function render(_ref3) {
|
|
145
|
+
var _props$featureFlags3, _props$featureFlags4;
|
|
146
|
+
var editor = _ref3.editor,
|
|
147
|
+
view = _ref3.view,
|
|
148
|
+
eventDispatcher = _ref3.eventDispatcher,
|
|
149
|
+
config = _ref3.config,
|
|
150
|
+
dispatchAnalyticsEvent = _ref3.dispatchAnalyticsEvent,
|
|
151
|
+
editorRef = _ref3.editorRef,
|
|
152
|
+
editorAPI = _ref3.editorAPI;
|
|
153
|
+
return (0, _react2.jsx)(_BaseThemeWrapper.BaseThemeWrapper, {
|
|
154
|
+
baseFontSize: (0, _getBaseFontSize.getBaseFontSize)(props.appearance)
|
|
155
|
+
}, (0, _react2.jsx)(AppearanceComponent, {
|
|
156
|
+
innerRef: editorRef,
|
|
157
|
+
editorAPI: editorAPI,
|
|
158
|
+
appearance: props.appearance,
|
|
159
|
+
disabled: props.disabled,
|
|
160
|
+
editorActions: editorActions,
|
|
161
|
+
editorDOMElement: editor,
|
|
162
|
+
editorView: view,
|
|
163
|
+
providerFactory: providerFactory,
|
|
164
|
+
eventDispatcher: eventDispatcher,
|
|
165
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
166
|
+
maxHeight: props.maxHeight,
|
|
167
|
+
minHeight: props.minHeight,
|
|
168
|
+
onSave: props.onSave ? handleSave : undefined,
|
|
169
|
+
onCancel: props.onCancel,
|
|
170
|
+
popupsMountPoint: props.popupsMountPoint,
|
|
171
|
+
popupsBoundariesElement: props.popupsBoundariesElement,
|
|
172
|
+
popupsScrollableElement: props.popupsScrollableElement,
|
|
173
|
+
contentComponents: config.contentComponents,
|
|
174
|
+
primaryToolbarComponents: config.primaryToolbarComponents,
|
|
175
|
+
primaryToolbarIconBefore: props.primaryToolbarIconBefore,
|
|
176
|
+
secondaryToolbarComponents: config.secondaryToolbarComponents,
|
|
177
|
+
customContentComponents: props.contentComponents,
|
|
178
|
+
customPrimaryToolbarComponents: props.primaryToolbarComponents,
|
|
179
|
+
customSecondaryToolbarComponents: props.secondaryToolbarComponents,
|
|
180
|
+
contextPanel: props.contextPanel,
|
|
181
|
+
collabEdit: props.collabEdit,
|
|
182
|
+
persistScrollGutter: props.persistScrollGutter,
|
|
183
|
+
enableToolbarMinWidth: ((_props$featureFlags3 = props.featureFlags) === null || _props$featureFlags3 === void 0 ? void 0 : _props$featureFlags3.toolbarMinWidthOverflow) != null ? !!((_props$featureFlags4 = props.featureFlags) !== null && _props$featureFlags4 !== void 0 && _props$featureFlags4.toolbarMinWidthOverflow) : props.allowUndoRedoButtons,
|
|
184
|
+
useStickyToolbar: props.useStickyToolbar,
|
|
185
|
+
featureFlags: featureFlags,
|
|
186
|
+
pluginHooks: config.pluginHooks
|
|
187
|
+
}));
|
|
188
|
+
}
|
|
133
189
|
}), (0, _react2.jsx)(PortalRenderer, null))))))));
|
|
134
190
|
});
|
|
135
191
|
function ReactEditorViewContextWrapper(props) {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.formatFullWidthAppearance = void 0;
|
|
7
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
8
|
+
var formatFullWidthAppearance = exports.formatFullWidthAppearance = function formatFullWidthAppearance(appearance) {
|
|
9
|
+
if (appearance === 'full-width') {
|
|
10
|
+
return _analytics.FULL_WIDTH_MODE.FULL_WIDTH;
|
|
11
|
+
}
|
|
12
|
+
return _analytics.FULL_WIDTH_MODE.FIXED_WIDTH;
|
|
13
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getUAPrefix = getUAPrefix;
|
|
7
|
+
var _browser = require("@atlaskit/editor-common/browser");
|
|
8
|
+
function getUAPrefix() {
|
|
9
|
+
if (_browser.browser.chrome) {
|
|
10
|
+
return 'ua-chrome';
|
|
11
|
+
} else if (_browser.browser.ie) {
|
|
12
|
+
return 'ua-ie';
|
|
13
|
+
} else if (_browser.browser.gecko) {
|
|
14
|
+
return 'ua-firefox';
|
|
15
|
+
} else if (_browser.browser.safari) {
|
|
16
|
+
return 'ua-safari';
|
|
17
|
+
}
|
|
18
|
+
return '';
|
|
19
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.handleEditorFocus = handleEditorFocus;
|
|
7
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
8
|
+
function handleEditorFocus(view) {
|
|
9
|
+
if (view.hasFocus()) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
return window.setTimeout(function () {
|
|
13
|
+
if (view.hasFocus()) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (!window.getSelection) {
|
|
17
|
+
view.focus();
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
var domSelection = window.getSelection();
|
|
21
|
+
if (!domSelection || domSelection.rangeCount === 0) {
|
|
22
|
+
view.focus();
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
var range = domSelection.getRangeAt(0);
|
|
26
|
+
// if selection is outside editor focus and exit
|
|
27
|
+
if (range.startContainer.contains(view.dom)) {
|
|
28
|
+
view.focus();
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
// set cursor/selection and focus
|
|
32
|
+
var anchor = view.posAtDOM(range.startContainer, range.startOffset);
|
|
33
|
+
var head = view.posAtDOM(range.endContainer, range.endOffset);
|
|
34
|
+
// if anchor or head < 0 focus and exit
|
|
35
|
+
if (anchor < 0 || head < 0) {
|
|
36
|
+
view.focus();
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
var selection = _state.TextSelection.create(view.state.doc, anchor, head);
|
|
40
|
+
var tr = view.state.tr.setSelection(selection);
|
|
41
|
+
view.dispatch(tr);
|
|
42
|
+
view.focus();
|
|
43
|
+
}, 0);
|
|
44
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useDispatchTransaction = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
9
|
+
var _coreUtils = require("@atlaskit/editor-common/core-utils");
|
|
10
|
+
var _performanceMeasures = require("@atlaskit/editor-common/performance-measures");
|
|
11
|
+
var _findChangedNodesFromTransaction = require("../../utils/findChangedNodesFromTransaction");
|
|
12
|
+
var _saferTransactions = require("../../utils/performance/safer-transactions");
|
|
13
|
+
var _trackTransactions = require("../../utils/performance/track-transactions");
|
|
14
|
+
var _validateNodes = require("../../utils/validateNodes");
|
|
15
|
+
var useDispatchTransaction = exports.useDispatchTransaction = function useDispatchTransaction(_ref) {
|
|
16
|
+
var onChange = _ref.onChange,
|
|
17
|
+
dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent,
|
|
18
|
+
onEditorViewUpdated = _ref.onEditorViewUpdated;
|
|
19
|
+
// We need to have a ref to the latest `onChange` since the `dispatchTransaction` gets captured
|
|
20
|
+
var onChangeRef = (0, _react.useRef)(onChange);
|
|
21
|
+
(0, _react.useEffect)(function () {
|
|
22
|
+
onChangeRef.current = onChange;
|
|
23
|
+
}, [onChange]);
|
|
24
|
+
var dispatchTransaction = (0, _react.useCallback)(function (view, unsafeTransaction) {
|
|
25
|
+
if (!view) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
var nodes = (0, _findChangedNodesFromTransaction.findChangedNodesFromTransaction)(unsafeTransaction);
|
|
29
|
+
var changedNodesValid = (0, _validateNodes.validateNodes)(nodes);
|
|
30
|
+
var transaction = new Proxy(unsafeTransaction, (0, _saferTransactions.freezeUnsafeTransactionProperties)({
|
|
31
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
32
|
+
pluginKey: 'unknown-reacteditorview'
|
|
33
|
+
}));
|
|
34
|
+
if (changedNodesValid) {
|
|
35
|
+
var oldEditorState = view.state;
|
|
36
|
+
|
|
37
|
+
// go ahead and update the state now we know the transaction is good
|
|
38
|
+
var _view$state$applyTran = view.state.applyTransaction(transaction),
|
|
39
|
+
newEditorState = _view$state$applyTran.state,
|
|
40
|
+
transactions = _view$state$applyTran.transactions;
|
|
41
|
+
if (newEditorState === oldEditorState) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
view.updateState(newEditorState);
|
|
45
|
+
onEditorViewUpdated({
|
|
46
|
+
originalTransaction: transaction,
|
|
47
|
+
transactions: transactions,
|
|
48
|
+
oldEditorState: oldEditorState,
|
|
49
|
+
newEditorState: newEditorState
|
|
50
|
+
});
|
|
51
|
+
if (onChangeRef.current && transaction.docChanged) {
|
|
52
|
+
var source = transaction.getMeta('isRemote') ? 'remote' : 'local';
|
|
53
|
+
(0, _performanceMeasures.startMeasure)(_trackTransactions.EVENT_NAME_ON_CHANGE);
|
|
54
|
+
onChangeRef.current(view, {
|
|
55
|
+
source: source
|
|
56
|
+
});
|
|
57
|
+
(0, _performanceMeasures.stopMeasure)(_trackTransactions.EVENT_NAME_ON_CHANGE, function (duration, startTime) {
|
|
58
|
+
dispatchAnalyticsEvent({
|
|
59
|
+
action: _analytics.ACTION.ON_CHANGE_CALLBACK,
|
|
60
|
+
actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
|
|
61
|
+
eventType: _analytics.EVENT_TYPE.OPERATIONAL,
|
|
62
|
+
attributes: {
|
|
63
|
+
duration: duration,
|
|
64
|
+
startTime: startTime
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return newEditorState;
|
|
70
|
+
} else {
|
|
71
|
+
var invalidNodes = nodes.filter(function (node) {
|
|
72
|
+
return !(0, _validateNodes.validNode)(node);
|
|
73
|
+
}).map(function (node) {
|
|
74
|
+
return (0, _coreUtils.getDocStructure)(node, {
|
|
75
|
+
compact: true
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
dispatchAnalyticsEvent({
|
|
79
|
+
action: _analytics.ACTION.DISPATCHED_INVALID_TRANSACTION,
|
|
80
|
+
actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
|
|
81
|
+
eventType: _analytics.EVENT_TYPE.OPERATIONAL,
|
|
82
|
+
attributes: {
|
|
83
|
+
analyticsEventPayloads: (0, _analytics.getAnalyticsEventsFromTransaction)(transaction),
|
|
84
|
+
invalidNodes: invalidNodes
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}, [dispatchAnalyticsEvent, onEditorViewUpdated]);
|
|
89
|
+
return dispatchTransaction;
|
|
90
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useFireFullWidthEvent = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
9
|
+
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
10
|
+
var _formatFullWidthAppearance = require("./formatFullWidthAppearance");
|
|
11
|
+
var useFireFullWidthEvent = exports.useFireFullWidthEvent = function useFireFullWidthEvent(appearance, dispatchAnalyticsEvent) {
|
|
12
|
+
var previousAppearance = (0, _hooks.usePreviousState)(appearance);
|
|
13
|
+
(0, _react.useEffect)(function () {
|
|
14
|
+
if (appearance !== previousAppearance) {
|
|
15
|
+
if (appearance === 'full-width' || previousAppearance === 'full-width') {
|
|
16
|
+
dispatchAnalyticsEvent({
|
|
17
|
+
action: _analytics.ACTION.CHANGED_FULL_WIDTH_MODE,
|
|
18
|
+
actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
|
|
19
|
+
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
20
|
+
attributes: {
|
|
21
|
+
previousMode: (0, _formatFullWidthAppearance.formatFullWidthAppearance)(previousAppearance),
|
|
22
|
+
newMode: (0, _formatFullWidthAppearance.formatFullWidthAppearance)(appearance)
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}, [appearance, previousAppearance, dispatchAnalyticsEvent]);
|
|
28
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.usePluginPerformanceObserver = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
9
|
+
var _countNodes = require("@atlaskit/editor-common/count-nodes");
|
|
10
|
+
var _pluginPerformanceObserver = require("../../utils/performance/plugin-performance-observer");
|
|
11
|
+
var usePluginPerformanceObserver = exports.usePluginPerformanceObserver = function usePluginPerformanceObserver(editorState, pluginInjectionAPI, dispatchAnalyticsEvent) {
|
|
12
|
+
var onPluginObservation = (0, _react.useCallback)(function (report) {
|
|
13
|
+
var _pluginInjectionAPI$c;
|
|
14
|
+
dispatchAnalyticsEvent({
|
|
15
|
+
action: _analytics.ACTION.TRANSACTION_DISPATCHED,
|
|
16
|
+
actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
|
|
17
|
+
eventType: _analytics.EVENT_TYPE.OPERATIONAL,
|
|
18
|
+
attributes: {
|
|
19
|
+
report: report,
|
|
20
|
+
participants: ((_pluginInjectionAPI$c = pluginInjectionAPI.current) === null || _pluginInjectionAPI$c === void 0 || (_pluginInjectionAPI$c = _pluginInjectionAPI$c.api().collabEdit) === null || _pluginInjectionAPI$c === void 0 || (_pluginInjectionAPI$c = _pluginInjectionAPI$c.sharedState.currentState()) === null || _pluginInjectionAPI$c === void 0 || (_pluginInjectionAPI$c = _pluginInjectionAPI$c.participants) === null || _pluginInjectionAPI$c === void 0 ? void 0 : _pluginInjectionAPI$c.size()) || 1
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}, [dispatchAnalyticsEvent, pluginInjectionAPI]);
|
|
24
|
+
var getPluginNames = (0, _react.useCallback)(function () {
|
|
25
|
+
var _editorState$current;
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
|
+
return (_editorState$current = editorState.current) === null || _editorState$current === void 0 ? void 0 : _editorState$current.plugins.map(function (p) {
|
|
28
|
+
return p.key;
|
|
29
|
+
});
|
|
30
|
+
}, [editorState]);
|
|
31
|
+
var pluginPerformanceObserver = (0, _react.useMemo)(function () {
|
|
32
|
+
return new _pluginPerformanceObserver.PluginPerformanceObserver(function (report) {
|
|
33
|
+
return onPluginObservation(report);
|
|
34
|
+
}).withPlugins(function () {
|
|
35
|
+
return getPluginNames();
|
|
36
|
+
}).withNodeCounts(function () {
|
|
37
|
+
return editorState.current ? (0, _countNodes.countNodes)(editorState.current) : {
|
|
38
|
+
nodeCount: {},
|
|
39
|
+
extensionNodeCount: {}
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
}, [onPluginObservation, getPluginNames, editorState]);
|
|
43
|
+
(0, _react.useLayoutEffect)(function () {
|
|
44
|
+
return function () {
|
|
45
|
+
pluginPerformanceObserver.disconnect();
|
|
46
|
+
};
|
|
47
|
+
}, [pluginPerformanceObserver]);
|
|
48
|
+
};
|