UNPKG

@atlaskit/editor-plugin-synced-block

Version:

SyncedBlock plugin for @atlaskit/editor-core

34 lines 2.6 kB
import React from 'react'; import { SyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block'; import { SyncBlockError } from '@atlaskit/editor-synced-block-provider'; import { SyncBlockLabel } from './SyncBlockLabel'; var SyncBlockRendererWrapperDataId = 'sync-block-plugin-renderer-wrapper'; var SyncBlockRendererWrapperComponent = function SyncBlockRendererWrapperComponent(_ref) { var _syncBlockFetchResult, _syncBlockFetchResult2, _syncBlockFetchResult3; var syncedBlockRenderer = _ref.syncedBlockRenderer, useFetchSyncBlockData = _ref.useFetchSyncBlockData, useFetchSyncBlockTitle = _ref.useFetchSyncBlockTitle, localId = _ref.localId, api = _ref.api; var syncBlockFetchResult = useFetchSyncBlockData(); var title = useFetchSyncBlockTitle === null || useFetchSyncBlockTitle === void 0 ? void 0 : useFetchSyncBlockTitle(); var contentUpdatedAt = syncBlockFetchResult === null || syncBlockFetchResult === void 0 || (_syncBlockFetchResult = syncBlockFetchResult.syncBlockInstance) === null || _syncBlockFetchResult === void 0 || (_syncBlockFetchResult = _syncBlockFetchResult.data) === null || _syncBlockFetchResult === void 0 ? void 0 : _syncBlockFetchResult.contentUpdatedAt; var isUnpublishedBlock = ((_syncBlockFetchResult2 = syncBlockFetchResult.syncBlockInstance) === null || _syncBlockFetchResult2 === void 0 || (_syncBlockFetchResult2 = _syncBlockFetchResult2.data) === null || _syncBlockFetchResult2 === void 0 ? void 0 : _syncBlockFetchResult2.status) === 'unpublished'; var isUnsyncedBlock = isUnpublishedBlock || (syncBlockFetchResult === null || syncBlockFetchResult === void 0 || (_syncBlockFetchResult3 = syncBlockFetchResult.syncBlockInstance) === null || _syncBlockFetchResult3 === void 0 || (_syncBlockFetchResult3 = _syncBlockFetchResult3.error) === null || _syncBlockFetchResult3 === void 0 ? void 0 : _syncBlockFetchResult3.type) === SyncBlockError.NotFound; return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { "data-testid": SyncBlockRendererWrapperDataId // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop , className: SyncBlockSharedCssClassName.renderer }, syncedBlockRenderer({ syncBlockFetchResult: syncBlockFetchResult, api: api })), /*#__PURE__*/React.createElement(SyncBlockLabel, { isSource: false, title: title, contentUpdatedAt: contentUpdatedAt, localId: localId, isUnsyncedBlock: isUnsyncedBlock })); }; export var SyncBlockRendererWrapper = /*#__PURE__*/React.memo(SyncBlockRendererWrapperComponent);