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