"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var extension_exports = {};
__export(extension_exports, {
  bulletedList: () => bulletedList
});
module.exports = __toCommonJS(extension_exports);
var import_v1 = require("./../../ricos-schema/legacy/wix/rich_content/v1/index.js");
var import_tiptap = require("./../../tiptap/index.js");
var import_core = require("./../../tiptap/core/index.js");
var import_plugin_commons = require("./../../plugin-commons/index.js");
var import_list_input_rule_handler = require("../list-input-rule-handler.js");
var import_styles_scss = __toESM(require("../statics/styles-scss.js"));
const inputRegex = /^\s*([-+*])\s$/;
const bulletedList = (0, import_plugin_commons.createRicosNodeExtension)({
  groups: ["no-trailing-node"],
  type: "html-node",
  name: import_v1.Node_Type.BULLETED_LIST,
  createExtensionConfig({ mergeAttributes }) {
    return {
      name: this.name,
      addOptions() {
        return {
          HTMLAttributes: { class: import_styles_scss.default.bulletedList },
          itemTypeName: import_v1.Node_Type.LIST_ITEM
        };
      },
      group: "block list listItemSecondChildContent smartBlockCellContent layoutCellContent collapsibleListItemTitleContent collapsibleListItemBodyContent tableCellContent",
      // group 'list' needed for tiptap's `isList` method to work.
      content() {
        return "LIST_ITEM+";
      },
      parseHTML() {
        return [{ tag: "ul" }];
      },
      addAttributes() {
        return {
          indentation: {
            default: 0
          },
          offset: {
            default: 0
          }
        };
      },
      renderHTML({ HTMLAttributes }) {
        return (0, import_plugin_commons.withBreakoutContainer)([
          "ul",
          mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
          0
        ]);
      },
      addCommands() {
        return {
          toggleBulletList: () => ({ commands }) => {
            return commands.toggleLists(this.name, import_v1.Node_Type.LIST_ITEM);
          },
          toggleOffBulletList: () => ({ state, commands }) => {
            const isActive = (0, import_tiptap.isNodeActive)(state, (0, import_tiptap.getNodeType)(this.name, state.schema));
            if (isActive) {
              return commands.toggleBulletList();
            }
            return true;
          }
        };
      },
      addKeyboardShortcuts() {
        return {
          "Mod-Shift-8": () => this.editor.commands.toggleBulletList()
        };
      },
      addInputRules() {
        return [
          new import_core.InputRule({
            find: inputRegex,
            handler: (0, import_list_input_rule_handler.createListInputRuleHandler)({ type: this.type })
          })
        ];
      }
    };
  }
});
//# sourceMappingURL=extension.js.map
