@atlaskit/editor-wikimarkup-transformer
Version:
Wiki markup transformer for JIRA and Confluence
25 lines (22 loc) • 1.29 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = getMediaGroupNodeView;
function getMediaGroupNodeView(schema, filename) {
var _context$conversion$m, _context$conversion;
var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var _schema$nodes = schema.nodes,
media = _schema$nodes.media,
mediaGroup = _schema$nodes.mediaGroup;
// try to look up media ID from conversion context
var id = (_context$conversion$m = context === null || context === void 0 || (_context$conversion = context.conversion) === null || _context$conversion === void 0 || (_context$conversion = _context$conversion.mediaConversion) === null || _context$conversion === void 0 || (_context$conversion = _context$conversion[filename]) === null || _context$conversion === void 0 ? void 0 : _context$conversion.transform) !== null && _context$conversion$m !== void 0 ? _context$conversion$m : filename;
// try to look up collection from media context
var collection = context.hydration && context.hydration.media && context.hydration.media.targetCollectionId;
var mediaNode = media.createChecked({
id: id,
type: 'file',
collection: collection || ''
});
return mediaGroup.createChecked({}, mediaNode);
}