Sha256: 7832913fb199cb165ac713f1a30ea9c0ae9f18fc8f72ddfc10eb41f07f9c4727

Contents?: true

Size: 990 Bytes

Versions: 1

Compression:

Stored size: 990 Bytes

Contents

wysihtml.commands.insertHorizontalRule = (function() {
  return {
    exec: function(composer) {
      var node = composer.selection.getSelectedNode(),
          phrasingOnlyParent = wysihtml.dom.getParentElement(node, { query: wysihtml.PERMITTED_PHRASING_CONTENT_ONLY }, null, composer.editableArea),
          elem = document.createElement('hr'),
          range, idx;

      // HR is not allowed into some elements (where only phrasing content is allowed)
      // thus the HR insertion must break out of those https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories
      if (phrasingOnlyParent) {
        composer.selection.splitElementAtCaret(phrasingOnlyParent, elem);
      } else {
        composer.selection.insertNode(elem);
      }

      if (elem.nextSibling) {
        composer.selection.setBefore(elem.nextSibling);
      } else {
        composer.selection.setAfter(elem);
      }
    },
    state: function() {
      return false; // :(
    }
  };
})();

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wysihtml-rails-0.6.0.beta2 vendor/assets/javascripts/wysihtml/extra_commands/insertHorizontalRule.js