Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mermaid JS renderer #12334

Merged
merged 6 commits into from
Jul 27, 2020
Merged

Add mermaid JS renderer #12334

merged 6 commits into from
Jul 27, 2020

Conversation

silverwind
Copy link
Member

@silverwind silverwind commented Jul 26, 2020

For feature parity with GitLab. Tested in files, issues, wiki, editor. arc-green only does an inversion because the renderer seems to like to render white backgrounds on boxes.

Ref: #3340
Fixes: #12307

Previews:

image

image

Sample for testing:

```mermaid
    stateDiagram
    [*] --> Active

    state Active {
        [*] --> NumLockOff
        NumLockOff --> NumLockOn : EvNumLockPressed
        NumLockOn --> NumLockOff : EvNumLockPressed
    }
```

For feature parity with GitLab. Tested in files, issues, wiki, editor.
arc-green only does an inversion because the renderer seems to like to
render white backgrounds on boxes.

Ref: go-gitea#3340
Fixes: go-gitea#12307
@silverwind
Copy link
Member Author

The only real downside I see with this is that the library is a bit heavy at 1.4MiB so will add a bit to our webpack build time. The code itself is rather trivial and should not require much to maintain.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jul 26, 2020
@lafriks lafriks added the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label Jul 26, 2020
@lafriks lafriks added this to the 1.13.0 milestone Jul 26, 2020
@lafriks lafriks added the type/changelog Adds the changelog for a new Gitea version label Jul 26, 2020
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Jul 26, 2020
@silverwind
Copy link
Member Author

silverwind commented Jul 26, 2020

Took a few hints from the gitlab implementation. Now renders without a border and with neutral theme. Updated screenshots.

@silverwind silverwind mentioned this pull request Jul 26, 2020
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jul 27, 2020
@lunny
Copy link
Member

lunny commented Jul 27, 2020

This may break the user's customerized mermaid rendering. We should have a warnning for that.

@techknowlogick
Copy link
Member

🚀

@techknowlogick techknowlogick merged commit 4315e31 into go-gitea:master Jul 27, 2020
@silverwind
Copy link
Member Author

silverwind commented Jul 27, 2020

This may break the user's customerized mermaid rendering

I don't think it will. Our script will likely run before the user-supplied one and then their script is essentially a noop because it won't find any matching elements.

A mention in the release notes about the necessary customization removal would be nice.

@silverwind silverwind deleted the mermaid branch July 27, 2020 07:12
@lafriks
Copy link
Member

lafriks commented Jul 27, 2020

Looks like editor is now broken with error:

Uncaught (in promise) TypeError: e[t] is undefined
    o https://try.gitea.io/js/index.js?v=2e108e628cde5272a8a152c33efb9249:1
    t https://try.gitea.io/js/index.js?v=2e108e628cde5272a8a152c33efb9249:1

@silverwind
Copy link
Member Author

It does work for me https://try.gitea.io/silverwind/symlink-test/issues/7. Try refreshing the page a few times? There's still a unresolved issue with bad serviceworker cache which I'll soon look into.

@silverwind
Copy link
Member Author

Ah, misread. What exactly do you do to trigger that error?

@lafriks
Copy link
Member

lafriks commented Jul 27, 2020

Just edit file in repository (I was trying to edit README.md)

@lafriks
Copy link
Member

lafriks commented Jul 27, 2020

nevermind, now it does work 😅

@silverwind
Copy link
Member Author

silverwind commented Jul 27, 2020

Yeah, serviceworker strikes again. I plan to experiment with contenthash chunks which will hopefully bust that cache and fix these issues after frontend rebuilds. Only problem is that we can't use contenthash for the index chunk because the backend doesn't know the filename (could probably be worked around via detection).

@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
@delvh delvh removed the type/changelog Adds the changelog for a new Gitea version label Oct 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/feature Completely new functionality. Can only be merged if feature freeze is not active.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mermaid Js not rendering in Readme but in Issues and Wiki
6 participants