UNPKG

@atlaskit/adf-schema

Version:

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

52 lines (50 loc) 1.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.subsup = void 0; var _markTypes = require("../../next-schema/generated/markTypes"); /** * @name subsup_mark */ function getAttrFromVerticalAlign(node) { if (node === 'sub') { return { type: 'sub' }; } if (node === 'super') { return { type: 'sup' }; } return false; } var subsup = exports.subsup = (0, _markTypes.subsup)({ 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 style: 'vertical-align=super', getAttrs: function getAttrs(node) { return getAttrFromVerticalAlign(node); } }, { style: 'vertical-align=sub', getAttrs: function getAttrs(node) { return getAttrFromVerticalAlign(node); } }], toDOM: function toDOM(mark) { return [mark.attrs.type]; } });