@atlaskit/editor-core 187.47.9 → 187.48.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/cjs/editor-next/index.js +2 -2
  3. package/dist/cjs/index.js +7 -7
  4. package/dist/cjs/labs/next/presets/default.js +2 -2
  5. package/dist/cjs/plugins/index.js +0 -7
  6. package/dist/cjs/test-utils.js +2 -2
  7. package/dist/cjs/version-wrapper.js +1 -1
  8. package/dist/es2019/editor-next/index.js +1 -1
  9. package/dist/es2019/index.js +1 -1
  10. package/dist/es2019/labs/next/presets/default.js +1 -1
  11. package/dist/es2019/plugins/index.js +0 -1
  12. package/dist/es2019/test-utils.js +1 -1
  13. package/dist/es2019/version-wrapper.js +1 -1
  14. package/dist/esm/editor-next/index.js +1 -1
  15. package/dist/esm/index.js +1 -1
  16. package/dist/esm/labs/next/presets/default.js +1 -1
  17. package/dist/esm/plugins/index.js +0 -1
  18. package/dist/esm/test-utils.js +1 -1
  19. package/dist/esm/version-wrapper.js +1 -1
  20. package/dist/types/create-editor/create-plugins-list.d.ts +1 -1
  21. package/dist/types/index.d.ts +1 -1
  22. package/dist/types/labs/next/presets/default.d.ts +1 -1
  23. package/dist/types/plugins/code-block/ide-ux/quote-handling.d.ts +1 -1
  24. package/dist/types/plugins/index.d.ts +0 -1
  25. package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
  26. package/dist/types/ui/ConfigPanel/FormErrorBoundary.d.ts +1 -1
  27. package/dist/types/ui/ContentStyles/index.d.ts +2 -2
  28. package/dist/types-ts4.5/create-editor/create-plugins-list.d.ts +1 -1
  29. package/dist/types-ts4.5/index.d.ts +1 -1
  30. package/dist/types-ts4.5/labs/next/presets/default.d.ts +1 -1
  31. package/dist/types-ts4.5/plugins/code-block/ide-ux/quote-handling.d.ts +1 -1
  32. package/dist/types-ts4.5/plugins/index.d.ts +0 -1
  33. package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
  34. package/dist/types-ts4.5/ui/ConfigPanel/FormErrorBoundary.d.ts +1 -1
  35. package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
  36. package/package.json +8 -9
  37. package/report.api.md +3 -26
  38. package/tmp/api-report-tmp.d.ts +3 -26
  39. package/dist/cjs/plugins/base/commands.js +0 -20
  40. package/dist/cjs/plugins/base/index.js +0 -13
  41. package/dist/cjs/plugins/base/plugin.js +0 -143
  42. package/dist/cjs/plugins/base/pm-plugins/context-identifier.js +0 -58
  43. package/dist/cjs/plugins/base/pm-plugins/disable-spell-checking.js +0 -63
  44. package/dist/cjs/plugins/base/pm-plugins/filter-steps.js +0 -34
  45. package/dist/cjs/plugins/base/pm-plugins/fix-chrome-88-selection.js +0 -34
  46. package/dist/cjs/plugins/base/pm-plugins/frozen-editor.js +0 -265
  47. package/dist/cjs/plugins/base/pm-plugins/inline-cursor-target.js +0 -183
  48. package/dist/cjs/plugins/base/pm-plugins/newline-preserve-marks.js +0 -34
  49. package/dist/cjs/plugins/base/pm-plugins/scroll-gutter/index.js +0 -262
  50. package/dist/cjs/plugins/base/pm-plugins/scroll-gutter/plugin-key.js +0 -15
  51. package/dist/cjs/plugins/base/utils/frozen-editor.js +0 -11
  52. package/dist/cjs/plugins/base/utils/input-latency-tracking.js +0 -134
  53. package/dist/es2019/plugins/base/commands.js +0 -13
  54. package/dist/es2019/plugins/base/index.js +0 -2
  55. package/dist/es2019/plugins/base/plugin.js +0 -113
  56. package/dist/es2019/plugins/base/pm-plugins/context-identifier.js +0 -43
  57. package/dist/es2019/plugins/base/pm-plugins/disable-spell-checking.js +0 -54
  58. package/dist/es2019/plugins/base/pm-plugins/filter-steps.js +0 -23
  59. package/dist/es2019/plugins/base/pm-plugins/fix-chrome-88-selection.js +0 -24
  60. package/dist/es2019/plugins/base/pm-plugins/frozen-editor.js +0 -258
  61. package/dist/es2019/plugins/base/pm-plugins/inline-cursor-target.js +0 -186
  62. package/dist/es2019/plugins/base/pm-plugins/newline-preserve-marks.js +0 -20
  63. package/dist/es2019/plugins/base/pm-plugins/scroll-gutter/index.js +0 -242
  64. package/dist/es2019/plugins/base/pm-plugins/scroll-gutter/plugin-key.js +0 -7
  65. package/dist/es2019/plugins/base/utils/frozen-editor.js +0 -2
  66. package/dist/es2019/plugins/base/utils/input-latency-tracking.js +0 -104
  67. package/dist/esm/plugins/base/commands.js +0 -13
  68. package/dist/esm/plugins/base/index.js +0 -2
  69. package/dist/esm/plugins/base/plugin.js +0 -131
  70. package/dist/esm/plugins/base/pm-plugins/context-identifier.js +0 -48
  71. package/dist/esm/plugins/base/pm-plugins/disable-spell-checking.js +0 -56
  72. package/dist/esm/plugins/base/pm-plugins/filter-steps.js +0 -27
  73. package/dist/esm/plugins/base/pm-plugins/fix-chrome-88-selection.js +0 -26
  74. package/dist/esm/plugins/base/pm-plugins/frozen-editor.js +0 -251
  75. package/dist/esm/plugins/base/pm-plugins/inline-cursor-target.js +0 -174
  76. package/dist/esm/plugins/base/pm-plugins/newline-preserve-marks.js +0 -26
  77. package/dist/esm/plugins/base/pm-plugins/scroll-gutter/index.js +0 -254
  78. package/dist/esm/plugins/base/pm-plugins/scroll-gutter/plugin-key.js +0 -7
  79. package/dist/esm/plugins/base/utils/frozen-editor.js +0 -4
  80. package/dist/esm/plugins/base/utils/input-latency-tracking.js +0 -128
  81. package/dist/types/plugins/base/commands.d.ts +0 -2
  82. package/dist/types/plugins/base/index.d.ts +0 -5
  83. package/dist/types/plugins/base/plugin.d.ts +0 -25
  84. package/dist/types/plugins/base/pm-plugins/context-identifier.d.ts +0 -13
  85. package/dist/types/plugins/base/pm-plugins/disable-spell-checking.d.ts +0 -4
  86. package/dist/types/plugins/base/pm-plugins/filter-steps.d.ts +0 -4
  87. package/dist/types/plugins/base/pm-plugins/fix-chrome-88-selection.d.ts +0 -5
  88. package/dist/types/plugins/base/pm-plugins/frozen-editor.d.ts +0 -12
  89. package/dist/types/plugins/base/pm-plugins/inline-cursor-target.d.ts +0 -17
  90. package/dist/types/plugins/base/pm-plugins/newline-preserve-marks.d.ts +0 -5
  91. package/dist/types/plugins/base/pm-plugins/scroll-gutter/index.d.ts +0 -22
  92. package/dist/types/plugins/base/pm-plugins/scroll-gutter/plugin-key.d.ts +0 -7
  93. package/dist/types/plugins/base/utils/frozen-editor.d.ts +0 -2
  94. package/dist/types/plugins/base/utils/input-latency-tracking.d.ts +0 -42
  95. package/dist/types-ts4.5/plugins/base/commands.d.ts +0 -2
  96. package/dist/types-ts4.5/plugins/base/index.d.ts +0 -5
  97. package/dist/types-ts4.5/plugins/base/plugin.d.ts +0 -27
  98. package/dist/types-ts4.5/plugins/base/pm-plugins/context-identifier.d.ts +0 -13
  99. package/dist/types-ts4.5/plugins/base/pm-plugins/disable-spell-checking.d.ts +0 -4
  100. package/dist/types-ts4.5/plugins/base/pm-plugins/filter-steps.d.ts +0 -4
  101. package/dist/types-ts4.5/plugins/base/pm-plugins/fix-chrome-88-selection.d.ts +0 -5
  102. package/dist/types-ts4.5/plugins/base/pm-plugins/frozen-editor.d.ts +0 -12
  103. package/dist/types-ts4.5/plugins/base/pm-plugins/inline-cursor-target.d.ts +0 -17
  104. package/dist/types-ts4.5/plugins/base/pm-plugins/newline-preserve-marks.d.ts +0 -5
  105. package/dist/types-ts4.5/plugins/base/pm-plugins/scroll-gutter/index.d.ts +0 -22
  106. package/dist/types-ts4.5/plugins/base/pm-plugins/scroll-gutter/plugin-key.d.ts +0 -7
  107. package/dist/types-ts4.5/plugins/base/utils/frozen-editor.d.ts +0 -2
  108. package/dist/types-ts4.5/plugins/base/utils/input-latency-tracking.d.ts +0 -42
@@ -1,262 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getKeyboardHeight = exports.default = void 0;
7
- var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
8
- var _utils = require("@atlaskit/editor-common/utils");
9
- var _pluginKey = require("./plugin-key");
10
- var getKeyboardHeight = function getKeyboardHeight(state) {
11
- if (state) {
12
- var scrollGutterPluginState = (0, _pluginKey.getScrollGutterPluginState)(state);
13
- return scrollGutterPluginState ? scrollGutterPluginState.keyboardHeight : undefined;
14
- }
15
- };
16
- exports.getKeyboardHeight = getKeyboardHeight;
17
- var MIN_TAP_SIZE_IN_PX = 40;
18
- function supportsIntersectionObserver() {
19
- if (typeof window !== 'undefined' && 'IntersectionObserver' in window && 'IntersectionObserverEntry' in window && 'intersectionRatio' in window.IntersectionObserverEntry.prototype) {
20
- return true;
21
- }
22
- return false;
23
- }
24
- function listenForGutterVisibilityChanges(scrollElement, gutterIsVisible) {
25
- if (supportsIntersectionObserver()) {
26
- var observer = new IntersectionObserver(function (entries, _) {
27
- entries.forEach(function (entry) {
28
- gutterIsVisible(entry.intersectionRatio > 0);
29
- });
30
- }, {
31
- root: scrollElement,
32
- rootMargin: '0px',
33
- threshold: 0
34
- });
35
- return observer;
36
- }
37
- return undefined;
38
- }
39
-
40
- /**
41
- * Create a gutter element that can be added or removed from the DOM.
42
- */
43
- function createGutter(gutterSize) {
44
- var gutter = document.createElement('div');
45
- gutter.style.paddingBottom = "".concat(gutterSize, "px");
46
- gutter.id = _utils.GUTTER_SELECTOR.substr(1);
47
- var initialized = false;
48
- var mounted = false;
49
- var currentParent = null;
50
- var observer;
51
- var isVisible = false;
52
- return {
53
- addGutter: function addGutter(parent) {
54
- if (parent) {
55
- currentParent = parent;
56
- parent.appendChild(gutter);
57
- mounted = true;
58
- if (observer) {
59
- observer.observe(gutter);
60
- }
61
- }
62
- },
63
- removeGutter: function removeGutter() {
64
- if (currentParent && mounted) {
65
- mounted = false;
66
- currentParent.removeChild(gutter);
67
- if (observer) {
68
- observer.unobserve(gutter);
69
- }
70
- }
71
- },
72
- element: function element() {
73
- return gutter;
74
- },
75
- isMounted: function isMounted() {
76
- return mounted;
77
- },
78
- visible: function visible() {
79
- // If we know whether it's visible we can avoid expensive calculations
80
- if (observer) {
81
- return isVisible;
82
- }
83
- // Fallback for legacy browsers assumes it's visible (if mounted)
84
- return mounted;
85
- },
86
- observe: function observe(scrollElement) {
87
- if (!initialized) {
88
- initialized = true;
89
- observer = listenForGutterVisibilityChanges(scrollElement, function (visible) {
90
- return isVisible = visible;
91
- });
92
- }
93
- },
94
- destroy: function destroy() {
95
- if (observer) {
96
- observer.disconnect();
97
- }
98
- observer = undefined;
99
- this.removeGutter();
100
- initialized = mounted = false;
101
- }
102
- };
103
- }
104
-
105
- /**
106
- * Get caret top position given the current selection,
107
- * use start container position as fallback
108
- */
109
- function getCaretTopPosition() {
110
- var windowSelection = window.getSelection();
111
- if (windowSelection && windowSelection.rangeCount > 0) {
112
- var range = windowSelection.getRangeAt(0);
113
- if (range) {
114
- var clientRects = range.getClientRects();
115
- // Return client rects
116
- if (clientRects && clientRects.length > 0) {
117
- return clientRects[0].top;
118
- }
119
-
120
- // Return container top
121
- var container = range.startContainer;
122
- if (container && container.getBoundingClientRect) {
123
- return container.getBoundingClientRect().top;
124
- }
125
- }
126
- }
127
- return;
128
- }
129
- function scrollToGutterElement(scrollContainer, gutterElement, gutterSize) {
130
- var viewportHeight = scrollContainer.offsetHeight;
131
- var viewportOffsetY = scrollContainer.getBoundingClientRect().top;
132
- var caretTopPosition = getCaretTopPosition();
133
- if (!caretTopPosition) {
134
- return false;
135
- }
136
- var caretTopFromContainer = caretTopPosition - viewportOffsetY;
137
- var gutterThresholdTop = viewportHeight - gutterSize - MIN_TAP_SIZE_IN_PX * 2;
138
- if (caretTopFromContainer < gutterThresholdTop) {
139
- return false;
140
- }
141
-
142
- // Clamp the scroll position to above the scroll gutter element.
143
- gutterElement.scrollIntoView(false);
144
-
145
- // Mark scrolling as handled so that other plugin's don't override our position.
146
- return true;
147
- }
148
- var _default = function _default() {
149
- var pluginOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
150
- var getScrollElement = pluginOptions.getScrollElement,
151
- allowCustomScrollHandler = pluginOptions.allowCustomScrollHandler,
152
- _pluginOptions$gutter = pluginOptions.gutterSize,
153
- gutterSize = _pluginOptions$gutter === void 0 ? _utils.GUTTER_SIZE_IN_PX : _pluginOptions$gutter;
154
- if (!getScrollElement) {
155
- return undefined;
156
- }
157
- var gutter = createGutter(gutterSize);
158
- var scrollElement = null; // | undefined;
159
-
160
- return new _safePlugin.SafePlugin({
161
- key: _pluginKey.scrollGutterPluginKey,
162
- state: {
163
- init: function init() {
164
- return {};
165
- },
166
- apply: function apply(tr, pluginState) {
167
- if (tr.getMeta(_pluginKey.scrollGutterPluginKey)) {
168
- return tr.getMeta(_pluginKey.scrollGutterPluginKey);
169
- }
170
- return pluginState;
171
- }
172
- },
173
- props: {
174
- // Determines the distance (in pixels) between the cursor and the end of the visible viewport at which point,
175
- // when scrolling the cursor into view, scrolling takes place.
176
- // Defaults to 0: https://prosemirror.net/docs/ref/#view.EditorProps.scrollThreshold
177
- scrollThreshold: gutterSize / 2,
178
- // Determines the extra space (in pixels) that is left above or below the cursor when it is scrolled into view.
179
- // Defaults to 5: https://prosemirror.net/docs/ref/#view.EditorProps.scrollMargin
180
- scrollMargin: gutterSize,
181
- // Called when the view, after updating its state, tries to scroll the selection into view
182
- // https://prosemirror.net/docs/ref/#view.EditorProps.handleScrollToSelection
183
- handleScrollToSelection: function handleScrollToSelection() {
184
- if (allowCustomScrollHandler === false) {
185
- return false;
186
- }
187
- if (!gutter.isMounted() || !gutter.visible() || !scrollElement) {
188
- // Avoid scrolling until applicable
189
- return false;
190
- }
191
- return scrollToGutterElement(scrollElement, gutter.element(), gutterSize);
192
- }
193
- },
194
- view: function (_view) {
195
- function view(_x) {
196
- return _view.apply(this, arguments);
197
- }
198
- view.toString = function () {
199
- return _view.toString();
200
- };
201
- return view;
202
- }(function (view) {
203
- // Store references to avoid lookups on successive checks.
204
- scrollElement = getScrollElement(view);
205
- var editorElement = view.dom;
206
- var editorParentElement = editorElement.parentElement;
207
- return {
208
- destroy: function destroy() {
209
- // Remove if it's mounted
210
- gutter.destroy();
211
- scrollElement = editorParentElement = editorElement = null;
212
- },
213
- /**
214
- * Toggle the Scroll Gutter Element
215
- */
216
- update: function update(view, prevState) {
217
- var _getKeyboardHeight;
218
- if (!scrollElement || !editorParentElement) {
219
- return;
220
- }
221
- var state = view.state;
222
- if (prevState.selection === state.selection) {
223
- // No need to recheck if the selected node hasn't changed.
224
- return;
225
- }
226
- var gutterMounted = gutter.isMounted();
227
- var addAndObserveGutter = function addAndObserveGutter() {
228
- if (!gutterMounted) {
229
- gutter.observe(scrollElement);
230
- gutter.addGutter(editorParentElement);
231
- }
232
- };
233
- if (pluginOptions.persistScrollGutter) {
234
- if (!(0, _utils.isEmptyDocument)(state.doc)) {
235
- addAndObserveGutter();
236
- } else {
237
- gutter.removeGutter();
238
- }
239
- return;
240
- }
241
- // Determine whether we need to consider Keyboard Height
242
- var keyboardHeight = (_getKeyboardHeight = getKeyboardHeight(state)) !== null && _getKeyboardHeight !== void 0 ? _getKeyboardHeight : 0;
243
- var viewportHeight = scrollElement.offsetHeight - keyboardHeight;
244
- var contentHeight = editorParentElement.offsetHeight - (gutterMounted ? gutterSize : 0);
245
-
246
- // Add or remove the gutter based on whether the content is about to exceed the viewport height.
247
- // We do this to ensure there is sufficient white space below the last content node in order to
248
- // see any UI control elements which may sit beneath it.
249
- var gutterThresholdHeight = viewportHeight - gutterSize;
250
- if (contentHeight >= gutterThresholdHeight) {
251
- addAndObserveGutter();
252
- } else {
253
- if (gutterMounted) {
254
- gutter.removeGutter();
255
- }
256
- }
257
- }
258
- };
259
- })
260
- });
261
- };
262
- exports.default = _default;
@@ -1,15 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.scrollGutterPluginKey = exports.getScrollGutterPluginState = void 0;
7
- var _state = require("@atlaskit/editor-prosemirror/state");
8
- var scrollGutterPluginKey = new _state.PluginKey('scrollGutter');
9
- exports.scrollGutterPluginKey = scrollGutterPluginKey;
10
- var getScrollGutterPluginState = function getScrollGutterPluginState(state) {
11
- if (state) {
12
- return scrollGutterPluginKey.getState(state);
13
- }
14
- };
15
- exports.getScrollGutterPluginState = getScrollGutterPluginState;
@@ -1,11 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.setInteractionType = void 0;
7
- /** Allows the possibility of overriding interaction type values in unit tests via jest.mock or spyOn. */
8
- var setInteractionType = function setInteractionType(value) {
9
- return value;
10
- };
11
- exports.setInteractionType = setInteractionType;
@@ -1,134 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
- var _utils = require("@atlaskit/editor-common/utils");
12
- var InputLatencyTracker = /*#__PURE__*/function () {
13
- function InputLatencyTracker(_ref) {
14
- var samplingRate = _ref.samplingRate,
15
- slowThreshold = _ref.slowThreshold,
16
- normalThreshold = _ref.normalThreshold,
17
- degradedThreshold = _ref.degradedThreshold,
18
- dispatchAverage = _ref.dispatchAverage,
19
- dispatchSample = _ref.dispatchSample,
20
- onSampleStart = _ref.onSampleStart,
21
- onSampleEnd = _ref.onSampleEnd,
22
- onSlowInput = _ref.onSlowInput;
23
- (0, _classCallCheck2.default)(this, InputLatencyTracker);
24
- (0, _defineProperty2.default)(this, "samples", []);
25
- (0, _defineProperty2.default)(this, "total", 0);
26
- this.samplingRate = samplingRate;
27
- this.slowThreshold = slowThreshold;
28
- this.normalThreshold = normalThreshold;
29
- this.degradedThreshold = degradedThreshold;
30
- this.dispatchAverage = dispatchAverage;
31
- this.dispatchSample = dispatchSample;
32
- this.onSampleStart = onSampleStart;
33
- this.onSampleEnd = onSampleEnd;
34
- this.onSlowInput = onSlowInput;
35
- }
36
- (0, _createClass2.default)(InputLatencyTracker, [{
37
- key: "start",
38
- value: function start() {
39
- var _this = this;
40
- var currentStart = performance.now();
41
- if (this.samples.length + 1 === this.samplingRate) {
42
- var _this$onSampleStart;
43
- (_this$onSampleStart = this.onSampleStart) === null || _this$onSampleStart === void 0 ? void 0 : _this$onSampleStart.call(this);
44
- }
45
- var end = function end() {
46
- if (currentStart === null) {
47
- return;
48
- }
49
- var isSlow = false;
50
- var time = (0, _utils.getTimeSince)(currentStart);
51
- _this.push(time);
52
- if (time > _this.slowThreshold) {
53
- var _this$onSlowInput;
54
- (_this$onSlowInput = _this.onSlowInput) === null || _this$onSlowInput === void 0 ? void 0 : _this$onSlowInput.call(_this, time);
55
- isSlow = true;
56
- }
57
- if (_this.samples.length === _this.samplingRate) {
58
- var _this$onSampleEnd;
59
- _this.flush();
60
- (_this$onSampleEnd = _this.onSampleEnd) === null || _this$onSampleEnd === void 0 ? void 0 : _this$onSampleEnd.call(_this, time, {
61
- isSlow: isSlow,
62
- severity: _this.severity(time)
63
- });
64
- }
65
- };
66
- return end;
67
- }
68
- }, {
69
- key: "flush",
70
- value: function flush() {
71
- if (this.samples.length === 0) {
72
- return;
73
- }
74
- this.dispatch();
75
- this.samples = [];
76
- this.total = 0;
77
- }
78
- }, {
79
- key: "dispatch",
80
- value: function dispatch() {
81
- var _this$dispatchSample, _this$dispatchAverage;
82
- (_this$dispatchSample = this.dispatchSample) === null || _this$dispatchSample === void 0 ? void 0 : _this$dispatchSample.call(this, this.getLast(), this.severity(this.getLast()));
83
- // cache
84
- var 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: median,
88
- sampleSize: this.samples.length
89
- }, this.severity(median));
90
- }
91
- }, {
92
- key: "push",
93
- value: function push(latency) {
94
- this.samples.push(latency);
95
- this.total += latency;
96
- }
97
- }, {
98
- key: "severity",
99
- value: function severity(time) {
100
- return (0, _utils.getAnalyticsEventSeverity)(time, this.normalThreshold, this.degradedThreshold);
101
- }
102
- }, {
103
- key: "getLast",
104
- value: function getLast() {
105
- return this.samples[this.samples.length - 1];
106
- }
107
- }, {
108
- key: "getMean",
109
- value: function getMean() {
110
- return this.total / this.samples.length;
111
- }
112
- }, {
113
- key: "getMedian",
114
- value: function getMedian() {
115
- if (this.samples.length === 1) {
116
- return this.samples[0];
117
- }
118
- this.samples.sort(function (a, b) {
119
- return a - b;
120
- });
121
- var middle = (this.samples.length + 1) / 2;
122
- var floorMiddle = Math.floor(middle);
123
- var remainder = middle % floorMiddle;
124
- if (remainder === 0) {
125
- return this.samples[middle - 1];
126
- }
127
- var left = this.samples[floorMiddle - 1];
128
- var right = this.samples[floorMiddle];
129
- return (left + right) / 2;
130
- }
131
- }]);
132
- return InputLatencyTracker;
133
- }();
134
- exports.default = InputLatencyTracker;
@@ -1,13 +0,0 @@
1
- import { scrollGutterPluginKey } from './pm-plugins/scroll-gutter/plugin-key';
2
- export const setKeyboardHeight = keyboardHeight => (state, dispatch) => {
3
- const {
4
- tr
5
- } = state;
6
- tr.setMeta(scrollGutterPluginKey, {
7
- keyboardHeight
8
- });
9
- if (dispatch) {
10
- dispatch(tr);
11
- }
12
- return true;
13
- };
@@ -1,2 +0,0 @@
1
- import basePlugin from './plugin';
2
- export { basePlugin };
@@ -1,113 +0,0 @@
1
- import { baseKeymap } from '@atlaskit/editor-prosemirror/commands';
2
- import { history } from '@atlaskit/editor-prosemirror/history';
3
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
4
- import { browser } from '@atlaskit/editor-common/utils';
5
- import { doc, paragraph, text } from '@atlaskit/adf-schema';
6
- import filterStepsPlugin from './pm-plugins/filter-steps';
7
- import fixChrome88SelectionPlugin from './pm-plugins/fix-chrome-88-selection';
8
- import disableSpellcheckingPlugin from './pm-plugins/disable-spell-checking';
9
- import contextIdentifierPlugin, { getContextIdentifier } from './pm-plugins/context-identifier';
10
- import newlinePreserveMarksPlugin from './pm-plugins/newline-preserve-marks';
11
- import inlineCursorTargetPlugin from './pm-plugins/inline-cursor-target';
12
- import scrollGutter, { getKeyboardHeight } from './pm-plugins/scroll-gutter';
13
- import { keymap } from '@atlaskit/editor-common/keymaps';
14
- import frozenEditor from './pm-plugins/frozen-editor';
15
- // Chrome >= 88
16
- export const isChromeWithSelectionBug = browser.chrome && browser.chrome_version >= 88;
17
- const basePlugin = ({
18
- config: options,
19
- api
20
- }) => {
21
- var _api$featureFlags;
22
- const featureFlags = (api === null || api === void 0 ? void 0 : (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
23
- return {
24
- name: 'base',
25
- getSharedState(editorState) {
26
- return {
27
- contextIdentifier: getContextIdentifier(editorState),
28
- keyboardHeight: getKeyboardHeight(editorState)
29
- };
30
- },
31
- pmPlugins() {
32
- const plugins = [{
33
- name: 'filterStepsPlugin',
34
- plugin: ({
35
- dispatchAnalyticsEvent
36
- }) => filterStepsPlugin(dispatchAnalyticsEvent)
37
- }];
38
-
39
- // In Chrome, when the selection is placed between adjacent nodes which are not contenteditatble
40
- // the cursor appears at the right most point of the parent container.
41
- // In Firefox, when the selection is placed between adjacent nodes which are not contenteditatble
42
- // no cursor is presented to users.
43
- // In Safari, when the selection is placed between adjacent nodes which are not contenteditatble
44
- // it is not possible to navigate with arrow keys.
45
- // This plugin works around the issues by inserting decorations between
46
- // inline nodes which are set as contenteditable, and have a zero width space.
47
- plugins.push({
48
- name: 'inlineCursorTargetPlugin',
49
- plugin: () => options && options.allowInlineCursorTarget ? inlineCursorTargetPlugin() : undefined
50
- });
51
- plugins.push({
52
- name: 'newlinePreserveMarksPlugin',
53
- plugin: newlinePreserveMarksPlugin
54
- }, {
55
- name: 'frozenEditor',
56
- plugin: ({
57
- dispatchAnalyticsEvent
58
- }) => {
59
- var _options$inputTrackin;
60
- return options !== null && options !== void 0 && (_options$inputTrackin = options.inputTracking) !== null && _options$inputTrackin !== void 0 && _options$inputTrackin.enabled || options !== null && options !== void 0 && options.ufo ? frozenEditor(dispatchAnalyticsEvent, options.inputTracking, options.browserFreezeTracking, options.ufo) : undefined;
61
- }
62
- }, {
63
- name: 'history',
64
- plugin: () => history()
65
- },
66
- // should be last :(
67
- {
68
- name: 'codeBlockIndent',
69
- plugin: () => keymap({
70
- ...baseKeymap,
71
- 'Mod-[': () => true,
72
- 'Mod-]': () => true
73
- })
74
- }, {
75
- name: 'contextIdentifier',
76
- plugin: ({
77
- dispatch,
78
- providerFactory
79
- }) => contextIdentifierPlugin(dispatch, providerFactory)
80
- });
81
- if (options && options.allowScrollGutter) {
82
- plugins.push({
83
- name: 'scrollGutterPlugin',
84
- plugin: () => scrollGutter(options.allowScrollGutter)
85
- });
86
- }
87
- if (isChromeWithSelectionBug && !getBooleanFF('platform.editor.disable-chrome-88-selection-fix_uk53m')) {
88
- plugins.push({
89
- name: 'fixChrome88SelectionPlugin',
90
- plugin: () => fixChrome88SelectionPlugin()
91
- });
92
- }
93
- plugins.push({
94
- name: 'disableSpellcheckingPlugin',
95
- plugin: () => disableSpellcheckingPlugin(featureFlags)
96
- });
97
- return plugins;
98
- },
99
- nodes() {
100
- return [{
101
- name: 'doc',
102
- node: doc
103
- }, {
104
- name: 'paragraph',
105
- node: paragraph
106
- }, {
107
- name: 'text',
108
- node: text
109
- }];
110
- }
111
- };
112
- };
113
- export default basePlugin;
@@ -1,43 +0,0 @@
1
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
- export const stateKey = new PluginKey('contextIdentiferPlugin');
4
- export const getContextIdentifier = state => {
5
- if (state) {
6
- var _stateKey$getState;
7
- return (_stateKey$getState = stateKey.getState(state)) === null || _stateKey$getState === void 0 ? void 0 : _stateKey$getState.contextIdentifierProvider;
8
- }
9
- };
10
- export default ((dispatch, providerFactory) => new SafePlugin({
11
- key: stateKey,
12
- state: {
13
- init: () => ({}),
14
- apply: (tr, pluginState) => {
15
- if (tr.getMeta(stateKey)) {
16
- return tr.getMeta(stateKey);
17
- }
18
- return pluginState;
19
- }
20
- },
21
- view: view => {
22
- const providerPromiseHandler = (name, providerPromise) => {
23
- if (providerPromise && name === 'contextIdentifierProvider') {
24
- providerPromise.then(provider => {
25
- const tr = view.state.tr.setMeta(stateKey, {
26
- contextIdentifierProvider: {
27
- ...provider
28
- }
29
- });
30
- view.dispatch(tr);
31
- });
32
- }
33
- };
34
- if (providerFactory) {
35
- providerFactory.subscribe('contextIdentifierProvider', providerPromiseHandler);
36
- }
37
- return {
38
- destroy: () => {
39
- providerFactory && providerFactory.unsubscribe('contextIdentifierProvider', providerPromiseHandler);
40
- }
41
- };
42
- }
43
- }));
@@ -1,54 +0,0 @@
1
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
- import { browser as browserEnv } from '@atlaskit/editor-common/utils';
4
- function getCurrentBrowserAndVersion() {
5
- switch (true) {
6
- case browserEnv.chrome === true:
7
- return {
8
- browser: 'chrome',
9
- version: browserEnv.chrome_version
10
- };
11
- case browserEnv.ie === true:
12
- return {
13
- browser: 'ie',
14
- version: browserEnv.ie_version
15
- };
16
- case browserEnv.gecko === true:
17
- return {
18
- browser: 'gecko',
19
- version: browserEnv.gecko_version
20
- };
21
- case browserEnv.safari === true:
22
- return {
23
- browser: 'safari',
24
- version: browserEnv.safari_version
25
- };
26
- }
27
- return undefined;
28
- }
29
- export default (featureFlags => new SafePlugin({
30
- key: new PluginKey('disableSpellchecking'),
31
- props: {
32
- attributes: editorState => {
33
- if (!featureFlags) {
34
- return {};
35
- }
36
- const browserConfigFeatureFlag = featureFlags.disableSpellcheckByBrowser;
37
- const userCurrentBrowserAndVersion = getCurrentBrowserAndVersion();
38
- if (!userCurrentBrowserAndVersion || !browserConfigFeatureFlag) {
39
- return {};
40
- }
41
- const browserVersionDisableRange = browserConfigFeatureFlag[userCurrentBrowserAndVersion.browser];
42
- if (!browserVersionDisableRange || !browserEnv[userCurrentBrowserAndVersion.browser]) {
43
- return {};
44
- }
45
- const shouldDisableSpellcheck = !!browserVersionDisableRange.maximum ? userCurrentBrowserAndVersion.version >= browserVersionDisableRange.minimum && userCurrentBrowserAndVersion.version <= browserVersionDisableRange.maximum : browserEnv[userCurrentBrowserAndVersion.browser] && userCurrentBrowserAndVersion.version >= browserVersionDisableRange.minimum;
46
- if (shouldDisableSpellcheck) {
47
- return {
48
- spellcheck: 'false'
49
- };
50
- }
51
- return {};
52
- }
53
- }
54
- }));
@@ -1,23 +0,0 @@
1
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import { ACTION_SUBJECT, ACTION, EVENT_TYPE, getAnalyticsEventsFromTransaction } from '@atlaskit/editor-common/analytics';
3
- const hasInvalidSteps = tr => (tr.steps || []).some(step => step.from > step.to);
4
- export default (dispatchAnalyticsEvent => {
5
- return new SafePlugin({
6
- filterTransaction(transaction) {
7
- if (hasInvalidSteps(transaction)) {
8
- // eslint-disable-next-line no-console
9
- console.warn('The transaction was blocked because it contains invalid steps', transaction.steps);
10
- dispatchAnalyticsEvent({
11
- action: ACTION.DISCARDED_INVALID_STEPS_FROM_TRANSACTION,
12
- actionSubject: ACTION_SUBJECT.EDITOR,
13
- attributes: {
14
- analyticsEventPayloads: getAnalyticsEventsFromTransaction(transaction)
15
- },
16
- eventType: EVENT_TYPE.OPERATIONAL
17
- });
18
- return false;
19
- }
20
- return true;
21
- }
22
- });
23
- });