-
Notifications
You must be signed in to change notification settings - Fork 46
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
feat(imsize): rework image styling to get more control #549
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
bbf59b6
feat(imsize): rework image styling to get more control
St1ggy c5296a1
chore: add more tests with different size configs, refactor styling b…
St1ggy 879e32d
chore: hide inline size styling behind feature flag
St1ggy 648f539
chore: add forcedSanitizeWhiteList
St1ggy d6ce8fb
chore: rename params
St1ggy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ export enum ImsizeAttr { | |
Title = 'title', | ||
Width = 'width', | ||
Height = 'height', | ||
Style = 'style', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
import {PluginSimple} from 'markdown-it'; | ||
import {PluginWithOptions} from 'markdown-it'; | ||
|
||
import {imageWithSize} from './plugin'; | ||
import {ImsizeOptions, imageWithSize} from './plugin'; | ||
|
||
/** | ||
* Imsize plugin for markdown-it. | ||
* This plugin overloads original image renderer. | ||
* Forked from https://github.com/tatsy/markdown-it-imsize | ||
*/ | ||
|
||
const imsize: PluginSimple = (md) => { | ||
md.inline.ruler.before('emphasis', 'image', imageWithSize(md)); | ||
const imsize: PluginWithOptions<ImsizeOptions> = (md, opts) => { | ||
md.inline.ruler.before('emphasis', 'image', imageWithSize(md, opts)); | ||
}; | ||
|
||
export = imsize; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
Coverage. Image with inlineStyling | ||
. | ||
 | ||
. | ||
<p><img src="x" alt="test" width="100" height="200" style="width: 100px;aspect-ratio: 100 / 200;height: auto;"></p> | ||
. | ||
. | ||
 | ||
. | ||
<p><img src="x" alt="test"></p> | ||
. | ||
. | ||
 | ||
. | ||
<p><img src="x" alt="test" width="100" style="width: 100px;"></p> | ||
. | ||
. | ||
 | ||
. | ||
<p><img src="x" alt="test" height="200" style="height: 200px;"></p> | ||
. | ||
. | ||
 | ||
. | ||
<p><img src="x" alt="test" title="title" width="100" height="200" style="width: 100px;aspect-ratio: 100 / 200;height: auto;"></p> | ||
. | ||
. | ||
 | ||
. | ||
<p></p> | ||
. | ||
. | ||
 | ||
. | ||
<p></p> | ||
. | ||
. | ||
 | ||
. | ||
<p></p> | ||
. | ||
. | ||
 | ||
. | ||
<p><img src="http://this.is.test.jpg" alt="test" width="100" height="200" style="width: 100px;aspect-ratio: 100 / 200;height: auto;"></p> | ||
. | ||
. | ||
 | ||
. | ||
<p></p> | ||
. | ||
. | ||
 | ||
. | ||
<p><img src="x" alt="test" width="100" height="200" style="width: 100px;aspect-ratio: 100 / 200;height: auto;"></p> | ||
. | ||
. | ||
 | ||
. | ||
<p><img src="test" alt="test" width="100%" style="width: 100%;"></p> | ||
. | ||
. | ||
 | ||
. | ||
<p><img src="test" alt="test" height="100%" style="height: 100%;"></p> | ||
. | ||
. | ||
 | ||
. | ||
<p><img src="test" alt="test" width="100%" height="100%" style="width: 100%;height: 100%;"></p> | ||
. | ||
. | ||
 | ||
. | ||
<p><img src="test" alt="test" width="100%" height="200" style="width: 100%;height: 200px;"></p> | ||
. | ||
. | ||
 | ||
. | ||
<p><img src="test" alt="test" width="100" height="100%" style="width: 100px;height: 100%;"></p> | ||
. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why we still need height and width attributes?
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.
transform/src/transform/plugins/changelog/index.ts
Lines 77 to 78 in bff7df9
Alas, that's why we still need 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.
I also noticed complaints about incorrect image appearance when the height was not proportional. However, I did not see any requests for a stretched image or an image with extra frames.
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 proportions of the image are calculated based on the height and width specified in the markup. If the container is larger than these dimensions, the image will maintain its original height and width. If the width of the container is less than the width of the image, the image's width will adjust to 100% of the container's width and the height will be adjusted proportionally based on the original height and width values from the markup.