@atlaskit/editor-common 60.1.0 → 60.2.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 +21 -0
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/styles/shared/block-marks.js +1 -1
- package/dist/cjs/styles/shared/panel.js +1 -1
- package/dist/cjs/styles/shared/table.js +1 -1
- package/dist/cjs/ufo/experience-store.js +159 -0
- package/dist/cjs/ufo/index.js +25 -0
- package/dist/cjs/utils/index.js +9 -1
- package/dist/cjs/utils/profiler/render-count.js +135 -0
- package/dist/cjs/utils/validator.js +34 -11
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/styles/shared/block-marks.js +1 -2
- package/dist/es2019/styles/shared/panel.js +5 -10
- package/dist/es2019/styles/shared/table.js +1 -1
- package/dist/es2019/ufo/experience-store.js +115 -0
- package/dist/es2019/ufo/index.js +1 -0
- package/dist/es2019/utils/index.js +2 -1
- package/dist/es2019/utils/profiler/render-count.js +107 -0
- package/dist/es2019/utils/validator.js +25 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/styles/shared/block-marks.js +1 -1
- package/dist/esm/styles/shared/panel.js +1 -1
- package/dist/esm/styles/shared/table.js +1 -1
- package/dist/esm/ufo/experience-store.js +143 -0
- package/dist/esm/ufo/index.js +1 -0
- package/dist/esm/utils/index.js +2 -1
- package/dist/esm/utils/profiler/render-count.js +123 -0
- package/dist/esm/utils/validator.js +34 -11
- package/dist/esm/version.json +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/ufo/experience-store.d.ts +32 -0
- package/dist/types/ufo/index.d.ts +1 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/profiler/render-count.d.ts +50 -0
- package/package.json +11 -9
- package/ufo/package.json +7 -0
- package/dist/cjs/ui/Caption/index.test.js +0 -82
- package/dist/cjs/utils/performance/measure-tti.test.js +0 -183
- package/dist/es2019/ui/Caption/index.test.js +0 -73
- package/dist/es2019/utils/performance/measure-tti.test.js +0 -124
- package/dist/esm/ui/Caption/index.test.js +0 -73
- package/dist/esm/utils/performance/measure-tti.test.js +0 -174
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import { ExperiencePerformanceTypes, ExperienceTypes, UFOExperience } from '@atlaskit/ufo';
|
|
3
|
+
export const experienceConfig = {
|
|
4
|
+
type: ExperienceTypes.Operation,
|
|
5
|
+
performanceType: ExperiencePerformanceTypes.Custom,
|
|
6
|
+
platform: {
|
|
7
|
+
component: 'editor'
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
export let EditorExperience;
|
|
11
|
+
|
|
12
|
+
(function (EditorExperience) {
|
|
13
|
+
EditorExperience["loadEditor"] = "load";
|
|
14
|
+
EditorExperience["typing"] = "type";
|
|
15
|
+
EditorExperience["interaction"] = "interact";
|
|
16
|
+
})(EditorExperience || (EditorExperience = {}));
|
|
17
|
+
|
|
18
|
+
export const RELIABILITY_INTERVAL = 30000;
|
|
19
|
+
export class ExperienceStore {
|
|
20
|
+
constructor() {
|
|
21
|
+
this.experiences = new Map();
|
|
22
|
+
|
|
23
|
+
for (const experienceId of Object.values(EditorExperience)) {
|
|
24
|
+
const experience = new UFOExperience(experienceId, experienceConfig);
|
|
25
|
+
this.experiences.set(experienceId, experience);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static getInstance(view, options = {}) {
|
|
30
|
+
if (!this.stores.get(view) || options !== null && options !== void 0 && options.forceNewInstance) {
|
|
31
|
+
const store = new ExperienceStore();
|
|
32
|
+
this.stores.set(view, store);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return this.stores.get(view);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
get(experienceId) {
|
|
39
|
+
return this.experiences.get(experienceId);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
getActive(experienceId) {
|
|
43
|
+
const experience = this.experiences.get(experienceId);
|
|
44
|
+
|
|
45
|
+
if (!(experience !== null && experience !== void 0 && experience.state.final)) {
|
|
46
|
+
return experience;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
getAll() {
|
|
51
|
+
return Array.from(this.experiences.values());
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
start(experienceId, startTime) {
|
|
55
|
+
var _this$get;
|
|
56
|
+
|
|
57
|
+
(_this$get = this.get(experienceId)) === null || _this$get === void 0 ? void 0 : _this$get.start(startTime);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
addMetadata(experienceId, metadata) {
|
|
61
|
+
var _this$get2;
|
|
62
|
+
|
|
63
|
+
(_this$get2 = this.get(experienceId)) === null || _this$get2 === void 0 ? void 0 : _this$get2.addMetadata(metadata);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
mark(experienceId, mark, value) {
|
|
67
|
+
var _this$get3;
|
|
68
|
+
|
|
69
|
+
(_this$get3 = this.get(experienceId)) === null || _this$get3 === void 0 ? void 0 : _this$get3.mark(mark, value);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
success(experienceId, metadata) {
|
|
73
|
+
var _this$getActive;
|
|
74
|
+
|
|
75
|
+
(_this$getActive = this.getActive(experienceId)) === null || _this$getActive === void 0 ? void 0 : _this$getActive.success({
|
|
76
|
+
metadata
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
fail(experienceId, metadata) {
|
|
81
|
+
var _this$getActive2;
|
|
82
|
+
|
|
83
|
+
(_this$getActive2 = this.getActive(experienceId)) === null || _this$getActive2 === void 0 ? void 0 : _this$getActive2.failure({
|
|
84
|
+
metadata
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
abort(experienceId, metadata) {
|
|
89
|
+
// We add this wait in here because when React catches an error it unmounts the component
|
|
90
|
+
// before the error boundary's componentDidCatch is called
|
|
91
|
+
// In this case we want to fail the experience, but without this wait, abort is called first
|
|
92
|
+
setTimeout(() => {
|
|
93
|
+
var _this$getActive3;
|
|
94
|
+
|
|
95
|
+
(_this$getActive3 = this.getActive(experienceId)) === null || _this$getActive3 === void 0 ? void 0 : _this$getActive3.abort({
|
|
96
|
+
metadata
|
|
97
|
+
});
|
|
98
|
+
}, 0);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
abortAll(metadata) {
|
|
102
|
+
this.experiences.forEach(experience => {
|
|
103
|
+
this.abort(experience.id, metadata);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
failAll(metadata) {
|
|
108
|
+
this.experiences.forEach(experience => {
|
|
109
|
+
this.fail(experience.id, metadata);
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
_defineProperty(ExperienceStore, "stores", new WeakMap());
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ExperienceStore, EditorExperience, RELIABILITY_INTERVAL } from './experience-store';
|
|
@@ -21,4 +21,5 @@ export { compose } from './compose';
|
|
|
21
21
|
export { ZERO_WIDTH_SPACE } from './whitespace';
|
|
22
22
|
export { shouldForceTracking } from './should-force-tracking';
|
|
23
23
|
export { getModeFromTheme } from './getModeFromTheme';
|
|
24
|
-
export { sniffUserBrowserExtensions } from './browser-extensions';
|
|
24
|
+
export { sniffUserBrowserExtensions } from './browser-extensions';
|
|
25
|
+
export { RenderCountProfiler } from './profiler/render-count';
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
export const PROFILER_KEY = '__editorRenderCountProfiler';
|
|
2
|
+
export class RenderCountProfiler {
|
|
3
|
+
/**
|
|
4
|
+
* The singleton/cached instance of RenderCountProfiler that will be shared
|
|
5
|
+
* betweenRenderCountProfiler.getInstance() calls
|
|
6
|
+
*/
|
|
7
|
+
constructor({
|
|
8
|
+
store
|
|
9
|
+
}) {
|
|
10
|
+
this.store = store;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Returns the singleton/cached instance of RenderCountProfiler that
|
|
14
|
+
* currently exists. If it hasn't been instantiated yet, the singleton
|
|
15
|
+
* instance will be created using the given params. Returns the latest
|
|
16
|
+
* singleton/instance.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
static getInstance(params) {
|
|
21
|
+
if (!RenderCountProfiler.instance) {
|
|
22
|
+
RenderCountProfiler.instance = new RenderCountProfiler({
|
|
23
|
+
store: params.store
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return RenderCountProfiler.instance;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
getData(profilerKey) {
|
|
31
|
+
var _this$store;
|
|
32
|
+
|
|
33
|
+
return (_this$store = this.store) === null || _this$store === void 0 ? void 0 : _this$store[profilerKey];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
enable() {
|
|
37
|
+
this.store[PROFILER_KEY] = { ...this.store[PROFILER_KEY],
|
|
38
|
+
enabled: true
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
remove() {
|
|
43
|
+
delete this.store[PROFILER_KEY];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
isEnabled() {
|
|
47
|
+
var _this$store2, _this$store2$PROFILER;
|
|
48
|
+
|
|
49
|
+
return Boolean((_this$store2 = this.store) === null || _this$store2 === void 0 ? void 0 : (_this$store2$PROFILER = _this$store2[PROFILER_KEY]) === null || _this$store2$PROFILER === void 0 ? void 0 : _this$store2$PROFILER.enabled);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
setRenderCount({
|
|
53
|
+
componentId,
|
|
54
|
+
renderCount,
|
|
55
|
+
instanceId
|
|
56
|
+
}) {
|
|
57
|
+
const profilerData = this.store[PROFILER_KEY];
|
|
58
|
+
const instance = {
|
|
59
|
+
count: renderCount
|
|
60
|
+
};
|
|
61
|
+
const existingComponents = profilerData === null || profilerData === void 0 ? void 0 : profilerData.components;
|
|
62
|
+
const existingInstances = existingComponents === null || existingComponents === void 0 ? void 0 : existingComponents[componentId];
|
|
63
|
+
const updatedComponent = { ...existingInstances,
|
|
64
|
+
[instanceId]: instance
|
|
65
|
+
};
|
|
66
|
+
this.store[PROFILER_KEY] = { ...profilerData,
|
|
67
|
+
components: { ...existingComponents,
|
|
68
|
+
[componentId]: updatedComponent
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
getInstanceRenderCounters({
|
|
74
|
+
componentId
|
|
75
|
+
}) {
|
|
76
|
+
var _this$store$PROFILER_, _this$store3, _this$store3$PROFILER, _this$store3$PROFILER2;
|
|
77
|
+
|
|
78
|
+
const component = (_this$store$PROFILER_ = (_this$store3 = this.store) === null || _this$store3 === void 0 ? void 0 : (_this$store3$PROFILER = _this$store3[PROFILER_KEY]) === null || _this$store3$PROFILER === void 0 ? void 0 : (_this$store3$PROFILER2 = _this$store3$PROFILER.components) === null || _this$store3$PROFILER2 === void 0 ? void 0 : _this$store3$PROFILER2[componentId]) !== null && _this$store$PROFILER_ !== void 0 ? _this$store$PROFILER_ : {};
|
|
79
|
+
const counters = [];
|
|
80
|
+
|
|
81
|
+
for (let instanceId in component) {
|
|
82
|
+
const counter = {
|
|
83
|
+
instanceId,
|
|
84
|
+
count: component[instanceId].count
|
|
85
|
+
};
|
|
86
|
+
counters.push(counter);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return counters;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
getRenderCount({
|
|
93
|
+
componentId
|
|
94
|
+
}) {
|
|
95
|
+
var _this$store$PROFILER_2, _this$store4, _this$store4$PROFILER, _this$store4$PROFILER2;
|
|
96
|
+
|
|
97
|
+
const component = (_this$store$PROFILER_2 = (_this$store4 = this.store) === null || _this$store4 === void 0 ? void 0 : (_this$store4$PROFILER = _this$store4[PROFILER_KEY]) === null || _this$store4$PROFILER === void 0 ? void 0 : (_this$store4$PROFILER2 = _this$store4$PROFILER.components) === null || _this$store4$PROFILER2 === void 0 ? void 0 : _this$store4$PROFILER2[componentId]) !== null && _this$store$PROFILER_2 !== void 0 ? _this$store$PROFILER_2 : {};
|
|
98
|
+
let total = 0;
|
|
99
|
+
|
|
100
|
+
for (let instanceId in component) {
|
|
101
|
+
total += component[instanceId].count;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return total;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
}
|
|
@@ -342,6 +342,31 @@ export const getValidNode = (originalNode, schema = defaultSchema, adfStage = 'f
|
|
|
342
342
|
break;
|
|
343
343
|
}
|
|
344
344
|
|
|
345
|
+
case 'mediaInline':
|
|
346
|
+
{
|
|
347
|
+
let mediaId = '';
|
|
348
|
+
let mediaCollection = [];
|
|
349
|
+
|
|
350
|
+
if (attrs) {
|
|
351
|
+
const {
|
|
352
|
+
id,
|
|
353
|
+
collection
|
|
354
|
+
} = attrs;
|
|
355
|
+
mediaId = id;
|
|
356
|
+
mediaCollection = collection;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
if (mediaId && mediaCollection && adfStage === 'stage0') {
|
|
360
|
+
return {
|
|
361
|
+
type,
|
|
362
|
+
attrs,
|
|
363
|
+
marks
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
break;
|
|
368
|
+
}
|
|
369
|
+
|
|
345
370
|
case 'media':
|
|
346
371
|
{
|
|
347
372
|
let mediaId = '';
|
package/dist/es2019/version.json
CHANGED
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { ADFTraversor, ErrorReporter, ZERO_WIDTH_SPACE, absoluteBreakoutWidth, browser, calcBreakoutWidth, breakoutConsts, calcTableColumnWidths, calcWideWidth, clearMeasure, compose, convertProsemirrorTableNodeToArrayOfRows, createCompareNodes, findAndTrackUnsupportedContentNodes, getAnalyticsAppearance, analyticsEventKey, getAnalyticsEventSeverity, getUnsupportedContentLevelData, UNSUPPORTED_CONTENT_LEVEL_SEVERITY_THRESHOLD_DEFAULTS, getExtensionLozengeData, getExtensionRenderer, getMarksByOrder, getModeFromTheme, getResponseEndTime, getValidContent, getValidDocument, getValidMark, getValidNode, getValidUnknownNode, hasMergedCell, isPastDate, isPerformanceAPIAvailable, isPerformanceObserverAvailable, isSameMark, isSubSupType, markOrder, measureRender, startMeasure, stopMeasure, measureTTI, getTTISeverity, TTI_SEVERITY_THRESHOLD_DEFAULTS, TTI_FROM_INVOCATION_SEVERITY_THRESHOLD_DEFAULTS, timestampToIsoFormat, timestampToString, timestampToTaskContext, timestampToUTCDate, todayTimestampInUTC, withImageLoader, canApplyAnnotationOnRange, getAnnotationIdsFromRange, SEVERITY, UNSUPPORTED_CONTENT_LEVEL_SEVERITY, shouldForceTracking, sniffUserBrowserExtensions } from './utils';
|
|
1
|
+
export { ADFTraversor, ErrorReporter, ZERO_WIDTH_SPACE, absoluteBreakoutWidth, browser, calcBreakoutWidth, breakoutConsts, calcTableColumnWidths, calcWideWidth, clearMeasure, compose, convertProsemirrorTableNodeToArrayOfRows, createCompareNodes, findAndTrackUnsupportedContentNodes, getAnalyticsAppearance, analyticsEventKey, getAnalyticsEventSeverity, getUnsupportedContentLevelData, UNSUPPORTED_CONTENT_LEVEL_SEVERITY_THRESHOLD_DEFAULTS, getExtensionLozengeData, getExtensionRenderer, getMarksByOrder, getModeFromTheme, getResponseEndTime, getValidContent, getValidDocument, getValidMark, getValidNode, getValidUnknownNode, hasMergedCell, isPastDate, isPerformanceAPIAvailable, isPerformanceObserverAvailable, isSameMark, isSubSupType, markOrder, measureRender, startMeasure, stopMeasure, measureTTI, getTTISeverity, TTI_SEVERITY_THRESHOLD_DEFAULTS, TTI_FROM_INVOCATION_SEVERITY_THRESHOLD_DEFAULTS, timestampToIsoFormat, timestampToString, timestampToTaskContext, timestampToUTCDate, todayTimestampInUTC, withImageLoader, canApplyAnnotationOnRange, getAnnotationIdsFromRange, SEVERITY, UNSUPPORTED_CONTENT_LEVEL_SEVERITY, shouldForceTracking, sniffUserBrowserExtensions, RenderCountProfiler } from './utils';
|
|
2
2
|
export { SortOrder, AnnotationUpdateEmitter, AnnotationUpdateEvent } from './types';
|
|
3
3
|
export { DefaultExtensionProvider, combineExtensionProviders, getExtensionKeyAndNodeKey, getExtensionModuleNode, getExtensionModuleNodePrivateProps, getQuickInsertItemsFromModule, getNodeRenderer, getContextualToolbarItemsFromModule, buildMenuItem, resolveImport } from './extensions';
|
|
4
4
|
export { ProviderFactory, WithProviders } from './provider-factory';
|
|
@@ -3,4 +3,4 @@ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral
|
|
|
3
3
|
var _templateObject;
|
|
4
4
|
|
|
5
5
|
import { css } from 'styled-components';
|
|
6
|
-
export var blockMarksSharedStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n /**\n * We need to remove margin-top from first item\n * inside doc, tableCell, tableHeader, blockquote, etc.\n */\n *:not(.fabric-editor-block-mark) >,\n /* For nested block marks */\n *:not(.fabric-editor-block-mark) > div.fabric-editor-block-mark:first-child {\n p,\n h1,\n h2,\n h3,\n h4,\n h5,\n h6
|
|
6
|
+
export var blockMarksSharedStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n /**\n * We need to remove margin-top from first item\n * inside doc, tableCell, tableHeader, blockquote, etc.\n */\n *:not(.fabric-editor-block-mark) >,\n /* For nested block marks */\n *:not(.fabric-editor-block-mark) > div.fabric-editor-block-mark:first-child {\n p,\n h1,\n h2,\n h3,\n h4,\n h5,\n h6 {\n &:first-child {\n margin-top: 0;\n }\n }\n }\n"])));
|
|
@@ -122,4 +122,4 @@ var mainDynamicStyles = function mainDynamicStyles(panelType) {
|
|
|
122
122
|
};
|
|
123
123
|
};
|
|
124
124
|
|
|
125
|
-
export var panelSharedStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .", " {\n border-radius: ", "px;\n margin: ", " 0 0;\n padding: ", "px;\n min-width: ", "px;\n display: flex;\n align-items: baseline;\n word-break: break-word;\n\n ", "\n\n .", " {\n
|
|
125
|
+
export var panelSharedStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .", " {\n border-radius: ", "px;\n margin: ", " 0 0;\n padding: ", "px;\n min-width: ", "px;\n display: flex;\n position: relative;\n align-items: baseline;\n word-break: break-word;\n\n ", "\n\n .", " {\n flex-shrink: 0;\n height: ", "px;\n width: ", "px;\n box-sizing: content-box;\n padding-right: ", "px;\n text-align: center;\n user-select: none;\n -moz-user-select: none;\n -webkit-user-select: none;\n -ms-user-select: none;\n ", "\n\n > span {\n vertical-align: middle;\n display: inline;\n }\n\n .", ", .", " {\n vertical-align: ", "px;\n }\n }\n\n .ak-editor-panel__content {\n margin: 1px 0 1px;\n flex: 1 0 0;\n /*\n https://ishadeed.com/article/min-max-css/#setting-min-width-to-zero-with-flexbox\n The default value for min-width is auto, which is computed to zero. When an element is a flex item, the value of min-width doesn\u2019t compute to zero. The minimum size of a flex item is equal to the size of its contents.\n */\n min-width: 0;\n }\n\n &[data-panel-type='", "'] {\n ", "\n\n .", " {\n ", "\n }\n }\n\n &[data-panel-type='", "'] {\n ", "\n\n .", " {\n ", "\n }\n }\n\n &[data-panel-type='", "'] {\n ", "\n\n .", " {\n ", "\n }\n }\n\n &[data-panel-type='", "'] {\n ", "\n\n .", " {\n ", "\n }\n }\n\n &[data-panel-type='", "'] {\n ", "\n\n .", " {\n ", "\n }\n }\n }\n"])), PanelSharedCssClassName.prefix, borderRadius(), blockNodesVerticalMargin, gridSize(), akEditorTableCellMinWidth, mainDynamicStyles(PanelType.INFO), PanelSharedCssClassName.icon, gridSize() * 3, gridSize() * 3, gridSize(), iconDynamicStyles(PanelType.INFO), emojiSprite, emojiImage, verticalAlignment, PanelType.NOTE, mainDynamicStyles(PanelType.NOTE), PanelSharedCssClassName.icon, iconDynamicStyles(PanelType.NOTE), PanelType.TIP, mainDynamicStyles(PanelType.TIP), PanelSharedCssClassName.icon, iconDynamicStyles(PanelType.TIP), PanelType.WARNING, mainDynamicStyles(PanelType.WARNING), PanelSharedCssClassName.icon, iconDynamicStyles(PanelType.WARNING), PanelType.ERROR, mainDynamicStyles(PanelType.ERROR), PanelSharedCssClassName.icon, iconDynamicStyles(PanelType.ERROR), PanelType.SUCCESS, mainDynamicStyles(PanelType.SUCCESS), PanelSharedCssClassName.icon, iconDynamicStyles(PanelType.SUCCESS));
|
|
@@ -35,7 +35,7 @@ var tableSharedStyle = css(_templateObject || (_templateObject = _taggedTemplate
|
|
|
35
35
|
}), tableCellMinWidth, themed({
|
|
36
36
|
light: akEditorTableBorder,
|
|
37
37
|
dark: akEditorTableBorderDark
|
|
38
|
-
}), tableCellPadding, browser.gecko || browser.ie ? 'background-clip: padding-box;' : '', themed({
|
|
38
|
+
}), tableCellPadding, browser.gecko || browser.ie || browser.mac && browser.chrome ? 'background-clip: padding-box;' : '', themed({
|
|
39
39
|
dark: getTableCellBackgroundDarkModeColors
|
|
40
40
|
}), themed({
|
|
41
41
|
light: akEditorTableToolbar,
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
+
import { ExperiencePerformanceTypes, ExperienceTypes, UFOExperience } from '@atlaskit/ufo';
|
|
5
|
+
export var experienceConfig = {
|
|
6
|
+
type: ExperienceTypes.Operation,
|
|
7
|
+
performanceType: ExperiencePerformanceTypes.Custom,
|
|
8
|
+
platform: {
|
|
9
|
+
component: 'editor'
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
export var EditorExperience;
|
|
13
|
+
|
|
14
|
+
(function (EditorExperience) {
|
|
15
|
+
EditorExperience["loadEditor"] = "load";
|
|
16
|
+
EditorExperience["typing"] = "type";
|
|
17
|
+
EditorExperience["interaction"] = "interact";
|
|
18
|
+
})(EditorExperience || (EditorExperience = {}));
|
|
19
|
+
|
|
20
|
+
export var RELIABILITY_INTERVAL = 30000;
|
|
21
|
+
export var ExperienceStore = /*#__PURE__*/function () {
|
|
22
|
+
function ExperienceStore() {
|
|
23
|
+
_classCallCheck(this, ExperienceStore);
|
|
24
|
+
|
|
25
|
+
this.experiences = new Map();
|
|
26
|
+
|
|
27
|
+
for (var _i = 0, _Object$values = Object.values(EditorExperience); _i < _Object$values.length; _i++) {
|
|
28
|
+
var experienceId = _Object$values[_i];
|
|
29
|
+
var experience = new UFOExperience(experienceId, experienceConfig);
|
|
30
|
+
this.experiences.set(experienceId, experience);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
_createClass(ExperienceStore, [{
|
|
35
|
+
key: "get",
|
|
36
|
+
value: function get(experienceId) {
|
|
37
|
+
return this.experiences.get(experienceId);
|
|
38
|
+
}
|
|
39
|
+
}, {
|
|
40
|
+
key: "getActive",
|
|
41
|
+
value: function getActive(experienceId) {
|
|
42
|
+
var experience = this.experiences.get(experienceId);
|
|
43
|
+
|
|
44
|
+
if (!(experience !== null && experience !== void 0 && experience.state.final)) {
|
|
45
|
+
return experience;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}, {
|
|
49
|
+
key: "getAll",
|
|
50
|
+
value: function getAll() {
|
|
51
|
+
return Array.from(this.experiences.values());
|
|
52
|
+
}
|
|
53
|
+
}, {
|
|
54
|
+
key: "start",
|
|
55
|
+
value: function start(experienceId, startTime) {
|
|
56
|
+
var _this$get;
|
|
57
|
+
|
|
58
|
+
(_this$get = this.get(experienceId)) === null || _this$get === void 0 ? void 0 : _this$get.start(startTime);
|
|
59
|
+
}
|
|
60
|
+
}, {
|
|
61
|
+
key: "addMetadata",
|
|
62
|
+
value: function addMetadata(experienceId, metadata) {
|
|
63
|
+
var _this$get2;
|
|
64
|
+
|
|
65
|
+
(_this$get2 = this.get(experienceId)) === null || _this$get2 === void 0 ? void 0 : _this$get2.addMetadata(metadata);
|
|
66
|
+
}
|
|
67
|
+
}, {
|
|
68
|
+
key: "mark",
|
|
69
|
+
value: function mark(experienceId, _mark, value) {
|
|
70
|
+
var _this$get3;
|
|
71
|
+
|
|
72
|
+
(_this$get3 = this.get(experienceId)) === null || _this$get3 === void 0 ? void 0 : _this$get3.mark(_mark, value);
|
|
73
|
+
}
|
|
74
|
+
}, {
|
|
75
|
+
key: "success",
|
|
76
|
+
value: function success(experienceId, metadata) {
|
|
77
|
+
var _this$getActive;
|
|
78
|
+
|
|
79
|
+
(_this$getActive = this.getActive(experienceId)) === null || _this$getActive === void 0 ? void 0 : _this$getActive.success({
|
|
80
|
+
metadata: metadata
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}, {
|
|
84
|
+
key: "fail",
|
|
85
|
+
value: function fail(experienceId, metadata) {
|
|
86
|
+
var _this$getActive2;
|
|
87
|
+
|
|
88
|
+
(_this$getActive2 = this.getActive(experienceId)) === null || _this$getActive2 === void 0 ? void 0 : _this$getActive2.failure({
|
|
89
|
+
metadata: metadata
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}, {
|
|
93
|
+
key: "abort",
|
|
94
|
+
value: function abort(experienceId, metadata) {
|
|
95
|
+
var _this = this;
|
|
96
|
+
|
|
97
|
+
// We add this wait in here because when React catches an error it unmounts the component
|
|
98
|
+
// before the error boundary's componentDidCatch is called
|
|
99
|
+
// In this case we want to fail the experience, but without this wait, abort is called first
|
|
100
|
+
setTimeout(function () {
|
|
101
|
+
var _this$getActive3;
|
|
102
|
+
|
|
103
|
+
(_this$getActive3 = _this.getActive(experienceId)) === null || _this$getActive3 === void 0 ? void 0 : _this$getActive3.abort({
|
|
104
|
+
metadata: metadata
|
|
105
|
+
});
|
|
106
|
+
}, 0);
|
|
107
|
+
}
|
|
108
|
+
}, {
|
|
109
|
+
key: "abortAll",
|
|
110
|
+
value: function abortAll(metadata) {
|
|
111
|
+
var _this2 = this;
|
|
112
|
+
|
|
113
|
+
this.experiences.forEach(function (experience) {
|
|
114
|
+
_this2.abort(experience.id, metadata);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}, {
|
|
118
|
+
key: "failAll",
|
|
119
|
+
value: function failAll(metadata) {
|
|
120
|
+
var _this3 = this;
|
|
121
|
+
|
|
122
|
+
this.experiences.forEach(function (experience) {
|
|
123
|
+
_this3.fail(experience.id, metadata);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}], [{
|
|
127
|
+
key: "getInstance",
|
|
128
|
+
value: function getInstance(view) {
|
|
129
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
130
|
+
|
|
131
|
+
if (!this.stores.get(view) || options !== null && options !== void 0 && options.forceNewInstance) {
|
|
132
|
+
var store = new ExperienceStore();
|
|
133
|
+
this.stores.set(view, store);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return this.stores.get(view);
|
|
137
|
+
}
|
|
138
|
+
}]);
|
|
139
|
+
|
|
140
|
+
return ExperienceStore;
|
|
141
|
+
}();
|
|
142
|
+
|
|
143
|
+
_defineProperty(ExperienceStore, "stores", new WeakMap());
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ExperienceStore, EditorExperience, RELIABILITY_INTERVAL } from './experience-store';
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -21,4 +21,5 @@ export { compose } from './compose';
|
|
|
21
21
|
export { ZERO_WIDTH_SPACE } from './whitespace';
|
|
22
22
|
export { shouldForceTracking } from './should-force-tracking';
|
|
23
23
|
export { getModeFromTheme } from './getModeFromTheme';
|
|
24
|
-
export { sniffUserBrowserExtensions } from './browser-extensions';
|
|
24
|
+
export { sniffUserBrowserExtensions } from './browser-extensions';
|
|
25
|
+
export { RenderCountProfiler } from './profiler/render-count';
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
+
|
|
5
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
6
|
+
|
|
7
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
8
|
+
|
|
9
|
+
export var PROFILER_KEY = '__editorRenderCountProfiler';
|
|
10
|
+
export var RenderCountProfiler = /*#__PURE__*/function () {
|
|
11
|
+
/**
|
|
12
|
+
* The singleton/cached instance of RenderCountProfiler that will be shared
|
|
13
|
+
* betweenRenderCountProfiler.getInstance() calls
|
|
14
|
+
*/
|
|
15
|
+
function RenderCountProfiler(_ref) {
|
|
16
|
+
var store = _ref.store;
|
|
17
|
+
|
|
18
|
+
_classCallCheck(this, RenderCountProfiler);
|
|
19
|
+
|
|
20
|
+
this.store = store;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Returns the singleton/cached instance of RenderCountProfiler that
|
|
24
|
+
* currently exists. If it hasn't been instantiated yet, the singleton
|
|
25
|
+
* instance will be created using the given params. Returns the latest
|
|
26
|
+
* singleton/instance.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
_createClass(RenderCountProfiler, [{
|
|
31
|
+
key: "getData",
|
|
32
|
+
value: function getData(profilerKey) {
|
|
33
|
+
var _this$store;
|
|
34
|
+
|
|
35
|
+
return (_this$store = this.store) === null || _this$store === void 0 ? void 0 : _this$store[profilerKey];
|
|
36
|
+
}
|
|
37
|
+
}, {
|
|
38
|
+
key: "enable",
|
|
39
|
+
value: function enable() {
|
|
40
|
+
this.store[PROFILER_KEY] = _objectSpread(_objectSpread({}, this.store[PROFILER_KEY]), {}, {
|
|
41
|
+
enabled: true
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}, {
|
|
45
|
+
key: "remove",
|
|
46
|
+
value: function remove() {
|
|
47
|
+
delete this.store[PROFILER_KEY];
|
|
48
|
+
}
|
|
49
|
+
}, {
|
|
50
|
+
key: "isEnabled",
|
|
51
|
+
value: function isEnabled() {
|
|
52
|
+
var _this$store2, _this$store2$PROFILER;
|
|
53
|
+
|
|
54
|
+
return Boolean((_this$store2 = this.store) === null || _this$store2 === void 0 ? void 0 : (_this$store2$PROFILER = _this$store2[PROFILER_KEY]) === null || _this$store2$PROFILER === void 0 ? void 0 : _this$store2$PROFILER.enabled);
|
|
55
|
+
}
|
|
56
|
+
}, {
|
|
57
|
+
key: "setRenderCount",
|
|
58
|
+
value: function setRenderCount(_ref2) {
|
|
59
|
+
var componentId = _ref2.componentId,
|
|
60
|
+
renderCount = _ref2.renderCount,
|
|
61
|
+
instanceId = _ref2.instanceId;
|
|
62
|
+
var profilerData = this.store[PROFILER_KEY];
|
|
63
|
+
var instance = {
|
|
64
|
+
count: renderCount
|
|
65
|
+
};
|
|
66
|
+
var existingComponents = profilerData === null || profilerData === void 0 ? void 0 : profilerData.components;
|
|
67
|
+
var existingInstances = existingComponents === null || existingComponents === void 0 ? void 0 : existingComponents[componentId];
|
|
68
|
+
|
|
69
|
+
var updatedComponent = _objectSpread(_objectSpread({}, existingInstances), {}, _defineProperty({}, instanceId, instance));
|
|
70
|
+
|
|
71
|
+
this.store[PROFILER_KEY] = _objectSpread(_objectSpread({}, profilerData), {}, {
|
|
72
|
+
components: _objectSpread(_objectSpread({}, existingComponents), {}, _defineProperty({}, componentId, updatedComponent))
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}, {
|
|
76
|
+
key: "getInstanceRenderCounters",
|
|
77
|
+
value: function getInstanceRenderCounters(_ref3) {
|
|
78
|
+
var _this$store$PROFILER_, _this$store3, _this$store3$PROFILER, _this$store3$PROFILER2;
|
|
79
|
+
|
|
80
|
+
var componentId = _ref3.componentId;
|
|
81
|
+
var component = (_this$store$PROFILER_ = (_this$store3 = this.store) === null || _this$store3 === void 0 ? void 0 : (_this$store3$PROFILER = _this$store3[PROFILER_KEY]) === null || _this$store3$PROFILER === void 0 ? void 0 : (_this$store3$PROFILER2 = _this$store3$PROFILER.components) === null || _this$store3$PROFILER2 === void 0 ? void 0 : _this$store3$PROFILER2[componentId]) !== null && _this$store$PROFILER_ !== void 0 ? _this$store$PROFILER_ : {};
|
|
82
|
+
var counters = [];
|
|
83
|
+
|
|
84
|
+
for (var _instanceId in component) {
|
|
85
|
+
var counter = {
|
|
86
|
+
instanceId: _instanceId,
|
|
87
|
+
count: component[_instanceId].count
|
|
88
|
+
};
|
|
89
|
+
counters.push(counter);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return counters;
|
|
93
|
+
}
|
|
94
|
+
}, {
|
|
95
|
+
key: "getRenderCount",
|
|
96
|
+
value: function getRenderCount(_ref4) {
|
|
97
|
+
var _this$store$PROFILER_2, _this$store4, _this$store4$PROFILER, _this$store4$PROFILER2;
|
|
98
|
+
|
|
99
|
+
var componentId = _ref4.componentId;
|
|
100
|
+
var component = (_this$store$PROFILER_2 = (_this$store4 = this.store) === null || _this$store4 === void 0 ? void 0 : (_this$store4$PROFILER = _this$store4[PROFILER_KEY]) === null || _this$store4$PROFILER === void 0 ? void 0 : (_this$store4$PROFILER2 = _this$store4$PROFILER.components) === null || _this$store4$PROFILER2 === void 0 ? void 0 : _this$store4$PROFILER2[componentId]) !== null && _this$store$PROFILER_2 !== void 0 ? _this$store$PROFILER_2 : {};
|
|
101
|
+
var total = 0;
|
|
102
|
+
|
|
103
|
+
for (var _instanceId2 in component) {
|
|
104
|
+
total += component[_instanceId2].count;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return total;
|
|
108
|
+
}
|
|
109
|
+
}], [{
|
|
110
|
+
key: "getInstance",
|
|
111
|
+
value: function getInstance(params) {
|
|
112
|
+
if (!RenderCountProfiler.instance) {
|
|
113
|
+
RenderCountProfiler.instance = new RenderCountProfiler({
|
|
114
|
+
store: params.store
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return RenderCountProfiler.instance;
|
|
119
|
+
}
|
|
120
|
+
}]);
|
|
121
|
+
|
|
122
|
+
return RenderCountProfiler;
|
|
123
|
+
}();
|
|
@@ -358,21 +358,44 @@ export var getValidNode = function getValidNode(originalNode) {
|
|
|
358
358
|
break;
|
|
359
359
|
}
|
|
360
360
|
|
|
361
|
-
case '
|
|
361
|
+
case 'mediaInline':
|
|
362
362
|
{
|
|
363
363
|
var mediaId = '';
|
|
364
|
-
var mediaType = '';
|
|
365
364
|
var mediaCollection = [];
|
|
366
|
-
var mediaUrl = '';
|
|
367
365
|
|
|
368
366
|
if (attrs) {
|
|
369
367
|
var id = attrs.id,
|
|
370
|
-
collection = attrs.collection
|
|
368
|
+
collection = attrs.collection;
|
|
369
|
+
mediaId = id;
|
|
370
|
+
mediaCollection = collection;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
if (mediaId && mediaCollection && adfStage === 'stage0') {
|
|
374
|
+
return {
|
|
375
|
+
type: type,
|
|
376
|
+
attrs: attrs,
|
|
377
|
+
marks: marks
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
break;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
case 'media':
|
|
385
|
+
{
|
|
386
|
+
var _mediaId = '';
|
|
387
|
+
var mediaType = '';
|
|
388
|
+
var _mediaCollection = [];
|
|
389
|
+
var mediaUrl = '';
|
|
390
|
+
|
|
391
|
+
if (attrs) {
|
|
392
|
+
var _id = attrs.id,
|
|
393
|
+
_collection = attrs.collection,
|
|
371
394
|
_type = attrs.type,
|
|
372
395
|
url = attrs.url;
|
|
373
|
-
|
|
396
|
+
_mediaId = _id;
|
|
374
397
|
mediaType = _type;
|
|
375
|
-
|
|
398
|
+
_mediaCollection = _collection;
|
|
376
399
|
mediaUrl = url;
|
|
377
400
|
}
|
|
378
401
|
|
|
@@ -392,11 +415,11 @@ export var getValidNode = function getValidNode(originalNode) {
|
|
|
392
415
|
type: type,
|
|
393
416
|
attrs: mediaAttrs
|
|
394
417
|
};
|
|
395
|
-
} else if (
|
|
418
|
+
} else if (_mediaId && mediaType) {
|
|
396
419
|
var _mediaAttrs = {
|
|
397
420
|
type: mediaType,
|
|
398
|
-
id:
|
|
399
|
-
collection:
|
|
421
|
+
id: _mediaId,
|
|
422
|
+
collection: _mediaCollection
|
|
400
423
|
};
|
|
401
424
|
|
|
402
425
|
if (attrs.width) {
|
|
@@ -465,10 +488,10 @@ export var getValidNode = function getValidNode(originalNode) {
|
|
|
465
488
|
if (attrs) {
|
|
466
489
|
var _text = attrs.text,
|
|
467
490
|
displayName = attrs.displayName,
|
|
468
|
-
|
|
491
|
+
_id2 = attrs.id,
|
|
469
492
|
accessLevel = attrs.accessLevel;
|
|
470
493
|
mentionText = _text || displayName;
|
|
471
|
-
mentionId =
|
|
494
|
+
mentionId = _id2;
|
|
472
495
|
mentionAccess = accessLevel;
|
|
473
496
|
}
|
|
474
497
|
|