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