UNPKG

@atlaskit/editor-wikimarkup-transformer

Version:

Wiki markup transformer for JIRA and Confluence

19 lines (17 loc) 1.15 kB
export default function getMediaGroupNodeView(schema, filename, context = {}) { var _context$conversion$m, _context$conversion, _context$conversion$m2, _context$conversion$m3; const { media, mediaGroup } = schema.nodes; // try to look up media ID from conversion context const id = (_context$conversion$m = context === null || context === void 0 ? void 0 : (_context$conversion = context.conversion) === null || _context$conversion === void 0 ? void 0 : (_context$conversion$m2 = _context$conversion.mediaConversion) === null || _context$conversion$m2 === void 0 ? void 0 : (_context$conversion$m3 = _context$conversion$m2[filename]) === null || _context$conversion$m3 === void 0 ? void 0 : _context$conversion$m3.transform) !== null && _context$conversion$m !== void 0 ? _context$conversion$m : filename; // try to look up collection from media context const collection = context.hydration && context.hydration.media && context.hydration.media.targetCollectionId; const mediaNode = media.createChecked({ id, type: 'file', collection: collection || '' }); return mediaGroup.createChecked({}, mediaNode); }