@atlaskit/editor-common 114.1.0 → 114.1.1

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-common
2
2
 
3
+ ## 114.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`2e95c42be9be9`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2e95c42be9be9) -
8
+ Fix inline node view portal rendering for SSR streaming. Add SSR branch in
9
+ `getInlineNodeViewProducer` that renders inline node views synchronously using `createRoot` +
10
+ `flushSync` directly into the `domRef`, bypassing the portal mechanism. Skip
11
+ `portalProviderAPI.remove()` during SSR cleanup. All changes gated behind
12
+ `platform_editor_editor_ssr_streaming`.
13
+
3
14
  ## 114.1.0
4
15
 
5
16
  ### Minor Changes
@@ -19,7 +19,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
19
19
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
20
20
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
21
21
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
22
- var packageVersion = "114.0.0";
22
+ var packageVersion = "0.0.0-development";
23
23
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
24
24
  // Remove URL as it has UGC
25
25
  // Ignored via go/ees007
@@ -10,9 +10,13 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
10
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
11
  var _react = _interopRequireDefault(require("react"));
12
12
  var _react2 = require("@emotion/react");
13
+ var _reactDom = require("react-dom");
14
+ var _client = require("react-dom/client");
13
15
  var _model = require("@atlaskit/editor-prosemirror/model");
14
16
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
17
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
15
18
  var _analytics = require("../analytics");
19
+ var _isSsr = require("../core-utils/is-ssr");
16
20
  var _ErrorBoundary = require("../ui/ErrorBoundary");
17
21
  var _utils = require("../utils");
18
22
  var _browser = require("../utils/browser");
@@ -24,7 +28,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
24
28
  * @jsxRuntime classic
25
29
  * @jsx jsx
26
30
  */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
27
- var isSSR = Boolean(process.env.REACT_SSR);
28
31
  var inlineNodeViewClassname = exports.inlineNodeViewClassname = 'inlineNodeView';
29
32
  var canRenderFallback = function canRenderFallback(node) {
30
33
  return node.type.isInline && node.type.isAtom && node.type.isLeaf;
@@ -77,13 +80,39 @@ function createNodeView(_ref) {
77
80
  // to the passed dom element (domRef) which means it is automatically
78
81
  // "cleaned up" when you do a "re render".
79
82
  function renderComponent() {
80
- pmPluginFactoryParams.portalProviderAPI.render(getPortalChildren({
81
- dispatchAnalyticsEvent: dispatchAnalyticsEvent,
82
- currentNode: currentNode,
83
- nodeViewParams: nodeViewParams,
84
- Component: Component,
85
- extraComponentProps: extraComponentProps
86
- }), domRef, key);
83
+ if ((0, _isSsr.isSSR)() && (0, _expValEquals.expValEquals)('platform_editor_editor_ssr_streaming', 'isEnabled', true)) {
84
+ var html = '';
85
+
86
+ // We don't use direct rendering to the domRef, as this can lead to unexpected behavior,
87
+ // when the domRef element might have handlers from ProseMirror that will start executing
88
+ // in JSDom. Therefore, we simply attempt to render the element synchronously, get its HTML, and set it to the domRef,
89
+ // to keep the domRef as clear as possible.
90
+ try {
91
+ var PortalComponent = getPortalChildren({
92
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
93
+ currentNode: currentNode,
94
+ nodeViewParams: nodeViewParams,
95
+ Component: Component,
96
+ extraComponentProps: extraComponentProps
97
+ });
98
+ var rootElement = document.createElement('span');
99
+ var ssrRoot = (0, _client.createRoot)(rootElement);
100
+ (0, _reactDom.flushSync)(function () {
101
+ ssrRoot.render((0, _react2.jsx)(PortalComponent, null));
102
+ });
103
+ html = rootElement.innerHTML;
104
+ ssrRoot.unmount();
105
+ } catch (_unused) {}
106
+ domRef.innerHTML = html;
107
+ } else {
108
+ pmPluginFactoryParams.portalProviderAPI.render(getPortalChildren({
109
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
110
+ currentNode: currentNode,
111
+ nodeViewParams: nodeViewParams,
112
+ Component: Component,
113
+ extraComponentProps: extraComponentProps
114
+ }), domRef, key);
115
+ }
87
116
  }
88
117
  var _getPerformanceOption = (0, _utils.getPerformanceOptions)(nodeViewParams.view),
89
118
  samplingRate = _getPerformanceOption.samplingRate,
@@ -137,10 +166,12 @@ function createNodeView(_ref) {
137
166
  return true;
138
167
  },
139
168
  destroy: function destroy() {
140
- // When prosemirror destroys the node view, we need to clean up
141
- // what we have previously rendered using the editor portal
142
- // provider api.
143
- pmPluginFactoryParams.portalProviderAPI.remove(key);
169
+ if (!(0, _isSsr.isSSR)() || !(0, _expValEquals.expValEquals)('platform_editor_editor_ssr_streaming', 'isEnabled', true)) {
170
+ // When prosemirror destroys the node view, we need to clean up
171
+ // what we have previously rendered using the editor portal
172
+ // provider api.
173
+ pmPluginFactoryParams.portalProviderAPI.remove(key);
174
+ }
144
175
  // @ts-expect-error Expect an error as domRef is expected to be
145
176
  // of HTMLSpanElement type however once the node view has
146
177
  // been destroyed no other consumers should still be using it.
@@ -412,7 +443,7 @@ function getInlineNodeViewProducer(_ref4) {
412
443
  extraNodeViewProps: extraNodeViewProps
413
444
  };
414
445
  var isNodeTypeAllowedToBeVirtualized = virtualizedNodeAllowlist.includes((node === null || node === void 0 || (_node$type = node.type) === null || _node$type === void 0 ? void 0 : _node$type.name) || '');
415
- if (!isNodeTypeAllowedToBeVirtualized || isSSR) {
446
+ if (!isNodeTypeAllowedToBeVirtualized || (0, _isSsr.isSSR)()) {
416
447
  return createNodeView(parameters);
417
448
  }
418
449
  if ((0, _platformFeatureFlags.fg)('platform_editor_inline_node_virt_threshold_override')) {
@@ -24,7 +24,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
24
24
  * @jsx jsx
25
25
  */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
26
26
  var packageName = "@atlaskit/editor-common";
27
- var packageVersion = "114.0.0";
27
+ var packageVersion = "0.0.0-development";
28
28
  var halfFocusRing = 1;
29
29
  var dropOffset = '0, 8';
30
30
  var fadeIn = (0, _react2.keyframes)({
@@ -4,7 +4,7 @@ import { isFedRamp } from './environment';
4
4
  import { normaliseSentryBreadcrumbs, SERIALIZABLE_ATTRIBUTES } from './normalise-sentry-breadcrumbs';
5
5
  const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
6
6
  const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
7
- const packageVersion = "114.0.0";
7
+ const packageVersion = "0.0.0-development";
8
8
  const sanitiseSentryEvents = (data, _hint) => {
9
9
  // Remove URL as it has UGC
10
10
  // Ignored via go/ees007
@@ -7,16 +7,19 @@ import React from 'react';
7
7
 
8
8
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
9
9
  import { jsx } from '@emotion/react';
10
+ import { flushSync } from 'react-dom';
11
+ import { createRoot } from 'react-dom/client';
10
12
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
11
13
  import { fg } from '@atlaskit/platform-feature-flags';
14
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
12
15
  import { ACTION_SUBJECT, ACTION_SUBJECT_ID } from '../analytics';
16
+ import { isSSR } from '../core-utils/is-ssr';
13
17
  import { ErrorBoundary } from '../ui/ErrorBoundary';
14
18
  import { analyticsEventKey, getPerformanceOptions, startMeasureReactNodeViewRendered, stopMeasureReactNodeViewRendered } from '../utils';
15
19
  import { getBrowserInfo } from '../utils/browser';
16
20
  import { ZERO_WIDTH_SPACE } from '../whitespace';
17
21
  import { generateUniqueNodeKey } from './generateUniqueNodeKey';
18
22
  import { getOrCreateOnVisibleObserver } from './onVisibleObserverFactory';
19
- const isSSR = Boolean(process.env.REACT_SSR);
20
23
  export const inlineNodeViewClassname = 'inlineNodeView';
21
24
  const canRenderFallback = node => {
22
25
  return node.type.isInline && node.type.isAtom && node.type.isLeaf;
@@ -70,13 +73,39 @@ function createNodeView({
70
73
  // to the passed dom element (domRef) which means it is automatically
71
74
  // "cleaned up" when you do a "re render".
72
75
  function renderComponent() {
73
- pmPluginFactoryParams.portalProviderAPI.render(getPortalChildren({
74
- dispatchAnalyticsEvent,
75
- currentNode,
76
- nodeViewParams,
77
- Component,
78
- extraComponentProps
79
- }), domRef, key);
76
+ if (isSSR() && expValEquals('platform_editor_editor_ssr_streaming', 'isEnabled', true)) {
77
+ let html = '';
78
+
79
+ // We don't use direct rendering to the domRef, as this can lead to unexpected behavior,
80
+ // when the domRef element might have handlers from ProseMirror that will start executing
81
+ // in JSDom. Therefore, we simply attempt to render the element synchronously, get its HTML, and set it to the domRef,
82
+ // to keep the domRef as clear as possible.
83
+ try {
84
+ const PortalComponent = getPortalChildren({
85
+ dispatchAnalyticsEvent,
86
+ currentNode,
87
+ nodeViewParams,
88
+ Component,
89
+ extraComponentProps
90
+ });
91
+ const rootElement = document.createElement('span');
92
+ const ssrRoot = createRoot(rootElement);
93
+ flushSync(() => {
94
+ ssrRoot.render(jsx(PortalComponent, null));
95
+ });
96
+ html = rootElement.innerHTML;
97
+ ssrRoot.unmount();
98
+ } catch {}
99
+ domRef.innerHTML = html;
100
+ } else {
101
+ pmPluginFactoryParams.portalProviderAPI.render(getPortalChildren({
102
+ dispatchAnalyticsEvent,
103
+ currentNode,
104
+ nodeViewParams,
105
+ Component,
106
+ extraComponentProps
107
+ }), domRef, key);
108
+ }
80
109
  }
81
110
  const {
82
111
  samplingRate,
@@ -133,10 +162,12 @@ function createNodeView({
133
162
  return true;
134
163
  },
135
164
  destroy() {
136
- // When prosemirror destroys the node view, we need to clean up
137
- // what we have previously rendered using the editor portal
138
- // provider api.
139
- pmPluginFactoryParams.portalProviderAPI.remove(key);
165
+ if (!isSSR() || !expValEquals('platform_editor_editor_ssr_streaming', 'isEnabled', true)) {
166
+ // When prosemirror destroys the node view, we need to clean up
167
+ // what we have previously rendered using the editor portal
168
+ // provider api.
169
+ pmPluginFactoryParams.portalProviderAPI.remove(key);
170
+ }
140
171
  // @ts-expect-error Expect an error as domRef is expected to be
141
172
  // of HTMLSpanElement type however once the node view has
142
173
  // been destroyed no other consumers should still be using it.
@@ -414,7 +445,7 @@ export function getInlineNodeViewProducer({
414
445
  extraNodeViewProps
415
446
  };
416
447
  const isNodeTypeAllowedToBeVirtualized = virtualizedNodeAllowlist.includes((node === null || node === void 0 ? void 0 : (_node$type = node.type) === null || _node$type === void 0 ? void 0 : _node$type.name) || '');
417
- if (!isNodeTypeAllowedToBeVirtualized || isSSR) {
448
+ if (!isNodeTypeAllowedToBeVirtualized || isSSR()) {
418
449
  return createNodeView(parameters);
419
450
  }
420
451
  if (fg('platform_editor_inline_node_virt_threshold_override')) {
@@ -14,7 +14,7 @@ import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
14
14
  import { fg } from '@atlaskit/platform-feature-flags';
15
15
  import Layer from '../Layer';
16
16
  const packageName = "@atlaskit/editor-common";
17
- const packageVersion = "114.0.0";
17
+ const packageVersion = "0.0.0-development";
18
18
  const halfFocusRing = 1;
19
19
  const dropOffset = '0, 8';
20
20
  const fadeIn = keyframes({
@@ -10,7 +10,7 @@ import { isFedRamp } from './environment';
10
10
  import { normaliseSentryBreadcrumbs, SERIALIZABLE_ATTRIBUTES } from './normalise-sentry-breadcrumbs';
11
11
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
12
12
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
13
- var packageVersion = "114.0.0";
13
+ var packageVersion = "0.0.0-development";
14
14
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
15
15
  // Remove URL as it has UGC
16
16
  // Ignored via go/ees007
@@ -10,16 +10,19 @@ import React from 'react';
10
10
 
11
11
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
12
12
  import { jsx } from '@emotion/react';
13
+ import { flushSync } from 'react-dom';
14
+ import { createRoot } from 'react-dom/client';
13
15
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
14
16
  import { fg } from '@atlaskit/platform-feature-flags';
17
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
15
18
  import { ACTION_SUBJECT, ACTION_SUBJECT_ID } from '../analytics';
19
+ import { isSSR } from '../core-utils/is-ssr';
16
20
  import { ErrorBoundary } from '../ui/ErrorBoundary';
17
21
  import { analyticsEventKey, getPerformanceOptions, startMeasureReactNodeViewRendered, stopMeasureReactNodeViewRendered } from '../utils';
18
22
  import { getBrowserInfo } from '../utils/browser';
19
23
  import { ZERO_WIDTH_SPACE } from '../whitespace';
20
24
  import { generateUniqueNodeKey } from './generateUniqueNodeKey';
21
25
  import { getOrCreateOnVisibleObserver } from './onVisibleObserverFactory';
22
- var isSSR = Boolean(process.env.REACT_SSR);
23
26
  export var inlineNodeViewClassname = 'inlineNodeView';
24
27
  var canRenderFallback = function canRenderFallback(node) {
25
28
  return node.type.isInline && node.type.isAtom && node.type.isLeaf;
@@ -72,13 +75,39 @@ function createNodeView(_ref) {
72
75
  // to the passed dom element (domRef) which means it is automatically
73
76
  // "cleaned up" when you do a "re render".
74
77
  function renderComponent() {
75
- pmPluginFactoryParams.portalProviderAPI.render(getPortalChildren({
76
- dispatchAnalyticsEvent: dispatchAnalyticsEvent,
77
- currentNode: currentNode,
78
- nodeViewParams: nodeViewParams,
79
- Component: Component,
80
- extraComponentProps: extraComponentProps
81
- }), domRef, key);
78
+ if (isSSR() && expValEquals('platform_editor_editor_ssr_streaming', 'isEnabled', true)) {
79
+ var html = '';
80
+
81
+ // We don't use direct rendering to the domRef, as this can lead to unexpected behavior,
82
+ // when the domRef element might have handlers from ProseMirror that will start executing
83
+ // in JSDom. Therefore, we simply attempt to render the element synchronously, get its HTML, and set it to the domRef,
84
+ // to keep the domRef as clear as possible.
85
+ try {
86
+ var PortalComponent = getPortalChildren({
87
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
88
+ currentNode: currentNode,
89
+ nodeViewParams: nodeViewParams,
90
+ Component: Component,
91
+ extraComponentProps: extraComponentProps
92
+ });
93
+ var rootElement = document.createElement('span');
94
+ var ssrRoot = createRoot(rootElement);
95
+ flushSync(function () {
96
+ ssrRoot.render(jsx(PortalComponent, null));
97
+ });
98
+ html = rootElement.innerHTML;
99
+ ssrRoot.unmount();
100
+ } catch (_unused) {}
101
+ domRef.innerHTML = html;
102
+ } else {
103
+ pmPluginFactoryParams.portalProviderAPI.render(getPortalChildren({
104
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
105
+ currentNode: currentNode,
106
+ nodeViewParams: nodeViewParams,
107
+ Component: Component,
108
+ extraComponentProps: extraComponentProps
109
+ }), domRef, key);
110
+ }
82
111
  }
83
112
  var _getPerformanceOption = getPerformanceOptions(nodeViewParams.view),
84
113
  samplingRate = _getPerformanceOption.samplingRate,
@@ -132,10 +161,12 @@ function createNodeView(_ref) {
132
161
  return true;
133
162
  },
134
163
  destroy: function destroy() {
135
- // When prosemirror destroys the node view, we need to clean up
136
- // what we have previously rendered using the editor portal
137
- // provider api.
138
- pmPluginFactoryParams.portalProviderAPI.remove(key);
164
+ if (!isSSR() || !expValEquals('platform_editor_editor_ssr_streaming', 'isEnabled', true)) {
165
+ // When prosemirror destroys the node view, we need to clean up
166
+ // what we have previously rendered using the editor portal
167
+ // provider api.
168
+ pmPluginFactoryParams.portalProviderAPI.remove(key);
169
+ }
139
170
  // @ts-expect-error Expect an error as domRef is expected to be
140
171
  // of HTMLSpanElement type however once the node view has
141
172
  // been destroyed no other consumers should still be using it.
@@ -407,7 +438,7 @@ export function getInlineNodeViewProducer(_ref4) {
407
438
  extraNodeViewProps: extraNodeViewProps
408
439
  };
409
440
  var isNodeTypeAllowedToBeVirtualized = virtualizedNodeAllowlist.includes((node === null || node === void 0 || (_node$type = node.type) === null || _node$type === void 0 ? void 0 : _node$type.name) || '');
410
- if (!isNodeTypeAllowedToBeVirtualized || isSSR) {
441
+ if (!isNodeTypeAllowedToBeVirtualized || isSSR()) {
411
442
  return createNodeView(parameters);
412
443
  }
413
444
  if (fg('platform_editor_inline_node_virt_threshold_override')) {
@@ -21,7 +21,7 @@ import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
21
21
  import { fg } from '@atlaskit/platform-feature-flags';
22
22
  import Layer from '../Layer';
23
23
  var packageName = "@atlaskit/editor-common";
24
- var packageVersion = "114.0.0";
24
+ var packageVersion = "0.0.0-development";
25
25
  var halfFocusRing = 1;
26
26
  var dropOffset = '0, 8';
27
27
  var fadeIn = keyframes({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "114.1.0",
3
+ "version": "114.1.1",
4
4
  "description": "A package that contains common classes and components for editor and renderer",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -56,7 +56,7 @@
56
56
  "@atlaskit/link": "^3.4.0",
57
57
  "@atlaskit/link-datasource": "^5.0.0",
58
58
  "@atlaskit/link-picker": "^5.0.0",
59
- "@atlaskit/media-card": "^80.0.0",
59
+ "@atlaskit/media-card": "^80.1.0",
60
60
  "@atlaskit/media-client": "^36.0.0",
61
61
  "@atlaskit/media-client-react": "^5.0.0",
62
62
  "@atlaskit/media-common": "^13.0.0",
@@ -70,16 +70,16 @@
70
70
  "@atlaskit/platform-feature-flags": "^1.1.0",
71
71
  "@atlaskit/platform-feature-flags-react": "^0.4.0",
72
72
  "@atlaskit/primitives": "^19.0.0",
73
- "@atlaskit/profilecard": "^25.0.0",
73
+ "@atlaskit/profilecard": "^25.1.0",
74
74
  "@atlaskit/prosemirror-history": "^0.2.0",
75
75
  "@atlaskit/react-ufo": "^5.14.0",
76
76
  "@atlaskit/section-message": "^8.12.0",
77
- "@atlaskit/smart-card": "^44.0.0",
77
+ "@atlaskit/smart-card": "^44.1.0",
78
78
  "@atlaskit/smart-user-picker": "^10.0.0",
79
79
  "@atlaskit/spinner": "^19.1.0",
80
80
  "@atlaskit/task-decision": "^20.0.0",
81
81
  "@atlaskit/textfield": "^8.3.0",
82
- "@atlaskit/tmp-editor-statsig": "^62.4.0",
82
+ "@atlaskit/tmp-editor-statsig": "^62.8.0",
83
83
  "@atlaskit/tokens": "^13.0.0",
84
84
  "@atlaskit/tooltip": "^21.1.0",
85
85
  "@atlaskit/width-detector": "^5.1.0",