UNPKG

@curvenote/schema

Version:

Schema and markdown parser for @curvenote/editor

61 lines 1.91 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.toTex = exports.toMarkdown = void 0; const utils_1 = require("../serialize/tex/utils"); const types_1 = require("./types"); const types_2 = require("../types"); const figcaption = { content: `${types_1.NodeGroups.inline}*`, attrs: { kind: { default: null }, }, draggable: false, defining: true, toDOM(node) { const { kind } = node.attrs; return [ 'figcaption', { kind: kind !== null && kind !== void 0 ? kind : undefined, }, 0, ]; }, parseDOM: [ { tag: 'figcaption', getAttrs(dom) { var _a; return { kind: (_a = dom.getAttribute('kind')) !== null && _a !== void 0 ? _a : null, }; }, }, ], attrsFromMyst: (token, tokens) => { const adjacentTypes = tokens.map((t) => t.type); return { kind: adjacentTypes.includes(types_2.nodeNames.table) ? types_1.CaptionKind.table : types_1.CaptionKind.fig }; }, toMyst: (props) => ({ type: 'caption', children: (props.children || []), }), }; const toMarkdown = (state, node) => { state.renderInline(node); state.closeBlock(node); }; exports.toMarkdown = toMarkdown; exports.toTex = (0, utils_1.createLatexStatement)((state, node) => { if (state.isInTable && node.attrs.kind !== types_1.CaptionKind.table) { return null; } const { nextCaptionNumbered: numbered, nextCaptionId: id } = state; return { command: numbered === false ? 'caption*' : 'caption', inline: true, after: numbered && id ? `\\label{${id}}` : '', }; }, (state, node) => state.renderInline(node)); exports.default = figcaption; //# sourceMappingURL=figcaption.js.map