fabianmichael / kirby-markdown-field

Super-sophisticated markdown editor for Kirby 3, community built.
Other
160 stars 14 forks source link

File upload broken #159

Closed nilshoerrmann closed 1 year ago

nilshoerrmann commented 1 year ago

When uploading an image via the Markdown field, I get the following error:

Bildschirmfoto am 2022-11-23 um 14 29 06

The upload endpoint returns a 404 error:

POST http://localhost:8888/api//pages/news+title/fields/preface/upload [HTTP/1.1 404 Not Found 0ms]

I see that the path is not correct, it should be http://localhost:8888/example.com/api/pages/news+title/fields/preface/upload – the path to my install is missing.

fabianmichael commented 1 year ago

@nilshoerrmann Does this issue still affect you/which Kirby version was/is affected?

nilshoerrmann commented 1 year ago

I'll be working again on that project next week and will check again, but I think it still affects us.

nilshoerrmann commented 1 year ago

This happened on Kirby 3.7.5 – I'll try the newest version next week to see if that fixes the issue.

nilshoerrmann commented 1 year ago

I finally found the time to check this issue again and, yes, this problem still exists. I'm not able to update this specific install to Kirby 3.9 yet so this is happening on Kirby 3.7.5 currently.

Two things to note:

  1. We are using the Markdown field within a module.
  2. We are uploading to the grandparent of the given page. This is the blueprint:
title: 'Feature: News'
fields:
  text:
    type: markdown
    label: Text
    size: small
    help: 'To insert image in text, use the paperclip. Remember to have a line space before and after, or it will not show up.'
    files: page.parent.parent.images
    uploads:
      parent: page.parent.parent
fabianmichael commented 1 year ago

@nilshoerrmann Thanks for the update. Unfortunately, I am currently not able to invest any time into this at least until March, so please be patient …

nilshoerrmann commented 1 year ago

No problem :)

nilshoerrmann commented 1 year ago

Comparing the core textarea upload implementation and the one from this field, it seems as if the uploadFile methods needs to be updated:

Textarea Field:

uploadFile() {
  this.$refs.fileUpload.open({
    url: this.$urls.api + "/" + this.endpoints.field + "/upload",
    multiple: false
  });
},

Markdown Field:

uploadFile() {
  this.$refs.fileUpload.open({
    url: "/api/" + this.endpoints.field + "/upload",
    multiple: false,
  });
},