benjypng / logseq-mermaid-plugin

Create mermaid diagrams in image format on-the-fly.
MIT License
92 stars 8 forks source link

Problem with render #3

Closed bepolymathe closed 2 years ago

bepolymathe commented 2 years ago

Hi,

I have just try with this but it don’t works :thinking:

```mermaid
pie title Pets adopted by volunteers
    "Dogs" : 386
    "Cats" : 85
    "Rats" : 15
Zachu commented 2 years ago

Weird. For me it renders correctly, although it's quite small.

- <img src="https://mermaid.ink/img/ICBwaWUgdGl0bGUgUGV0cyBhZG9wdGVkIGJ5IHZvbHVudGVlcnMKICAgICJEb2dzIiA6IDM4NgogICAgIkNhdHMiIDogODUKICAgICJSYXRzIiA6IDE1Cg==" />
  {{renderer :mermaid_wsnmmsuqmx}}
        - ```mermaid
          pie title Pets adopted by volunteers
              "Dogs" : 386
              "Cats" : 85
              "Rats" : 15

![image](https://user-images.githubusercontent.com/1262488/153896321-8396eb98-1b8c-41c2-afe2-89f699046737.png)
bepolymathe commented 2 years ago

Strange :thinking:

image

Zachu commented 2 years ago

Sorry for asking dumb questions but have you clicked the Render button?

bepolymathe commented 2 years ago

Yes ;-)

Zachu commented 2 years ago

Your screenshot doesn't show it but does anything appear on top of the Render button? Like an erronous image icon as can be seen in #2

Can you show how that section looks like when opening the file in another text editor? Does it even have the image link as is in my first comment?

Also does any other graph render correctly?

bepolymathe commented 2 years ago

Hi,

Thanks for help.

Your screenshot doesn't show it but does anything appear on top of the Render button? Like an erronous image icon as can be seen in #2

There is nothing on the top after clicking on the render button.

Can you show how that section looks like when opening the file in another text editor?

image

Does it even have the image link as is in my first comment?

No.

Also does any other graph render correctly?

Just try dans no. Same problem.

logseq-cldwalker commented 2 years ago

Hi @hkgnp. Cool looking plugin. Great timing as github just announced mermaid support :)

I also have problems when I click the render. The example I used was:

 graph TD;
      A-->B;
      A-->C;
      B-->D;
      C-->D;

I see this on the latest nightly build, https://github.com/logseq/logseq/releases/tag/nightly and 0.5.9. The error I see in the console is:

Access to fetch at 'https://mermaid.ink/img/ICAgZ3JhcGggVEQ7CiAgICAgIEEtLT5COwogICAgICBBLS0+QzsKICAgICAgQi0tPkQ7CiAgICAgIEMtLT5EOwo=' from origin 'lsp://logseq.io' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Curious if you or anyone have seen this error?

rubbsdecvik commented 2 years ago

I too am seeing the same error with a simple graph as well. I'm on the stable release of 0.5.9.

Access to fetch at 'https://mermaid.ink/img/ICBmbG93Y2hhcnQgVEQ7CiAgYSAtLT4gYgogIGIgLS0+IGMKICBhIC0tPiBjCg==' from origin 'lsp://logseq.io' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
benjypng commented 2 years ago

@logseq-cldwalker @rubbsdecvik Thanks for reporting this. Created a new issue to track this CORS problem.

@bepolymathe Apologies, can you take a screenshot of the entire block, please? If no url is actually appearing, then it sounds like you're not rendering the plugin correctly. Having some steps would help that you did would help as well.

Zachu commented 2 years ago

Actually I can reproduce. It's a regression bug. Happening to me too after updating from 1.0.2 to 1.0.3. Clicking the Render button just quickly flashes the {{render :mermaid_...}} there and nothing else happens.

image

$ cat ~/Documents/PKM/journals/2022_02_15.md

- 08:29 Journal started
- {{renderer :mermaid_clxrepte}}
        - ```mermaid
          graph TD
            Foo --> Bar
benjypng commented 2 years ago

Actually I can reproduce. It's a regression bug. Happening to me too after updating from 1.0.2 to 1.0.3. Clicking the Render button just quickly flashes the {{render :mermaid_...}} there and nothing else happens.

image

$ cat ~/Documents/PKM/journals/2022_02_15.md

- 08:29 Journal started
- {{renderer :mermaid_clxrepte}}
        - ```mermaid
          graph TD
            Foo --> Bar
  • Nothing comes from clicking the Render button :(
  • ``

Do you get the CORS error in your console logs as well? Could you also try it with 1.0.5 if it's not too much trouble?

Zachu commented 2 years ago

Is there a way to increase the verbosity of Logseq or another way to view logs? The only message I see on the foreground when launching logseq from terminal is

08:34:36.631 › Logseq App(0.5.9) Starting...

I don't know if I've ever seen anything more than that =)

I've secretly now tested 1.0.4 and 1.0.5 and it doesn't fix the issue for me

benjypng commented 2 years ago

How about opening up the Dev Console from within Logseq?

You can press “Command-Option-I” on macOS or “Control-Alt-I” on Windows or Linux. I believe the issue is with how I am testing for the validity of the URL, but I strangely am not able to replicate it on my machine.

Zachu commented 2 years ago

Ahh! CTRL + Shift + I it seems. Nice, thanks. Yeah it seems to be the CORS issue as well

image

I think up to the warning they are from launching Logseq. undefined and after that comes when clicking Render

benjypng commented 2 years ago

@Zachu Guessed as much. Will continue in the other thread. undefined actually comes from the background colour bit so I don't think it's related!

Do jump over to: https://github.com/hkgnp/logseq-mermaid-plugin/issues/4 for the CORS issue.

bepolymathe commented 2 years ago

Hi,

Same for me...

image

image

Zachu commented 2 years ago

@bepolymathe as per #4 the issue is now (temporarily at least) fixed with 1.0.7 version so you should update your plugin to that. This should resolve your issue.

benjypng commented 2 years ago

@Zachu if you don't mind, could you try 1.0.8? I've tried to use a non http approach.

Zachu commented 2 years ago

@hkgnp 1.0.8 works, and so does the error message :) Thanks!

benjypng commented 2 years ago

Closing this issue and moving it to https://github.com/hkgnp/logseq-mermaid-plugin/issues/4#issuecomment-1040007982

bepolymathe commented 2 years ago

@hkgnp @Zachu same for me. 1.0.8 works. :+1: