import { Node_Type } from "./../ricos-schema/legacy/wix/rich_content/v1/index.js";
import { TIPTAP_TYPE_TO_RICOS_TYPE } from "./../tiptap-editor/consts.js";
const textContainers = [
  Node_Type.PARAGRAPH,
  Node_Type.CODE_BLOCK,
  Node_Type.HEADING,
  Node_Type.CAPTION
];
const invokeAtomicBlockFocus = ({
  selectedNodes,
  onAtomicBlockFocus
}) => {
  const parentNodes = selectedNodes.length === 2 && selectedNodes[0].type.name.includes("FIGURE") ? [selectedNodes[1]] : selectedNodes.length === 1 ? selectedNodes : selectedNodes.filter((node) => textContainers.includes(node.type.name));
  if (parentNodes.length === 1 && parentNodes[0].isBlock) {
    const firstNode = parentNodes[0];
    const blockKey = firstNode.attrs.id;
    const type = TIPTAP_TYPE_TO_RICOS_TYPE[firstNode.type.name] || "text";
    const data = firstNode.attrs;
    onAtomicBlockFocus?.({ blockKey, type, data });
  } else {
    onAtomicBlockFocus?.({
      blockKey: void 0,
      type: void 0,
      data: void 0
    });
  }
};
export {
  invokeAtomicBlockFocus
};
//# sourceMappingURL=invoke-atomic-block-focus.js.map
