<commit_before>define(
  'ephox.alloy.spec.ButtonSpec',

  [
    'ephox.alloy.api.SystemEvents',
    'ephox.alloy.construct.EventHandler',
    'ephox.alloy.spec.SpecSchema',
    'ephox.boulder.api.FieldSchema',
    'ephox.boulder.api.Objects',
    'ephox.compass.Arr',
    'ephox.highway.Merger',
    'ephox.peanut.Fun'
  ],

  function (SystemEvents, EventHandler, SpecSchema, FieldSchema, Objects, Arr, Merger, Fun) {
    var schema = [
      FieldSchema.option('action'),
      FieldSchema.option('role')
    ];


    var make = function (spec) {
      var detail = SpecSchema.asRawOrDie('button', schema, spec, [ ]);

      var executeHandler = EventHandler.nu({
        run: function (component, simulatedEvent) {
          detail.action.each(function (action) {
            action(component);
            simulatedEvent.stop();
          });
        }
      });

      var clickHandler = EventHandler.nu({
        run: function (component, simulatedEvent) {
          var system = component.getSystem();
          simulatedEvent.stop();
          system.triggerEvent(SystemEvents.execute(), component.element(), {
            button: Fun.constant(component)
          });
        }
      });

      var events = Objects.wrapAll(
        Arr.flatten([
          detail.action.isSome() ? [ { key: SystemEvents.execute(), value: executeHandler } ] : [ ],
          [ { key: 'click', value: clickHandler } ]
        ])
      );

      return Merger.deepMerge(
        {
          events: events
        },

        {
          // tabstopping: true,
          focusing: true,<commit_msg>VAN-44-wheel-hackery-apis: button cutting mousedown events<commit_after>define(
  'ephox.alloy.spec.ButtonSpec',

  [
    'ephox.alloy.api.SystemEvents',
    'ephox.alloy.construct.EventHandler',
    'ephox.alloy.spec.SpecSchema',
    'ephox.boulder.api.FieldSchema',
    'ephox.boulder.api.Objects',
    'ephox.compass.Arr',
    'ephox.highway.Merger',
    'ephox.peanut.Fun'
  ],

  function (SystemEvents, EventHandler, SpecSchema, FieldSchema, Objects, Arr, Merger, Fun) {
    var schema = [
      FieldSchema.option('action'),
      FieldSchema.option('role')
    ];


    var make = function (spec) {
      var detail = SpecSchema.asRawOrDie('button', schema, spec, [ ]);

      var executeHandler = EventHandler.nu({
        run: function (component, simulatedEvent) {
          detail.action.each(function (action) {
            action(component);
            simulatedEvent.stop();
          });
        }
      });

      var clickHandler = EventHandler.nu({
        run: function (component, simulatedEvent) {
          var system = component.getSystem();
          simulatedEvent.stop();
          system.triggerEvent(SystemEvents.execute(), component.element(), {
            button: Fun.constant(component)
          });
        }
      });

      // Other mouse down listeners above this one should not get mousedown behaviour (like dragging)
      var mousedownHandler = EventHandler.nu({
        run: function (component, simulatedEvent) {
          simulatedEvent.cut();
        }
      });

      var events = Objects.wrapAll(
        Arr.flatten([
          detail.action.isSome() ? [ { key: SystemEvents.execute(), value: executeHandler } ] : [ ],
          [ { key: 'click', value: clickHandler } ],
          [ { key: 'mousedown', value: mousedownHandler } ]
        ])
      );

      return Merger.deepMerge(
        {
          events: events
        },

        {
          // tabstopping: true,
          focusing: true,
{'fraction_non_alphanumeric': 0.1334841628959276, 'fraction_numerical': 0.0005656108597285068, 'mean_word_length': 2.17219730941704, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4928142', 'n_tokens_mistral': 1051, 'n_tokens_neox': 1033, 'n_words': 187}