Issue #347○ OpenOpened September 28, 2017by cmcintosh0 reactions

Storing to Drupal

待解决问题

No community answers yet. Open the original discussion on GitHub to share your solution.

Question

This is inside of a Plugin, I can confirm after init. That the editor is using the defined storage that I defined. Additionally, I can trigger editor.load() and editor.store() and see ajax calls go out if i crate them in the respective options. However, if I do not have load or store defined then I see no traffic in the network console.

` var storageManager = editor.StorageManager; var drupalStorage = storageManager.add('drupal', { type: 'remote', urlStore: '/js/grapesjs/save',

代码片段TEXT
urlLoad: '/js/grapesjs/load',
      autosave: true,
      params: {
        entity_type: drupalSettings.wembassy.siteBuilder.entity_type,
        'bundle': drupalSettings.wembassy.siteBuilder.bundle,
        'template': $('#gjs-pn-templates-a select').val(),
        'default': 1,
        'status': 1
      },
      load: function(keys) {
        console.log('Loading', keys);
        var res = {};
        for (var i = 0, len = keys.length; i < len; i++){
          var v = drupalSettings.wembassy.siteBuilder.template_data[keys[i]];
          if(v) res[keys[i]] = v;
        }
        return res;
      },
      store: function(data){
        var templateData = {
          'entity_type': drupalSettings.wembassy.siteBuilder.entity_type,
          'bundle': drupalSettings.wembassy.siteBuilder.bundle,
          'template': $('#gjs-pn-templates-a select').val(),
          'data': data,
          'default': 1,
          'status': 1,
        };
        $.ajax({
          type: "POST",
          url: "/js/grapesjs/save",
          data: templateData,
          async: false,
          success: function(e) {
            console.log("Saved data", e);
            return true;
          },
          dataType: "json"
        });
      }});

    storageManager.setCurrent('drupal');
`

Answers (0)

No answers yet.

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...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.

Browse premium plugins →

Related tutorials

In-depth guides on the same topic.

All tutorials →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.