@atlaskit/editor-ssr-renderer 3.2.4 → 3.3.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,16 @@
1
1
  # @atlaskit/editor-ssr-renderer
2
2
 
3
+ ## 3.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`3f28038f8be0f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3f28038f8be0f) -
8
+ Add support SSR streaming for SSREditorRenderer
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies
13
+
3
14
  ## 3.2.4
4
15
 
5
16
  ### 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, {
@@ -402,6 +411,11 @@ function EditorSSRRenderer(_ref) {
402
411
  }, /*#__PURE__*/_react.default.createElement("div", {
403
412
  ref: containerRef,
404
413
  id: divProps.id
414
+ // eslint-disable-next-line react/no-danger -- It's intentional by design
415
+ ,
416
+ dangerouslySetInnerHTML: typeof editorHTML === 'string' && (0, _expValEquals.expValEquals)('platform_editor_editor_ssr_streaming', 'isEnabled', true) ? {
417
+ __html: editorHTML
418
+ } : undefined
405
419
  // For some reason on SSR, the result `class` has a trailing space, that broke UFO,
406
420
  // because ReactEditorView produces a div with `class` without space.
407
421
  // 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, {
@@ -310,6 +319,11 @@ export function EditorSSRRenderer({
310
319
  }, /*#__PURE__*/React.createElement("div", {
311
320
  ref: containerRef,
312
321
  id: divProps.id
322
+ // eslint-disable-next-line react/no-danger -- It's intentional by design
323
+ ,
324
+ dangerouslySetInnerHTML: typeof editorHTML === 'string' && expValEquals('platform_editor_editor_ssr_streaming', 'isEnabled', true) ? {
325
+ __html: editorHTML
326
+ } : undefined
313
327
  // For some reason on SSR, the result `class` has a trailing space, that broke UFO,
314
328
  // because ReactEditorView produces a div with `class` without space.
315
329
  // 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, {
@@ -393,6 +402,11 @@ export function EditorSSRRenderer(_ref) {
393
402
  }, /*#__PURE__*/React.createElement("div", {
394
403
  ref: containerRef,
395
404
  id: divProps.id
405
+ // eslint-disable-next-line react/no-danger -- It's intentional by design
406
+ ,
407
+ dangerouslySetInnerHTML: typeof editorHTML === 'string' && expValEquals('platform_editor_editor_ssr_streaming', 'isEnabled', true) ? {
408
+ __html: editorHTML
409
+ } : undefined
396
410
  // For some reason on SSR, the result `class` has a trailing space, that broke UFO,
397
411
  // because ReactEditorView produces a div with `class` without space.
398
412
  // 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.2.4",
3
+ "version": "3.3.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": "^58.0.0",
33
+ "@atlaskit/tmp-editor-statsig": "^59.1.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.19.0",
38
+ "@atlaskit/editor-common": "^112.20.0",
39
39
  "react": "^18.2.0"
40
40
  }
41
41
  }