import { isRicosMarkExtension } from "./../../ricos-types/index.js";
import {
  isMarkActive,
  Mark,
  markInputRule,
  markPasteRule,
  mergeAttributes,
  textblockTypeInputRule
} from "./../../tiptap/core/index.js";
import { Plugin, PluginKey } from "./../../tiptap/pm/state.js";
import { DEFAULT_PRIORITY } from "./constants.js";
class MarkExtension {
  constructor(extension, config) {
    this.type = "mark";
    if (!isRicosMarkExtension(extension)) {
      throw new TypeError("invalid argument");
    }
    this.groups = extension.groups || [];
    this.settings = extension.settings || {};
    const { addKeyboardShortcuts, ...rest } = config || extension.createExtensionConfig({
      isMarkActive,
      textblockTypeInputRule,
      mergeAttributes,
      markInputRule,
      markPasteRule,
      Plugin,
      PluginKey
    });
    this.config = {
      ...rest,
      ...extension.groups.includes("shortcuts-enabled") ? { addKeyboardShortcuts } : {},
      type: "mark"
    };
    this.priority = this.config.priority || DEFAULT_PRIORITY;
    this.name = this.config.name;
    this.ricosExtension = extension;
    this.reconfigure = extension.reconfigure || (() => this.config);
  }
  getRicosExtension() {
    return this.ricosExtension;
  }
  toTiptapExtension(extensions, ricosProps, services) {
    const config = this.reconfigure(this.config, extensions, ricosProps, this.settings, services);
    return Mark.create(config);
  }
}
export {
  MarkExtension
};
//# sourceMappingURL=mark-extension.js.map
