@atlaskit/renderer 113.2.2 → 114.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.
Files changed (50) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/afm-cc/tsconfig.json +3 -0
  3. package/afm-jira/tsconfig.json +3 -0
  4. package/afm-post-office/tsconfig.json +3 -0
  5. package/dist/cjs/actions/index.js +3 -2
  6. package/dist/cjs/react/index.js +2 -2
  7. package/dist/cjs/react/nodes/heading-anchor.js +1 -1
  8. package/dist/cjs/react/nodes/heading.js +13 -1
  9. package/dist/cjs/react/nodes/mediaSingle/index.js +0 -3
  10. package/dist/cjs/react/nodes/multiBodiedExtension.js +2 -0
  11. package/dist/cjs/react/nodes/table/sticky.js +1 -1
  12. package/dist/cjs/ui/MediaCard.js +1 -1
  13. package/dist/cjs/ui/Renderer/RendererStyleContainer.js +12 -0
  14. package/dist/cjs/ui/Renderer/index.js +9 -7
  15. package/dist/cjs/ui/Renderer/rendererHelper.js +53 -0
  16. package/dist/cjs/ui/Renderer/style.js +2 -5
  17. package/dist/cjs/ui/Renderer/truncated-wrapper.js +1 -1
  18. package/dist/es2019/actions/index.js +3 -2
  19. package/dist/es2019/react/index.js +2 -2
  20. package/dist/es2019/react/nodes/heading-anchor.js +1 -1
  21. package/dist/es2019/react/nodes/heading.js +13 -1
  22. package/dist/es2019/react/nodes/mediaSingle/index.js +0 -3
  23. package/dist/es2019/react/nodes/multiBodiedExtension.js +2 -0
  24. package/dist/es2019/react/nodes/table/sticky.js +1 -1
  25. package/dist/es2019/ui/MediaCard.js +1 -1
  26. package/dist/es2019/ui/Renderer/RendererStyleContainer.js +12 -0
  27. package/dist/es2019/ui/Renderer/index.js +9 -7
  28. package/dist/es2019/ui/Renderer/rendererHelper.js +43 -0
  29. package/dist/es2019/ui/Renderer/style.js +36 -35
  30. package/dist/es2019/ui/Renderer/truncated-wrapper.js +1 -1
  31. package/dist/esm/actions/index.js +3 -2
  32. package/dist/esm/react/index.js +2 -2
  33. package/dist/esm/react/nodes/heading-anchor.js +1 -1
  34. package/dist/esm/react/nodes/heading.js +13 -1
  35. package/dist/esm/react/nodes/mediaSingle/index.js +0 -3
  36. package/dist/esm/react/nodes/multiBodiedExtension.js +2 -0
  37. package/dist/esm/react/nodes/table/sticky.js +1 -1
  38. package/dist/esm/ui/MediaCard.js +1 -1
  39. package/dist/esm/ui/Renderer/RendererStyleContainer.js +12 -0
  40. package/dist/esm/ui/Renderer/index.js +9 -7
  41. package/dist/esm/ui/Renderer/rendererHelper.js +46 -0
  42. package/dist/esm/ui/Renderer/style.js +2 -5
  43. package/dist/esm/ui/Renderer/truncated-wrapper.js +1 -1
  44. package/dist/types/ui/Renderer/index.d.ts +1 -0
  45. package/dist/types/ui/Renderer/rendererHelper.d.ts +2 -0
  46. package/dist/types/ui/renderer-props.d.ts +3 -0
  47. package/dist/types-ts4.5/ui/Renderer/index.d.ts +1 -0
  48. package/dist/types-ts4.5/ui/Renderer/rendererHelper.d.ts +2 -0
  49. package/dist/types-ts4.5/ui/renderer-props.d.ts +3 -0
  50. package/package.json +5 -4
@@ -44,10 +44,11 @@ import { TruncatedWrapper } from './truncated-wrapper';
44
44
  import { ValidationContext } from './ValidationContext';
45
45
  import { RendererStyleContainer } from './RendererStyleContainer';
46
46
  import { getBaseFontSize } from './get-base-font-size';
47
+ import { removeEmptySpaceAroundContent } from './rendererHelper';
47
48
  export const NORMAL_SEVERITY_THRESHOLD = 2000;
48
49
  export const DEGRADED_SEVERITY_THRESHOLD = 3000;
49
50
  const packageName = "@atlaskit/renderer";
50
- const packageVersion = "113.2.2";
51
+ const packageVersion = "114.0.0";
51
52
  const setAsQueryContainerStyles = css({
52
53
  containerName: 'ak-renderer-wrapper',
53
54
  containerType: 'inline-size',
@@ -285,7 +286,7 @@ export class __RendererClassComponent extends PureComponent {
285
286
  // does not currently support SSR, should not be enabled in environments where Renderer is SSR-ed
286
287
  allowWindowedCodeBlock: featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.allowWindowedCodeBlock,
287
288
  isInsideOfInlineExtension: props.isInsideOfInlineExtension,
288
- textHighlighter: props.UNSTABLE_textHighlighter,
289
+ textHighlighter: props.textHighlighter || props.UNSTABLE_textHighlighter,
289
290
  allowTableAlignment: props.UNSTABLE_allowTableAlignment,
290
291
  allowTableResizing: props.UNSTABLE_allowTableResizing
291
292
  };
@@ -371,7 +372,7 @@ export class __RendererClassComponent extends PureComponent {
371
372
  result,
372
373
  stat,
373
374
  pmDoc
374
- } = renderDocument(adfDocument, this.serializer, schema, adfStage, this.props.useSpecBasedValidator, this.id, this.fireAnalyticsEvent, this.props.unsupportedContentLevelsTracking, this.props.appearance, this.props.includeNodesCountInStats, skipValidation);
375
+ } = renderDocument(this.props.shouldRemoveEmptySpaceAroundContent ? removeEmptySpaceAroundContent(adfDocument) : adfDocument, this.serializer, schema, adfStage, this.props.useSpecBasedValidator, this.id, this.fireAnalyticsEvent, this.props.unsupportedContentLevelsTracking, this.props.appearance, this.props.includeNodesCountInStats, skipValidation);
375
376
  if (onComplete) {
376
377
  onComplete(stat);
377
378
  }
@@ -592,7 +593,7 @@ const RendererFunctionalComponent = props => {
592
593
  extensionHandlers: props.extensionHandlers,
593
594
  portal: props.portal,
594
595
  objectContext: {
595
- adDoc: props.document,
596
+ adDoc: props.shouldRemoveEmptySpaceAroundContent ? removeEmptySpaceAroundContent(props.document) : props.document,
596
597
  schema: props.schema,
597
598
  ...props.rendererContext
598
599
  },
@@ -620,7 +621,7 @@ const RendererFunctionalComponent = props => {
620
621
  nodeComponents: props.nodeComponents,
621
622
  allowWindowedCodeBlock: featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.allowWindowedCodeBlock,
622
623
  isInsideOfInlineExtension: props.isInsideOfInlineExtension,
623
- textHighlighter: props.UNSTABLE_textHighlighter,
624
+ textHighlighter: props.textHighlighter || props.UNSTABLE_textHighlighter,
624
625
  allowTableAlignment: props.UNSTABLE_allowTableAlignment,
625
626
  allowTableResizing: props.UNSTABLE_allowTableResizing
626
627
  };
@@ -744,7 +745,7 @@ const RendererFunctionalComponent = props => {
744
745
  result,
745
746
  stat,
746
747
  pmDoc
747
- } = renderDocument(props.document, serializer, schema, props.adfStage, props.useSpecBasedValidator, id, fireAnalyticsEvent, props.unsupportedContentLevelsTracking, props.appearance, props.includeNodesCountInStats, props.skipValidation);
748
+ } = renderDocument(props.shouldRemoveEmptySpaceAroundContent ? removeEmptySpaceAroundContent(props.document) : props.document, serializer, schema, props.adfStage, props.useSpecBasedValidator, id, fireAnalyticsEvent, props.unsupportedContentLevelsTracking, props.appearance, props.includeNodesCountInStats, props.skipValidation);
748
749
  if (props.onComplete) {
749
750
  props.onComplete(stat);
750
751
  }
@@ -774,7 +775,8 @@ const RendererFunctionalComponent = props => {
774
775
  onMouseDown: onMouseDownEditView,
775
776
  ssr: (_props$media = props.media) === null || _props$media === void 0 ? void 0 : _props$media.ssr,
776
777
  isInsideOfInlineExtension: props.isInsideOfInlineExtension,
777
- isTopLevelRenderer: createRendererContext(props.featureFlags, props.isTopLevelRenderer).isTopLevelRenderer
778
+ isTopLevelRenderer: createRendererContext(props.featureFlags, props.isTopLevelRenderer).isTopLevelRenderer,
779
+ shouldRemoveEmptySpaceAroundContent: props.shouldRemoveEmptySpaceAroundContent
778
780
  }, props.enableSsrInlineScripts || props.noOpSSRInlineScript ? jsx(BreakoutSSRInlineScript, {
779
781
  noOpSSRInlineScript: Boolean(props.noOpSSRInlineScript)
780
782
  }) : null, jsx(RendererActionsInternalUpdater, {
@@ -0,0 +1,43 @@
1
+ export const removeEmptySpaceAroundContent = document => {
2
+ // Check if the document is valid
3
+ if (!document || !document.content || !Array.isArray(document.content)) {
4
+ return document;
5
+ }
6
+ const isParagraphWithContent = node => {
7
+ if (node.type !== 'paragraph' || !node.content || node.content.length === 0) {
8
+ return false;
9
+ }
10
+ // Check if paragraph has any content other than `hardBreak`
11
+ return node.content.some(child => (child === null || child === void 0 ? void 0 : child.type) !== 'hardBreak');
12
+ };
13
+ const content = document.content;
14
+ let firstContentIndex = -1;
15
+ let lastContentIndex = -1;
16
+
17
+ // Find the first and last paragraphs with content
18
+ for (let i = 0; i < content.length; i++) {
19
+ if (isParagraphWithContent(content[i])) {
20
+ if (firstContentIndex === -1) {
21
+ firstContentIndex = i;
22
+ }
23
+ lastContentIndex = i;
24
+ }
25
+ }
26
+
27
+ // If no content was found, return an empty document
28
+ if (firstContentIndex === -1) {
29
+ return {
30
+ ...document,
31
+ content: []
32
+ };
33
+ }
34
+
35
+ // Slice the content array to include only paragraphs between the first and last content
36
+ const trimmedContent = content.slice(firstContentIndex, lastContentIndex + 1);
37
+
38
+ // Return a new document with the trimmed content
39
+ return {
40
+ ...document,
41
+ content: trimmedContent
42
+ };
43
+ };
@@ -118,26 +118,24 @@ const headingSizes = {
118
118
  lineHeight: getLineHeight('h100')
119
119
  }
120
120
  };
121
- const headingAnchorStyle = headingTag =>
122
- // TODO Delete this comment after verifying space token -> previous value `margin-left: 6px`
123
- css`
124
- /**
121
+ const headingAnchorStyle = headingTag => css`
122
+ /**
125
123
  * The copy link button doesn't reserve space in the DOM so that
126
124
  * the text alignment isn't impacted by the button/icon's space.
127
125
  */
128
- .${HeadingAnchorWrapperClassName} {
129
- position: absolute;
130
- height: ${headingSizes[headingTag].lineHeight}em;
126
+ .${HeadingAnchorWrapperClassName} {
127
+ position: absolute;
128
+ height: ${headingSizes[headingTag].lineHeight}em;
131
129
 
132
- margin-left: ${"var(--ds-space-075, 6px)"};
130
+ margin-left: ${"var(--ds-space-075, 6px)"};
133
131
 
134
- button {
135
- padding-left: 0;
136
- padding-right: 0;
137
- }
132
+ button {
133
+ padding-left: 0;
134
+ padding-right: 0;
138
135
  }
136
+ }
139
137
 
140
- /**
138
+ /**
141
139
  * Applies hover effects to the heading anchor link button
142
140
  * to fade in when the user rolls over the heading.
143
141
  *
@@ -146,42 +144,41 @@ css`
146
144
  *
147
145
  * @see https://caniuse.com/mdn-css_at-rules_media_hover
148
146
  */
149
- @media (hover: hover) and (pointer: fine) {
150
- .${HeadingAnchorWrapperClassName} {
151
- > button {
152
- opacity: 0;
153
- transform: translate(-8px, 0px);
154
- transition:
155
- opacity 0.2s ease 0s,
156
- transform 0.2s ease 0s;
157
- }
147
+ @media (hover: hover) and (pointer: fine) {
148
+ .${HeadingAnchorWrapperClassName} {
149
+ > button {
150
+ opacity: 0;
151
+ transform: translate(-8px, 0px);
152
+ transition:
153
+ opacity 0.2s ease 0s,
154
+ transform 0.2s ease 0s;
158
155
  }
156
+ }
159
157
 
160
- &:hover {
161
- .${HeadingAnchorWrapperClassName} > button {
162
- opacity: 1;
163
- transform: none !important;
164
- }
158
+ &:hover {
159
+ .${HeadingAnchorWrapperClassName} > button {
160
+ opacity: 1;
161
+ transform: none !important;
165
162
  }
166
163
  }
164
+ }
167
165
 
168
- /**
166
+ /**
169
167
  * Adds the visibility of the button when in focus through keyboard navigation.
170
168
  */
171
- .${HeadingAnchorWrapperClassName} {
172
- button:focus {
173
- opacity: 1;
174
- transform: none !important;
175
- }
169
+ .${HeadingAnchorWrapperClassName} {
170
+ button:focus {
171
+ opacity: 1;
172
+ transform: none !important;
176
173
  }
177
- `;
174
+ }
175
+ `;
178
176
  const alignedHeadingAnchorStyle = ({
179
177
  allowNestedHeaderLinks
180
178
  }) => {
181
179
  if (!allowNestedHeaderLinks) {
182
180
  return '';
183
181
  }
184
- // TODO Delete this comment after verifying space token -> previous value `margin: 6px`
185
182
  return css`
186
183
  .fabric-editor-block-mark[data-align] > {
187
184
  h1,
@@ -392,12 +389,16 @@ const fullWidthStyles = ({
392
389
  const breakoutWidthStyle = () => {
393
390
  return css`
394
391
  *:not([data-mark-type='fragment']) .${TableSharedCssClassName.TABLE_CONTAINER} {
392
+ // Ignored via go/ees007
393
+ // eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
395
394
  // TODO - improve inline style logic on table container so important styles aren't required here
396
395
  width: 100% !important;
397
396
  left: 0 !important;
398
397
  }
399
398
 
400
399
  [data-mark-type='fragment'] * .${TableSharedCssClassName.TABLE_CONTAINER} {
400
+ // Ignored via go/ees007
401
+ // eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
401
402
  // TODO - improve inline style logic on table container so important styles aren't required here
402
403
  width: 100% !important;
403
404
  left: 0 !important;
@@ -43,7 +43,7 @@ export class TruncatedWrapper extends Component {
43
43
  super(props);
44
44
  }
45
45
 
46
- // TODO: Quality ticket as elevation.surface will be issue when sits top of modal. https://product-fabric.atlassian.net/browse/DSP-4123
46
+ // TODO: DSP-4123 - Quality ticket as elevation.surface will be issue when sits top of modal.
47
47
  render() {
48
48
  const {
49
49
  height = 95,
@@ -367,8 +367,9 @@ var RendererActions = /*#__PURE__*/function () {
367
367
  };
368
368
  }
369
369
 
370
- // TODO: Do not forget to remove `undefined` when the
371
- // `editor_inline_comments_on_inline_nodes` is removed.
370
+ // Ignored via go/ees007
371
+ // eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
372
+ // TODO: Do not forget to remove `undefined` when the `editor_inline_comments_on_inline_nodes` is removed.
372
373
  }, {
373
374
  key: "getInlineNodeTypes",
374
375
  value: function getInlineNodeTypes(annotationId) {
@@ -395,7 +395,7 @@ var ReactSerializer = /*#__PURE__*/function () {
395
395
  var isInsideMultiBodiedExtension = insideMultiBodiedExtension(path, node.type.schema);
396
396
  var isInsideOfTable = insideTable(path, node.type.schema);
397
397
 
398
- // TODO: https://product-fabric.atlassian.net/browse/CEMS-1048
398
+ // TODO: CEMS-1048 - Support sticky headers inside breakout + layout
399
399
  var stickyHeaders = !isInsideOfTable && !insideBreakoutLayout(path) ? this.stickyHeaders : undefined;
400
400
  return _objectSpread(_objectSpread({}, this.getProps(node)), {}, {
401
401
  allowColumnSorting: this.allowColumnSorting,
@@ -731,7 +731,7 @@ var ReactSerializer = /*#__PURE__*/function () {
731
731
  }));
732
732
  }
733
733
 
734
- // TODO: ED-9004 Remove unused ReactSerializer.fromSchema in renderer
734
+ // TODO: ED-9004 - Remove unused ReactSerializer.fromSchema in renderer
735
735
  // https://sourcegraph-frontend.internal.shared-prod.us-west-2.kitt-inf.net/search?q=ReactSerializer.fromSchema&patternType=literal
736
736
  }, {
737
737
  key: "fromSchema",
@@ -60,7 +60,7 @@ var HeadingAnchor = /*#__PURE__*/function (_React$PureComponent) {
60
60
  _defineProperty(_this, "setTooltipState", function (message) {
61
61
  var isClicked = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
62
62
  _this.setState({
63
- // TODO: ED-14403 investigate why this does not translate
63
+ // TODO: ED-14403 - investigate why this does not translate
64
64
  tooltipMessage: _this.props.intl.formatMessage(message),
65
65
  isClicked: isClicked
66
66
  });
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import VisuallyHidden from '@atlaskit/visually-hidden';
3
3
  import { fg } from '@atlaskit/platform-feature-flags';
4
+ import { abortAll } from '@atlaskit/react-ufo/interaction-metrics';
4
5
  import HeadingAnchor from './heading-anchor';
5
6
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
6
7
  import AnalyticsContext from '../../analytics/analyticsContext';
@@ -50,13 +51,24 @@ function Heading(props) {
50
51
  marks = props.marks,
51
52
  invisible = props.invisible;
52
53
  var HX = "h".concat(props.level);
54
+ var mouseEntered = React.useRef(false);
53
55
  var showAnchorLink = !!props.showAnchorLink;
54
56
  var isRightAligned = hasRightAlignmentMark(marks);
55
57
  var enableNestedHeaderLinks = allowHeadingAnchorLinks && allowHeadingAnchorLinks.allowNestedHeaderLinks;
56
58
  var headingIdToUse = invisible ? undefined : headingId;
59
+ var mouseEnterHandler = function mouseEnterHandler() {
60
+ if (showAnchorLink && !mouseEntered.current) {
61
+ // Abort TTVC calculation when the mouse hovers over heading. Hovering over
62
+ // heading render heading anchor and inline comment buttons. These user-induced
63
+ // DOM changes are valid reasons to abort the TTVC calculation.
64
+ abortAll('new_interaction');
65
+ mouseEntered.current = true;
66
+ }
67
+ };
57
68
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(HX, {
58
69
  id: headingIdToUse,
59
- "data-renderer-start-pos": dataAttributes['data-renderer-start-pos']
70
+ "data-renderer-start-pos": dataAttributes['data-renderer-start-pos'],
71
+ onMouseEnter: mouseEnterHandler
60
72
  }, /*#__PURE__*/React.createElement(React.Fragment, null, showAnchorLink && headingId && isRightAligned && /*#__PURE__*/React.createElement(WrappedHeadingAnchor, {
61
73
  level: props.level,
62
74
  enableNestedHeaderLinks: enableNestedHeaderLinks,
@@ -116,9 +116,6 @@ var MediaSingleWithChildren = function MediaSingleWithChildren(props) {
116
116
  width = DEFAULT_WIDTH;
117
117
  height = DEFAULT_HEIGHT;
118
118
  }
119
-
120
- // TODO: put appearance-based padding into theme instead
121
-
122
119
  var isFullPage = rendererAppearance === 'full-page';
123
120
  var isFullWidth = rendererAppearance === 'full-width';
124
121
  var padding = isFullPage ? FullPagePadding * 2 : 0;
@@ -68,6 +68,8 @@ var MultiBodiedExtension = function MultiBodiedExtension(props) {
68
68
  var overflowContainerClass = !removeOverflow ? RendererCssClassName.EXTENSION_OVERFLOW_CONTAINER : '';
69
69
  var updateActiveChild = React.useCallback(function (index) {
70
70
  if (typeof index !== 'number') {
71
+ // Ignored via go/ees007
72
+ // eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
71
73
  // TODO: Make sure we log this somewhere if this happens
72
74
  setActiveChildIndex(0);
73
75
  return false;
@@ -29,7 +29,7 @@ var modeSpecficStyles = {
29
29
  })
30
30
  };
31
31
 
32
- // TODO: Quality ticket: https://product-fabric.atlassian.net/browse/DSP-4123
32
+ // TODO: DSP-4123 - Quality ticket
33
33
  var fixedTableDivStaticStyles = function fixedTableDivStaticStyles(top, width, allowTableResizing) {
34
34
  var stickyHeaderZIndex;
35
35
  if (allowTableResizing) {
@@ -226,7 +226,7 @@ export var MediaCardView = /*#__PURE__*/function (_Component) {
226
226
  React.createElement("div", _extends({}, dataAttributes, {
227
227
  "data-node-type": "media"
228
228
  }), /*#__PURE__*/React.createElement(Card
229
- // TODO MPT-315: clean up after we move mediaClientConfig into FileIdentifier
229
+ // TODO: MPT-315 - clean up after we move mediaClientConfig into FileIdentifier
230
230
  // context is not really used when the type is external and we want to render the component asap
231
231
  // Ignored via go/ees005
232
232
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@@ -32,6 +32,8 @@ var TELEPOINTER_ID = 'ai-streaming-telepointer';
32
32
  var tableShadowWidth = 32;
33
33
  var LAYOUT_BREAKPOINT_RENDERER = 629;
34
34
  // originally defined from packages/editor/editor-plugin-table/src/ui/common-styles.ts
35
+ // Temporarily ignoring the below the owning team can add the ticket number for the TODO. Context: https://atlassian.slack.com/archives/CPUEVD9MY/p1741565387326829
36
+ // eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
35
37
  // TODO: tableRowHeight can be moved into `@atlaskit/editor-common/table`
36
38
  var tableRowHeight = 44;
37
39
  var _getGlobalTheme = getGlobalTheme(),
@@ -318,6 +320,8 @@ var headingsSharedStyles = css({
318
320
  }
319
321
  });
320
322
 
323
+ // Temporarily ignoring the below the owning team can add the ticket number for the TODO. Context: https://atlassian.slack.com/archives/CPUEVD9MY/p1741565387326829
324
+ // eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
321
325
  // TODO: emotion refactor - check if we need UGC token?
322
326
  var headingsSharedStylesWithEditorUGC = css({
323
327
  '& h1': {
@@ -725,10 +729,14 @@ var baseOtherStyles = css(_defineProperty(_defineProperty(_defineProperty(_defin
725
729
  marginLeft: 0,
726
730
  marginRight: 0
727
731
  }), ".".concat(RendererCssClassName.DOCUMENT, " >"), _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "*:not([data-mark-type='fragment']) .".concat(TableSharedCssClassName.TABLE_CONTAINER), {
732
+ // Temporarily ignoring the below the owning team can add the ticket number for the TODO. Context: https://atlassian.slack.com/archives/CPUEVD9MY/p1741565387326829
733
+ // eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
728
734
  // TODO - improve inline style logic on table container so important styles aren't required here
729
735
  width: '100% !important',
730
736
  left: '0 !important'
731
737
  }), "[data-mark-type='fragment'] * .".concat(TableSharedCssClassName.TABLE_CONTAINER), {
738
+ // Temporarily ignoring the below the owning team can add the ticket number for the TODO. Context: https://atlassian.slack.com/archives/CPUEVD9MY/p1741565387326829
739
+ // eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
732
740
  // TODO - improve inline style logic on table container so important styles aren't required here
733
741
  width: '100% !important',
734
742
  left: '0 !important'
@@ -748,6 +756,8 @@ var baseOtherStyles = css(_defineProperty(_defineProperty(_defineProperty(_defin
748
756
  display: 'flex'
749
757
  })));
750
758
  var alignedHeadingAnchorStyle = css({
759
+ // Temporarily ignoring the below the owning team can add the ticket number for the TODO. Context: https://atlassian.slack.com/archives/CPUEVD9MY/p1741565387326829
760
+ // eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
751
761
  // TODO Delete this comment after verifying space token -> previous value `margin: 6px`
752
762
  '.fabric-editor-block-mark[data-align] >': {
753
763
  'h1, h2, h3, h4, h5, h6': {
@@ -767,6 +777,8 @@ var alignedHeadingAnchorStyle = css({
767
777
  }))
768
778
  });
769
779
 
780
+ // Temporarily ignoring the below the owning team can add the ticket number for the TODO. Context: https://atlassian.slack.com/archives/CPUEVD9MY/p1741565387326829
781
+ // eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
770
782
  // TODO: emotion refactor - there's a mediaSingleSharedNewStyle, but not originally used in the renderer.
771
783
  var mediaSingleSharedStyle = css(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "li .".concat(richMediaClassName), {
772
784
  margin: 0
@@ -53,10 +53,11 @@ import { TruncatedWrapper } from './truncated-wrapper';
53
53
  import { ValidationContext } from './ValidationContext';
54
54
  import { RendererStyleContainer } from './RendererStyleContainer';
55
55
  import { getBaseFontSize } from './get-base-font-size';
56
+ import { removeEmptySpaceAroundContent } from './rendererHelper';
56
57
  export var NORMAL_SEVERITY_THRESHOLD = 2000;
57
58
  export var DEGRADED_SEVERITY_THRESHOLD = 3000;
58
59
  var packageName = "@atlaskit/renderer";
59
- var packageVersion = "113.2.2";
60
+ var packageVersion = "114.0.0";
60
61
  var setAsQueryContainerStyles = css({
61
62
  containerName: 'ak-renderer-wrapper',
62
63
  containerType: 'inline-size',
@@ -295,7 +296,7 @@ export var __RendererClassComponent = /*#__PURE__*/function (_PureComponent) {
295
296
  // does not currently support SSR, should not be enabled in environments where Renderer is SSR-ed
296
297
  allowWindowedCodeBlock: featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.allowWindowedCodeBlock,
297
298
  isInsideOfInlineExtension: props.isInsideOfInlineExtension,
298
- textHighlighter: props.UNSTABLE_textHighlighter,
299
+ textHighlighter: props.textHighlighter || props.UNSTABLE_textHighlighter,
299
300
  allowTableAlignment: props.UNSTABLE_allowTableAlignment,
300
301
  allowTableResizing: props.UNSTABLE_allowTableResizing
301
302
  };
@@ -379,7 +380,7 @@ export var __RendererClassComponent = /*#__PURE__*/function (_PureComponent) {
379
380
  try {
380
381
  var _rendererContext$feat;
381
382
  var schema = this.getSchema(this.props.schema, this.props.adfStage);
382
- var _renderDocument = renderDocument(adfDocument, this.serializer, schema, adfStage, this.props.useSpecBasedValidator, this.id, this.fireAnalyticsEvent, this.props.unsupportedContentLevelsTracking, this.props.appearance, this.props.includeNodesCountInStats, skipValidation),
383
+ var _renderDocument = renderDocument(this.props.shouldRemoveEmptySpaceAroundContent ? removeEmptySpaceAroundContent(adfDocument) : adfDocument, this.serializer, schema, adfStage, this.props.useSpecBasedValidator, this.id, this.fireAnalyticsEvent, this.props.unsupportedContentLevelsTracking, this.props.appearance, this.props.includeNodesCountInStats, skipValidation),
383
384
  result = _renderDocument.result,
384
385
  stat = _renderDocument.stat,
385
386
  pmDoc = _renderDocument.pmDoc;
@@ -603,7 +604,7 @@ var RendererFunctionalComponent = function RendererFunctionalComponent(props) {
603
604
  extensionHandlers: props.extensionHandlers,
604
605
  portal: props.portal,
605
606
  objectContext: _objectSpread({
606
- adDoc: props.document,
607
+ adDoc: props.shouldRemoveEmptySpaceAroundContent ? removeEmptySpaceAroundContent(props.document) : props.document,
607
608
  schema: props.schema
608
609
  }, props.rendererContext),
609
610
  appearance: props.appearance,
@@ -630,7 +631,7 @@ var RendererFunctionalComponent = function RendererFunctionalComponent(props) {
630
631
  nodeComponents: props.nodeComponents,
631
632
  allowWindowedCodeBlock: featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.allowWindowedCodeBlock,
632
633
  isInsideOfInlineExtension: props.isInsideOfInlineExtension,
633
- textHighlighter: props.UNSTABLE_textHighlighter,
634
+ textHighlighter: props.textHighlighter || props.UNSTABLE_textHighlighter,
634
635
  allowTableAlignment: props.UNSTABLE_allowTableAlignment,
635
636
  allowTableResizing: props.UNSTABLE_allowTableResizing
636
637
  };
@@ -751,7 +752,7 @@ var RendererFunctionalComponent = function RendererFunctionalComponent(props) {
751
752
  try {
752
753
  var _createRendererContex2, _props$media;
753
754
  var schema = getSchema(props.schema, props.adfStage);
754
- var _renderDocument2 = renderDocument(props.document, serializer, schema, props.adfStage, props.useSpecBasedValidator, id, _fireAnalyticsEvent, props.unsupportedContentLevelsTracking, props.appearance, props.includeNodesCountInStats, props.skipValidation),
755
+ var _renderDocument2 = renderDocument(props.shouldRemoveEmptySpaceAroundContent ? removeEmptySpaceAroundContent(props.document) : props.document, serializer, schema, props.adfStage, props.useSpecBasedValidator, id, _fireAnalyticsEvent, props.unsupportedContentLevelsTracking, props.appearance, props.includeNodesCountInStats, props.skipValidation),
755
756
  result = _renderDocument2.result,
756
757
  stat = _renderDocument2.stat,
757
758
  pmDoc = _renderDocument2.pmDoc;
@@ -788,7 +789,8 @@ var RendererFunctionalComponent = function RendererFunctionalComponent(props) {
788
789
  onMouseDown: onMouseDownEditView,
789
790
  ssr: (_props$media = props.media) === null || _props$media === void 0 ? void 0 : _props$media.ssr,
790
791
  isInsideOfInlineExtension: props.isInsideOfInlineExtension,
791
- isTopLevelRenderer: createRendererContext(props.featureFlags, props.isTopLevelRenderer).isTopLevelRenderer
792
+ isTopLevelRenderer: createRendererContext(props.featureFlags, props.isTopLevelRenderer).isTopLevelRenderer,
793
+ shouldRemoveEmptySpaceAroundContent: props.shouldRemoveEmptySpaceAroundContent
792
794
  }, props.enableSsrInlineScripts || props.noOpSSRInlineScript ? jsx(BreakoutSSRInlineScript, {
793
795
  noOpSSRInlineScript: Boolean(props.noOpSSRInlineScript)
794
796
  }) : null, jsx(RendererActionsInternalUpdater, {
@@ -0,0 +1,46 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ export var removeEmptySpaceAroundContent = function removeEmptySpaceAroundContent(document) {
5
+ // Check if the document is valid
6
+ if (!document || !document.content || !Array.isArray(document.content)) {
7
+ return document;
8
+ }
9
+ var isParagraphWithContent = function isParagraphWithContent(node) {
10
+ if (node.type !== 'paragraph' || !node.content || node.content.length === 0) {
11
+ return false;
12
+ }
13
+ // Check if paragraph has any content other than `hardBreak`
14
+ return node.content.some(function (child) {
15
+ return (child === null || child === void 0 ? void 0 : child.type) !== 'hardBreak';
16
+ });
17
+ };
18
+ var content = document.content;
19
+ var firstContentIndex = -1;
20
+ var lastContentIndex = -1;
21
+
22
+ // Find the first and last paragraphs with content
23
+ for (var i = 0; i < content.length; i++) {
24
+ if (isParagraphWithContent(content[i])) {
25
+ if (firstContentIndex === -1) {
26
+ firstContentIndex = i;
27
+ }
28
+ lastContentIndex = i;
29
+ }
30
+ }
31
+
32
+ // If no content was found, return an empty document
33
+ if (firstContentIndex === -1) {
34
+ return _objectSpread(_objectSpread({}, document), {}, {
35
+ content: []
36
+ });
37
+ }
38
+
39
+ // Slice the content array to include only paragraphs between the first and last content
40
+ var trimmedContent = content.slice(firstContentIndex, lastContentIndex + 1);
41
+
42
+ // Return a new document with the trimmed content
43
+ return _objectSpread(_objectSpread({}, document), {}, {
44
+ content: trimmedContent
45
+ });
46
+ };
@@ -96,16 +96,13 @@ var headingSizes = {
96
96
  }
97
97
  };
98
98
  var headingAnchorStyle = function headingAnchorStyle(headingTag) {
99
- return (// TODO Delete this comment after verifying space token -> previous value `margin-left: 6px`
100
- css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n\t\t/**\n * The copy link button doesn't reserve space in the DOM so that\n * the text alignment isn't impacted by the button/icon's space.\n */\n\t\t.", " {\n\t\t\tposition: absolute;\n\t\t\theight: ", "em;\n\n\t\t\tmargin-left: ", ";\n\n\t\t\tbutton {\n\t\t\t\tpadding-left: 0;\n\t\t\t\tpadding-right: 0;\n\t\t\t}\n\t\t}\n\n\t\t/**\n * Applies hover effects to the heading anchor link button\n * to fade in when the user rolls over the heading.\n *\n * The link is persistent on mobile, so we use feature detection\n * to enable hover effects for systems that support it (desktop).\n *\n * @see https://caniuse.com/mdn-css_at-rules_media_hover\n */\n\t\t@media (hover: hover) and (pointer: fine) {\n\t\t\t.", " {\n\t\t\t\t> button {\n\t\t\t\t\topacity: 0;\n\t\t\t\t\ttransform: translate(-8px, 0px);\n\t\t\t\t\ttransition:\n\t\t\t\t\t\topacity 0.2s ease 0s,\n\t\t\t\t\t\ttransform 0.2s ease 0s;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t&:hover {\n\t\t\t\t.", " > button {\n\t\t\t\t\topacity: 1;\n\t\t\t\t\ttransform: none !important;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t/**\n * Adds the visibility of the button when in focus through keyboard navigation.\n */\n\t\t.", " {\n\t\t\tbutton:focus {\n\t\t\t\topacity: 1;\n\t\t\t\ttransform: none !important;\n\t\t\t}\n\t\t}\n\t"])), HeadingAnchorWrapperClassName, headingSizes[headingTag].lineHeight, "var(--ds-space-075, 6px)", HeadingAnchorWrapperClassName, HeadingAnchorWrapperClassName, HeadingAnchorWrapperClassName)
101
- );
99
+ return css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n\t/**\n * The copy link button doesn't reserve space in the DOM so that\n * the text alignment isn't impacted by the button/icon's space.\n */\n\t.", " {\n\t\tposition: absolute;\n\t\theight: ", "em;\n\n\t\tmargin-left: ", ";\n\n\t\tbutton {\n\t\t\tpadding-left: 0;\n\t\t\tpadding-right: 0;\n\t\t}\n\t}\n\n\t/**\n * Applies hover effects to the heading anchor link button\n * to fade in when the user rolls over the heading.\n *\n * The link is persistent on mobile, so we use feature detection\n * to enable hover effects for systems that support it (desktop).\n *\n * @see https://caniuse.com/mdn-css_at-rules_media_hover\n */\n\t@media (hover: hover) and (pointer: fine) {\n\t\t.", " {\n\t\t\t> button {\n\t\t\t\topacity: 0;\n\t\t\t\ttransform: translate(-8px, 0px);\n\t\t\t\ttransition:\n\t\t\t\t\topacity 0.2s ease 0s,\n\t\t\t\t\ttransform 0.2s ease 0s;\n\t\t\t}\n\t\t}\n\n\t\t&:hover {\n\t\t\t.", " > button {\n\t\t\t\topacity: 1;\n\t\t\t\ttransform: none !important;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n * Adds the visibility of the button when in focus through keyboard navigation.\n */\n\t.", " {\n\t\tbutton:focus {\n\t\t\topacity: 1;\n\t\t\ttransform: none !important;\n\t\t}\n\t}\n"])), HeadingAnchorWrapperClassName, headingSizes[headingTag].lineHeight, "var(--ds-space-075, 6px)", HeadingAnchorWrapperClassName, HeadingAnchorWrapperClassName, HeadingAnchorWrapperClassName);
102
100
  };
103
101
  var alignedHeadingAnchorStyle = function alignedHeadingAnchorStyle(_ref) {
104
102
  var allowNestedHeaderLinks = _ref.allowNestedHeaderLinks;
105
103
  if (!allowNestedHeaderLinks) {
106
104
  return '';
107
105
  }
108
- // TODO Delete this comment after verifying space token -> previous value `margin: 6px`
109
106
  return css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n\t\t.fabric-editor-block-mark[data-align] > {\n\t\t\th1,\n\t\t\th2,\n\t\t\th3,\n\t\t\th4,\n\t\t\th5,\n\t\t\th6 {\n\t\t\t\tposition: relative;\n\t\t\t}\n\t\t}\n\n\t\t/**\n * For right-alignment we flip the link to be before the heading\n * text so that the text is flush up against the edge of the editor's\n * container edge.\n */\n\t\t.fabric-editor-block-mark:not([data-align='center'])[data-align] {\n\t\t\t.", " {\n\t\t\t\tmargin: 0 ", " 0 0;\n\t\t\t\t// If the anchor is right aligned then the left side of the heading\n\t\t\t\t// is aligned with the left side of the anchor.\n\t\t\t\t// In order to align as expected we transform it the width of the element (plus our expected 6px)\n\t\t\t\t// to the left\n\t\t\t\ttransform: translateX(calc(-100% - ", "));\n\t\t\t}\n\n\t\t\t@media (hover: hover) and (pointer: fine) {\n\t\t\t\t.", " > button {\n\t\t\t\t\ttransform: translate(8px, 0px);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t"])), HeadingAnchorWrapperClassName, "var(--ds-space-075, 6px)", "var(--ds-space-075, 6px)", HeadingAnchorWrapperClassName);
110
107
  };
111
108
  var tableSortableColumnStyle = function tableSortableColumnStyle(_ref2) {
@@ -136,7 +133,7 @@ var fullWidthStyles = function fullWidthStyles(_ref5) {
136
133
  return css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n\t\tmax-width: ", "px;\n\t\tmargin: 0 auto;\n\n\t\t/* don't override if the breakout mark has width attribute defined */\n\t\t.fabric-editor-breakout-mark:not([data-has-width='true']),\n\t\t.ak-renderer-extension {\n\t\t\twidth: 100% !important;\n\t\t}\n\n\t\t", "\n\t"])), akEditorFullWidthLayoutWidth, isTableResizingEnabled(appearance) ? '' : "\n .pm-table-container {\n width: 100% !important;\n }\n ");
137
134
  };
138
135
  var breakoutWidthStyle = function breakoutWidthStyle() {
139
- return css(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n\t\t*:not([data-mark-type='fragment']) .", " {\n\t\t\t// TODO - improve inline style logic on table container so important styles aren't required here\n\t\t\twidth: 100% !important;\n\t\t\tleft: 0 !important;\n\t\t}\n\n\t\t[data-mark-type='fragment'] * .", " {\n\t\t\t// TODO - improve inline style logic on table container so important styles aren't required here\n\t\t\twidth: 100% !important;\n\t\t\tleft: 0 !important;\n\t\t}\n\t"])), TableSharedCssClassName.TABLE_CONTAINER, TableSharedCssClassName.TABLE_CONTAINER);
136
+ return css(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n\t\t*:not([data-mark-type='fragment']) .", " {\n\t\t\t// Ignored via go/ees007\n\t\t\t// eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format\n\t\t\t// TODO - improve inline style logic on table container so important styles aren't required here\n\t\t\twidth: 100% !important;\n\t\t\tleft: 0 !important;\n\t\t}\n\n\t\t[data-mark-type='fragment'] * .", " {\n\t\t\t// Ignored via go/ees007\n\t\t\t// eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format\n\t\t\t// TODO - improve inline style logic on table container so important styles aren't required here\n\t\t\twidth: 100% !important;\n\t\t\tleft: 0 !important;\n\t\t}\n\t"])), TableSharedCssClassName.TABLE_CONTAINER, TableSharedCssClassName.TABLE_CONTAINER);
140
137
  };
141
138
  var getShadowOverrides = function getShadowOverrides() {
142
139
  return css(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n\t\t/** Shadow overrides */\n\t\t&.", "::after, &.", "::before {\n\t\t\twidth: ", "px;\n\t\t\tbackground: linear-gradient(\n\t\t\t\t\tto left,\n\t\t\t\t\ttransparent 0,\n\t\t\t\t\t", " 140%\n\t\t\t\t),\n\t\t\t\tlinear-gradient(\n\t\t\t\t\tto right,\n\t\t\t\t\t", " 0px,\n\t\t\t\t\ttransparent 1px\n\t\t\t\t);\n\t\t}\n\n\t\t&.", "::after {\n\t\t\tbackground: linear-gradient(\n\t\t\t\t\tto right,\n\t\t\t\t\ttransparent 0,\n\t\t\t\t\t", " 140%\n\t\t\t\t),\n\t\t\t\tlinear-gradient(\n\t\t\t\t\tto left,\n\t\t\t\t\t", " 0px,\n\t\t\t\t\ttransparent 1px\n\t\t\t\t);\n\t\t\tright: 0px;\n\t\t}\n\t"])), shadowClassNames.RIGHT_SHADOW, shadowClassNames.LEFT_SHADOW, tableShadowWidth, "var(--ds-shadow-overflow-spread, ".concat(N40A, ")"), "var(--ds-shadow-overflow-perimeter, transparent)", shadowClassNames.RIGHT_SHADOW, "var(--ds-shadow-overflow-spread, ".concat(N40A, ")"), "var(--ds-shadow-overflow-perimeter, transparent)");
@@ -51,7 +51,7 @@ export var TruncatedWrapper = /*#__PURE__*/function (_Component) {
51
51
  return _callSuper(this, TruncatedWrapper, [props]);
52
52
  }
53
53
 
54
- // TODO: Quality ticket as elevation.surface will be issue when sits top of modal. https://product-fabric.atlassian.net/browse/DSP-4123
54
+ // TODO: DSP-4123 - Quality ticket as elevation.surface will be issue when sits top of modal.
55
55
  _inherits(TruncatedWrapper, _Component);
56
56
  return _createClass(TruncatedWrapper, [{
57
57
  key: "render",
@@ -64,6 +64,7 @@ export type RendererWrapperProps = {
64
64
  isInsideOfInlineExtension?: boolean;
65
65
  allowTableResizing?: boolean;
66
66
  isTopLevelRenderer?: boolean;
67
+ shouldRemoveEmptySpaceAroundContent?: boolean;
67
68
  } & {
68
69
  children?: React.ReactNode;
69
70
  };
@@ -0,0 +1,2 @@
1
+ import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
2
+ export declare const removeEmptySpaceAroundContent: (document: JSONDocNode) => JSONDocNode;
@@ -68,6 +68,7 @@ export interface RendererProps {
68
68
  isInsideOfInlineExtension?: boolean;
69
69
  isTopLevelRenderer?: boolean;
70
70
  includeNodesCountInStats?: boolean;
71
+ shouldRemoveEmptySpaceAroundContent?: boolean;
71
72
  /**
72
73
  * When enabled a trailing telepointer will be added to the rendered document
73
74
  * following content updates.
@@ -78,6 +79,7 @@ export interface RendererProps {
78
79
  * is updated as a result of a content update.
79
80
  */
80
81
  addTelepointer?: boolean;
82
+ textHighlighter?: TextHighlighter;
81
83
  /**
82
84
  * @default undefined
83
85
  * @description
@@ -109,6 +111,7 @@ export interface RendererProps {
109
111
  featureFlags?: {
110
112
  [featureFlag: string]: boolean;
111
113
  } | Partial<RawObjectFeatureFlags>;
114
+ /** @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-26490 Internal documentation for deprecation (no external access)} This prop has been marked stable and therefore replaced by the `textHighlighter` prop. Please use `textHighlighter` prop instead. */
112
115
  UNSTABLE_textHighlighter?: TextHighlighter;
113
116
  UNSTABLE_allowTableAlignment?: boolean;
114
117
  UNSTABLE_allowTableResizing?: boolean;
@@ -64,6 +64,7 @@ export type RendererWrapperProps = {
64
64
  isInsideOfInlineExtension?: boolean;
65
65
  allowTableResizing?: boolean;
66
66
  isTopLevelRenderer?: boolean;
67
+ shouldRemoveEmptySpaceAroundContent?: boolean;
67
68
  } & {
68
69
  children?: React.ReactNode;
69
70
  };
@@ -0,0 +1,2 @@
1
+ import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
2
+ export declare const removeEmptySpaceAroundContent: (document: JSONDocNode) => JSONDocNode;