text: "use strict";
  
  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  exports.default = TogglePlaceHolderAttributePlugin;
  
  // This plugin toggles data prop 'placeholder' on a contenBlock
  // The block is considered a placeholder if it is the single one
  // in the document and and empty. A unset patch for the field will be
  // sent by createOperationToPatches if the placeholder block is the
  // only thing left in the document
  function toggle(event, editor, next) {
    var isCommand = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
    var block = editor.value.document.nodes.first();
  
    if (isCommand) {
      if (event.type !== 'insertInlineObject') {
        return next();
      }
  
      var newData = block.data.toObject();
      delete newData.placeholder;
      editor.setNodeByKey(block.key, {
        data: newData
      });
      return next();
    }
  
    if (editor.value.document.nodes.size === 1) {
      if (block.type === 'contentBlock' && block.nodes.every(node => node.object === 'text') && block.text === '') {
        var _newData = block.data.toObject();
  
        _newData.placeholder = true;
        editor.setNodeByKey(block.key, {
          data: _newData
        });
      } else if (block.type === 'contentBlock' && block.data.get('placeholder')) {
        var _newData2 = block.data.toObject();
  
        delete _newData2.placeholder;
        editor.setNodeByKey(block.key, {
          data: _newData2
        });
      }
    }
  
    return next();
  }
  
  function TogglePlaceHolderAttributePlugin() {
    return {
      onKeyUp: toggle,
      onCommand: (command, editor, next) => toggle(command, editor, next, true)
    };
  }