import {
  HeadingOne,
  HeadingOneSmall,
  HeadingThree,
  HeadingThreeSmall,
  HeadingTwo,
  HeadingTwoSmall
} from "@wix/wix-ui-icons-common";
import { HEADER_BLOCK } from "./../ricos-content/index.js";
import { Node_Type, createShortcut, quickActionsModalSections } from "./../ricos-types/index.js";
import { DEFAULTS } from "./defaults.js";
import { getTextButtons } from "./get-text-buttons.js";
import { HEADINGS_DROPDOWN_TYPE } from "./types.js";
const headerBlockByLevel = [
  HEADER_BLOCK.ONE,
  HEADER_BLOCK.TWO,
  HEADER_BLOCK.THREE,
  HEADER_BLOCK.FOUR,
  HEADER_BLOCK.FIVE,
  HEADER_BLOCK.SIX
];
const headingTypeToLevel = {
  H1: 1,
  H2: 2,
  H3: 3,
  H4: 4,
  H5: 5,
  H6: 6,
  P: null
};
const getShortcut = (level) => createShortcut({
  name: `${Node_Type.HEADING}.${level}`,
  description: `ShortcutsSheet_Formatting_Heading${level}`,
  keys: { macOs: `Meta+Alt+${level}`, windows: `Ctrl+Alt+${level}` },
  command({ publicCommands }) {
    publicCommands.setBlockType(headerBlockByLevel[level - 1]);
    return "continue";
  },
  group: "ShortcutsSheet_Section_Formatting",
  enabled: true,
  showInShortcutSheet: true
});
const getShortcuts = (customHeadings) => {
  const levels = customHeadings?.length ? customHeadings.map((heading) => headingTypeToLevel[heading]).filter((level) => level !== null) : [1, 2, 3, 4, 5, 6];
  return levels.map(getShortcut);
};
const pluginHeadings = (config) => {
  return {
    config: { type: "heading", ...DEFAULTS.config, ...config },
    type: HEADINGS_DROPDOWN_TYPE,
    tiptapExtensions: [],
    shortcuts: getShortcuts(config?.customHeadings),
    textButtons: getTextButtons(config),
    getQuickActions: ({ config: config2, pluginServices }) => {
      const isMobile = pluginServices?.context.isMobile;
      return [
        ...config2?.customHeadings?.includes("H1") ? [
          {
            id: "headingOne",
            title: "QuickActionsPlugin_ActionTitle_HeadingOne",
            icon: isMobile ? HeadingOne : HeadingOneSmall,
            section: quickActionsModalSections.FormatLayout,
            tags: [
              "title",
              "header",
              "section title",
              "main heading",
              "h1",
              "top level heading",
              "large text"
            ],
            command: ({ publicCommands }) => publicCommands.setBlockType(HEADER_BLOCK.ONE)
          }
        ] : [],
        ...config2?.customHeadings?.includes("H2") ? [
          {
            id: "headingTwo",
            title: "QuickActionsPlugin_ActionTitle_HeadingTwo",
            icon: isMobile ? HeadingTwo : HeadingTwoSmall,
            section: quickActionsModalSections.FormatLayout,
            tags: ["subheading", "h2", "medium heading", "section heading"],
            command: ({ publicCommands }) => publicCommands.setBlockType(HEADER_BLOCK.TWO)
          }
        ] : [],
        ...config2?.customHeadings?.includes("H3") ? [
          {
            id: "headingThree",
            title: "QuickActionsPlugin_ActionTitle_HeadingThree",
            icon: isMobile ? HeadingThree : HeadingThreeSmall,
            section: quickActionsModalSections.FormatLayout,
            tags: [
              "h3",
              "small heading",
              "section subheading",
              "sub-subheading",
              "subsection heading"
            ],
            command: ({ publicCommands }) => publicCommands.setBlockType(HEADER_BLOCK.THREE)
          }
        ] : []
      ];
    }
  };
};
export {
  pluginHeadings
};
//# sourceMappingURL=editor.js.map
