feat: static preview of album description markdown

in dashboard's edit album prompt
This commit is contained in:
Bobby 2022-05-05 13:17:32 +07:00
parent 7dd4f50e9e
commit 39b7d96b8f
No known key found for this signature in database
GPG Key ID: 941839794CBF5A09
3 changed files with 24 additions and 2 deletions

View File

@ -128,6 +128,9 @@ self.list = async (req, res, next) => {
album.uploads = 0
album.size = 0
album.zipSize = null
album.descriptionHtml = album.description
? utils.md.instance.render(album.description)
: ''
// Map by IDs
albumids[album.id] = album

View File

@ -158,3 +158,13 @@ $swal-modal-background: $grey-darker;
align-items: center;
justify-content: center
}
.swal-display-description-preview {
background-color: $scheme-main;
border-radius: 4px;
padding: calc(0.5em - 1px) calc(0.75em - 1px) calc(0.5em - 1px) calc(0.75em - 1px);
&.content {
margin-bottom: 0
}
}

View File

@ -1797,6 +1797,7 @@ page.getAlbums = (params = {}) => {
download: album.download,
public: album.public,
description: album.description,
descriptionHtml: album.descriptionHtml,
enabled,
homeDomain,
urlPath,
@ -1895,8 +1896,16 @@ page.editAlbum = id => {
<div class="control">
<textarea id="swalDescription" class="textarea" placeholder="Description" rows="2" maxlength="${page.albumDescMaxLength}">${(album.description || '').substring(0, page.albumDescMaxLength)}</textarea>
</div>
<p class="help">Max length is ${page.albumDescMaxLength} characters.</p>
<p class="help"><b>Markdown supported.</b> Max length is ${page.albumDescMaxLength} characters.</p>
</div>
${album.descriptionHtml
? `<div class="field">
<div class="content swal-display-description-preview">
${album.descriptionHtml}
</div>
<p class="help">Save changes then re-open this Edit prompt to refresh this preview.</p>
</div>`
: ''}
${page.currentView === 'albumsAll' && page.permissions.moderator
? `<div class="field">
<div class="control">
@ -2668,7 +2677,7 @@ page.editUser = id => {
${isHigher
? ''
: `<div class="notification is-danger">
You <strong>cannot</strong> modify user in the same or higher group as you.
You <b>cannot</b> modify user in the same or higher group as you.
</div>`
}
`