<commit_before>'use strict'

/**
 * This module expose the plugin event handlers
 * @module
 * @name eventHandlers
 */

var uiUtils = require('./utils/ui')

module.exports = {
  'Init': {
    setBodies: setBodies,
    setStackedLayout: setStackedLayout,
    setPageLayout: setPageLayout,
    applyDefaultFormat: applyDefaultFormat
  },
  'NodeChange': {},
  'SetContent': {},
  'BeforeSetContent': {},
  'Focus': {
    enterHeadFoot: enterHeadFoot
  },
  'Blur': {
    leaveHeadFoot: leaveHeadFoot
  },
  'Focus Blur Paste SetContent NodeChange HeadersFooters:SetFormat': {
    applyCurrentFormat: applyCurrentFormat
  }
}

function setBodies (evt) {
  var editor = evt.target
  this.documentBodies.mce[this.type] = editor.getBody()
  if (!this.documentBodies.app) {
    this.documentBodies.app = window.document.body
  }
  this.documentBody = editor.getBody()
}

function setStackedLayout (evt) {
  uiUtils.mapMceLayoutElements(this.bodyClass, this.stackedLayout)
}

function setPageLayout (evt) {
  if (this.isMaster) {
    uiUtils.mapPageLayoutElements(this.pageLayout)
  }
}

function enterHeadFoot (evt) {
  this.enable()
}

function leaveHeadFoot (evt) {
  this.disable()
}

function applyCurrentFormat (evt) {
  var that = this
  if (this.currentFormat) {
    // console.info('evt', that.type, evt.type)
    if (evt.type === 'blur' || evt.type === 'focus') {
      setTimeout(function () {
        that.currentFormat.applyToPlugin(that)
      }, 200)
    } else {
      that.currentFormat.applyToPlugin(that)
    }
  }
}

function applyDefaultFormat (evt) {
  this.currentFormat = this.defaultFormat
  this.currentFormat.applyToPlugin(this)
}<commit_msg>unimplement applyDefaultFormat() event callback and unbind it from editor on init<commit_after>'use strict'

/**
 * This module expose the plugin event handlers
 * @module
 * @name eventHandlers
 */

var uiUtils = require('./utils/ui')

module.exports = {
  'Init': {
    setBodies: setBodies,
    setStackedLayout: setStackedLayout,
    setPageLayout: setPageLayout
  },
  'NodeChange': {},
  'SetContent': {},
  'BeforeSetContent': {},
  'Focus': {
    enterHeadFoot: enterHeadFoot
  },
  'Blur': {
    leaveHeadFoot: leaveHeadFoot
  },
  'Focus Blur Paste SetContent NodeChange HeadersFooters:SetFormat': {
    applyCurrentFormat: applyCurrentFormat
  }
}

function setBodies (evt) {
  var editor = evt.target
  this.documentBodies.mce[this.type] = editor.getBody()
  if (!this.documentBodies.app) {
    this.documentBodies.app = window.document.body
  }
  this.documentBody = editor.getBody()
}

function setStackedLayout (evt) {
  uiUtils.mapMceLayoutElements(this.bodyClass, this.stackedLayout)
}

function setPageLayout (evt) {
  if (this.isMaster) {
    uiUtils.mapPageLayoutElements(this.pageLayout)
  }
}

function enterHeadFoot (evt) {
  this.enable()
}

function leaveHeadFoot (evt) {
  this.disable()
}

function applyCurrentFormat (evt) {
  var that = this
  if (this.currentFormat) {
    // console.info('evt', that.type, evt.type)
    if (evt.type === 'blur' || evt.type === 'focus') {
      setTimeout(function () {
        that.currentFormat.applyToPlugin(that)
      }, 200)
    } else {
      that.currentFormat.applyToPlugin(that)
    }
  }
}
{'fraction_non_alphanumeric': 0.12996277915632753, 'fraction_numerical': 0.0018610421836228288, 'mean_word_length': 3.763663220088626, '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': '1165338', 'n_tokens_mistral': 1080, 'n_tokens_neox': 1082, 'n_words': 206}