@atlaskit/editor-core 201.2.0 → 201.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/cjs/composable-editor/core-editor.js +8 -6
- package/dist/cjs/composable-editor/editor-internal.js +1 -1
- package/dist/cjs/create-editor/ReactEditorView/useDispatchTransaction.js +0 -1
- package/dist/cjs/create-editor/ReactEditorView/usePluginPerformanceObserver.js +7 -6
- package/dist/cjs/create-editor/ReactEditorView.js +3 -3
- package/dist/cjs/create-editor/ReactEditorViewNext.js +56 -45
- package/dist/cjs/create-editor/create-plugins-list.js +1 -1
- package/dist/cjs/create-editor/create-universal-preset.js +1 -1
- package/dist/cjs/create-editor/feature-flags-from-props.js +9 -11
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/composable-editor/core-editor.js +5 -1
- package/dist/es2019/composable-editor/editor-internal.js +1 -1
- package/dist/es2019/create-editor/ReactEditorView/useDispatchTransaction.js +0 -1
- package/dist/es2019/create-editor/ReactEditorView/usePluginPerformanceObserver.js +11 -8
- package/dist/es2019/create-editor/ReactEditorView.js +3 -3
- package/dist/es2019/create-editor/ReactEditorViewNext.js +47 -42
- package/dist/es2019/create-editor/create-plugins-list.js +1 -1
- package/dist/es2019/create-editor/create-universal-preset.js +1 -1
- package/dist/es2019/create-editor/feature-flags-from-props.js +9 -11
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/composable-editor/core-editor.js +7 -1
- package/dist/esm/composable-editor/editor-internal.js +1 -1
- package/dist/esm/create-editor/ReactEditorView/useDispatchTransaction.js +0 -1
- package/dist/esm/create-editor/ReactEditorView/usePluginPerformanceObserver.js +7 -6
- package/dist/esm/create-editor/ReactEditorView.js +3 -3
- package/dist/esm/create-editor/ReactEditorViewNext.js +56 -45
- package/dist/esm/create-editor/create-plugins-list.js +1 -1
- package/dist/esm/create-editor/create-universal-preset.js +1 -1
- package/dist/esm/create-editor/feature-flags-from-props.js +9 -11
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/create-editor/ReactEditorView/useDispatchTransaction.d.ts +2 -2
- package/dist/types/create-editor/ReactEditorView/usePluginPerformanceObserver.d.ts +1 -1
- package/dist/types/create-editor/feature-flags-from-props.d.ts +1 -1
- package/dist/types-ts4.5/create-editor/ReactEditorView/useDispatchTransaction.d.ts +2 -2
- package/dist/types-ts4.5/create-editor/ReactEditorView/usePluginPerformanceObserver.d.ts +1 -1
- package/dist/types-ts4.5/create-editor/feature-flags-from-props.d.ts +1 -1
- package/package.json +7 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @atlaskit/editor-core
|
|
2
2
|
|
|
3
|
+
## 201.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#162942](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/162942)
|
|
8
|
+
[`f7eedf81e6de4`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/f7eedf81e6de4) -
|
|
9
|
+
Refactor ReactEditorViewNext to avoid unnecessary call of functions on re-render and mark
|
|
10
|
+
`useNativeCollabPlugin` FeatureFlag as deprecated.
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
3
13
|
## 201.2.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.CoreEditor = CoreEditor;
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
11
|
var _react = require("react");
|
|
11
12
|
var _react2 = require("@emotion/react");
|
|
12
13
|
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
|
@@ -26,13 +27,11 @@ var _useMeasureEditorMountTime = _interopRequireDefault(require("./hooks/useMeas
|
|
|
26
27
|
var _useMemoEditorProps = _interopRequireDefault(require("./hooks/useMemoEditorProps"));
|
|
27
28
|
var _useProviderFactory = _interopRequireDefault(require("./hooks/useProviderFactory"));
|
|
28
29
|
var _sendDurationAnalytics = _interopRequireDefault(require("./utils/sendDurationAnalytics"));
|
|
29
|
-
|
|
30
|
+
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; }
|
|
31
|
+
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; } /**
|
|
30
32
|
* @jsxRuntime classic
|
|
31
33
|
* @jsx jsx
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
35
|
-
|
|
34
|
+
*/ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
36
35
|
/**
|
|
37
36
|
* Editor wrapper that deals with the lifecycle logic of the editor
|
|
38
37
|
*/
|
|
@@ -53,7 +52,10 @@ function Editor(passedProps) {
|
|
|
53
52
|
(0, _analytics.fireAnalyticsEvent)(createAnalyticsEvent)(data);
|
|
54
53
|
}, [createAnalyticsEvent]);
|
|
55
54
|
var getFeatureFlagsFromRef = (0, _react.useCallback)(function () {
|
|
56
|
-
|
|
55
|
+
var _propsRef$current$col, _propsRef$current$col2;
|
|
56
|
+
return _objectSpread(_objectSpread({}, (0, _featureFlagsFromProps.createFeatureFlagsFromProps)(propsRef.current.featureFlags)), {}, {
|
|
57
|
+
useNativeCollabPlugin: Boolean(typeof ((_propsRef$current$col = propsRef.current.collabEdit) === null || _propsRef$current$col === void 0 ? void 0 : _propsRef$current$col.useNativePlugin) === 'boolean' ? !!((_propsRef$current$col2 = propsRef.current.collabEdit) !== null && _propsRef$current$col2 !== void 0 && _propsRef$current$col2.useNativePlugin) : false)
|
|
58
|
+
});
|
|
57
59
|
}, []);
|
|
58
60
|
var onEditorCreated = (0, _react.useCallback)(function (instance) {
|
|
59
61
|
var _propsRef$current = propsRef.current,
|
|
@@ -55,7 +55,7 @@ var EditorInternal = exports.EditorInternal = /*#__PURE__*/(0, _react.memo)(func
|
|
|
55
55
|
// noop all analytic events, even if a handler is still passed.
|
|
56
56
|
analyticsHandler: undefined
|
|
57
57
|
});
|
|
58
|
-
var featureFlags = (0, _featureFlagsFromProps.createFeatureFlagsFromProps)(props);
|
|
58
|
+
var featureFlags = (0, _featureFlagsFromProps.createFeatureFlagsFromProps)(props.featureFlags);
|
|
59
59
|
|
|
60
60
|
// Render tracking is firing too many events in Jira so we are disabling them for now. See - https://product-fabric.atlassian.net/browse/ED-25616
|
|
61
61
|
var renderTrackingEnabled = !(0, _platformFeatureFlags.fg)('platform_editor_disable_rerender_tracking_jira');
|
|
@@ -8,7 +8,7 @@ var _react = require("react");
|
|
|
8
8
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
9
9
|
var _countNodes = require("@atlaskit/editor-common/count-nodes");
|
|
10
10
|
var _pluginPerformanceObserver = require("../../utils/performance/plugin-performance-observer");
|
|
11
|
-
var usePluginPerformanceObserver = exports.usePluginPerformanceObserver = function usePluginPerformanceObserver(
|
|
11
|
+
var usePluginPerformanceObserver = exports.usePluginPerformanceObserver = function usePluginPerformanceObserver(getEditorState, pluginInjectionAPI, dispatchAnalyticsEvent) {
|
|
12
12
|
var onPluginObservation = (0, _react.useCallback)(function (report) {
|
|
13
13
|
var _pluginInjectionAPI$c;
|
|
14
14
|
dispatchAnalyticsEvent({
|
|
@@ -22,24 +22,25 @@ var usePluginPerformanceObserver = exports.usePluginPerformanceObserver = functi
|
|
|
22
22
|
});
|
|
23
23
|
}, [dispatchAnalyticsEvent, pluginInjectionAPI]);
|
|
24
24
|
var getPluginNames = (0, _react.useCallback)(function () {
|
|
25
|
-
var
|
|
25
|
+
var _getEditorState;
|
|
26
26
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
|
-
return (
|
|
27
|
+
return (_getEditorState = getEditorState()) === null || _getEditorState === void 0 ? void 0 : _getEditorState.plugins.map(function (p) {
|
|
28
28
|
return p.key;
|
|
29
29
|
});
|
|
30
|
-
}, [
|
|
30
|
+
}, [getEditorState]);
|
|
31
31
|
var pluginPerformanceObserver = (0, _react.useMemo)(function () {
|
|
32
|
+
var state = getEditorState();
|
|
32
33
|
return new _pluginPerformanceObserver.PluginPerformanceObserver(function (report) {
|
|
33
34
|
return onPluginObservation(report);
|
|
34
35
|
}).withPlugins(function () {
|
|
35
36
|
return getPluginNames();
|
|
36
37
|
}).withNodeCounts(function () {
|
|
37
|
-
return
|
|
38
|
+
return state ? (0, _countNodes.countNodes)(state) : {
|
|
38
39
|
nodeCount: {},
|
|
39
40
|
extensionNodeCount: {}
|
|
40
41
|
};
|
|
41
42
|
});
|
|
42
|
-
}, [onPluginObservation, getPluginNames,
|
|
43
|
+
}, [onPluginObservation, getPluginNames, getEditorState]);
|
|
43
44
|
(0, _react.useLayoutEffect)(function () {
|
|
44
45
|
return function () {
|
|
45
46
|
pluginPerformanceObserver.disconnect();
|
|
@@ -137,7 +137,7 @@ var ReactEditorView = exports.ReactEditorView = /*#__PURE__*/function (_React$Co
|
|
|
137
137
|
// so we blur here to stop ProseMirror from trying to apply selection to detached nodes or
|
|
138
138
|
// nodes that haven't been re-rendered to the document yet.
|
|
139
139
|
_this.blur();
|
|
140
|
-
_this.featureFlags = (0, _featureFlagsFromProps.createFeatureFlagsFromProps)(_this.props.editorProps);
|
|
140
|
+
_this.featureFlags = (0, _featureFlagsFromProps.createFeatureFlagsFromProps)(_this.props.editorProps.featureFlags);
|
|
141
141
|
_this.editorState = _this.createEditorState({
|
|
142
142
|
props: _this.props,
|
|
143
143
|
doc: doc,
|
|
@@ -477,7 +477,7 @@ var ReactEditorView = exports.ReactEditorView = /*#__PURE__*/function (_React$Co
|
|
|
477
477
|
}).withNodeCounts(function () {
|
|
478
478
|
return _this.countNodes();
|
|
479
479
|
});
|
|
480
|
-
_this.featureFlags = (0, _featureFlagsFromProps.createFeatureFlagsFromProps)(_this.props.editorProps);
|
|
480
|
+
_this.featureFlags = (0, _featureFlagsFromProps.createFeatureFlagsFromProps)(_this.props.editorProps.featureFlags);
|
|
481
481
|
var featureFlagsEnabled = _this.featureFlags ? (0, _normalizeFeatureFlags.getEnabledFeatureFlagKeys)(_this.featureFlags) : [];
|
|
482
482
|
|
|
483
483
|
// This needs to be before initialising editorState because
|
|
@@ -586,7 +586,7 @@ var ReactEditorView = exports.ReactEditorView = /*#__PURE__*/function (_React$Co
|
|
|
586
586
|
portalProviderAPI: props.portalProviderAPI,
|
|
587
587
|
nodeViewPortalProviderAPI: props.nodeViewPortalProviderAPI,
|
|
588
588
|
dispatchAnalyticsEvent: this.dispatchAnalyticsEvent,
|
|
589
|
-
featureFlags: (0, _featureFlagsFromProps.createFeatureFlagsFromProps)(props.editorProps),
|
|
589
|
+
featureFlags: (0, _featureFlagsFromProps.createFeatureFlagsFromProps)(props.editorProps.featureFlags),
|
|
590
590
|
getIntl: function getIntl() {
|
|
591
591
|
return _this2.props.intl;
|
|
592
592
|
}
|
|
@@ -50,7 +50,10 @@ function ReactEditorView(props) {
|
|
|
50
50
|
var preset = props.preset,
|
|
51
51
|
_props$editorProps = props.editorProps,
|
|
52
52
|
nextAppearance = _props$editorProps.appearance,
|
|
53
|
-
disabled = _props$editorProps.disabled
|
|
53
|
+
disabled = _props$editorProps.disabled,
|
|
54
|
+
editorPropFeatureFlags = _props$editorProps.featureFlags,
|
|
55
|
+
errorReporterHandler = _props$editorProps.errorReporterHandler,
|
|
56
|
+
defaultValue = _props$editorProps.defaultValue;
|
|
54
57
|
var _useState = (0, _react.useState)(undefined),
|
|
55
58
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
56
59
|
editorAPI = _useState2[0],
|
|
@@ -76,7 +79,9 @@ function ReactEditorView(props) {
|
|
|
76
79
|
onEditorViewStateUpdatedCallbacks: []
|
|
77
80
|
});
|
|
78
81
|
var contentTransformer = (0, _react.useRef)(undefined);
|
|
79
|
-
var featureFlags = (0, _react.
|
|
82
|
+
var featureFlags = (0, _react.useMemo)(function () {
|
|
83
|
+
return (0, _featureFlagsFromProps.createFeatureFlagsFromProps)(editorPropFeatureFlags);
|
|
84
|
+
}, [editorPropFeatureFlags]);
|
|
80
85
|
var getEditorState = (0, _react.useCallback)(function () {
|
|
81
86
|
var _viewRef$current;
|
|
82
87
|
return (_viewRef$current = viewRef.current) === null || _viewRef$current === void 0 ? void 0 : _viewRef$current.state;
|
|
@@ -87,7 +92,9 @@ function ReactEditorView(props) {
|
|
|
87
92
|
var dispatch = (0, _react.useMemo)(function () {
|
|
88
93
|
return (0, _eventDispatcher.createDispatch)(eventDispatcher);
|
|
89
94
|
}, [eventDispatcher]);
|
|
90
|
-
var errorReporter = (0, _react.
|
|
95
|
+
var errorReporter = (0, _react.useMemo)(function () {
|
|
96
|
+
return (0, _createEditor.createErrorReporter)(errorReporterHandler);
|
|
97
|
+
}, [errorReporterHandler]);
|
|
91
98
|
var handleAnalyticsEvent = (0, _react.useCallback)(function (payload) {
|
|
92
99
|
(0, _analytics.fireAnalyticsEvent)(props.createAnalyticsEvent)(payload);
|
|
93
100
|
}, [props.createAnalyticsEvent]);
|
|
@@ -104,22 +111,6 @@ function ReactEditorView(props) {
|
|
|
104
111
|
(0, _react.useLayoutEffect)(function () {
|
|
105
112
|
setEditorAPI(pluginInjectionAPI.current.api());
|
|
106
113
|
}, []);
|
|
107
|
-
var blur = (0, _react.useCallback)(function () {
|
|
108
|
-
if (!viewRef.current) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
if (viewRef.current.dom instanceof HTMLElement && viewRef.current.hasFocus()) {
|
|
112
|
-
viewRef.current.dom.blur();
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// The selectionToDOM method uses the document selection to determine currently selected node
|
|
116
|
-
// We need to mimic blurring this as it seems doing the above is not enough.
|
|
117
|
-
// @ts-expect-error
|
|
118
|
-
var sel = viewRef.current.root.getSelection();
|
|
119
|
-
if (sel) {
|
|
120
|
-
sel.removeAllRanges();
|
|
121
|
-
}
|
|
122
|
-
}, []);
|
|
123
114
|
var createEditorState = (0, _react.useCallback)(function (options) {
|
|
124
115
|
var _api$editorViewMode;
|
|
125
116
|
var schema;
|
|
@@ -151,14 +142,14 @@ function ReactEditorView(props) {
|
|
|
151
142
|
var plugins = (0, _createEditor.createPMPlugins)({
|
|
152
143
|
schema: schema,
|
|
153
144
|
dispatch: dispatch,
|
|
154
|
-
errorReporter: errorReporter
|
|
145
|
+
errorReporter: errorReporter,
|
|
155
146
|
editorConfig: config.current,
|
|
156
147
|
eventDispatcher: eventDispatcher,
|
|
157
148
|
providerFactory: options.props.providerFactory,
|
|
158
149
|
portalProviderAPI: props.portalProviderAPI,
|
|
159
150
|
nodeViewPortalProviderAPI: props.nodeViewPortalProviderAPI,
|
|
160
151
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
161
|
-
featureFlags: featureFlags
|
|
152
|
+
featureFlags: featureFlags,
|
|
162
153
|
getIntl: function getIntl() {
|
|
163
154
|
return props.intl;
|
|
164
155
|
}
|
|
@@ -200,7 +191,38 @@ function ReactEditorView(props) {
|
|
|
200
191
|
doc: doc,
|
|
201
192
|
selection: patchedSelection
|
|
202
193
|
});
|
|
203
|
-
}, [props.intl, props.portalProviderAPI, props.nodeViewPortalProviderAPI, props.editorProps, dispatchAnalyticsEvent, eventDispatcher, dispatch]);
|
|
194
|
+
}, [errorReporter, featureFlags, props.intl, props.portalProviderAPI, props.nodeViewPortalProviderAPI, props.editorProps, dispatchAnalyticsEvent, eventDispatcher, dispatch]);
|
|
195
|
+
var initialEditorState = (0, _react.useMemo)(function () {
|
|
196
|
+
return createEditorState({
|
|
197
|
+
props: props,
|
|
198
|
+
doc: defaultValue,
|
|
199
|
+
// ED-4759: Don't set selection at end for full-page editor - should be at start.
|
|
200
|
+
selectionAtStart: (0, _isFullPage.isFullPage)(nextAppearance)
|
|
201
|
+
});
|
|
202
|
+
},
|
|
203
|
+
// This is only used for the initial state - afterwards we will have `viewRef` available for use
|
|
204
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
205
|
+
[]);
|
|
206
|
+
var getCurrentEditorState = (0, _react.useCallback)(function () {
|
|
207
|
+
var _viewRef$current$stat, _viewRef$current2;
|
|
208
|
+
return (_viewRef$current$stat = (_viewRef$current2 = viewRef.current) === null || _viewRef$current2 === void 0 ? void 0 : _viewRef$current2.state) !== null && _viewRef$current$stat !== void 0 ? _viewRef$current$stat : initialEditorState;
|
|
209
|
+
}, [initialEditorState]);
|
|
210
|
+
var blur = (0, _react.useCallback)(function () {
|
|
211
|
+
if (!viewRef.current) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
if (viewRef.current.dom instanceof HTMLElement && viewRef.current.hasFocus()) {
|
|
215
|
+
viewRef.current.dom.blur();
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// The selectionToDOM method uses the document selection to determine currently selected node
|
|
219
|
+
// We need to mimic blurring this as it seems doing the above is not enough.
|
|
220
|
+
// @ts-expect-error
|
|
221
|
+
var sel = viewRef.current.root.getSelection();
|
|
222
|
+
if (sel) {
|
|
223
|
+
sel.removeAllRanges();
|
|
224
|
+
}
|
|
225
|
+
}, []);
|
|
204
226
|
var resetEditorState = (0, _react.useCallback)(function (_ref) {
|
|
205
227
|
var _props$editorProps$on, _props$editorProps2;
|
|
206
228
|
var doc = _ref.doc,
|
|
@@ -213,14 +235,12 @@ function ReactEditorView(props) {
|
|
|
213
235
|
// so we blur here to stop ProseMirror from trying to apply selection to detached nodes or
|
|
214
236
|
// nodes that haven't been re-rendered to the document yet.
|
|
215
237
|
blur();
|
|
216
|
-
featureFlags.current = (0, _featureFlagsFromProps.createFeatureFlagsFromProps)(props.editorProps);
|
|
217
238
|
var newEditorState = createEditorState({
|
|
218
239
|
props: props,
|
|
219
240
|
doc: doc,
|
|
220
241
|
resetting: true,
|
|
221
242
|
selectionAtStart: !shouldScrollToBottom
|
|
222
243
|
});
|
|
223
|
-
editorState.current = newEditorState;
|
|
224
244
|
viewRef.current.updateState(newEditorState);
|
|
225
245
|
(_props$editorProps$on = (_props$editorProps2 = props.editorProps).onChange) === null || _props$editorProps$on === void 0 || _props$editorProps$on.call(_props$editorProps2, viewRef.current, {
|
|
226
246
|
source: 'local'
|
|
@@ -235,7 +255,7 @@ function ReactEditorView(props) {
|
|
|
235
255
|
actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
|
|
236
256
|
attributes: {
|
|
237
257
|
platform: _analytics.PLATFORMS.WEB,
|
|
238
|
-
featureFlags: featureFlags
|
|
258
|
+
featureFlags: featureFlags ? (0, _normalizeFeatureFlags.getEnabledFeatureFlagKeys)(featureFlags) : []
|
|
239
259
|
},
|
|
240
260
|
eventType: _analytics.EVENT_TYPE.UI
|
|
241
261
|
});
|
|
@@ -262,9 +282,9 @@ function ReactEditorView(props) {
|
|
|
262
282
|
}
|
|
263
283
|
if (viewRef.current) {
|
|
264
284
|
// Destroy the state if the Editor is being unmounted
|
|
265
|
-
var
|
|
266
|
-
|
|
267
|
-
var state = plugin.getState(
|
|
285
|
+
var editorState = viewRef.current.state;
|
|
286
|
+
editorState.plugins.forEach(function (plugin) {
|
|
287
|
+
var state = plugin.getState(editorState);
|
|
268
288
|
if (state && state.destroy) {
|
|
269
289
|
state.destroy();
|
|
270
290
|
}
|
|
@@ -285,18 +305,18 @@ function ReactEditorView(props) {
|
|
|
285
305
|
blur();
|
|
286
306
|
var editorPlugins = (0, _createPluginsList.default)(props.preset, props.editorProps, pluginInjectionAPI.current);
|
|
287
307
|
config.current = (0, _createEditor.processPluginsList)(editorPlugins);
|
|
288
|
-
var state =
|
|
308
|
+
var state = viewRef.current.state;
|
|
289
309
|
var plugins = (0, _createEditor.createPMPlugins)({
|
|
290
310
|
schema: state.schema,
|
|
291
311
|
dispatch: dispatch,
|
|
292
|
-
errorReporter: errorReporter
|
|
312
|
+
errorReporter: errorReporter,
|
|
293
313
|
editorConfig: config.current,
|
|
294
314
|
eventDispatcher: eventDispatcher,
|
|
295
315
|
providerFactory: props.providerFactory,
|
|
296
316
|
portalProviderAPI: props.portalProviderAPI,
|
|
297
317
|
nodeViewPortalProviderAPI: props.nodeViewPortalProviderAPI,
|
|
298
318
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
299
|
-
featureFlags:
|
|
319
|
+
featureFlags: featureFlags,
|
|
300
320
|
getIntl: function getIntl() {
|
|
301
321
|
return props.intl;
|
|
302
322
|
}
|
|
@@ -311,7 +331,7 @@ function ReactEditorView(props) {
|
|
|
311
331
|
return viewRef.current.update(_objectSpread(_objectSpread({}, viewRef.current.props), {}, {
|
|
312
332
|
state: newState
|
|
313
333
|
}));
|
|
314
|
-
}, [blur, dispatchAnalyticsEvent, eventDispatcher, dispatch]);
|
|
334
|
+
}, [blur, dispatchAnalyticsEvent, eventDispatcher, dispatch, errorReporter, featureFlags]);
|
|
315
335
|
var onEditorViewUpdated = (0, _react.useCallback)(function (_ref2) {
|
|
316
336
|
var _config$current;
|
|
317
337
|
var originalTransaction = _ref2.originalTransaction,
|
|
@@ -353,16 +373,13 @@ function ReactEditorView(props) {
|
|
|
353
373
|
});
|
|
354
374
|
var getDirectEditorProps = (0, _react.useCallback)(function (state) {
|
|
355
375
|
return {
|
|
356
|
-
state: state
|
|
376
|
+
state: state !== null && state !== void 0 ? state : getCurrentEditorState(),
|
|
357
377
|
dispatchTransaction: function dispatchTransaction(tr) {
|
|
358
378
|
// Block stale transactions:
|
|
359
379
|
// Prevent runtime exeptions from async transactions that would attempt to
|
|
360
380
|
// update the DOM after React has unmounted the Editor.
|
|
361
381
|
if (canDispatchTransactions.current) {
|
|
362
|
-
|
|
363
|
-
if (newState) {
|
|
364
|
-
editorState.current = newState;
|
|
365
|
-
}
|
|
382
|
+
_dispatchTransaction(viewRef.current, tr);
|
|
366
383
|
}
|
|
367
384
|
},
|
|
368
385
|
// Disables the contentEditable attribute of the editor if the editor is disabled
|
|
@@ -373,7 +390,7 @@ function ReactEditorView(props) {
|
|
|
373
390
|
'data-gramm': 'false'
|
|
374
391
|
}
|
|
375
392
|
};
|
|
376
|
-
}, [_dispatchTransaction, disabled]);
|
|
393
|
+
}, [_dispatchTransaction, disabled, getCurrentEditorState]);
|
|
377
394
|
var createEditorView = (0, _react.useCallback)(function (node) {
|
|
378
395
|
(0, _measureRender.measureRender)(_measureEnum.default.PROSEMIRROR_RENDERED, function (_ref3) {
|
|
379
396
|
var duration = _ref3.duration,
|
|
@@ -500,13 +517,7 @@ function ReactEditorView(props) {
|
|
|
500
517
|
}
|
|
501
518
|
}, [disabled, shouldFocus, previousDisabledState]);
|
|
502
519
|
(0, _useFireFullWidthEvent.useFireFullWidthEvent)(nextAppearance, dispatchAnalyticsEvent);
|
|
503
|
-
|
|
504
|
-
props: props,
|
|
505
|
-
doc: props.editorProps.defaultValue,
|
|
506
|
-
// ED-4759: Don't set selection at end for full-page editor - should be at start.
|
|
507
|
-
selectionAtStart: (0, _isFullPage.isFullPage)(props.editorProps.appearance)
|
|
508
|
-
}));
|
|
509
|
-
(0, _usePluginPerformanceObserver.usePluginPerformanceObserver)(editorState, pluginInjectionAPI, dispatchAnalyticsEvent);
|
|
520
|
+
(0, _usePluginPerformanceObserver.usePluginPerformanceObserver)(getCurrentEditorState, pluginInjectionAPI, dispatchAnalyticsEvent);
|
|
510
521
|
var editor = (0, _react.useMemo)(function () {
|
|
511
522
|
return createEditor(props.editorProps.assistiveLabel, props.editorProps.assistiveDescribedBy);
|
|
512
523
|
},
|
|
@@ -39,7 +39,7 @@ function getDefaultPresetOptionsFromEditorProps(props, createAnalyticsEvent
|
|
|
39
39
|
typeAhead: {
|
|
40
40
|
isMobile: false
|
|
41
41
|
},
|
|
42
|
-
featureFlags: (0, _featureFlagsFromProps.createFeatureFlagsFromProps)(props),
|
|
42
|
+
featureFlags: (0, _featureFlagsFromProps.createFeatureFlagsFromProps)(props.featureFlags),
|
|
43
43
|
paste: {
|
|
44
44
|
cardOptions: cardOptions,
|
|
45
45
|
sanitizePrivateContent: props.sanitizePrivateContent
|
|
@@ -19,7 +19,7 @@ function createUniversalPreset(_ref) {
|
|
|
19
19
|
appearance: props.appearance,
|
|
20
20
|
props: (0, _createPluginsList.getDefaultPresetOptionsFromEditorProps)(props),
|
|
21
21
|
initialPluginConfiguration: initialPluginConfiguration,
|
|
22
|
-
featureFlags: (0, _featureFlagsFromProps.createFeatureFlagsFromProps)(props),
|
|
22
|
+
featureFlags: (0, _featureFlagsFromProps.createFeatureFlagsFromProps)(props.featureFlags),
|
|
23
23
|
prevAppearance: prevProps === null || prevProps === void 0 ? void 0 : prevProps.appearance
|
|
24
24
|
});
|
|
25
25
|
return withDangerouslyAppendPlugins(preset)((_props$dangerouslyApp = props.dangerouslyAppendPlugins) === null || _props$dangerouslyApp === void 0 ? void 0 : _props$dangerouslyApp.__plugins);
|
|
@@ -31,18 +31,16 @@ function getSpellCheck(featureFlags) {
|
|
|
31
31
|
* Transforms EditorProps to an FeatureFlags object,
|
|
32
32
|
* which is used by both current and archv3 editors.
|
|
33
33
|
*/
|
|
34
|
-
function createFeatureFlagsFromProps(
|
|
35
|
-
var
|
|
36
|
-
var normalizedFeatureFlags = (0, _normalizeFeatureFlags.normalizeFeatureFlags)(props.featureFlags);
|
|
34
|
+
function createFeatureFlagsFromProps(featureFlags) {
|
|
35
|
+
var normalizedFeatureFlags = (0, _normalizeFeatureFlags.normalizeFeatureFlags)(featureFlags);
|
|
37
36
|
return _objectSpread(_objectSpread({}, normalizedFeatureFlags), {}, {
|
|
38
37
|
catchAllTracking: false,
|
|
39
|
-
showAvatarGroupAsPlugin: Boolean(typeof (
|
|
40
|
-
errorBoundaryDocStructure: Boolean(typeof (
|
|
41
|
-
synchronyErrorDocStructure: Boolean(typeof (
|
|
42
|
-
enableViewUpdateSubscription: Boolean(typeof (
|
|
43
|
-
collabAvatarScroll: Boolean(typeof (
|
|
44
|
-
twoLineEditorToolbar: Boolean(typeof (
|
|
45
|
-
|
|
46
|
-
disableSpellcheckByBrowser: getSpellCheck(props.featureFlags)
|
|
38
|
+
showAvatarGroupAsPlugin: Boolean(typeof (featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.showAvatarGroupAsPlugin) === 'boolean' ? !!(featureFlags !== null && featureFlags !== void 0 && featureFlags.showAvatarGroupAsPlugin) : false),
|
|
39
|
+
errorBoundaryDocStructure: Boolean(typeof (featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.useErrorBoundaryDocStructure) === 'boolean' ? !!(featureFlags !== null && featureFlags !== void 0 && featureFlags.useErrorBoundaryDocStructure) : false),
|
|
40
|
+
synchronyErrorDocStructure: Boolean(typeof (featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.synchronyErrorDocStructure) === 'boolean' ? !!(featureFlags !== null && featureFlags !== void 0 && featureFlags.synchronyErrorDocStructure) : false),
|
|
41
|
+
enableViewUpdateSubscription: Boolean(typeof (featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.enableViewUpdateSubscription) === 'boolean' ? !!(featureFlags !== null && featureFlags !== void 0 && featureFlags.enableViewUpdateSubscription) : false),
|
|
42
|
+
collabAvatarScroll: Boolean(typeof (featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.collabAvatarScroll) === 'boolean' ? !!(featureFlags !== null && featureFlags !== void 0 && featureFlags.collabAvatarScroll) : false),
|
|
43
|
+
twoLineEditorToolbar: Boolean(typeof (featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.twoLineEditorToolbar) === 'boolean' ? !!(featureFlags !== null && featureFlags !== void 0 && featureFlags.twoLineEditorToolbar) : false),
|
|
44
|
+
disableSpellcheckByBrowser: getSpellCheck(featureFlags)
|
|
47
45
|
});
|
|
48
46
|
}
|
|
@@ -44,7 +44,11 @@ function Editor(passedProps) {
|
|
|
44
44
|
fireAnalyticsEvent(createAnalyticsEvent)(data);
|
|
45
45
|
}, [createAnalyticsEvent]);
|
|
46
46
|
const getFeatureFlagsFromRef = useCallback(() => {
|
|
47
|
-
|
|
47
|
+
var _propsRef$current$col, _propsRef$current$col2;
|
|
48
|
+
return {
|
|
49
|
+
...createFeatureFlagsFromProps(propsRef.current.featureFlags),
|
|
50
|
+
useNativeCollabPlugin: Boolean(typeof ((_propsRef$current$col = propsRef.current.collabEdit) === null || _propsRef$current$col === void 0 ? void 0 : _propsRef$current$col.useNativePlugin) === 'boolean' ? !!((_propsRef$current$col2 = propsRef.current.collabEdit) !== null && _propsRef$current$col2 !== void 0 && _propsRef$current$col2.useNativePlugin) : false)
|
|
51
|
+
};
|
|
48
52
|
}, []);
|
|
49
53
|
const onEditorCreated = useCallback(instance => {
|
|
50
54
|
const {
|
|
@@ -49,7 +49,7 @@ export const EditorInternal = /*#__PURE__*/memo(({
|
|
|
49
49
|
// noop all analytic events, even if a handler is still passed.
|
|
50
50
|
analyticsHandler: undefined
|
|
51
51
|
};
|
|
52
|
-
const featureFlags = createFeatureFlagsFromProps(props);
|
|
52
|
+
const featureFlags = createFeatureFlagsFromProps(props.featureFlags);
|
|
53
53
|
|
|
54
54
|
// Render tracking is firing too many events in Jira so we are disabling them for now. See - https://product-fabric.atlassian.net/browse/ED-25616
|
|
55
55
|
const renderTrackingEnabled = !fg('platform_editor_disable_rerender_tracking_jira');
|
|
@@ -2,7 +2,7 @@ import { useCallback, useLayoutEffect, useMemo } from 'react';
|
|
|
2
2
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import { countNodes } from '@atlaskit/editor-common/count-nodes';
|
|
4
4
|
import { PluginPerformanceObserver } from '../../utils/performance/plugin-performance-observer';
|
|
5
|
-
export const usePluginPerformanceObserver = (
|
|
5
|
+
export const usePluginPerformanceObserver = (getEditorState, pluginInjectionAPI, dispatchAnalyticsEvent) => {
|
|
6
6
|
const onPluginObservation = useCallback(report => {
|
|
7
7
|
var _pluginInjectionAPI$c, _pluginInjectionAPI$c2, _pluginInjectionAPI$c3, _pluginInjectionAPI$c4;
|
|
8
8
|
dispatchAnalyticsEvent({
|
|
@@ -16,14 +16,17 @@ export const usePluginPerformanceObserver = (editorState, pluginInjectionAPI, di
|
|
|
16
16
|
});
|
|
17
17
|
}, [dispatchAnalyticsEvent, pluginInjectionAPI]);
|
|
18
18
|
const getPluginNames = useCallback(() => {
|
|
19
|
-
var
|
|
19
|
+
var _getEditorState;
|
|
20
20
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
|
-
return (
|
|
22
|
-
}, [
|
|
23
|
-
const pluginPerformanceObserver = useMemo(() =>
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
return (_getEditorState = getEditorState()) === null || _getEditorState === void 0 ? void 0 : _getEditorState.plugins.map(p => p.key);
|
|
22
|
+
}, [getEditorState]);
|
|
23
|
+
const pluginPerformanceObserver = useMemo(() => {
|
|
24
|
+
const state = getEditorState();
|
|
25
|
+
return new PluginPerformanceObserver(report => onPluginObservation(report)).withPlugins(() => getPluginNames()).withNodeCounts(() => state ? countNodes(state) : {
|
|
26
|
+
nodeCount: {},
|
|
27
|
+
extensionNodeCount: {}
|
|
28
|
+
});
|
|
29
|
+
}, [onPluginObservation, getPluginNames, getEditorState]);
|
|
27
30
|
useLayoutEffect(() => {
|
|
28
31
|
return () => {
|
|
29
32
|
pluginPerformanceObserver.disconnect();
|
|
@@ -128,7 +128,7 @@ export class ReactEditorView extends React.Component {
|
|
|
128
128
|
// so we blur here to stop ProseMirror from trying to apply selection to detached nodes or
|
|
129
129
|
// nodes that haven't been re-rendered to the document yet.
|
|
130
130
|
this.blur();
|
|
131
|
-
this.featureFlags = createFeatureFlagsFromProps(this.props.editorProps);
|
|
131
|
+
this.featureFlags = createFeatureFlagsFromProps(this.props.editorProps.featureFlags);
|
|
132
132
|
this.editorState = this.createEditorState({
|
|
133
133
|
props: this.props,
|
|
134
134
|
doc: doc,
|
|
@@ -459,7 +459,7 @@ export class ReactEditorView extends React.Component {
|
|
|
459
459
|
this.dispatch = createDispatch(this.eventDispatcher);
|
|
460
460
|
this.errorReporter = createErrorReporter(props.editorProps.errorReporterHandler);
|
|
461
461
|
this.pluginPerformanceObserver = new PluginPerformanceObserver(report => this.onPluginObservation(report)).withPlugins(() => this.getPluginNames()).withNodeCounts(() => this.countNodes());
|
|
462
|
-
this.featureFlags = createFeatureFlagsFromProps(this.props.editorProps);
|
|
462
|
+
this.featureFlags = createFeatureFlagsFromProps(this.props.editorProps.featureFlags);
|
|
463
463
|
const featureFlagsEnabled = this.featureFlags ? getEnabledFeatureFlagKeys(this.featureFlags) : [];
|
|
464
464
|
|
|
465
465
|
// This needs to be before initialising editorState because
|
|
@@ -542,7 +542,7 @@ export class ReactEditorView extends React.Component {
|
|
|
542
542
|
portalProviderAPI: props.portalProviderAPI,
|
|
543
543
|
nodeViewPortalProviderAPI: props.nodeViewPortalProviderAPI,
|
|
544
544
|
dispatchAnalyticsEvent: this.dispatchAnalyticsEvent,
|
|
545
|
-
featureFlags: createFeatureFlagsFromProps(props.editorProps),
|
|
545
|
+
featureFlags: createFeatureFlagsFromProps(props.editorProps.featureFlags),
|
|
546
546
|
getIntl: () => this.props.intl
|
|
547
547
|
});
|
|
548
548
|
const newState = state.reconfigure({
|