@atlaskit/renderer 114.11.1 → 114.12.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 (72) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/afm-cc/tsconfig.json +3 -0
  3. package/dist/cjs/react/marks/alignment.js +3 -15
  4. package/dist/cjs/react/nodes/blockCard.js +24 -8
  5. package/dist/cjs/react/nodes/codeBlock/components/codeBlockContainer.js +3 -10
  6. package/dist/cjs/react/nodes/codeBlock/components/lightWeightCodeBlock.js +8 -53
  7. package/dist/cjs/react/nodes/layoutColumn.js +3 -11
  8. package/dist/cjs/react/nodes/media/index.js +28 -58
  9. package/dist/cjs/react/nodes/panel.js +2 -26
  10. package/dist/cjs/react/nodes/table/colgroup.js +5 -2
  11. package/dist/cjs/react/nodes/table/sticky.js +3 -57
  12. package/dist/cjs/react/nodes/table/table.js +6 -1
  13. package/dist/cjs/react/nodes/table.js +51 -23
  14. package/dist/cjs/react/nodes/tableNew.js +550 -0
  15. package/dist/cjs/ui/Expand.js +12 -62
  16. package/dist/cjs/ui/Renderer/RendererStyleContainer.js +19 -42
  17. package/dist/cjs/ui/Renderer/breakout-ssr.js +22 -22
  18. package/dist/cjs/ui/Renderer/index.js +4 -2
  19. package/dist/cjs/ui/Renderer/style.js +2 -208
  20. package/dist/cjs/ui/annotations/draft/component.js +2 -17
  21. package/dist/cjs/ui/annotations/element/mark.js +12 -61
  22. package/dist/es2019/react/marks/alignment.js +2 -17
  23. package/dist/es2019/react/nodes/blockCard.js +24 -8
  24. package/dist/es2019/react/nodes/codeBlock/components/codeBlockContainer.js +2 -39
  25. package/dist/es2019/react/nodes/codeBlock/components/lightWeightCodeBlock.js +5 -50
  26. package/dist/es2019/react/nodes/layoutColumn.js +4 -12
  27. package/dist/es2019/react/nodes/media/index.js +3 -36
  28. package/dist/es2019/react/nodes/panel.js +2 -41
  29. package/dist/es2019/react/nodes/table/colgroup.js +5 -2
  30. package/dist/es2019/react/nodes/table/sticky.js +3 -70
  31. package/dist/es2019/react/nodes/table/table.js +6 -1
  32. package/dist/es2019/react/nodes/table.js +50 -22
  33. package/dist/es2019/react/nodes/tableNew.js +501 -0
  34. package/dist/es2019/ui/Expand.js +11 -67
  35. package/dist/es2019/ui/Renderer/RendererStyleContainer.js +20 -43
  36. package/dist/es2019/ui/Renderer/breakout-ssr.js +22 -22
  37. package/dist/es2019/ui/Renderer/index.js +4 -2
  38. package/dist/es2019/ui/Renderer/style.js +1 -889
  39. package/dist/es2019/ui/annotations/draft/component.js +2 -15
  40. package/dist/es2019/ui/annotations/element/mark.js +9 -71
  41. package/dist/esm/react/marks/alignment.js +2 -16
  42. package/dist/esm/react/nodes/blockCard.js +24 -8
  43. package/dist/esm/react/nodes/codeBlock/components/codeBlockContainer.js +2 -11
  44. package/dist/esm/react/nodes/codeBlock/components/lightWeightCodeBlock.js +7 -52
  45. package/dist/esm/react/nodes/layoutColumn.js +4 -12
  46. package/dist/esm/react/nodes/media/index.js +28 -58
  47. package/dist/esm/react/nodes/panel.js +3 -27
  48. package/dist/esm/react/nodes/table/colgroup.js +5 -2
  49. package/dist/esm/react/nodes/table/sticky.js +3 -57
  50. package/dist/esm/react/nodes/table/table.js +6 -1
  51. package/dist/esm/react/nodes/table.js +51 -21
  52. package/dist/esm/react/nodes/tableNew.js +544 -0
  53. package/dist/esm/ui/Expand.js +12 -62
  54. package/dist/esm/ui/Renderer/RendererStyleContainer.js +20 -43
  55. package/dist/esm/ui/Renderer/breakout-ssr.js +22 -22
  56. package/dist/esm/ui/Renderer/index.js +4 -2
  57. package/dist/esm/ui/Renderer/style.js +1 -203
  58. package/dist/esm/ui/annotations/draft/component.js +2 -17
  59. package/dist/esm/ui/annotations/element/mark.js +9 -56
  60. package/dist/types/react/nodes/codeBlock/components/lightWeightCodeBlock.d.ts +1 -1
  61. package/dist/types/react/nodes/table.d.ts +35 -254
  62. package/dist/types/react/nodes/tableNew.d.ts +83 -0
  63. package/dist/types/ui/Renderer/breakout-ssr.d.ts +1 -2
  64. package/dist/types/ui/Renderer/style.d.ts +0 -11
  65. package/dist/types/ui/annotations/element/mark.d.ts +30 -6
  66. package/dist/types-ts4.5/react/nodes/codeBlock/components/lightWeightCodeBlock.d.ts +1 -1
  67. package/dist/types-ts4.5/react/nodes/table.d.ts +35 -254
  68. package/dist/types-ts4.5/react/nodes/tableNew.d.ts +83 -0
  69. package/dist/types-ts4.5/ui/Renderer/breakout-ssr.d.ts +1 -2
  70. package/dist/types-ts4.5/ui/Renderer/style.d.ts +0 -11
  71. package/dist/types-ts4.5/ui/annotations/element/mark.d.ts +30 -6
  72. package/package.json +14 -7
@@ -8,7 +8,7 @@
8
8
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled
9
9
  import { css, jsx } from '@emotion/react';
10
10
  import { B300, B400, B500, N20, N200, N30A, N40A, N60A, N800, R50, R500, Y300, Y75 } from '@atlaskit/theme/colors';
11
- import { FullPagePadding, rendererStyles } from './style';
11
+ import { FullPagePadding } from './style';
12
12
  import { fg } from '@atlaskit/platform-feature-flags';
13
13
  import { RendererCssClassName } from '../../consts';
14
14
  import { akEditorBlockquoteBorderColor, akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth, akEditorLineHeight, akEditorSelectedNodeClassName, akEditorShadowZIndex, akEditorStickyHeaderZIndex, akEditorTableBorder, akEditorTableCellMinWidth, akEditorTableNumberColumnWidth, akEditorTableToolbar, blockNodesVerticalMargin, gridMediumMaxWidth } from '@atlaskit/editor-shared-styles';
@@ -1735,59 +1735,36 @@ export const RendererStyleContainer = props => {
1735
1735
  appearance,
1736
1736
  allowNestedHeaderLinks,
1737
1737
  allowColumnSorting,
1738
- allowAnnotations,
1739
- allowTableResizing,
1740
1738
  useBlockRenderForCodeBlock,
1741
1739
  children,
1742
1740
  innerRef,
1743
1741
  testId
1744
1742
  } = props;
1745
1743
  const isAdvancedLayoutsOn = editorExperiment('advanced_layouts', true);
1746
- if (fg('platform_editor_emotion_refactor_renderer')) {
1747
- return (
1748
- // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions, @atlassian/a11y/interactive-element-not-keyboard-focusable
1749
- jsx("div", {
1750
- ref: innerRef,
1751
- onClick: onClick,
1752
- onMouseDown: onMouseDown,
1753
- style: {
1754
- '--ak-renderer-base-font-size': `${getBaseFontSize(appearance)}px`,
1755
- '--ak-renderer-editor-font-heading-h1': `${editorUGCToken('editor.font.heading.h1')}`,
1756
- '--ak-renderer-editor-font-heading-h2': `${editorUGCToken('editor.font.heading.h2')}`,
1757
- '--ak-renderer-editor-font-heading-h3': `${editorUGCToken('editor.font.heading.h3')}`,
1758
- '--ak-renderer-editor-font-heading-h4': `${editorUGCToken('editor.font.heading.h4')}`,
1759
- '--ak-renderer-editor-font-heading-h5': `${editorUGCToken('editor.font.heading.h5')}`,
1760
- '--ak-renderer-editor-font-heading-h6': `${editorUGCToken('editor.font.heading.h6')}`,
1761
- '--ak-renderer-editor-font-normal-text': `${editorUGCToken('editor.font.body')}`
1762
- },
1763
- css: [baseStyles, appearance === 'full-page' && rendererFullPageStyles, appearance === 'full-width' && rendererFullWidthStyles, !isTableResizingEnabled(appearance) && rendererFullWidthStylesForTableResizing, telepointerStyles, whitespaceSharedStyles, blockquoteSharedStyles, fg('platform_editor_typography_ugc') ? headingsSharedStylesWithEditorUGC : headingsSharedStyles, headingWithAlignmentStyles, ruleSharedStyles, fg('platform_editor_typography_ugc') ? paragraphSharedStylesWithEditorUGC : paragraphSharedStyles, listsSharedStyles, browser.gecko && listsSharedStylesForGekko, indentationSharedStyles, blockMarksSharedStyles, codeMarkSharedStyles, shadowSharedStyle, dateSharedStyle, textColorStyles, backgroundColorStyles, tasksAndDecisionsStyles, smartCardStyles, fg('platform-linking-visual-refresh-v1') && smartCardStylesAvatarFix,
1764
- // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
1765
- fg('editor_inline_comments_on_inline_nodes') && rendererAnnotationStyles,
1766
- // eslint-disable-next-line @atlaskit/platform/no-preconditioning, @atlaskit/platform/ensure-feature-flag-prefix
1767
- fg('editor_inline_comments_on_inline_nodes') &&
1768
- // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
1769
- fg('annotations_align_editor_and_renderer_styles') && rendererAnnotationStylesCommentHeightFix, baseOtherStyles, allowNestedHeaderLinks && alignedHeadingAnchorStyle, mediaSingleSharedStyle, tableSharedStyle, tableRendererHeaderStylesForTableCellOnly, isBackgroundClipBrowserFixNeeded() && tableStylesBackGroundClipForGeckoForTableCellOnly, fg('platform_editor_nested_dnd_styles_changes') ? firstNodeWithNotMarginTopWithNestedDnD : firstNodeWithNotMarginTop, rendererTableStyles, isStickyScrollbarEnabled(appearance) && stickyScrollbarStyles, rendererTableHeaderEqualHeightStylesForTableCellOnly, allowColumnSorting && rendererTableSortableColumnStyles, allowColumnSorting && allowNestedHeaderLinks && rendererTableHeaderEqualHeightStylesAllowNestedHeaderLinks, fg('platform_editor_tables_numbered_column_correction') ? rendererTableColumnStyles : rendererTableColumnStylesOld, stickyHeaderStyles, codeBlockAndLayoutStyles, columnLayoutSharedStyle, isAdvancedLayoutsOn && columnLayoutResponsiveSharedStyle, isAdvancedLayoutsOn && columnLayoutResponsiveRendererStyles, isAdvancedLayoutsOn && layoutSectionForAdvancedLayoutsStyles, !useBlockRenderForCodeBlock && gridRenderForCodeBlockStyles, browser.safari && codeBlockInListSafariFixStyles],
1770
- "data-testid": testId
1771
- }, children)
1772
- );
1773
- }
1774
1744
  return (
1775
1745
  // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions, @atlassian/a11y/interactive-element-not-keyboard-focusable
1776
1746
  jsx("div", {
1777
1747
  ref: innerRef,
1778
1748
  onClick: onClick,
1779
- onMouseDown: onMouseDown
1780
- // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
1781
- ,
1782
- css: rendererStyles({
1783
- appearance,
1784
- allowNestedHeaderLinks,
1785
- allowColumnSorting: !!allowColumnSorting,
1786
- useBlockRenderForCodeBlock,
1787
- allowAnnotations: allowAnnotations,
1788
- allowTableResizing: allowTableResizing
1789
- }),
1749
+ onMouseDown: onMouseDown,
1750
+ style: {
1751
+ '--ak-renderer-base-font-size': `${getBaseFontSize(appearance)}px`,
1752
+ '--ak-renderer-editor-font-heading-h1': `${editorUGCToken('editor.font.heading.h1')}`,
1753
+ '--ak-renderer-editor-font-heading-h2': `${editorUGCToken('editor.font.heading.h2')}`,
1754
+ '--ak-renderer-editor-font-heading-h3': `${editorUGCToken('editor.font.heading.h3')}`,
1755
+ '--ak-renderer-editor-font-heading-h4': `${editorUGCToken('editor.font.heading.h4')}`,
1756
+ '--ak-renderer-editor-font-heading-h5': `${editorUGCToken('editor.font.heading.h5')}`,
1757
+ '--ak-renderer-editor-font-heading-h6': `${editorUGCToken('editor.font.heading.h6')}`,
1758
+ '--ak-renderer-editor-font-normal-text': `${editorUGCToken('editor.font.body')}`
1759
+ },
1760
+ css: [baseStyles, appearance === 'full-page' && rendererFullPageStyles, appearance === 'full-width' && rendererFullWidthStyles, appearance === 'full-width' && !isTableResizingEnabled(appearance) && rendererFullWidthStylesForTableResizing, telepointerStyles, whitespaceSharedStyles, blockquoteSharedStyles, fg('platform_editor_typography_ugc') ? headingsSharedStylesWithEditorUGC : headingsSharedStyles, headingWithAlignmentStyles, ruleSharedStyles, fg('platform_editor_typography_ugc') ? paragraphSharedStylesWithEditorUGC : paragraphSharedStyles, listsSharedStyles, browser.gecko && listsSharedStylesForGekko, indentationSharedStyles, blockMarksSharedStyles, codeMarkSharedStyles, shadowSharedStyle, dateSharedStyle, textColorStyles, backgroundColorStyles, tasksAndDecisionsStyles, smartCardStyles, fg('platform-linking-visual-refresh-v1') && smartCardStylesAvatarFix,
1761
+ // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
1762
+ fg('editor_inline_comments_on_inline_nodes') && rendererAnnotationStyles,
1763
+ // eslint-disable-next-line @atlaskit/platform/no-preconditioning, @atlaskit/platform/ensure-feature-flag-prefix
1764
+ fg('editor_inline_comments_on_inline_nodes') &&
1765
+ // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
1766
+ fg('annotations_align_editor_and_renderer_styles') && rendererAnnotationStylesCommentHeightFix, baseOtherStyles, allowNestedHeaderLinks && alignedHeadingAnchorStyle, mediaSingleSharedStyle, tableSharedStyle, tableRendererHeaderStylesForTableCellOnly, isBackgroundClipBrowserFixNeeded() && tableStylesBackGroundClipForGeckoForTableCellOnly, fg('platform_editor_nested_dnd_styles_changes') ? firstNodeWithNotMarginTopWithNestedDnD : firstNodeWithNotMarginTop, rendererTableStyles, isStickyScrollbarEnabled(appearance) && stickyScrollbarStyles, rendererTableHeaderEqualHeightStylesForTableCellOnly, allowColumnSorting && rendererTableSortableColumnStyles, allowColumnSorting && allowNestedHeaderLinks && rendererTableHeaderEqualHeightStylesAllowNestedHeaderLinks, fg('platform_editor_tables_numbered_column_correction') ? rendererTableColumnStyles : rendererTableColumnStylesOld, stickyHeaderStyles, codeBlockAndLayoutStyles, columnLayoutSharedStyle, isAdvancedLayoutsOn && columnLayoutResponsiveSharedStyle, isAdvancedLayoutsOn && columnLayoutResponsiveRendererStyles, isAdvancedLayoutsOn && layoutSectionForAdvancedLayoutsStyles, !useBlockRenderForCodeBlock && gridRenderForCodeBlockStyles, browser.safari && codeBlockInListSafariFixStyles],
1790
1767
  "data-testid": testId
1791
- }, props.children)
1768
+ }, children)
1792
1769
  );
1793
1770
  };
@@ -5,7 +5,6 @@ import { FullPagePadding } from './style';
5
5
  /**
6
6
  * Inline Script that updates breakout node width on client side,
7
7
  * before main JavaScript bundle is ready.
8
- *
9
8
  * More info: https://product-fabric.atlassian.net/wiki/spaces/E/pages/1216218119/Renderer+SSR+for+Breakout+Nodes
10
9
  */
11
10
  export function BreakoutSSRInlineScript({
@@ -26,26 +25,25 @@ export function BreakoutSSRInlineScript({
26
25
  }
27
26
  }
28
27
  const id = Math.floor(Math.random() * (9999999999 - 9999 + 1)) + 9999;
29
- const context = createBreakoutInlineScript(id);
30
28
  return /*#__PURE__*/React.createElement("script", {
31
29
  "data-breakout-script-id": id
32
30
  // To investigate if we can replace this.
33
31
  // eslint-disable-next-line react/no-danger
34
32
  ,
35
33
  dangerouslySetInnerHTML: {
36
- __html: context
34
+ __html: fg('platform-ssr-table-resize') ? createBreakoutInlineScript(id, true) : createBreakoutInlineScript(id)
37
35
  },
38
36
  "data-testid": "breakout-ssr-inline-script"
39
37
  });
40
38
  }
41
- export function createBreakoutInlineScript(id) {
39
+ export function createBreakoutInlineScript(id, optionalFlagArg) {
42
40
  return `
43
41
  (function(window){
44
42
  if(typeof window !== 'undefined' && window.__RENDERER_BYPASS_BREAKOUT_SSR__) {
45
43
  return;
46
44
  }
47
45
  ${breakoutInlineScriptContext};
48
- (${applyBreakoutAfterSSR.toString()})("${id}", breakoutConsts, ${Boolean(fg('platform-fix-table-ssr-resizing'))});
46
+ (${applyBreakoutAfterSSR.toString()})("${id}", breakoutConsts, ${optionalFlagArg !== null && optionalFlagArg !== void 0 ? optionalFlagArg : false});
49
47
  })(window);
50
48
  `;
51
49
  }
@@ -62,7 +60,7 @@ export const breakoutInlineScriptContext = `
62
60
 
63
61
  // Ignored via go/ees005
64
62
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
65
- function applyBreakoutAfterSSR(id, breakoutConsts, shouldFixTableResizing) {
63
+ function applyBreakoutAfterSSR(id, breakoutConsts, isFeatureFlagEnabled) {
66
64
  const MEDIA_NODE_TYPE = 'mediaSingle';
67
65
  const WIDE_LAYOUT_MODES = ['full-width', 'wide', 'custom'];
68
66
  function findUp(element, condition) {
@@ -76,7 +74,7 @@ function applyBreakoutAfterSSR(id, breakoutConsts, shouldFixTableResizing) {
76
74
  element = element.parentElement;
77
75
  }
78
76
  }
79
- const renderer = findUp(document.querySelector('[data-breakout-script-id="' + id + '"]'), elem => {
77
+ const renderer = findUp(document.querySelector(`[data-breakout-script-id="${id}"]`), elem => {
80
78
  var _elem$parentElement;
81
79
  return !!((_elem$parentElement = elem.parentElement) !== null && _elem$parentElement !== void 0 && _elem$parentElement.classList.contains('ak-renderer-wrapper'));
82
80
  });
@@ -88,7 +86,23 @@ function applyBreakoutAfterSSR(id, breakoutConsts, shouldFixTableResizing) {
88
86
  if (item.target.nodeType !== Node.ELEMENT_NODE) {
89
87
  return;
90
88
  }
89
+ if (
90
+ /**
91
+ * The mutation observer is only called once per added node.
92
+ * The above condition only deals with direct children of <div class="ak-renderer-document" />
93
+ * When it is initially called on the direct children, not all the sub children have loaded.
94
+ * So nested media elements which are not immediately loaded as sub children are not available in the above conditional.
95
+ * Thus adding this conditional to deal with all media elements directly.
96
+ */
97
+ // Ignored via go/ees005
98
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
99
+ item.target.dataset.nodeType === MEDIA_NODE_TYPE) {
100
+ // Ignored via go/ees005
101
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
102
+ applyMediaBreakout(item.target);
103
+ }
91
104
 
105
+ // Remove with feature gate 'platform-ssr-table-resize'
92
106
  // Ignored via go/ees005
93
107
  // eslint-disable-next-line @atlaskit/editor/no-as-casting
94
108
  if (item.target.classList.contains('ak-renderer-document')) {
@@ -108,7 +122,7 @@ function applyBreakoutAfterSSR(id, breakoutConsts, shouldFixTableResizing) {
108
122
  }
109
123
 
110
124
  // When flag is on we are using CSS to calculate the table width thus don't need logic below to set the width and left.
111
- if (!shouldFixTableResizing) {
125
+ if (!isFeatureFlagEnabled) {
112
126
  if (node.classList.contains('pm-table-container') && mode === 'custom') {
113
127
  // Ignored via go/ees005
114
128
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@@ -147,20 +161,6 @@ function applyBreakoutAfterSSR(id, breakoutConsts, shouldFixTableResizing) {
147
161
  }
148
162
  }
149
163
  });
150
- } else if (
151
- /**
152
- * The mutation observer is only called once per added node.
153
- * The above condition only deals with direct children of <div class="ak-renderer-document" />
154
- * When it is initially called on the direct children, not all the sub children have loaded.
155
- * So nested media elements which are not immediately loaded as sub children are not available in the above conditional.
156
- * Thus adding this conditional to deal with all media elements directly.
157
- */
158
- // Ignored via go/ees005
159
- // eslint-disable-next-line @atlaskit/editor/no-as-casting
160
- item.target.dataset.nodeType === MEDIA_NODE_TYPE) {
161
- // Ignored via go/ees005
162
- // eslint-disable-next-line @atlaskit/editor/no-as-casting
163
- applyMediaBreakout(item.target);
164
164
  }
165
165
  });
166
166
  });
@@ -46,7 +46,7 @@ import { removeEmptySpaceAroundContent } from './rendererHelper';
46
46
  export const NORMAL_SEVERITY_THRESHOLD = 2000;
47
47
  export const DEGRADED_SEVERITY_THRESHOLD = 3000;
48
48
  const packageName = "@atlaskit/renderer";
49
- const packageVersion = "114.11.1";
49
+ const packageVersion = "114.12.0";
50
50
  const setAsQueryContainerStyles = css({
51
51
  containerName: 'ak-renderer-wrapper',
52
52
  containerType: 'inline-size',
@@ -433,6 +433,7 @@ export const RendererFunctionalComponent = props => {
433
433
  }, jsx(UnsupportedBlock, null));
434
434
  }
435
435
  };
436
+ const RendererFunctionalComponentMemoized = /*#__PURE__*/React.memo(RendererFunctionalComponent);
436
437
  export function Renderer(props) {
437
438
  const {
438
439
  startPos
@@ -443,7 +444,8 @@ export function Renderer(props) {
443
444
  const {
444
445
  skipValidation
445
446
  } = useContext(ValidationContext) || {};
446
- return jsx(RendererFunctionalComponent
447
+ const RendererComponent = fg('cc_perf_reduce_rerenders') ? RendererFunctionalComponentMemoized : RendererFunctionalComponent;
448
+ return jsx(RendererComponent
447
449
  // Ignored via go/ees005
448
450
  // eslint-disable-next-line react/jsx-props-no-spreading
449
451
  , _extends({}, props, {