export default function excessiveCare(cm, change) {
  if (change.origin === '+input' || change.origin === '*compose'
  /*||
  change.origin === "paste"*/
  ) {
      var matchFlag = false;
      var replaced = [];
      change.text.forEach(function (input) {
        if (input.match(/[！-～|”|’|、|。]/g)) {
          var han = input.replace(/[！-～]/g, function (s) {
            return String.fromCharCode(s.charCodeAt(0) - 0xfee0);
          }).replace(/”/g, '"').replace(/’/g, "'").replace(/、/g, ',').replace(/。/g, '.');
          replaced.push(han);
          matchFlag = true;
        } else {
          replaced.push(input);
        }
      });

      if (matchFlag) {
        change.update(change.from, change.to, replaced, '');
      }
    }

  if (change.origin === '+delete') {
    // 特殊記号を消す前に警告を表示する
    var removed = cm.doc.getRange(change.from, change.to);

    if (/[=;.(){}*+-/'"]/.test(removed)) {
      var message = "".concat(removed, " \u306F \u3068\u304F\u3079\u3064\u306A \u3044\u307F\u3092\u3082\u3064 \u304D\u3054\u3046\u3067\u3059\u3002\u307B\u3093\u3068\u3046\u306B \u3051\u3057\u3066\u3044\u3044\u3067\u3059\u304B\uFF1F");

      if (!confirm(message)) {
        change.cancel();
      }
    }
  }
}