@atlaskit/editor-plugin-synced-block
Version:
SyncedBlock plugin for @atlaskit/editor-core
34 lines (33 loc) • 1.22 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.SyncBlockSSRReactContextsProvider = SyncBlockSSRReactContextsProvider;
var _react = _interopRequireDefault(require("react"));
var _reactIntl = require("react-intl");
var _coreUtils = require("@atlaskit/editor-common/core-utils");
/**
* Wraps syncBlock nodeview children with the editor's actual IntlProvider during
* SSR streaming (renderToStaticMarkup). This ensures that components using
* useIntl() — such as SyncBlockLabel, SyncedBlockLoadingState, and
* ReactRenderer's table/code-block node renderers — have a valid intl context
* and do not throw during the static render pass.
*
* Outside of SSR streaming this is a no-op passthrough.
*
* Follows the same pattern as MediaSSRReactContextsProvider.
*/
function SyncBlockSSRReactContextsProvider(_ref) {
var children = _ref.children,
intl = _ref.intl;
if (!(0, _coreUtils.isSSR)()) {
return children;
}
if (!intl) {
return children;
}
return /*#__PURE__*/_react.default.createElement(_reactIntl.RawIntlProvider, {
value: intl
}, children);
}