import { TIPTAP_GIF_TYPE } from "./../../ricos-content/index.js";
import { findParentNodeClosestToPos } from "./../../tiptap/index.js";
import { createRicosNodeExtension } from "./../../plugin-commons/index.js";
import { Gif } from "./component.js";
const tiptapExtensions = [
  createRicosNodeExtension({
    name: TIPTAP_GIF_TYPE,
    groups: ["not-overtypable", "custom-styles"],
    type: "react-node",
    reconfigure: (config, _extensions, _props, settings) => ({
      ...config,
      addOptions: () => settings
    }),
    Component: Gif,
    createExtensionConfig() {
      return {
        name: this.name,
        group: "block figureFirstChildContent",
        selectable: true,
        draggable: true,
        addAttributes: () => ({
          containerData: null,
          height: null,
          width: null,
          original: null,
          downsized: null,
          gifType: null
        }),
        addCommands() {
          return {};
        },
        addKeyboardShortcuts() {
          const newLine = ({ editor }) => {
            const gifFigure = findParentNodeClosestToPos(
              editor.state.selection.$from,
              (node) => node.type.name === TIPTAP_GIF_TYPE
            );
            if (!gifFigure) {
              return false;
            }
            editor.chain().setTextSelection(gifFigure.start + gifFigure.node.nodeSize - 1).createParagraphNear().focus().run();
            return true;
          };
          const tiptapKeyboardShortcuts = {
            Enter: newLine
          };
          return tiptapKeyboardShortcuts;
        }
      };
    }
  })
];
export {
  tiptapExtensions
};
//# sourceMappingURL=tiptap.js.map
