@atlaskit/editor-plugin-synced-block
Version:
SyncedBlock plugin for @atlaskit/editor-core
41 lines (40 loc) • 2.95 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.SyncBlockRendererWrapper = void 0;
var _react = _interopRequireDefault(require("react"));
var _syncBlock = require("@atlaskit/editor-common/sync-block");
var _editorSyncedBlockProvider = require("@atlaskit/editor-synced-block-provider");
var _SyncBlockLabel = require("./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) === _editorSyncedBlockProvider.SyncBlockError.NotFound;
return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", {
"data-testid": SyncBlockRendererWrapperDataId
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
,
className: _syncBlock.SyncBlockSharedCssClassName.renderer
}, syncedBlockRenderer({
syncBlockFetchResult: syncBlockFetchResult,
api: api
})), /*#__PURE__*/_react.default.createElement(_SyncBlockLabel.SyncBlockLabel, {
isSource: false,
title: title,
contentUpdatedAt: contentUpdatedAt,
localId: localId,
isUnsyncedBlock: isUnsyncedBlock
}));
};
var SyncBlockRendererWrapper = exports.SyncBlockRendererWrapper = /*#__PURE__*/_react.default.memo(SyncBlockRendererWrapperComponent);