UNPKG

@atlaskit/adf-schema

Version:

Shared package that contains the ADF-schema (json) and ProseMirror node/mark specs

60 lines (58 loc) 1.18 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.subsup = void 0; var _groups = require("../groups"); /** * @name subsup_mark */ function getAttrFromVerticalAlign(node) { if (node.style.verticalAlign) { var type = node.style.verticalAlign.slice(0, 3); if (type === 'sub' || type === 'sup') { return { type: type }; } } return false; } var subsup = { inclusive: true, group: _groups.FONT_STYLE, attrs: { type: { default: 'sub' } }, parseDOM: [{ tag: 'sub', attrs: { type: 'sub' } }, { tag: 'sup', attrs: { type: 'sup' } }, { // Special case for pasting from Google Docs // Google Docs uses vertical align to denote subscript and super script tag: 'span', style: 'vertical-align=super', getAttrs: function getAttrs(node) { return getAttrFromVerticalAlign(node); } }, { tag: 'span', style: 'vertical-align=sub', getAttrs: function getAttrs(node) { return getAttrFromVerticalAlign(node); } }], toDOM: function toDOM(mark) { return [mark.attrs.type]; } }; exports.subsup = subsup;