import { Image as ImageIcon, ImageSmall } from "@wix/wix-ui-icons-common";
import { pluginFigure } from "./../plugin-figure/index.js";
import { IMAGE_TYPE, TIPTAP_FIGURE_TYPE, TIPTAP_IMAGE_TYPE } from "./../ricos-content/index.js";
import {
  Node_Type,
  RicosPluginToolbarNames,
  quickActionsModalSections
} from "./../ricos-types/index.js";
import { DEFAULTS } from "./consts.js";
import { ImagePluginContextProvider } from "./context.js";
import { imageConverter } from "./converter/image-converter.js";
import { getAddButtons } from "./get-add-buttons.js";
import { getToolbarButtons } from "./get-toolbar-buttons.js";
import { handleImageUpload } from "./handle-image-upload.js";
import { imageTiptapExtension } from "./tiptap/image-tiptap-extension.js";
const pluginImage = (config) => {
  const pluginConfig = {
    type: "image",
    ...DEFAULTS.config,
    ...config
  };
  return {
    config: pluginConfig,
    type: IMAGE_TYPE,
    pmMarkConverters: [],
    pmNodeConverters: [imageConverter],
    tiptapExtensions: [imageTiptapExtension],
    toolbar: {
      names: [RicosPluginToolbarNames.IMAGE],
      getButtons: (config2, services) => getToolbarButtons(config2, services),
      isVisible: (selection) => {
        if (!("node" in selection) || !selection.node) {
          return false;
        }
        if (selection.node.type.name === TIPTAP_IMAGE_TYPE) {
          return true;
        }
        return selection.node.type.name === TIPTAP_FIGURE_TYPE && selection.node.firstChild?.type.name === TIPTAP_IMAGE_TYPE;
      }
    },
    getAddButtons: (config2, services) => getAddButtons(config2, services),
    getQuickActions: ({ pluginServices, config: config2 }) => [
      {
        id: Node_Type.IMAGE,
        title: "QuickActionsPlugin_ActionTitle_Image",
        icon: pluginServices?.context.isMobile ? ImageIcon : ImageSmall,
        section: quickActionsModalSections.Media,
        tags: ["photo", "picture", "graphic", "visual", "illustration"],
        command: ({ publicCommands }) => {
          handleImageUpload({ services: pluginServices, config: config2, publicCommands });
        }
      }
    ],
    dependencies: [pluginFigure],
    Provider: ImagePluginContextProvider
  };
};
export {
  pluginImage
};
//# sourceMappingURL=editor.js.map

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