import { Extension as p, isNodeEmpty as u } from "../../../../../@tiptap_core@2.14.0_@tiptap_pm@2.14.0/node_modules/@tiptap/core/dist/index.js";
import { Plugin as m, PluginKey as y } from "../../../../../prosemirror-state@1.4.3/node_modules/prosemirror-state/dist/index.js";
import { Decoration as f, DecorationSet as E } from "../../../../../prosemirror-view@1.40.0/node_modules/prosemirror-view/dist/index.js";
const P = p.create({
  name: "placeholder",
  addOptions() {
    return {
      emptyEditorClass: "is-editor-empty",
      emptyNodeClass: "is-empty",
      placeholder: "Write something …",
      showOnlyWhenEditable: !0,
      showOnlyCurrent: !0,
      includeChildren: !1
    };
  },
  addProseMirrorPlugins() {
    return [
      new m({
        key: new y("placeholder"),
        props: {
          decorations: ({ doc: o, selection: l }) => {
            const a = this.editor.isEditable || !this.options.showOnlyWhenEditable, { anchor: i } = l, s = [];
            if (!a)
              return null;
            const d = this.editor.isEmpty;
            return o.descendants((t, e) => {
              const n = i >= e && i <= e + t.nodeSize, c = !t.isLeaf && u(t);
              if ((n || !this.options.showOnlyCurrent) && c) {
                const r = [this.options.emptyNodeClass];
                d && r.push(this.options.emptyEditorClass);
                const h = f.node(e, e + t.nodeSize, {
                  class: r.join(" "),
                  "data-placeholder": typeof this.options.placeholder == "function" ? this.options.placeholder({
                    editor: this.editor,
                    node: t,
                    pos: e,
                    hasAnchor: n
                  }) : this.options.placeholder
                });
                s.push(h);
              }
              return this.options.includeChildren;
            }), E.create(o, s);
          }
        }
      })
    ];
  }
});
export {
  P as Placeholder,
  P as default
};
//# sourceMappingURL=index.js.map
