-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(imsize): rework image styling to get more control (#549)
* feat(imsize): rework image styling to get more control * chore: add more tests with different size configs, refactor styling block * chore: hide inline size styling behind feature flag * chore: add forcedSanitizeWhiteList * chore: rename params
- Loading branch information
Showing
9 changed files
with
168 additions
and
9 deletions.
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 | ||
. | ||
![test]( x =100x200) | ||
. | ||
<p><img src="x" alt="test" width="100" height="200" style="width: 100px;aspect-ratio: 100 / 200;height: auto;"></p> | ||
. | ||
. | ||
![test]( x =x) | ||
. | ||
<p><img src="x" alt="test"></p> | ||
. | ||
. | ||
![test]( x =100x) | ||
. | ||
<p><img src="x" alt="test" width="100" style="width: 100px;"></p> | ||
. | ||
. | ||
![test]( x =x200) | ||
. | ||
<p><img src="x" alt="test" height="200" style="height: 200px;"></p> | ||
. | ||
. | ||
![test]( x "title" =100x200) | ||
. | ||
<p><img src="x" alt="test" title="title" width="100" height="200" style="width: 100px;aspect-ratio: 100 / 200;height: auto;"></p> | ||
. | ||
. | ||
![test]( x =WxH ) | ||
. | ||
<p>![test]( x =WxH )</p> | ||
. | ||
. | ||
![test]( x = 100x200 ) | ||
. | ||
<p>![test]( x = 100x200 )</p> | ||
. | ||
. | ||
![test]( x =aaaxbbb ) | ||
. | ||
<p>![test]( x =aaaxbbb )</p> | ||
. | ||
. | ||
![test](http://this.is.test.jpg =100x200) | ||
. | ||
<p><img src="http://this.is.test.jpg" alt="test" width="100" height="200" style="width: 100px;aspect-ratio: 100 / 200;height: auto;"></p> | ||
. | ||
. | ||
![test](<x =100x200) | ||
. | ||
<p>![test](<x =100x200)</p> | ||
. | ||
. | ||
![test](<x> =100x200) | ||
. | ||
<p><img src="x" alt="test" width="100" height="200" style="width: 100px;aspect-ratio: 100 / 200;height: auto;"></p> | ||
. | ||
. | ||
![test](test =100%x) | ||
. | ||
<p><img src="test" alt="test" width="100%" style="width: 100%;"></p> | ||
. | ||
. | ||
![test](test =x100%) | ||
. | ||
<p><img src="test" alt="test" height="100%" style="height: 100%;"></p> | ||
. | ||
. | ||
![test](test =100%x100%) | ||
. | ||
<p><img src="test" alt="test" width="100%" height="100%" style="width: 100%;height: 100%;"></p> | ||
. | ||
. | ||
![test](test =100%x200) | ||
. | ||
<p><img src="test" alt="test" width="100%" height="200" style="width: 100%;height: 200px;"></p> | ||
. | ||
. | ||
![test](test =100x100%) | ||
. | ||
<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