@atlaskit/editor-wikimarkup-transformer
Version:
Wiki markup transformer for JIRA and Confluence
59 lines (57 loc) • 1.77 kB
JavaScript
import { blockquote } from './nodes/blockquote';
import { bulletList } from './nodes/bullet-list';
import { taskList } from './nodes/taskList';
import { decisionList } from './nodes/decisionList';
import { codeBlock } from './nodes/code-block';
import { doc } from './nodes/doc';
import { expand } from './nodes/expand';
import { heading } from './nodes/heading';
import { mediaGroup } from './nodes/media-group';
import { mediaInline } from './nodes/media-inline';
import { orderedList } from './nodes/ordered-list';
import { panel } from './nodes/panel';
import { paragraph } from './nodes/paragraph';
import { rule } from './nodes/rule';
import { table } from './nodes/table';
import { unknown } from './nodes/unknown';
import { blockCard } from './nodes/block-card';
import { embedCard } from './nodes/embed-card';
import { caption } from './nodes/caption';
import { bodiedSyncBlock } from './nodes/bodied-sync-block';
// Ignored via go/ees005
// eslint-disable-next-line @typescript-eslint/no-explicit-any
var nodeEncoderMapping = {
blockquote: blockquote,
bulletList: bulletList,
taskList: taskList,
decisionList: decisionList,
codeBlock: codeBlock,
doc: doc,
heading: heading,
caption: caption,
mediaGroup: mediaGroup,
mediaInline: mediaInline,
mediaSingle: mediaGroup,
orderedList: orderedList,
panel: panel,
paragraph: paragraph,
rule: rule,
table: table,
blockCard: blockCard,
embedCard: embedCard,
expand: expand,
bodiedSyncBlock: bodiedSyncBlock
};
export function encode(node, context) {
var encoder = nodeEncoderMapping[node.type.name];
try {
if (encoder) {
return encoder(node, {
context: context
});
}
return unknown(node);
} catch (err) {
return unknown(node);
}
}