Issue #3565Opened June 24, 2021by Ubanna0 reactions

undefined for multiple page manager in React

Question

Hi, please what is the best way to implement multiple page manager in a react app.

I have successfully implemented this without page manager like so:

  useEffect(() => {
    const editor = grapesjs.init({
      container: "#editor",
      storageManager: {
        type: "remote",
        stepsBeforeSave: 2,
        contentTypeJson: true,
        storeComponents: true,
        storeStyles: true,
        storeHtml: true,
        storeCss: true,
        // id: "my-",
        urlStore: `some-url`,
        urlLoad: `some-url`,
        headers: {
          "Content-Type": "application/json",
        },
        credentials: 'omit',
      },
      panels: { defaults: [] },
      plugins: [gjsPresetWebpage],
      pluginsOpts: {
        gjsPresetWebpage: {},
      },
    });
    editor.Panels.getButton('options', 'sw-visibility').set('active', true);
    setEditor(editor);
  }, []);


  return (
    <Wrapper bgColor={bgColor} hoverColor={hoverColor}>
      <div id="editor"></div>
    </Wrapper>
  );

For the page manager implementation I try this:

  useEffect(() => {
    const editor = grapesjs.init({
      container: "#editor",
      storageManager: {
        type: "remote",
        stepsBeforeSave: 2,
        contentTypeJson: true,
        storeComponents: true,
        storeStyles: true,
        storeHtml: true,
        storeCss: true,
        // id: "my-",
        urlStore: `some-url`,
        urlLoad: `some-url`,
        headers: {
          "Content-Type": "application/json",
        },
        credentials: 'omit',
      },
    pageManager: true, // here
      panels: { defaults: [] },
      plugins: [gjsPresetWebpage],
      pluginsOpts: {
        gjsPresetWebpage: {},
      },
    });
    editor.Panels.getButton('options', 'sw-visibility').set('active', true);
  const pageManager = editor.Pages;  // here
  pageManager.getAll() // here
console.log(pageManager) // undefined
    setEditor(editor);
  }, []);

Here, I get undefined for page manager. I would appreciate any help please.

Thanks

Answers (1)

artfJune 25, 20210 reactions

I think you're just using an old version of GrapesJS

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.