редактор js плагин изображения возвращаемый URL-адрес изображения не подобран - PullRequest
2 голосов
/ 03 февраля 2020

Я настроил редактор js в моем приложении. Я установил имиджевый плагин , чтобы я мог загрузить изображение на сервер. Теперь мой сервер загружает изображение и возвращает json в указанном формате, т. Е.

{
    "success" : 1,
    "file": {
        "url" : "https://www.tesla.com/tesla_theme/assets/img/_vehicle_redesign/roadster_and_semi/roadster/hero.jpg",
        // ... and any additional fields you want to store, such as width, height, color, extension, etc
    }
}

В ответе есть файл-> url, но сообщение об ошибке при загрузке все равно

Image of Error

Вот мой код конфигурации:

const editor = new EditorJS({
  /**
   * Id of Element that should contain Editor instance
   */
  holder: 'heditor', 

  /** 
   * Available Tools list. 
   * Pass Tool's class or Settings object for each Tool you want to use 
   */ 
      tools: { 
        header: {
          class: Header, 
          inlineToolbar: ['link'],
          config: {
            placeholder: 'Title...'
          }
        }, 
        paragraph: {
          class: Paragraph,
          inlineToolbar: true,
        },
        image: {
          class: ImageTool,
          config: {
            endpoints: {
              accept: 'image/*',
              byFile: $('#heditor').data('url'), // Your backend file uploader endpoint
              byUrl: $('#heditor').data('url'), // Your endpoint that provides uploading by Url
            },
            additionalRequestHeaders : {
              'x-auth-token': $('#heditor').data('token'), 
            } 
          }
        },
        linkTool: {
          class: LinkTool,
          config: {
            endpoint: 'http://localhost:8008/fetchUrl', // Your backend endpoint for url data fetching
          }
        },
        inlineCode: {
          class: InlineCode,
          shortcut: 'CMD+SHIFT+M',
        },
        Marker: {
          class: Marker,
          shortcut: 'CMD+SHIFT+M',
        },
        embed: Embed,

        list: { 
          class: List, 
          inlineToolbar: true 
        } 
      }, 

      /**
       * This Tool will be used as default
       */
      // initialBlock: 'paragraph',

      /**
       * Initial Editor data
       */
      data: {
        blocks: [
          {
            type: "header",
            data: {
              text: "Title of your story",
              level: 2
            }
          },
          {
            type : 'paragraph',
            data : {
              text : 'Hey. Meet the new Story Editor. On this page you can start writing your story — try to edit this text...'
            }
          }  
        ]
      },
      onReady: function(){
        saveButton.click();
      },
      onChange: function() {
        console.log('something changed');
      }
});

/**
     * Saving example
     */
    saveButton.addEventListener('click', function () {
      editor.save().then((savedData) => {
         $("#output").html(savedData);
      });
    });

Что я делаю не так, может кто-нибудь помочь?

...