@atlaskit/editor-plugin-base 0.3.3 → 0.3.5
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.
- package/CHANGELOG.md +13 -0
- package/dist/cjs/plugin.js +2 -13
- package/dist/cjs/pm-plugins/frozen-editor.js +217 -214
- package/dist/cjs/pm-plugins/scroll-gutter/index.js +5 -5
- package/dist/es2019/plugin.js +2 -12
- package/dist/es2019/pm-plugins/frozen-editor.js +13 -14
- package/dist/es2019/pm-plugins/scroll-gutter/index.js +5 -5
- package/dist/esm/plugin.js +2 -13
- package/dist/esm/pm-plugins/frozen-editor.js +217 -214
- package/dist/esm/pm-plugins/scroll-gutter/index.js +5 -5
- package/dist/types/plugin.d.ts +5 -3
- package/dist/types/pm-plugins/frozen-editor.d.ts +3 -2
- package/dist/types-ts4.5/plugin.d.ts +3 -3
- package/dist/types-ts4.5/pm-plugins/frozen-editor.d.ts +3 -2
- package/package.json +5 -10
- package/tsconfig.app.json +2 -2
- package/dist/cjs/pm-plugins/context-identifier.js +0 -55
- package/dist/cjs/pm-plugins/scroll-gutter/plugin-deprecated.js +0 -262
- package/dist/es2019/pm-plugins/context-identifier.js +0 -43
- package/dist/es2019/pm-plugins/scroll-gutter/plugin-deprecated.js +0 -244
- package/dist/esm/pm-plugins/context-identifier.js +0 -48
- package/dist/esm/pm-plugins/scroll-gutter/plugin-deprecated.js +0 -256
- package/dist/types/pm-plugins/context-identifier.d.ts +0 -12
- package/dist/types/pm-plugins/scroll-gutter/plugin-deprecated.d.ts +0 -22
- package/dist/types-ts4.5/pm-plugins/context-identifier.d.ts +0 -12
- package/dist/types-ts4.5/pm-plugins/scroll-gutter/plugin-deprecated.d.ts +0 -22
|
@@ -8,7 +8,6 @@ import { countNodes, getAnalyticsEventSeverity, isPerformanceAPIAvailable, isPer
|
|
|
8
8
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
9
9
|
import { setInteractionType } from '../utils/frozen-editor';
|
|
10
10
|
import InputLatencyTracker from '../utils/input-latency-tracking';
|
|
11
|
-
import { getContextIdentifier } from './context-identifier';
|
|
12
11
|
export var frozenEditorPluginKey = new PluginKey('frozenEditor');
|
|
13
12
|
var DEFAULT_KEYSTROKE_SAMPLING_LIMIT = 100;
|
|
14
13
|
var DEFAULT_SLOW_THRESHOLD = 300;
|
|
@@ -18,234 +17,238 @@ export var DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
|
18
17
|
var DEFAULT_TRACK_SEVERITY_ENABLED = false;
|
|
19
18
|
export var DEFAULT_TRACK_SEVERITY_THRESHOLD_NORMAL = 100;
|
|
20
19
|
export var DEFAULT_TRACK_SEVERITY_THRESHOLD_DEGRADED = 500;
|
|
21
|
-
var dispatchLongTaskEvent = function dispatchLongTaskEvent(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
20
|
+
var dispatchLongTaskEvent = function dispatchLongTaskEvent(contextIdentifierPlugin) {
|
|
21
|
+
return function (dispatchAnalyticsEvent, view, time, getNodeCount, interactionType, severity) {
|
|
22
|
+
var _contextIdentifierPlu;
|
|
23
|
+
var state = view.state;
|
|
24
|
+
var nodesCount = getNodeCount(state);
|
|
25
|
+
return dispatchAnalyticsEvent({
|
|
26
|
+
action: ACTION.BROWSER_FREEZE,
|
|
27
|
+
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
28
|
+
attributes: _objectSpread(_objectSpread({
|
|
29
|
+
objectId: contextIdentifierPlugin === null || contextIdentifierPlugin === void 0 || (_contextIdentifierPlu = contextIdentifierPlugin.sharedState.currentState()) === null || _contextIdentifierPlu === void 0 || (_contextIdentifierPlu = _contextIdentifierPlu.contextIdentifierProvider) === null || _contextIdentifierPlu === void 0 ? void 0 : _contextIdentifierPlu.objectId,
|
|
30
|
+
freezeTime: time,
|
|
31
|
+
nodeSize: state.doc.nodeSize
|
|
32
|
+
}, nodesCount), {}, {
|
|
33
|
+
interactionType: interactionType,
|
|
34
|
+
severity: severity
|
|
35
|
+
}),
|
|
36
|
+
eventType: EVENT_TYPE.OPERATIONAL
|
|
37
|
+
});
|
|
38
|
+
};
|
|
38
39
|
};
|
|
39
|
-
export default (function (
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
40
|
+
export default (function (contextIdentifierPlugin) {
|
|
41
|
+
return function (dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, ufo) {
|
|
42
|
+
var interactionType;
|
|
43
|
+
var inputLatencyTracker = null;
|
|
44
|
+
var inputLatencySingleKeyTracker = null;
|
|
45
|
+
var inputLatencyRenderedTracker = null;
|
|
46
|
+
if (browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackInteractionType) {
|
|
47
|
+
interactionType = setInteractionType(BROWSER_FREEZE_INTERACTION_TYPE.LOADING);
|
|
48
|
+
}
|
|
49
|
+
var samplingRate = inputTracking && typeof inputTracking.samplingRate === 'number' ? inputTracking.samplingRate : DEFAULT_KEYSTROKE_SAMPLING_LIMIT;
|
|
50
|
+
var slowThreshold = inputTracking && typeof inputTracking.slowThreshold === 'number' ? inputTracking.slowThreshold : DEFAULT_SLOW_THRESHOLD;
|
|
51
|
+
var freezeThreshold = inputTracking && typeof inputTracking.freezeThreshold === 'number' ? inputTracking.freezeThreshold : DEFAULT_FREEZE_THRESHOLD;
|
|
52
|
+
var allowCountNodes = inputTracking && inputTracking.countNodes;
|
|
53
|
+
var prevNodeCountState = null;
|
|
54
|
+
var prevNodeCount = {};
|
|
53
55
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
// Cache the result as we were calling this multiple times
|
|
57
|
+
// and has potential to be expensive
|
|
58
|
+
var getNodeCount = function getNodeCount(state) {
|
|
59
|
+
if (state === prevNodeCountState) {
|
|
60
|
+
return prevNodeCount;
|
|
61
|
+
}
|
|
62
|
+
prevNodeCount = allowCountNodes ? countNodes(state) : {};
|
|
63
|
+
prevNodeCountState = state;
|
|
58
64
|
return prevNodeCount;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}),
|
|
82
|
-
eventType: EVENT_TYPE.OPERATIONAL
|
|
65
|
+
};
|
|
66
|
+
var shouldTrackSeverity = (inputTracking === null || inputTracking === void 0 ? void 0 : inputTracking.trackSeverity) || DEFAULT_TRACK_SEVERITY_ENABLED;
|
|
67
|
+
var severityThresholdNormal = (inputTracking === null || inputTracking === void 0 ? void 0 : inputTracking.severityNormalThreshold) || DEFAULT_TRACK_SEVERITY_THRESHOLD_NORMAL;
|
|
68
|
+
var severityThresholdDegraded = (inputTracking === null || inputTracking === void 0 ? void 0 : inputTracking.severityDegradedThreshold) || DEFAULT_TRACK_SEVERITY_THRESHOLD_DEGRADED;
|
|
69
|
+
var createDispatchSample = function createDispatchSample(action, view) {
|
|
70
|
+
return function (time, severity) {
|
|
71
|
+
var _contextIdentifierPlu2;
|
|
72
|
+
var state = view.state;
|
|
73
|
+
var nodesCount = getNodeCount(state);
|
|
74
|
+
var samplePayload = {
|
|
75
|
+
action: action,
|
|
76
|
+
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
77
|
+
attributes: _objectSpread(_objectSpread({
|
|
78
|
+
time: time,
|
|
79
|
+
nodeSize: state.doc.nodeSize
|
|
80
|
+
}, nodesCount), {}, {
|
|
81
|
+
objectId: contextIdentifierPlugin === null || contextIdentifierPlugin === void 0 || (_contextIdentifierPlu2 = contextIdentifierPlugin.sharedState.currentState()) === null || _contextIdentifierPlu2 === void 0 || (_contextIdentifierPlu2 = _contextIdentifierPlu2.contextIdentifierProvider) === null || _contextIdentifierPlu2 === void 0 ? void 0 : _contextIdentifierPlu2.objectId,
|
|
82
|
+
severity: shouldTrackSeverity ? severity : undefined
|
|
83
|
+
}),
|
|
84
|
+
eventType: EVENT_TYPE.OPERATIONAL
|
|
85
|
+
};
|
|
86
|
+
dispatchAnalyticsEvent(samplePayload);
|
|
83
87
|
};
|
|
84
|
-
dispatchAnalyticsEvent(samplePayload);
|
|
85
88
|
};
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
89
|
+
var createDispatchAverage = function createDispatchAverage(action, view) {
|
|
90
|
+
return function (_ref, severity) {
|
|
91
|
+
var _contextIdentifierPlu3;
|
|
92
|
+
var mean = _ref.mean,
|
|
93
|
+
median = _ref.median,
|
|
94
|
+
sampleSize = _ref.sampleSize;
|
|
95
|
+
var state = view.state;
|
|
96
|
+
var nodeCount = getNodeCount(state);
|
|
97
|
+
var averagePayload = {
|
|
98
|
+
action: action,
|
|
99
|
+
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
100
|
+
attributes: _objectSpread(_objectSpread({
|
|
101
|
+
mean: mean,
|
|
102
|
+
median: median,
|
|
103
|
+
sampleSize: sampleSize
|
|
104
|
+
}, nodeCount), {}, {
|
|
105
|
+
nodeSize: state.doc.nodeSize,
|
|
106
|
+
severity: shouldTrackSeverity ? severity : undefined,
|
|
107
|
+
objectId: contextIdentifierPlugin === null || contextIdentifierPlugin === void 0 || (_contextIdentifierPlu3 = contextIdentifierPlugin.sharedState.currentState()) === null || _contextIdentifierPlu3 === void 0 || (_contextIdentifierPlu3 = _contextIdentifierPlu3.contextIdentifierProvider) === null || _contextIdentifierPlu3 === void 0 ? void 0 : _contextIdentifierPlu3.objectId
|
|
108
|
+
}),
|
|
109
|
+
eventType: EVENT_TYPE.OPERATIONAL
|
|
110
|
+
};
|
|
111
|
+
dispatchAnalyticsEvent(averagePayload);
|
|
108
112
|
};
|
|
109
|
-
dispatchAnalyticsEvent(averagePayload);
|
|
110
113
|
};
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
var end = inputLatencyTracker.start();
|
|
114
|
+
return new SafePlugin({
|
|
115
|
+
key: frozenEditorPluginKey,
|
|
116
|
+
props: isPerformanceAPIAvailable() ? {
|
|
117
|
+
handleTextInput: function handleTextInput(view) {
|
|
118
|
+
if (browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackInteractionType) {
|
|
119
|
+
interactionType = BROWSER_FREEZE_INTERACTION_TYPE.TYPING;
|
|
120
|
+
}
|
|
121
|
+
if (inputLatencyTracker) {
|
|
122
|
+
var end = inputLatencyTracker.start();
|
|
121
123
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
124
|
+
// This is called after all handleTextInput events are executed which means first handleTextInput time incorporates following handleTextInput processing time
|
|
125
|
+
// Also this is called before browser rendering so it doesn't count it.
|
|
126
|
+
requestAnimationFrame(end);
|
|
127
|
+
}
|
|
128
|
+
if (inputLatencySingleKeyTracker) {
|
|
129
|
+
var _end = inputLatencySingleKeyTracker.start();
|
|
128
130
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
131
|
+
// This is executed before next handleTextInput when multiple keypress events are in one animation frame
|
|
132
|
+
// so it tracks individual keypress processing time
|
|
133
|
+
Promise.resolve().then(_end);
|
|
134
|
+
}
|
|
135
|
+
if (inputLatencyRenderedTracker) {
|
|
136
|
+
var _end2 = inputLatencyRenderedTracker.start();
|
|
135
137
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
return false;
|
|
140
|
-
},
|
|
141
|
-
handleDOMEvents: browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackInteractionType ? {
|
|
142
|
-
click: function click() {
|
|
143
|
-
interactionType = setInteractionType(BROWSER_FREEZE_INTERACTION_TYPE.CLICKING);
|
|
138
|
+
// This is called at the next event loop so it counts browser rendering time.
|
|
139
|
+
setTimeout(_end2);
|
|
140
|
+
}
|
|
144
141
|
return false;
|
|
145
142
|
},
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
} : undefined
|
|
151
|
-
} : undefined,
|
|
152
|
-
view: function view(_view) {
|
|
153
|
-
if (!isPerformanceObserverAvailable()) {
|
|
154
|
-
return {};
|
|
155
|
-
}
|
|
156
|
-
var experienceStore = ufo ? ExperienceStore.getInstance(_view) : undefined;
|
|
157
|
-
if (inputTracking !== null && inputTracking !== void 0 && inputTracking.enabled) {
|
|
158
|
-
inputLatencyTracker = new InputLatencyTracker({
|
|
159
|
-
samplingRate: samplingRate,
|
|
160
|
-
slowThreshold: slowThreshold,
|
|
161
|
-
normalThreshold: severityThresholdNormal,
|
|
162
|
-
degradedThreshold: severityThresholdDegraded,
|
|
163
|
-
onSampleStart: function onSampleStart() {
|
|
164
|
-
experienceStore === null || experienceStore === void 0 || experienceStore.start(EditorExperience.typing);
|
|
165
|
-
},
|
|
166
|
-
onSampleEnd: function onSampleEnd(time, _ref2) {
|
|
167
|
-
var _getContextIdentifier4;
|
|
168
|
-
var isSlow = _ref2.isSlow,
|
|
169
|
-
severity = _ref2.severity;
|
|
170
|
-
var state = _view.state;
|
|
171
|
-
var nodesCount = getNodeCount(state);
|
|
172
|
-
if (isSlow) {
|
|
173
|
-
experienceStore === null || experienceStore === void 0 || experienceStore.addMetadata(EditorExperience.typing, {
|
|
174
|
-
slowInput: true
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
experienceStore === null || experienceStore === void 0 || experienceStore.success(EditorExperience.typing, _objectSpread(_objectSpread({
|
|
178
|
-
nodeSize: state.doc.nodeSize
|
|
179
|
-
}, nodesCount), {}, {
|
|
180
|
-
objectId: (_getContextIdentifier4 = getContextIdentifier(state)) === null || _getContextIdentifier4 === void 0 ? void 0 : _getContextIdentifier4.objectId,
|
|
181
|
-
time: time,
|
|
182
|
-
severity: shouldTrackSeverity ? severity : undefined
|
|
183
|
-
}));
|
|
143
|
+
handleDOMEvents: browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackInteractionType ? {
|
|
144
|
+
click: function click() {
|
|
145
|
+
interactionType = setInteractionType(BROWSER_FREEZE_INTERACTION_TYPE.CLICKING);
|
|
146
|
+
return false;
|
|
184
147
|
},
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
148
|
+
paste: function paste() {
|
|
149
|
+
interactionType = setInteractionType(BROWSER_FREEZE_INTERACTION_TYPE.PASTING);
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
} : undefined
|
|
153
|
+
} : undefined,
|
|
154
|
+
view: function view(_view) {
|
|
155
|
+
if (!isPerformanceObserverAvailable()) {
|
|
156
|
+
return {};
|
|
157
|
+
}
|
|
158
|
+
var experienceStore = ufo ? ExperienceStore.getInstance(_view) : undefined;
|
|
159
|
+
if (inputTracking !== null && inputTracking !== void 0 && inputTracking.enabled) {
|
|
160
|
+
inputLatencyTracker = new InputLatencyTracker({
|
|
161
|
+
samplingRate: samplingRate,
|
|
162
|
+
slowThreshold: slowThreshold,
|
|
163
|
+
normalThreshold: severityThresholdNormal,
|
|
164
|
+
degradedThreshold: severityThresholdDegraded,
|
|
165
|
+
onSampleStart: function onSampleStart() {
|
|
166
|
+
experienceStore === null || experienceStore === void 0 || experienceStore.start(EditorExperience.typing);
|
|
167
|
+
},
|
|
168
|
+
onSampleEnd: function onSampleEnd(time, _ref2) {
|
|
169
|
+
var _contextIdentifierPlu4;
|
|
170
|
+
var isSlow = _ref2.isSlow,
|
|
171
|
+
severity = _ref2.severity;
|
|
172
|
+
var state = _view.state;
|
|
173
|
+
var nodesCount = getNodeCount(state);
|
|
174
|
+
if (isSlow) {
|
|
175
|
+
experienceStore === null || experienceStore === void 0 || experienceStore.addMetadata(EditorExperience.typing, {
|
|
176
|
+
slowInput: true
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
experienceStore === null || experienceStore === void 0 || experienceStore.success(EditorExperience.typing, _objectSpread(_objectSpread({
|
|
196
180
|
nodeSize: state.doc.nodeSize
|
|
197
181
|
}, nodesCount), {}, {
|
|
198
|
-
objectId: (
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
degradedThreshold: severityThresholdDegraded,
|
|
221
|
-
dispatchSample: createDispatchSample(ACTION.INPUT_PERF_SAMPLING_RENDERED, _view),
|
|
222
|
-
dispatchAverage: createDispatchAverage(ACTION.INPUT_PERF_SAMPLING_RENDERED_AVG, _view)
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
var observer;
|
|
226
|
-
try {
|
|
227
|
-
observer = new PerformanceObserver(function (list) {
|
|
228
|
-
var perfEntries = list.getEntries();
|
|
229
|
-
for (var i = 0; i < perfEntries.length; i++) {
|
|
230
|
-
var duration = perfEntries[i].duration;
|
|
231
|
-
if (duration > freezeThreshold) {
|
|
232
|
-
dispatchLongTaskEvent(dispatchAnalyticsEvent, _view, duration, getNodeCount, browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackInteractionType ? interactionType : undefined, browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackSeverity ? getAnalyticsEventSeverity(duration, browserFreezeTracking.severityNormalThreshold || NORMAL_SEVERITY_THRESHOLD, browserFreezeTracking.severityDegradedThreshold || DEGRADED_SEVERITY_THRESHOLD) : undefined);
|
|
182
|
+
objectId: contextIdentifierPlugin === null || contextIdentifierPlugin === void 0 || (_contextIdentifierPlu4 = contextIdentifierPlugin.sharedState.currentState()) === null || _contextIdentifierPlu4 === void 0 || (_contextIdentifierPlu4 = _contextIdentifierPlu4.contextIdentifierProvider) === null || _contextIdentifierPlu4 === void 0 ? void 0 : _contextIdentifierPlu4.objectId,
|
|
183
|
+
time: time,
|
|
184
|
+
severity: shouldTrackSeverity ? severity : undefined
|
|
185
|
+
}));
|
|
186
|
+
},
|
|
187
|
+
dispatchSample: createDispatchSample(ACTION.INPUT_PERF_SAMPLING, _view),
|
|
188
|
+
dispatchAverage: createDispatchAverage(ACTION.INPUT_PERF_SAMPLING_AVG, _view),
|
|
189
|
+
onSlowInput: function onSlowInput(time) {
|
|
190
|
+
var _contextIdentifierPlu5;
|
|
191
|
+
var state = _view.state;
|
|
192
|
+
var nodesCount = getNodeCount(state);
|
|
193
|
+
dispatchAnalyticsEvent({
|
|
194
|
+
action: ACTION.SLOW_INPUT,
|
|
195
|
+
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
196
|
+
attributes: _objectSpread(_objectSpread({
|
|
197
|
+
time: time,
|
|
198
|
+
nodeSize: state.doc.nodeSize
|
|
199
|
+
}, nodesCount), {}, {
|
|
200
|
+
objectId: contextIdentifierPlugin === null || contextIdentifierPlugin === void 0 || (_contextIdentifierPlu5 = contextIdentifierPlugin.sharedState.currentState()) === null || _contextIdentifierPlu5 === void 0 || (_contextIdentifierPlu5 = _contextIdentifierPlu5.contextIdentifierProvider) === null || _contextIdentifierPlu5 === void 0 ? void 0 : _contextIdentifierPlu5.objectId
|
|
201
|
+
}),
|
|
202
|
+
eventType: EVENT_TYPE.OPERATIONAL
|
|
203
|
+
});
|
|
233
204
|
}
|
|
234
|
-
}
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
// register observer for long task notifications
|
|
238
|
-
observer.observe({
|
|
239
|
-
entryTypes: ['longtask']
|
|
240
|
-
});
|
|
241
|
-
} catch (e) {}
|
|
242
|
-
return {
|
|
243
|
-
destroy: function destroy() {
|
|
244
|
-
var _inputLatencyTracker, _observer;
|
|
245
|
-
(_inputLatencyTracker = inputLatencyTracker) === null || _inputLatencyTracker === void 0 || _inputLatencyTracker.flush();
|
|
246
|
-
(_observer = observer) === null || _observer === void 0 || _observer.disconnect();
|
|
205
|
+
});
|
|
247
206
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
207
|
+
if (inputTracking !== null && inputTracking !== void 0 && inputTracking.trackSingleKeypress) {
|
|
208
|
+
inputLatencySingleKeyTracker = new InputLatencyTracker({
|
|
209
|
+
samplingRate: samplingRate,
|
|
210
|
+
slowThreshold: slowThreshold,
|
|
211
|
+
normalThreshold: severityThresholdNormal,
|
|
212
|
+
degradedThreshold: severityThresholdDegraded,
|
|
213
|
+
dispatchSample: createDispatchSample(ACTION.INPUT_PERF_SAMPLING_SINGLE_KEYPRESS, _view),
|
|
214
|
+
dispatchAverage: createDispatchAverage(ACTION.INPUT_PERF_SAMPLING_SINGLE_KEYPRESS_AVG, _view)
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
if (inputTracking !== null && inputTracking !== void 0 && inputTracking.trackRenderingTime) {
|
|
218
|
+
inputLatencyRenderedTracker = new InputLatencyTracker({
|
|
219
|
+
samplingRate: samplingRate,
|
|
220
|
+
slowThreshold: slowThreshold,
|
|
221
|
+
normalThreshold: severityThresholdNormal,
|
|
222
|
+
degradedThreshold: severityThresholdDegraded,
|
|
223
|
+
dispatchSample: createDispatchSample(ACTION.INPUT_PERF_SAMPLING_RENDERED, _view),
|
|
224
|
+
dispatchAverage: createDispatchAverage(ACTION.INPUT_PERF_SAMPLING_RENDERED_AVG, _view)
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
var observer;
|
|
228
|
+
try {
|
|
229
|
+
observer = new PerformanceObserver(function (list) {
|
|
230
|
+
var perfEntries = list.getEntries();
|
|
231
|
+
for (var i = 0; i < perfEntries.length; i++) {
|
|
232
|
+
var duration = perfEntries[i].duration;
|
|
233
|
+
if (duration > freezeThreshold) {
|
|
234
|
+
dispatchLongTaskEvent(contextIdentifierPlugin)(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);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
// register observer for long task notifications
|
|
240
|
+
observer.observe({
|
|
241
|
+
entryTypes: ['longtask']
|
|
242
|
+
});
|
|
243
|
+
} catch (e) {}
|
|
244
|
+
return {
|
|
245
|
+
destroy: function destroy() {
|
|
246
|
+
var _inputLatencyTracker, _observer;
|
|
247
|
+
(_inputLatencyTracker = inputLatencyTracker) === null || _inputLatencyTracker === void 0 || _inputLatencyTracker.flush();
|
|
248
|
+
(_observer = observer) === null || _observer === void 0 || _observer.disconnect();
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
};
|
|
251
254
|
});
|
|
@@ -210,7 +210,7 @@ export default (function () {
|
|
|
210
210
|
gutter.addGutter(editorParentElement);
|
|
211
211
|
}
|
|
212
212
|
};
|
|
213
|
-
var toggleGutter = function toggleGutter(
|
|
213
|
+
var toggleGutter = function toggleGutter(contentSize, threshold) {
|
|
214
214
|
if (pluginOptions.persistScrollGutter) {
|
|
215
215
|
if (!isEmptyDocument(view.state.doc)) {
|
|
216
216
|
addAndObserveGutter();
|
|
@@ -223,8 +223,7 @@ export default (function () {
|
|
|
223
223
|
// Add or remove the gutter based on whether the content is about to exceed the viewport height.
|
|
224
224
|
// We do this to ensure there is sufficient white space below the last content node in order to
|
|
225
225
|
// see any UI control elements which may sit beneath it.
|
|
226
|
-
|
|
227
|
-
if (contentSize >= gutterThresholdHeight) {
|
|
226
|
+
if (contentSize >= threshold) {
|
|
228
227
|
addAndObserveGutter();
|
|
229
228
|
} else {
|
|
230
229
|
if (gutter.isMounted()) {
|
|
@@ -252,7 +251,7 @@ export default (function () {
|
|
|
252
251
|
} finally {
|
|
253
252
|
_iterator.f();
|
|
254
253
|
}
|
|
255
|
-
toggleGutter(
|
|
254
|
+
toggleGutter(contentElementHeight, viewportElementHeight);
|
|
256
255
|
};
|
|
257
256
|
|
|
258
257
|
// Subscribe to updates of the height of the viewport and content elements
|
|
@@ -282,7 +281,8 @@ export default (function () {
|
|
|
282
281
|
// No need to recheck if the selected node hasn't changed.
|
|
283
282
|
return;
|
|
284
283
|
}
|
|
285
|
-
|
|
284
|
+
var gutterThresholdHeight = viewportElementHeight - gutterSize;
|
|
285
|
+
toggleGutter(contentElementHeight, gutterThresholdHeight);
|
|
286
286
|
}
|
|
287
287
|
};
|
|
288
288
|
})
|
package/dist/types/plugin.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ContextIdentifierProvider } from '@atlaskit/editor-common/provider-factory';
|
|
2
1
|
import type { BrowserFreezetracking, InputTracking, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { ContextIdentifierPlugin } from '@atlaskit/editor-plugin-context-identifier';
|
|
3
3
|
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
4
4
|
import { setKeyboardHeight } from './commands';
|
|
5
5
|
import type { ScrollGutterPluginOptions } from './pm-plugins/scroll-gutter';
|
|
@@ -11,13 +11,15 @@ export interface BasePluginOptions {
|
|
|
11
11
|
ufo?: boolean;
|
|
12
12
|
}
|
|
13
13
|
export type BasePluginState = {
|
|
14
|
-
contextIdentifier: ContextIdentifierProvider | undefined;
|
|
15
14
|
/** Current height of keyboard (+ custom toolbar) in iOS app */
|
|
16
15
|
keyboardHeight: number | undefined;
|
|
17
16
|
};
|
|
18
17
|
export type BasePlugin = NextEditorPlugin<'base', {
|
|
19
18
|
pluginConfiguration: BasePluginOptions | undefined;
|
|
20
|
-
dependencies: [
|
|
19
|
+
dependencies: [
|
|
20
|
+
OptionalPlugin<FeatureFlagsPlugin>,
|
|
21
|
+
OptionalPlugin<ContextIdentifierPlugin>
|
|
22
|
+
];
|
|
21
23
|
sharedState: BasePluginState;
|
|
22
24
|
actions: {
|
|
23
25
|
setKeyboardHeight: typeof setKeyboardHeight;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
-
import type { BrowserFreezetracking, InputTracking } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { BrowserFreezetracking, ExtractInjectionAPI, InputTracking } from '@atlaskit/editor-common/types';
|
|
4
4
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
+
import type { BasePlugin } from '../index';
|
|
5
6
|
export declare const frozenEditorPluginKey: PluginKey<any>;
|
|
6
7
|
export declare const DEFAULT_FREEZE_THRESHOLD = 600;
|
|
7
8
|
export declare const NORMAL_SEVERITY_THRESHOLD = 2000;
|
|
8
9
|
export declare const DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
9
10
|
export declare const DEFAULT_TRACK_SEVERITY_THRESHOLD_NORMAL = 100;
|
|
10
11
|
export declare const DEFAULT_TRACK_SEVERITY_THRESHOLD_DEGRADED = 500;
|
|
11
|
-
declare const _default: (dispatchAnalyticsEvent: DispatchAnalyticsEvent, inputTracking?: InputTracking, browserFreezeTracking?: BrowserFreezetracking, ufo?: boolean) => SafePlugin<any>;
|
|
12
|
+
declare const _default: (contextIdentifierPlugin: ExtractInjectionAPI<BasePlugin>['contextIdentifier'] | undefined) => (dispatchAnalyticsEvent: DispatchAnalyticsEvent, inputTracking?: InputTracking, browserFreezeTracking?: BrowserFreezetracking, ufo?: boolean) => SafePlugin<any>;
|
|
12
13
|
export default _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ContextIdentifierProvider } from '@atlaskit/editor-common/provider-factory';
|
|
2
1
|
import type { BrowserFreezetracking, InputTracking, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { ContextIdentifierPlugin } from '@atlaskit/editor-plugin-context-identifier';
|
|
3
3
|
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
4
4
|
import { setKeyboardHeight } from './commands';
|
|
5
5
|
import type { ScrollGutterPluginOptions } from './pm-plugins/scroll-gutter';
|
|
@@ -11,14 +11,14 @@ export interface BasePluginOptions {
|
|
|
11
11
|
ufo?: boolean;
|
|
12
12
|
}
|
|
13
13
|
export type BasePluginState = {
|
|
14
|
-
contextIdentifier: ContextIdentifierProvider | undefined;
|
|
15
14
|
/** Current height of keyboard (+ custom toolbar) in iOS app */
|
|
16
15
|
keyboardHeight: number | undefined;
|
|
17
16
|
};
|
|
18
17
|
export type BasePlugin = NextEditorPlugin<'base', {
|
|
19
18
|
pluginConfiguration: BasePluginOptions | undefined;
|
|
20
19
|
dependencies: [
|
|
21
|
-
OptionalPlugin<FeatureFlagsPlugin
|
|
20
|
+
OptionalPlugin<FeatureFlagsPlugin>,
|
|
21
|
+
OptionalPlugin<ContextIdentifierPlugin>
|
|
22
22
|
];
|
|
23
23
|
sharedState: BasePluginState;
|
|
24
24
|
actions: {
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
-
import type { BrowserFreezetracking, InputTracking } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { BrowserFreezetracking, ExtractInjectionAPI, InputTracking } from '@atlaskit/editor-common/types';
|
|
4
4
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
+
import type { BasePlugin } from '../index';
|
|
5
6
|
export declare const frozenEditorPluginKey: PluginKey<any>;
|
|
6
7
|
export declare const DEFAULT_FREEZE_THRESHOLD = 600;
|
|
7
8
|
export declare const NORMAL_SEVERITY_THRESHOLD = 2000;
|
|
8
9
|
export declare const DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
9
10
|
export declare const DEFAULT_TRACK_SEVERITY_THRESHOLD_NORMAL = 100;
|
|
10
11
|
export declare const DEFAULT_TRACK_SEVERITY_THRESHOLD_DEGRADED = 500;
|
|
11
|
-
declare const _default: (dispatchAnalyticsEvent: DispatchAnalyticsEvent, inputTracking?: InputTracking, browserFreezeTracking?: BrowserFreezetracking, ufo?: boolean) => SafePlugin<any>;
|
|
12
|
+
declare const _default: (contextIdentifierPlugin: ExtractInjectionAPI<BasePlugin>['contextIdentifier'] | undefined) => (dispatchAnalyticsEvent: DispatchAnalyticsEvent, inputTracking?: InputTracking, browserFreezeTracking?: BrowserFreezetracking, ufo?: boolean) => SafePlugin<any>;
|
|
12
13
|
export default _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-base",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"description": "Base plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,19 +33,19 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@atlaskit/adf-schema": "^35.3.0",
|
|
36
|
-
"@atlaskit/editor-common": "^77.
|
|
36
|
+
"@atlaskit/editor-common": "^77.1.0",
|
|
37
|
+
"@atlaskit/editor-plugin-context-identifier": "^0.1.0",
|
|
37
38
|
"@atlaskit/editor-plugin-feature-flags": "^1.0.1",
|
|
38
39
|
"@atlaskit/editor-prosemirror": "1.1.0",
|
|
39
|
-
"@atlaskit/platform-feature-flags": "^0.2.0",
|
|
40
40
|
"@babel/runtime": "^7.0.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@atlaskit/editor-plugin-analytics": "^0.4.0",
|
|
44
44
|
"@atlaskit/editor-plugin-content-insertion": "^0.1.0",
|
|
45
|
-
"@atlaskit/editor-plugin-emoji": "^1.
|
|
45
|
+
"@atlaskit/editor-plugin-emoji": "^1.1.0",
|
|
46
46
|
"@atlaskit/editor-plugin-guideline": "^0.5.0",
|
|
47
47
|
"@atlaskit/editor-plugin-selection": "^0.2.0",
|
|
48
|
-
"@atlaskit/editor-plugin-table": "^
|
|
48
|
+
"@atlaskit/editor-plugin-table": "^7.1.0",
|
|
49
49
|
"@atlaskit/editor-plugin-type-ahead": "^0.9.0",
|
|
50
50
|
"@atlaskit/editor-plugin-width": "^0.2.0",
|
|
51
51
|
"@atlaskit/util-data-test": "^17.8.0",
|
|
@@ -86,11 +86,6 @@
|
|
|
86
86
|
}
|
|
87
87
|
},
|
|
88
88
|
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0",
|
|
89
|
-
"platform-feature-flags": {
|
|
90
|
-
"platform.editor.scroll-gutter.reflow-optimisation": {
|
|
91
|
-
"type": "boolean"
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
89
|
"stricter": {
|
|
95
90
|
"no-unused-dependencies": {
|
|
96
91
|
"checkDevDependencies": true
|