@atlaskit/editor-core 188.8.0 → 188.9.0

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.
Files changed (95) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/composable-editor/editor-internal.js +2 -2
  3. package/dist/cjs/create-editor/ReactEditorView.js +796 -8
  4. package/dist/cjs/labs/next/presets/universal.js +7 -4
  5. package/dist/cjs/plugins/index.js +0 -21
  6. package/dist/cjs/version-wrapper.js +1 -1
  7. package/dist/es2019/composable-editor/editor-internal.js +1 -1
  8. package/dist/es2019/create-editor/ReactEditorView.js +753 -2
  9. package/dist/es2019/labs/next/presets/universal.js +4 -1
  10. package/dist/es2019/plugins/index.js +0 -3
  11. package/dist/es2019/version-wrapper.js +1 -1
  12. package/dist/esm/composable-editor/editor-internal.js +1 -1
  13. package/dist/esm/create-editor/ReactEditorView.js +797 -8
  14. package/dist/esm/labs/next/presets/universal.js +4 -1
  15. package/dist/esm/plugins/index.js +0 -3
  16. package/dist/esm/version-wrapper.js +1 -1
  17. package/dist/types/create-editor/ReactEditorView.d.ts +119 -5
  18. package/dist/types/plugins/index.d.ts +0 -3
  19. package/dist/types/plugins/insert-block/types.d.ts +1 -1
  20. package/dist/types/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.d.ts +1 -1
  21. package/dist/types-ts4.5/create-editor/ReactEditorView.d.ts +119 -5
  22. package/dist/types-ts4.5/plugins/index.d.ts +0 -3
  23. package/dist/types-ts4.5/plugins/insert-block/types.d.ts +1 -1
  24. package/dist/types-ts4.5/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.d.ts +1 -1
  25. package/package.json +5 -3
  26. package/dist/cjs/create-editor/ReactEditorViewInternal.js +0 -812
  27. package/dist/cjs/create-editor/ReactEditorViewNext.js +0 -15
  28. package/dist/cjs/plugins/save-on-enter/index.js +0 -70
  29. package/dist/cjs/plugins/scroll-into-view/index.js +0 -55
  30. package/dist/cjs/plugins/status/actions.js +0 -158
  31. package/dist/cjs/plugins/status/analytics.js +0 -31
  32. package/dist/cjs/plugins/status/index.js +0 -143
  33. package/dist/cjs/plugins/status/keymap.js +0 -22
  34. package/dist/cjs/plugins/status/nodeviews/status.js +0 -58
  35. package/dist/cjs/plugins/status/plugin-key.js +0 -9
  36. package/dist/cjs/plugins/status/plugin.js +0 -133
  37. package/dist/cjs/plugins/status/types.js +0 -5
  38. package/dist/cjs/plugins/status/ui/statusPicker.js +0 -314
  39. package/dist/cjs/plugins/status/utils.js +0 -22
  40. package/dist/es2019/create-editor/ReactEditorViewInternal.js +0 -753
  41. package/dist/es2019/create-editor/ReactEditorViewNext.js +0 -7
  42. package/dist/es2019/plugins/save-on-enter/index.js +0 -63
  43. package/dist/es2019/plugins/scroll-into-view/index.js +0 -44
  44. package/dist/es2019/plugins/status/actions.js +0 -144
  45. package/dist/es2019/plugins/status/analytics.js +0 -18
  46. package/dist/es2019/plugins/status/index.js +0 -135
  47. package/dist/es2019/plugins/status/keymap.js +0 -13
  48. package/dist/es2019/plugins/status/nodeviews/status.js +0 -60
  49. package/dist/es2019/plugins/status/plugin-key.js +0 -3
  50. package/dist/es2019/plugins/status/plugin.js +0 -113
  51. package/dist/es2019/plugins/status/types.js +0 -1
  52. package/dist/es2019/plugins/status/ui/statusPicker.js +0 -293
  53. package/dist/es2019/plugins/status/utils.js +0 -12
  54. package/dist/esm/create-editor/ReactEditorViewInternal.js +0 -806
  55. package/dist/esm/create-editor/ReactEditorViewNext.js +0 -7
  56. package/dist/esm/plugins/save-on-enter/index.js +0 -63
  57. package/dist/esm/plugins/scroll-into-view/index.js +0 -50
  58. package/dist/esm/plugins/status/actions.js +0 -151
  59. package/dist/esm/plugins/status/analytics.js +0 -24
  60. package/dist/esm/plugins/status/index.js +0 -136
  61. package/dist/esm/plugins/status/keymap.js +0 -15
  62. package/dist/esm/plugins/status/nodeviews/status.js +0 -51
  63. package/dist/esm/plugins/status/plugin-key.js +0 -3
  64. package/dist/esm/plugins/status/plugin.js +0 -115
  65. package/dist/esm/plugins/status/types.js +0 -1
  66. package/dist/esm/plugins/status/ui/statusPicker.js +0 -308
  67. package/dist/esm/plugins/status/utils.js +0 -16
  68. package/dist/types/create-editor/ReactEditorViewInternal.d.ts +0 -119
  69. package/dist/types/create-editor/ReactEditorViewNext.d.ts +0 -8
  70. package/dist/types/plugins/save-on-enter/index.d.ts +0 -10
  71. package/dist/types/plugins/scroll-into-view/index.d.ts +0 -14
  72. package/dist/types/plugins/status/actions.d.ts +0 -16
  73. package/dist/types/plugins/status/analytics.d.ts +0 -4
  74. package/dist/types/plugins/status/index.d.ts +0 -15
  75. package/dist/types/plugins/status/keymap.d.ts +0 -3
  76. package/dist/types/plugins/status/nodeviews/status.d.ts +0 -25
  77. package/dist/types/plugins/status/plugin-key.d.ts +0 -4
  78. package/dist/types/plugins/status/plugin.d.ts +0 -7
  79. package/dist/types/plugins/status/types.d.ts +0 -18
  80. package/dist/types/plugins/status/ui/statusPicker.d.ts +0 -63
  81. package/dist/types/plugins/status/utils.d.ts +0 -5
  82. package/dist/types-ts4.5/create-editor/ReactEditorViewInternal.d.ts +0 -119
  83. package/dist/types-ts4.5/create-editor/ReactEditorViewNext.d.ts +0 -8
  84. package/dist/types-ts4.5/plugins/save-on-enter/index.d.ts +0 -10
  85. package/dist/types-ts4.5/plugins/scroll-into-view/index.d.ts +0 -14
  86. package/dist/types-ts4.5/plugins/status/actions.d.ts +0 -16
  87. package/dist/types-ts4.5/plugins/status/analytics.d.ts +0 -4
  88. package/dist/types-ts4.5/plugins/status/index.d.ts +0 -17
  89. package/dist/types-ts4.5/plugins/status/keymap.d.ts +0 -3
  90. package/dist/types-ts4.5/plugins/status/nodeviews/status.d.ts +0 -25
  91. package/dist/types-ts4.5/plugins/status/plugin-key.d.ts +0 -4
  92. package/dist/types-ts4.5/plugins/status/plugin.d.ts +0 -7
  93. package/dist/types-ts4.5/plugins/status/types.d.ts +0 -18
  94. package/dist/types-ts4.5/plugins/status/ui/statusPicker.d.ts +0 -63
  95. package/dist/types-ts4.5/plugins/status/utils.d.ts +0 -5
@@ -5,22 +5,810 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = exports.ReactEditorView = void 0;
8
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
8
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
9
9
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
10
12
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
11
13
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
12
14
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
13
- var _ReactEditorViewInternal = require("./ReactEditorViewInternal");
15
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
+ var _react = _interopRequireDefault(require("react"));
14
17
  var _reactIntlNext = require("react-intl-next");
18
+ var _propTypes = _interopRequireDefault(require("prop-types"));
19
+ var _state2 = require("@atlaskit/editor-prosemirror/state");
20
+ var _view = require("@atlaskit/editor-prosemirror/view");
21
+ var _messages = require("./messages");
22
+ var _utils = require("@atlaskit/editor-common/utils");
23
+ var _ufo = require("@atlaskit/editor-common/ufo");
24
+ var _eventDispatcher = require("../event-dispatcher");
25
+ var _saferTransactions = require("../utils/performance/safer-transactions");
26
+ var _RenderTracking = require("../utils/performance/components/RenderTracking");
27
+ var _nodes = require("../utils/nodes");
28
+ var _analytics = require("@atlaskit/editor-common/analytics");
29
+ var _featureFlagsFromProps = require("./feature-flags-from-props");
30
+ var _normalizeFeatureFlags = require("@atlaskit/editor-common/normalize-feature-flags");
31
+ var _createEditor = require("./create-editor");
32
+ var _documentLogger = require("../utils/document-logger");
33
+ var _isFullPage = require("../utils/is-full-page");
34
+ var _measureEnum = _interopRequireDefault(require("../utils/performance/measure-enum"));
35
+ var _document = require("../utils/document");
36
+ var _createSchema = require("./create-schema");
37
+ var _pluginPerformanceObserver = require("../utils/performance/plugin-performance-observer");
38
+ var _getParticipantsCount = require("../plugins/collab-edit/get-participants-count");
39
+ var _trackTransactions = require("../utils/performance/track-transactions");
40
+ var _createPluginsList = _interopRequireDefault(require("./create-plugins-list"));
41
+ var _consts = require("./consts");
42
+ var _ReactEditorViewContext = _interopRequireDefault(require("./ReactEditorViewContext"));
43
+ var _preset = require("@atlaskit/editor-common/preset");
44
+ var _ui = require("@atlaskit/editor-common/ui");
45
+ 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; }
46
+ 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; }
15
47
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
16
48
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
17
- var ReactEditorView = exports.ReactEditorView = /*#__PURE__*/function (_BaseReactEditorView) {
18
- (0, _inherits2.default)(ReactEditorView, _BaseReactEditorView);
49
+ function handleEditorFocus(view) {
50
+ if (view.hasFocus()) {
51
+ return;
52
+ }
53
+ return window.setTimeout(function () {
54
+ if (view.hasFocus()) {
55
+ return;
56
+ }
57
+ if (!window.getSelection) {
58
+ view.focus();
59
+ return;
60
+ }
61
+ var domSelection = window.getSelection();
62
+ if (!domSelection || domSelection.rangeCount === 0) {
63
+ view.focus();
64
+ return;
65
+ }
66
+ var range = domSelection.getRangeAt(0);
67
+ // if selection is outside editor focus and exit
68
+ if (range.startContainer.contains(view.dom)) {
69
+ view.focus();
70
+ return;
71
+ }
72
+ // set cursor/selection and focus
73
+ var anchor = view.posAtDOM(range.startContainer, range.startOffset);
74
+ var head = view.posAtDOM(range.endContainer, range.endOffset);
75
+ // if anchor or head < 0 focus and exit
76
+ if (anchor < 0 || head < 0) {
77
+ view.focus();
78
+ return;
79
+ }
80
+ var selection = _state2.TextSelection.create(view.state.doc, anchor, head);
81
+ var tr = view.state.tr.setSelection(selection);
82
+ view.dispatch(tr);
83
+ view.focus();
84
+ }, 0);
85
+ }
86
+ var ReactEditorView = exports.ReactEditorView = /*#__PURE__*/function (_React$Component) {
87
+ (0, _inherits2.default)(ReactEditorView, _React$Component);
19
88
  var _super = _createSuper(ReactEditorView);
20
- function ReactEditorView() {
89
+ function ReactEditorView(props, context) {
90
+ var _props$setEditorApi, _props$editorProps;
91
+ var _this;
21
92
  (0, _classCallCheck2.default)(this, ReactEditorView);
22
- return _super.apply(this, arguments);
93
+ _this = _super.call(this, props, context);
94
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "editorRef", /*#__PURE__*/_react.default.createRef());
95
+ // ProseMirror is instantiated prior to the initial React render cycle,
96
+ // so we allow transactions by default, to avoid discarding the initial one.
97
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "canDispatchTransactions", true);
98
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onPluginObservation", function (report, editorState) {
99
+ _this.dispatchAnalyticsEvent({
100
+ action: _analytics.ACTION.TRANSACTION_DISPATCHED,
101
+ actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
102
+ eventType: _analytics.EVENT_TYPE.OPERATIONAL,
103
+ attributes: {
104
+ report: report,
105
+ participants: (0, _getParticipantsCount.getParticipantsCount)(editorState)
106
+ }
107
+ });
108
+ });
109
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getEditorState", function () {
110
+ var _this$view;
111
+ return (_this$view = _this.view) === null || _this$view === void 0 ? void 0 : _this$view.state;
112
+ });
113
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getEditorView", function () {
114
+ return _this.view;
115
+ });
116
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "formatFullWidthAppearance", function (appearance) {
117
+ if (appearance === 'full-width') {
118
+ return _analytics.FULL_WIDTH_MODE.FULL_WIDTH;
119
+ }
120
+ return _analytics.FULL_WIDTH_MODE.FIXED_WIDTH;
121
+ });
122
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "resetEditorState", function (_ref) {
123
+ var _this$props$editorPro, _this$props$editorPro2;
124
+ var doc = _ref.doc,
125
+ shouldScrollToBottom = _ref.shouldScrollToBottom;
126
+ if (!_this.view) {
127
+ return;
128
+ }
129
+
130
+ // We cannot currently guarentee when all the portals will have re-rendered during a reconfigure
131
+ // so we blur here to stop ProseMirror from trying to apply selection to detached nodes or
132
+ // nodes that haven't been re-rendered to the document yet.
133
+ _this.blur();
134
+ _this.featureFlags = (0, _featureFlagsFromProps.createFeatureFlagsFromProps)(_this.props.editorProps);
135
+ _this.editorState = _this.createEditorState({
136
+ props: _this.props,
137
+ context: _this.context,
138
+ doc: doc,
139
+ resetting: true,
140
+ selectionAtStart: !shouldScrollToBottom
141
+ });
142
+ _this.view.updateState(_this.editorState);
143
+ (_this$props$editorPro = (_this$props$editorPro2 = _this.props.editorProps).onChange) === null || _this$props$editorPro === void 0 || _this$props$editorPro.call(_this$props$editorPro2, _this.view, {
144
+ source: 'local'
145
+ });
146
+ });
147
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "blur", function () {
148
+ if (!_this.view) {
149
+ return;
150
+ }
151
+ if (_this.view.dom instanceof HTMLElement && _this.view.hasFocus()) {
152
+ _this.view.dom.blur();
153
+ }
154
+
155
+ // The selectionToDOM method uses the document selection to determine currently selected node
156
+ // We need to mimic blurring this as it seems doing the above is not enough.
157
+ // @ts-expect-error
158
+ var sel = _this.view.root.getSelection();
159
+ if (sel) {
160
+ sel.removeAllRanges();
161
+ }
162
+ });
163
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleAnalyticsEvent", function (payload) {
164
+ (0, _analytics.fireAnalyticsEvent)(_this.props.createAnalyticsEvent)(payload);
165
+ });
166
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "editorPlugins", []);
167
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "createEditorState", function (options) {
168
+ var schema;
169
+ if (_this.view) {
170
+ if (options.resetting) {
171
+ /**
172
+ * ReactEditorView currently does NOT handle dynamic schema,
173
+ * We are reusing the existing schema, and rely on #reconfigureState
174
+ * to update `this.config`
175
+ */
176
+ schema = _this.view.state.schema;
177
+ } else {
178
+ /**
179
+ * There's presently a number of issues with changing the schema of a
180
+ * editor inflight. A significant issue is that we lose the ability
181
+ * to keep track of a user's history as the internal plugin state
182
+ * keeps a list of Steps to undo/redo (which are tied to the schema).
183
+ * Without a good way to do work around this, we prevent this for now.
184
+ */
185
+ // eslint-disable-next-line no-console
186
+ console.warn('The editor does not support changing the schema dynamically.');
187
+ return _this.editorState;
188
+ }
189
+ } else {
190
+ _this.config = (0, _createEditor.processPluginsList)(_this.getPlugins(options.props.preset));
191
+ schema = (0, _createSchema.createSchema)(_this.config);
192
+ }
193
+ var contentTransformerProvider = options.props.editorProps.contentTransformerProvider;
194
+ var plugins = (0, _createEditor.createPMPlugins)({
195
+ schema: schema,
196
+ dispatch: _this.dispatch,
197
+ errorReporter: _this.errorReporter,
198
+ editorConfig: _this.config,
199
+ eventDispatcher: _this.eventDispatcher,
200
+ providerFactory: options.props.providerFactory,
201
+ portalProviderAPI: _this.props.portalProviderAPI,
202
+ reactContext: function reactContext() {
203
+ return options.context;
204
+ },
205
+ dispatchAnalyticsEvent: _this.dispatchAnalyticsEvent,
206
+ performanceTracking: _this.props.editorProps.performanceTracking,
207
+ transactionTracker: _this.transactionTracker,
208
+ featureFlags: _this.featureFlags,
209
+ getIntl: function getIntl() {
210
+ return _this.props.intl;
211
+ }
212
+ });
213
+ _this.contentTransformer = contentTransformerProvider ? contentTransformerProvider(schema) : undefined;
214
+ var doc;
215
+ if (options.doc) {
216
+ doc = (0, _utils.processRawValue)(schema, options.doc, options.props.providerFactory, options.props.editorProps.sanitizePrivateContent, _this.contentTransformer, _this.dispatchAnalyticsEvent);
217
+ }
218
+ var selection;
219
+ if (doc) {
220
+ selection = options.selectionAtStart ? _state2.Selection.atStart(doc) : _state2.Selection.atEnd(doc);
221
+ }
222
+ // Workaround for ED-3507: When media node is the last element, scrollIntoView throws an error
223
+ var patchedSelection = selection ? _state2.Selection.findFrom(selection.$head, -1, true) || undefined : undefined;
224
+ return _state2.EditorState.create({
225
+ schema: schema,
226
+ plugins: plugins,
227
+ doc: doc,
228
+ selection: patchedSelection
229
+ });
230
+ });
231
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onEditorViewStateUpdated", function (_ref2) {
232
+ var originalTransaction = _ref2.originalTransaction,
233
+ transactions = _ref2.transactions,
234
+ oldEditorState = _ref2.oldEditorState,
235
+ newEditorState = _ref2.newEditorState;
236
+ var trackinEnabled = _this.transactionTracking.enabled;
237
+ _this.config.onEditorViewStateUpdatedCallbacks.forEach(function (entry) {
238
+ trackinEnabled && (0, _utils.startMeasure)("\uD83E\uDD89 ".concat(entry.pluginName, "::onEditorViewStateUpdated"));
239
+ entry.callback({
240
+ originalTransaction: originalTransaction,
241
+ transactions: transactions,
242
+ oldEditorState: oldEditorState,
243
+ newEditorState: newEditorState
244
+ });
245
+ trackinEnabled && (0, _utils.stopMeasure)("\uD83E\uDD89 ".concat(entry.pluginName, "::onEditorViewStateUpdated"));
246
+ });
247
+ });
248
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "trackValidTransactions", function () {
249
+ var editorProps = _this.props.editorProps;
250
+ if (!_this.isTransactionTrackingExplicitlyDisabled() && editorProps !== null && editorProps !== void 0 && editorProps.trackValidTransactions) {
251
+ _this.validTransactionCount++;
252
+ var samplingRate = (0, _typeof2.default)(editorProps.trackValidTransactions) === 'object' && editorProps.trackValidTransactions.samplingRate || _consts.DEFAULT_SAMPLING_RATE_VALID_TRANSACTIONS;
253
+ if (_this.validTransactionCount >= samplingRate) {
254
+ _this.dispatchAnalyticsEvent({
255
+ action: _analytics.ACTION.DISPATCHED_VALID_TRANSACTION,
256
+ actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
257
+ eventType: _analytics.EVENT_TYPE.OPERATIONAL
258
+ });
259
+ _this.validTransactionCount = 0;
260
+ }
261
+ }
262
+ });
263
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "dispatchTransaction", function (unsafeTransaction) {
264
+ if (!_this.view) {
265
+ return;
266
+ }
267
+ _this.transactionTracker.bumpDispatchCounter(_this.transactionTracking);
268
+ var _this$transactionTrac = _this.transactionTracker.getMeasureHelpers(_this.transactionTracking),
269
+ startMeasure = _this$transactionTrac.startMeasure,
270
+ stopMeasure = _this$transactionTrac.stopMeasure;
271
+ startMeasure(_trackTransactions.EVENT_NAME_DISPATCH_TRANSACTION);
272
+ if (_this.transactionTracker.shouldTrackTransaction(_this.transactionTracking)) {
273
+ var _this$experienceStore;
274
+ (_this$experienceStore = _this.experienceStore) === null || _this$experienceStore === void 0 || _this$experienceStore.start(_ufo.EditorExperience.interaction);
275
+ }
276
+ var nodes = (0, _nodes.findChangedNodesFromTransaction)(unsafeTransaction);
277
+ var changedNodesValid = (0, _nodes.validateNodes)(nodes);
278
+ var transaction = _this.featureFlags.saferDispatchedTransactions || _this.featureFlags.saferDispatchedTransactionsAnalyticsOnly ? new Proxy(unsafeTransaction, (0, _saferTransactions.freezeUnsafeTransactionProperties)({
279
+ dispatchAnalyticsEvent: _this.dispatchAnalyticsEvent,
280
+ pluginKey: 'unknown-reacteditorview',
281
+ analyticsOnly: _this.featureFlags.saferDispatchedTransactionsAnalyticsOnly
282
+ })) : unsafeTransaction;
283
+ if (changedNodesValid) {
284
+ var oldEditorState = _this.view.state;
285
+
286
+ // go ahead and update the state now we know the transaction is good
287
+ startMeasure(_trackTransactions.EVENT_NAME_STATE_APPLY);
288
+ var _this$view$state$appl = _this.view.state.applyTransaction(transaction),
289
+ editorState = _this$view$state$appl.state,
290
+ transactions = _this$view$state$appl.transactions;
291
+ stopMeasure(_trackTransactions.EVENT_NAME_STATE_APPLY, function (duration, startTime) {
292
+ var _this$experienceStore2;
293
+ (_this$experienceStore2 = _this.experienceStore) === null || _this$experienceStore2 === void 0 || _this$experienceStore2.mark(_ufo.EditorExperience.interaction, 'stateApply', startTime + duration);
294
+ });
295
+ _this.trackValidTransactions();
296
+ if (editorState === oldEditorState) {
297
+ return;
298
+ }
299
+ startMeasure(_trackTransactions.EVENT_NAME_UPDATE_STATE);
300
+ _this.view.updateState(editorState);
301
+ stopMeasure(_trackTransactions.EVENT_NAME_UPDATE_STATE, function (duration, startTime) {
302
+ var _this$experienceStore3;
303
+ (_this$experienceStore3 = _this.experienceStore) === null || _this$experienceStore3 === void 0 || _this$experienceStore3.mark(_ufo.EditorExperience.interaction, 'viewUpdateState', startTime + duration);
304
+ });
305
+ _this.pluginInjectionAPI.onEditorViewUpdated({
306
+ newEditorState: editorState,
307
+ oldEditorState: oldEditorState
308
+ });
309
+ startMeasure(_trackTransactions.EVENT_NAME_VIEW_STATE_UPDATED);
310
+ _this.onEditorViewStateUpdated({
311
+ originalTransaction: transaction,
312
+ transactions: transactions,
313
+ oldEditorState: oldEditorState,
314
+ newEditorState: editorState
315
+ });
316
+ stopMeasure(_trackTransactions.EVENT_NAME_VIEW_STATE_UPDATED, function (duration, startTime) {
317
+ var _this$experienceStore4;
318
+ (_this$experienceStore4 = _this.experienceStore) === null || _this$experienceStore4 === void 0 || _this$experienceStore4.mark(_ufo.EditorExperience.interaction, 'onEditorViewStateUpdated', startTime + duration);
319
+ });
320
+ if (_this.props.editorProps.onChange && transaction.docChanged) {
321
+ var source = transaction.getMeta('isRemote') ? 'remote' : 'local';
322
+ startMeasure(_trackTransactions.EVENT_NAME_ON_CHANGE);
323
+ _this.props.editorProps.onChange(_this.view, {
324
+ source: source
325
+ });
326
+ stopMeasure(_trackTransactions.EVENT_NAME_ON_CHANGE, function (duration, startTime) {
327
+ var _this$experienceStore5, _this$props$editorPro3;
328
+ (_this$experienceStore5 = _this.experienceStore) === null || _this$experienceStore5 === void 0 || _this$experienceStore5.mark(_ufo.EditorExperience.interaction, 'onChange', startTime + duration);
329
+ if (((_this$props$editorPro3 = _this.props.editorProps.performanceTracking) === null || _this$props$editorPro3 === void 0 || (_this$props$editorPro3 = _this$props$editorPro3.onChangeCallbackTracking) === null || _this$props$editorPro3 === void 0 ? void 0 : _this$props$editorPro3.enabled) !== true) {
330
+ return;
331
+ }
332
+ _this.dispatchAnalyticsEvent({
333
+ action: _analytics.ACTION.ON_CHANGE_CALLBACK,
334
+ actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
335
+ eventType: _analytics.EVENT_TYPE.OPERATIONAL,
336
+ attributes: {
337
+ duration: duration,
338
+ startTime: startTime
339
+ }
340
+ });
341
+ });
342
+ }
343
+ _this.editorState = editorState;
344
+ stopMeasure(_trackTransactions.EVENT_NAME_DISPATCH_TRANSACTION, function (duration, startTime) {
345
+ var _this$experienceStore6, _this$experienceStore7;
346
+ (_this$experienceStore6 = _this.experienceStore) === null || _this$experienceStore6 === void 0 || _this$experienceStore6.mark(_ufo.EditorExperience.interaction, 'dispatchTransaction', startTime + duration);
347
+ (_this$experienceStore7 = _this.experienceStore) === null || _this$experienceStore7 === void 0 || _this$experienceStore7.success(_ufo.EditorExperience.interaction);
348
+ });
349
+ } else {
350
+ var _this$experienceStore8;
351
+ var invalidNodes = nodes.filter(function (node) {
352
+ return !(0, _nodes.validNode)(node);
353
+ }).map(function (node) {
354
+ return (0, _documentLogger.getDocStructure)(node, {
355
+ compact: true
356
+ });
357
+ });
358
+ if (!_this.isTransactionTrackingExplicitlyDisabled()) {
359
+ _this.dispatchAnalyticsEvent({
360
+ action: _analytics.ACTION.DISPATCHED_INVALID_TRANSACTION,
361
+ actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
362
+ eventType: _analytics.EVENT_TYPE.OPERATIONAL,
363
+ attributes: {
364
+ analyticsEventPayloads: (0, _analytics.getAnalyticsEventsFromTransaction)(transaction),
365
+ invalidNodes: invalidNodes
366
+ }
367
+ });
368
+ }
369
+ (_this$experienceStore8 = _this.experienceStore) === null || _this$experienceStore8 === void 0 || _this$experienceStore8.fail(_ufo.EditorExperience.interaction, {
370
+ reason: 'invalid transaction',
371
+ invalidNodes: invalidNodes.toString()
372
+ });
373
+ }
374
+ });
375
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getDirectEditorProps", function (state) {
376
+ return {
377
+ state: state || _this.editorState,
378
+ dispatchTransaction: function dispatchTransaction(tr) {
379
+ // Block stale transactions:
380
+ // Prevent runtime exeptions from async transactions that would attempt to
381
+ // update the DOM after React has unmounted the Editor.
382
+ if (_this.canDispatchTransactions) {
383
+ _this.dispatchTransaction(tr);
384
+ }
385
+ },
386
+ // Disables the contentEditable attribute of the editor if the editor is disabled
387
+ editable: function editable(_state) {
388
+ return !_this.props.editorProps.disabled;
389
+ },
390
+ attributes: {
391
+ 'data-gramm': 'false'
392
+ }
393
+ };
394
+ });
395
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "createEditorView", function (node) {
396
+ (0, _utils.measureRender)(_measureEnum.default.PROSEMIRROR_RENDERED, function (_ref3) {
397
+ var _this$props$editorPro4, _proseMirrorRenderedT, _proseMirrorRenderedT2;
398
+ var duration = _ref3.duration,
399
+ startTime = _ref3.startTime,
400
+ distortedDuration = _ref3.distortedDuration;
401
+ var proseMirrorRenderedTracking = (_this$props$editorPro4 = _this.props.editorProps) === null || _this$props$editorPro4 === void 0 || (_this$props$editorPro4 = _this$props$editorPro4.performanceTracking) === null || _this$props$editorPro4 === void 0 ? void 0 : _this$props$editorPro4.proseMirrorRenderedTracking;
402
+ var forceSeverityTracking = typeof proseMirrorRenderedTracking === 'undefined' && (0, _utils.shouldForceTracking)();
403
+ _this.proseMirrorRenderedSeverity = !!forceSeverityTracking || proseMirrorRenderedTracking !== null && proseMirrorRenderedTracking !== void 0 && proseMirrorRenderedTracking.trackSeverity ? (0, _utils.getAnalyticsEventSeverity)(duration, (_proseMirrorRenderedT = proseMirrorRenderedTracking === null || proseMirrorRenderedTracking === void 0 ? void 0 : proseMirrorRenderedTracking.severityNormalThreshold) !== null && _proseMirrorRenderedT !== void 0 ? _proseMirrorRenderedT : _consts.PROSEMIRROR_RENDERED_NORMAL_SEVERITY_THRESHOLD, (_proseMirrorRenderedT2 = proseMirrorRenderedTracking === null || proseMirrorRenderedTracking === void 0 ? void 0 : proseMirrorRenderedTracking.severityDegradedThreshold) !== null && _proseMirrorRenderedT2 !== void 0 ? _proseMirrorRenderedT2 : _consts.PROSEMIRROR_RENDERED_DEGRADED_SEVERITY_THRESHOLD) : undefined;
404
+ if (_this.view) {
405
+ var _this$pluginInjection, _this$experienceStore10;
406
+ var nodes = (0, _document.getNodesCount)(_this.view.state.doc);
407
+ var ttfb = (0, _utils.getResponseEndTime)();
408
+ var contextIdentifier = (_this$pluginInjection = _this.pluginInjectionAPI.api().base) === null || _this$pluginInjection === void 0 ? void 0 : _this$pluginInjection.sharedState.currentState();
409
+ _this.dispatchAnalyticsEvent({
410
+ action: _analytics.ACTION.PROSEMIRROR_RENDERED,
411
+ actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
412
+ attributes: {
413
+ duration: duration,
414
+ startTime: startTime,
415
+ nodes: nodes,
416
+ ttfb: ttfb,
417
+ severity: _this.proseMirrorRenderedSeverity,
418
+ objectId: contextIdentifier === null || contextIdentifier === void 0 ? void 0 : contextIdentifier.objectId,
419
+ distortedDuration: distortedDuration
420
+ },
421
+ eventType: _analytics.EVENT_TYPE.OPERATIONAL
422
+ });
423
+ if (!distortedDuration) {
424
+ var _this$experienceStore9;
425
+ (_this$experienceStore9 = _this.experienceStore) === null || _this$experienceStore9 === void 0 || _this$experienceStore9.mark(_ufo.EditorExperience.loadEditor, _analytics.ACTION.PROSEMIRROR_RENDERED, startTime + duration);
426
+ }
427
+ (_this$experienceStore10 = _this.experienceStore) === null || _this$experienceStore10 === void 0 || _this$experienceStore10.addMetadata(_ufo.EditorExperience.loadEditor, {
428
+ nodes: nodes,
429
+ ttfb: ttfb
430
+ });
431
+ }
432
+ });
433
+
434
+ // Creates the editor-view from this.editorState. If an editor has been mounted
435
+ // previously, this will contain the previous state of the editor.
436
+ _this.view = new _view.EditorView({
437
+ mount: node
438
+ }, _this.getDirectEditorProps());
439
+ _this.pluginInjectionAPI.onEditorViewUpdated({
440
+ newEditorState: _this.view.state,
441
+ oldEditorState: undefined
442
+ });
443
+ });
444
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleEditorViewRef", function (node) {
445
+ if (!_this.view && node) {
446
+ _this.createEditorView(node);
447
+ var view = _this.view;
448
+ _this.props.onEditorCreated({
449
+ view: view,
450
+ config: _this.config,
451
+ eventDispatcher: _this.eventDispatcher,
452
+ transformer: _this.contentTransformer
453
+ });
454
+ if (_this.props.editorProps.shouldFocus && view.props.editable && view.props.editable(view.state)) {
455
+ _this.focusTimeoutId = handleEditorFocus(view);
456
+ }
457
+ if (_this.featureFlags.ufo) {
458
+ _this.experienceStore = _ufo.ExperienceStore.getInstance(view);
459
+ _this.experienceStore.start(_ufo.EditorExperience.editSession);
460
+ _this.experienceStore.addMetadata(_ufo.EditorExperience.editSession, {
461
+ reliabilityInterval: _ufo.RELIABILITY_INTERVAL
462
+ });
463
+ _this.reliabilityInterval = window.setInterval(function () {
464
+ var _this$experienceStore11;
465
+ (_this$experienceStore11 = _this.experienceStore) === null || _this$experienceStore11 === void 0 || (_this$experienceStore11 = _this$experienceStore11.success(_ufo.EditorExperience.editSession)) === null || _this$experienceStore11 === void 0 || _this$experienceStore11.finally(function () {
466
+ var _this$experienceStore12, _this$experienceStore13;
467
+ (_this$experienceStore12 = _this.experienceStore) === null || _this$experienceStore12 === void 0 || _this$experienceStore12.start(_ufo.EditorExperience.editSession);
468
+ (_this$experienceStore13 = _this.experienceStore) === null || _this$experienceStore13 === void 0 || _this$experienceStore13.addMetadata(_ufo.EditorExperience.editSession, {
469
+ reliabilityInterval: _ufo.RELIABILITY_INTERVAL
470
+ });
471
+ });
472
+ var reliabilityEvent = {
473
+ action: _analytics.ACTION.UFO_SESSION_COMPLETE,
474
+ actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
475
+ attributes: {
476
+ interval: _ufo.RELIABILITY_INTERVAL
477
+ },
478
+ eventType: _analytics.EVENT_TYPE.OPERATIONAL
479
+ };
480
+ _this.dispatchAnalyticsEvent(reliabilityEvent);
481
+ }, _ufo.RELIABILITY_INTERVAL);
482
+ }
483
+
484
+ // Force React to re-render so consumers get a reference to the editor view
485
+ _this.forceUpdate();
486
+ } else if (_this.view && !node) {
487
+ // When the appearance is changed, React will call handleEditorViewRef with node === null
488
+ // to destroy the old EditorView, before calling this method again with node === div to
489
+ // create the new EditorView
490
+ _this.props.onEditorDestroyed({
491
+ view: _this.view,
492
+ config: _this.config,
493
+ eventDispatcher: _this.eventDispatcher,
494
+ transformer: _this.contentTransformer
495
+ });
496
+
497
+ // Allows us to dispatch analytics within the plugin view.destory methods
498
+ var analyticsConnected = _this.eventDispatcher.has(_utils.analyticsEventKey, _this.handleAnalyticsEvent);
499
+ if (!analyticsConnected) {
500
+ _this.eventDispatcher.on(_utils.analyticsEventKey, _this.handleAnalyticsEvent);
501
+ }
502
+ _this.view.destroy(); // Destroys the dom node & all node views
503
+
504
+ if (!analyticsConnected) {
505
+ _this.eventDispatcher.off(_utils.analyticsEventKey, _this.handleAnalyticsEvent);
506
+ }
507
+ _this.view = undefined;
508
+ }
509
+ });
510
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "dispatchAnalyticsEvent", function (payload) {
511
+ if (_this.eventDispatcher) {
512
+ var dispatch = (0, _eventDispatcher.createDispatch)(_this.eventDispatcher);
513
+ dispatch(_utils.analyticsEventKey, {
514
+ payload: payload
515
+ });
516
+ }
517
+ });
518
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "createEditor", function (assistiveLabel) {
519
+ return /*#__PURE__*/_react.default.createElement("div", {
520
+ className: getUAPrefix(),
521
+ key: "ProseMirror",
522
+ ref: _this.handleEditorViewRef,
523
+ "aria-label": assistiveLabel || _this.props.intl.formatMessage(_messages.editorMessages.editorAssistiveLabel)
524
+ // setting aria-multiline to true when not mobile appearance.
525
+ // because somehow mobile tests are failing when it set.
526
+ // don't know why that is happening.
527
+ // Created https://product-fabric.atlassian.net/jira/servicedesk/projects/DTR/queues/issue/DTR-1675
528
+ // to investigate further.
529
+ ,
530
+ "aria-multiline": _this.props.editorProps.appearance !== 'mobile' ? true : false,
531
+ role: "textbox",
532
+ id: _ui.EDIT_AREA_ID
533
+ });
534
+ });
535
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "editor", _this.createEditor(_this.props.editorProps.assistiveLabel));
536
+ _this.pluginInjectionAPI = new _preset.EditorPluginInjectionAPI({
537
+ getEditorState: _this.getEditorState,
538
+ getEditorView: _this.getEditorView
539
+ });
540
+ (_props$setEditorApi = props.setEditorApi) === null || _props$setEditorApi === void 0 || _props$setEditorApi.call(props, _this.pluginInjectionAPI.api());
541
+ _this.eventDispatcher = new _eventDispatcher.EventDispatcher();
542
+ _this.dispatch = (0, _eventDispatcher.createDispatch)(_this.eventDispatcher);
543
+ _this.errorReporter = (0, _createEditor.createErrorReporter)(props.editorProps.errorReporterHandler);
544
+ _this.transactionTracker = new _trackTransactions.TransactionTracker();
545
+ _this.pluginPerformanceObserver = new _pluginPerformanceObserver.PluginPerformanceObserver(function (report) {
546
+ return _this.onPluginObservation(report, _this.editorState);
547
+ }).withPlugins(function () {
548
+ return _this.getPluginNames();
549
+ }).withNodeCounts(function () {
550
+ return _this.countNodes();
551
+ }).withOptions(function () {
552
+ return _this.transactionTracking;
553
+ }).withTransactionTracker(function () {
554
+ return _this.transactionTracker;
555
+ });
556
+ _this.validTransactionCount = 0;
557
+ _this.featureFlags = (0, _featureFlagsFromProps.createFeatureFlagsFromProps)(_this.props.editorProps);
558
+ var featureFlagsEnabled = _this.featureFlags ? (0, _normalizeFeatureFlags.getEnabledFeatureFlagKeys)(_this.featureFlags) : [];
559
+
560
+ // START TEMPORARY CODE ED-10584
561
+ if (_this.props.createAnalyticsEvent) {
562
+ _this.props.createAnalyticsEvent.__queueAnalytics = _this.featureFlags.queueAnalytics;
563
+ }
564
+ // END TEMPORARY CODE ED-10584
565
+
566
+ // This needs to be before initialising editorState because
567
+ // we dispatch analytics events in plugin initialisation
568
+ _this.eventDispatcher.on(_utils.analyticsEventKey, _this.handleAnalyticsEvent);
569
+ _this.eventDispatcher.on('resetEditorState', _this.resetEditorState);
570
+ _this.editorState = _this.createEditorState({
571
+ props: props,
572
+ context: context,
573
+ doc: props.editorProps.defaultValue,
574
+ // ED-4759: Don't set selection at end for full-page editor - should be at start.
575
+ selectionAtStart: (0, _isFullPage.isFullPage)(props.editorProps.appearance)
576
+ });
577
+
578
+ // ED-16320: Check for explicit disable so that by default
579
+ // it will still be enabled as it currently is. Then we can
580
+ // progressively opt out synthetic tenants.
581
+ var isEditorStartedExplicitlyDisabled = ((_props$editorProps = props.editorProps) === null || _props$editorProps === void 0 || (_props$editorProps = _props$editorProps.performanceTracking) === null || _props$editorProps === void 0 || (_props$editorProps = _props$editorProps.startedTracking) === null || _props$editorProps === void 0 ? void 0 : _props$editorProps.enabled) === false;
582
+ if (!isEditorStartedExplicitlyDisabled) {
583
+ _this.dispatchAnalyticsEvent({
584
+ action: _analytics.ACTION.STARTED,
585
+ actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
586
+ attributes: {
587
+ platform: _analytics.PLATFORMS.WEB,
588
+ featureFlags: featureFlagsEnabled
589
+ },
590
+ eventType: _analytics.EVENT_TYPE.UI
591
+ });
592
+ }
593
+ return _this;
594
+ }
595
+ (0, _createClass2.default)(ReactEditorView, [{
596
+ key: "transactionTracking",
597
+ get: function get() {
598
+ var _this$props$editorPro5, _this$props$editorPro6;
599
+ return (_this$props$editorPro5 = (_this$props$editorPro6 = this.props.editorProps.performanceTracking) === null || _this$props$editorPro6 === void 0 ? void 0 : _this$props$editorPro6.transactionTracking) !== null && _this$props$editorPro5 !== void 0 ? _this$props$editorPro5 : {
600
+ enabled: false
601
+ };
602
+ }
603
+ }, {
604
+ key: "getPluginNames",
605
+ value: function getPluginNames() {
606
+ return this.editorState.plugins.map(function (p) {
607
+ return p.key;
608
+ });
609
+ }
610
+ }, {
611
+ key: "countNodes",
612
+ value: function countNodes() {
613
+ return (0, _utils.countNodes)(this.editorState);
614
+ }
615
+ }, {
616
+ key: "isTransactionTrackingExplicitlyDisabled",
617
+ value: function isTransactionTrackingExplicitlyDisabled() {
618
+ var _this$props$editorPro7;
619
+ // ED-16320: Check for explicit disable so that by default
620
+ // it will still be enabled as it currently is. Then we can
621
+ // progressively opt out synthetic tenants.
622
+ return ((_this$props$editorPro7 = this.props.editorProps) === null || _this$props$editorPro7 === void 0 || (_this$props$editorPro7 = _this$props$editorPro7.performanceTracking) === null || _this$props$editorPro7 === void 0 || (_this$props$editorPro7 = _this$props$editorPro7.transactionTracking) === null || _this$props$editorPro7 === void 0 ? void 0 : _this$props$editorPro7.enabled) === false;
623
+ }
624
+ }, {
625
+ key: "UNSAFE_componentWillReceiveProps",
626
+ value: function UNSAFE_componentWillReceiveProps(nextProps) {
627
+ // START TEMPORARY CODE ED-10584
628
+ if (nextProps.createAnalyticsEvent && nextProps.createAnalyticsEvent !== this.props.createAnalyticsEvent) {
629
+ var featureFlags = (0, _featureFlagsFromProps.createFeatureFlagsFromProps)(nextProps.editorProps);
630
+ nextProps.createAnalyticsEvent.__queueAnalytics = featureFlags.queueAnalytics;
631
+ }
632
+ // END TEMPORARY CODE ED-10584
633
+
634
+ if (this.view && this.props.editorProps.disabled !== nextProps.editorProps.disabled) {
635
+ // Disables the contentEditable attribute of the editor if the editor is disabled
636
+ this.view.setProps({
637
+ editable: function editable(_state) {
638
+ return !nextProps.editorProps.disabled;
639
+ }
640
+ });
641
+ if (!nextProps.editorProps.disabled && nextProps.editorProps.shouldFocus) {
642
+ this.focusTimeoutId = handleEditorFocus(this.view);
643
+ }
644
+ }
645
+ var appearance = this.props.editorProps.appearance;
646
+ var nextAppearance = nextProps.editorProps.appearance;
647
+ if (this.props.preset !== nextProps.preset) {
648
+ this.reconfigureState(nextProps);
649
+ }
650
+ if (nextAppearance !== appearance) {
651
+ if (nextAppearance === 'full-width' || appearance === 'full-width') {
652
+ this.dispatchAnalyticsEvent({
653
+ action: _analytics.ACTION.CHANGED_FULL_WIDTH_MODE,
654
+ actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
655
+ eventType: _analytics.EVENT_TYPE.TRACK,
656
+ attributes: {
657
+ previousMode: this.formatFullWidthAppearance(appearance),
658
+ newMode: this.formatFullWidthAppearance(nextAppearance)
659
+ }
660
+ });
661
+ }
662
+ }
663
+ if (!this.transactionTracking.enabled) {
664
+ this.pluginPerformanceObserver.disconnect();
665
+ }
666
+ if (nextProps.editorProps.assistiveLabel !== this.props.editorProps.assistiveLabel) {
667
+ this.editor = this.createEditor(nextProps.editorProps.assistiveLabel);
668
+ }
669
+ }
670
+ }, {
671
+ key: "reconfigureState",
672
+ value: function reconfigureState(props) {
673
+ var _this2 = this;
674
+ if (!this.view) {
675
+ return;
676
+ }
677
+
678
+ // We cannot currently guarentee when all the portals will have re-rendered during a reconfigure
679
+ // so we blur here to stop ProseMirror from trying to apply selection to detached nodes or
680
+ // nodes that haven't been re-rendered to the document yet.
681
+ this.blur();
682
+ var editorPlugins = this.getPlugins(props.preset);
683
+ this.config = (0, _createEditor.processPluginsList)(editorPlugins);
684
+ var state = this.editorState;
685
+ var plugins = (0, _createEditor.createPMPlugins)({
686
+ schema: state.schema,
687
+ dispatch: this.dispatch,
688
+ errorReporter: this.errorReporter,
689
+ editorConfig: this.config,
690
+ eventDispatcher: this.eventDispatcher,
691
+ providerFactory: props.providerFactory,
692
+ portalProviderAPI: props.portalProviderAPI,
693
+ reactContext: function reactContext() {
694
+ return _this2.context;
695
+ },
696
+ dispatchAnalyticsEvent: this.dispatchAnalyticsEvent,
697
+ performanceTracking: props.editorProps.performanceTracking,
698
+ transactionTracker: this.transactionTracker,
699
+ featureFlags: (0, _featureFlagsFromProps.createFeatureFlagsFromProps)(props.editorProps),
700
+ getIntl: function getIntl() {
701
+ return _this2.props.intl;
702
+ }
703
+ });
704
+ var newState = state.reconfigure({
705
+ plugins: plugins
706
+ });
707
+
708
+ // need to update the state first so when the view builds the nodeviews it is
709
+ // using the latest plugins
710
+ this.view.updateState(newState);
711
+ return this.view.update(_objectSpread(_objectSpread({}, this.view.props), {}, {
712
+ state: newState
713
+ }));
714
+ }
715
+ }, {
716
+ key: "componentDidMount",
717
+ value: function componentDidMount() {
718
+ // Transaction dispatching is already enabled by default prior to
719
+ // mounting, but we reset it here, just in case the editor view
720
+ // instance is ever recycled (mounted again after unmounting) with
721
+ // the same key.
722
+ // Although storing mounted state is an anti-pattern in React,
723
+ // we do so here so that we can intercept and abort asynchronous
724
+ // ProseMirror transactions when a dismount is imminent.
725
+ this.canDispatchTransactions = true;
726
+ if (this.transactionTracking.enabled) {
727
+ this.pluginPerformanceObserver.observe();
728
+ }
729
+ }
730
+
731
+ /**
732
+ * Clean up any non-PM resources when the editor is unmounted
733
+ */
734
+ }, {
735
+ key: "componentWillUnmount",
736
+ value: function componentWillUnmount() {
737
+ // We can ignore any transactions from this point onwards.
738
+ // This serves to avoid potential runtime exceptions which could arise
739
+ // from an async dispatched transaction after it's unmounted.
740
+ this.canDispatchTransactions = false;
741
+ clearTimeout(this.focusTimeoutId);
742
+ if (this.reliabilityInterval) {
743
+ clearInterval(this.reliabilityInterval);
744
+ }
745
+ this.pluginPerformanceObserver.disconnect();
746
+ if (this.view) {
747
+ // Destroy the state if the Editor is being unmounted
748
+ var editorState = this.view.state;
749
+ editorState.plugins.forEach(function (plugin) {
750
+ var state = plugin.getState(editorState);
751
+ if (state && state.destroy) {
752
+ state.destroy();
753
+ }
754
+ });
755
+ }
756
+ this.eventDispatcher.destroy();
757
+ // this.view will be destroyed when React unmounts in handleEditorViewRef
758
+ }
759
+ }, {
760
+ key: "getPlugins",
761
+ value:
762
+ // Helper to allow tests to inject plugins directly
763
+ function getPlugins(preset) {
764
+ var plugins = (0, _createPluginsList.default)(preset, this.props.editorProps, this.pluginInjectionAPI);
765
+ this.editorPlugins = plugins;
766
+ return this.editorPlugins;
767
+ }
768
+ }, {
769
+ key: "render",
770
+ value: function render() {
771
+ var _this$props$editorPro8;
772
+ var renderTracking = (_this$props$editorPro8 = this.props.editorProps.performanceTracking) === null || _this$props$editorPro8 === void 0 || (_this$props$editorPro8 = _this$props$editorPro8.renderTracking) === null || _this$props$editorPro8 === void 0 ? void 0 : _this$props$editorPro8.reactEditorView;
773
+ var renderTrackingEnabled = renderTracking === null || renderTracking === void 0 ? void 0 : renderTracking.enabled;
774
+ var useShallow = renderTracking === null || renderTracking === void 0 ? void 0 : renderTracking.useShallow;
775
+ return /*#__PURE__*/_react.default.createElement(_ReactEditorViewContext.default.Provider, {
776
+ value: {
777
+ editorRef: this.editorRef,
778
+ editorView: this.view
779
+ }
780
+ }, renderTrackingEnabled && /*#__PURE__*/_react.default.createElement(_RenderTracking.RenderTracking, {
781
+ componentProps: this.props,
782
+ action: _analytics.ACTION.RE_RENDERED,
783
+ actionSubject: _analytics.ACTION_SUBJECT.REACT_EDITOR_VIEW,
784
+ handleAnalyticsEvent: this.handleAnalyticsEvent,
785
+ useShallow: useShallow
786
+ }), this.props.render ? this.props.render({
787
+ editor: this.editor,
788
+ view: this.view,
789
+ config: this.config,
790
+ eventDispatcher: this.eventDispatcher,
791
+ transformer: this.contentTransformer,
792
+ dispatchAnalyticsEvent: this.dispatchAnalyticsEvent,
793
+ editorRef: this.editorRef
794
+ }) : this.editor);
795
+ }
796
+ }]);
797
+ return ReactEditorView;
798
+ }(_react.default.Component);
799
+ (0, _defineProperty2.default)(ReactEditorView, "contextTypes", {
800
+ getAtlaskitAnalyticsEventHandlers: _propTypes.default.func
801
+ });
802
+ function getUAPrefix() {
803
+ if (_utils.browser.chrome) {
804
+ return 'ua-chrome';
805
+ } else if (_utils.browser.ie) {
806
+ return 'ua-ie';
807
+ } else if (_utils.browser.gecko) {
808
+ return 'ua-firefox';
809
+ } else if (_utils.browser.safari) {
810
+ return 'ua-safari';
23
811
  }
24
- return (0, _createClass2.default)(ReactEditorView);
25
- }(_ReactEditorViewInternal.ReactEditorView);
812
+ return '';
813
+ }
26
814
  var _default = exports.default = (0, _reactIntlNext.injectIntl)(ReactEditorView);