import { Node } from 'prosemirror-model';
import { toClosestFontPtSize } from './toClosestFontPtSize.js';
var FontSizeMarkSpec = {
  attrs: {
    pt: {
      "default": null
    },
    overridden: {
      "default": false
    }
  },
  inline: true,
  group: 'inline',
  parseDOM: [{
    tag: 'span[style*=font-size]',
    getAttrs: function getAttrs(domNode) {
      var _domNode$parentNode, _domNode$parentNode2;
      var fontSize = domNode.style.fontSize || '';
      var _mOverriden = domNode.getAttribute('overridden');
      var ptValue = 0;
      var _mptValue = 0;
      var parentFontsize = ((_domNode$parentNode = domNode.parentNode) === null || _domNode$parentNode === void 0 ? void 0 : _domNode$parentNode.style.fontSize) || '';
      var mparent_overriden = (_domNode$parentNode2 = domNode.parentNode) === null || _domNode$parentNode2 === void 0 ? void 0 : _domNode$parentNode2.getAttribute('overridden');
      if (fontSize !== '') {
        ptValue = toClosestFontPtSize(fontSize);
      }
      if (parentFontsize !== '') {
        _mptValue = toClosestFontPtSize(parentFontsize);
      }
      var overridden = _mOverriden === 'true' && fontSize !== '' || parentFontsize !== '' && mparent_overriden === 'true'; // Check if the font is overridden

      return {
        pt: ptValue || _mptValue,
        overridden: overridden
      };
    }
  }],
  toDOM: function toDOM(node) {
    var _node$attrs = node.attrs,
      pt = _node$attrs.pt,
      overridden = _node$attrs.overridden;
    var attrs = {
      overridden: overridden
    };
    if (pt) {
      attrs.style = "font-size: ".concat(pt, "pt;");
      attrs["class"] = 'czi-font-size-mark';
    }
    return ['span', attrs, 0];
  }
};
export default FontSizeMarkSpec;
import { bpfrpt_proptype_MarkSpec } from "./Types.js";