@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
|
@@ -5,7 +5,6 @@ import { countNodes, getAnalyticsEventSeverity, isPerformanceAPIAvailable, isPer
|
|
|
5
5
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
6
6
|
import { setInteractionType } from '../utils/frozen-editor';
|
|
7
7
|
import InputLatencyTracker from '../utils/input-latency-tracking';
|
|
8
|
-
import { getContextIdentifier } from './context-identifier';
|
|
9
8
|
export const frozenEditorPluginKey = new PluginKey('frozenEditor');
|
|
10
9
|
const DEFAULT_KEYSTROKE_SAMPLING_LIMIT = 100;
|
|
11
10
|
const DEFAULT_SLOW_THRESHOLD = 300;
|
|
@@ -15,8 +14,8 @@ export const DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
|
15
14
|
const DEFAULT_TRACK_SEVERITY_ENABLED = false;
|
|
16
15
|
export const DEFAULT_TRACK_SEVERITY_THRESHOLD_NORMAL = 100;
|
|
17
16
|
export const DEFAULT_TRACK_SEVERITY_THRESHOLD_DEGRADED = 500;
|
|
18
|
-
const dispatchLongTaskEvent = (dispatchAnalyticsEvent, view, time, getNodeCount, interactionType, severity) => {
|
|
19
|
-
var
|
|
17
|
+
const dispatchLongTaskEvent = contextIdentifierPlugin => (dispatchAnalyticsEvent, view, time, getNodeCount, interactionType, severity) => {
|
|
18
|
+
var _contextIdentifierPlu, _contextIdentifierPlu2;
|
|
20
19
|
const {
|
|
21
20
|
state
|
|
22
21
|
} = view;
|
|
@@ -25,7 +24,7 @@ const dispatchLongTaskEvent = (dispatchAnalyticsEvent, view, time, getNodeCount,
|
|
|
25
24
|
action: ACTION.BROWSER_FREEZE,
|
|
26
25
|
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
27
26
|
attributes: {
|
|
28
|
-
objectId: (
|
|
27
|
+
objectId: contextIdentifierPlugin === null || contextIdentifierPlugin === void 0 ? void 0 : (_contextIdentifierPlu = contextIdentifierPlugin.sharedState.currentState()) === null || _contextIdentifierPlu === void 0 ? void 0 : (_contextIdentifierPlu2 = _contextIdentifierPlu.contextIdentifierProvider) === null || _contextIdentifierPlu2 === void 0 ? void 0 : _contextIdentifierPlu2.objectId,
|
|
29
28
|
freezeTime: time,
|
|
30
29
|
nodeSize: state.doc.nodeSize,
|
|
31
30
|
...nodesCount,
|
|
@@ -35,7 +34,7 @@ const dispatchLongTaskEvent = (dispatchAnalyticsEvent, view, time, getNodeCount,
|
|
|
35
34
|
eventType: EVENT_TYPE.OPERATIONAL
|
|
36
35
|
});
|
|
37
36
|
};
|
|
38
|
-
export default ((dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, ufo) => {
|
|
37
|
+
export default (contextIdentifierPlugin => (dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, ufo) => {
|
|
39
38
|
let interactionType;
|
|
40
39
|
let inputLatencyTracker = null;
|
|
41
40
|
let inputLatencySingleKeyTracker = null;
|
|
@@ -64,7 +63,7 @@ export default ((dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, u
|
|
|
64
63
|
const severityThresholdNormal = (inputTracking === null || inputTracking === void 0 ? void 0 : inputTracking.severityNormalThreshold) || DEFAULT_TRACK_SEVERITY_THRESHOLD_NORMAL;
|
|
65
64
|
const severityThresholdDegraded = (inputTracking === null || inputTracking === void 0 ? void 0 : inputTracking.severityDegradedThreshold) || DEFAULT_TRACK_SEVERITY_THRESHOLD_DEGRADED;
|
|
66
65
|
const createDispatchSample = (action, view) => (time, severity) => {
|
|
67
|
-
var
|
|
66
|
+
var _contextIdentifierPlu3, _contextIdentifierPlu4;
|
|
68
67
|
const {
|
|
69
68
|
state
|
|
70
69
|
} = view;
|
|
@@ -76,7 +75,7 @@ export default ((dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, u
|
|
|
76
75
|
time,
|
|
77
76
|
nodeSize: state.doc.nodeSize,
|
|
78
77
|
...nodesCount,
|
|
79
|
-
objectId: (
|
|
78
|
+
objectId: contextIdentifierPlugin === null || contextIdentifierPlugin === void 0 ? void 0 : (_contextIdentifierPlu3 = contextIdentifierPlugin.sharedState.currentState()) === null || _contextIdentifierPlu3 === void 0 ? void 0 : (_contextIdentifierPlu4 = _contextIdentifierPlu3.contextIdentifierProvider) === null || _contextIdentifierPlu4 === void 0 ? void 0 : _contextIdentifierPlu4.objectId,
|
|
80
79
|
severity: shouldTrackSeverity ? severity : undefined
|
|
81
80
|
},
|
|
82
81
|
eventType: EVENT_TYPE.OPERATIONAL
|
|
@@ -88,7 +87,7 @@ export default ((dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, u
|
|
|
88
87
|
median,
|
|
89
88
|
sampleSize
|
|
90
89
|
}, severity) => {
|
|
91
|
-
var
|
|
90
|
+
var _contextIdentifierPlu5, _contextIdentifierPlu6;
|
|
92
91
|
const {
|
|
93
92
|
state
|
|
94
93
|
} = view;
|
|
@@ -103,7 +102,7 @@ export default ((dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, u
|
|
|
103
102
|
...nodeCount,
|
|
104
103
|
nodeSize: state.doc.nodeSize,
|
|
105
104
|
severity: shouldTrackSeverity ? severity : undefined,
|
|
106
|
-
objectId: (
|
|
105
|
+
objectId: contextIdentifierPlugin === null || contextIdentifierPlugin === void 0 ? void 0 : (_contextIdentifierPlu5 = contextIdentifierPlugin.sharedState.currentState()) === null || _contextIdentifierPlu5 === void 0 ? void 0 : (_contextIdentifierPlu6 = _contextIdentifierPlu5.contextIdentifierProvider) === null || _contextIdentifierPlu6 === void 0 ? void 0 : _contextIdentifierPlu6.objectId
|
|
107
106
|
},
|
|
108
107
|
eventType: EVENT_TYPE.OPERATIONAL
|
|
109
108
|
};
|
|
@@ -167,7 +166,7 @@ export default ((dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, u
|
|
|
167
166
|
isSlow,
|
|
168
167
|
severity
|
|
169
168
|
}) => {
|
|
170
|
-
var
|
|
169
|
+
var _contextIdentifierPlu7, _contextIdentifierPlu8;
|
|
171
170
|
const {
|
|
172
171
|
state
|
|
173
172
|
} = view;
|
|
@@ -180,7 +179,7 @@ export default ((dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, u
|
|
|
180
179
|
experienceStore === null || experienceStore === void 0 ? void 0 : experienceStore.success(EditorExperience.typing, {
|
|
181
180
|
nodeSize: state.doc.nodeSize,
|
|
182
181
|
...nodesCount,
|
|
183
|
-
objectId: (
|
|
182
|
+
objectId: contextIdentifierPlugin === null || contextIdentifierPlugin === void 0 ? void 0 : (_contextIdentifierPlu7 = contextIdentifierPlugin.sharedState.currentState()) === null || _contextIdentifierPlu7 === void 0 ? void 0 : (_contextIdentifierPlu8 = _contextIdentifierPlu7.contextIdentifierProvider) === null || _contextIdentifierPlu8 === void 0 ? void 0 : _contextIdentifierPlu8.objectId,
|
|
184
183
|
time,
|
|
185
184
|
severity: shouldTrackSeverity ? severity : undefined
|
|
186
185
|
});
|
|
@@ -188,7 +187,7 @@ export default ((dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, u
|
|
|
188
187
|
dispatchSample: createDispatchSample(ACTION.INPUT_PERF_SAMPLING, view),
|
|
189
188
|
dispatchAverage: createDispatchAverage(ACTION.INPUT_PERF_SAMPLING_AVG, view),
|
|
190
189
|
onSlowInput: time => {
|
|
191
|
-
var
|
|
190
|
+
var _contextIdentifierPlu9, _contextIdentifierPlu10;
|
|
192
191
|
const {
|
|
193
192
|
state
|
|
194
193
|
} = view;
|
|
@@ -200,7 +199,7 @@ export default ((dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, u
|
|
|
200
199
|
time,
|
|
201
200
|
nodeSize: state.doc.nodeSize,
|
|
202
201
|
...nodesCount,
|
|
203
|
-
objectId: (
|
|
202
|
+
objectId: contextIdentifierPlugin === null || contextIdentifierPlugin === void 0 ? void 0 : (_contextIdentifierPlu9 = contextIdentifierPlugin.sharedState.currentState()) === null || _contextIdentifierPlu9 === void 0 ? void 0 : (_contextIdentifierPlu10 = _contextIdentifierPlu9.contextIdentifierProvider) === null || _contextIdentifierPlu10 === void 0 ? void 0 : _contextIdentifierPlu10.objectId
|
|
204
203
|
},
|
|
205
204
|
eventType: EVENT_TYPE.OPERATIONAL
|
|
206
205
|
});
|
|
@@ -236,7 +235,7 @@ export default ((dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, u
|
|
|
236
235
|
duration
|
|
237
236
|
} = perfEntries[i];
|
|
238
237
|
if (duration > freezeThreshold) {
|
|
239
|
-
dispatchLongTaskEvent(dispatchAnalyticsEvent, view, duration, getNodeCount, browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackInteractionType ? interactionType : undefined, browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackSeverity ? getAnalyticsEventSeverity(duration, browserFreezeTracking.severityNormalThreshold || NORMAL_SEVERITY_THRESHOLD, browserFreezeTracking.severityDegradedThreshold || DEGRADED_SEVERITY_THRESHOLD) : undefined);
|
|
238
|
+
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);
|
|
240
239
|
}
|
|
241
240
|
}
|
|
242
241
|
});
|
|
@@ -195,7 +195,7 @@ export default ((pluginOptions = {}) => {
|
|
|
195
195
|
gutter.addGutter(editorParentElement);
|
|
196
196
|
}
|
|
197
197
|
};
|
|
198
|
-
const toggleGutter = (
|
|
198
|
+
const toggleGutter = (contentSize, threshold) => {
|
|
199
199
|
if (pluginOptions.persistScrollGutter) {
|
|
200
200
|
if (!isEmptyDocument(view.state.doc)) {
|
|
201
201
|
addAndObserveGutter();
|
|
@@ -208,8 +208,7 @@ export default ((pluginOptions = {}) => {
|
|
|
208
208
|
// Add or remove the gutter based on whether the content is about to exceed the viewport height.
|
|
209
209
|
// We do this to ensure there is sufficient white space below the last content node in order to
|
|
210
210
|
// see any UI control elements which may sit beneath it.
|
|
211
|
-
|
|
212
|
-
if (contentSize >= gutterThresholdHeight) {
|
|
211
|
+
if (contentSize >= threshold) {
|
|
213
212
|
addAndObserveGutter();
|
|
214
213
|
} else {
|
|
215
214
|
if (gutter.isMounted()) {
|
|
@@ -228,7 +227,7 @@ export default ((pluginOptions = {}) => {
|
|
|
228
227
|
contentElementHeight = elementHeight - (gutter.isMounted() ? gutterSize : 0);
|
|
229
228
|
}
|
|
230
229
|
}
|
|
231
|
-
toggleGutter(
|
|
230
|
+
toggleGutter(contentElementHeight, viewportElementHeight);
|
|
232
231
|
};
|
|
233
232
|
|
|
234
233
|
// Subscribe to updates of the height of the viewport and content elements
|
|
@@ -258,7 +257,8 @@ export default ((pluginOptions = {}) => {
|
|
|
258
257
|
// No need to recheck if the selected node hasn't changed.
|
|
259
258
|
return;
|
|
260
259
|
}
|
|
261
|
-
|
|
260
|
+
const gutterThresholdHeight = viewportElementHeight - gutterSize;
|
|
261
|
+
toggleGutter(contentElementHeight, gutterThresholdHeight);
|
|
262
262
|
}
|
|
263
263
|
};
|
|
264
264
|
}
|
package/dist/esm/plugin.js
CHANGED
|
@@ -5,16 +5,13 @@ import { doc, paragraph, text } from '@atlaskit/adf-schema';
|
|
|
5
5
|
import { keymap } from '@atlaskit/editor-common/keymaps';
|
|
6
6
|
import { baseKeymap } from '@atlaskit/editor-prosemirror/commands';
|
|
7
7
|
import { history } from '@atlaskit/editor-prosemirror/history';
|
|
8
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
9
8
|
import { setKeyboardHeight } from './commands';
|
|
10
|
-
import contextIdentifierPlugin, { getContextIdentifier } from './pm-plugins/context-identifier';
|
|
11
9
|
import disableSpellcheckingPlugin from './pm-plugins/disable-spell-checking';
|
|
12
10
|
import filterStepsPlugin from './pm-plugins/filter-steps';
|
|
13
11
|
import frozenEditor from './pm-plugins/frozen-editor';
|
|
14
12
|
import inlineCursorTargetPlugin from './pm-plugins/inline-cursor-target';
|
|
15
13
|
import newlinePreserveMarksPlugin from './pm-plugins/newline-preserve-marks';
|
|
16
14
|
import scrollGutter, { getKeyboardHeight } from './pm-plugins/scroll-gutter';
|
|
17
|
-
import deprecatedScrollGutter from './pm-plugins/scroll-gutter/plugin-deprecated';
|
|
18
15
|
var basePlugin = function basePlugin(_ref) {
|
|
19
16
|
var _api$featureFlags;
|
|
20
17
|
var options = _ref.config,
|
|
@@ -24,7 +21,6 @@ var basePlugin = function basePlugin(_ref) {
|
|
|
24
21
|
name: 'base',
|
|
25
22
|
getSharedState: function getSharedState(editorState) {
|
|
26
23
|
return {
|
|
27
|
-
contextIdentifier: getContextIdentifier(editorState),
|
|
28
24
|
keyboardHeight: getKeyboardHeight(editorState)
|
|
29
25
|
};
|
|
30
26
|
},
|
|
@@ -65,7 +61,7 @@ var basePlugin = function basePlugin(_ref) {
|
|
|
65
61
|
plugin: function plugin(_ref3) {
|
|
66
62
|
var _options$inputTrackin;
|
|
67
63
|
var dispatchAnalyticsEvent = _ref3.dispatchAnalyticsEvent;
|
|
68
|
-
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;
|
|
64
|
+
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(api === null || api === void 0 ? void 0 : api.contextIdentifier)(dispatchAnalyticsEvent, options.inputTracking, options.browserFreezeTracking, options.ufo) : undefined;
|
|
69
65
|
}
|
|
70
66
|
}, {
|
|
71
67
|
name: 'history',
|
|
@@ -86,19 +82,12 @@ var basePlugin = function basePlugin(_ref) {
|
|
|
86
82
|
}
|
|
87
83
|
}));
|
|
88
84
|
}
|
|
89
|
-
}, {
|
|
90
|
-
name: 'contextIdentifier',
|
|
91
|
-
plugin: function plugin(_ref4) {
|
|
92
|
-
var dispatch = _ref4.dispatch,
|
|
93
|
-
providerFactory = _ref4.providerFactory;
|
|
94
|
-
return contextIdentifierPlugin(dispatch, providerFactory);
|
|
95
|
-
}
|
|
96
85
|
});
|
|
97
86
|
if (options && options.allowScrollGutter) {
|
|
98
87
|
plugins.push({
|
|
99
88
|
name: 'scrollGutterPlugin',
|
|
100
89
|
plugin: function plugin() {
|
|
101
|
-
return
|
|
90
|
+
return scrollGutter(options.allowScrollGutter);
|
|
102
91
|
}
|
|
103
92
|
});
|
|
104
93
|
}
|