import { Node } from 'prosemirror-model';
import { isTransparent, toCSSColor } from './ui/toCSSColor.js';
var TextHighlightMarkSpec = {
  attrs: {
    highlightColor: {
      "default": null
    },
    // Allow missing color
    overridden: {
      "default": false
    }
  },
  inline: true,
  group: 'inline',
  parseDOM: [{
    tag: 'span[style*=background-color]',
    priority: 100,
    getAttrs: function getAttrs(dom) {
      var backgroundColor = dom.style.backgroundColor;
      var color = toCSSColor(backgroundColor);
      var overridden = dom.getAttribute('overridden') === 'true'; // Extract overridden flag

      return {
        highlightColor: isTransparent(color) ? '' : color,
        overridden: overridden // Ensure overridden is captured
      };
    }
  }],
  toDOM: function toDOM(node) {
    var _node$attrs = node.attrs,
      highlightColor = _node$attrs.highlightColor,
      overridden = _node$attrs.overridden;
    var attrs = {};
    if (highlightColor) {
      attrs.style = "background-color: ".concat(highlightColor, ";");
    }

    // Store overridden flag properly as a data attribute
    attrs['overridden'] = overridden === null || overridden === void 0 ? void 0 : overridden.toString();
    return ['span', attrs, 0];
  }
};
export default TextHighlightMarkSpec;
import { bpfrpt_proptype_MarkSpec } from "./Types.js";