"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var editor_exports = {};
__export(editor_exports, {
  pluginCard: () => pluginCard
});
module.exports = __toCommonJS(editor_exports);
var import_wix_ui_icons_common = require("@wix/wix-ui-icons-common");
var import_ricos_content = require("./../ricos-content/index.js");
var import_v1 = require("./../ricos-schema/legacy/wix/rich_content/v1/index.js");
var import_ricos_types = require("./../ricos-types/index.js");
var import_card_content_extension = require("./card-content-extension.js");
var import_card_converter = require("./card-converter.js");
var import_card_footer_extension = require("./card-footer-extension.js");
var import_card_header_extension = require("./card-header-extension.js");
var import_extension = require("./extension.js");
const pluginCard = (config = {}) => {
  return {
    type: import_v1.Node_Type.CARD,
    config,
    pmMarkConverters: [],
    pmNodeConverters: [
      import_card_converter.cardConverter,
      import_card_converter.cardHeaderConverter,
      import_card_converter.cardContentConverter,
      import_card_converter.cardFooterConverter
    ],
    tiptapExtensions: [
      import_extension.cardExtension,
      import_card_header_extension.cardHeaderExtension,
      import_card_content_extension.cardContentExtension,
      import_card_footer_extension.cardFooterExtension
    ],
    textButtons: [],
    getQuickActions: ({ pluginServices }) => [
      {
        id: "pageBreak",
        title: "QuickActionsPlugin_ActionTitle_PageBreak",
        icon: pluginServices?.context.isMobile ? import_wix_ui_icons_common.LayoutSplit : import_wix_ui_icons_common.LayoutSplitSmall,
        section: import_ricos_types.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 === import_ricos_content.TIPTAP_CARD_HEADER_TYPE || name === import_ricos_content.TIPTAP_CARD_FOOTER_TYPE) {
              return false;
            }
          }
          return true;
        }
      }
    ]
  };
};
//# sourceMappingURL=editor.js.map
