<commit_before>define('scribe-plugin-image-inserter', [
  'eventsWithPromises',
  'rangy-core',
  'rangy-selectionsaverestore',
  'filter-event'
],
function (eventsWithPromises, rangy, rangySelectionSaveRestore, filterEvent) {
  'use strict';

  /**
   * This plugin adds a command for editing/creating links via LinkEditor/LinkInserter
   */
  return function (context) {
    return function (scribe) {
      var insertImageCommand = new scribe.api.Command('insertHTML');

      insertImageCommand.nodeName = 'IMG';

      insertImageCommand.execute = function () {
        return true;
      };

      insertImageCommand.queryState = function () {
        return false;
      };

      insertImageCommand.queryEnabled = function() {
        return true;
      };

      insertImageCommand.insert = function (url) {
        scribe.api.SimpleCommand.prototype.execute.call(this, '<img src="'+ url +'">');
      };

      insertImageCommand.handleInsertPublished = function(eventData) {
        if(!eventData.val) return;
        this.insert(eventData.val);
      };

      insertImageCommand.setupEvents = function() {
        eventsWithPromises.subscribe('insertmanager:insert-published',
          filterEvent(this.handleInsertPublished.bind(this), context)
        );
      };

      insertImageCommand.init = function() {
        this.setupEvents();
      };

      insertImageCommand.init();
<commit_msg>Enable toolbar buttons only within certain tags<commit_after>define('scribe-plugin-image-inserter', [
  'eventsWithPromises',
  'rangy-core',
  'rangy-selectionsaverestore',
  'filter-event'
],
function (eventsWithPromises, rangy, rangySelectionSaveRestore, filterEvent) {
  'use strict';

  /**
   * This plugin adds a command for editing/creating links via LinkEditor/LinkInserter
   */
  return function (context) {
    return function (scribe) {
      var insertImageCommand = new scribe.api.Command('insertHTML');

      insertImageCommand.nodeName = 'P';
      insertImageCommand.validNodes = ['P','LI','A'];

      insertImageCommand.execute = function () {
        return true;
      };

      insertImageCommand.queryState = function () {
        return false;
      };

      insertImageCommand.queryEnabled = function() {
        var selection = new scribe.api.Selection();
        return selection.getContaining(function (node) {
          return insertImageCommand.validNodes.indexOf(node.nodeName) !== -1;
        });
      };

      insertImageCommand.insert = function (url) {
        scribe.api.SimpleCommand.prototype.execute.call(this, '<img src="'+ url +'">');
      };

      insertImageCommand.handleInsertPublished = function(eventData) {
        if(!eventData.val) return;
        this.insert(eventData.val);
      };

      insertImageCommand.setupEvents = function() {
        eventsWithPromises.subscribe('insertmanager:insert-published',
          filterEvent(this.handleInsertPublished.bind(this), context)
        );
      };

      insertImageCommand.init = function() {
        this.setupEvents();
      };

      insertImageCommand.init();

{'fraction_non_alphanumeric': 0.12134977287475665, 'fraction_numerical': 0.0003244646333549643, 'mean_word_length': 3.003896103896104, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1924520', 'n_tokens_mistral': 869, 'n_tokens_neox': 833, 'n_words': 150}