@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.
- package/CHANGELOG.md +11 -0
- package/dist/cjs/editor-next/index.js +2 -2
- package/dist/cjs/index.js +7 -7
- package/dist/cjs/labs/next/presets/default.js +2 -2
- package/dist/cjs/plugins/index.js +0 -7
- package/dist/cjs/test-utils.js +2 -2
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/editor-next/index.js +1 -1
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/labs/next/presets/default.js +1 -1
- package/dist/es2019/plugins/index.js +0 -1
- package/dist/es2019/test-utils.js +1 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/editor-next/index.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/labs/next/presets/default.js +1 -1
- package/dist/esm/plugins/index.js +0 -1
- package/dist/esm/test-utils.js +1 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/create-editor/create-plugins-list.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/labs/next/presets/default.d.ts +1 -1
- package/dist/types/plugins/code-block/ide-ux/quote-handling.d.ts +1 -1
- package/dist/types/plugins/index.d.ts +0 -1
- package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
- package/dist/types/ui/ConfigPanel/FormErrorBoundary.d.ts +1 -1
- package/dist/types/ui/ContentStyles/index.d.ts +2 -2
- package/dist/types-ts4.5/create-editor/create-plugins-list.d.ts +1 -1
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/labs/next/presets/default.d.ts +1 -1
- package/dist/types-ts4.5/plugins/code-block/ide-ux/quote-handling.d.ts +1 -1
- package/dist/types-ts4.5/plugins/index.d.ts +0 -1
- package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
- package/dist/types-ts4.5/ui/ConfigPanel/FormErrorBoundary.d.ts +1 -1
- package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
- package/package.json +8 -9
- package/report.api.md +3 -26
- package/tmp/api-report-tmp.d.ts +3 -26
- package/dist/cjs/plugins/base/commands.js +0 -20
- package/dist/cjs/plugins/base/index.js +0 -13
- package/dist/cjs/plugins/base/plugin.js +0 -143
- package/dist/cjs/plugins/base/pm-plugins/context-identifier.js +0 -58
- package/dist/cjs/plugins/base/pm-plugins/disable-spell-checking.js +0 -63
- package/dist/cjs/plugins/base/pm-plugins/filter-steps.js +0 -34
- package/dist/cjs/plugins/base/pm-plugins/fix-chrome-88-selection.js +0 -34
- package/dist/cjs/plugins/base/pm-plugins/frozen-editor.js +0 -265
- package/dist/cjs/plugins/base/pm-plugins/inline-cursor-target.js +0 -183
- package/dist/cjs/plugins/base/pm-plugins/newline-preserve-marks.js +0 -34
- package/dist/cjs/plugins/base/pm-plugins/scroll-gutter/index.js +0 -262
- package/dist/cjs/plugins/base/pm-plugins/scroll-gutter/plugin-key.js +0 -15
- package/dist/cjs/plugins/base/utils/frozen-editor.js +0 -11
- package/dist/cjs/plugins/base/utils/input-latency-tracking.js +0 -134
- package/dist/es2019/plugins/base/commands.js +0 -13
- package/dist/es2019/plugins/base/index.js +0 -2
- package/dist/es2019/plugins/base/plugin.js +0 -113
- package/dist/es2019/plugins/base/pm-plugins/context-identifier.js +0 -43
- package/dist/es2019/plugins/base/pm-plugins/disable-spell-checking.js +0 -54
- package/dist/es2019/plugins/base/pm-plugins/filter-steps.js +0 -23
- package/dist/es2019/plugins/base/pm-plugins/fix-chrome-88-selection.js +0 -24
- package/dist/es2019/plugins/base/pm-plugins/frozen-editor.js +0 -258
- package/dist/es2019/plugins/base/pm-plugins/inline-cursor-target.js +0 -186
- package/dist/es2019/plugins/base/pm-plugins/newline-preserve-marks.js +0 -20
- package/dist/es2019/plugins/base/pm-plugins/scroll-gutter/index.js +0 -242
- package/dist/es2019/plugins/base/pm-plugins/scroll-gutter/plugin-key.js +0 -7
- package/dist/es2019/plugins/base/utils/frozen-editor.js +0 -2
- package/dist/es2019/plugins/base/utils/input-latency-tracking.js +0 -104
- package/dist/esm/plugins/base/commands.js +0 -13
- package/dist/esm/plugins/base/index.js +0 -2
- package/dist/esm/plugins/base/plugin.js +0 -131
- package/dist/esm/plugins/base/pm-plugins/context-identifier.js +0 -48
- package/dist/esm/plugins/base/pm-plugins/disable-spell-checking.js +0 -56
- package/dist/esm/plugins/base/pm-plugins/filter-steps.js +0 -27
- package/dist/esm/plugins/base/pm-plugins/fix-chrome-88-selection.js +0 -26
- package/dist/esm/plugins/base/pm-plugins/frozen-editor.js +0 -251
- package/dist/esm/plugins/base/pm-plugins/inline-cursor-target.js +0 -174
- package/dist/esm/plugins/base/pm-plugins/newline-preserve-marks.js +0 -26
- package/dist/esm/plugins/base/pm-plugins/scroll-gutter/index.js +0 -254
- package/dist/esm/plugins/base/pm-plugins/scroll-gutter/plugin-key.js +0 -7
- package/dist/esm/plugins/base/utils/frozen-editor.js +0 -4
- package/dist/esm/plugins/base/utils/input-latency-tracking.js +0 -128
- package/dist/types/plugins/base/commands.d.ts +0 -2
- package/dist/types/plugins/base/index.d.ts +0 -5
- package/dist/types/plugins/base/plugin.d.ts +0 -25
- package/dist/types/plugins/base/pm-plugins/context-identifier.d.ts +0 -13
- package/dist/types/plugins/base/pm-plugins/disable-spell-checking.d.ts +0 -4
- package/dist/types/plugins/base/pm-plugins/filter-steps.d.ts +0 -4
- package/dist/types/plugins/base/pm-plugins/fix-chrome-88-selection.d.ts +0 -5
- package/dist/types/plugins/base/pm-plugins/frozen-editor.d.ts +0 -12
- package/dist/types/plugins/base/pm-plugins/inline-cursor-target.d.ts +0 -17
- package/dist/types/plugins/base/pm-plugins/newline-preserve-marks.d.ts +0 -5
- package/dist/types/plugins/base/pm-plugins/scroll-gutter/index.d.ts +0 -22
- package/dist/types/plugins/base/pm-plugins/scroll-gutter/plugin-key.d.ts +0 -7
- package/dist/types/plugins/base/utils/frozen-editor.d.ts +0 -2
- package/dist/types/plugins/base/utils/input-latency-tracking.d.ts +0 -42
- package/dist/types-ts4.5/plugins/base/commands.d.ts +0 -2
- package/dist/types-ts4.5/plugins/base/index.d.ts +0 -5
- package/dist/types-ts4.5/plugins/base/plugin.d.ts +0 -27
- package/dist/types-ts4.5/plugins/base/pm-plugins/context-identifier.d.ts +0 -13
- package/dist/types-ts4.5/plugins/base/pm-plugins/disable-spell-checking.d.ts +0 -4
- package/dist/types-ts4.5/plugins/base/pm-plugins/filter-steps.d.ts +0 -4
- package/dist/types-ts4.5/plugins/base/pm-plugins/fix-chrome-88-selection.d.ts +0 -5
- package/dist/types-ts4.5/plugins/base/pm-plugins/frozen-editor.d.ts +0 -12
- package/dist/types-ts4.5/plugins/base/pm-plugins/inline-cursor-target.d.ts +0 -17
- package/dist/types-ts4.5/plugins/base/pm-plugins/newline-preserve-marks.d.ts +0 -5
- package/dist/types-ts4.5/plugins/base/pm-plugins/scroll-gutter/index.d.ts +0 -22
- package/dist/types-ts4.5/plugins/base/pm-plugins/scroll-gutter/plugin-key.d.ts +0 -7
- package/dist/types-ts4.5/plugins/base/utils/frozen-editor.d.ts +0 -2
- package/dist/types-ts4.5/plugins/base/utils/input-latency-tracking.d.ts +0 -42
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.fixChromeSelectionKey = exports.default = void 0;
|
|
7
|
-
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
8
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
9
|
-
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
10
|
-
function isDivHTMLElement(elm) {
|
|
11
|
-
return elm.tagName.toLowerCase() === 'div';
|
|
12
|
-
}
|
|
13
|
-
var fixChromeSelectionKey = new _state.PluginKey('fixChromeSelectionPlugin');
|
|
14
|
-
exports.fixChromeSelectionKey = fixChromeSelectionKey;
|
|
15
|
-
var _default = function _default() {
|
|
16
|
-
return new _safePlugin.SafePlugin({
|
|
17
|
-
key: fixChromeSelectionKey,
|
|
18
|
-
props: {
|
|
19
|
-
handleDOMEvents: {
|
|
20
|
-
focus: function focus(view) {
|
|
21
|
-
// We don't need to reset when there's a NodeSelection
|
|
22
|
-
// It creates other problem. @see HOT-94478
|
|
23
|
-
if (isDivHTMLElement(view.dom) && !(0, _utils.isNodeSelection)(view.state.selection)) {
|
|
24
|
-
view.dom.style.display = 'inline-block';
|
|
25
|
-
view.dom.offsetHeight;
|
|
26
|
-
view.dom.style.display = 'block';
|
|
27
|
-
}
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
exports.default = _default;
|
|
@@ -1,265 +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.frozenEditorPluginKey = exports.default = exports.NORMAL_SEVERITY_THRESHOLD = exports.DEGRADED_SEVERITY_THRESHOLD = exports.DEFAULT_TRACK_SEVERITY_THRESHOLD_NORMAL = exports.DEFAULT_TRACK_SEVERITY_THRESHOLD_DEGRADED = exports.DEFAULT_FREEZE_THRESHOLD = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
10
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
11
|
-
var _utils = require("@atlaskit/editor-common/utils");
|
|
12
|
-
var _ufo = require("@atlaskit/editor-common/ufo");
|
|
13
|
-
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
14
|
-
var _contextIdentifier = require("./context-identifier");
|
|
15
|
-
var _frozenEditor = require("../utils/frozen-editor");
|
|
16
|
-
var _inputLatencyTracking = _interopRequireDefault(require("../utils/input-latency-tracking"));
|
|
17
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
18
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
19
|
-
var frozenEditorPluginKey = new _state.PluginKey('frozenEditor');
|
|
20
|
-
exports.frozenEditorPluginKey = frozenEditorPluginKey;
|
|
21
|
-
var DEFAULT_KEYSTROKE_SAMPLING_LIMIT = 100;
|
|
22
|
-
var DEFAULT_SLOW_THRESHOLD = 300;
|
|
23
|
-
var DEFAULT_FREEZE_THRESHOLD = 600;
|
|
24
|
-
exports.DEFAULT_FREEZE_THRESHOLD = DEFAULT_FREEZE_THRESHOLD;
|
|
25
|
-
var NORMAL_SEVERITY_THRESHOLD = 2000;
|
|
26
|
-
exports.NORMAL_SEVERITY_THRESHOLD = NORMAL_SEVERITY_THRESHOLD;
|
|
27
|
-
var DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
28
|
-
exports.DEGRADED_SEVERITY_THRESHOLD = DEGRADED_SEVERITY_THRESHOLD;
|
|
29
|
-
var DEFAULT_TRACK_SEVERITY_ENABLED = false;
|
|
30
|
-
var DEFAULT_TRACK_SEVERITY_THRESHOLD_NORMAL = 100;
|
|
31
|
-
exports.DEFAULT_TRACK_SEVERITY_THRESHOLD_NORMAL = DEFAULT_TRACK_SEVERITY_THRESHOLD_NORMAL;
|
|
32
|
-
var DEFAULT_TRACK_SEVERITY_THRESHOLD_DEGRADED = 500;
|
|
33
|
-
exports.DEFAULT_TRACK_SEVERITY_THRESHOLD_DEGRADED = DEFAULT_TRACK_SEVERITY_THRESHOLD_DEGRADED;
|
|
34
|
-
var dispatchLongTaskEvent = function dispatchLongTaskEvent(dispatchAnalyticsEvent, view, time, getNodeCount, interactionType, severity) {
|
|
35
|
-
var _getContextIdentifier;
|
|
36
|
-
var state = view.state;
|
|
37
|
-
var nodesCount = getNodeCount(state);
|
|
38
|
-
return dispatchAnalyticsEvent({
|
|
39
|
-
action: _analytics.ACTION.BROWSER_FREEZE,
|
|
40
|
-
actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
|
|
41
|
-
attributes: _objectSpread(_objectSpread({
|
|
42
|
-
objectId: (_getContextIdentifier = (0, _contextIdentifier.getContextIdentifier)(state)) === null || _getContextIdentifier === void 0 ? void 0 : _getContextIdentifier.objectId,
|
|
43
|
-
freezeTime: time,
|
|
44
|
-
nodeSize: state.doc.nodeSize
|
|
45
|
-
}, nodesCount), {}, {
|
|
46
|
-
interactionType: interactionType,
|
|
47
|
-
severity: severity
|
|
48
|
-
}),
|
|
49
|
-
eventType: _analytics.EVENT_TYPE.OPERATIONAL
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
var _default = function _default(dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, ufo) {
|
|
53
|
-
var interactionType;
|
|
54
|
-
var inputLatencyTracker = null;
|
|
55
|
-
var inputLatencySingleKeyTracker = null;
|
|
56
|
-
var inputLatencyRenderedTracker = null;
|
|
57
|
-
if (browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackInteractionType) {
|
|
58
|
-
interactionType = (0, _frozenEditor.setInteractionType)(_analytics.BROWSER_FREEZE_INTERACTION_TYPE.LOADING);
|
|
59
|
-
}
|
|
60
|
-
var samplingRate = inputTracking && typeof inputTracking.samplingRate === 'number' ? inputTracking.samplingRate : DEFAULT_KEYSTROKE_SAMPLING_LIMIT;
|
|
61
|
-
var slowThreshold = inputTracking && typeof inputTracking.slowThreshold === 'number' ? inputTracking.slowThreshold : DEFAULT_SLOW_THRESHOLD;
|
|
62
|
-
var freezeThreshold = inputTracking && typeof inputTracking.freezeThreshold === 'number' ? inputTracking.freezeThreshold : DEFAULT_FREEZE_THRESHOLD;
|
|
63
|
-
var allowCountNodes = inputTracking && inputTracking.countNodes;
|
|
64
|
-
var prevNodeCountState = null;
|
|
65
|
-
var prevNodeCount = {};
|
|
66
|
-
|
|
67
|
-
// Cache the result as we were calling this multiple times
|
|
68
|
-
// and has potential to be expensive
|
|
69
|
-
var getNodeCount = function getNodeCount(state) {
|
|
70
|
-
if (state === prevNodeCountState) {
|
|
71
|
-
return prevNodeCount;
|
|
72
|
-
}
|
|
73
|
-
prevNodeCount = allowCountNodes ? (0, _utils.countNodes)(state) : {};
|
|
74
|
-
prevNodeCountState = state;
|
|
75
|
-
return prevNodeCount;
|
|
76
|
-
};
|
|
77
|
-
var shouldTrackSeverity = (inputTracking === null || inputTracking === void 0 ? void 0 : inputTracking.trackSeverity) || DEFAULT_TRACK_SEVERITY_ENABLED;
|
|
78
|
-
var severityThresholdNormal = (inputTracking === null || inputTracking === void 0 ? void 0 : inputTracking.severityNormalThreshold) || DEFAULT_TRACK_SEVERITY_THRESHOLD_NORMAL;
|
|
79
|
-
var severityThresholdDegraded = (inputTracking === null || inputTracking === void 0 ? void 0 : inputTracking.severityDegradedThreshold) || DEFAULT_TRACK_SEVERITY_THRESHOLD_DEGRADED;
|
|
80
|
-
var createDispatchSample = function createDispatchSample(action, view) {
|
|
81
|
-
return function (time, severity) {
|
|
82
|
-
var _getContextIdentifier2;
|
|
83
|
-
var state = view.state;
|
|
84
|
-
var nodesCount = getNodeCount(state);
|
|
85
|
-
var samplePayload = {
|
|
86
|
-
action: action,
|
|
87
|
-
actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
|
|
88
|
-
attributes: _objectSpread(_objectSpread({
|
|
89
|
-
time: time,
|
|
90
|
-
nodeSize: state.doc.nodeSize
|
|
91
|
-
}, nodesCount), {}, {
|
|
92
|
-
objectId: (_getContextIdentifier2 = (0, _contextIdentifier.getContextIdentifier)(state)) === null || _getContextIdentifier2 === void 0 ? void 0 : _getContextIdentifier2.objectId,
|
|
93
|
-
severity: shouldTrackSeverity ? severity : undefined
|
|
94
|
-
}),
|
|
95
|
-
eventType: _analytics.EVENT_TYPE.OPERATIONAL
|
|
96
|
-
};
|
|
97
|
-
dispatchAnalyticsEvent(samplePayload);
|
|
98
|
-
};
|
|
99
|
-
};
|
|
100
|
-
var createDispatchAverage = function createDispatchAverage(action, view) {
|
|
101
|
-
return function (_ref, severity) {
|
|
102
|
-
var _getContextIdentifier3;
|
|
103
|
-
var mean = _ref.mean,
|
|
104
|
-
median = _ref.median,
|
|
105
|
-
sampleSize = _ref.sampleSize;
|
|
106
|
-
var state = view.state;
|
|
107
|
-
var nodeCount = getNodeCount(state);
|
|
108
|
-
var averagePayload = {
|
|
109
|
-
action: action,
|
|
110
|
-
actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
|
|
111
|
-
attributes: _objectSpread(_objectSpread({
|
|
112
|
-
mean: mean,
|
|
113
|
-
median: median,
|
|
114
|
-
sampleSize: sampleSize
|
|
115
|
-
}, nodeCount), {}, {
|
|
116
|
-
nodeSize: state.doc.nodeSize,
|
|
117
|
-
severity: shouldTrackSeverity ? severity : undefined,
|
|
118
|
-
objectId: (_getContextIdentifier3 = (0, _contextIdentifier.getContextIdentifier)(state)) === null || _getContextIdentifier3 === void 0 ? void 0 : _getContextIdentifier3.objectId
|
|
119
|
-
}),
|
|
120
|
-
eventType: _analytics.EVENT_TYPE.OPERATIONAL
|
|
121
|
-
};
|
|
122
|
-
dispatchAnalyticsEvent(averagePayload);
|
|
123
|
-
};
|
|
124
|
-
};
|
|
125
|
-
return new _safePlugin.SafePlugin({
|
|
126
|
-
key: frozenEditorPluginKey,
|
|
127
|
-
props: (0, _utils.isPerformanceAPIAvailable)() ? {
|
|
128
|
-
handleTextInput: function handleTextInput(view) {
|
|
129
|
-
if (browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackInteractionType) {
|
|
130
|
-
interactionType = _analytics.BROWSER_FREEZE_INTERACTION_TYPE.TYPING;
|
|
131
|
-
}
|
|
132
|
-
if (inputLatencyTracker) {
|
|
133
|
-
var end = inputLatencyTracker.start();
|
|
134
|
-
|
|
135
|
-
// This is called after all handleTextInput events are executed which means first handleTextInput time incorporates following handleTextInput processing time
|
|
136
|
-
// Also this is called before browser rendering so it doesn't count it.
|
|
137
|
-
requestAnimationFrame(end);
|
|
138
|
-
}
|
|
139
|
-
if (inputLatencySingleKeyTracker) {
|
|
140
|
-
var _end = inputLatencySingleKeyTracker.start();
|
|
141
|
-
|
|
142
|
-
// This is executed before next handleTextInput when multiple keypress events are in one animation frame
|
|
143
|
-
// so it tracks individual keypress processing time
|
|
144
|
-
Promise.resolve().then(_end);
|
|
145
|
-
}
|
|
146
|
-
if (inputLatencyRenderedTracker) {
|
|
147
|
-
var _end2 = inputLatencyRenderedTracker.start();
|
|
148
|
-
|
|
149
|
-
// This is called at the next event loop so it counts browser rendering time.
|
|
150
|
-
setTimeout(_end2);
|
|
151
|
-
}
|
|
152
|
-
return false;
|
|
153
|
-
},
|
|
154
|
-
handleDOMEvents: browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackInteractionType ? {
|
|
155
|
-
click: function click() {
|
|
156
|
-
interactionType = (0, _frozenEditor.setInteractionType)(_analytics.BROWSER_FREEZE_INTERACTION_TYPE.CLICKING);
|
|
157
|
-
return false;
|
|
158
|
-
},
|
|
159
|
-
paste: function paste() {
|
|
160
|
-
interactionType = (0, _frozenEditor.setInteractionType)(_analytics.BROWSER_FREEZE_INTERACTION_TYPE.PASTING);
|
|
161
|
-
return false;
|
|
162
|
-
}
|
|
163
|
-
} : undefined
|
|
164
|
-
} : undefined,
|
|
165
|
-
view: function view(_view) {
|
|
166
|
-
if (!(0, _utils.isPerformanceObserverAvailable)()) {
|
|
167
|
-
return {};
|
|
168
|
-
}
|
|
169
|
-
var experienceStore = ufo ? _ufo.ExperienceStore.getInstance(_view) : undefined;
|
|
170
|
-
if (inputTracking !== null && inputTracking !== void 0 && inputTracking.enabled) {
|
|
171
|
-
inputLatencyTracker = new _inputLatencyTracking.default({
|
|
172
|
-
samplingRate: samplingRate,
|
|
173
|
-
slowThreshold: slowThreshold,
|
|
174
|
-
normalThreshold: severityThresholdNormal,
|
|
175
|
-
degradedThreshold: severityThresholdDegraded,
|
|
176
|
-
onSampleStart: function onSampleStart() {
|
|
177
|
-
experienceStore === null || experienceStore === void 0 ? void 0 : experienceStore.start(_ufo.EditorExperience.typing);
|
|
178
|
-
},
|
|
179
|
-
onSampleEnd: function onSampleEnd(time, _ref2) {
|
|
180
|
-
var _getContextIdentifier4;
|
|
181
|
-
var isSlow = _ref2.isSlow,
|
|
182
|
-
severity = _ref2.severity;
|
|
183
|
-
var state = _view.state;
|
|
184
|
-
var nodesCount = getNodeCount(state);
|
|
185
|
-
if (isSlow) {
|
|
186
|
-
experienceStore === null || experienceStore === void 0 ? void 0 : experienceStore.addMetadata(_ufo.EditorExperience.typing, {
|
|
187
|
-
slowInput: true
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
experienceStore === null || experienceStore === void 0 ? void 0 : experienceStore.success(_ufo.EditorExperience.typing, _objectSpread(_objectSpread({
|
|
191
|
-
nodeSize: state.doc.nodeSize
|
|
192
|
-
}, nodesCount), {}, {
|
|
193
|
-
objectId: (_getContextIdentifier4 = (0, _contextIdentifier.getContextIdentifier)(state)) === null || _getContextIdentifier4 === void 0 ? void 0 : _getContextIdentifier4.objectId,
|
|
194
|
-
time: time,
|
|
195
|
-
severity: shouldTrackSeverity ? severity : undefined
|
|
196
|
-
}));
|
|
197
|
-
},
|
|
198
|
-
dispatchSample: createDispatchSample(_analytics.ACTION.INPUT_PERF_SAMPLING, _view),
|
|
199
|
-
dispatchAverage: createDispatchAverage(_analytics.ACTION.INPUT_PERF_SAMPLING_AVG, _view),
|
|
200
|
-
onSlowInput: function onSlowInput(time) {
|
|
201
|
-
var _getContextIdentifier5;
|
|
202
|
-
var state = _view.state;
|
|
203
|
-
var nodesCount = getNodeCount(state);
|
|
204
|
-
dispatchAnalyticsEvent({
|
|
205
|
-
action: _analytics.ACTION.SLOW_INPUT,
|
|
206
|
-
actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
|
|
207
|
-
attributes: _objectSpread(_objectSpread({
|
|
208
|
-
time: time,
|
|
209
|
-
nodeSize: state.doc.nodeSize
|
|
210
|
-
}, nodesCount), {}, {
|
|
211
|
-
objectId: (_getContextIdentifier5 = (0, _contextIdentifier.getContextIdentifier)(state)) === null || _getContextIdentifier5 === void 0 ? void 0 : _getContextIdentifier5.objectId
|
|
212
|
-
}),
|
|
213
|
-
eventType: _analytics.EVENT_TYPE.OPERATIONAL
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
if (inputTracking !== null && inputTracking !== void 0 && inputTracking.trackSingleKeypress) {
|
|
219
|
-
inputLatencySingleKeyTracker = new _inputLatencyTracking.default({
|
|
220
|
-
samplingRate: samplingRate,
|
|
221
|
-
slowThreshold: slowThreshold,
|
|
222
|
-
normalThreshold: severityThresholdNormal,
|
|
223
|
-
degradedThreshold: severityThresholdDegraded,
|
|
224
|
-
dispatchSample: createDispatchSample(_analytics.ACTION.INPUT_PERF_SAMPLING_SINGLE_KEYPRESS, _view),
|
|
225
|
-
dispatchAverage: createDispatchAverage(_analytics.ACTION.INPUT_PERF_SAMPLING_SINGLE_KEYPRESS_AVG, _view)
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
if (inputTracking !== null && inputTracking !== void 0 && inputTracking.trackRenderingTime) {
|
|
229
|
-
inputLatencyRenderedTracker = new _inputLatencyTracking.default({
|
|
230
|
-
samplingRate: samplingRate,
|
|
231
|
-
slowThreshold: slowThreshold,
|
|
232
|
-
normalThreshold: severityThresholdNormal,
|
|
233
|
-
degradedThreshold: severityThresholdDegraded,
|
|
234
|
-
dispatchSample: createDispatchSample(_analytics.ACTION.INPUT_PERF_SAMPLING_RENDERED, _view),
|
|
235
|
-
dispatchAverage: createDispatchAverage(_analytics.ACTION.INPUT_PERF_SAMPLING_RENDERED_AVG, _view)
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
var observer;
|
|
239
|
-
try {
|
|
240
|
-
var _observer = new PerformanceObserver(function (list) {
|
|
241
|
-
var perfEntries = list.getEntries();
|
|
242
|
-
for (var i = 0; i < perfEntries.length; i++) {
|
|
243
|
-
var duration = perfEntries[i].duration;
|
|
244
|
-
if (duration > freezeThreshold) {
|
|
245
|
-
dispatchLongTaskEvent(dispatchAnalyticsEvent, _view, duration, getNodeCount, browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackInteractionType ? interactionType : undefined, browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackSeverity ? (0, _utils.getAnalyticsEventSeverity)(duration, browserFreezeTracking.severityNormalThreshold || NORMAL_SEVERITY_THRESHOLD, browserFreezeTracking.severityDegradedThreshold || DEGRADED_SEVERITY_THRESHOLD) : undefined);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
// register observer for long task notifications
|
|
251
|
-
_observer.observe({
|
|
252
|
-
entryTypes: ['longtask']
|
|
253
|
-
});
|
|
254
|
-
} catch (e) {}
|
|
255
|
-
return {
|
|
256
|
-
destroy: function destroy() {
|
|
257
|
-
var _inputLatencyTracker;
|
|
258
|
-
(_inputLatencyTracker = inputLatencyTracker) === null || _inputLatencyTracker === void 0 ? void 0 : _inputLatencyTracker.flush();
|
|
259
|
-
observer === null || observer === void 0 ? void 0 : observer.disconnect();
|
|
260
|
-
}
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
});
|
|
264
|
-
};
|
|
265
|
-
exports.default = _default;
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isInlineNodeView = exports.inlineCursorTargetStateKey = exports.default = void 0;
|
|
7
|
-
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
8
|
-
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
9
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
10
|
-
var _utils = require("@atlaskit/editor-common/utils");
|
|
11
|
-
var inlineCursorTargetStateKey = new _state.PluginKey('inlineCursorTargetPlugin');
|
|
12
|
-
exports.inlineCursorTargetStateKey = inlineCursorTargetStateKey;
|
|
13
|
-
var isInlineNodeView = function isInlineNodeView(node) {
|
|
14
|
-
return node && node.type.isInline && !node.type.isText;
|
|
15
|
-
};
|
|
16
|
-
exports.isInlineNodeView = isInlineNodeView;
|
|
17
|
-
var _default = function _default() {
|
|
18
|
-
return new _safePlugin.SafePlugin({
|
|
19
|
-
key: inlineCursorTargetStateKey,
|
|
20
|
-
state: {
|
|
21
|
-
init: function init() {
|
|
22
|
-
return {
|
|
23
|
-
cursorTarget: undefined
|
|
24
|
-
};
|
|
25
|
-
},
|
|
26
|
-
apply: function apply(tr) {
|
|
27
|
-
var selection = tr.selection,
|
|
28
|
-
doc = tr.doc;
|
|
29
|
-
var $from = selection.$from,
|
|
30
|
-
$to = selection.$to;
|
|
31
|
-
// In Safari, if the cursor target is to the right of the cursor it will block selections
|
|
32
|
-
// made with shift + arrowRight and vice versa for shift + arrowLeft. This is due to a
|
|
33
|
-
// contenteditable bug in safari, where editable elements block the selection but we need
|
|
34
|
-
// the cursor target to be editable for the following:
|
|
35
|
-
// - Ability to navigate with down/up arrows when between inline nodes
|
|
36
|
-
// - Ability to navigate with down/up arrows when between the start of a paragraph & an inline node
|
|
37
|
-
// - Ability to click and drag to select an inline node if it is the first node
|
|
38
|
-
// To prevent blocking the selection, we check handleDOMEvents and add meta to
|
|
39
|
-
// the transaction to prevent the plugin from making cursor target decorations.
|
|
40
|
-
var safariShiftSelection = tr.getMeta(inlineCursorTargetStateKey);
|
|
41
|
-
if (selection && (0, _utils.isTextSelection)(selection) && !safariShiftSelection) {
|
|
42
|
-
var hasInlineNodeViewAfter = isInlineNodeView($from.nodeAfter);
|
|
43
|
-
var hasInlineNodeViewBefore = isInlineNodeView($from.nodeBefore);
|
|
44
|
-
var isAtStartAndInlineNodeViewAfter = $from.parentOffset === 0 && isInlineNodeView($from.nodeAfter);
|
|
45
|
-
var isAtEndAndInlineNodeViewBefore = doc.resolve($from.pos).node().lastChild === $from.nodeBefore && isInlineNodeView($from.nodeBefore);
|
|
46
|
-
var createWidget = function createWidget(side) {
|
|
47
|
-
var node = document.createElement('span');
|
|
48
|
-
node.contentEditable = 'true';
|
|
49
|
-
node.setAttribute('aria-hidden', 'true');
|
|
50
|
-
node.appendChild(document.createTextNode(_utils.ZERO_WIDTH_SPACE));
|
|
51
|
-
node.className = 'cursor-target';
|
|
52
|
-
var $from = selection.$from;
|
|
53
|
-
var rightPosition = $from.pos;
|
|
54
|
-
var leftPosition = $from.posAtIndex(Math.max($from.index() - 1, 0));
|
|
55
|
-
var widgetPos = side === 'left' ? leftPosition : rightPosition;
|
|
56
|
-
return _view.Decoration.widget(widgetPos, node, {
|
|
57
|
-
raw: true,
|
|
58
|
-
key: 'inlineCursor'
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
// Create editable decoration widgets around the current inline node to allow proper cursor navigation.
|
|
63
|
-
if ((hasInlineNodeViewAfter || isAtEndAndInlineNodeViewBefore) && (hasInlineNodeViewBefore || isAtStartAndInlineNodeViewAfter)) {
|
|
64
|
-
return {
|
|
65
|
-
cursorTarget: {
|
|
66
|
-
decorations: [createWidget('left'), createWidget('right')],
|
|
67
|
-
positions: {
|
|
68
|
-
from: $from.pos,
|
|
69
|
-
to: $to.pos
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return {
|
|
76
|
-
cursorTarget: undefined
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
props: {
|
|
81
|
-
decorations: function decorations(state) {
|
|
82
|
-
var doc = state.doc;
|
|
83
|
-
var _ref = inlineCursorTargetStateKey.getState(state),
|
|
84
|
-
cursorTarget = _ref.cursorTarget;
|
|
85
|
-
if (cursorTargetHasValidDecorations(cursorTarget)) {
|
|
86
|
-
return _view.DecorationSet.create(doc, cursorTarget.decorations);
|
|
87
|
-
}
|
|
88
|
-
return null;
|
|
89
|
-
},
|
|
90
|
-
handleDOMEvents: {
|
|
91
|
-
// Workaround to prevent the decorations created by the plugin from
|
|
92
|
-
// blocking shift + arrow left/right selections in safari. When
|
|
93
|
-
// a shift + arrow left/right event is detected, send meta data to the
|
|
94
|
-
// plugin to prevent it from creating decorations.
|
|
95
|
-
// TODO We may be able to remove this when playing the following ticket:
|
|
96
|
-
// https://product-fabric.atlassian.net/browse/ED-14938
|
|
97
|
-
keydown: function keydown(view, event) {
|
|
98
|
-
if (_utils.browser.safari && event instanceof KeyboardEvent && event.shiftKey && (event.key === 'ArrowLeft' || event.key === 'ArrowRight')) {
|
|
99
|
-
view.dispatch(view.state.tr.setMeta(inlineCursorTargetStateKey, {
|
|
100
|
-
cursorTarget: undefined
|
|
101
|
-
}));
|
|
102
|
-
}
|
|
103
|
-
return false;
|
|
104
|
-
},
|
|
105
|
-
// Check the DOM to see if there are inline cursor targets
|
|
106
|
-
// after a composition event ends. If so, manually insert the
|
|
107
|
-
// event data in order to prevent contents ending up inside
|
|
108
|
-
// of the cursor target decorations.
|
|
109
|
-
compositionend: function compositionend(view, incorrectlyTypedEvent) {
|
|
110
|
-
// This is typed by the prosemirror definitions as Event,
|
|
111
|
-
// this type is incorrect, and it is actually an InputEvent
|
|
112
|
-
var event = incorrectlyTypedEvent;
|
|
113
|
-
var state = view.state;
|
|
114
|
-
var _ref2 = inlineCursorTargetStateKey.getState(state),
|
|
115
|
-
cursorTarget = _ref2.cursorTarget;
|
|
116
|
-
if (cursorTarget !== undefined) {
|
|
117
|
-
handleTextInputInsideCursorTargetDecoration({
|
|
118
|
-
event: event,
|
|
119
|
-
cursorTarget: cursorTarget,
|
|
120
|
-
view: view
|
|
121
|
-
});
|
|
122
|
-
return true;
|
|
123
|
-
}
|
|
124
|
-
return false;
|
|
125
|
-
},
|
|
126
|
-
// Check the DOM to see if there are inline cursor targets
|
|
127
|
-
// before any input event. If so, manually insert the
|
|
128
|
-
// event data in order to prevent contents ending up inside
|
|
129
|
-
// of the cursor target decorations.
|
|
130
|
-
beforeinput: function beforeinput(view, incorrectlyTypedEvent) {
|
|
131
|
-
// This is typed by the prosemirror definitions as Event,
|
|
132
|
-
// this type is incorrect, and it is actually an InputEvent
|
|
133
|
-
var event = incorrectlyTypedEvent;
|
|
134
|
-
var state = view.state;
|
|
135
|
-
var _ref3 = inlineCursorTargetStateKey.getState(state),
|
|
136
|
-
cursorTarget = _ref3.cursorTarget;
|
|
137
|
-
if (!event.isComposing && cursorTarget !== undefined) {
|
|
138
|
-
handleTextInputInsideCursorTargetDecoration({
|
|
139
|
-
event: event,
|
|
140
|
-
cursorTarget: cursorTarget,
|
|
141
|
-
view: view
|
|
142
|
-
});
|
|
143
|
-
return true;
|
|
144
|
-
}
|
|
145
|
-
return false;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
};
|
|
151
|
-
exports.default = _default;
|
|
152
|
-
function cursorTargetHasValidDecorations(cursorTarget) {
|
|
153
|
-
if (!cursorTarget ||
|
|
154
|
-
// Decorations can end up as null when the decorations prop is
|
|
155
|
-
// called after the decorations have been removed from the dom.
|
|
156
|
-
// https://github.com/ProseMirror/prosemirror-view/blob/8f0d313a6389b86a335274fba36534ba1cb21f12/src/decoration.js#L30
|
|
157
|
-
cursorTarget.decorations.includes(null)) {
|
|
158
|
-
return false;
|
|
159
|
-
}
|
|
160
|
-
return true;
|
|
161
|
-
}
|
|
162
|
-
function handleTextInputInsideCursorTargetDecoration(_ref4) {
|
|
163
|
-
var event = _ref4.event,
|
|
164
|
-
view = _ref4.view,
|
|
165
|
-
cursorTarget = _ref4.cursorTarget;
|
|
166
|
-
event.stopPropagation();
|
|
167
|
-
event.preventDefault();
|
|
168
|
-
var content = event.data || '';
|
|
169
|
-
var tr = view.state.tr;
|
|
170
|
-
|
|
171
|
-
// ensure any custom handleTextInput handlers are called for the input event
|
|
172
|
-
// ie. type ahead, emoji shortcuts.
|
|
173
|
-
var potentiallyHandleByHandleTextInput = view.someProp('handleTextInput', function (f) {
|
|
174
|
-
return f(view, cursorTarget.positions.from, cursorTarget.positions.to, content);
|
|
175
|
-
});
|
|
176
|
-
if (potentiallyHandleByHandleTextInput) {
|
|
177
|
-
// if a handleTextInput handler has handled the event, we don't want to
|
|
178
|
-
// manually update the document.
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
tr.insertText(content);
|
|
182
|
-
view.dispatch(tr);
|
|
183
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.newlinePreserveMarksKey = exports.default = void 0;
|
|
7
|
-
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
8
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
9
|
-
var _keymap = require("@atlaskit/editor-prosemirror/keymap");
|
|
10
|
-
var _utils = require("@atlaskit/editor-common/utils");
|
|
11
|
-
var newlinePreserveMarksKey = new _state.PluginKey('newlinePreserveMarksPlugin');
|
|
12
|
-
exports.newlinePreserveMarksKey = newlinePreserveMarksKey;
|
|
13
|
-
var isSelectionAligned = function isSelectionAligned(state) {
|
|
14
|
-
return !!state.selection.$to.parent.marks.find(function (m) {
|
|
15
|
-
return m.type === state.schema.marks.alignment;
|
|
16
|
-
});
|
|
17
|
-
};
|
|
18
|
-
var splitBlockPreservingMarks = function splitBlockPreservingMarks(state, dispatch) {
|
|
19
|
-
if (dispatch) {
|
|
20
|
-
dispatch(state.tr.split(state.tr.mapping.map(state.selection.$from.pos), 1));
|
|
21
|
-
}
|
|
22
|
-
return true;
|
|
23
|
-
};
|
|
24
|
-
var _default = function _default() {
|
|
25
|
-
return new _safePlugin.SafePlugin({
|
|
26
|
-
key: newlinePreserveMarksKey,
|
|
27
|
-
props: {
|
|
28
|
-
handleKeyDown: (0, _keymap.keydownHandler)({
|
|
29
|
-
Enter: (0, _utils.filterCommand)([_utils.isSelectionEndOfParagraph, isSelectionAligned], splitBlockPreservingMarks)
|
|
30
|
-
})
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
exports.default = _default;
|