@atlaskit/editor-common 101.1.2 → 102.1.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.
Files changed (125) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/cjs/ai-messages/ai.js +5 -0
  3. package/dist/cjs/analytics/types/general-events.js +1 -1
  4. package/dist/cjs/collab/index.js +2 -0
  5. package/dist/cjs/element-browser/hooks/use-select-and-focus-on-arrow-navigation.js +26 -52
  6. package/dist/cjs/extensibility/MultiBodiedExtension/action-api.js +2 -0
  7. package/dist/cjs/insert/index.js +2 -0
  8. package/dist/cjs/keymaps/keymap.js +4 -2
  9. package/dist/cjs/lazy-node-view/index.js +1 -1
  10. package/dist/cjs/media-inline/inline-image-card.js +2 -0
  11. package/dist/cjs/messages/annotation.js +2 -0
  12. package/dist/cjs/messages/help-dialog.js +2 -0
  13. package/dist/cjs/monitoring/environment.js +2 -0
  14. package/dist/cjs/monitoring/error.js +3 -1
  15. package/dist/cjs/node-width/index.js +0 -1
  16. package/dist/cjs/quick-insert/assets/datasource-assets-objects.js +1 -1
  17. package/dist/cjs/quick-insert/assets/datasource-jira-issue.js +1 -1
  18. package/dist/cjs/quick-insert/assets/feedback.js +1 -1
  19. package/dist/cjs/quick-insert/assets/quote.js +1 -1
  20. package/dist/cjs/react-node-view/getInlineNodeViewProducer.js +1 -1
  21. package/dist/cjs/react-node-view/index.js +1 -1
  22. package/dist/cjs/selection/gap-cursor/selection.js +1 -1
  23. package/dist/cjs/selection/utils.js +2 -2
  24. package/dist/cjs/styles/shared/annotation.js +1 -1
  25. package/dist/cjs/ugc-tokens/index.js +13 -0
  26. package/dist/cjs/ui/DropList/index.js +1 -1
  27. package/dist/cjs/ui/Layer/index.js +0 -1
  28. package/dist/cjs/ui-menu/ColorPickerButton/index.js +1 -1
  29. package/dist/cjs/ui-menu/ToolbarButton/styles.js +2 -0
  30. package/dist/cjs/ui-react/with-react-editor-view-outer-listeners.js +13 -4
  31. package/dist/cjs/utils/calculate-toolbar-position.js +4 -0
  32. package/dist/cjs/utils/compareNodes.js +0 -1
  33. package/dist/cjs/utils/get-performance-options.js +0 -1
  34. package/dist/cjs/utils/is-text-input.js +0 -2
  35. package/dist/cjs/utils/table.js +2 -0
  36. package/dist/cjs/utils/validate-using-spec.js +2 -0
  37. package/dist/cjs/with-plugin-state/index.js +4 -270
  38. package/dist/es2019/ai-messages/ai.js +5 -0
  39. package/dist/es2019/analytics/types/general-events.js +1 -3
  40. package/dist/es2019/collab/index.js +2 -0
  41. package/dist/es2019/element-browser/hooks/use-select-and-focus-on-arrow-navigation.js +28 -54
  42. package/dist/es2019/extensibility/MultiBodiedExtension/action-api.js +2 -0
  43. package/dist/es2019/insert/index.js +2 -0
  44. package/dist/es2019/keymaps/keymap.js +4 -2
  45. package/dist/es2019/lazy-node-view/index.js +1 -1
  46. package/dist/es2019/media-inline/inline-image-card.js +2 -0
  47. package/dist/es2019/messages/annotation.js +2 -0
  48. package/dist/es2019/messages/help-dialog.js +2 -0
  49. package/dist/es2019/monitoring/environment.js +2 -0
  50. package/dist/es2019/monitoring/error.js +3 -1
  51. package/dist/es2019/node-width/index.js +0 -1
  52. package/dist/es2019/quick-insert/assets/datasource-assets-objects.js +1 -1
  53. package/dist/es2019/quick-insert/assets/datasource-jira-issue.js +1 -1
  54. package/dist/es2019/quick-insert/assets/feedback.js +1 -1
  55. package/dist/es2019/quick-insert/assets/quote.js +1 -1
  56. package/dist/es2019/react-node-view/getInlineNodeViewProducer.js +1 -1
  57. package/dist/es2019/react-node-view/index.js +1 -1
  58. package/dist/es2019/selection/gap-cursor/selection.js +1 -1
  59. package/dist/es2019/selection/utils.js +2 -2
  60. package/dist/es2019/styles/shared/annotation.js +1 -1
  61. package/dist/es2019/ugc-tokens/index.js +3 -0
  62. package/dist/es2019/ui/DropList/index.js +1 -1
  63. package/dist/es2019/ui/Layer/index.js +0 -1
  64. package/dist/es2019/ui-menu/ColorPickerButton/index.js +1 -1
  65. package/dist/es2019/ui-menu/ToolbarButton/styles.js +2 -0
  66. package/dist/es2019/ui-react/with-react-editor-view-outer-listeners.js +12 -3
  67. package/dist/es2019/utils/calculate-toolbar-position.js +4 -0
  68. package/dist/es2019/utils/compareNodes.js +0 -1
  69. package/dist/es2019/utils/get-performance-options.js +0 -1
  70. package/dist/es2019/utils/is-text-input.js +0 -2
  71. package/dist/es2019/utils/table.js +2 -0
  72. package/dist/es2019/utils/validate-using-spec.js +2 -0
  73. package/dist/es2019/with-plugin-state/index.js +2 -241
  74. package/dist/esm/ai-messages/ai.js +5 -0
  75. package/dist/esm/analytics/types/general-events.js +1 -3
  76. package/dist/esm/collab/index.js +2 -0
  77. package/dist/esm/element-browser/hooks/use-select-and-focus-on-arrow-navigation.js +27 -52
  78. package/dist/esm/extensibility/MultiBodiedExtension/action-api.js +2 -0
  79. package/dist/esm/insert/index.js +2 -0
  80. package/dist/esm/keymaps/keymap.js +4 -2
  81. package/dist/esm/lazy-node-view/index.js +1 -1
  82. package/dist/esm/media-inline/inline-image-card.js +2 -0
  83. package/dist/esm/messages/annotation.js +2 -0
  84. package/dist/esm/messages/help-dialog.js +2 -0
  85. package/dist/esm/monitoring/environment.js +2 -0
  86. package/dist/esm/monitoring/error.js +3 -1
  87. package/dist/esm/node-width/index.js +0 -1
  88. package/dist/esm/quick-insert/assets/datasource-assets-objects.js +1 -1
  89. package/dist/esm/quick-insert/assets/datasource-jira-issue.js +1 -1
  90. package/dist/esm/quick-insert/assets/feedback.js +1 -1
  91. package/dist/esm/quick-insert/assets/quote.js +1 -1
  92. package/dist/esm/react-node-view/getInlineNodeViewProducer.js +1 -1
  93. package/dist/esm/react-node-view/index.js +1 -1
  94. package/dist/esm/selection/gap-cursor/selection.js +1 -1
  95. package/dist/esm/selection/utils.js +2 -2
  96. package/dist/esm/styles/shared/annotation.js +1 -1
  97. package/dist/esm/ugc-tokens/index.js +3 -0
  98. package/dist/esm/ui/DropList/index.js +1 -1
  99. package/dist/esm/ui/Layer/index.js +0 -1
  100. package/dist/esm/ui-menu/ColorPickerButton/index.js +1 -1
  101. package/dist/esm/ui-menu/ToolbarButton/styles.js +2 -0
  102. package/dist/esm/ui-react/with-react-editor-view-outer-listeners.js +13 -4
  103. package/dist/esm/utils/calculate-toolbar-position.js +4 -0
  104. package/dist/esm/utils/compareNodes.js +0 -1
  105. package/dist/esm/utils/get-performance-options.js +0 -1
  106. package/dist/esm/utils/is-text-input.js +0 -2
  107. package/dist/esm/utils/table.js +2 -0
  108. package/dist/esm/utils/validate-using-spec.js +2 -0
  109. package/dist/esm/with-plugin-state/index.js +2 -270
  110. package/dist/types/ai-messages/ai.d.ts +5 -0
  111. package/dist/types/analytics/types/ai-unified-events.d.ts +13 -6
  112. package/dist/types/selection/utils.d.ts +3 -4
  113. package/dist/types/types/annotation/index.d.ts +0 -3
  114. package/dist/types/ugc-tokens/index.d.ts +2 -0
  115. package/dist/types/ui-react/with-react-editor-view-outer-listeners.d.ts +6 -0
  116. package/dist/types/with-plugin-state/index.d.ts +0 -42
  117. package/dist/types-ts4.5/ai-messages/ai.d.ts +5 -0
  118. package/dist/types-ts4.5/analytics/types/ai-unified-events.d.ts +13 -6
  119. package/dist/types-ts4.5/selection/utils.d.ts +3 -4
  120. package/dist/types-ts4.5/types/annotation/index.d.ts +0 -3
  121. package/dist/types-ts4.5/ugc-tokens/index.d.ts +2 -0
  122. package/dist/types-ts4.5/ui-react/with-react-editor-view-outer-listeners.d.ts +6 -0
  123. package/dist/types-ts4.5/with-plugin-state/index.d.ts +0 -42
  124. package/package.json +8 -10
  125. package/ugc-tokens/package.json +17 -0
@@ -3,6 +3,8 @@ var FEDRAMP_MODERATE = 'fedramp-moderate';
3
3
  // To determine whether an instance is a FedRAMP instance
4
4
  // Copied from platform/packages/uip/atl-context/src/services/is-fedramp/index.tsx
5
5
  // We cannot import the same-named function from @atlassian/atl-context due to editor-common being a public package (and atl-context being private)
6
+ // Ignored via go/ees007
7
+ // eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
6
8
  // TODO: Seek alternatives
7
9
  export function isFedRamp() {
8
10
  var _global$location;
@@ -7,9 +7,11 @@ 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 = "101.1.2";
10
+ var packageVersion = "102.1.0";
11
11
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
12
12
  // Remove URL as it has UGC
13
+ // Ignored via go/ees007
14
+ // eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
13
15
  // TODO: Sanitise the URL instead of just removing it
14
16
  if (data.request) {
15
17
  delete data.request.url;
@@ -35,7 +35,6 @@ export var getParentNodeWidth = function getParentNodeWidth(pos, state, containe
35
35
  }
36
36
  var parentWidth = calcBreakoutNodeWidth(layout, containerWidth, isFullWidthModeEnabled);
37
37
 
38
- // TODO: ED-15663
39
38
  // Please, do not copy or use this kind of code below
40
39
  // @ts-ignore
41
40
  var contextPanelPluginKey = {
@@ -1,4 +1,4 @@
1
- // TODO: https://product-fabric.atlassian.net/browse/DSP-4138
1
+ // TODO: DSP-4138 - migrate to @atlaskit/design-system
2
2
  /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
3
3
  import React from 'react';
4
4
  export default function IconDatasourceAssetsObjects() {
@@ -1,4 +1,4 @@
1
- // TODO: https://product-fabric.atlassian.net/browse/DSP-4138
1
+ // TODO: DSP-4138 - Migrate to @atlaskit/design-system
2
2
  /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
3
3
  import React from 'react';
4
4
  export default function IconDatasourceJiraIssue() {
@@ -1,4 +1,4 @@
1
- // TODO: https://product-fabric.atlassian.net/browse/DSP-4138
1
+ // TODO: DSP-4138 - Migrate to @atlaskit/design-system
2
2
  /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
3
3
  import React from 'react';
4
4
  export default function IconFeedback() {
@@ -1,4 +1,4 @@
1
- // TODO: https://product-fabric.atlassian.net/browse/DSP-4138
1
+ // TODO: DSP-4138 - Migrate to @atlaskit/design-system
2
2
  /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
3
3
  import React from 'react';
4
4
  import { useIconThemed } from '../use-icon-themed';
@@ -267,7 +267,7 @@ function getPortalChildren(_ref2) {
267
267
  className: "".concat(inlineNodeViewClassname, "AddZeroWidthSpace")
268
268
  }), ZERO_WIDTH_SPACE), jsx(Component, _extends({
269
269
  view: nodeViewParams.view
270
- // TODO: ED-13910 - Remove the boolean to fix the prosemirror view type
270
+ // TODO: ED-13910 - Remove the boolean to fix the prosemirror view type
271
271
  // Ignored via go/ees005
272
272
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
273
273
  ,
@@ -221,7 +221,7 @@ var ReactNodeView = /*#__PURE__*/function () {
221
221
 
222
222
  // View should not process a re-render if this is false.
223
223
  // We dont want to destroy the view, so we return true.
224
- // TODO: ED-13910 Fix viewShouldUpdate readonly decoration array
224
+ // TODO: ED-13910 - Fix viewShouldUpdate readonly decoration array
225
225
  if (!this.viewShouldUpdate(node, decorations)) {
226
226
  this.node = node;
227
227
  return true;
@@ -87,7 +87,7 @@ export var GapCursorSelection = /*#__PURE__*/function (_Selection) {
87
87
  }
88
88
  var pos = $pos.pos;
89
89
 
90
- // TODO: Fix any, potential issue. ED-5048
90
+ // TODO: ED-5048 - Fix any, potential issue.
91
91
  // Ignored via go/ees005
92
92
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
93
93
  var next = null;
@@ -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.node)) {
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.node)) {
25
+ if (node && node.eq(parentNode)) {
26
26
  break;
27
27
  }
28
28
  if (i > 1 && $pos.after(i) !== $pos.after(i - 1) - 1) {
@@ -61,7 +61,7 @@ export var AnnotationSharedCSSByState = function AnnotationSharedCSSByState() {
61
61
  // emotion and token look up
62
62
  background: "var(--ds-background-accent-yellow-subtler, #F8E6A0)",
63
63
  borderBottom: "2px solid ".concat("var(--ds-border-accent-yellow, #B38600)"),
64
- // TODO: https://product-fabric.atlassian.net/browse/DSP-4147
64
+ // TODO: DSP-4147 - Annotation shadow
65
65
  boxShadow: "var(--ds-shadow-overlay, 0px 8px 12px #091E4226, 0px 0px 1px #091E424f)",
66
66
  cursor: 'pointer'
67
67
  }),
@@ -0,0 +1,3 @@
1
+ /* eslint-disable @atlaskit/editor/no-re-export */
2
+ import editorUGCToken from './get-editor-ugc-token';
3
+ export { editorUGCToken };
@@ -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 = "101.1.2";
23
+ var packageVersion = "102.1.0";
24
24
  var halfFocusRing = 1;
25
25
  var dropOffset = '0, 8';
26
26
  // Ignored via go/ees005
@@ -23,7 +23,6 @@ var defaultState = {
23
23
  position: null
24
24
  }
25
25
  },
26
- // fix Safari parent width: https://product-fabric.atlassian.net/browse/ED-1784
27
26
  cssPosition: 'absolute',
28
27
  originalHeight: null,
29
28
  maxHeight: null
@@ -51,7 +51,7 @@ var colorPickerButtonStyle = css({
51
51
  });
52
52
 
53
53
  // Control the size of color picker buttons and preview
54
- // TODO: https://product-fabric.atlassian.net/browse/DSP-4134
54
+ // TODO: DSP-4134 - Color picking UI
55
55
  /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
56
56
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
57
57
  var colorPickerWrapper = function colorPickerWrapper() {
@@ -9,6 +9,8 @@ export default /*#__PURE__*/React.forwardRef(function (props, ref) {
9
9
  // Ignored via go/ees005
10
10
  // eslint-disable-next-line react/jsx-props-no-spreading
11
11
  }, props, {
12
+ // Ignored via go/ees007
13
+ // eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
12
14
  // TODO: (from codemod) Buttons with "component", "css" or "style" prop can't be automatically migrated with codemods. Please migrate it manually.
13
15
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
14
16
  style: {
@@ -6,10 +6,11 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstruct
6
6
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
7
  import _inherits from "@babel/runtime/helpers/inherits";
8
8
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
9
- var _excluded = ["handleClickOutside", "handleEnterKeydown", "handleEscapeKeydown", "closeOnTab"];
9
+ var _excluded = ["handleClickOutside", "handleEnterKeydown", "handleEscapeKeydown", "closeOnTab", "captureClick"];
10
10
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
11
11
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
12
12
  import React, { PureComponent, useCallback, useEffect, useRef, useState } from 'react';
13
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
13
14
  import ReactEditorViewContext from './ReactEditorViewContext';
14
15
  // Use this context to pass in the reference of the element that should be considered as the outside click target
15
16
  // The outside click target is the element that should be clicked outside of to trigger the `handleClickOutside` event
@@ -68,9 +69,12 @@ var WithOutsideClick = /*#__PURE__*/function (_PureComponent) {
68
69
  key: "componentDidMount",
69
70
  value: function componentDidMount() {
70
71
  if (this.props.handleClickOutside) {
72
+ var options = this.props.captureClick && editorExperiment('platform_editor_controls', 'variant1') ? {
73
+ capture: true
74
+ } : false;
71
75
  // Ignored via go/ees005
72
76
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
73
- document.addEventListener('click', this.handleClick, false);
77
+ document.addEventListener('click', this.handleClick, options);
74
78
  }
75
79
  if (this.props.handleEscapeKeydown) {
76
80
  var _this$props$editorRef;
@@ -88,9 +92,12 @@ var WithOutsideClick = /*#__PURE__*/function (_PureComponent) {
88
92
  key: "componentWillUnmount",
89
93
  value: function componentWillUnmount() {
90
94
  if (this.props.handleClickOutside) {
95
+ var options = this.props.captureClick && editorExperiment('platform_editor_controls', 'variant1') ? {
96
+ capture: true
97
+ } : false;
91
98
  // Ignored via go/ees005
92
99
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
93
- document.removeEventListener('click', this.handleClick, false);
100
+ document.removeEventListener('click', this.handleClick, options);
94
101
  }
95
102
  if (this.props.handleEscapeKeydown) {
96
103
  var _this$props$editorRef2;
@@ -121,6 +128,7 @@ export default function withReactEditorViewOuterListeners(Component) {
121
128
  handleEnterKeydown = _ref.handleEnterKeydown,
122
129
  handleEscapeKeydown = _ref.handleEscapeKeydown,
123
130
  closeOnTab = _ref.closeOnTab,
131
+ captureClick = _ref.captureClick,
124
132
  props = _objectWithoutProperties(_ref, _excluded);
125
133
  var isActiveProp = hasIsOpen(props) ? props.isOpen : true;
126
134
  var _useState = useState(false),
@@ -152,7 +160,8 @@ export default function withReactEditorViewOuterListeners(Component) {
152
160
  handleClickOutside: handleClickOutside,
153
161
  handleEnterKeydown: handleEnterKeydown,
154
162
  handleEscapeKeydown: handleEscapeKeydown,
155
- closeOnTab: closeOnTab
163
+ closeOnTab: closeOnTab,
164
+ captureClick: captureClick
156
165
  }, /*#__PURE__*/React.createElement(Component
157
166
  // Ignored via go/ees005
158
167
  // eslint-disable-next-line react/jsx-props-no-spreading
@@ -18,6 +18,8 @@ export var calculateToolbarPositionAboveSelection = function calculateToolbarPos
18
18
  return nextPos;
19
19
  }
20
20
  // scroll wrapper for full page, fall back to document body
21
+ // Ignored via go/ees007
22
+ // eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
21
23
  // TODO: look into using getScrollGutterOptions()
22
24
  var scrollWrapper = editorView.dom.closest('.fabric-editor-popup-scroll-parent') || document.body;
23
25
  var wrapperBounds = scrollWrapper.getBoundingClientRect();
@@ -92,6 +94,8 @@ export var calculateToolbarPositionTrackHead = function calculateToolbarPosition
92
94
  return nextPos;
93
95
  }
94
96
  // scroll wrapper for full page, fall back to document body
97
+ // Ignored via go/ees007
98
+ // eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
95
99
  // TODO: look into using getScrollGutterOptions()
96
100
  var scrollWrapper = editorView.dom.closest('.fabric-editor-popup-scroll-parent') || document.body;
97
101
  var wrapperBounds = scrollWrapper.getBoundingClientRect();
@@ -157,7 +157,6 @@ function getMetaFromNode(node, options, normalizeTextParser) {
157
157
  }
158
158
  case 'mention':
159
159
  {
160
- // TODO: Check what should be the fallback when mention does not have a text
161
160
  var _text2 = firstChild.attrs.text || '';
162
161
  return {
163
162
  type: ContentType.MENTION,
@@ -8,7 +8,6 @@ var DEFAULT_SAMPLING_RATE = 100;
8
8
  var DEFAULT_SLOW_THRESHOLD = 7;
9
9
  export function getPerformanceOptions(view) {
10
10
  var _nodeViewTracking$sam, _nodeViewTracking$slo;
11
- // TODO: ED-15663
12
11
  // Please, do not copy or use this kind of code below
13
12
  // @ts-ignore
14
13
  var fakePluginKey = {
@@ -1,6 +1,4 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- // TODO: remove from editor-core utils, re-export from editor-common
3
-
4
2
  import { ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
5
3
  export var isTextInput = function isTextInput(tr) {
6
4
  var _tr$steps = _slicedToArray(tr.steps, 1),
@@ -33,6 +33,8 @@ export function getColumnWidths(node) {
33
33
  return tableColumnWidths;
34
34
  }
35
35
  export function calcTableColumnWidths(node) {
36
+ // Ignored via go/ees007
37
+ // eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
36
38
  // TODO: replaced with getColumnWidths, which correctly scans entire table for column widths
37
39
  if (fg('platform_editor_table_row_span_fix')) {
38
40
  var _firstRow = node.firstChild;
@@ -42,6 +42,8 @@ export var validationErrorHandler = function validationErrorHandler(entity, erro
42
42
  };
43
43
  }
44
44
 
45
+ // Ignored via go/ees007
46
+ // eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
45
47
  // TODO: We can repair missing content like `panel` without a `paragraph`.
46
48
  if (error.code === 'INVALID_CONTENT_LENGTH') {
47
49
  if (error.meta && options.allowUnsupportedBlock && entity.content) {
@@ -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(WithPluginStateOld, this.props);
75
+ return /*#__PURE__*/React.createElement(WithPluginStateEditionActionsWrapper, this.props);
83
76
  }
84
77
  }]);
85
78
  }(React.Component);
86
- function WithPluginStateNew(props) {
79
+ function WithPluginStateEditionActionsWrapper(props) {
87
80
  var context = React.useContext(EditorContext);
88
81
  return /*#__PURE__*/React.createElement(WithPluginStateInner
89
82
  // Ignored via go/ees005
@@ -217,7 +210,6 @@ export var WithPluginStateInner = /*#__PURE__*/function (_React$Component2) {
217
210
  return;
218
211
  }
219
212
 
220
- // TODO: ED-15663
221
213
  // Please, do not copy or use this kind of code below
222
214
  // @ts-ignore
223
215
  var fakePluginKey = {
@@ -348,265 +340,5 @@ export var WithPluginStateInner = /*#__PURE__*/function (_React$Component2) {
348
340
  }
349
341
  }]);
350
342
  }(React.Component);
351
-
352
- // Ignored via go/ees005
353
- // eslint-disable-next-line @repo/internal/react/no-class-components
354
343
  _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
344
  export { WithPluginState };
@@ -4,6 +4,11 @@ export declare const aiMessages: {
4
4
  defaultMessage: string;
5
5
  description: string;
6
6
  };
7
+ eventHubfallbackSuggestedTitlePrefix: {
8
+ id: string;
9
+ defaultMessage: string;
10
+ description: string;
11
+ };
7
12
  aiToolbarTitle: {
8
13
  id: string;
9
14
  defaultMessage: string;
@@ -14,19 +14,26 @@ export type AIUnifiedCommonAttributes = {
14
14
  aiExperienceName?: string;
15
15
  traceIds?: string[];
16
16
  };
17
- type AIInteractionInitiatedAEP = TrackAEP<ACTION.INITIATED, ACTION_SUBJECT.AI_INTERACTION, ACTION_SUBJECT_ID.EDITOR_PLUGIN_AI, AIUnifiedCommonAttributes, undefined>;
18
- type AIInteractionDismissedAEP = TrackAEP<ACTION.DISMISSED, ACTION_SUBJECT.AI_INTERACTION, ACTION_SUBJECT_ID.EDITOR_PLUGIN_AI, AIUnifiedCommonAttributes, undefined>;
19
- type AIResultViewedAEP = TrackAEP<ACTION.VIEWED, ACTION_SUBJECT.AI_RESULT, ACTION_SUBJECT_ID.EDITOR_PLUGIN_AI, AIUnifiedCommonAttributes, undefined>;
20
- type AIResultActionedAEP = TrackAEP<ACTION.ACTIONED, ACTION_SUBJECT.AI_RESULT, ACTION_SUBJECT_ID.EDITOR_PLUGIN_AI, AIUnifiedCommonAttributes & {
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;