@atlaskit/editor-core 164.0.4 → 166.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (182) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/dist/cjs/actions/index.js +9 -0
  3. package/dist/cjs/create-editor/ReactEditorView.js +14 -6
  4. package/dist/cjs/create-editor/create-plugins-list.js +1 -2
  5. package/dist/cjs/editor.js +13 -0
  6. package/dist/cjs/event-dispatcher/index.js +9 -0
  7. package/dist/cjs/nodeviews/ReactNodeView.js +1 -11
  8. package/dist/cjs/nodeviews/getInlineNodeViewProducer.styles.js +1 -1
  9. package/dist/cjs/nodeviews/getPerformanceOptions.js +1 -1
  10. package/dist/cjs/plugins/analytics/types/enums.js +1 -0
  11. package/dist/cjs/plugins/base/pm-plugins/frozen-editor.js +128 -79
  12. package/dist/cjs/plugins/base/utils/input-latency-tracking.js +157 -0
  13. package/dist/cjs/plugins/card/styles.js +3 -1
  14. package/dist/cjs/plugins/code-block/styles.js +6 -4
  15. package/dist/cjs/plugins/collab-edit/plugin-state.js +23 -5
  16. package/dist/cjs/plugins/date/styles.js +3 -1
  17. package/dist/cjs/plugins/emoji/index.js +30 -34
  18. package/dist/cjs/plugins/emoji/nodeviews/emoji.js +12 -66
  19. package/dist/cjs/plugins/emoji/styles.js +3 -17
  20. package/dist/cjs/plugins/expand/ui/styles.js +2 -2
  21. package/dist/cjs/plugins/extension/ui/styles.js +3 -1
  22. package/dist/cjs/plugins/feature-flags-context/feature-flags-from-props.js +20 -22
  23. package/dist/cjs/plugins/hyperlink/pm-plugins/input-rule.js +1 -9
  24. package/dist/cjs/plugins/hyperlink/pm-plugins/keymap.js +1 -9
  25. package/dist/cjs/plugins/layout/styles.js +3 -1
  26. package/dist/cjs/plugins/list/commands/indent-list.js +5 -1
  27. package/dist/cjs/plugins/list/commands/outdent-list.js +5 -1
  28. package/dist/cjs/plugins/list/transforms.js +11 -3
  29. package/dist/cjs/plugins/media/styles.js +3 -1
  30. package/dist/cjs/plugins/mentions/index.js +10 -14
  31. package/dist/cjs/plugins/mentions/nodeviews/mention.js +15 -67
  32. package/dist/cjs/plugins/mentions/pm-plugins/main.js +19 -10
  33. package/dist/cjs/plugins/mentions/type-ahead/index.js +7 -2
  34. package/dist/cjs/plugins/panel/styles.js +3 -1
  35. package/dist/cjs/plugins/placeholder-text/placeholder-text-nodeview.js +3 -1
  36. package/dist/cjs/plugins/rule/styles.js +3 -1
  37. package/dist/cjs/plugins/selection/utils.js +39 -23
  38. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +24 -0
  39. package/dist/cjs/plugins/table/ui/common-styles.js +1 -1
  40. package/dist/cjs/plugins/table/ui/consts.js +6 -4
  41. package/dist/cjs/plugins/tasks-and-decisions/styles.js +3 -1
  42. package/dist/cjs/plugins/type-ahead/index.js +6 -2
  43. package/dist/cjs/plugins/unsupported-content/index.js +22 -10
  44. package/dist/cjs/plugins/unsupported-content/styles.js +4 -2
  45. package/dist/cjs/plugins/unsupported-content/unsupported-inline-node-view.js +21 -0
  46. package/dist/cjs/ui/Appearance/Chromeless.js +6 -3
  47. package/dist/cjs/ui/Appearance/Comment/Comment.js +6 -4
  48. package/dist/cjs/ui/ChromeCollapsed/styles.js +3 -1
  49. package/dist/cjs/ui/ContentStyles/index.js +2 -2
  50. package/dist/cjs/version-wrapper.js +1 -1
  51. package/dist/cjs/version.json +1 -1
  52. package/dist/es2019/actions/index.js +12 -1
  53. package/dist/es2019/create-editor/ReactEditorView.js +14 -6
  54. package/dist/es2019/create-editor/create-plugins-list.js +1 -2
  55. package/dist/es2019/editor.js +14 -0
  56. package/dist/es2019/event-dispatcher/index.js +8 -0
  57. package/dist/es2019/nodeviews/ReactNodeView.js +1 -10
  58. package/dist/es2019/nodeviews/getInlineNodeViewProducer.styles.js +9 -0
  59. package/dist/es2019/plugins/analytics/types/enums.js +1 -0
  60. package/dist/es2019/plugins/base/pm-plugins/frozen-editor.js +138 -80
  61. package/dist/es2019/plugins/base/utils/input-latency-tracking.js +128 -0
  62. package/dist/es2019/plugins/card/styles.js +9 -5
  63. package/dist/es2019/plugins/code-block/styles.js +11 -8
  64. package/dist/es2019/plugins/collab-edit/plugin-state.js +23 -8
  65. package/dist/es2019/plugins/date/styles.js +3 -1
  66. package/dist/es2019/plugins/emoji/index.js +16 -21
  67. package/dist/es2019/plugins/emoji/nodeviews/emoji.js +12 -31
  68. package/dist/es2019/plugins/emoji/styles.js +1 -82
  69. package/dist/es2019/plugins/expand/ui/styles.js +2 -2
  70. package/dist/es2019/plugins/extension/ui/styles.js +4 -2
  71. package/dist/es2019/plugins/feature-flags-context/feature-flags-from-props.js +20 -22
  72. package/dist/es2019/plugins/hyperlink/pm-plugins/input-rule.js +1 -8
  73. package/dist/es2019/plugins/hyperlink/pm-plugins/keymap.js +1 -8
  74. package/dist/es2019/plugins/layout/styles.js +3 -2
  75. package/dist/es2019/plugins/list/commands/indent-list.js +4 -1
  76. package/dist/es2019/plugins/list/commands/outdent-list.js +4 -1
  77. package/dist/es2019/plugins/list/transforms.js +9 -4
  78. package/dist/es2019/plugins/media/styles.js +9 -7
  79. package/dist/es2019/plugins/mentions/index.js +1 -6
  80. package/dist/es2019/plugins/mentions/nodeviews/mention.js +16 -35
  81. package/dist/es2019/plugins/mentions/pm-plugins/main.js +18 -10
  82. package/dist/es2019/plugins/mentions/type-ahead/index.js +7 -2
  83. package/dist/es2019/plugins/panel/styles.js +5 -4
  84. package/dist/es2019/plugins/placeholder-text/placeholder-text-nodeview.js +3 -1
  85. package/dist/es2019/plugins/rule/styles.js +2 -1
  86. package/dist/es2019/plugins/selection/utils.js +35 -20
  87. package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +22 -0
  88. package/dist/es2019/plugins/table/ui/common-styles.js +4 -0
  89. package/dist/es2019/plugins/table/ui/consts.js +5 -4
  90. package/dist/es2019/plugins/tasks-and-decisions/styles.js +4 -2
  91. package/dist/es2019/plugins/type-ahead/index.js +5 -1
  92. package/dist/es2019/plugins/unsupported-content/index.js +23 -12
  93. package/dist/es2019/plugins/unsupported-content/styles.js +5 -3
  94. package/dist/es2019/plugins/unsupported-content/unsupported-inline-node-view.js +7 -0
  95. package/dist/es2019/ui/Appearance/Chromeless.js +5 -2
  96. package/dist/es2019/ui/Appearance/Comment/Comment.js +5 -2
  97. package/dist/es2019/ui/ChromeCollapsed/styles.js +2 -1
  98. package/dist/es2019/ui/ContentStyles/index.js +3 -3
  99. package/dist/es2019/version-wrapper.js +1 -1
  100. package/dist/es2019/version.json +1 -1
  101. package/dist/esm/actions/index.js +8 -0
  102. package/dist/esm/create-editor/ReactEditorView.js +14 -6
  103. package/dist/esm/create-editor/create-plugins-list.js +1 -2
  104. package/dist/esm/editor.js +14 -0
  105. package/dist/esm/event-dispatcher/index.js +9 -0
  106. package/dist/esm/nodeviews/ReactNodeView.js +1 -10
  107. package/dist/esm/nodeviews/getInlineNodeViewProducer.styles.js +1 -1
  108. package/dist/esm/plugins/analytics/types/enums.js +1 -0
  109. package/dist/esm/plugins/base/pm-plugins/frozen-editor.js +128 -79
  110. package/dist/esm/plugins/base/utils/input-latency-tracking.js +149 -0
  111. package/dist/esm/plugins/card/styles.js +2 -1
  112. package/dist/esm/plugins/code-block/styles.js +5 -4
  113. package/dist/esm/plugins/collab-edit/plugin-state.js +21 -6
  114. package/dist/esm/plugins/date/styles.js +2 -1
  115. package/dist/esm/plugins/emoji/index.js +26 -29
  116. package/dist/esm/plugins/emoji/nodeviews/emoji.js +11 -56
  117. package/dist/esm/plugins/emoji/styles.js +3 -14
  118. package/dist/esm/plugins/expand/ui/styles.js +2 -2
  119. package/dist/esm/plugins/extension/ui/styles.js +2 -1
  120. package/dist/esm/plugins/feature-flags-context/feature-flags-from-props.js +20 -22
  121. package/dist/esm/plugins/hyperlink/pm-plugins/input-rule.js +1 -8
  122. package/dist/esm/plugins/hyperlink/pm-plugins/keymap.js +1 -8
  123. package/dist/esm/plugins/layout/styles.js +2 -1
  124. package/dist/esm/plugins/list/commands/indent-list.js +4 -1
  125. package/dist/esm/plugins/list/commands/outdent-list.js +4 -1
  126. package/dist/esm/plugins/list/transforms.js +9 -4
  127. package/dist/esm/plugins/media/styles.js +2 -1
  128. package/dist/esm/plugins/mentions/index.js +10 -14
  129. package/dist/esm/plugins/mentions/nodeviews/mention.js +13 -58
  130. package/dist/esm/plugins/mentions/pm-plugins/main.js +18 -10
  131. package/dist/esm/plugins/mentions/type-ahead/index.js +7 -2
  132. package/dist/esm/plugins/panel/styles.js +2 -1
  133. package/dist/esm/plugins/placeholder-text/placeholder-text-nodeview.js +3 -1
  134. package/dist/esm/plugins/rule/styles.js +2 -1
  135. package/dist/esm/plugins/selection/utils.js +35 -20
  136. package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +23 -0
  137. package/dist/esm/plugins/table/ui/common-styles.js +1 -1
  138. package/dist/esm/plugins/table/ui/consts.js +5 -4
  139. package/dist/esm/plugins/tasks-and-decisions/styles.js +2 -1
  140. package/dist/esm/plugins/type-ahead/index.js +6 -2
  141. package/dist/esm/plugins/unsupported-content/index.js +21 -11
  142. package/dist/esm/plugins/unsupported-content/styles.js +3 -2
  143. package/dist/esm/plugins/unsupported-content/unsupported-inline-node-view.js +7 -0
  144. package/dist/esm/ui/Appearance/Chromeless.js +6 -3
  145. package/dist/esm/ui/Appearance/Comment/Comment.js +6 -4
  146. package/dist/esm/ui/ChromeCollapsed/styles.js +2 -1
  147. package/dist/esm/ui/ContentStyles/index.js +3 -3
  148. package/dist/esm/version-wrapper.js +1 -1
  149. package/dist/esm/version.json +1 -1
  150. package/dist/types/actions/index.d.ts +3 -1
  151. package/dist/types/editor.d.ts +3 -0
  152. package/dist/types/event-dispatcher/index.d.ts +1 -0
  153. package/dist/types/nodeviews/ReactNodeView.d.ts +1 -5
  154. package/dist/types/plugins/analytics/types/enums.d.ts +1 -0
  155. package/dist/types/plugins/analytics/types/events.d.ts +2 -2
  156. package/dist/types/plugins/analytics/types/general-events.d.ts +10 -1
  157. package/dist/types/plugins/base/utils/input-latency-tracking.d.ts +44 -0
  158. package/dist/types/plugins/collab-edit/plugin-state.d.ts +4 -0
  159. package/dist/types/plugins/emoji/index.d.ts +2 -6
  160. package/dist/types/plugins/emoji/nodeviews/emoji.d.ts +4 -14
  161. package/dist/types/plugins/emoji/styles.d.ts +0 -1
  162. package/dist/types/plugins/emoji/types.d.ts +0 -1
  163. package/dist/types/plugins/list/transforms.d.ts +10 -1
  164. package/dist/types/plugins/mentions/nodeviews/mention.d.ts +6 -14
  165. package/dist/types/plugins/mentions/pm-plugins/main.d.ts +2 -5
  166. package/dist/types/plugins/selection/utils.d.ts +7 -15
  167. package/dist/types/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.d.ts +3 -0
  168. package/dist/types/plugins/table/ui/consts.d.ts +2 -2
  169. package/dist/types/plugins/type-ahead/types.d.ts +1 -0
  170. package/dist/types/plugins/unsupported-content/unsupported-inline-node-view.d.ts +11 -0
  171. package/dist/types/types/editor-appearance-component.d.ts +1 -0
  172. package/dist/types/types/editor-props.d.ts +1 -0
  173. package/dist/types/types/feature-flags.d.ts +0 -14
  174. package/dist/types/ui/Appearance/Chromeless.d.ts +1 -0
  175. package/dist/types/ui/Appearance/Comment/Comment.d.ts +1 -0
  176. package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +4 -4
  177. package/dist/types/ui/ContentStyles/index.d.ts +2 -2
  178. package/package.json +23 -23
  179. package/dist/cjs/plugins/emoji/nodeviews/emoji-next.js +0 -250
  180. package/dist/es2019/plugins/emoji/nodeviews/emoji-next.js +0 -177
  181. package/dist/esm/plugins/emoji/nodeviews/emoji-next.js +0 -234
  182. package/dist/types/plugins/emoji/nodeviews/emoji-next.d.ts +0 -31
@@ -7,7 +7,7 @@ import { getParticipantsCount } from '../../collab-edit/get-participants-count';
7
7
  import { countNodes } from '../../../utils/count-nodes';
8
8
  import { getContextIdentifier } from './context-identifier';
9
9
  import { setInteractionType } from '../utils/frozen-editor';
10
- import { getTimeSince } from '../../../utils/performance/get-performance-timing';
10
+ import InputLatencyTracker from '../utils/input-latency-tracking';
11
11
  export const frozenEditorPluginKey = new PluginKey('frozenEditor');
12
12
  const DEFAULT_KEYSTROKE_SAMPLING_LIMIT = 100;
13
13
  const DEFAULT_SLOW_THRESHOLD = 300;
@@ -18,13 +18,13 @@ const DEFAULT_TRACK_SEVERITY_ENABLED = false;
18
18
  export const DEFAULT_TRACK_SEVERITY_THRESHOLD_NORMAL = 100;
19
19
  export const DEFAULT_TRACK_SEVERITY_THRESHOLD_DEGRADED = 500;
20
20
 
21
- const dispatchLongTaskEvent = (dispatchAnalyticsEvent, view, time, allowCountNodes, interactionType, severity) => {
21
+ const dispatchLongTaskEvent = (dispatchAnalyticsEvent, view, time, getNodeCount, interactionType, severity) => {
22
22
  var _getContextIdentifier;
23
23
 
24
24
  const {
25
25
  state
26
26
  } = view;
27
- const nodesCount = allowCountNodes ? countNodes(view.state) : {};
27
+ const nodesCount = getNodeCount(state);
28
28
  return dispatchAnalyticsEvent({
29
29
  action: ACTION.BROWSER_FREEZE,
30
30
  actionSubject: ACTION_SUBJECT.EDITOR,
@@ -42,8 +42,8 @@ const dispatchLongTaskEvent = (dispatchAnalyticsEvent, view, time, allowCountNod
42
42
  };
43
43
 
44
44
  export default ((dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, ufo) => {
45
- let keystrokeCount = 0;
46
45
  let interactionType;
46
+ let inputLatencyTracker = null;
47
47
 
48
48
  if (browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackInteractionType) {
49
49
  interactionType = setInteractionType(BROWSER_FREEZE_INTERACTION_TYPE.LOADING);
@@ -53,6 +53,20 @@ export default ((dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, u
53
53
  const slowThreshold = inputTracking && typeof inputTracking.slowThreshold === 'number' ? inputTracking.slowThreshold : DEFAULT_SLOW_THRESHOLD;
54
54
  const freezeThreshold = inputTracking && typeof inputTracking.freezeThreshold === 'number' ? inputTracking.freezeThreshold : DEFAULT_FREEZE_THRESHOLD;
55
55
  const allowCountNodes = inputTracking && inputTracking.countNodes;
56
+ let prevNodeCountState = null;
57
+ let prevNodeCount = {}; // Cache the result as we were calling this multiple times
58
+ // and has potential to be expensive
59
+
60
+ const getNodeCount = state => {
61
+ if (state === prevNodeCountState) {
62
+ return prevNodeCount;
63
+ }
64
+
65
+ prevNodeCount = allowCountNodes ? countNodes(state) : {};
66
+ prevNodeCountState = state;
67
+ return prevNodeCount;
68
+ };
69
+
56
70
  const shouldTrackSeverity = (inputTracking === null || inputTracking === void 0 ? void 0 : inputTracking.trackSeverity) || DEFAULT_TRACK_SEVERITY_ENABLED;
57
71
  const severityThresholdNormal = (inputTracking === null || inputTracking === void 0 ? void 0 : inputTracking.severityNormalThreshold) || DEFAULT_TRACK_SEVERITY_THRESHOLD_NORMAL;
58
72
  const severityThresholdDegraded = (inputTracking === null || inputTracking === void 0 ? void 0 : inputTracking.severityDegradedThreshold) || DEFAULT_TRACK_SEVERITY_THRESHOLD_DEGRADED;
@@ -60,85 +74,18 @@ export default ((dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, u
60
74
  key: frozenEditorPluginKey,
61
75
  props: isPerformanceAPIAvailable() ? {
62
76
  handleTextInput(view) {
63
- const {
64
- state
65
- } = view;
66
- const now = performance.now();
77
+ var _inputLatencyTracker;
78
+
79
+ (_inputLatencyTracker = inputLatencyTracker) === null || _inputLatencyTracker === void 0 ? void 0 : _inputLatencyTracker.start();
67
80
 
68
81
  if (browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackInteractionType) {
69
82
  interactionType = BROWSER_FREEZE_INTERACTION_TYPE.TYPING;
70
83
  }
71
84
 
72
- const experienceStore = ufo ? ExperienceStore.getInstance(view) : undefined;
73
- const trackTyping = samplingRate && ++keystrokeCount === samplingRate;
74
-
75
- if (trackTyping) {
76
- experienceStore === null || experienceStore === void 0 ? void 0 : experienceStore.start(EditorExperience.typing);
77
- }
78
-
79
85
  requestAnimationFrame(() => {
80
- const diff = getTimeSince(now);
81
-
82
- if (diff > slowThreshold) {
83
- const nodesCount = allowCountNodes ? countNodes(view.state) : {};
84
-
85
- if (inputTracking !== null && inputTracking !== void 0 && inputTracking.enabled) {
86
- var _getContextIdentifier2;
87
-
88
- dispatchAnalyticsEvent({
89
- action: ACTION.SLOW_INPUT,
90
- actionSubject: ACTION_SUBJECT.EDITOR,
91
- attributes: {
92
- time: diff,
93
- nodeSize: state.doc.nodeSize,
94
- ...nodesCount,
95
- participants: getParticipantsCount(state),
96
- objectId: (_getContextIdentifier2 = getContextIdentifier(state)) === null || _getContextIdentifier2 === void 0 ? void 0 : _getContextIdentifier2.objectId
97
- },
98
- eventType: EVENT_TYPE.OPERATIONAL
99
- });
100
- }
101
-
102
- experienceStore === null || experienceStore === void 0 ? void 0 : experienceStore.addMetadata(EditorExperience.typing, {
103
- slowInput: true
104
- });
105
- }
106
-
107
- if (trackTyping) {
108
- var _getContextIdentifier4;
86
+ var _inputLatencyTracker2;
109
87
 
110
- const nodesCount = allowCountNodes ? countNodes(view.state) : {};
111
- keystrokeCount = 0;
112
- const severity = shouldTrackSeverity ? getAnalyticsEventSeverity(diff, severityThresholdNormal, severityThresholdDegraded) : undefined;
113
-
114
- if (inputTracking !== null && inputTracking !== void 0 && inputTracking.enabled) {
115
- var _getContextIdentifier3;
116
-
117
- const payload = {
118
- action: ACTION.INPUT_PERF_SAMPLING,
119
- actionSubject: ACTION_SUBJECT.EDITOR,
120
- attributes: {
121
- time: diff,
122
- nodeSize: state.doc.nodeSize,
123
- ...nodesCount,
124
- participants: getParticipantsCount(state),
125
- objectId: (_getContextIdentifier3 = getContextIdentifier(state)) === null || _getContextIdentifier3 === void 0 ? void 0 : _getContextIdentifier3.objectId,
126
- severity
127
- },
128
- eventType: EVENT_TYPE.OPERATIONAL
129
- };
130
- dispatchAnalyticsEvent(payload);
131
- }
132
-
133
- experienceStore === null || experienceStore === void 0 ? void 0 : experienceStore.success(EditorExperience.typing, {
134
- nodeSize: state.doc.nodeSize,
135
- ...nodesCount,
136
- participants: getParticipantsCount(state),
137
- objectId: (_getContextIdentifier4 = getContextIdentifier(state)) === null || _getContextIdentifier4 === void 0 ? void 0 : _getContextIdentifier4.objectId,
138
- time: diff,
139
- severity
140
- });
141
- }
88
+ (_inputLatencyTracker2 = inputLatencyTracker) === null || _inputLatencyTracker2 === void 0 ? void 0 : _inputLatencyTracker2.end();
142
89
  });
143
90
  return false;
144
91
  },
@@ -160,6 +107,116 @@ export default ((dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, u
160
107
  return {};
161
108
  }
162
109
 
110
+ const experienceStore = ufo ? ExperienceStore.getInstance(view) : undefined;
111
+
112
+ if (inputTracking !== null && inputTracking !== void 0 && inputTracking.enabled) {
113
+ inputLatencyTracker = new InputLatencyTracker({
114
+ samplingRate,
115
+ slowThreshold,
116
+ normalThreshold: severityThresholdNormal,
117
+ degradedThreshold: severityThresholdDegraded,
118
+ onSampleStart: () => {
119
+ experienceStore === null || experienceStore === void 0 ? void 0 : experienceStore.start(EditorExperience.typing);
120
+ },
121
+ onSampleEnd: (time, {
122
+ isSlow,
123
+ severity
124
+ }) => {
125
+ var _getContextIdentifier2;
126
+
127
+ const {
128
+ state
129
+ } = view;
130
+ const nodesCount = getNodeCount(state);
131
+
132
+ if (isSlow) {
133
+ experienceStore === null || experienceStore === void 0 ? void 0 : experienceStore.addMetadata(EditorExperience.typing, {
134
+ slowInput: true
135
+ });
136
+ }
137
+
138
+ experienceStore === null || experienceStore === void 0 ? void 0 : experienceStore.success(EditorExperience.typing, {
139
+ nodeSize: state.doc.nodeSize,
140
+ ...nodesCount,
141
+ participants: getParticipantsCount(state),
142
+ objectId: (_getContextIdentifier2 = getContextIdentifier(state)) === null || _getContextIdentifier2 === void 0 ? void 0 : _getContextIdentifier2.objectId,
143
+ time,
144
+ severity: shouldTrackSeverity ? severity : undefined
145
+ });
146
+ },
147
+ dispatchSample: (time, severity) => {
148
+ var _getContextIdentifier3;
149
+
150
+ const {
151
+ state
152
+ } = view;
153
+ const nodesCount = getNodeCount(state);
154
+ const samplePayload = {
155
+ action: ACTION.INPUT_PERF_SAMPLING,
156
+ actionSubject: ACTION_SUBJECT.EDITOR,
157
+ attributes: {
158
+ time,
159
+ nodeSize: state.doc.nodeSize,
160
+ ...nodesCount,
161
+ participants: getParticipantsCount(state),
162
+ objectId: (_getContextIdentifier3 = getContextIdentifier(state)) === null || _getContextIdentifier3 === void 0 ? void 0 : _getContextIdentifier3.objectId,
163
+ severity: shouldTrackSeverity ? severity : undefined
164
+ },
165
+ eventType: EVENT_TYPE.OPERATIONAL
166
+ };
167
+ dispatchAnalyticsEvent(samplePayload);
168
+ },
169
+ dispatchAverage: ({
170
+ mean,
171
+ median,
172
+ sampleSize
173
+ }, severity) => {
174
+ var _getContextIdentifier4;
175
+
176
+ const {
177
+ state
178
+ } = view;
179
+ const nodeCount = getNodeCount(state);
180
+ const averagePayload = {
181
+ action: ACTION.INPUT_PERF_SAMPLING_AVG,
182
+ actionSubject: ACTION_SUBJECT.EDITOR,
183
+ attributes: {
184
+ mean,
185
+ median,
186
+ sampleSize,
187
+ ...nodeCount,
188
+ nodeSize: state.doc.nodeSize,
189
+ severity: shouldTrackSeverity ? severity : undefined,
190
+ participants: getParticipantsCount(state),
191
+ objectId: (_getContextIdentifier4 = getContextIdentifier(state)) === null || _getContextIdentifier4 === void 0 ? void 0 : _getContextIdentifier4.objectId
192
+ },
193
+ eventType: EVENT_TYPE.OPERATIONAL
194
+ };
195
+ dispatchAnalyticsEvent(averagePayload);
196
+ },
197
+ onSlowInput: time => {
198
+ var _getContextIdentifier5;
199
+
200
+ const {
201
+ state
202
+ } = view;
203
+ const nodesCount = getNodeCount(state);
204
+ dispatchAnalyticsEvent({
205
+ action: ACTION.SLOW_INPUT,
206
+ actionSubject: ACTION_SUBJECT.EDITOR,
207
+ attributes: {
208
+ time,
209
+ nodeSize: state.doc.nodeSize,
210
+ ...nodesCount,
211
+ participants: getParticipantsCount(state),
212
+ objectId: (_getContextIdentifier5 = getContextIdentifier(state)) === null || _getContextIdentifier5 === void 0 ? void 0 : _getContextIdentifier5.objectId
213
+ },
214
+ eventType: EVENT_TYPE.OPERATIONAL
215
+ });
216
+ }
217
+ });
218
+ }
219
+
163
220
  let observer;
164
221
 
165
222
  try {
@@ -172,7 +229,7 @@ export default ((dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, u
172
229
  } = perfEntries[i];
173
230
 
174
231
  if (duration > freezeThreshold) {
175
- dispatchLongTaskEvent(dispatchAnalyticsEvent, view, duration, allowCountNodes, 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);
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);
176
233
  }
177
234
  }
178
235
  }); // register observer for long task notifications
@@ -184,9 +241,10 @@ export default ((dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, u
184
241
 
185
242
  return {
186
243
  destroy: () => {
187
- if (observer) {
188
- observer.disconnect();
189
- }
244
+ var _inputLatencyTracker3;
245
+
246
+ (_inputLatencyTracker3 = inputLatencyTracker) === null || _inputLatencyTracker3 === void 0 ? void 0 : _inputLatencyTracker3.flush();
247
+ observer === null || observer === void 0 ? void 0 : observer.disconnect();
190
248
  }
191
249
  };
192
250
  }
@@ -0,0 +1,128 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import { getTimeSince } from '../../../utils/performance/get-performance-timing';
3
+ import { getAnalyticsEventSeverity } from '@atlaskit/editor-common/utils';
4
+ export default class InputLatencyTracker {
5
+ constructor({
6
+ samplingRate,
7
+ slowThreshold,
8
+ normalThreshold,
9
+ degradedThreshold,
10
+ dispatchAverage,
11
+ dispatchSample,
12
+ onSampleStart,
13
+ onSampleEnd,
14
+ onSlowInput
15
+ }) {
16
+ _defineProperty(this, "samples", []);
17
+
18
+ _defineProperty(this, "total", 0);
19
+
20
+ this.currentStart = null;
21
+ this.samplingRate = samplingRate;
22
+ this.slowThreshold = slowThreshold;
23
+ this.normalThreshold = normalThreshold;
24
+ this.degradedThreshold = degradedThreshold;
25
+ this.dispatchAverage = dispatchAverage;
26
+ this.dispatchSample = dispatchSample;
27
+ this.onSampleStart = onSampleStart;
28
+ this.onSampleEnd = onSampleEnd;
29
+ this.onSlowInput = onSlowInput;
30
+ }
31
+
32
+ start() {
33
+ this.currentStart = performance.now();
34
+
35
+ if (this.samples.length + 1 === this.samplingRate) {
36
+ var _this$onSampleStart;
37
+
38
+ (_this$onSampleStart = this.onSampleStart) === null || _this$onSampleStart === void 0 ? void 0 : _this$onSampleStart.call(this);
39
+ }
40
+ }
41
+
42
+ end() {
43
+ if (this.currentStart === null) {
44
+ return;
45
+ }
46
+
47
+ let isSlow = false;
48
+ const time = getTimeSince(this.currentStart);
49
+ this.push(time);
50
+
51
+ if (time > this.slowThreshold) {
52
+ var _this$onSlowInput;
53
+
54
+ (_this$onSlowInput = this.onSlowInput) === null || _this$onSlowInput === void 0 ? void 0 : _this$onSlowInput.call(this, time);
55
+ isSlow = true;
56
+ }
57
+
58
+ if (this.samples.length === this.samplingRate) {
59
+ var _this$onSampleEnd;
60
+
61
+ this.flush();
62
+ (_this$onSampleEnd = this.onSampleEnd) === null || _this$onSampleEnd === void 0 ? void 0 : _this$onSampleEnd.call(this, time, {
63
+ isSlow,
64
+ severity: this.severity(time)
65
+ });
66
+ }
67
+ }
68
+
69
+ flush() {
70
+ if (this.samples.length === 0) {
71
+ return;
72
+ }
73
+
74
+ this.dispatch();
75
+ this.samples = [];
76
+ this.total = 0;
77
+ }
78
+
79
+ dispatch() {
80
+ var _this$dispatchSample, _this$dispatchAverage;
81
+
82
+ (_this$dispatchSample = this.dispatchSample) === null || _this$dispatchSample === void 0 ? void 0 : _this$dispatchSample.call(this, this.getLast(), this.severity(this.getLast())); // cache
83
+
84
+ const median = this.getMedian();
85
+ (_this$dispatchAverage = this.dispatchAverage) === null || _this$dispatchAverage === void 0 ? void 0 : _this$dispatchAverage.call(this, {
86
+ mean: this.getMean(),
87
+ median,
88
+ sampleSize: this.samples.length
89
+ }, this.severity(median));
90
+ }
91
+
92
+ push(latency) {
93
+ this.samples.push(latency);
94
+ this.total += latency;
95
+ }
96
+
97
+ severity(time) {
98
+ return getAnalyticsEventSeverity(time, this.normalThreshold, this.degradedThreshold);
99
+ }
100
+
101
+ getLast() {
102
+ return this.samples[this.samples.length - 1];
103
+ }
104
+
105
+ getMean() {
106
+ return this.total / this.samples.length;
107
+ }
108
+
109
+ getMedian() {
110
+ if (this.samples.length === 1) {
111
+ return this.samples[0];
112
+ }
113
+
114
+ this.samples.sort((a, b) => a - b);
115
+ const middle = (this.samples.length + 1) / 2;
116
+ const floorMiddle = Math.floor(middle);
117
+ const remainder = middle % floorMiddle;
118
+
119
+ if (remainder === 0) {
120
+ return this.samples[middle - 1];
121
+ }
122
+
123
+ const left = this.samples[floorMiddle - 1];
124
+ const right = this.samples[floorMiddle];
125
+ return (left + right) / 2;
126
+ }
127
+
128
+ }
@@ -3,6 +3,7 @@ import { SelectionStyle, getSelectionStyles, akEditorDeleteBorder, akEditorDelet
3
3
  import { N20 } from '@atlaskit/theme/colors';
4
4
  import { SmartCardSharedCssClassName } from '@atlaskit/editor-common/styles';
5
5
  import { akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles';
6
+ import { token } from '@atlaskit/tokens';
6
7
  export const smartCardStyles = css`
7
8
  .${SmartCardSharedCssClassName.INLINE_CARD_CONTAINER} {
8
9
  max-width: calc(100% - 20px);
@@ -32,7 +33,8 @@ export const smartCardStyles = css`
32
33
 
33
34
  &.danger {
34
35
  .${SmartCardSharedCssClassName.LOADER_WRAPPER} > a {
35
- box-shadow: 0 0 0 1px ${akEditorDeleteBorder};
36
+ box-shadow: 0 0 0 1px
37
+ ${token('color.border.danger', akEditorDeleteBorder)};
36
38
  /* EDM-1717: box-shadow Safari fix start */
37
39
  z-index: 2;
38
40
  /* EDM-1717: box-shadow Safari fix end */
@@ -56,7 +58,8 @@ export const smartCardStyles = css`
56
58
 
57
59
  &.danger {
58
60
  .${SmartCardSharedCssClassName.LOADER_WRAPPER} > div {
59
- box-shadow: 0 0 0 1px ${akEditorDeleteBorder} !important;
61
+ box-shadow: 0 0 0 1px
62
+ ${token('color.border.danger', akEditorDeleteBorder)} !important;
60
63
  }
61
64
  }
62
65
  }
@@ -82,12 +85,13 @@ export const smartCardStyles = css`
82
85
 
83
86
  &.danger {
84
87
  .media-card-frame::after {
85
- box-shadow: 0 0 0 1px ${akEditorDeleteBorder} !important;
86
- background: ${akEditorDeleteBackground} !important;
88
+ box-shadow: 0 0 0 1px
89
+ ${token('color.border.danger', akEditorDeleteBorder)} !important;
90
+ background: ${token('color.background.danger', akEditorDeleteBackground)} !important;
87
91
  }
88
92
  .richMedia-resize-handle-right::after,
89
93
  .richMedia-resize-handle-left::after {
90
- background: ${akEditorDeleteBorder};
94
+ background: ${token('color.border.danger', akEditorDeleteBorder)};
91
95
  }
92
96
  }
93
97
  }
@@ -2,6 +2,7 @@ import { css } from '@emotion/react';
2
2
  import { themed } from '@atlaskit/theme/components';
3
3
  import { borderRadius, fontSize, gridSize } from '@atlaskit/theme/constants';
4
4
  import * as colors from '@atlaskit/theme/colors';
5
+ import { token } from '@atlaskit/tokens';
5
6
  import { blockNodesVerticalMargin, akEditorTableCellMinWidth, akEditorDeleteBackground, akEditorDeleteBorder, akEditorSelectedBorderSize, akEditorDeleteIconColor, SelectionStyle, getSelectionStyles, akEditorCodeFontFamily, akEditorSelectedNodeClassName, overflowShadow, relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
6
7
  import { codeBlockClassNames } from './ui/class-names';
7
8
  export const highlightingCodeBlockStyles = props => css`
@@ -132,15 +133,16 @@ export const highlightingCodeBlockStyles = props => css`
132
133
 
133
134
  /* Danger when top level node */
134
135
  .ProseMirror .danger.code-block {
135
- box-shadow: 0 0 0 ${akEditorSelectedBorderSize}px ${akEditorDeleteBorder};
136
+ box-shadow: 0 0 0 ${akEditorSelectedBorderSize}px
137
+ ${token('color.border.danger', akEditorDeleteBorder)};
136
138
 
137
139
  .${codeBlockClassNames.gutter} {
138
140
  background-color: ${colors.R75};
139
- color: ${akEditorDeleteIconColor};
141
+ color: ${token('color.text.danger', akEditorDeleteIconColor)};
140
142
  }
141
143
 
142
144
  .${codeBlockClassNames.content} {
143
- background-color: ${akEditorDeleteBackground};
145
+ background-color: ${token('color.background.danger', akEditorDeleteBackground)};
144
146
  }
145
147
  }
146
148
 
@@ -148,7 +150,7 @@ export const highlightingCodeBlockStyles = props => css`
148
150
  .ProseMirror .danger .code-block {
149
151
  .${codeBlockClassNames.gutter} {
150
152
  background-color: rgba(255, 143, 115, 0.5);
151
- color: ${akEditorDeleteIconColor};
153
+ color: ${token('color.text.danger', akEditorDeleteIconColor)};
152
154
  }
153
155
 
154
156
  .${codeBlockClassNames.content} {
@@ -247,15 +249,16 @@ export const codeBlockStyles = props => css`
247
249
 
248
250
  /* Danger when top level node */
249
251
  .ProseMirror .danger.code-block {
250
- box-shadow: 0 0 0 ${akEditorSelectedBorderSize}px ${akEditorDeleteBorder};
252
+ box-shadow: 0 0 0 ${akEditorSelectedBorderSize}px
253
+ ${token('color.border.danger', akEditorDeleteBorder)};
251
254
 
252
255
  .${codeBlockClassNames.gutter} {
253
256
  background-color: ${colors.R75};
254
- color: ${akEditorDeleteIconColor};
257
+ color: ${token('color.text.danger', akEditorDeleteIconColor)};
255
258
  }
256
259
 
257
260
  .${codeBlockClassNames.content} {
258
- background-color: ${akEditorDeleteBackground};
261
+ background-color: ${token('color.background.danger', akEditorDeleteBackground)};
259
262
  }
260
263
  }
261
264
 
@@ -263,7 +266,7 @@ export const codeBlockStyles = props => css`
263
266
  .ProseMirror .danger .code-block {
264
267
  .${codeBlockClassNames.gutter} {
265
268
  background-color: rgba(255, 143, 115, 0.5);
266
- color: ${akEditorDeleteIconColor};
269
+ color: ${token('color.text.danger', akEditorDeleteIconColor)};
267
270
  }
268
271
 
269
272
  .${codeBlockClassNames.content} {
@@ -12,14 +12,19 @@ export const TELEPOINTER_DIM_CLASS = 'telepointer-dim';
12
12
  * Returns position where it's possible to place a decoration.
13
13
  */
14
14
 
15
- const getValidPos = (tr, pos) => {
16
- const resolvedPos = tr.doc.resolve(pos);
17
- const backwardSelection = Selection.findFrom(resolvedPos, -1, true); // if there's no correct cursor position before the `pos`, we try to find it after the `pos`
15
+ export const getValidPos = (tr, pos) => {
16
+ const endOfDocPos = tr.doc.nodeSize - 2;
18
17
 
19
- const forwardSelection = Selection.findFrom(resolvedPos, 1, true);
20
- return backwardSelection ? backwardSelection.from : forwardSelection ? forwardSelection.from : pos;
21
- };
18
+ if (pos <= endOfDocPos) {
19
+ const resolvedPos = tr.doc.resolve(pos);
20
+ const backwardSelection = Selection.findFrom(resolvedPos, -1, true); // if there's no correct cursor position before the `pos`, we try to find it after the `pos`
21
+
22
+ const forwardSelection = Selection.findFrom(resolvedPos, 1, true);
23
+ return backwardSelection ? backwardSelection.from : forwardSelection ? forwardSelection.from : pos;
24
+ }
22
25
 
26
+ return endOfDocPos;
27
+ };
23
28
  export class PluginState {
24
29
  // eslint-disable-next-line no-console
25
30
  get decorations() {
@@ -100,12 +105,22 @@ export class PluginState {
100
105
  remove = remove.concat(oldPointers);
101
106
  }
102
107
 
108
+ const endOfDocPos = tr.doc.nodeSize - 2;
103
109
  const {
104
110
  anchor,
105
111
  head
106
112
  } = telepointerData.selection;
107
- const rawFrom = anchor < head ? anchor : head;
108
- const rawTo = anchor >= head ? anchor : head;
113
+ let rawFrom = anchor < head ? anchor : head;
114
+ let rawTo = anchor >= head ? anchor : head;
115
+
116
+ if (rawFrom > endOfDocPos) {
117
+ rawFrom = endOfDocPos;
118
+ }
119
+
120
+ if (rawTo > endOfDocPos) {
121
+ rawTo = endOfDocPos;
122
+ }
123
+
109
124
  const isSelection = rawTo - rawFrom > 0;
110
125
  let from = 1;
111
126
  let to = 1;
@@ -1,5 +1,6 @@
1
1
  import { css } from '@emotion/react';
2
2
  import { DateSharedCssClassName } from '@atlaskit/editor-common/styles';
3
+ import { token } from '@atlaskit/tokens';
3
4
  import { SelectionStyle, getSelectionStyles, akEditorSelectedBorderSize, akEditorDeleteBorder, akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles';
4
5
  export const dateStyles = css`
5
6
  .${DateSharedCssClassName.DATE_CONTAINER} {
@@ -19,7 +20,8 @@ export const dateStyles = css`
19
20
  .${DateSharedCssClassName.DATE_CONTAINER}.${akEditorSelectedNodeClassName}
20
21
  .${DateSharedCssClassName.DATE_WRAPPER}
21
22
  > span {
22
- box-shadow: 0 0 0 ${akEditorSelectedBorderSize}px ${akEditorDeleteBorder};
23
+ box-shadow: 0 0 0 ${akEditorSelectedBorderSize}px
24
+ ${token('color.border.danger', akEditorDeleteBorder)};
23
25
  }
24
26
  }
25
27
  `;