@atlaskit/editor-core 165.0.0 → 166.0.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 (244) 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/plugins/analytics/types/enums.js +1 -0
  10. package/dist/cjs/plugins/annotation/pm-plugins/inline-comment.js +2 -2
  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/index.js +2 -2
  16. package/dist/cjs/plugins/collab-edit/plugin-state.js +23 -5
  17. package/dist/cjs/plugins/collab-edit/provider/channel.js +2 -2
  18. package/dist/cjs/plugins/date/styles.js +3 -1
  19. package/dist/cjs/plugins/emoji/index.js +30 -34
  20. package/dist/cjs/plugins/emoji/nodeviews/emoji.js +12 -66
  21. package/dist/cjs/plugins/emoji/styles.js +3 -17
  22. package/dist/cjs/plugins/expand/ui/styles.js +2 -2
  23. package/dist/cjs/plugins/extension/context-panel.js +2 -2
  24. package/dist/cjs/plugins/extension/pm-plugins/main.js +2 -2
  25. package/dist/cjs/plugins/extension/ui/styles.js +3 -1
  26. package/dist/cjs/plugins/feature-flags-context/feature-flags-from-props.js +20 -22
  27. package/dist/cjs/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +2 -2
  28. package/dist/cjs/plugins/hyperlink/pm-plugins/input-rule.js +1 -9
  29. package/dist/cjs/plugins/hyperlink/pm-plugins/keymap.js +1 -9
  30. package/dist/cjs/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +2 -2
  31. package/dist/cjs/plugins/layout/styles.js +3 -1
  32. package/dist/cjs/plugins/list/commands/indent-list.js +5 -1
  33. package/dist/cjs/plugins/list/commands/outdent-list.js +5 -1
  34. package/dist/cjs/plugins/list/transforms.js +11 -3
  35. package/dist/cjs/plugins/macro/actions.js +2 -2
  36. package/dist/cjs/plugins/media/nodeviews/mediaInline.js +2 -2
  37. package/dist/cjs/plugins/media/nodeviews/mediaSingle.js +2 -2
  38. package/dist/cjs/plugins/media/styles.js +3 -1
  39. package/dist/cjs/plugins/media/ui/ResizableMediaSingle/index.js +2 -2
  40. package/dist/cjs/plugins/mentions/index.js +10 -14
  41. package/dist/cjs/plugins/mentions/nodeviews/mention.js +15 -67
  42. package/dist/cjs/plugins/mentions/pm-plugins/main.js +19 -10
  43. package/dist/cjs/plugins/mentions/type-ahead/index.js +7 -2
  44. package/dist/cjs/plugins/panel/styles.js +3 -1
  45. package/dist/cjs/plugins/placeholder-text/placeholder-text-nodeview.js +3 -1
  46. package/dist/cjs/plugins/rule/styles.js +3 -1
  47. package/dist/cjs/plugins/selection/utils.js +39 -23
  48. package/dist/cjs/plugins/table/event-handlers.js +3 -3
  49. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +24 -0
  50. package/dist/cjs/plugins/table/ui/common-styles.js +1 -1
  51. package/dist/cjs/plugins/table/ui/consts.js +6 -4
  52. package/dist/cjs/plugins/tasks-and-decisions/styles.js +3 -1
  53. package/dist/cjs/plugins/text-formatting/utils.js +1 -1
  54. package/dist/cjs/plugins/type-ahead/index.js +6 -2
  55. package/dist/cjs/plugins/unsupported-content/index.js +22 -10
  56. package/dist/cjs/plugins/unsupported-content/styles.js +4 -2
  57. package/dist/cjs/plugins/unsupported-content/unsupported-inline-node-view.js +21 -0
  58. package/dist/cjs/ui/Appearance/Chromeless.js +6 -3
  59. package/dist/cjs/ui/Appearance/Comment/Comment.js +6 -4
  60. package/dist/cjs/ui/ChromeCollapsed/styles.js +3 -1
  61. package/dist/cjs/ui/ConfigPanel/ConfigPanel.js +2 -2
  62. package/dist/cjs/ui/ConfigPanel/Fields/CustomSelect.js +2 -2
  63. package/dist/cjs/ui/ConfigPanel/Fields/UserSelect.js +2 -2
  64. package/dist/cjs/ui/ConfigPanel/transformers.js +2 -2
  65. package/dist/cjs/ui/ContentStyles/index.js +2 -2
  66. package/dist/cjs/version-wrapper.js +1 -1
  67. package/dist/cjs/version.json +1 -1
  68. package/dist/es2019/actions/index.js +12 -1
  69. package/dist/es2019/create-editor/ReactEditorView.js +14 -6
  70. package/dist/es2019/create-editor/create-plugins-list.js +1 -2
  71. package/dist/es2019/editor.js +14 -0
  72. package/dist/es2019/event-dispatcher/index.js +8 -0
  73. package/dist/es2019/nodeviews/ReactNodeView.js +1 -10
  74. package/dist/es2019/nodeviews/getInlineNodeViewProducer.styles.js +9 -0
  75. package/dist/es2019/plugins/analytics/types/enums.js +1 -0
  76. package/dist/es2019/plugins/base/pm-plugins/frozen-editor.js +138 -80
  77. package/dist/es2019/plugins/base/utils/input-latency-tracking.js +128 -0
  78. package/dist/es2019/plugins/card/styles.js +9 -5
  79. package/dist/es2019/plugins/code-block/styles.js +11 -8
  80. package/dist/es2019/plugins/collab-edit/plugin-state.js +23 -8
  81. package/dist/es2019/plugins/date/styles.js +3 -1
  82. package/dist/es2019/plugins/emoji/index.js +16 -21
  83. package/dist/es2019/plugins/emoji/nodeviews/emoji.js +12 -31
  84. package/dist/es2019/plugins/emoji/styles.js +1 -82
  85. package/dist/es2019/plugins/expand/ui/styles.js +2 -2
  86. package/dist/es2019/plugins/extension/ui/styles.js +4 -2
  87. package/dist/es2019/plugins/feature-flags-context/feature-flags-from-props.js +20 -22
  88. package/dist/es2019/plugins/hyperlink/pm-plugins/input-rule.js +1 -8
  89. package/dist/es2019/plugins/hyperlink/pm-plugins/keymap.js +1 -8
  90. package/dist/es2019/plugins/layout/styles.js +3 -2
  91. package/dist/es2019/plugins/list/commands/indent-list.js +4 -1
  92. package/dist/es2019/plugins/list/commands/outdent-list.js +4 -1
  93. package/dist/es2019/plugins/list/transforms.js +9 -4
  94. package/dist/es2019/plugins/media/styles.js +9 -7
  95. package/dist/es2019/plugins/mentions/index.js +1 -6
  96. package/dist/es2019/plugins/mentions/nodeviews/mention.js +16 -35
  97. package/dist/es2019/plugins/mentions/pm-plugins/main.js +18 -10
  98. package/dist/es2019/plugins/mentions/type-ahead/index.js +7 -2
  99. package/dist/es2019/plugins/panel/styles.js +5 -4
  100. package/dist/es2019/plugins/placeholder-text/placeholder-text-nodeview.js +3 -1
  101. package/dist/es2019/plugins/rule/styles.js +2 -1
  102. package/dist/es2019/plugins/selection/utils.js +35 -20
  103. package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +22 -0
  104. package/dist/es2019/plugins/table/ui/common-styles.js +4 -0
  105. package/dist/es2019/plugins/table/ui/consts.js +5 -4
  106. package/dist/es2019/plugins/tasks-and-decisions/styles.js +4 -2
  107. package/dist/es2019/plugins/text-formatting/utils.js +1 -1
  108. package/dist/es2019/plugins/type-ahead/index.js +5 -1
  109. package/dist/es2019/plugins/unsupported-content/index.js +23 -12
  110. package/dist/es2019/plugins/unsupported-content/styles.js +5 -3
  111. package/dist/es2019/plugins/unsupported-content/unsupported-inline-node-view.js +7 -0
  112. package/dist/es2019/ui/Appearance/Chromeless.js +5 -2
  113. package/dist/es2019/ui/Appearance/Comment/Comment.js +5 -2
  114. package/dist/es2019/ui/ChromeCollapsed/styles.js +2 -1
  115. package/dist/es2019/ui/ContentStyles/index.js +3 -3
  116. package/dist/es2019/version-wrapper.js +1 -1
  117. package/dist/es2019/version.json +1 -1
  118. package/dist/esm/actions/index.js +9 -1
  119. package/dist/esm/create-editor/ErrorBoundary.js +1 -1
  120. package/dist/esm/create-editor/ReactEditorView.js +14 -6
  121. package/dist/esm/create-editor/create-plugins-list.js +1 -2
  122. package/dist/esm/editor.js +16 -1
  123. package/dist/esm/event-dispatcher/index.js +9 -0
  124. package/dist/esm/nodeviews/ReactNodeView.js +1 -10
  125. package/dist/esm/nodeviews/getInlineNodeViewProducer.styles.js +1 -1
  126. package/dist/esm/plugins/analytics/types/enums.js +1 -0
  127. package/dist/esm/plugins/annotation/pm-plugins/inline-comment.js +1 -1
  128. package/dist/esm/plugins/base/pm-plugins/frozen-editor.js +128 -79
  129. package/dist/esm/plugins/base/utils/input-latency-tracking.js +149 -0
  130. package/dist/esm/plugins/card/styles.js +2 -1
  131. package/dist/esm/plugins/code-block/styles.js +5 -4
  132. package/dist/esm/plugins/collab-edit/index.js +1 -1
  133. package/dist/esm/plugins/collab-edit/plugin-state.js +21 -6
  134. package/dist/esm/plugins/collab-edit/provider/channel.js +1 -1
  135. package/dist/esm/plugins/custom-autoformat/doc.js +1 -1
  136. package/dist/esm/plugins/custom-autoformat/index.js +1 -1
  137. package/dist/esm/plugins/date/styles.js +2 -1
  138. package/dist/esm/plugins/emoji/index.js +26 -29
  139. package/dist/esm/plugins/emoji/nodeviews/emoji.js +11 -56
  140. package/dist/esm/plugins/emoji/styles.js +3 -14
  141. package/dist/esm/plugins/expand/ui/styles.js +2 -2
  142. package/dist/esm/plugins/extension/actions.js +1 -1
  143. package/dist/esm/plugins/extension/context-panel.js +1 -1
  144. package/dist/esm/plugins/extension/pm-plugins/main.js +1 -1
  145. package/dist/esm/plugins/extension/ui/Extension/ExtensionComponent.js +1 -1
  146. package/dist/esm/plugins/extension/ui/styles.js +2 -1
  147. package/dist/esm/plugins/feature-flags-context/feature-flags-from-props.js +20 -22
  148. package/dist/esm/plugins/feedback-dialog/index.js +1 -1
  149. package/dist/esm/plugins/feedback-dialog/loadJiraCollectorDialogScript.js +1 -1
  150. package/dist/esm/plugins/find-replace/utils/batch-decorations.js +1 -1
  151. package/dist/esm/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +1 -1
  152. package/dist/esm/plugins/hyperlink/HyperlinkToolbarAppearance.js +1 -1
  153. package/dist/esm/plugins/hyperlink/pm-plugins/input-rule.js +1 -8
  154. package/dist/esm/plugins/hyperlink/pm-plugins/keymap.js +1 -8
  155. package/dist/esm/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +2 -1
  156. package/dist/esm/plugins/image-upload/pm-plugins/main.js +1 -1
  157. package/dist/esm/plugins/layout/styles.js +2 -1
  158. package/dist/esm/plugins/list/commands/indent-list.js +4 -1
  159. package/dist/esm/plugins/list/commands/outdent-list.js +4 -1
  160. package/dist/esm/plugins/list/transforms.js +9 -4
  161. package/dist/esm/plugins/macro/actions.js +1 -1
  162. package/dist/esm/plugins/media/nodeviews/mediaGroup.js +1 -1
  163. package/dist/esm/plugins/media/nodeviews/mediaInline.js +2 -1
  164. package/dist/esm/plugins/media/nodeviews/mediaNodeUpdater.js +1 -1
  165. package/dist/esm/plugins/media/nodeviews/mediaNodeView/media.js +1 -1
  166. package/dist/esm/plugins/media/nodeviews/mediaSingle.js +1 -1
  167. package/dist/esm/plugins/media/picker-facade.js +1 -1
  168. package/dist/esm/plugins/media/pm-plugins/main.js +1 -1
  169. package/dist/esm/plugins/media/styles.js +2 -1
  170. package/dist/esm/plugins/media/toolbar/utils.js +1 -1
  171. package/dist/esm/plugins/media/ui/MediaPicker/PickerFacadeProvider.js +1 -1
  172. package/dist/esm/plugins/media/ui/ResizableMediaSingle/index.js +1 -1
  173. package/dist/esm/plugins/media/utils/check-media-type.js +1 -1
  174. package/dist/esm/plugins/mentions/index.js +10 -14
  175. package/dist/esm/plugins/mentions/nodeviews/mention.js +13 -58
  176. package/dist/esm/plugins/mentions/pm-plugins/main.js +18 -10
  177. package/dist/esm/plugins/mentions/type-ahead/index.js +7 -2
  178. package/dist/esm/plugins/panel/styles.js +2 -1
  179. package/dist/esm/plugins/paste/handlers.js +1 -1
  180. package/dist/esm/plugins/paste/pm-plugins/main.js +1 -1
  181. package/dist/esm/plugins/placeholder-text/placeholder-text-nodeview.js +3 -1
  182. package/dist/esm/plugins/quick-insert/index.js +1 -1
  183. package/dist/esm/plugins/rule/styles.js +2 -1
  184. package/dist/esm/plugins/selection/utils.js +35 -20
  185. package/dist/esm/plugins/table/event-handlers.js +3 -3
  186. package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +23 -0
  187. package/dist/esm/plugins/table/ui/common-styles.js +1 -1
  188. package/dist/esm/plugins/table/ui/consts.js +5 -4
  189. package/dist/esm/plugins/tasks-and-decisions/styles.js +2 -1
  190. package/dist/esm/plugins/tasks-and-decisions/ui/Task/task-item-with-providers.js +1 -1
  191. package/dist/esm/plugins/text-formatting/utils.js +1 -1
  192. package/dist/esm/plugins/type-ahead/index.js +6 -2
  193. package/dist/esm/plugins/unsupported-content/index.js +21 -11
  194. package/dist/esm/plugins/unsupported-content/styles.js +3 -2
  195. package/dist/esm/plugins/unsupported-content/unsupported-inline-node-view.js +7 -0
  196. package/dist/esm/ui/Appearance/Chromeless.js +6 -3
  197. package/dist/esm/ui/Appearance/Comment/Comment.js +6 -4
  198. package/dist/esm/ui/ChromeCollapsed/styles.js +2 -1
  199. package/dist/esm/ui/ConfigPanel/ConfigPanel.js +1 -1
  200. package/dist/esm/ui/ConfigPanel/Fields/CustomSelect.js +1 -1
  201. package/dist/esm/ui/ConfigPanel/Fields/UserSelect.js +1 -1
  202. package/dist/esm/ui/ConfigPanel/FormErrorBoundary.js +1 -1
  203. package/dist/esm/ui/ConfigPanel/transformers.js +1 -1
  204. package/dist/esm/ui/ContentStyles/index.js +3 -3
  205. package/dist/esm/ui/LinkSearch/index.js +1 -1
  206. package/dist/esm/ui/ToolbarFeedback/index.js +1 -1
  207. package/dist/esm/utils/action.js +1 -1
  208. package/dist/esm/utils/clipboard.js +1 -1
  209. package/dist/esm/utils/extensions.js +1 -1
  210. package/dist/esm/version-wrapper.js +1 -1
  211. package/dist/esm/version.json +1 -1
  212. package/dist/types/actions/index.d.ts +3 -1
  213. package/dist/types/editor.d.ts +3 -0
  214. package/dist/types/event-dispatcher/index.d.ts +1 -0
  215. package/dist/types/nodeviews/ReactNodeView.d.ts +1 -5
  216. package/dist/types/plugins/analytics/types/enums.d.ts +1 -0
  217. package/dist/types/plugins/analytics/types/events.d.ts +2 -2
  218. package/dist/types/plugins/analytics/types/general-events.d.ts +10 -1
  219. package/dist/types/plugins/base/utils/input-latency-tracking.d.ts +44 -0
  220. package/dist/types/plugins/collab-edit/plugin-state.d.ts +4 -0
  221. package/dist/types/plugins/emoji/index.d.ts +2 -6
  222. package/dist/types/plugins/emoji/nodeviews/emoji.d.ts +4 -14
  223. package/dist/types/plugins/emoji/styles.d.ts +0 -1
  224. package/dist/types/plugins/emoji/types.d.ts +0 -1
  225. package/dist/types/plugins/list/transforms.d.ts +10 -1
  226. package/dist/types/plugins/mentions/nodeviews/mention.d.ts +6 -14
  227. package/dist/types/plugins/mentions/pm-plugins/main.d.ts +2 -5
  228. package/dist/types/plugins/selection/utils.d.ts +7 -15
  229. package/dist/types/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.d.ts +3 -0
  230. package/dist/types/plugins/table/ui/consts.d.ts +2 -2
  231. package/dist/types/plugins/type-ahead/types.d.ts +1 -0
  232. package/dist/types/plugins/unsupported-content/unsupported-inline-node-view.d.ts +11 -0
  233. package/dist/types/types/editor-appearance-component.d.ts +1 -0
  234. package/dist/types/types/editor-props.d.ts +1 -0
  235. package/dist/types/types/feature-flags.d.ts +0 -14
  236. package/dist/types/ui/Appearance/Chromeless.d.ts +1 -0
  237. package/dist/types/ui/Appearance/Comment/Comment.d.ts +1 -0
  238. package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +4 -4
  239. package/dist/types/ui/ContentStyles/index.d.ts +2 -2
  240. package/package.json +23 -23
  241. package/dist/cjs/plugins/emoji/nodeviews/emoji-next.js +0 -250
  242. package/dist/es2019/plugins/emoji/nodeviews/emoji-next.js +0 -177
  243. package/dist/esm/plugins/emoji/nodeviews/emoji-next.js +0 -234
  244. package/dist/types/plugins/emoji/nodeviews/emoji-next.d.ts +0 -31
@@ -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
  `;
@@ -5,14 +5,13 @@ import { emoji } from '@atlaskit/adf-schema';
5
5
  import { Fragment } from 'prosemirror-model';
6
6
  import { TypeAheadAvailableNodes } from '@atlaskit/editor-common/type-ahead';
7
7
  import { EmojiTypeAheadItem, SearchSort, recordSelectionSucceededSli, recordSelectionFailedSli } from '@atlaskit/emoji';
8
+ import { getInlineNodeViewProducer } from '../../nodeviews/getInlineNodeViewProducer';
8
9
  import { inputRulePlugin as asciiInputRulePlugin } from './pm-plugins/ascii-input-rules';
9
10
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, addAnalytics, EVENT_TYPE, INPUT_METHOD } from '../analytics';
10
11
  import { IconEmoji } from '../quick-insert/assets';
11
- import emojiNodeView from './nodeviews/emoji';
12
- import emojiNodeViewNext from './nodeviews/emoji-next';
12
+ import { EmojiNodeView } from './nodeviews/emoji';
13
13
  import { EmojiContextProvider } from './ui/EmojiContextProvider';
14
14
  import { messages } from '../insert-block/ui/ToolbarInsertBlock/messages';
15
- import { getFeatureFlags } from '../feature-flags-context';
16
15
  import { openTypeAheadAtCursor } from '../type-ahead/transforms/open-typeahead-at-cursor';
17
16
  export const emojiToTypeaheadItem = (emoji, emojiProvider) => ({
18
17
  title: emoji.shortName || '',
@@ -181,12 +180,7 @@ const emojiPlugin = options => {
181
180
  pmPlugins() {
182
181
  return [{
183
182
  name: 'emoji',
184
- plugin: ({
185
- providerFactory,
186
- dispatch,
187
- portalProviderAPI,
188
- eventDispatcher
189
- }) => emojiPluginFactory(dispatch, providerFactory, portalProviderAPI, eventDispatcher, options)
183
+ plugin: pmPluginFactoryParams => createEmojiPlugin(pmPluginFactoryParams)
190
184
  }, {
191
185
  name: 'emojiAsciiInputRule',
192
186
  plugin: ({
@@ -271,7 +265,7 @@ export const emojiPluginKey = new PluginKey('emojiPlugin');
271
265
  export function getEmojiPluginState(state) {
272
266
  return emojiPluginKey.getState(state) || {};
273
267
  }
274
- export function emojiPluginFactory(dispatch, providerFactory, portalProviderAPI, eventDispatcher, options) {
268
+ export function createEmojiPlugin(pmPluginFactoryParams) {
275
269
  return new SafePlugin({
276
270
  key: emojiPluginKey,
277
271
  state: {
@@ -294,14 +288,14 @@ export function emojiPluginFactory(dispatch, providerFactory, portalProviderAPI,
294
288
  newPluginState = { ...pluginState,
295
289
  emojiProvider: params.provider
296
290
  };
297
- dispatch(emojiPluginKey, newPluginState);
291
+ pmPluginFactoryParams.dispatch(emojiPluginKey, newPluginState);
298
292
  return newPluginState;
299
293
 
300
294
  case ACTIONS.SET_ASCII_MAP:
301
295
  newPluginState = { ...pluginState,
302
296
  asciiMap: params.asciiMap
303
297
  };
304
- dispatch(emojiPluginKey, newPluginState);
298
+ pmPluginFactoryParams.dispatch(emojiPluginKey, newPluginState);
305
299
  return newPluginState;
306
300
  }
307
301
 
@@ -311,12 +305,13 @@ export function emojiPluginFactory(dispatch, providerFactory, portalProviderAPI,
311
305
  },
312
306
  props: {
313
307
  nodeViews: {
314
- emoji(node, view, getPos) {
315
- const featureFlags = getFeatureFlags(view.state);
316
- const createEmojiNodeView = featureFlags !== null && featureFlags !== void 0 && featureFlags.nextEmojiNodeView ? emojiNodeViewNext(providerFactory, options) : emojiNodeView(portalProviderAPI, eventDispatcher, providerFactory, options);
317
- return createEmojiNodeView(node, view, getPos);
318
- }
319
-
308
+ emoji: getInlineNodeViewProducer({
309
+ pmPluginFactoryParams,
310
+ Component: EmojiNodeView,
311
+ extraComponentProps: {
312
+ providerFactory: pmPluginFactoryParams.providerFactory
313
+ }
314
+ })
320
315
  }
321
316
  },
322
317
 
@@ -340,11 +335,11 @@ export function emojiPluginFactory(dispatch, providerFactory, portalProviderAPI,
340
335
  return;
341
336
  };
342
337
 
343
- providerFactory.subscribe('emojiProvider', providerHandler);
338
+ pmPluginFactoryParams.providerFactory.subscribe('emojiProvider', providerHandler);
344
339
  return {
345
340
  destroy() {
346
- if (providerFactory) {
347
- providerFactory.unsubscribe('emojiProvider', providerHandler);
341
+ if (pmPluginFactoryParams.providerFactory) {
342
+ pmPluginFactoryParams.providerFactory.unsubscribe('emojiProvider', providerHandler);
348
343
  }
349
344
  }
350
345
 
@@ -1,34 +1,15 @@
1
1
  import React from 'react';
2
- import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/utils';
3
2
  import Emoji from '../ui/Emoji';
4
- import { ReactNodeView } from '../../../nodeviews';
5
- export class EmojiNodeView extends ReactNodeView {
6
- createDomRef() {
7
- return super.createDomRef();
8
- }
9
-
10
- render(props) {
11
- const {
12
- providerFactory,
13
- options
14
- } = props;
15
- const {
16
- shortName,
17
- id,
18
- text
19
- } = this.node.attrs;
20
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Emoji, {
21
- providers: providerFactory,
22
- id: id,
23
- shortName: shortName,
24
- fallback: text
25
- }), options && options.allowZeroWidthSpaceAfter && ZERO_WIDTH_SPACE);
26
- }
27
-
28
- }
29
- export default function emojiNodeView(portalProviderAPI, eventDispatcher, providerFactory, options) {
30
- return (node, view, getPos) => new EmojiNodeView(node, view, getPos, portalProviderAPI, eventDispatcher, {
31
- providerFactory,
32
- options
33
- }).init();
3
+ export function EmojiNodeView(props) {
4
+ const {
5
+ shortName,
6
+ id,
7
+ text
8
+ } = props.node.attrs;
9
+ return /*#__PURE__*/React.createElement(Emoji, {
10
+ providers: props.providerFactory,
11
+ id: id,
12
+ shortName: shortName,
13
+ fallback: text
14
+ });
34
15
  }
@@ -1,8 +1,6 @@
1
1
  import { css } from '@emotion/react';
2
- import { N0, N20, N900 } from '@atlaskit/theme/colors';
3
- import { borderRadius, fontSizeSmall, gridSize } from '@atlaskit/theme/constants';
4
2
  import { EmojiSharedCssClassName } from '@atlaskit/editor-common/emoji';
5
- import { SelectionStyle, getSelectionStyles, akEditorSelectedNodeClassName, relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
3
+ import { SelectionStyle, getSelectionStyles, akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles';
6
4
  export const emojiStyles = css`
7
5
  .${EmojiSharedCssClassName.EMOJI_CONTAINER} {
8
6
  display: inline-block;
@@ -24,83 +22,4 @@ export const emojiStyles = css`
24
22
  }
25
23
  }
26
24
  }
27
- `;
28
- const grid = gridSize() / 2;
29
- const fontSize = fontSizeSmall();
30
- const lineHeight = 4 * grid / fontSize;
31
- const maxWidth = 105 * grid; // ~420px
32
-
33
- const leftAndRightTextPadding = 2 * grid;
34
- const topAndBottomPadding = grid / 4;
35
- const marginDistance = 2 * grid;
36
- export const emojiStylesNext = css`
37
- .editor-emoji {
38
- position: relative;
39
- display: inline-block;
40
- width: 20px;
41
- height: 20px;
42
- background-repeat: none;
43
- background-size: contain;
44
- cursor: pointer;
45
- vertical-align: middle;
46
-
47
- &.editor-emoji-loading {
48
- border-radius: ${borderRadius()}px;
49
- background: ${N20};
50
- }
51
-
52
- &.editor-emoji-fallback {
53
- display: inline;
54
- background: transparent;
55
- vertical-align: baseline;
56
- }
57
-
58
- &.ProseMirror-selectednode:empty {
59
- outline: none;
60
- }
61
-
62
- &:not(.editor-emoji-fallback) {
63
- font-size: 0px;
64
- }
65
-
66
- &:not(.editor-emoji-fallback)::before {
67
- content: attr(data-emoji-shortname);
68
- display: block;
69
- box-sizing: border-box;
70
- width: auto;
71
- position: absolute;
72
- top: 100%;
73
- left: 50%;
74
- transform: translate(-50%, ${marginDistance}px);
75
-
76
- // packages/css-packs/reduced-ui-pack/src/tooltip.js:25
77
- color: ${N0};
78
- background-color: ${N900};
79
- font-size: ${relativeFontSizeToBase16(fontSize)};
80
- line-height: ${lineHeight};
81
- max-width: ${maxWidth}px;
82
- border-radius: ${borderRadius()}px;
83
- overflow: hidden;
84
- padding: ${topAndBottomPadding}px ${leftAndRightTextPadding}px;
85
- pointer-events: none;
86
- text-decoration: none;
87
- text-overflow: ellipsis;
88
- white-space: nowrap;
89
- z-index: 10000;
90
-
91
- opacity: 0; // invisible by default
92
- transition: opacity 0.35s; // (durationStep * 14)
93
- }
94
-
95
- &:not(.editor-emoji-fallback):hover::before {
96
- opacity: 1;
97
- transition: opacity 0s 0.35s; // (durationStep * 14)
98
- }
99
-
100
- &.${akEditorSelectedNodeClassName} {
101
- z-index: 2;
102
- border-radius: 2px;
103
- ${getSelectionStyles([SelectionStyle.Blanket, SelectionStyle.BoxShadow])}
104
- }
105
- }
106
25
  `;
@@ -19,10 +19,10 @@ const EXPAND_ICON_COLOR = props => css`
19
19
  `;
20
20
 
21
21
  const ACTIVE_STATE_BACKGROUND_COLOR = themed({
22
- dark: `#0C294F`
22
+ dark: `#0C294F4B`
23
23
  });
24
24
  const ACTIVE_STATE_BORDER = themed({
25
- dark: `1px solid #4794ff`
25
+ dark: `1px solid #4794ff4B`
26
26
  });
27
27
  const ACTIVE_STATE_BORDER_RADIUS = themed({
28
28
  dark: '3px'
@@ -1,5 +1,6 @@
1
1
  import { css } from '@emotion/react';
2
2
  import { blockNodesVerticalMargin, akEditorSelectedBorderSize, akEditorDeleteBorder, akEditorDeleteBackground, SelectionStyle, getSelectionStyles, akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles';
3
+ import { token } from '@atlaskit/tokens';
3
4
  export const extensionStyles = css`
4
5
  .extensionView-content-wrap,
5
6
  .bodiedExtensionView-content-wrap {
@@ -20,8 +21,9 @@ export const extensionStyles = css`
20
21
  }
21
22
 
22
23
  &.danger > span > .extension-container {
23
- box-shadow: 0 0 0 ${akEditorSelectedBorderSize}px ${akEditorDeleteBorder};
24
- background-color: ${akEditorDeleteBackground};
24
+ box-shadow: 0 0 0 ${akEditorSelectedBorderSize}px
25
+ ${token('color.border.danger', akEditorDeleteBorder)};
26
+ background-color: ${token('color.background.danger', akEditorDeleteBackground)};
25
27
  }
26
28
 
27
29
  &.inline {