How to use the @lrnwebcomponents/utils/utils.js.encapScript 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 / src / hax-body.js View on Github external
content = content.replace(re, "");
        string = "x-scope " + tags[i] + "-0";
        re = new RegExp(string, "g");
        content = content.replace(re, "");
      }
    }
    // remove empty class structures
    content = content.replace(/\sclass=\"\"/g, "");
    content = content.replace(/\sclass=\"\s\"/g, "");
    // re-apply contenteditable if needed
    this._applyContentEditable(this.editMode);
    // set active again
    window.HaxStore.write("activeNode", __active, this);
    window.HaxStore.write("activeContainerNode", __active, this);
    // oh one last thing. escape all script/style tags
    content = encapScript(content);
    if (this.globalPreferences.haxDeveloperMode) {
      console.warn(content);
    }
    return content;
  }
  /**
github elmsln / lrnwebcomponents / elements / haxcms-elements / lib / core / themes / haxcms-legacy-player.js View on Github external
_activeItemContentChanged(newValue, oldValue) {
    if (newValue) {
      var html = newValue;
      // only append if not empty
      if (html !== null) {
        wipeSlot(this, "*");
        html = encapScript(newValue);
        // insert the content as quickly as possible, then work on the dynamic imports
        microTask.run(() => {
          setTimeout(() => {
            let frag = document.createRange().createContextualFragment(html);
            this.appendChild(frag);
            const evt = new CustomEvent(
              "json-outline-schema-active-body-changed",
              {
                bubbles: true,
                composed: true,
                cancelable: false,
                detail: { html }
              }
            );
          }, 5);
        });
github elmsln / lrnwebcomponents / elements / hax-body / src / hax-body.js View on Github external
setTimeout(() => {
      html = encapScript(html);
      let fragment = document.createElement("div");
      fragment.insertAdjacentHTML("beforeend", html);
      while (fragment.firstChild !== null) {
        if (typeof fragment.firstChild.tagName !== typeof undefined) {
          // ensure import doesn't import non-sandbox safe things!
          if (
            window.HaxStore.instance._isSandboxed &&
            fragment.firstChild.tagName.toLowerCase() === "iframe"
          ) {
            // Create a replacement tag of the desired type
            var replacement = document.createElement("webview");
            // Grab all of the original's attributes, and pass them to the replacement
            for (
              var j = 0, l = fragment.firstChild.attributes.length;
              j < l;
              ++j
github elmsln / lrnwebcomponents / elements / haxcms-elements / lib / ui-components / active-item / site-render-item.js View on Github external
_itemContentChanged(newValue, oldValue) {
    if (newValue) {
      var html = newValue;
      // only append if not empty
      if (html !== null) {
        html = encapScript(newValue);
        wipeSlot(this, "*");
        // insert the content as quickly as possible, then work on the dynamic imports
        microTask.run(() => {
          setTimeout(() => {
            let frag = document.createRange().createContextualFragment(html);
            this.appendChild(frag);
          }, 5);
        });
        // if there are, dynamically import them
        if (varExists(this.manifest, "metadata.node.dynamicElementLoader")) {
          let tagsFound = findTagsInHTML(html);
          const basePath = this.pathFromUrl(
            decodeURIComponent(import.meta.url)
          );
          for (var i in tagsFound) {
            const tagName = tagsFound[i];
github elmsln / lrnwebcomponents / elements / haxcms-elements / lib / core / haxcms-site-builder.js View on Github external
_activeItemContentChanged(newValue, oldValue) {
    if (newValue) {
      var html = newValue;
      // only append if not empty
      if (html !== null) {
        wipeSlot(store.themeElement, "*");
        html = encapScript(newValue);
        // set in the store
        store.activeItemContent = html;
        // insert the content as quickly as possible, then work on the dynamic imports
        setTimeout(() => {
          if (store.themeElement.childNodes.length === 0) {
            let frag = document.createRange().createContextualFragment(html);
            store.themeElement.appendChild(frag);
            this.dispatchEvent(
              new CustomEvent("json-outline-schema-active-body-changed", {
                bubbles: true,
                composed: true,
                cancelable: false,
                detail: html
              })
            );
          }
github elmsln / lrnwebcomponents / elements / eco-json-schema-form / lib / eco-json-schema-markup.js View on Github external
_valueChanged(newValue) {
    // clear self
    wipeSlot(this);
    // sanity check to ditch scripts
    let html = encapScript(newValue);
    let frag = document.createRange().createContextualFragment(html);
    // self apend to flow into slot and show up
    this.appendChild(frag);
  }
}
github elmsln / lrnwebcomponents / elements / hax-body / lib / hax-store.js View on Github external
window.HaxStore.encapScript = html => {
  return encapScript(html);
};
/**