npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@serpstat/pagebuilder

v2.1.61

Published

[Dev Documentation](https://xwiki.serpstat.com/bin/view/%D0%A2%D0%B5%D1%85%D0%BD%D0%B8%D1%87%D0%B5%D1%81%D0%BA%D0%B0%D1%8F%20%D0%B4%D0%BE%D0%BA%D1%83%D0%BC%D0%B5%D0%BD%D1%82%D0%B0%D1%86%D0%B8%D1%8F/%D0%9C%D0%BE%D0%B4%D1%83%D0%BB%D0%B8%20Serpstat/%D0%90%D0

Downloads

2,255

Readme

Page builder

Dev Documentation

User Documntation

Development

npm install npm run start

Open:

http://localhost:8085/

Add new component

  1. Create new forlder in src/components.
  2. Add index.js
export default function NewComponent(editor) {
}
  1. Add style file for component (optional). Naming by template NewComponent.style.scss.

  2. Add new component to file src/components/index.js

 ...
 require('./NewComponent').default(editor);
}

Usage Serpstat admin panel

For example see file backend/views/pagebuilder_script/pagebuilder_script.php in prodvigator repo.

<link href="https://unpkg.com/grapesjs/dist/css/grapes.min.css" rel="stylesheet">
<link href="https://unpkg.com/@serpstat/[email protected]/dist/css/pagebuilderStyles.css" rel="stylesheet">
<script src="https://unpkg.com/[email protected]/dist/grapes.min.js"></script>
<script src="https://unpkg.com/@serpstat/[email protected]/dist/dist/pagebuilder.min.js"></script>

<script>
{
  const openPageBuilderBtn = document.querySelectorAll('.open-in-page-builder');

  function setReadyHtmlCss({ destinationResultHtmlId, html, css }) {
    const el = document.getElementById(destinationResultHtmlId);

    el.value = [
      `<style>${css}</style>`,
      html.replace('<body>', '').replace('</body>', ''),
    ].join('');
  }

  const builderVisibility = {
    hide(pagebilderContainerId) {
      const editorWrapp = document.getElementById(pagebilderContainerId);

      editorWrapp.style.display = 'none';
      document.querySelector('html').style.fontSize = '10px';
    },
    show(pagebilderContainerId) {
      const editorWrapp = document.getElementById(pagebilderContainerId);
      editorWrapp.style.display = 'block';
      editorWrapp.style.width = '100%';
      editorWrapp.style.position = 'fixed';
      editorWrapp.style.zIndex = '10000';
      editorWrapp.style.left = 0;
      editorWrapp.style.top = 0;
      document.querySelector('html').style.fontSize = '16px';
    }
  };

  try {
    for (const btn of openPageBuilderBtn) {
      let gEditor = null;

      function runEditorOnClick({
        storageDocId,
        destinationResultHtmlId,
        pagebilderContainerId,
        storageTextareaSelector,
      }) {
        return runEditor({
          container: `#${pagebilderContainerId}`,
          storageDocId: `${window.location.hostname}_${storageDocId}`,
          dependenciesStyles: [
            'https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700&amp;subset=latin,cyrillic&amp;display=swap',
            'https://serpstat.com/css/base_global.css',
            'https://serpstat.com/css/dialog.css?518901310',
            'https://unpkg.com/@serpstat/[email protected]/dist/css/pagebuilder.css'
          ],
          saveAndCloseCallback() {
            const html = gEditor.getHtml({ cleanId: true });
            const css = gEditor.getCss();

            setReadyHtmlCss({
              destinationResultHtmlId, html, css
            });

            builderVisibility.hide(pagebilderContainerId);
          },
          assetManagerConfig: {
            upload: '/site/upload_image',
            uploadName: 'uploadfile',
            multiUpload: false,
            customFetch(url, fetchOpts) {
              return fetch(url, fetchOpts).then(res =>
                ((res.status / 200) | 0) == 1 ?
                  res.json().then(res => {
                    return {
                      data: [res.filelink],
                    }
                  }) :
                  res.text().then(text => Promise.reject(text)
                  )
              );
            }
          },
          storageManager: {
            type: 'textarea-storage',
            options: {
              ['textarea-storage']: {
                selector: storageTextareaSelector,
              }
            }
          }
        });
      }

      btn.addEventListener('click', function () {
        const {
          storageDocId,
          destinationResultHtmlId,
          pagebilderContainerId,
          storageTextareaSelector,
        } = this.dataset;

        if (!gEditor) {
          if (typeof runEditor === 'undefined') {
            const initContent = btn.innerText;
            btn.setAttribute('disable', true);
            btn.innerText = 'Loading builder...';

            const internal = setInterval(() => {
              if (
                typeof runEditor === 'undefined' ||
                typeof grapesjs === 'undefined'
              ) {
                return;
              };

              btn.setAttribute('disable', false);
              btn.innerText = initContent;
              gEditor = runEditorOnClick({
                storageDocId,
                destinationResultHtmlId,
                pagebilderContainerId,
                storageTextareaSelector,
              });
              builderVisibility.show(pagebilderContainerId);

              clearInterval(internal);
            }, 1000);

          } else {
            gEditor = runEditorOnClick({
              storageDocId,
              destinationResultHtmlId,
              pagebilderContainerId,
              storageTextareaSelector,
            });
            builderVisibility.show(pagebilderContainerId);
          }

          return;
        };

        builderVisibility.show(pagebilderContainerId);
      });
    }
  } catch (e) {
    console.error(e);
  }
}
</script>