import { LayoutSplit, LayoutSplitSmall } from "@wix/wix-ui-icons-common";
import { TIPTAP_CARD_FOOTER_TYPE, TIPTAP_CARD_HEADER_TYPE } from "./../ricos-content/index.js";
import { Node_Type } from "./../ricos-schema/legacy/wix/rich_content/v1/index.js";
import { quickActionsModalSections } from "./../ricos-types/index.js";
import { cardContentExtension } from "./card-content-extension.js";
import {
  cardContentConverter,
  cardConverter,
  cardFooterConverter,
  cardHeaderConverter
} from "./card-converter.js";
import { cardFooterExtension } from "./card-footer-extension.js";
import { cardHeaderExtension } from "./card-header-extension.js";
import { cardExtension } from "./extension.js";
const pluginCard = (config = {}) => {
  return {
    type: Node_Type.CARD,
    config,
    pmMarkConverters: [],
    pmNodeConverters: [
      cardConverter,
      cardHeaderConverter,
      cardContentConverter,
      cardFooterConverter
    ],
    tiptapExtensions: [
      cardExtension,
      cardHeaderExtension,
      cardContentExtension,
      cardFooterExtension
    ],
    textButtons: [],
    getQuickActions: ({ pluginServices }) => [
      {
        id: "pageBreak",
        title: "QuickActionsPlugin_ActionTitle_PageBreak",
        icon: pluginServices?.context.isMobile ? LayoutSplit : LayoutSplitSmall,
        section: quickActionsModalSections.FormatLayout,
        tags: ["page break", "split", "page", "break", "card"],
        command: ({ editor }) => {
          editor.commands.splitCard();
        },
        // Hide the page-break action when the cursor is inside the card's
        // CARD_HEADER or CARD_FOOTER — splitting there is not meaningful.
        isVisible: (editor) => {
          const $from = editor.state.selection.$from;
          for (let depth = $from.depth; depth >= 0; depth--) {
            const name = $from.node(depth).type.name;
            if (name === TIPTAP_CARD_HEADER_TYPE || name === TIPTAP_CARD_FOOTER_TYPE) {
              return false;
            }
          }
          return true;
        }
      }
    ]
  };
};
export {
  pluginCard
};
//# sourceMappingURL=editor.js.map

import { injectCss } from "./viewer-styles-inject.js";
injectCss();
