-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 image gallery #2465
add image gallery #2465
Conversation
I've updated the PR to support markdown image syntax inside the gallery block.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The scrollbar of the image list doesn't seem to follow when you try to switch to an image outside the list
@@ -227,7 +227,7 @@ function migrateAttachments (markdownContent, storagePath, noteKey) { | |||
* @returns {String} postprocessed HTML in which all :storage references are mapped to the actual paths. | |||
*/ | |||
function fixLocalURLS (renderedHTML, storagePath) { | |||
return renderedHTML.replace(new RegExp('/?' + STORAGE_FOLDER_PLACEHOLDER + '.*?"', 'g'), function (match) { | |||
return renderedHTML.replace(new RegExp('/?' + STORAGE_FOLDER_PLACEHOLDER + '(?:\\\/|%5C)[\\w.]+', 'g'), function (match) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add some comment explaining the regex?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've undone the change because I don't remember why I've changed it. And it works with the original one...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, now, I understand why 😁
![#5.jpg](:storage/3b6f8bd6-4edd-4b15-96e0-eadc4475b564/fad71156.jpg)
generates
<p data-line="1"><img src=":storage/3b6f8bd6-4edd-4b15-96e0-eadc4475b564/fad71156.jpg" alt="#5.jpg" /></p>
```gallery(30h) ![#5.jpg](:storage/3b6f8bd6-4edd-4b15-96e0-eadc4475b564/fad71156.jpg) ```
generates
<pre class="fence" data-line="1"> <span class="filename"></span> <div class="gallery" data-autoplay="undefined" data-height="20">:storage/3b6f8bd6-4edd-4b15-96e0-eadc4475b564/fad71156.jpg</div> </pre>
new RegExp('/?' + STORAGE_FOLDER_PLACEHOLDER + '.*?"', 'g')
will only match the first image due to the need of the closing "
.
new RegExp('/?' + STORAGE_FOLDER_PLACEHOLDER + '(?:\\\/|%5C)[\\w.]+', 'g')
will match both images. The \\\/
is for posix systems and %5C
is for windows.
It might need further testing on windows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't you use the PATH_SEPARATORS
variable which is defined at the top of the file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PATH_SEPARATORS
's value is /\\
so it can't be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you, at least, use path.win32.sep
and path.posix.sep
? That would make clearer what the RegExp means..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
path.win32.sep
is \\
which is far from the needed %5C
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then i am wondering whether you really need your %5C
i mean: it dosen't appear everywhere else in the attachment-management, does it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the URI encoding of \
. After I don't know where it's been done.
The scrollbar issue is due to the component. I will try to look at it when I have time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🎉
This change adds the possibility to display image gallery.