Custom Area

<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
    <style>
      body {
        margin: .5em;
        overflow: hidden;
        padding: 0;
      }
      .wrap {
        margin: 0 0 7.5em;
      }
      custom-area {
        display: block;
        font-family: 'Courier New', Courier, monospace;
        font-size: 16px;
        height: auto;
        margin: 2em 1em;
      }
    </style>
    <script nomodule type="text/javascript">
      alert("Do not use IE, the evil browser.");
    </script>
    <script type="module">
      import * as _ from "../custom-area/1";
 
      var ca = document.querySelectorAll('custom-area');
 
      ca[0].highlight(function(t) {
        var r = [{
            regex: '(scp foundation)',
            flag: 'i',
            resolve: '<span style="color:purple">$1</span>'
          },{
            regex: '(scp)',
            flag: 'i',
            resolve: '<span style="color:#b01">$1</span>'
          }
        ];
        return (function _f(_,i) {
          var p = r[i];
          var reg = new RegExp(p.regex, (p.flag||'').replace(/g/g,''));
          var res = p.resolve;
          i++;
          return _.split(reg).map(function(v) {
            if(v.match(reg)) {
              return v.replace(reg,res);
            }
            else if(i < r.length) {
              return _f(v,i);
            }else {
              return v;
            }
          })
        })(t,0).flat(Infinity).join('');
      });
 
      ca[1].highlight(function(t){
          var c = document.createElement('code');
          c.textContent = t;
          hljs.highlightBlock(c);
          return c.innerHTML;
      }, ':host > div{color:#abb2bf;background:#223747}:host textarea{caret-color:#abb2bf}.hljs-comment,.hljs-quote{color:#5c6370;font-style:italic}.hljs-doctag,.hljs-keyword,.hljs-formula{color:#c678dd}.hljs-section,.hljs-name,.hljs-selector-tag,.hljs-deletion,.hljs-subst{color:#e06c75}.hljs-literal{color:#56b6c2}.hljs-string,.hljs-regexp,.hljs-addition,.hljs-attribute,.hljs-meta-string{color:#98c379}.hljs-built_in,.hljs-class .hljs-title{color:#e6c07b}.hljs-attr,.hljs-variable,.hljs-template-variable,.hljs-type,.hljs-selector-class,.hljs-selector-attr,.hljs-selector-pseudo,.hljs-number{color:#d19a66}.hljs-symbol,.hljs-bullet,.hljs-link,.hljs-meta,.hljs-selector-id,.hljs-title{color:#61aeee}.hljs-emphasis{font-style:italic}.hljs-link{text-decoration:underline}');
 
      if(window !== window.parent) {//based on C-take's resizing iframe method
        var site = `http://${document.referrer.split("http://")[1].split("/")[0]}/`;
        var _wrap = document.createElement("div");
        document.body.appendChild(_wrap);
        var _old= 0;
        var url = location.href.replace(/^.*\//,'/');
 
        (function _f() {
          var _new = _wrap.getBoundingClientRect().top;
          if(_new !== _old){
            var iframe = document.createElement("iframe");
            var _rand = String(Math.floor(Math.random() * 10000));
            _wrap.innerHTML = '';
            iframe.src = `${site}common--javascript/resize-iframe.html?${_rand}#${_new}${url}`;
            iframe.style.display = "none";
            _wrap.appendChild(iframe);
            _old = _new;
          }
          setTimeout(_f, 250);
        })();
      }
    </script>
  </head>
  <body>
    <div class="wrap">
      <p>/(scp foundation)/i, /(scp)/i</p>
      <custom-area
        ca-spellcheck="false"
        ca-value="scp Scp SCP scp Scp SCP scp Scp SCP spc Scp SCP Foundation"
        ca-placeholder="text"
      ></custom-area>
 
      <p>syntax highlight</p>
      <custom-area
        ca-spellcheck="false"
        ca-placeholder="text"
      >@media (max-width: 767px) {
  pre.test1,
  div[src*="test"] pre {
    color: red;
  }
}
@keyframes anim {
  0%,
  99% {
    color: red;
  }
  100% {
    color: blue;
  }
}</custom-area>
    </div>
  </body>
</html>
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License