import { useCallback as s } from "react";
import { TextSelection as f } from "@tiptap/pm/state";
function p(t) {
  const o = s(
    (n) => {
      if (!t) return;
      const { src: e, alignment: l, width: a, height: u } = n;
      if (!e.trim())
        return;
      t.chain().focus().insertContent({
        type: "video",
        attrs: {
          src: e,
          alignment: l ?? "left",
          width: a ?? null,
          height: u ?? null
        }
      }).run();
      const { $to: r } = t.state.selection, m = t.state.doc.resolve(Math.min(r.pos, t.state.doc.content.size));
      t.commands.setTextSelection(f.near(m).from);
    },
    [t]
  ), c = s(
    (n) => {
      if (!t) return;
      const { alignment: e } = n;
      t.chain().focus().updateAttributes("video", { alignment: e }).run();
    },
    [t]
  ), i = s(() => {
    t && t.chain().focus().deleteNode("video").run();
  }, [t]);
  return { handleInsertVideo: o, handleUpdateVideoAlignment: c, handleDeleteVideo: i };
}
export {
  p as default
};
//# sourceMappingURL=useHtmlEditorVideoAction.js.map
