@atlaskit/editor-common 134.18.0 → 134.20.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 (54) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/alignment-icon-map/package.json +10 -0
  3. package/credit-guard/check-ai-credit-status/package.json +10 -0
  4. package/credit-guard/popup/package.json +10 -0
  5. package/credit-guard/types/package.json +10 -0
  6. package/credit-guard/use-ai-credit-guard/package.json +10 -0
  7. package/credit-guard/use-ai-credit-status/package.json +10 -0
  8. package/credit-guard/use-credit-checked-action/package.json +10 -0
  9. package/dist/cjs/credit-guard/useAICreditStatus.js +40 -0
  10. package/dist/cjs/credit-guard/useCreditCheckedAction.js +19 -0
  11. package/dist/cjs/extensibility/Extension/InlineExtension/index.js +15 -5
  12. package/dist/cjs/extensibility/Extension/Lozenge/ExtensionLabel.js +19 -5
  13. package/dist/cjs/extensibility/Extension/Lozenge/LozengeComponent.js +4 -1
  14. package/dist/cjs/media/messages/caption.js +5 -0
  15. package/dist/cjs/messages/rule.js +10 -0
  16. package/dist/cjs/monitoring/error.js +1 -1
  17. package/dist/cjs/table/normalize-column-widths.js +68 -0
  18. package/dist/cjs/ui/DropList/index.js +1 -1
  19. package/dist/cjs/ui/OverflowShadow/index.js +31 -1
  20. package/dist/cjs/ui/alignment-icon-map.js +40 -0
  21. package/dist/es2019/credit-guard/useAICreditStatus.js +26 -0
  22. package/dist/es2019/credit-guard/useCreditCheckedAction.js +13 -0
  23. package/dist/es2019/extensibility/Extension/InlineExtension/index.js +15 -5
  24. package/dist/es2019/extensibility/Extension/Lozenge/ExtensionLabel.js +19 -5
  25. package/dist/es2019/extensibility/Extension/Lozenge/LozengeComponent.js +4 -1
  26. package/dist/es2019/media/messages/caption.js +5 -0
  27. package/dist/es2019/messages/rule.js +10 -0
  28. package/dist/es2019/monitoring/error.js +1 -1
  29. package/dist/es2019/table/normalize-column-widths.js +46 -0
  30. package/dist/es2019/ui/DropList/index.js +1 -1
  31. package/dist/es2019/ui/OverflowShadow/index.js +29 -1
  32. package/dist/es2019/ui/alignment-icon-map.js +34 -0
  33. package/dist/esm/credit-guard/useAICreditStatus.js +33 -0
  34. package/dist/esm/credit-guard/useCreditCheckedAction.js +13 -0
  35. package/dist/esm/extensibility/Extension/InlineExtension/index.js +15 -5
  36. package/dist/esm/extensibility/Extension/Lozenge/ExtensionLabel.js +19 -5
  37. package/dist/esm/extensibility/Extension/Lozenge/LozengeComponent.js +4 -1
  38. package/dist/esm/media/messages/caption.js +5 -0
  39. package/dist/esm/messages/rule.js +10 -0
  40. package/dist/esm/monitoring/error.js +1 -1
  41. package/dist/esm/table/normalize-column-widths.js +63 -0
  42. package/dist/esm/ui/DropList/index.js +1 -1
  43. package/dist/esm/ui/OverflowShadow/index.js +31 -1
  44. package/dist/esm/ui/alignment-icon-map.js +33 -0
  45. package/dist/types/credit-guard/types.d.ts +16 -1
  46. package/dist/types/credit-guard/useAICreditStatus.d.ts +3 -0
  47. package/dist/types/credit-guard/useCreditCheckedAction.d.ts +3 -0
  48. package/dist/types/media/messages/caption.d.ts +5 -0
  49. package/dist/types/messages/rule.d.ts +10 -0
  50. package/dist/types/table/normalize-column-widths.d.ts +10 -0
  51. package/dist/types/ui/OverflowShadow/index.d.ts +2 -0
  52. package/dist/types/ui/alignment-icon-map.d.ts +8 -0
  53. package/package.json +10 -10
  54. package/table/normalize-column-widths/package.json +10 -0
@@ -8,6 +8,7 @@ import React, { Fragment, useMemo } from 'react';
8
8
  import { css, jsx } from '@emotion/react';
9
9
  import classnames from 'classnames';
10
10
  import { akEditorGutterPaddingDynamic, akEditorGutterPaddingReduced, akEditorFullPageNarrowBreakout } from '@atlaskit/editor-shared-styles/constants';
11
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
11
12
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
12
13
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
13
14
  import { useSharedPluginStateWithSelector } from '../../../hooks';
@@ -80,6 +81,9 @@ const InlineExtension = props => {
80
81
  const {
81
82
  showMacroInteractionDesignUpdates
82
83
  } = macroInteractionDesignFeatureFlags || {};
84
+ // The HTML parser closes an open `<p>` at a `<div>`, so server-rendered inline
85
+ // extensions need span elements to stay inside their paragraph.
86
+ const WrapperElement = isExperimentEnabled('platform_editor_inline_extension_spans') ? 'span' : 'div';
83
87
  const {
84
88
  width
85
89
  } = useSharedPluginStateWithSelector(pluginInjectionApi, ['width'], states => {
@@ -117,22 +121,28 @@ const InlineExtension = props => {
117
121
  setIsNodeHovered: setIsNodeHovered,
118
122
  pluginInjectionApi: pluginInjectionApi,
119
123
  hideConfigureLabel: hideConfigureLabel
120
- }), jsx("div", {
121
- "data-testid": "inline-extension-wrapper",
124
+ }), jsx(WrapperElement, {
125
+ "data-testid": "inline-extension-wrapper"
126
+ // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- WrapperElement is a 'span' or 'div' tag, not a component
127
+ ,
122
128
  css: [
123
129
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
124
130
  wrapperStyle, inlineWrapperStyles, showMacroInteractionDesignUpdates && !isLivePageViewMode && hoverStyles, flowingInlineWrapperStyles]
125
131
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
126
132
  ,
127
- className: classNames,
133
+ className: classNames
134
+ // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- WrapperElement is a 'span' or 'div' tag, not a component
135
+ ,
128
136
  onMouseEnter: () => handleMouseEvent(true)
129
137
  // @atlassian/a11y/mouse-events-have-key-events: hover border is also accessible via keyboard selection.
130
138
  // No-ops here satisfy the rule without duplicating state updates.
131
139
  ,
132
- onFocus: expValEquals('editor_a11y__enghealth-46814_fy26', 'isEnabled', true) ? () => {} : undefined,
140
+ onFocus: expValEquals('editor_a11y__enghealth-46814_fy26', 'isEnabled', true) ? () => {} : undefined
141
+ // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- WrapperElement is a 'span' or 'div' tag, not a component
142
+ ,
133
143
  onMouseLeave: () => handleMouseEvent(false),
134
144
  onBlur: expValEquals('editor_a11y__enghealth-46814_fy26', 'isEnabled', true) ? () => {} : undefined
135
- }, jsx("div", {
145
+ }, jsx(WrapperElement, {
136
146
  css: overlay,
137
147
  className: "extension-overlay"
138
148
  }), children ? children : jsx(ExtensionLozenge, {
@@ -26,6 +26,11 @@ const containerStyles = css({
26
26
  marginTop: "var(--ds-space-300, 24px)"
27
27
  }
28
28
  });
29
+
30
+ // Keeps a span container laid out like the div it replaces.
31
+ const blockContainerStyles = css({
32
+ display: 'block'
33
+ });
29
34
  const showLabelStyles = css({
30
35
  opacity: 1
31
36
  });
@@ -126,6 +131,9 @@ export const ExtensionLabel = ({
126
131
  pluginInjectionApi: _pluginInjectionApi
127
132
  }) => {
128
133
  const isInlineExtension = extensionName === 'inlineExtension';
134
+ // Inside a paragraph, a div container would close the paragraph in server-rendered HTML.
135
+ const useSpanElements = isInlineExtension && isExperimentEnabled('platform_editor_inline_extension_spans');
136
+ const ContainerElement = useSpanElements ? 'span' : 'div';
129
137
  const showDefaultBodiedStyles = isBodiedMacro;
130
138
  const containerClassNames = classnames({
131
139
  bodied: isBodiedMacro
@@ -153,15 +161,18 @@ export const ExtensionLabel = ({
153
161
  };
154
162
  return (
155
163
  // eslint-disable-next-line @atlassian/a11y/no-static-element-interactions, @atlassian/a11y/click-events-have-key-events, @atlassian/a11y/interactive-element-not-keyboard-focusable
156
- jsx("div", {
157
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
158
- css: containerStyles
164
+ jsx(ContainerElement
165
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop, @atlassian/perf-linting/no-unstable-inline-props -- ContainerElement is a 'span' or 'div' tag, not a component
166
+ , {
167
+ css: [containerStyles, useSpanElements && blockContainerStyles]
159
168
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
160
169
  ,
161
170
  className: containerClassNames
162
171
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
163
172
  ,
164
- style: customContainerStyles,
173
+ style: customContainerStyles
174
+ // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- ContainerElement is a 'span' or 'div' tag, not a component
175
+ ,
165
176
  onMouseOver: () => {
166
177
  setIsNodeHovered === null || setIsNodeHovered === void 0 ? void 0 : setIsNodeHovered(true);
167
178
  }
@@ -169,7 +180,9 @@ export const ExtensionLabel = ({
169
180
  // handled via the .ak-editor-selected-node CSS class applied by ProseMirror on node selection.
170
181
  // No-ops here satisfy the rule.
171
182
  ,
172
- onFocus: expValEquals('editor_a11y__enghealth-46814_fy26', 'isEnabled', true) ? () => {} : undefined,
183
+ onFocus: expValEquals('editor_a11y__enghealth-46814_fy26', 'isEnabled', true) ? () => {} : undefined
184
+ // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- ContainerElement is a 'span' or 'div' tag, not a component
185
+ ,
173
186
  onMouseLeave: () => {
174
187
  setIsNodeHovered === null || setIsNodeHovered === void 0 ? void 0 : setIsNodeHovered(false);
175
188
  },
@@ -202,6 +215,7 @@ export const ExtensionLabel = ({
202
215
  }, jsx(CustomizeIcon, {
203
216
  label: ""
204
217
  })))), jsx(Box, {
218
+ as: useSpanElements ? 'span' : 'div',
205
219
  xcss: spacerStyles
206
220
  }))
207
221
  );
@@ -8,6 +8,7 @@ import { Fragment } from 'react';
8
8
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled, @typescript-eslint/consistent-type-imports -- Ignored via go/DSP-18766; jsx required at runtime for @jsxRuntime classic
9
9
  import { jsx } from '@emotion/react';
10
10
  import EditorFileIcon from '@atlaskit/icon/core/file';
11
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
11
12
  import { placeholderFallback, placeholderFallbackParams } from '../styles';
12
13
  import { EditToggle } from './EditToggle';
13
14
  import { ExtensionLabel } from './ExtensionLabel';
@@ -59,9 +60,11 @@ export const LozengeComponent = ({
59
60
  }));
60
61
  }
61
62
  const isBlockExtension = extensionName === 'extension';
63
+ // A div inside an inline extension would close its paragraph in server-rendered HTML.
64
+ const FallbackElement = extensionName === 'inlineExtension' && isExperimentEnabled('platform_editor_inline_extension_spans') ? 'span' : 'div';
62
65
  return (
63
66
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
64
- jsx("div", {
67
+ jsx(FallbackElement, {
65
68
  "data-testid": "lozenge-fallback",
66
69
  css: placeholderFallback
67
70
  }, lozengeData && !isBlockExtension ? renderImage({
@@ -5,6 +5,11 @@ export const captionMessages = defineMessages({
5
5
  defaultMessage: 'Add a caption',
6
6
  description: 'Placeholder description for an empty (new) caption in the editor'
7
7
  },
8
+ placeholderWithClickAgainPrompt: {
9
+ id: 'fabric.editor.captionPlaceholderWithClickAgainPrompt',
10
+ defaultMessage: 'Add a caption - click again to preview',
11
+ description: 'Placeholder description to prompt users to add a caption and click already selected media again to preview'
12
+ },
8
13
  placeholderWithDoubleClickPrompt: {
9
14
  id: 'fabric.editor.captionPlaceholderWithDoubleClickPrompt',
10
15
  defaultMessage: 'Add a caption - double-click to preview',
@@ -1,5 +1,15 @@
1
1
  import { defineMessages } from 'react-intl';
2
2
  export const ruleMessages = defineMessages({
3
+ addText: {
4
+ id: 'editor-common.messages.rule.addText',
5
+ defaultMessage: 'Add text',
6
+ description: 'Button for adding a text label to a divider.'
7
+ },
8
+ alignText: {
9
+ id: 'editor-common.messages.rule.alignText',
10
+ defaultMessage: 'Align text',
11
+ description: 'Button for aligning the text label of a divider.'
12
+ },
3
13
  customDividerColor: {
4
14
  id: 'editor-common.messages.rule.customDividerColor',
5
15
  defaultMessage: 'Custom',
@@ -13,7 +13,7 @@ const NETWORK_FAILURE_REGEX = /^network failure/i;
13
13
  const RESIZE_OBSERVER_LOOP_REGEX = /ResizeObserver loop completed with undelivered notifications/;
14
14
  const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
15
15
  const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
16
- const packageVersion = "134.17.0";
16
+ const packageVersion = "134.19.0";
17
17
  const sanitiseSentryEvents = (data, _hint) => {
18
18
  // Remove URL as it has UGC
19
19
  // Ignored via go/ees007
@@ -0,0 +1,46 @@
1
+ import { akEditorTableLegacyCellMinWidth, akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles/constants';
2
+ import { tableCellBorderWidth, tableCellMinWidth } from '../styles/shared/table';
3
+
4
+ /**
5
+ * Fits columns to a saved table width, independently of the viewport. Zero widths share the
6
+ * remaining space; minimum widths can require overflow when the saved table is too narrow.
7
+ */
8
+ export const normalizeTableColumnWidths = ({
9
+ columnWidths,
10
+ isNumberColumnEnabled,
11
+ skipMinWidth = false,
12
+ tableWidth
13
+ }) => {
14
+ const unsizedCount = columnWidths.filter(width => width === 0).length;
15
+ const minWidth = skipMinWidth ? 0 : unsizedCount && unsizedCount < columnWidths.length ? akEditorTableLegacyCellMinWidth : tableCellMinWidth;
16
+ let availableWidth = Math.max(tableWidth - tableCellBorderWidth - (isNumberColumnEnabled ? akEditorTableNumberColumnWidth : 0), columnWidths.length * minWidth);
17
+ const widths = columnWidths.map(width => width ? Math.max(width - tableCellBorderWidth, minWidth) : 0);
18
+ let remaining = columnWidths.flatMap((width, index) => width ? [index] : []);
19
+ if (unsizedCount) {
20
+ const sizedTotal = widths.reduce((sum, width) => sum + width, 0);
21
+ const unsizedWidth = Math.max((availableWidth - sizedTotal) / unsizedCount, minWidth);
22
+ columnWidths.forEach((width, index) => {
23
+ if (!width) {
24
+ widths[index] = unsizedWidth;
25
+ }
26
+ });
27
+ availableWidth -= unsizedWidth * unsizedCount;
28
+ }
29
+ while (remaining.length) {
30
+ const total = remaining.reduce((sum, index) => sum + widths[index], 0);
31
+ const scale = total ? availableWidth / total : 0;
32
+ const constrained = remaining.filter(index => widths[index] * scale < minWidth);
33
+ if (!constrained.length) {
34
+ remaining.forEach(index => {
35
+ widths[index] = total ? widths[index] * scale : availableWidth / remaining.length;
36
+ });
37
+ break;
38
+ }
39
+ constrained.forEach(index => {
40
+ widths[index] = minWidth;
41
+ availableWidth -= minWidth;
42
+ });
43
+ remaining = remaining.filter(index => !constrained.includes(index));
44
+ }
45
+ return widths;
46
+ };
@@ -13,7 +13,7 @@ import withAnalyticsContext from '@atlaskit/analytics-next/withAnalyticsContext'
13
13
  import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
14
14
  import Layer from '../Layer';
15
15
  const packageName = "@atlaskit/editor-common";
16
- const packageVersion = "134.17.0";
16
+ const packageVersion = "134.19.0";
17
17
  const halfFocusRing = 1;
18
18
  const dropOffset = '0, 8';
19
19
  // Ignored via go/ees005
@@ -91,7 +91,19 @@ export default function overflowShadow(Component, options) {
91
91
  this.overflowContainer.addEventListener('scroll', this.handleScroll);
92
92
  });
93
93
  }
94
+ static getDerivedStateFromProps(props, state) {
95
+ if (props.disableShadowTracking && (state.showLeftShadow || state.showRightShadow)) {
96
+ return {
97
+ showLeftShadow: false,
98
+ showRightShadow: false
99
+ };
100
+ }
101
+ return null;
102
+ }
94
103
  get isDisabled() {
104
+ if (this.props.disableShadowTracking) {
105
+ return true;
106
+ }
95
107
  if (this.disabled === undefined) {
96
108
  var _options$isDisabled, _options$isDisabled2;
97
109
  this.disabled = (_options$isDisabled = (_options$isDisabled2 = options.isDisabled) === null || _options$isDisabled2 === void 0 ? void 0 : _options$isDisabled2.call(options)) !== null && _options$isDisabled !== void 0 ? _options$isDisabled : false;
@@ -109,7 +121,20 @@ export default function overflowShadow(Component, options) {
109
121
  }
110
122
  this.updateShadows();
111
123
  }
112
- componentDidUpdate() {
124
+ componentDidUpdate(prevProps) {
125
+ if (this.props.disableShadowTracking !== prevProps.disableShadowTracking) {
126
+ if (this.props.disableShadowTracking) {
127
+ var _this$shadowObserver, _this$overflowContain;
128
+ (_this$shadowObserver = this.shadowObserver) === null || _this$shadowObserver === void 0 ? void 0 : _this$shadowObserver.dispose();
129
+ this.shadowObserver = undefined;
130
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
131
+ (_this$overflowContain = this.overflowContainer) === null || _this$overflowContain === void 0 ? void 0 : _this$overflowContain.removeEventListener('scroll', this.handleScroll);
132
+ } else if (prevProps.disableShadowTracking && this.container) {
133
+ const container = this.container;
134
+ this.container = undefined;
135
+ this.handleContainer(container);
136
+ }
137
+ }
113
138
  if (!options.useShadowObserver) {
114
139
  this.updateShadows();
115
140
  }
@@ -121,6 +146,9 @@ export default function overflowShadow(Component, options) {
121
146
  this.shadowObserver = new ShadowObserver({
122
147
  scrollContainer: this.overflowContainer,
123
148
  onUpdateShadows: shadowStates => {
149
+ if (this.props.disableShadowTracking) {
150
+ return;
151
+ }
124
152
  this.setState(prevState => {
125
153
  const {
126
154
  showLeftShadow,
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+ import { useIntl } from 'react-intl';
3
+ import AlignTextCenterIcon from '@atlaskit/icon/core/align-text-center';
4
+ import AlignTextLeftIcon from '@atlaskit/icon/core/align-text-left';
5
+ import AlignTextRightIcon from '@atlaskit/icon/core/align-text-right';
6
+ import { alignmentMessages as messages } from '../messages/alignment';
7
+ const iconAndMessageMap = {
8
+ start: {
9
+ Component: AlignTextLeftIcon,
10
+ label: messages.alignLeft
11
+ },
12
+ end: {
13
+ Component: AlignTextRightIcon,
14
+ label: messages.alignRight
15
+ },
16
+ center: {
17
+ Component: AlignTextCenterIcon,
18
+ label: messages.alignCenter
19
+ }
20
+ };
21
+ export const AlignmentIconMap = props => {
22
+ var _iconAndMessageMap$pr, _props$size;
23
+ const {
24
+ Component,
25
+ label
26
+ } = (_iconAndMessageMap$pr = iconAndMessageMap[props.alignment]) !== null && _iconAndMessageMap$pr !== void 0 ? _iconAndMessageMap$pr : iconAndMessageMap.center;
27
+ const intl = useIntl();
28
+ return /*#__PURE__*/React.createElement(Component, {
29
+ label: intl.formatMessage(label),
30
+ color: "currentColor",
31
+ spacing: "spacious",
32
+ size: (_props$size = props.size) !== null && _props$size !== void 0 ? _props$size : 'medium'
33
+ });
34
+ };
@@ -0,0 +1,33 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import { useEffect, useState } from 'react';
3
+ import { checkAICreditStatus } from './checkAICreditStatus';
4
+ var available = {
5
+ isBlocked: false
6
+ };
7
+
8
+ /** Reuses cached product decisions; notifications preserve live depletion and recovery. */
9
+ export var useAICreditStatus = function useAICreditStatus(provider, featureName) {
10
+ var isActive = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
11
+ var getAICreditStatus = provider === null || provider === void 0 ? void 0 : provider.getAICreditStatus;
12
+ var subscribe = provider === null || provider === void 0 ? void 0 : provider.subscribeToAICreditStatus;
13
+ var _useState = useState(function () {
14
+ return isActive && getAICreditStatus ? checkAICreditStatus(getAICreditStatus, {
15
+ featureName: featureName
16
+ }) : available;
17
+ }),
18
+ _useState2 = _slicedToArray(_useState, 2),
19
+ status = _useState2[0],
20
+ setStatus = _useState2[1];
21
+ useEffect(function () {
22
+ if (!isActive) return;
23
+ var refresh = function refresh() {
24
+ setStatus(getAICreditStatus ? checkAICreditStatus(getAICreditStatus, {
25
+ featureName: featureName
26
+ }) : available);
27
+ };
28
+ var unsubscribe = subscribe === null || subscribe === void 0 ? void 0 : subscribe(refresh);
29
+ refresh();
30
+ return unsubscribe;
31
+ }, [featureName, getAICreditStatus, subscribe, isActive]);
32
+ return isActive && getAICreditStatus ? status : available;
33
+ };
@@ -0,0 +1,13 @@
1
+ import { useCallback } from 'react';
2
+ import { checkAICreditStatus } from './checkAICreditStatus';
3
+ /** Recheck synchronously at activation using the same shared guard as other Editor actions. */
4
+ export var useCreditCheckedAction = function useCreditCheckedAction(provider, featureName) {
5
+ var getAICreditStatus = provider === null || provider === void 0 ? void 0 : provider.getAICreditStatus;
6
+ return useCallback(function (action) {
7
+ if (!getAICreditStatus || !checkAICreditStatus(getAICreditStatus, {
8
+ featureName: featureName
9
+ }).isBlocked) {
10
+ action();
11
+ }
12
+ }, [getAICreditStatus, featureName]);
13
+ };
@@ -8,6 +8,7 @@ import React, { Fragment, useMemo } from 'react';
8
8
  import { css, jsx } from '@emotion/react';
9
9
  import classnames from 'classnames';
10
10
  import { akEditorGutterPaddingDynamic, akEditorGutterPaddingReduced, akEditorFullPageNarrowBreakout } from '@atlaskit/editor-shared-styles/constants';
11
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
11
12
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
12
13
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
13
14
  import { useSharedPluginStateWithSelector } from '../../../hooks';
@@ -77,6 +78,9 @@ var InlineExtension = function InlineExtension(props) {
77
78
  hideConfigureLabel = props.hideConfigureLabel;
78
79
  var _ref3 = macroInteractionDesignFeatureFlags || {},
79
80
  showMacroInteractionDesignUpdates = _ref3.showMacroInteractionDesignUpdates;
81
+ // The HTML parser closes an open `<p>` at a `<div>`, so server-rendered inline
82
+ // extensions need span elements to stay inside their paragraph.
83
+ var WrapperElement = isExperimentEnabled('platform_editor_inline_extension_spans') ? 'span' : 'div';
80
84
  var _useSharedPluginState = useSharedPluginStateWithSelector(pluginInjectionApi, ['width'], function (states) {
81
85
  var _states$widthState;
82
86
  return {
@@ -113,26 +117,32 @@ var InlineExtension = function InlineExtension(props) {
113
117
  setIsNodeHovered: setIsNodeHovered,
114
118
  pluginInjectionApi: pluginInjectionApi,
115
119
  hideConfigureLabel: hideConfigureLabel
116
- }), jsx("div", {
117
- "data-testid": "inline-extension-wrapper",
120
+ }), jsx(WrapperElement, {
121
+ "data-testid": "inline-extension-wrapper"
122
+ // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- WrapperElement is a 'span' or 'div' tag, not a component
123
+ ,
118
124
  css: [
119
125
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
120
126
  wrapperStyle, inlineWrapperStyles, showMacroInteractionDesignUpdates && !isLivePageViewMode && hoverStyles, flowingInlineWrapperStyles]
121
127
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
122
128
  ,
123
- className: classNames,
129
+ className: classNames
130
+ // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- WrapperElement is a 'span' or 'div' tag, not a component
131
+ ,
124
132
  onMouseEnter: function onMouseEnter() {
125
133
  return handleMouseEvent(true);
126
134
  }
127
135
  // @atlassian/a11y/mouse-events-have-key-events: hover border is also accessible via keyboard selection.
128
136
  // No-ops here satisfy the rule without duplicating state updates.
129
137
  ,
130
- onFocus: expValEquals('editor_a11y__enghealth-46814_fy26', 'isEnabled', true) ? function () {} : undefined,
138
+ onFocus: expValEquals('editor_a11y__enghealth-46814_fy26', 'isEnabled', true) ? function () {} : undefined
139
+ // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- WrapperElement is a 'span' or 'div' tag, not a component
140
+ ,
131
141
  onMouseLeave: function onMouseLeave() {
132
142
  return handleMouseEvent(false);
133
143
  },
134
144
  onBlur: expValEquals('editor_a11y__enghealth-46814_fy26', 'isEnabled', true) ? function () {} : undefined
135
- }, jsx("div", {
145
+ }, jsx(WrapperElement, {
136
146
  css: overlay,
137
147
  className: "extension-overlay"
138
148
  }), children ? children : jsx(ExtensionLozenge, {
@@ -26,6 +26,11 @@ var containerStyles = css({
26
26
  marginTop: "var(--ds-space-300, 24px)"
27
27
  }
28
28
  });
29
+
30
+ // Keeps a span container laid out like the div it replaces.
31
+ var blockContainerStyles = css({
32
+ display: 'block'
33
+ });
29
34
  var showLabelStyles = css({
30
35
  opacity: 1
31
36
  });
@@ -125,6 +130,9 @@ export var ExtensionLabel = function ExtensionLabel(_ref) {
125
130
  showBodiedExtensionRendererView = _ref.showBodiedExtensionRendererView,
126
131
  _pluginInjectionApi = _ref.pluginInjectionApi;
127
132
  var isInlineExtension = extensionName === 'inlineExtension';
133
+ // Inside a paragraph, a div container would close the paragraph in server-rendered HTML.
134
+ var useSpanElements = isInlineExtension && isExperimentEnabled('platform_editor_inline_extension_spans');
135
+ var ContainerElement = useSpanElements ? 'span' : 'div';
128
136
  var showDefaultBodiedStyles = isBodiedMacro;
129
137
  var containerClassNames = classnames({
130
138
  bodied: isBodiedMacro
@@ -154,15 +162,18 @@ export var ExtensionLabel = function ExtensionLabel(_ref) {
154
162
  };
155
163
  return (
156
164
  // eslint-disable-next-line @atlassian/a11y/no-static-element-interactions, @atlassian/a11y/click-events-have-key-events, @atlassian/a11y/interactive-element-not-keyboard-focusable
157
- jsx("div", {
158
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
159
- css: containerStyles
165
+ jsx(ContainerElement
166
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop, @atlassian/perf-linting/no-unstable-inline-props -- ContainerElement is a 'span' or 'div' tag, not a component
167
+ , {
168
+ css: [containerStyles, useSpanElements && blockContainerStyles]
160
169
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
161
170
  ,
162
171
  className: containerClassNames
163
172
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
164
173
  ,
165
- style: customContainerStyles,
174
+ style: customContainerStyles
175
+ // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- ContainerElement is a 'span' or 'div' tag, not a component
176
+ ,
166
177
  onMouseOver: function onMouseOver() {
167
178
  setIsNodeHovered === null || setIsNodeHovered === void 0 || setIsNodeHovered(true);
168
179
  }
@@ -170,7 +181,9 @@ export var ExtensionLabel = function ExtensionLabel(_ref) {
170
181
  // handled via the .ak-editor-selected-node CSS class applied by ProseMirror on node selection.
171
182
  // No-ops here satisfy the rule.
172
183
  ,
173
- onFocus: expValEquals('editor_a11y__enghealth-46814_fy26', 'isEnabled', true) ? function () {} : undefined,
184
+ onFocus: expValEquals('editor_a11y__enghealth-46814_fy26', 'isEnabled', true) ? function () {} : undefined
185
+ // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- ContainerElement is a 'span' or 'div' tag, not a component
186
+ ,
174
187
  onMouseLeave: function onMouseLeave() {
175
188
  setIsNodeHovered === null || setIsNodeHovered === void 0 || setIsNodeHovered(false);
176
189
  },
@@ -205,6 +218,7 @@ export var ExtensionLabel = function ExtensionLabel(_ref) {
205
218
  label: ""
206
219
  })));
207
220
  }), jsx(Box, {
221
+ as: useSpanElements ? 'span' : 'div',
208
222
  xcss: spacerStyles
209
223
  }))
210
224
  );
@@ -11,6 +11,7 @@ import { Fragment } from 'react';
11
11
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled, @typescript-eslint/consistent-type-imports -- Ignored via go/DSP-18766; jsx required at runtime for @jsxRuntime classic
12
12
  import { jsx } from '@emotion/react';
13
13
  import EditorFileIcon from '@atlaskit/icon/core/file';
14
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
14
15
  import { placeholderFallback, placeholderFallbackParams } from '../styles';
15
16
  import { EditToggle } from './EditToggle';
16
17
  import { ExtensionLabel } from './ExtensionLabel';
@@ -61,9 +62,11 @@ export var LozengeComponent = function LozengeComponent(_ref) {
61
62
  }));
62
63
  }
63
64
  var isBlockExtension = extensionName === 'extension';
65
+ // A div inside an inline extension would close its paragraph in server-rendered HTML.
66
+ var FallbackElement = extensionName === 'inlineExtension' && isExperimentEnabled('platform_editor_inline_extension_spans') ? 'span' : 'div';
64
67
  return (
65
68
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
66
- jsx("div", {
69
+ jsx(FallbackElement, {
67
70
  "data-testid": "lozenge-fallback",
68
71
  css: placeholderFallback
69
72
  }, lozengeData && !isBlockExtension ? renderImage(_objectSpread({
@@ -5,6 +5,11 @@ export var captionMessages = defineMessages({
5
5
  defaultMessage: 'Add a caption',
6
6
  description: 'Placeholder description for an empty (new) caption in the editor'
7
7
  },
8
+ placeholderWithClickAgainPrompt: {
9
+ id: 'fabric.editor.captionPlaceholderWithClickAgainPrompt',
10
+ defaultMessage: 'Add a caption - click again to preview',
11
+ description: 'Placeholder description to prompt users to add a caption and click already selected media again to preview'
12
+ },
8
13
  placeholderWithDoubleClickPrompt: {
9
14
  id: 'fabric.editor.captionPlaceholderWithDoubleClickPrompt',
10
15
  defaultMessage: 'Add a caption - double-click to preview',
@@ -1,5 +1,15 @@
1
1
  import { defineMessages } from 'react-intl';
2
2
  export var ruleMessages = defineMessages({
3
+ addText: {
4
+ id: 'editor-common.messages.rule.addText',
5
+ defaultMessage: 'Add text',
6
+ description: 'Button for adding a text label to a divider.'
7
+ },
8
+ alignText: {
9
+ id: 'editor-common.messages.rule.alignText',
10
+ defaultMessage: 'Align text',
11
+ description: 'Button for aligning the text label of a divider.'
12
+ },
3
13
  customDividerColor: {
4
14
  id: 'editor-common.messages.rule.customDividerColor',
5
15
  defaultMessage: 'Custom',
@@ -19,7 +19,7 @@ var NETWORK_FAILURE_REGEX = /^network failure/i;
19
19
  var RESIZE_OBSERVER_LOOP_REGEX = /ResizeObserver loop completed with undelivered notifications/;
20
20
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
21
21
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
22
- var packageVersion = "134.17.0";
22
+ var packageVersion = "134.19.0";
23
23
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
24
24
  // Remove URL as it has UGC
25
25
  // Ignored via go/ees007
@@ -0,0 +1,63 @@
1
+ import { akEditorTableLegacyCellMinWidth, akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles/constants';
2
+ import { tableCellBorderWidth, tableCellMinWidth } from '../styles/shared/table';
3
+
4
+ /**
5
+ * Fits columns to a saved table width, independently of the viewport. Zero widths share the
6
+ * remaining space; minimum widths can require overflow when the saved table is too narrow.
7
+ */
8
+ export var normalizeTableColumnWidths = function normalizeTableColumnWidths(_ref) {
9
+ var columnWidths = _ref.columnWidths,
10
+ isNumberColumnEnabled = _ref.isNumberColumnEnabled,
11
+ _ref$skipMinWidth = _ref.skipMinWidth,
12
+ skipMinWidth = _ref$skipMinWidth === void 0 ? false : _ref$skipMinWidth,
13
+ tableWidth = _ref.tableWidth;
14
+ var unsizedCount = columnWidths.filter(function (width) {
15
+ return width === 0;
16
+ }).length;
17
+ var minWidth = skipMinWidth ? 0 : unsizedCount && unsizedCount < columnWidths.length ? akEditorTableLegacyCellMinWidth : tableCellMinWidth;
18
+ var availableWidth = Math.max(tableWidth - tableCellBorderWidth - (isNumberColumnEnabled ? akEditorTableNumberColumnWidth : 0), columnWidths.length * minWidth);
19
+ var widths = columnWidths.map(function (width) {
20
+ return width ? Math.max(width - tableCellBorderWidth, minWidth) : 0;
21
+ });
22
+ var remaining = columnWidths.flatMap(function (width, index) {
23
+ return width ? [index] : [];
24
+ });
25
+ if (unsizedCount) {
26
+ var sizedTotal = widths.reduce(function (sum, width) {
27
+ return sum + width;
28
+ }, 0);
29
+ var unsizedWidth = Math.max((availableWidth - sizedTotal) / unsizedCount, minWidth);
30
+ columnWidths.forEach(function (width, index) {
31
+ if (!width) {
32
+ widths[index] = unsizedWidth;
33
+ }
34
+ });
35
+ availableWidth -= unsizedWidth * unsizedCount;
36
+ }
37
+ var _loop = function _loop() {
38
+ var total = remaining.reduce(function (sum, index) {
39
+ return sum + widths[index];
40
+ }, 0);
41
+ var scale = total ? availableWidth / total : 0;
42
+ var constrained = remaining.filter(function (index) {
43
+ return widths[index] * scale < minWidth;
44
+ });
45
+ if (!constrained.length) {
46
+ remaining.forEach(function (index) {
47
+ widths[index] = total ? widths[index] * scale : availableWidth / remaining.length;
48
+ });
49
+ return 1; // break
50
+ }
51
+ constrained.forEach(function (index) {
52
+ widths[index] = minWidth;
53
+ availableWidth -= minWidth;
54
+ });
55
+ remaining = remaining.filter(function (index) {
56
+ return !constrained.includes(index);
57
+ });
58
+ };
59
+ while (remaining.length) {
60
+ if (_loop()) break;
61
+ }
62
+ return widths;
63
+ };
@@ -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 = "134.17.0";
23
+ var packageVersion = "134.19.0";
24
24
  var halfFocusRing = 1;
25
25
  var dropOffset = '0, 8';
26
26
  // Ignored via go/ees005