UNPKG

@atlaskit/editor-wikimarkup-transformer

Version:

Wiki markup transformer for JIRA and Confluence

33 lines 1.15 kB
import _slicedToArray from "@babel/runtime/helpers/slicedToArray"; import getMediaSingleNodeView from '../nodes/mediaSingle'; import { parseAttrs } from '../utils/attrs'; import { commonFormatter } from './common-formatter'; export var media = function media(_ref) { var input = _ref.input, position = _ref.position, schema = _ref.schema, context = _ref.context; var rawContentProcessor = function rawContentProcessor(raw, length) { /** * !image.gif|align=right, vspace=4|ignore-this! * If it splits into more than 2 items, we ignore the rest */ var _raw$split = raw.split('|'), _raw$split2 = _slicedToArray(_raw$split, 2), rawContent = _raw$split2[0], _raw$split2$ = _raw$split2[1], rawAttrs = _raw$split2$ === void 0 ? '' : _raw$split2$; var node = getMediaSingleNodeView(schema, rawContent, parseAttrs(rawAttrs, ','), context); return { type: 'pmnode', nodes: [node], length: length }; }; return commonFormatter(input, position, schema, { opening: '!', closing: '!', context: context, rawContentProcessor: rawContentProcessor }); };