@atlaskit/renderer 148.0.3 → 148.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @atlaskit/renderer
2
2
 
3
+ ## 148.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`f115a893c63dd`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f115a893c63dd) -
8
+ Exports `ExpandBodyProvider` (`@atlaskit/renderer/expand-body`), so a product can provide the
9
+ outermost expand body itself. Expands under it share one `revealedByFind` set, so they come back
10
+ as browser find left them when the product remounts them, such as when it replaces a lightly
11
+ rendered subtree with its full render. Under `cc_light_mode_table_virtualization`, the set also
12
+ records expands the reader opens and closes, so they come back as the reader left them too.
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies
17
+
18
+ ## 148.0.4
19
+
20
+ ### Patch Changes
21
+
22
+ - [`b50791096b149`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b50791096b149) -
23
+ Reduce built-in paragraph serializer props allocation behind
24
+ platform_renderer_paragraph_props_fast_path.
25
+ - Updated dependencies
26
+
3
27
  ## 148.0.3
4
28
 
5
29
  ### Patch Changes
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "ExpandBodyProvider", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _expandBody.ExpandBodyProvider;
10
+ }
11
+ });
12
+ var _expandBody = require("../ui/utils/expand-body");
@@ -66,6 +66,7 @@ var ReactSerializer = exports.default = /*#__PURE__*/function () {
66
66
  (0, _defineProperty2.default)(this, "allowCustomPanels", false);
67
67
  (0, _defineProperty2.default)(this, "surroundTextNodesWithTextWrapper", false);
68
68
  (0, _defineProperty2.default)(this, "textFastPath", false);
69
+ (0, _defineProperty2.default)(this, "paragraphPropsFastPath", false);
69
70
  (0, _defineProperty2.default)(this, "allowAnnotations", false);
70
71
  (0, _defineProperty2.default)(this, "standaloneBackgroundColorMarks", []);
71
72
  (0, _defineProperty2.default)(this, "inlinePositions", new Set());
@@ -210,6 +211,7 @@ var ReactSerializer = exports.default = /*#__PURE__*/function () {
210
211
  this.allowAnnotations = Boolean(init.allowAnnotations);
211
212
  this.surroundTextNodesWithTextWrapper = Boolean(init.surroundTextNodesWithTextWrapper);
212
213
  this.textFastPath = (0, _expVal.expVal)('platform_renderer_text_paragraph_fast_path', 'isEnabled', false);
214
+ this.paragraphPropsFastPath = (0, _expVal.expVal)('platform_renderer_paragraph_props_fast_path', 'isEnabled', false);
213
215
  this.media = init.media;
214
216
  this.mentionNodeDataProvider = init.mentionNodeDataProvider;
215
217
  this.emojiProviderLookupOrder = init.emojiProviderLookupOrder;
@@ -243,6 +245,12 @@ var ReactSerializer = exports.default = /*#__PURE__*/function () {
243
245
  value: function getNodeProps(node, parentInfo) {
244
246
  var path = parentInfo ? parentInfo.path : undefined;
245
247
  switch (node.type.name) {
248
+ case 'paragraph':
249
+ // Explicit paragraph overrides retain the full generic props contract.
250
+ if (this.paragraphPropsFastPath && (!this.nodeComponents || !Object.prototype.hasOwnProperty.call(this.nodeComponents, 'paragraph'))) {
251
+ return this.getParagraphProps(node, path);
252
+ }
253
+ return this.getProps(node, path);
246
254
  case 'date':
247
255
  return this.getDateProps(node, parentInfo, path);
248
256
  case 'hardBreak':
@@ -661,6 +669,25 @@ var ReactSerializer = exports.default = /*#__PURE__*/function () {
661
669
  allowCustomPanels: this.allowCustomPanels
662
670
  });
663
671
  }
672
+ }, {
673
+ key: "getParagraphProps",
674
+ value: function getParagraphProps(node) {
675
+ var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
676
+ var startPos = this.startPos + path.length;
677
+
678
+ // Keep traversal metadata for serializer subclasses without allocating unused content getters.
679
+ return _objectSpread({
680
+ asInline: this.inlinePositions.has(startPos) ? 'on' : undefined,
681
+ plainTextFastPath: this.textFastPath,
682
+ nodeType: node.type.name,
683
+ marks: node.marks,
684
+ dataAttributes: {
685
+ 'data-renderer-start-pos': startPos
686
+ },
687
+ startPos: startPos,
688
+ path: path
689
+ }, node.attrs);
690
+ }
664
691
  }, {
665
692
  key: "getProps",
666
693
  value: function getProps(node) {
@@ -17,6 +17,7 @@ var _analytics = require("@atlaskit/editor-common/analytics");
17
17
  var _ui = require("@atlaskit/editor-common/ui");
18
18
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
19
19
  var _chevronRight = _interopRequireDefault(require("@atlaskit/icon/core/chevron-right"));
20
+ var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
20
21
  var _Tooltip = _interopRequireDefault(require("@atlaskit/tooltip/Tooltip"));
21
22
  var _events = require("../analytics/events");
22
23
  var _activeHeaderIdProvider = require("./active-header-id-provider");
@@ -403,10 +404,19 @@ function Expand(_ref) {
403
404
  e.preventDefault();
404
405
  e.stopPropagation();
405
406
  fireExpandToggleAnalytics(nodeType, expanded, fireAnalyticsEvent);
407
+ // Recorded so a product remounting this expand under its own body gets it back as the
408
+ // reader left it.
409
+ var recordsToggle = node !== undefined && (0, _isExperimentEnabled.isExperimentEnabled)('cc_light_mode_table_virtualization');
406
410
  if (expanded) {
407
411
  setExpanded(false);
412
+ if (recordsToggle) {
413
+ revealedByFind.delete(node);
414
+ }
408
415
  } else {
409
416
  openBody();
417
+ if (recordsToggle) {
418
+ revealedByFind.add(node);
419
+ }
410
420
  }
411
421
  e.persist();
412
422
  // @ts-ignore detail doesn't exist on type
@@ -72,7 +72,7 @@ var DEGRADED_SEVERITY_THRESHOLD = exports.DEGRADED_SEVERITY_THRESHOLD = 3000;
72
72
  var TABLE_INFO_TIMEOUT = 10000;
73
73
  var RENDER_EVENT_SAMPLE_RATE = 0.1;
74
74
  var packageName = "@atlaskit/renderer";
75
- var packageVersion = "148.0.2";
75
+ var packageVersion = "148.0.4";
76
76
  var setAsQueryContainerStyles = (0, _react2.css)({
77
77
  containerName: 'ak-renderer-wrapper',
78
78
  containerType: 'inline-size'
@@ -0,0 +1,3 @@
1
+ /* eslint-disable @atlaskit/editor/no-re-export */
2
+
3
+ export { ExpandBodyProvider } from '../ui/utils/expand-body';
@@ -50,6 +50,7 @@ export default class ReactSerializer {
50
50
  _defineProperty(this, "allowCustomPanels", false);
51
51
  _defineProperty(this, "surroundTextNodesWithTextWrapper", false);
52
52
  _defineProperty(this, "textFastPath", false);
53
+ _defineProperty(this, "paragraphPropsFastPath", false);
53
54
  _defineProperty(this, "allowAnnotations", false);
54
55
  _defineProperty(this, "standaloneBackgroundColorMarks", []);
55
56
  _defineProperty(this, "inlinePositions", new Set());
@@ -197,6 +198,7 @@ export default class ReactSerializer {
197
198
  this.allowAnnotations = Boolean(init.allowAnnotations);
198
199
  this.surroundTextNodesWithTextWrapper = Boolean(init.surroundTextNodesWithTextWrapper);
199
200
  this.textFastPath = expVal('platform_renderer_text_paragraph_fast_path', 'isEnabled', false);
201
+ this.paragraphPropsFastPath = expVal('platform_renderer_paragraph_props_fast_path', 'isEnabled', false);
200
202
  this.media = init.media;
201
203
  this.mentionNodeDataProvider = init.mentionNodeDataProvider;
202
204
  this.emojiProviderLookupOrder = init.emojiProviderLookupOrder;
@@ -226,6 +228,12 @@ export default class ReactSerializer {
226
228
  getNodeProps(node, parentInfo) {
227
229
  const path = parentInfo ? parentInfo.path : undefined;
228
230
  switch (node.type.name) {
231
+ case 'paragraph':
232
+ // Explicit paragraph overrides retain the full generic props contract.
233
+ if (this.paragraphPropsFastPath && (!this.nodeComponents || !Object.prototype.hasOwnProperty.call(this.nodeComponents, 'paragraph'))) {
234
+ return this.getParagraphProps(node, path);
235
+ }
236
+ return this.getProps(node, path);
229
237
  case 'date':
230
238
  return this.getDateProps(node, parentInfo, path);
231
239
  case 'hardBreak':
@@ -590,6 +598,23 @@ export default class ReactSerializer {
590
598
  allowCustomPanels: this.allowCustomPanels
591
599
  };
592
600
  }
601
+ getParagraphProps(node, path = []) {
602
+ const startPos = this.startPos + path.length;
603
+
604
+ // Keep traversal metadata for serializer subclasses without allocating unused content getters.
605
+ return {
606
+ asInline: this.inlinePositions.has(startPos) ? 'on' : undefined,
607
+ plainTextFastPath: this.textFastPath,
608
+ nodeType: node.type.name,
609
+ marks: node.marks,
610
+ dataAttributes: {
611
+ 'data-renderer-start-pos': startPos
612
+ },
613
+ startPos,
614
+ path,
615
+ ...node.attrs
616
+ };
617
+ }
593
618
  getProps(node, path = []) {
594
619
  const startPos = this.startPos + path.length;
595
620
  return {
@@ -15,6 +15,7 @@ import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/anal
15
15
  import { ExpandIconWrapper, ExpandLayoutWrapperWithRef, expandMessages, WidthProvider } from '@atlaskit/editor-common/ui';
16
16
  import { akEditorLineHeight, akEditorSwoopCubicBezier, akLayoutGutterOffset } from '@atlaskit/editor-shared-styles';
17
17
  import ChevronRightIcon from '@atlaskit/icon/core/chevron-right';
18
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
18
19
  import Tooltip from '@atlaskit/tooltip/Tooltip';
19
20
  import { MODE, PLATFORM } from '../analytics/events';
20
21
  import { ActiveHeaderIdConsumer } from './active-header-id-provider';
@@ -379,10 +380,19 @@ function Expand({
379
380
  e.preventDefault();
380
381
  e.stopPropagation();
381
382
  fireExpandToggleAnalytics(nodeType, expanded, fireAnalyticsEvent);
383
+ // Recorded so a product remounting this expand under its own body gets it back as the
384
+ // reader left it.
385
+ const recordsToggle = node !== undefined && isExperimentEnabled('cc_light_mode_table_virtualization');
382
386
  if (expanded) {
383
387
  setExpanded(false);
388
+ if (recordsToggle) {
389
+ revealedByFind.delete(node);
390
+ }
384
391
  } else {
385
392
  openBody();
393
+ if (recordsToggle) {
394
+ revealedByFind.add(node);
395
+ }
386
396
  }
387
397
  e.persist();
388
398
  // @ts-ignore detail doesn't exist on type
@@ -57,7 +57,7 @@ export const DEGRADED_SEVERITY_THRESHOLD = 3000;
57
57
  const TABLE_INFO_TIMEOUT = 10000;
58
58
  const RENDER_EVENT_SAMPLE_RATE = 0.1;
59
59
  const packageName = "@atlaskit/renderer";
60
- const packageVersion = "148.0.2";
60
+ const packageVersion = "148.0.4";
61
61
  const setAsQueryContainerStyles = css({
62
62
  containerName: 'ak-renderer-wrapper',
63
63
  containerType: 'inline-size'
@@ -0,0 +1,3 @@
1
+ /* eslint-disable @atlaskit/editor/no-re-export */
2
+
3
+ export { ExpandBodyProvider } from '../ui/utils/expand-body';
@@ -59,6 +59,7 @@ var ReactSerializer = /*#__PURE__*/function () {
59
59
  _defineProperty(this, "allowCustomPanels", false);
60
60
  _defineProperty(this, "surroundTextNodesWithTextWrapper", false);
61
61
  _defineProperty(this, "textFastPath", false);
62
+ _defineProperty(this, "paragraphPropsFastPath", false);
62
63
  _defineProperty(this, "allowAnnotations", false);
63
64
  _defineProperty(this, "standaloneBackgroundColorMarks", []);
64
65
  _defineProperty(this, "inlinePositions", new Set());
@@ -203,6 +204,7 @@ var ReactSerializer = /*#__PURE__*/function () {
203
204
  this.allowAnnotations = Boolean(init.allowAnnotations);
204
205
  this.surroundTextNodesWithTextWrapper = Boolean(init.surroundTextNodesWithTextWrapper);
205
206
  this.textFastPath = expVal('platform_renderer_text_paragraph_fast_path', 'isEnabled', false);
207
+ this.paragraphPropsFastPath = expVal('platform_renderer_paragraph_props_fast_path', 'isEnabled', false);
206
208
  this.media = init.media;
207
209
  this.mentionNodeDataProvider = init.mentionNodeDataProvider;
208
210
  this.emojiProviderLookupOrder = init.emojiProviderLookupOrder;
@@ -236,6 +238,12 @@ var ReactSerializer = /*#__PURE__*/function () {
236
238
  value: function getNodeProps(node, parentInfo) {
237
239
  var path = parentInfo ? parentInfo.path : undefined;
238
240
  switch (node.type.name) {
241
+ case 'paragraph':
242
+ // Explicit paragraph overrides retain the full generic props contract.
243
+ if (this.paragraphPropsFastPath && (!this.nodeComponents || !Object.prototype.hasOwnProperty.call(this.nodeComponents, 'paragraph'))) {
244
+ return this.getParagraphProps(node, path);
245
+ }
246
+ return this.getProps(node, path);
239
247
  case 'date':
240
248
  return this.getDateProps(node, parentInfo, path);
241
249
  case 'hardBreak':
@@ -654,6 +662,25 @@ var ReactSerializer = /*#__PURE__*/function () {
654
662
  allowCustomPanels: this.allowCustomPanels
655
663
  });
656
664
  }
665
+ }, {
666
+ key: "getParagraphProps",
667
+ value: function getParagraphProps(node) {
668
+ var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
669
+ var startPos = this.startPos + path.length;
670
+
671
+ // Keep traversal metadata for serializer subclasses without allocating unused content getters.
672
+ return _objectSpread({
673
+ asInline: this.inlinePositions.has(startPos) ? 'on' : undefined,
674
+ plainTextFastPath: this.textFastPath,
675
+ nodeType: node.type.name,
676
+ marks: node.marks,
677
+ dataAttributes: {
678
+ 'data-renderer-start-pos': startPos
679
+ },
680
+ startPos: startPos,
681
+ path: path
682
+ }, node.attrs);
683
+ }
657
684
  }, {
658
685
  key: "getProps",
659
686
  value: function getProps(node) {
@@ -16,6 +16,7 @@ import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/anal
16
16
  import { ExpandIconWrapper, ExpandLayoutWrapperWithRef, expandMessages, WidthProvider } from '@atlaskit/editor-common/ui';
17
17
  import { akEditorLineHeight, akEditorSwoopCubicBezier, akLayoutGutterOffset } from '@atlaskit/editor-shared-styles';
18
18
  import ChevronRightIcon from '@atlaskit/icon/core/chevron-right';
19
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
19
20
  import Tooltip from '@atlaskit/tooltip/Tooltip';
20
21
  import { MODE, PLATFORM } from '../analytics/events';
21
22
  import { ActiveHeaderIdConsumer } from './active-header-id-provider';
@@ -394,10 +395,19 @@ function Expand(_ref) {
394
395
  e.preventDefault();
395
396
  e.stopPropagation();
396
397
  fireExpandToggleAnalytics(nodeType, expanded, fireAnalyticsEvent);
398
+ // Recorded so a product remounting this expand under its own body gets it back as the
399
+ // reader left it.
400
+ var recordsToggle = node !== undefined && isExperimentEnabled('cc_light_mode_table_virtualization');
397
401
  if (expanded) {
398
402
  setExpanded(false);
403
+ if (recordsToggle) {
404
+ revealedByFind.delete(node);
405
+ }
399
406
  } else {
400
407
  openBody();
408
+ if (recordsToggle) {
409
+ revealedByFind.add(node);
410
+ }
401
411
  }
402
412
  e.persist();
403
413
  // @ts-ignore detail doesn't exist on type
@@ -62,7 +62,7 @@ export var DEGRADED_SEVERITY_THRESHOLD = 3000;
62
62
  var TABLE_INFO_TIMEOUT = 10000;
63
63
  var RENDER_EVENT_SAMPLE_RATE = 0.1;
64
64
  var packageName = "@atlaskit/renderer";
65
- var packageVersion = "148.0.2";
65
+ var packageVersion = "148.0.4";
66
66
  var setAsQueryContainerStyles = css({
67
67
  containerName: 'ak-renderer-wrapper',
68
68
  containerType: 'inline-size'
@@ -0,0 +1,2 @@
1
+ export { ExpandBodyProvider } from '../ui/utils/expand-body';
2
+ export type { ExpandBody } from '../ui/utils/expand-body';
@@ -105,6 +105,7 @@ export default class ReactSerializer implements Serializer<JSX.Element> {
105
105
  private startPos;
106
106
  private surroundTextNodesWithTextWrapper;
107
107
  private textFastPath;
108
+ private paragraphPropsFastPath;
108
109
  private media?;
109
110
  private mentionNodeDataProvider?;
110
111
  private emojiProviderLookupOrder?;
@@ -156,6 +157,7 @@ export default class ReactSerializer implements Serializer<JSX.Element> {
156
157
  private getCodeBlockProps;
157
158
  private getPanelProps;
158
159
  private getUnsupportedContentProps;
160
+ private getParagraphProps;
159
161
  private getProps;
160
162
  private headingAnchorSupported;
161
163
  private getHeadingProps;
@@ -58,6 +58,11 @@ export interface NodeMeta {
58
58
  serializer: Serializer<JSX.Element>;
59
59
  text?: PMNode['text'];
60
60
  }
61
+ /** Internal metadata for built-in paragraphs; custom node components still receive NodeMeta. */
62
+ export type ParagraphMeta = Pick<NodeMeta, 'asInline' | 'plainTextFastPath' | 'dataAttributes' | 'nodeType' | 'marks'> & {
63
+ path: PMNode[];
64
+ startPos: number;
65
+ };
61
66
  export interface MarkMeta {
62
67
  [key: string]: any;
63
68
  dataAttributes: {
@@ -1,6 +1,6 @@
1
1
  import type { Provider, ReactNode } from 'react';
2
2
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
- type ExpandBody = {
3
+ export type ExpandBody = {
4
4
  /**
5
5
  * Opens this expand, then asks the expand above it to do the same.
6
6
  *
@@ -20,11 +20,13 @@ type ExpandBody = {
20
20
  */
21
21
  revealed: boolean;
22
22
  /**
23
- * The expands browser find has opened. One set is shared by a whole chain of expands.
23
+ * The expands browser find or the reader has opened. One set is shared by a whole chain of
24
+ * expands, and by every expand under a body a product provides itself.
24
25
  *
25
26
  * A table standing in for itself does swap out what it renders, and a nested expand in one of its
26
27
  * rows is rebuilt when it does. This is how that expand knows to come back open rather than
27
- * closed over the match the reader was just taken to.
28
+ * closed over the match the reader was just taken to. A product that remounts what is under its
29
+ * own body gets its expands back the same way.
28
30
  */
29
31
  revealedByFind: WeakSet<PMNode>;
30
32
  };
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "@atlaskit/renderer/expand-body",
3
+ "main": "../dist/cjs/entry-points/expand-body.js",
4
+ "module": "../dist/esm/entry-points/expand-body.js",
5
+ "module:es2019": "../dist/es2019/entry-points/expand-body.js",
6
+ "sideEffects": [
7
+ "*.compiled.css"
8
+ ],
9
+ "types": "../dist/types/entry-points/expand-body.d.ts"
10
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/renderer",
3
- "version": "148.0.3",
3
+ "version": "148.1.0",
4
4
  "description": "Renderer component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -73,7 +73,7 @@
73
73
  "@atlaskit/status": "^5.13.0",
74
74
  "@atlaskit/task-decision": "^21.12.0",
75
75
  "@atlaskit/theme": "^28.2.0",
76
- "@atlaskit/tmp-editor-statsig": "^226.0.0",
76
+ "@atlaskit/tmp-editor-statsig": "^227.0.0",
77
77
  "@atlaskit/tokens": "^20.3.0",
78
78
  "@atlaskit/tooltip": "^24.4.0",
79
79
  "@atlaskit/visually-hidden": "^4.4.0",