How to use the @lrnwebcomponents/utils/utils.js.stripMSWord function in @lrnwebcomponents/utils

To help you get started, we’ve selected a few @lrnwebcomponents/utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github elmsln / lrnwebcomponents / elements / hax-body / lib / hax-store.js View on Github external
var mswTest = pasteContent.replace(/(class=(")?Mso[a-zA-Z]+(")?)/g, "");
      let wordPaste = false;
      // the string to import as sanitized by hax
      let newContent = "";
      mswTest = mswTest.replace("mso-style-", "");
      if (pasteContent != mswTest) {
        wordPaste = true;
      }
      // clear empty span tags that can pop up
      pasteContent = pasteContent.replace(/<span>\s*?&lt;\/span&gt;/g, " ");
      // clean up div tags that can come in from contenteditable pastes
      // p tags make more sense in the content area
      pasteContent = pasteContent.replace(/<div>/g, "<p></p>");
      // NOW we can safely handle paste from word cases
      pasteContent = stripMSWord(pasteContent);
      // edges that some things preserve empty white space needlessly
      let haxElements = window.HaxStore.htmlToHaxElements(pasteContent);
      // if interpretation as HTML fails then let's ignore this whole thing
      // as we allow normal contenteditable to handle the paste
      // we only worry about HTML structures
      if (haxElements.length === 0) {
        // wrap in a paragraph tag if there is any this ensures it correctly imports
        // as it might not have evaluated above as having elements bc of the scrubber
        if (wordPaste) {
          newContent = pasteContent;
        } else {
          return false;
        }
      }
      // account for incredibly basic pastes of single groups of characters
      else if (haxElements.length === 1 &amp;&amp; haxElements[0].tag === "p") {</div></span>