@atlaskit/editor-ssr-renderer 3.1.11 → 3.2.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,27 @@
1
1
  # @atlaskit/editor-ssr-renderer
2
2
 
3
+ ## 3.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`e9ef7c6fc5370`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e9ef7c6fc5370) -
8
+ EDITOR-6179: Enable SSR Streaming for Edit Page and Live Doc routes.
9
+ - Add `platform_editor_editor_ssr_streaming` experiment to `tmp-editor-statsig` experiments
10
+ config.
11
+ - `EditorSSRRenderer`: replace `useLayoutEffect`+`containerRef` DOM mutation with
12
+ `dangerouslySetInnerHTML` for rendering serialized editor HTML, enabling correct rendering in
13
+ `renderToPipeableStream` SSR streaming context.
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies
18
+
19
+ ## 3.1.12
20
+
21
+ ### Patch Changes
22
+
23
+ - Updated dependencies
24
+
3
25
  ## 3.1.11
4
26
 
5
27
  ### Patch Changes
@@ -379,7 +379,14 @@ function EditorSSRRenderer(_ref) {
379
379
  doc.descendants(function (node, pos) {
380
380
  nodePositions.set(node, pos);
381
381
  });
382
- return serializer.serializeFragment(doc.content);
382
+ if ((0, _expValEquals.expValEquals)('platform_editor_editor_ssr_streaming', 'isEnabled', true)) {
383
+ var fragment = serializer.serializeFragment(doc.content);
384
+ var wrapper = document.createElement('div');
385
+ wrapper.appendChild(fragment);
386
+ return wrapper.innerHTML;
387
+ } else {
388
+ return serializer.serializeFragment(doc.content);
389
+ }
383
390
  };
384
391
  try {
385
392
  return (0, _ssrMeasures.profileSSROperation)("".concat(SSR_TRACE_SEGMENT_NAME, "/serializeFragment"), serializeFragment, onSSRMeasure);
@@ -390,9 +397,11 @@ function EditorSSRRenderer(_ref) {
390
397
  }, [doc, serializer, nodePositions, onSSRMeasure]);
391
398
  var containerRef = (0, _react.useRef)(null);
392
399
  (0, _react.useLayoutEffect)(function () {
393
- if (containerRef.current && editorHTML) {
394
- containerRef.current.innerHTML = '';
395
- containerRef.current.appendChild(editorHTML);
400
+ if (!(0, _expValEquals.expValEquals)('platform_editor_editor_ssr_streaming', 'isEnabled', true)) {
401
+ if (containerRef.current && editorHTML && typeof editorHTML !== 'string') {
402
+ containerRef.current.innerHTML = '';
403
+ containerRef.current.appendChild(editorHTML);
404
+ }
396
405
  }
397
406
  }, [editorHTML]);
398
407
  return /*#__PURE__*/_react.default.createElement(_ssrMeasures.SSRRenderMeasure, {
@@ -400,8 +409,12 @@ function EditorSSRRenderer(_ref) {
400
409
  startTimestampRef: firstRenderStartTimestampRef,
401
410
  onSSRMeasure: onSSRMeasure
402
411
  }, /*#__PURE__*/_react.default.createElement("div", {
403
- ref: containerRef,
404
412
  id: divProps.id
413
+ // eslint-disable-next-line react/no-danger -- It's intentional by design
414
+ ,
415
+ dangerouslySetInnerHTML: typeof editorHTML === 'string' && (0, _expValEquals.expValEquals)('platform_editor_editor_ssr_streaming', 'isEnabled', true) ? {
416
+ __html: editorHTML
417
+ } : undefined
405
418
  // For some reason on SSR, the result `class` has a trailing space, that broke UFO,
406
419
  // because ReactEditorView produces a div with `class` without space.
407
420
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
@@ -287,7 +287,14 @@ export function EditorSSRRenderer({
287
287
  doc.descendants((node, pos) => {
288
288
  nodePositions.set(node, pos);
289
289
  });
290
- return serializer.serializeFragment(doc.content);
290
+ if (expValEquals('platform_editor_editor_ssr_streaming', 'isEnabled', true)) {
291
+ const fragment = serializer.serializeFragment(doc.content);
292
+ const wrapper = document.createElement('div');
293
+ wrapper.appendChild(fragment);
294
+ return wrapper.innerHTML;
295
+ } else {
296
+ return serializer.serializeFragment(doc.content);
297
+ }
291
298
  };
292
299
  try {
293
300
  return profileSSROperation(`${SSR_TRACE_SEGMENT_NAME}/serializeFragment`, serializeFragment, onSSRMeasure);
@@ -298,9 +305,11 @@ export function EditorSSRRenderer({
298
305
  }, [doc, serializer, nodePositions, onSSRMeasure]);
299
306
  const containerRef = useRef(null);
300
307
  useLayoutEffect(() => {
301
- if (containerRef.current && editorHTML) {
302
- containerRef.current.innerHTML = '';
303
- containerRef.current.appendChild(editorHTML);
308
+ if (!expValEquals('platform_editor_editor_ssr_streaming', 'isEnabled', true)) {
309
+ if (containerRef.current && editorHTML && typeof editorHTML !== 'string') {
310
+ containerRef.current.innerHTML = '';
311
+ containerRef.current.appendChild(editorHTML);
312
+ }
304
313
  }
305
314
  }, [editorHTML]);
306
315
  return /*#__PURE__*/React.createElement(SSRRenderMeasure, {
@@ -308,8 +317,12 @@ export function EditorSSRRenderer({
308
317
  startTimestampRef: firstRenderStartTimestampRef,
309
318
  onSSRMeasure: onSSRMeasure
310
319
  }, /*#__PURE__*/React.createElement("div", {
311
- ref: containerRef,
312
320
  id: divProps.id
321
+ // eslint-disable-next-line react/no-danger -- It's intentional by design
322
+ ,
323
+ dangerouslySetInnerHTML: typeof editorHTML === 'string' && expValEquals('platform_editor_editor_ssr_streaming', 'isEnabled', true) ? {
324
+ __html: editorHTML
325
+ } : undefined
313
326
  // For some reason on SSR, the result `class` has a trailing space, that broke UFO,
314
327
  // because ReactEditorView produces a div with `class` without space.
315
328
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
@@ -370,7 +370,14 @@ export function EditorSSRRenderer(_ref) {
370
370
  doc.descendants(function (node, pos) {
371
371
  nodePositions.set(node, pos);
372
372
  });
373
- return serializer.serializeFragment(doc.content);
373
+ if (expValEquals('platform_editor_editor_ssr_streaming', 'isEnabled', true)) {
374
+ var fragment = serializer.serializeFragment(doc.content);
375
+ var wrapper = document.createElement('div');
376
+ wrapper.appendChild(fragment);
377
+ return wrapper.innerHTML;
378
+ } else {
379
+ return serializer.serializeFragment(doc.content);
380
+ }
374
381
  };
375
382
  try {
376
383
  return profileSSROperation("".concat(SSR_TRACE_SEGMENT_NAME, "/serializeFragment"), serializeFragment, onSSRMeasure);
@@ -381,9 +388,11 @@ export function EditorSSRRenderer(_ref) {
381
388
  }, [doc, serializer, nodePositions, onSSRMeasure]);
382
389
  var containerRef = useRef(null);
383
390
  useLayoutEffect(function () {
384
- if (containerRef.current && editorHTML) {
385
- containerRef.current.innerHTML = '';
386
- containerRef.current.appendChild(editorHTML);
391
+ if (!expValEquals('platform_editor_editor_ssr_streaming', 'isEnabled', true)) {
392
+ if (containerRef.current && editorHTML && typeof editorHTML !== 'string') {
393
+ containerRef.current.innerHTML = '';
394
+ containerRef.current.appendChild(editorHTML);
395
+ }
387
396
  }
388
397
  }, [editorHTML]);
389
398
  return /*#__PURE__*/React.createElement(SSRRenderMeasure, {
@@ -391,8 +400,12 @@ export function EditorSSRRenderer(_ref) {
391
400
  startTimestampRef: firstRenderStartTimestampRef,
392
401
  onSSRMeasure: onSSRMeasure
393
402
  }, /*#__PURE__*/React.createElement("div", {
394
- ref: containerRef,
395
403
  id: divProps.id
404
+ // eslint-disable-next-line react/no-danger -- It's intentional by design
405
+ ,
406
+ dangerouslySetInnerHTML: typeof editorHTML === 'string' && expValEquals('platform_editor_editor_ssr_streaming', 'isEnabled', true) ? {
407
+ __html: editorHTML
408
+ } : undefined
396
409
  // For some reason on SSR, the result `class` has a trailing space, that broke UFO,
397
410
  // because ReactEditorView produces a div with `class` without space.
398
411
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-ssr-renderer",
3
- "version": "3.1.11",
3
+ "version": "3.2.0",
4
4
  "description": "SSR Renderer based on Editor",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "atlassian": {
@@ -30,12 +30,12 @@
30
30
  "@atlaskit/adf-schema": "^52.4.0",
31
31
  "@atlaskit/editor-prosemirror": "^7.3.0",
32
32
  "@atlaskit/platform-feature-flags": "^1.1.0",
33
- "@atlaskit/tmp-editor-statsig": "^53.0.0",
33
+ "@atlaskit/tmp-editor-statsig": "^54.2.0",
34
34
  "@babel/runtime": "^7.0.0",
35
35
  "react-intl-next": "npm:react-intl@^5.18.1"
36
36
  },
37
37
  "peerDependencies": {
38
- "@atlaskit/editor-common": "^112.15.0",
38
+ "@atlaskit/editor-common": "^112.17.0",
39
39
  "react": "^18.2.0"
40
40
  }
41
41
  }