@atlaskit/editor-core 187.47.9 → 187.48.2

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 (190) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/cjs/{editor-next → composable-editor}/editor-internal.js +2 -22
  3. package/dist/cjs/{editor-next/index.js → composable-editor/editor.js} +16 -10
  4. package/dist/cjs/composable-editor.js +2 -3
  5. package/dist/cjs/editor.js +4 -4
  6. package/dist/cjs/index.js +7 -7
  7. package/dist/cjs/labs/next/presets/default.js +2 -2
  8. package/dist/cjs/plugins/floating-toolbar/ui/Toolbar.js +3 -70
  9. package/dist/cjs/plugins/floating-toolbar/utils.js +0 -41
  10. package/dist/cjs/plugins/index.js +0 -7
  11. package/dist/cjs/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.js +28 -11
  12. package/dist/cjs/test-utils.js +2 -2
  13. package/dist/cjs/ui/CollapsedEditor/index.js +3 -3
  14. package/dist/cjs/version-wrapper.js +1 -1
  15. package/dist/es2019/{editor-next → composable-editor}/editor-internal.js +1 -23
  16. package/dist/es2019/{editor-next/index.js → composable-editor/editor.js} +15 -7
  17. package/dist/es2019/composable-editor.js +1 -1
  18. package/dist/es2019/editor.js +4 -4
  19. package/dist/es2019/index.js +1 -1
  20. package/dist/es2019/labs/next/presets/default.js +1 -1
  21. package/dist/es2019/plugins/floating-toolbar/ui/Toolbar.js +1 -52
  22. package/dist/es2019/plugins/floating-toolbar/utils.js +0 -36
  23. package/dist/es2019/plugins/index.js +0 -1
  24. package/dist/es2019/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.js +21 -4
  25. package/dist/es2019/test-utils.js +1 -1
  26. package/dist/es2019/ui/CollapsedEditor/index.js +3 -3
  27. package/dist/es2019/version-wrapper.js +1 -1
  28. package/dist/esm/{editor-next → composable-editor}/editor-internal.js +1 -20
  29. package/dist/esm/{editor-next/index.js → composable-editor/editor.js} +15 -7
  30. package/dist/esm/composable-editor.js +1 -1
  31. package/dist/esm/editor.js +4 -4
  32. package/dist/esm/index.js +1 -1
  33. package/dist/esm/labs/next/presets/default.js +1 -1
  34. package/dist/esm/plugins/floating-toolbar/ui/Toolbar.js +1 -66
  35. package/dist/esm/plugins/floating-toolbar/utils.js +0 -37
  36. package/dist/esm/plugins/index.js +0 -1
  37. package/dist/esm/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.js +21 -4
  38. package/dist/esm/test-utils.js +1 -1
  39. package/dist/esm/ui/CollapsedEditor/index.js +3 -3
  40. package/dist/esm/version-wrapper.js +1 -1
  41. package/dist/{types-ts4.5/editor-next → types/composable-editor}/editor-internal.d.ts +4 -13
  42. package/dist/{types-ts4.5/editor-next/index.d.ts → types/composable-editor/editor.d.ts} +2 -4
  43. package/dist/types/{editor-next → composable-editor}/hooks/useMeasureEditorMountTime.d.ts +3 -3
  44. package/dist/types/{editor-next → composable-editor}/utils/getBaseFontSize.d.ts +1 -1
  45. package/dist/{types-ts4.5/editor-next → types/composable-editor}/utils/getProvidersFromEditorProps.d.ts +2 -2
  46. package/dist/types/{editor-next → composable-editor}/utils/sendDurationAnalytics.d.ts +4 -4
  47. package/dist/{types-ts4.5/editor-next → types/composable-editor}/utils/trackEditorActions.d.ts +3 -3
  48. package/dist/types/composable-editor.d.ts +1 -1
  49. package/dist/types/create-editor/create-plugins-list.d.ts +1 -1
  50. package/dist/types/index.d.ts +1 -1
  51. package/dist/types/labs/next/presets/default.d.ts +1 -1
  52. package/dist/types/plugins/code-block/ide-ux/quote-handling.d.ts +1 -1
  53. package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/commands.d.ts +1 -1
  54. package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin.d.ts +1 -1
  55. package/dist/types/plugins/floating-toolbar/ui/Select.d.ts +1 -1
  56. package/dist/types/plugins/floating-toolbar/ui/Toolbar.d.ts +3 -4
  57. package/dist/types/plugins/floating-toolbar/utils.d.ts +0 -2
  58. package/dist/types/plugins/index.d.ts +0 -1
  59. package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
  60. package/dist/types/ui/ConfigPanel/FormErrorBoundary.d.ts +1 -1
  61. package/dist/types/ui/ContentStyles/index.d.ts +2 -2
  62. package/dist/{types/editor-next → types-ts4.5/composable-editor}/editor-internal.d.ts +4 -13
  63. package/dist/{types/editor-next/index.d.ts → types-ts4.5/composable-editor/editor.d.ts} +2 -4
  64. package/dist/types-ts4.5/{editor-next → composable-editor}/hooks/useMeasureEditorMountTime.d.ts +3 -3
  65. package/dist/types-ts4.5/{editor-next → composable-editor}/utils/getBaseFontSize.d.ts +1 -1
  66. package/dist/{types/editor-next → types-ts4.5/composable-editor}/utils/getProvidersFromEditorProps.d.ts +2 -2
  67. package/dist/types-ts4.5/{editor-next → composable-editor}/utils/sendDurationAnalytics.d.ts +4 -4
  68. package/dist/{types/editor-next → types-ts4.5/composable-editor}/utils/trackEditorActions.d.ts +3 -3
  69. package/dist/types-ts4.5/composable-editor.d.ts +1 -1
  70. package/dist/types-ts4.5/create-editor/create-plugins-list.d.ts +1 -1
  71. package/dist/types-ts4.5/index.d.ts +1 -1
  72. package/dist/types-ts4.5/labs/next/presets/default.d.ts +1 -1
  73. package/dist/types-ts4.5/plugins/code-block/ide-ux/quote-handling.d.ts +1 -1
  74. package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/commands.d.ts +1 -1
  75. package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin.d.ts +1 -1
  76. package/dist/types-ts4.5/plugins/floating-toolbar/ui/Select.d.ts +1 -1
  77. package/dist/types-ts4.5/plugins/floating-toolbar/ui/Toolbar.d.ts +3 -4
  78. package/dist/types-ts4.5/plugins/floating-toolbar/utils.d.ts +0 -2
  79. package/dist/types-ts4.5/plugins/index.d.ts +0 -1
  80. package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
  81. package/dist/types-ts4.5/ui/ConfigPanel/FormErrorBoundary.d.ts +1 -1
  82. package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
  83. package/package.json +8 -9
  84. package/report.api.md +3 -26
  85. package/tmp/api-report-tmp.d.ts +3 -26
  86. package/dist/cjs/plugins/base/commands.js +0 -20
  87. package/dist/cjs/plugins/base/index.js +0 -13
  88. package/dist/cjs/plugins/base/plugin.js +0 -143
  89. package/dist/cjs/plugins/base/pm-plugins/context-identifier.js +0 -58
  90. package/dist/cjs/plugins/base/pm-plugins/disable-spell-checking.js +0 -63
  91. package/dist/cjs/plugins/base/pm-plugins/filter-steps.js +0 -34
  92. package/dist/cjs/plugins/base/pm-plugins/fix-chrome-88-selection.js +0 -34
  93. package/dist/cjs/plugins/base/pm-plugins/frozen-editor.js +0 -265
  94. package/dist/cjs/plugins/base/pm-plugins/inline-cursor-target.js +0 -183
  95. package/dist/cjs/plugins/base/pm-plugins/newline-preserve-marks.js +0 -34
  96. package/dist/cjs/plugins/base/pm-plugins/scroll-gutter/index.js +0 -262
  97. package/dist/cjs/plugins/base/pm-plugins/scroll-gutter/plugin-key.js +0 -15
  98. package/dist/cjs/plugins/base/utils/frozen-editor.js +0 -11
  99. package/dist/cjs/plugins/base/utils/input-latency-tracking.js +0 -134
  100. package/dist/es2019/plugins/base/commands.js +0 -13
  101. package/dist/es2019/plugins/base/index.js +0 -2
  102. package/dist/es2019/plugins/base/plugin.js +0 -113
  103. package/dist/es2019/plugins/base/pm-plugins/context-identifier.js +0 -43
  104. package/dist/es2019/plugins/base/pm-plugins/disable-spell-checking.js +0 -54
  105. package/dist/es2019/plugins/base/pm-plugins/filter-steps.js +0 -23
  106. package/dist/es2019/plugins/base/pm-plugins/fix-chrome-88-selection.js +0 -24
  107. package/dist/es2019/plugins/base/pm-plugins/frozen-editor.js +0 -258
  108. package/dist/es2019/plugins/base/pm-plugins/inline-cursor-target.js +0 -186
  109. package/dist/es2019/plugins/base/pm-plugins/newline-preserve-marks.js +0 -20
  110. package/dist/es2019/plugins/base/pm-plugins/scroll-gutter/index.js +0 -242
  111. package/dist/es2019/plugins/base/pm-plugins/scroll-gutter/plugin-key.js +0 -7
  112. package/dist/es2019/plugins/base/utils/frozen-editor.js +0 -2
  113. package/dist/es2019/plugins/base/utils/input-latency-tracking.js +0 -104
  114. package/dist/esm/plugins/base/commands.js +0 -13
  115. package/dist/esm/plugins/base/index.js +0 -2
  116. package/dist/esm/plugins/base/plugin.js +0 -131
  117. package/dist/esm/plugins/base/pm-plugins/context-identifier.js +0 -48
  118. package/dist/esm/plugins/base/pm-plugins/disable-spell-checking.js +0 -56
  119. package/dist/esm/plugins/base/pm-plugins/filter-steps.js +0 -27
  120. package/dist/esm/plugins/base/pm-plugins/fix-chrome-88-selection.js +0 -26
  121. package/dist/esm/plugins/base/pm-plugins/frozen-editor.js +0 -251
  122. package/dist/esm/plugins/base/pm-plugins/inline-cursor-target.js +0 -174
  123. package/dist/esm/plugins/base/pm-plugins/newline-preserve-marks.js +0 -26
  124. package/dist/esm/plugins/base/pm-plugins/scroll-gutter/index.js +0 -254
  125. package/dist/esm/plugins/base/pm-plugins/scroll-gutter/plugin-key.js +0 -7
  126. package/dist/esm/plugins/base/utils/frozen-editor.js +0 -4
  127. package/dist/esm/plugins/base/utils/input-latency-tracking.js +0 -128
  128. package/dist/types/plugins/base/commands.d.ts +0 -2
  129. package/dist/types/plugins/base/index.d.ts +0 -5
  130. package/dist/types/plugins/base/plugin.d.ts +0 -25
  131. package/dist/types/plugins/base/pm-plugins/context-identifier.d.ts +0 -13
  132. package/dist/types/plugins/base/pm-plugins/disable-spell-checking.d.ts +0 -4
  133. package/dist/types/plugins/base/pm-plugins/filter-steps.d.ts +0 -4
  134. package/dist/types/plugins/base/pm-plugins/fix-chrome-88-selection.d.ts +0 -5
  135. package/dist/types/plugins/base/pm-plugins/frozen-editor.d.ts +0 -12
  136. package/dist/types/plugins/base/pm-plugins/inline-cursor-target.d.ts +0 -17
  137. package/dist/types/plugins/base/pm-plugins/newline-preserve-marks.d.ts +0 -5
  138. package/dist/types/plugins/base/pm-plugins/scroll-gutter/index.d.ts +0 -22
  139. package/dist/types/plugins/base/pm-plugins/scroll-gutter/plugin-key.d.ts +0 -7
  140. package/dist/types/plugins/base/utils/frozen-editor.d.ts +0 -2
  141. package/dist/types/plugins/base/utils/input-latency-tracking.d.ts +0 -42
  142. package/dist/types-ts4.5/plugins/base/commands.d.ts +0 -2
  143. package/dist/types-ts4.5/plugins/base/index.d.ts +0 -5
  144. package/dist/types-ts4.5/plugins/base/plugin.d.ts +0 -27
  145. package/dist/types-ts4.5/plugins/base/pm-plugins/context-identifier.d.ts +0 -13
  146. package/dist/types-ts4.5/plugins/base/pm-plugins/disable-spell-checking.d.ts +0 -4
  147. package/dist/types-ts4.5/plugins/base/pm-plugins/filter-steps.d.ts +0 -4
  148. package/dist/types-ts4.5/plugins/base/pm-plugins/fix-chrome-88-selection.d.ts +0 -5
  149. package/dist/types-ts4.5/plugins/base/pm-plugins/frozen-editor.d.ts +0 -12
  150. package/dist/types-ts4.5/plugins/base/pm-plugins/inline-cursor-target.d.ts +0 -17
  151. package/dist/types-ts4.5/plugins/base/pm-plugins/newline-preserve-marks.d.ts +0 -5
  152. package/dist/types-ts4.5/plugins/base/pm-plugins/scroll-gutter/index.d.ts +0 -22
  153. package/dist/types-ts4.5/plugins/base/pm-plugins/scroll-gutter/plugin-key.d.ts +0 -7
  154. package/dist/types-ts4.5/plugins/base/utils/frozen-editor.d.ts +0 -2
  155. package/dist/types-ts4.5/plugins/base/utils/input-latency-tracking.d.ts +0 -42
  156. /package/dist/cjs/{editor-next → composable-editor}/hooks/useEditorMeasuresConstructor.js +0 -0
  157. /package/dist/cjs/{editor-next → composable-editor}/hooks/useMeasureEditorMountTime.js +0 -0
  158. /package/dist/cjs/{editor-next → composable-editor}/hooks/useProviderFactory.js +0 -0
  159. /package/dist/cjs/{editor-next → composable-editor}/utils/editorMeasureTTICallback.js +0 -0
  160. /package/dist/cjs/{editor-next → composable-editor}/utils/getBaseFontSize.js +0 -0
  161. /package/dist/cjs/{editor-next → composable-editor}/utils/getProvidersFromEditorProps.js +0 -0
  162. /package/dist/cjs/{editor-next → composable-editor}/utils/handleProviders.js +0 -0
  163. /package/dist/cjs/{editor-next → composable-editor}/utils/sendDurationAnalytics.js +0 -0
  164. /package/dist/cjs/{editor-next → composable-editor}/utils/trackEditorActions.js +0 -0
  165. /package/dist/es2019/{editor-next → composable-editor}/hooks/useEditorMeasuresConstructor.js +0 -0
  166. /package/dist/es2019/{editor-next → composable-editor}/hooks/useMeasureEditorMountTime.js +0 -0
  167. /package/dist/es2019/{editor-next → composable-editor}/hooks/useProviderFactory.js +0 -0
  168. /package/dist/es2019/{editor-next → composable-editor}/utils/editorMeasureTTICallback.js +0 -0
  169. /package/dist/es2019/{editor-next → composable-editor}/utils/getBaseFontSize.js +0 -0
  170. /package/dist/es2019/{editor-next → composable-editor}/utils/getProvidersFromEditorProps.js +0 -0
  171. /package/dist/es2019/{editor-next → composable-editor}/utils/handleProviders.js +0 -0
  172. /package/dist/es2019/{editor-next → composable-editor}/utils/sendDurationAnalytics.js +0 -0
  173. /package/dist/es2019/{editor-next → composable-editor}/utils/trackEditorActions.js +0 -0
  174. /package/dist/esm/{editor-next → composable-editor}/hooks/useEditorMeasuresConstructor.js +0 -0
  175. /package/dist/esm/{editor-next → composable-editor}/hooks/useMeasureEditorMountTime.js +0 -0
  176. /package/dist/esm/{editor-next → composable-editor}/hooks/useProviderFactory.js +0 -0
  177. /package/dist/esm/{editor-next → composable-editor}/utils/editorMeasureTTICallback.js +0 -0
  178. /package/dist/esm/{editor-next → composable-editor}/utils/getBaseFontSize.js +0 -0
  179. /package/dist/esm/{editor-next → composable-editor}/utils/getProvidersFromEditorProps.js +0 -0
  180. /package/dist/esm/{editor-next → composable-editor}/utils/handleProviders.js +0 -0
  181. /package/dist/esm/{editor-next → composable-editor}/utils/sendDurationAnalytics.js +0 -0
  182. /package/dist/esm/{editor-next → composable-editor}/utils/trackEditorActions.js +0 -0
  183. /package/dist/types/{editor-next → composable-editor}/hooks/useEditorMeasuresConstructor.d.ts +0 -0
  184. /package/dist/types/{editor-next → composable-editor}/hooks/useProviderFactory.d.ts +0 -0
  185. /package/dist/types/{editor-next → composable-editor}/utils/editorMeasureTTICallback.d.ts +0 -0
  186. /package/dist/types/{editor-next → composable-editor}/utils/handleProviders.d.ts +0 -0
  187. /package/dist/types-ts4.5/{editor-next → composable-editor}/hooks/useEditorMeasuresConstructor.d.ts +0 -0
  188. /package/dist/types-ts4.5/{editor-next → composable-editor}/hooks/useProviderFactory.d.ts +0 -0
  189. /package/dist/types-ts4.5/{editor-next → composable-editor}/utils/editorMeasureTTICallback.d.ts +0 -0
  190. /package/dist/types-ts4.5/{editor-next → composable-editor}/utils/handleProviders.d.ts +0 -0
@@ -1,251 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- 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; }
3
- 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; }
4
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
5
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
6
- import { isPerformanceObserverAvailable, isPerformanceAPIAvailable, getAnalyticsEventSeverity, countNodes } from '@atlaskit/editor-common/utils';
7
- import { EditorExperience, ExperienceStore } from '@atlaskit/editor-common/ufo';
8
- import { ACTION, ACTION_SUBJECT, BROWSER_FREEZE_INTERACTION_TYPE, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
9
- import { getContextIdentifier } from './context-identifier';
10
- import { setInteractionType } from '../utils/frozen-editor';
11
- import InputLatencyTracker from '../utils/input-latency-tracking';
12
- export var frozenEditorPluginKey = new PluginKey('frozenEditor');
13
- var DEFAULT_KEYSTROKE_SAMPLING_LIMIT = 100;
14
- var DEFAULT_SLOW_THRESHOLD = 300;
15
- export var DEFAULT_FREEZE_THRESHOLD = 600;
16
- export var NORMAL_SEVERITY_THRESHOLD = 2000;
17
- export var DEGRADED_SEVERITY_THRESHOLD = 3000;
18
- var DEFAULT_TRACK_SEVERITY_ENABLED = false;
19
- export var DEFAULT_TRACK_SEVERITY_THRESHOLD_NORMAL = 100;
20
- export var DEFAULT_TRACK_SEVERITY_THRESHOLD_DEGRADED = 500;
21
- var dispatchLongTaskEvent = function dispatchLongTaskEvent(dispatchAnalyticsEvent, view, time, getNodeCount, interactionType, severity) {
22
- var _getContextIdentifier;
23
- var state = view.state;
24
- var nodesCount = getNodeCount(state);
25
- return dispatchAnalyticsEvent({
26
- action: ACTION.BROWSER_FREEZE,
27
- actionSubject: ACTION_SUBJECT.EDITOR,
28
- attributes: _objectSpread(_objectSpread({
29
- objectId: (_getContextIdentifier = getContextIdentifier(state)) === null || _getContextIdentifier === void 0 ? void 0 : _getContextIdentifier.objectId,
30
- freezeTime: time,
31
- nodeSize: state.doc.nodeSize
32
- }, nodesCount), {}, {
33
- interactionType: interactionType,
34
- severity: severity
35
- }),
36
- eventType: EVENT_TYPE.OPERATIONAL
37
- });
38
- };
39
- export default (function (dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, ufo) {
40
- var interactionType;
41
- var inputLatencyTracker = null;
42
- var inputLatencySingleKeyTracker = null;
43
- var inputLatencyRenderedTracker = null;
44
- if (browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackInteractionType) {
45
- interactionType = setInteractionType(BROWSER_FREEZE_INTERACTION_TYPE.LOADING);
46
- }
47
- var samplingRate = inputTracking && typeof inputTracking.samplingRate === 'number' ? inputTracking.samplingRate : DEFAULT_KEYSTROKE_SAMPLING_LIMIT;
48
- var slowThreshold = inputTracking && typeof inputTracking.slowThreshold === 'number' ? inputTracking.slowThreshold : DEFAULT_SLOW_THRESHOLD;
49
- var freezeThreshold = inputTracking && typeof inputTracking.freezeThreshold === 'number' ? inputTracking.freezeThreshold : DEFAULT_FREEZE_THRESHOLD;
50
- var allowCountNodes = inputTracking && inputTracking.countNodes;
51
- var prevNodeCountState = null;
52
- var prevNodeCount = {};
53
-
54
- // Cache the result as we were calling this multiple times
55
- // and has potential to be expensive
56
- var getNodeCount = function getNodeCount(state) {
57
- if (state === prevNodeCountState) {
58
- return prevNodeCount;
59
- }
60
- prevNodeCount = allowCountNodes ? countNodes(state) : {};
61
- prevNodeCountState = state;
62
- return prevNodeCount;
63
- };
64
- var shouldTrackSeverity = (inputTracking === null || inputTracking === void 0 ? void 0 : inputTracking.trackSeverity) || DEFAULT_TRACK_SEVERITY_ENABLED;
65
- var severityThresholdNormal = (inputTracking === null || inputTracking === void 0 ? void 0 : inputTracking.severityNormalThreshold) || DEFAULT_TRACK_SEVERITY_THRESHOLD_NORMAL;
66
- var severityThresholdDegraded = (inputTracking === null || inputTracking === void 0 ? void 0 : inputTracking.severityDegradedThreshold) || DEFAULT_TRACK_SEVERITY_THRESHOLD_DEGRADED;
67
- var createDispatchSample = function createDispatchSample(action, view) {
68
- return function (time, severity) {
69
- var _getContextIdentifier2;
70
- var state = view.state;
71
- var nodesCount = getNodeCount(state);
72
- var samplePayload = {
73
- action: action,
74
- actionSubject: ACTION_SUBJECT.EDITOR,
75
- attributes: _objectSpread(_objectSpread({
76
- time: time,
77
- nodeSize: state.doc.nodeSize
78
- }, nodesCount), {}, {
79
- objectId: (_getContextIdentifier2 = getContextIdentifier(state)) === null || _getContextIdentifier2 === void 0 ? void 0 : _getContextIdentifier2.objectId,
80
- severity: shouldTrackSeverity ? severity : undefined
81
- }),
82
- eventType: EVENT_TYPE.OPERATIONAL
83
- };
84
- dispatchAnalyticsEvent(samplePayload);
85
- };
86
- };
87
- var createDispatchAverage = function createDispatchAverage(action, view) {
88
- return function (_ref, severity) {
89
- var _getContextIdentifier3;
90
- var mean = _ref.mean,
91
- median = _ref.median,
92
- sampleSize = _ref.sampleSize;
93
- var state = view.state;
94
- var nodeCount = getNodeCount(state);
95
- var averagePayload = {
96
- action: action,
97
- actionSubject: ACTION_SUBJECT.EDITOR,
98
- attributes: _objectSpread(_objectSpread({
99
- mean: mean,
100
- median: median,
101
- sampleSize: sampleSize
102
- }, nodeCount), {}, {
103
- nodeSize: state.doc.nodeSize,
104
- severity: shouldTrackSeverity ? severity : undefined,
105
- objectId: (_getContextIdentifier3 = getContextIdentifier(state)) === null || _getContextIdentifier3 === void 0 ? void 0 : _getContextIdentifier3.objectId
106
- }),
107
- eventType: EVENT_TYPE.OPERATIONAL
108
- };
109
- dispatchAnalyticsEvent(averagePayload);
110
- };
111
- };
112
- return new SafePlugin({
113
- key: frozenEditorPluginKey,
114
- props: isPerformanceAPIAvailable() ? {
115
- handleTextInput: function handleTextInput(view) {
116
- if (browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackInteractionType) {
117
- interactionType = BROWSER_FREEZE_INTERACTION_TYPE.TYPING;
118
- }
119
- if (inputLatencyTracker) {
120
- var end = inputLatencyTracker.start();
121
-
122
- // This is called after all handleTextInput events are executed which means first handleTextInput time incorporates following handleTextInput processing time
123
- // Also this is called before browser rendering so it doesn't count it.
124
- requestAnimationFrame(end);
125
- }
126
- if (inputLatencySingleKeyTracker) {
127
- var _end = inputLatencySingleKeyTracker.start();
128
-
129
- // This is executed before next handleTextInput when multiple keypress events are in one animation frame
130
- // so it tracks individual keypress processing time
131
- Promise.resolve().then(_end);
132
- }
133
- if (inputLatencyRenderedTracker) {
134
- var _end2 = inputLatencyRenderedTracker.start();
135
-
136
- // This is called at the next event loop so it counts browser rendering time.
137
- setTimeout(_end2);
138
- }
139
- return false;
140
- },
141
- handleDOMEvents: browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackInteractionType ? {
142
- click: function click() {
143
- interactionType = setInteractionType(BROWSER_FREEZE_INTERACTION_TYPE.CLICKING);
144
- return false;
145
- },
146
- paste: function paste() {
147
- interactionType = setInteractionType(BROWSER_FREEZE_INTERACTION_TYPE.PASTING);
148
- return false;
149
- }
150
- } : undefined
151
- } : undefined,
152
- view: function view(_view) {
153
- if (!isPerformanceObserverAvailable()) {
154
- return {};
155
- }
156
- var experienceStore = ufo ? ExperienceStore.getInstance(_view) : undefined;
157
- if (inputTracking !== null && inputTracking !== void 0 && inputTracking.enabled) {
158
- inputLatencyTracker = new InputLatencyTracker({
159
- samplingRate: samplingRate,
160
- slowThreshold: slowThreshold,
161
- normalThreshold: severityThresholdNormal,
162
- degradedThreshold: severityThresholdDegraded,
163
- onSampleStart: function onSampleStart() {
164
- experienceStore === null || experienceStore === void 0 ? void 0 : experienceStore.start(EditorExperience.typing);
165
- },
166
- onSampleEnd: function onSampleEnd(time, _ref2) {
167
- var _getContextIdentifier4;
168
- var isSlow = _ref2.isSlow,
169
- severity = _ref2.severity;
170
- var state = _view.state;
171
- var nodesCount = getNodeCount(state);
172
- if (isSlow) {
173
- experienceStore === null || experienceStore === void 0 ? void 0 : experienceStore.addMetadata(EditorExperience.typing, {
174
- slowInput: true
175
- });
176
- }
177
- experienceStore === null || experienceStore === void 0 ? void 0 : experienceStore.success(EditorExperience.typing, _objectSpread(_objectSpread({
178
- nodeSize: state.doc.nodeSize
179
- }, nodesCount), {}, {
180
- objectId: (_getContextIdentifier4 = getContextIdentifier(state)) === null || _getContextIdentifier4 === void 0 ? void 0 : _getContextIdentifier4.objectId,
181
- time: time,
182
- severity: shouldTrackSeverity ? severity : undefined
183
- }));
184
- },
185
- dispatchSample: createDispatchSample(ACTION.INPUT_PERF_SAMPLING, _view),
186
- dispatchAverage: createDispatchAverage(ACTION.INPUT_PERF_SAMPLING_AVG, _view),
187
- onSlowInput: function onSlowInput(time) {
188
- var _getContextIdentifier5;
189
- var state = _view.state;
190
- var nodesCount = getNodeCount(state);
191
- dispatchAnalyticsEvent({
192
- action: ACTION.SLOW_INPUT,
193
- actionSubject: ACTION_SUBJECT.EDITOR,
194
- attributes: _objectSpread(_objectSpread({
195
- time: time,
196
- nodeSize: state.doc.nodeSize
197
- }, nodesCount), {}, {
198
- objectId: (_getContextIdentifier5 = getContextIdentifier(state)) === null || _getContextIdentifier5 === void 0 ? void 0 : _getContextIdentifier5.objectId
199
- }),
200
- eventType: EVENT_TYPE.OPERATIONAL
201
- });
202
- }
203
- });
204
- }
205
- if (inputTracking !== null && inputTracking !== void 0 && inputTracking.trackSingleKeypress) {
206
- inputLatencySingleKeyTracker = new InputLatencyTracker({
207
- samplingRate: samplingRate,
208
- slowThreshold: slowThreshold,
209
- normalThreshold: severityThresholdNormal,
210
- degradedThreshold: severityThresholdDegraded,
211
- dispatchSample: createDispatchSample(ACTION.INPUT_PERF_SAMPLING_SINGLE_KEYPRESS, _view),
212
- dispatchAverage: createDispatchAverage(ACTION.INPUT_PERF_SAMPLING_SINGLE_KEYPRESS_AVG, _view)
213
- });
214
- }
215
- if (inputTracking !== null && inputTracking !== void 0 && inputTracking.trackRenderingTime) {
216
- inputLatencyRenderedTracker = new InputLatencyTracker({
217
- samplingRate: samplingRate,
218
- slowThreshold: slowThreshold,
219
- normalThreshold: severityThresholdNormal,
220
- degradedThreshold: severityThresholdDegraded,
221
- dispatchSample: createDispatchSample(ACTION.INPUT_PERF_SAMPLING_RENDERED, _view),
222
- dispatchAverage: createDispatchAverage(ACTION.INPUT_PERF_SAMPLING_RENDERED_AVG, _view)
223
- });
224
- }
225
- var observer;
226
- try {
227
- var _observer = new PerformanceObserver(function (list) {
228
- var perfEntries = list.getEntries();
229
- for (var i = 0; i < perfEntries.length; i++) {
230
- var duration = perfEntries[i].duration;
231
- if (duration > freezeThreshold) {
232
- dispatchLongTaskEvent(dispatchAnalyticsEvent, _view, duration, getNodeCount, browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackInteractionType ? interactionType : undefined, browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackSeverity ? getAnalyticsEventSeverity(duration, browserFreezeTracking.severityNormalThreshold || NORMAL_SEVERITY_THRESHOLD, browserFreezeTracking.severityDegradedThreshold || DEGRADED_SEVERITY_THRESHOLD) : undefined);
233
- }
234
- }
235
- });
236
-
237
- // register observer for long task notifications
238
- _observer.observe({
239
- entryTypes: ['longtask']
240
- });
241
- } catch (e) {}
242
- return {
243
- destroy: function destroy() {
244
- var _inputLatencyTracker;
245
- (_inputLatencyTracker = inputLatencyTracker) === null || _inputLatencyTracker === void 0 ? void 0 : _inputLatencyTracker.flush();
246
- observer === null || observer === void 0 ? void 0 : observer.disconnect();
247
- }
248
- };
249
- }
250
- });
251
- });
@@ -1,174 +0,0 @@
1
- import { DecorationSet, Decoration } from '@atlaskit/editor-prosemirror/view';
2
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
4
- import { ZERO_WIDTH_SPACE, browser, isTextSelection } from '@atlaskit/editor-common/utils';
5
- export var inlineCursorTargetStateKey = new PluginKey('inlineCursorTargetPlugin');
6
- export var isInlineNodeView = function isInlineNodeView(node) {
7
- return node && node.type.isInline && !node.type.isText;
8
- };
9
- export default (function () {
10
- return new SafePlugin({
11
- key: inlineCursorTargetStateKey,
12
- state: {
13
- init: function init() {
14
- return {
15
- cursorTarget: undefined
16
- };
17
- },
18
- apply: function apply(tr) {
19
- var selection = tr.selection,
20
- doc = tr.doc;
21
- var $from = selection.$from,
22
- $to = selection.$to;
23
- // In Safari, if the cursor target is to the right of the cursor it will block selections
24
- // made with shift + arrowRight and vice versa for shift + arrowLeft. This is due to a
25
- // contenteditable bug in safari, where editable elements block the selection but we need
26
- // the cursor target to be editable for the following:
27
- // - Ability to navigate with down/up arrows when between inline nodes
28
- // - Ability to navigate with down/up arrows when between the start of a paragraph & an inline node
29
- // - Ability to click and drag to select an inline node if it is the first node
30
- // To prevent blocking the selection, we check handleDOMEvents and add meta to
31
- // the transaction to prevent the plugin from making cursor target decorations.
32
- var safariShiftSelection = tr.getMeta(inlineCursorTargetStateKey);
33
- if (selection && isTextSelection(selection) && !safariShiftSelection) {
34
- var hasInlineNodeViewAfter = isInlineNodeView($from.nodeAfter);
35
- var hasInlineNodeViewBefore = isInlineNodeView($from.nodeBefore);
36
- var isAtStartAndInlineNodeViewAfter = $from.parentOffset === 0 && isInlineNodeView($from.nodeAfter);
37
- var isAtEndAndInlineNodeViewBefore = doc.resolve($from.pos).node().lastChild === $from.nodeBefore && isInlineNodeView($from.nodeBefore);
38
- var createWidget = function createWidget(side) {
39
- var node = document.createElement('span');
40
- node.contentEditable = 'true';
41
- node.setAttribute('aria-hidden', 'true');
42
- node.appendChild(document.createTextNode(ZERO_WIDTH_SPACE));
43
- node.className = 'cursor-target';
44
- var $from = selection.$from;
45
- var rightPosition = $from.pos;
46
- var leftPosition = $from.posAtIndex(Math.max($from.index() - 1, 0));
47
- var widgetPos = side === 'left' ? leftPosition : rightPosition;
48
- return Decoration.widget(widgetPos, node, {
49
- raw: true,
50
- key: 'inlineCursor'
51
- });
52
- };
53
-
54
- // Create editable decoration widgets around the current inline node to allow proper cursor navigation.
55
- if ((hasInlineNodeViewAfter || isAtEndAndInlineNodeViewBefore) && (hasInlineNodeViewBefore || isAtStartAndInlineNodeViewAfter)) {
56
- return {
57
- cursorTarget: {
58
- decorations: [createWidget('left'), createWidget('right')],
59
- positions: {
60
- from: $from.pos,
61
- to: $to.pos
62
- }
63
- }
64
- };
65
- }
66
- }
67
- return {
68
- cursorTarget: undefined
69
- };
70
- }
71
- },
72
- props: {
73
- decorations: function decorations(state) {
74
- var doc = state.doc;
75
- var _ref = inlineCursorTargetStateKey.getState(state),
76
- cursorTarget = _ref.cursorTarget;
77
- if (cursorTargetHasValidDecorations(cursorTarget)) {
78
- return DecorationSet.create(doc, cursorTarget.decorations);
79
- }
80
- return null;
81
- },
82
- handleDOMEvents: {
83
- // Workaround to prevent the decorations created by the plugin from
84
- // blocking shift + arrow left/right selections in safari. When
85
- // a shift + arrow left/right event is detected, send meta data to the
86
- // plugin to prevent it from creating decorations.
87
- // TODO We may be able to remove this when playing the following ticket:
88
- // https://product-fabric.atlassian.net/browse/ED-14938
89
- keydown: function keydown(view, event) {
90
- if (browser.safari && event instanceof KeyboardEvent && event.shiftKey && (event.key === 'ArrowLeft' || event.key === 'ArrowRight')) {
91
- view.dispatch(view.state.tr.setMeta(inlineCursorTargetStateKey, {
92
- cursorTarget: undefined
93
- }));
94
- }
95
- return false;
96
- },
97
- // Check the DOM to see if there are inline cursor targets
98
- // after a composition event ends. If so, manually insert the
99
- // event data in order to prevent contents ending up inside
100
- // of the cursor target decorations.
101
- compositionend: function compositionend(view, incorrectlyTypedEvent) {
102
- // This is typed by the prosemirror definitions as Event,
103
- // this type is incorrect, and it is actually an InputEvent
104
- var event = incorrectlyTypedEvent;
105
- var state = view.state;
106
- var _ref2 = inlineCursorTargetStateKey.getState(state),
107
- cursorTarget = _ref2.cursorTarget;
108
- if (cursorTarget !== undefined) {
109
- handleTextInputInsideCursorTargetDecoration({
110
- event: event,
111
- cursorTarget: cursorTarget,
112
- view: view
113
- });
114
- return true;
115
- }
116
- return false;
117
- },
118
- // Check the DOM to see if there are inline cursor targets
119
- // before any input event. If so, manually insert the
120
- // event data in order to prevent contents ending up inside
121
- // of the cursor target decorations.
122
- beforeinput: function beforeinput(view, incorrectlyTypedEvent) {
123
- // This is typed by the prosemirror definitions as Event,
124
- // this type is incorrect, and it is actually an InputEvent
125
- var event = incorrectlyTypedEvent;
126
- var state = view.state;
127
- var _ref3 = inlineCursorTargetStateKey.getState(state),
128
- cursorTarget = _ref3.cursorTarget;
129
- if (!event.isComposing && cursorTarget !== undefined) {
130
- handleTextInputInsideCursorTargetDecoration({
131
- event: event,
132
- cursorTarget: cursorTarget,
133
- view: view
134
- });
135
- return true;
136
- }
137
- return false;
138
- }
139
- }
140
- }
141
- });
142
- });
143
- function cursorTargetHasValidDecorations(cursorTarget) {
144
- if (!cursorTarget ||
145
- // Decorations can end up as null when the decorations prop is
146
- // called after the decorations have been removed from the dom.
147
- // https://github.com/ProseMirror/prosemirror-view/blob/8f0d313a6389b86a335274fba36534ba1cb21f12/src/decoration.js#L30
148
- cursorTarget.decorations.includes(null)) {
149
- return false;
150
- }
151
- return true;
152
- }
153
- function handleTextInputInsideCursorTargetDecoration(_ref4) {
154
- var event = _ref4.event,
155
- view = _ref4.view,
156
- cursorTarget = _ref4.cursorTarget;
157
- event.stopPropagation();
158
- event.preventDefault();
159
- var content = event.data || '';
160
- var tr = view.state.tr;
161
-
162
- // ensure any custom handleTextInput handlers are called for the input event
163
- // ie. type ahead, emoji shortcuts.
164
- var potentiallyHandleByHandleTextInput = view.someProp('handleTextInput', function (f) {
165
- return f(view, cursorTarget.positions.from, cursorTarget.positions.to, content);
166
- });
167
- if (potentiallyHandleByHandleTextInput) {
168
- // if a handleTextInput handler has handled the event, we don't want to
169
- // manually update the document.
170
- return;
171
- }
172
- tr.insertText(content);
173
- view.dispatch(tr);
174
- }
@@ -1,26 +0,0 @@
1
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
- import { keydownHandler } from '@atlaskit/editor-prosemirror/keymap';
4
- import { filterCommand as filter, isSelectionEndOfParagraph } from '@atlaskit/editor-common/utils';
5
- export var newlinePreserveMarksKey = new PluginKey('newlinePreserveMarksPlugin');
6
- var isSelectionAligned = function isSelectionAligned(state) {
7
- return !!state.selection.$to.parent.marks.find(function (m) {
8
- return m.type === state.schema.marks.alignment;
9
- });
10
- };
11
- var splitBlockPreservingMarks = function splitBlockPreservingMarks(state, dispatch) {
12
- if (dispatch) {
13
- dispatch(state.tr.split(state.tr.mapping.map(state.selection.$from.pos), 1));
14
- }
15
- return true;
16
- };
17
- export default (function () {
18
- return new SafePlugin({
19
- key: newlinePreserveMarksKey,
20
- props: {
21
- handleKeyDown: keydownHandler({
22
- Enter: filter([isSelectionEndOfParagraph, isSelectionAligned], splitBlockPreservingMarks)
23
- })
24
- }
25
- });
26
- });