import { Mark as l, mergeAttributes as a } from "../../../../../@tiptap_core@2.14.0_@tiptap_pm@2.14.0/node_modules/@tiptap/core/dist/index.js";
const u = (t) => {
  if (!t.children.length)
    return;
  const s = t.querySelectorAll("span");
  s && s.forEach((e) => {
    var n, r;
    const i = e.getAttribute("style"), o = (r = (n = e.parentElement) === null || n === void 0 ? void 0 : n.closest("span")) === null || r === void 0 ? void 0 : r.getAttribute("style");
    e.setAttribute("style", `${o};${i}`);
  });
}, p = l.create({
  name: "textStyle",
  priority: 101,
  addOptions() {
    return {
      HTMLAttributes: {},
      mergeNestedSpanStyles: !1
    };
  },
  parseHTML() {
    return [
      {
        tag: "span",
        getAttrs: (t) => t.hasAttribute("style") ? (this.options.mergeNestedSpanStyles && u(t), {}) : !1
      }
    ];
  },
  renderHTML({ HTMLAttributes: t }) {
    return ["span", a(this.options.HTMLAttributes, t), 0];
  },
  addCommands() {
    return {
      removeEmptyTextStyle: () => ({ tr: t }) => {
        const { selection: s } = t;
        return t.doc.nodesBetween(s.from, s.to, (e, n) => {
          if (e.isTextblock)
            return !0;
          e.marks.filter((r) => r.type === this.type).some((r) => Object.values(r.attrs).some((i) => !!i)) || t.removeMark(n, n + e.nodeSize, this.type);
        }), !0;
      }
    };
  }
});
export {
  p as TextStyle,
  p as default
};
//# sourceMappingURL=index.js.map
