UNPKG

@atlaskit/editor-plugin-synced-block

Version:

SyncedBlock plugin for @atlaskit/editor-core

28 lines 879 B
import React from 'react'; import { RawIntlProvider } from 'react-intl'; import { isSSR } from '@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. */ export function SyncBlockSSRReactContextsProvider({ children, intl }) { if (!isSSR()) { return children; } if (!intl) { return children; } return /*#__PURE__*/React.createElement(RawIntlProvider, { value: intl }, children); }