@atlaskit/editor-common 101.1.1 → 102.0.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 +17 -0
- package/dist/cjs/extensions/messages.js +5 -0
- package/dist/cjs/monitoring/error.js +1 -1
- package/dist/cjs/selection/utils.js +2 -2
- package/dist/cjs/ugc-tokens/index.js +13 -0
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/cjs/with-plugin-state/index.js +4 -269
- package/dist/es2019/extensions/messages.js +5 -0
- package/dist/es2019/monitoring/error.js +1 -1
- package/dist/es2019/selection/utils.js +2 -2
- package/dist/es2019/ugc-tokens/index.js +3 -0
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/es2019/with-plugin-state/index.js +2 -240
- package/dist/esm/extensions/messages.js +5 -0
- package/dist/esm/monitoring/error.js +1 -1
- package/dist/esm/selection/utils.js +2 -2
- package/dist/esm/ugc-tokens/index.js +3 -0
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/esm/with-plugin-state/index.js +2 -269
- package/dist/types/analytics/types/ai-unified-events.d.ts +13 -6
- package/dist/types/extensions/messages.d.ts +5 -0
- package/dist/types/selection/utils.d.ts +3 -4
- package/dist/types/ugc-tokens/index.d.ts +2 -0
- package/dist/types/with-plugin-state/index.d.ts +0 -42
- package/dist/types-ts4.5/analytics/types/ai-unified-events.d.ts +13 -6
- package/dist/types-ts4.5/extensions/messages.d.ts +5 -0
- package/dist/types-ts4.5/selection/utils.d.ts +3 -4
- package/dist/types-ts4.5/ugc-tokens/index.d.ts +2 -0
- package/dist/types-ts4.5/with-plugin-state/index.d.ts +0 -42
- package/package.json +8 -7
- package/ugc-tokens/package.json +17 -0
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
5
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
4
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '../analytics';
|
|
7
5
|
import { createDispatch } from '../event-dispatcher';
|
|
8
6
|
import { startMeasure, stopMeasure } from '../performance-measures';
|
|
@@ -59,17 +57,12 @@ class WithPluginState extends React.Component {
|
|
|
59
57
|
super(props);
|
|
60
58
|
}
|
|
61
59
|
render() {
|
|
62
|
-
if (fg('platform_editor_react18_phase2_v2')) {
|
|
63
|
-
// Ignored via go/ees005
|
|
64
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
65
|
-
return /*#__PURE__*/React.createElement(WithPluginStateNew, this.props);
|
|
66
|
-
}
|
|
67
60
|
// Ignored via go/ees005
|
|
68
61
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
69
|
-
return /*#__PURE__*/React.createElement(
|
|
62
|
+
return /*#__PURE__*/React.createElement(WithPluginStateEditionActionsWrapper, this.props);
|
|
70
63
|
}
|
|
71
64
|
}
|
|
72
|
-
function
|
|
65
|
+
function WithPluginStateEditionActionsWrapper(props) {
|
|
73
66
|
const context = React.useContext(EditorContext);
|
|
74
67
|
return /*#__PURE__*/React.createElement(WithPluginStateInner
|
|
75
68
|
// Ignored via go/ees005
|
|
@@ -299,236 +292,5 @@ export class WithPluginStateInner extends React.Component {
|
|
|
299
292
|
return render(this.state);
|
|
300
293
|
}
|
|
301
294
|
}
|
|
302
|
-
|
|
303
|
-
// Ignored via go/ees005
|
|
304
|
-
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
305
295
|
_defineProperty(WithPluginStateInner, "displayName", 'WithPluginState');
|
|
306
|
-
export class WithPluginStateOld extends React.Component {
|
|
307
|
-
constructor(props, context) {
|
|
308
|
-
super(props, context);
|
|
309
|
-
_defineProperty(this, "listeners", {});
|
|
310
|
-
_defineProperty(this, "debounce", null);
|
|
311
|
-
_defineProperty(this, "notAppliedState", {});
|
|
312
|
-
_defineProperty(this, "isSubscribed", false);
|
|
313
|
-
_defineProperty(this, "callsCount", 0);
|
|
314
|
-
_defineProperty(this, "handlePluginStateChange", (propName, pluginName, performanceOptions, skipEqualityCheck) =>
|
|
315
|
-
// Ignored via go/ees005
|
|
316
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
317
|
-
pluginState => {
|
|
318
|
-
// skipEqualityCheck is being used for old plugins since they are mutating plugin state instead of creating a new one
|
|
319
|
-
// Ignored via go/ees005
|
|
320
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
321
|
-
if (this.state[propName] !== pluginState || skipEqualityCheck) {
|
|
322
|
-
this.updateState({
|
|
323
|
-
stateSubset: {
|
|
324
|
-
[propName]: pluginState
|
|
325
|
-
},
|
|
326
|
-
pluginName,
|
|
327
|
-
performanceOptions
|
|
328
|
-
});
|
|
329
|
-
}
|
|
330
|
-
});
|
|
331
|
-
/**
|
|
332
|
-
* Debounces setState calls in order to reduce number of re-renders caused by several plugin state changes.
|
|
333
|
-
*/
|
|
334
|
-
_defineProperty(this, "updateState", ({
|
|
335
|
-
stateSubset,
|
|
336
|
-
pluginName,
|
|
337
|
-
performanceOptions
|
|
338
|
-
}) => {
|
|
339
|
-
this.notAppliedState = {
|
|
340
|
-
...this.notAppliedState,
|
|
341
|
-
...stateSubset
|
|
342
|
-
};
|
|
343
|
-
if (this.debounce) {
|
|
344
|
-
window.clearTimeout(this.debounce);
|
|
345
|
-
}
|
|
346
|
-
const debounce = this.props.debounce !== false ? fn => window.setTimeout(fn, 0) : fn => fn();
|
|
347
|
-
this.debounce = debounce(() => {
|
|
348
|
-
const measure = `🦉${pluginName}::WithPluginState`;
|
|
349
|
-
performanceOptions.trackingEnabled && startMeasure(measure);
|
|
350
|
-
this.setState(this.notAppliedState, () => {
|
|
351
|
-
performanceOptions.trackingEnabled && stopMeasure(measure, duration => {
|
|
352
|
-
// Each WithPluginState component will fire analytics event no more than once every `samplingLimit` times
|
|
353
|
-
if (++this.callsCount % performanceOptions.samplingRate === 0 && duration > performanceOptions.slowThreshold) {
|
|
354
|
-
this.dispatchAnalyticsEvent({
|
|
355
|
-
action: ACTION.WITH_PLUGIN_STATE_CALLED,
|
|
356
|
-
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
357
|
-
eventType: EVENT_TYPE.OPERATIONAL,
|
|
358
|
-
attributes: {
|
|
359
|
-
plugin: pluginName,
|
|
360
|
-
duration
|
|
361
|
-
}
|
|
362
|
-
});
|
|
363
|
-
}
|
|
364
|
-
});
|
|
365
|
-
});
|
|
366
|
-
this.debounce = null;
|
|
367
|
-
this.notAppliedState = {};
|
|
368
|
-
});
|
|
369
|
-
});
|
|
370
|
-
_defineProperty(this, "dispatchAnalyticsEvent", payload => {
|
|
371
|
-
const eventDispatcher = this.getEventDispatcher();
|
|
372
|
-
if (eventDispatcher) {
|
|
373
|
-
const dispatch = createDispatch(eventDispatcher);
|
|
374
|
-
dispatch(analyticsEventKey, {
|
|
375
|
-
payload
|
|
376
|
-
});
|
|
377
|
-
}
|
|
378
|
-
});
|
|
379
|
-
_defineProperty(this, "onContextUpdate", () => {
|
|
380
|
-
this.subscribe(this.props);
|
|
381
|
-
});
|
|
382
|
-
this.state = this.getPluginsStates(this.props.plugins, this.getEditorView(props, context));
|
|
383
|
-
}
|
|
384
|
-
getEditorView(maybeProps, maybeContext) {
|
|
385
|
-
const props = maybeProps || this.props;
|
|
386
|
-
const context = maybeContext || this.context;
|
|
387
|
-
return props.editorView || context && context.editorActions && context.editorActions._privateGetEditorView() || context && context.editorSharedConfig && context.editorSharedConfig.editorView;
|
|
388
|
-
}
|
|
389
|
-
getEventDispatcher(maybeProps) {
|
|
390
|
-
const props = maybeProps || this.props;
|
|
391
|
-
return props.eventDispatcher || this.context && this.context.editorActions && this.context.editorActions._privateGetEventDispatcher() || this.context && this.context.editorSharedConfig && this.context.editorSharedConfig.eventDispatcher;
|
|
392
|
-
}
|
|
393
|
-
getPluginsStates(plugins, editorView) {
|
|
394
|
-
if (!editorView || !plugins) {
|
|
395
|
-
return {};
|
|
396
|
-
}
|
|
397
|
-
const keys = Object.keys(plugins);
|
|
398
|
-
return keys.reduce((acc, propName) => {
|
|
399
|
-
const pluginKey = plugins[propName];
|
|
400
|
-
if (!pluginKey) {
|
|
401
|
-
return acc;
|
|
402
|
-
}
|
|
403
|
-
acc[propName] = pluginKey.getState(editorView.state);
|
|
404
|
-
return acc;
|
|
405
|
-
}, {});
|
|
406
|
-
}
|
|
407
|
-
subscribe(props) {
|
|
408
|
-
var _uiTracking$samplingR2, _uiTracking$slowThres2;
|
|
409
|
-
const plugins = props.plugins;
|
|
410
|
-
const eventDispatcher = this.getEventDispatcher(props);
|
|
411
|
-
const editorView = this.getEditorView(props);
|
|
412
|
-
if (!eventDispatcher || !editorView || this.isSubscribed) {
|
|
413
|
-
return;
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
// TODO: ED-15663
|
|
417
|
-
// Please, do not copy or use this kind of code below
|
|
418
|
-
// @ts-ignore
|
|
419
|
-
const fakePluginKey = {
|
|
420
|
-
key: 'analyticsPlugin$',
|
|
421
|
-
getState: state => {
|
|
422
|
-
// Ignored via go/ees005
|
|
423
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
424
|
-
return state['analyticsPlugin$'];
|
|
425
|
-
}
|
|
426
|
-
};
|
|
427
|
-
const analyticsPlugin = fakePluginKey.getState(editorView.state);
|
|
428
|
-
const uiTracking = analyticsPlugin && analyticsPlugin.performanceTracking ? analyticsPlugin.performanceTracking.uiTracking || {} : {};
|
|
429
|
-
const trackingEnabled = uiTracking.enabled === true;
|
|
430
|
-
const samplingRate = (_uiTracking$samplingR2 = uiTracking.samplingRate) !== null && _uiTracking$samplingR2 !== void 0 ? _uiTracking$samplingR2 : DEFAULT_SAMPLING_RATE;
|
|
431
|
-
const slowThreshold = (_uiTracking$slowThres2 = uiTracking.slowThreshold) !== null && _uiTracking$slowThres2 !== void 0 ? _uiTracking$slowThres2 : DEFAULT_SLOW_THRESHOLD;
|
|
432
|
-
this.isSubscribed = true;
|
|
433
|
-
const pluginsStates = this.getPluginsStates(plugins, editorView);
|
|
434
|
-
this.setState(pluginsStates);
|
|
435
|
-
Object.keys(plugins).forEach(propName => {
|
|
436
|
-
const pluginKey = plugins[propName];
|
|
437
|
-
if (!pluginKey) {
|
|
438
|
-
return;
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
// Ignored via go/ees005
|
|
442
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
443
|
-
const pluginName = pluginKey.key;
|
|
444
|
-
// Ignored via go/ees005
|
|
445
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
446
|
-
const pluginState = pluginsStates[propName];
|
|
447
|
-
const isPluginWithSubscribe = pluginState && pluginState.subscribe;
|
|
448
|
-
const handler = this.handlePluginStateChange(propName, pluginName, {
|
|
449
|
-
samplingRate,
|
|
450
|
-
slowThreshold,
|
|
451
|
-
trackingEnabled
|
|
452
|
-
}, isPluginWithSubscribe);
|
|
453
|
-
if (isPluginWithSubscribe) {
|
|
454
|
-
pluginState.subscribe(handler);
|
|
455
|
-
} else {
|
|
456
|
-
// Ignored via go/ees005
|
|
457
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
458
|
-
eventDispatcher.on(pluginKey.key, handler);
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
// Ignored via go/ees005
|
|
462
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
463
|
-
// Ignored via go/ees005
|
|
464
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
465
|
-
this.listeners[pluginKey.key] = {
|
|
466
|
-
handler,
|
|
467
|
-
pluginKey
|
|
468
|
-
};
|
|
469
|
-
});
|
|
470
|
-
}
|
|
471
|
-
unsubscribe() {
|
|
472
|
-
const eventDispatcher = this.getEventDispatcher();
|
|
473
|
-
const editorView = this.getEditorView();
|
|
474
|
-
if (!eventDispatcher || !editorView || !this.isSubscribed) {
|
|
475
|
-
return;
|
|
476
|
-
}
|
|
477
|
-
Object.keys(this.listeners).forEach(key => {
|
|
478
|
-
// Ignored via go/ees005
|
|
479
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
480
|
-
const pluginState = this.listeners[key].pluginKey.getState(editorView.state);
|
|
481
|
-
if (pluginState && pluginState.unsubscribe) {
|
|
482
|
-
// Ignored via go/ees005
|
|
483
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
484
|
-
pluginState.unsubscribe(this.listeners[key].handler);
|
|
485
|
-
} else {
|
|
486
|
-
// Ignored via go/ees005
|
|
487
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
488
|
-
eventDispatcher.off(key, this.listeners[key].handler);
|
|
489
|
-
}
|
|
490
|
-
});
|
|
491
|
-
this.listeners = [];
|
|
492
|
-
}
|
|
493
|
-
subscribeToContextUpdates(context) {
|
|
494
|
-
if (context && context.editorActions) {
|
|
495
|
-
context.editorActions._privateSubscribe(this.onContextUpdate);
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
unsubscribeFromContextUpdates(context) {
|
|
499
|
-
if (context && context.editorActions) {
|
|
500
|
-
context.editorActions._privateUnsubscribe(this.onContextUpdate);
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
componentDidMount() {
|
|
504
|
-
this.subscribe(this.props);
|
|
505
|
-
this.subscribeToContextUpdates(this.context);
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
// Ignored via go/ees005
|
|
509
|
-
// eslint-disable-next-line react/no-unsafe
|
|
510
|
-
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
511
|
-
if (!this.isSubscribed) {
|
|
512
|
-
this.subscribe(nextProps);
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
componentWillUnmount() {
|
|
516
|
-
if (this.debounce) {
|
|
517
|
-
window.clearTimeout(this.debounce);
|
|
518
|
-
}
|
|
519
|
-
this.unsubscribeFromContextUpdates(this.context);
|
|
520
|
-
this.unsubscribe();
|
|
521
|
-
}
|
|
522
|
-
render() {
|
|
523
|
-
const {
|
|
524
|
-
render
|
|
525
|
-
} = this.props;
|
|
526
|
-
return render(this.state);
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
_defineProperty(WithPluginStateOld, "displayName", 'WithPluginState');
|
|
530
|
-
_defineProperty(WithPluginStateOld, "contextTypes", {
|
|
531
|
-
editorActions: PropTypes.object,
|
|
532
|
-
editorSharedConfig: PropTypes.object
|
|
533
|
-
});
|
|
534
296
|
export { WithPluginState };
|
|
@@ -131,5 +131,10 @@ export var configPanelMessages = defineMessages({
|
|
|
131
131
|
id: 'fabric.editor.configPanel.errorBoundary.note',
|
|
132
132
|
defaultMessage: "We've let the team know. You can still edit and publish this page, or check the error console for more information.",
|
|
133
133
|
description: 'Note for uncaught config panel error'
|
|
134
|
+
},
|
|
135
|
+
objectSidebarPanelHeaderLabel: {
|
|
136
|
+
id: 'fabric.editor.configPanel.objectSidebarPanelHeaderLabel',
|
|
137
|
+
defaultMessage: ' ',
|
|
138
|
+
description: 'Keep this empty. Defined it as headerLabel is required field.'
|
|
134
139
|
}
|
|
135
140
|
});
|
|
@@ -7,7 +7,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
7
7
|
import { isFedRamp } from './environment';
|
|
8
8
|
var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
9
9
|
var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
10
|
-
var packageVersion = "
|
|
10
|
+
var packageVersion = "102.0.0";
|
|
11
11
|
var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
|
|
12
12
|
// Remove URL as it has UGC
|
|
13
13
|
// TODO: Sanitise the URL instead of just removing it
|
|
@@ -7,7 +7,7 @@ export var isSelectionAtStartOfNode = function isSelectionAtStartOfNode($pos, pa
|
|
|
7
7
|
}
|
|
8
8
|
for (var i = $pos.depth + 1; i > 0; i--) {
|
|
9
9
|
var node = $pos.node(i);
|
|
10
|
-
if (node && node.eq(parentNode
|
|
10
|
+
if (node && node.eq(parentNode)) {
|
|
11
11
|
break;
|
|
12
12
|
}
|
|
13
13
|
if (i > 1 && $pos.before(i) !== $pos.before(i - 1) + 1) {
|
|
@@ -22,7 +22,7 @@ export var isSelectionAtEndOfNode = function isSelectionAtEndOfNode($pos, parent
|
|
|
22
22
|
}
|
|
23
23
|
for (var i = $pos.depth + 1; i > 0; i--) {
|
|
24
24
|
var node = $pos.node(i);
|
|
25
|
-
if (node && node.eq(parentNode
|
|
25
|
+
if (node && node.eq(parentNode)) {
|
|
26
26
|
break;
|
|
27
27
|
}
|
|
28
28
|
if (i > 1 && $pos.after(i) !== $pos.after(i - 1) - 1) {
|
|
@@ -20,7 +20,7 @@ import withAnalyticsContext from '@atlaskit/analytics-next/withAnalyticsContext'
|
|
|
20
20
|
import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
|
|
21
21
|
import Layer from '../Layer';
|
|
22
22
|
var packageName = "@atlaskit/editor-common";
|
|
23
|
-
var packageVersion = "
|
|
23
|
+
var packageVersion = "102.0.0";
|
|
24
24
|
var halfFocusRing = 1;
|
|
25
25
|
var dropOffset = '0, 8';
|
|
26
26
|
// Ignored via go/ees005
|
|
@@ -11,8 +11,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
11
11
|
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
12
12
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
13
13
|
import React from 'react';
|
|
14
|
-
import PropTypes from 'prop-types';
|
|
15
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
16
14
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '../analytics';
|
|
17
15
|
import { createDispatch } from '../event-dispatcher';
|
|
18
16
|
import { startMeasure, stopMeasure } from '../performance-measures';
|
|
@@ -72,18 +70,13 @@ var WithPluginState = /*#__PURE__*/function (_React$Component) {
|
|
|
72
70
|
return _createClass(WithPluginState, [{
|
|
73
71
|
key: "render",
|
|
74
72
|
value: function render() {
|
|
75
|
-
if (fg('platform_editor_react18_phase2_v2')) {
|
|
76
|
-
// Ignored via go/ees005
|
|
77
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
78
|
-
return /*#__PURE__*/React.createElement(WithPluginStateNew, this.props);
|
|
79
|
-
}
|
|
80
73
|
// Ignored via go/ees005
|
|
81
74
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
82
|
-
return /*#__PURE__*/React.createElement(
|
|
75
|
+
return /*#__PURE__*/React.createElement(WithPluginStateEditionActionsWrapper, this.props);
|
|
83
76
|
}
|
|
84
77
|
}]);
|
|
85
78
|
}(React.Component);
|
|
86
|
-
function
|
|
79
|
+
function WithPluginStateEditionActionsWrapper(props) {
|
|
87
80
|
var context = React.useContext(EditorContext);
|
|
88
81
|
return /*#__PURE__*/React.createElement(WithPluginStateInner
|
|
89
82
|
// Ignored via go/ees005
|
|
@@ -348,265 +341,5 @@ export var WithPluginStateInner = /*#__PURE__*/function (_React$Component2) {
|
|
|
348
341
|
}
|
|
349
342
|
}]);
|
|
350
343
|
}(React.Component);
|
|
351
|
-
|
|
352
|
-
// Ignored via go/ees005
|
|
353
|
-
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
354
344
|
_defineProperty(WithPluginStateInner, "displayName", 'WithPluginState');
|
|
355
|
-
export var WithPluginStateOld = /*#__PURE__*/function (_React$Component3) {
|
|
356
|
-
function WithPluginStateOld(props, context) {
|
|
357
|
-
var _this6;
|
|
358
|
-
_classCallCheck(this, WithPluginStateOld);
|
|
359
|
-
_this6 = _callSuper(this, WithPluginStateOld, [props, context]);
|
|
360
|
-
_defineProperty(_this6, "listeners", {});
|
|
361
|
-
_defineProperty(_this6, "debounce", null);
|
|
362
|
-
_defineProperty(_this6, "notAppliedState", {});
|
|
363
|
-
_defineProperty(_this6, "isSubscribed", false);
|
|
364
|
-
_defineProperty(_this6, "callsCount", 0);
|
|
365
|
-
_defineProperty(_this6, "handlePluginStateChange", function (propName, pluginName, performanceOptions, skipEqualityCheck) {
|
|
366
|
-
return (
|
|
367
|
-
// Ignored via go/ees005
|
|
368
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
369
|
-
function (pluginState) {
|
|
370
|
-
// skipEqualityCheck is being used for old plugins since they are mutating plugin state instead of creating a new one
|
|
371
|
-
// Ignored via go/ees005
|
|
372
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
373
|
-
if (_this6.state[propName] !== pluginState || skipEqualityCheck) {
|
|
374
|
-
_this6.updateState({
|
|
375
|
-
stateSubset: _defineProperty({}, propName, pluginState),
|
|
376
|
-
pluginName: pluginName,
|
|
377
|
-
performanceOptions: performanceOptions
|
|
378
|
-
});
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
);
|
|
382
|
-
});
|
|
383
|
-
/**
|
|
384
|
-
* Debounces setState calls in order to reduce number of re-renders caused by several plugin state changes.
|
|
385
|
-
*/
|
|
386
|
-
_defineProperty(_this6, "updateState", function (_ref2) {
|
|
387
|
-
var stateSubset = _ref2.stateSubset,
|
|
388
|
-
pluginName = _ref2.pluginName,
|
|
389
|
-
performanceOptions = _ref2.performanceOptions;
|
|
390
|
-
_this6.notAppliedState = _objectSpread(_objectSpread({}, _this6.notAppliedState), stateSubset);
|
|
391
|
-
if (_this6.debounce) {
|
|
392
|
-
window.clearTimeout(_this6.debounce);
|
|
393
|
-
}
|
|
394
|
-
var debounce = _this6.props.debounce !== false ? function (fn) {
|
|
395
|
-
return window.setTimeout(fn, 0);
|
|
396
|
-
} : function (fn) {
|
|
397
|
-
return fn();
|
|
398
|
-
};
|
|
399
|
-
_this6.debounce = debounce(function () {
|
|
400
|
-
var measure = "\uD83E\uDD89".concat(pluginName, "::WithPluginState");
|
|
401
|
-
performanceOptions.trackingEnabled && startMeasure(measure);
|
|
402
|
-
_this6.setState(_this6.notAppliedState, function () {
|
|
403
|
-
performanceOptions.trackingEnabled && stopMeasure(measure, function (duration) {
|
|
404
|
-
// Each WithPluginState component will fire analytics event no more than once every `samplingLimit` times
|
|
405
|
-
if (++_this6.callsCount % performanceOptions.samplingRate === 0 && duration > performanceOptions.slowThreshold) {
|
|
406
|
-
_this6.dispatchAnalyticsEvent({
|
|
407
|
-
action: ACTION.WITH_PLUGIN_STATE_CALLED,
|
|
408
|
-
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
409
|
-
eventType: EVENT_TYPE.OPERATIONAL,
|
|
410
|
-
attributes: {
|
|
411
|
-
plugin: pluginName,
|
|
412
|
-
duration: duration
|
|
413
|
-
}
|
|
414
|
-
});
|
|
415
|
-
}
|
|
416
|
-
});
|
|
417
|
-
});
|
|
418
|
-
_this6.debounce = null;
|
|
419
|
-
_this6.notAppliedState = {};
|
|
420
|
-
});
|
|
421
|
-
});
|
|
422
|
-
_defineProperty(_this6, "dispatchAnalyticsEvent", function (payload) {
|
|
423
|
-
var eventDispatcher = _this6.getEventDispatcher();
|
|
424
|
-
if (eventDispatcher) {
|
|
425
|
-
var dispatch = createDispatch(eventDispatcher);
|
|
426
|
-
dispatch(analyticsEventKey, {
|
|
427
|
-
payload: payload
|
|
428
|
-
});
|
|
429
|
-
}
|
|
430
|
-
});
|
|
431
|
-
_defineProperty(_this6, "onContextUpdate", function () {
|
|
432
|
-
_this6.subscribe(_this6.props);
|
|
433
|
-
});
|
|
434
|
-
_this6.state = _this6.getPluginsStates(_this6.props.plugins, _this6.getEditorView(props, context));
|
|
435
|
-
return _this6;
|
|
436
|
-
}
|
|
437
|
-
_inherits(WithPluginStateOld, _React$Component3);
|
|
438
|
-
return _createClass(WithPluginStateOld, [{
|
|
439
|
-
key: "getEditorView",
|
|
440
|
-
value: function getEditorView(maybeProps, maybeContext) {
|
|
441
|
-
var props = maybeProps || this.props;
|
|
442
|
-
var context = maybeContext || this.context;
|
|
443
|
-
return props.editorView || context && context.editorActions && context.editorActions._privateGetEditorView() || context && context.editorSharedConfig && context.editorSharedConfig.editorView;
|
|
444
|
-
}
|
|
445
|
-
}, {
|
|
446
|
-
key: "getEventDispatcher",
|
|
447
|
-
value: function getEventDispatcher(maybeProps) {
|
|
448
|
-
var props = maybeProps || this.props;
|
|
449
|
-
return props.eventDispatcher || this.context && this.context.editorActions && this.context.editorActions._privateGetEventDispatcher() || this.context && this.context.editorSharedConfig && this.context.editorSharedConfig.eventDispatcher;
|
|
450
|
-
}
|
|
451
|
-
}, {
|
|
452
|
-
key: "getPluginsStates",
|
|
453
|
-
value: function getPluginsStates(plugins, editorView) {
|
|
454
|
-
if (!editorView || !plugins) {
|
|
455
|
-
return {};
|
|
456
|
-
}
|
|
457
|
-
var keys = Object.keys(plugins);
|
|
458
|
-
return keys.reduce(function (acc, propName) {
|
|
459
|
-
var pluginKey = plugins[propName];
|
|
460
|
-
if (!pluginKey) {
|
|
461
|
-
return acc;
|
|
462
|
-
}
|
|
463
|
-
acc[propName] = pluginKey.getState(editorView.state);
|
|
464
|
-
return acc;
|
|
465
|
-
}, {});
|
|
466
|
-
}
|
|
467
|
-
}, {
|
|
468
|
-
key: "subscribe",
|
|
469
|
-
value: function subscribe(props) {
|
|
470
|
-
var _uiTracking$samplingR2,
|
|
471
|
-
_uiTracking$slowThres2,
|
|
472
|
-
_this7 = this;
|
|
473
|
-
var plugins = props.plugins;
|
|
474
|
-
var eventDispatcher = this.getEventDispatcher(props);
|
|
475
|
-
var editorView = this.getEditorView(props);
|
|
476
|
-
if (!eventDispatcher || !editorView || this.isSubscribed) {
|
|
477
|
-
return;
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
// TODO: ED-15663
|
|
481
|
-
// Please, do not copy or use this kind of code below
|
|
482
|
-
// @ts-ignore
|
|
483
|
-
var fakePluginKey = {
|
|
484
|
-
key: 'analyticsPlugin$',
|
|
485
|
-
getState: function getState(state) {
|
|
486
|
-
// Ignored via go/ees005
|
|
487
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
488
|
-
return state['analyticsPlugin$'];
|
|
489
|
-
}
|
|
490
|
-
};
|
|
491
|
-
var analyticsPlugin = fakePluginKey.getState(editorView.state);
|
|
492
|
-
var uiTracking = analyticsPlugin && analyticsPlugin.performanceTracking ? analyticsPlugin.performanceTracking.uiTracking || {} : {};
|
|
493
|
-
var trackingEnabled = uiTracking.enabled === true;
|
|
494
|
-
var samplingRate = (_uiTracking$samplingR2 = uiTracking.samplingRate) !== null && _uiTracking$samplingR2 !== void 0 ? _uiTracking$samplingR2 : DEFAULT_SAMPLING_RATE;
|
|
495
|
-
var slowThreshold = (_uiTracking$slowThres2 = uiTracking.slowThreshold) !== null && _uiTracking$slowThres2 !== void 0 ? _uiTracking$slowThres2 : DEFAULT_SLOW_THRESHOLD;
|
|
496
|
-
this.isSubscribed = true;
|
|
497
|
-
var pluginsStates = this.getPluginsStates(plugins, editorView);
|
|
498
|
-
this.setState(pluginsStates);
|
|
499
|
-
Object.keys(plugins).forEach(function (propName) {
|
|
500
|
-
var pluginKey = plugins[propName];
|
|
501
|
-
if (!pluginKey) {
|
|
502
|
-
return;
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
// Ignored via go/ees005
|
|
506
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
507
|
-
var pluginName = pluginKey.key;
|
|
508
|
-
// Ignored via go/ees005
|
|
509
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
510
|
-
var pluginState = pluginsStates[propName];
|
|
511
|
-
var isPluginWithSubscribe = pluginState && pluginState.subscribe;
|
|
512
|
-
var handler = _this7.handlePluginStateChange(propName, pluginName, {
|
|
513
|
-
samplingRate: samplingRate,
|
|
514
|
-
slowThreshold: slowThreshold,
|
|
515
|
-
trackingEnabled: trackingEnabled
|
|
516
|
-
}, isPluginWithSubscribe);
|
|
517
|
-
if (isPluginWithSubscribe) {
|
|
518
|
-
pluginState.subscribe(handler);
|
|
519
|
-
} else {
|
|
520
|
-
// Ignored via go/ees005
|
|
521
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
522
|
-
eventDispatcher.on(pluginKey.key, handler);
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
// Ignored via go/ees005
|
|
526
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
527
|
-
// Ignored via go/ees005
|
|
528
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
529
|
-
_this7.listeners[pluginKey.key] = {
|
|
530
|
-
handler: handler,
|
|
531
|
-
pluginKey: pluginKey
|
|
532
|
-
};
|
|
533
|
-
});
|
|
534
|
-
}
|
|
535
|
-
}, {
|
|
536
|
-
key: "unsubscribe",
|
|
537
|
-
value: function unsubscribe() {
|
|
538
|
-
var _this8 = this;
|
|
539
|
-
var eventDispatcher = this.getEventDispatcher();
|
|
540
|
-
var editorView = this.getEditorView();
|
|
541
|
-
if (!eventDispatcher || !editorView || !this.isSubscribed) {
|
|
542
|
-
return;
|
|
543
|
-
}
|
|
544
|
-
Object.keys(this.listeners).forEach(function (key) {
|
|
545
|
-
// Ignored via go/ees005
|
|
546
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
547
|
-
var pluginState = _this8.listeners[key].pluginKey.getState(editorView.state);
|
|
548
|
-
if (pluginState && pluginState.unsubscribe) {
|
|
549
|
-
// Ignored via go/ees005
|
|
550
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
551
|
-
pluginState.unsubscribe(_this8.listeners[key].handler);
|
|
552
|
-
} else {
|
|
553
|
-
// Ignored via go/ees005
|
|
554
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
555
|
-
eventDispatcher.off(key, _this8.listeners[key].handler);
|
|
556
|
-
}
|
|
557
|
-
});
|
|
558
|
-
this.listeners = [];
|
|
559
|
-
}
|
|
560
|
-
}, {
|
|
561
|
-
key: "subscribeToContextUpdates",
|
|
562
|
-
value: function subscribeToContextUpdates(context) {
|
|
563
|
-
if (context && context.editorActions) {
|
|
564
|
-
context.editorActions._privateSubscribe(this.onContextUpdate);
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
}, {
|
|
568
|
-
key: "unsubscribeFromContextUpdates",
|
|
569
|
-
value: function unsubscribeFromContextUpdates(context) {
|
|
570
|
-
if (context && context.editorActions) {
|
|
571
|
-
context.editorActions._privateUnsubscribe(this.onContextUpdate);
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
}, {
|
|
575
|
-
key: "componentDidMount",
|
|
576
|
-
value: function componentDidMount() {
|
|
577
|
-
this.subscribe(this.props);
|
|
578
|
-
this.subscribeToContextUpdates(this.context);
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
// Ignored via go/ees005
|
|
582
|
-
// eslint-disable-next-line react/no-unsafe
|
|
583
|
-
}, {
|
|
584
|
-
key: "UNSAFE_componentWillReceiveProps",
|
|
585
|
-
value: function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
586
|
-
if (!this.isSubscribed) {
|
|
587
|
-
this.subscribe(nextProps);
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
}, {
|
|
591
|
-
key: "componentWillUnmount",
|
|
592
|
-
value: function componentWillUnmount() {
|
|
593
|
-
if (this.debounce) {
|
|
594
|
-
window.clearTimeout(this.debounce);
|
|
595
|
-
}
|
|
596
|
-
this.unsubscribeFromContextUpdates(this.context);
|
|
597
|
-
this.unsubscribe();
|
|
598
|
-
}
|
|
599
|
-
}, {
|
|
600
|
-
key: "render",
|
|
601
|
-
value: function render() {
|
|
602
|
-
var render = this.props.render;
|
|
603
|
-
return render(this.state);
|
|
604
|
-
}
|
|
605
|
-
}]);
|
|
606
|
-
}(React.Component);
|
|
607
|
-
_defineProperty(WithPluginStateOld, "displayName", 'WithPluginState');
|
|
608
|
-
_defineProperty(WithPluginStateOld, "contextTypes", {
|
|
609
|
-
editorActions: PropTypes.object,
|
|
610
|
-
editorSharedConfig: PropTypes.object
|
|
611
|
-
});
|
|
612
345
|
export { WithPluginState };
|
|
@@ -14,19 +14,26 @@ export type AIUnifiedCommonAttributes = {
|
|
|
14
14
|
aiExperienceName?: string;
|
|
15
15
|
traceIds?: string[];
|
|
16
16
|
};
|
|
17
|
-
type
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
type AIUnifiedAgentAttributes = {
|
|
18
|
+
agentName?: string;
|
|
19
|
+
agentId?: string;
|
|
20
|
+
agentCreatorType?: string;
|
|
21
|
+
agentExternalConfigReference?: string;
|
|
22
|
+
agentIsDefault?: boolean;
|
|
23
|
+
};
|
|
24
|
+
type AIInteractionInitiatedAEP = TrackAEP<ACTION.INITIATED, ACTION_SUBJECT.AI_INTERACTION, ACTION_SUBJECT_ID.EDITOR_PLUGIN_AI, AIUnifiedCommonAttributes & AIUnifiedAgentAttributes, undefined>;
|
|
25
|
+
type AIInteractionDismissedAEP = TrackAEP<ACTION.DISMISSED, ACTION_SUBJECT.AI_INTERACTION, ACTION_SUBJECT_ID.EDITOR_PLUGIN_AI, AIUnifiedCommonAttributes & AIUnifiedAgentAttributes, undefined>;
|
|
26
|
+
type AIResultViewedAEP = TrackAEP<ACTION.VIEWED, ACTION_SUBJECT.AI_RESULT, ACTION_SUBJECT_ID.EDITOR_PLUGIN_AI, AIUnifiedCommonAttributes & AIUnifiedAgentAttributes, undefined>;
|
|
27
|
+
type AIResultActionedAEP = TrackAEP<ACTION.ACTIONED, ACTION_SUBJECT.AI_RESULT, ACTION_SUBJECT_ID.EDITOR_PLUGIN_AI, AIUnifiedCommonAttributes & AIUnifiedAgentAttributes & {
|
|
21
28
|
promptType?: string;
|
|
22
29
|
refinementCount?: number;
|
|
23
30
|
aiResultAction: string;
|
|
24
31
|
}, undefined>;
|
|
25
|
-
type AIResultErrorAEP = TrackAEP<ACTION.ERROR, ACTION_SUBJECT.AI_RESULT, ACTION_SUBJECT_ID.EDITOR_PLUGIN_AI, AIUnifiedCommonAttributes & {
|
|
32
|
+
type AIResultErrorAEP = TrackAEP<ACTION.ERROR, ACTION_SUBJECT.AI_RESULT, ACTION_SUBJECT_ID.EDITOR_PLUGIN_AI, AIUnifiedCommonAttributes & AIUnifiedAgentAttributes & {
|
|
26
33
|
aiErrorMessage?: string;
|
|
27
34
|
aiErrorCode?: number;
|
|
28
35
|
}, undefined>;
|
|
29
|
-
type AIFeedbackSubmittedAEP = TrackAEP<ACTION.SUBMITTED, ACTION_SUBJECT.AI_FEEDBACK, ACTION_SUBJECT_ID.EDITOR_PLUGIN_AI, AIUnifiedCommonAttributes & {
|
|
36
|
+
type AIFeedbackSubmittedAEP = TrackAEP<ACTION.SUBMITTED, ACTION_SUBJECT.AI_FEEDBACK, ACTION_SUBJECT_ID.EDITOR_PLUGIN_AI, AIUnifiedCommonAttributes & AIUnifiedAgentAttributes & {
|
|
30
37
|
aiFeedbackResult: 'up' | 'down';
|
|
31
38
|
}, undefined>;
|
|
32
39
|
export type AIUnifiedEventPayload = AIInteractionInitiatedAEP | AIResultViewedAEP | AIResultErrorAEP | AIInteractionDismissedAEP | AIResultActionedAEP | AIFeedbackSubmittedAEP;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { ResolvedPos } from '@atlaskit/editor-prosemirror/model';
|
|
1
|
+
import type { ResolvedPos, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const isSelectionAtEndOfNode: ($pos: ResolvedPos, parentNode?: ContentNodeWithPos) => boolean;
|
|
3
|
+
export declare const isSelectionAtStartOfNode: ($pos: ResolvedPos, parentNode?: PMNode) => boolean;
|
|
4
|
+
export declare const isSelectionAtEndOfNode: ($pos: ResolvedPos, parentNode?: PMNode) => boolean;
|
|
6
5
|
export declare function atTheEndOfDoc(state: EditorState): boolean;
|
|
7
6
|
export declare function atTheBeginningOfDoc(state: EditorState): boolean;
|
|
8
7
|
export declare function atTheEndOfBlock(state: EditorState): boolean;
|