mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 05:49:53 +08:00
markdown-it: support specifying image size via markdown-it-imsize plugin
Only supported in read mode.
This commit is contained in:
parent
ccaaeeef87
commit
6558fa85b7
@ -195,6 +195,7 @@ In VNote, almost everything is configurable, such as background color, font, and
|
||||
- [markdown-it-sub](https://github.com/markdown-it/markdown-it-sub) (MIT License)
|
||||
- [markdown-it-sup](https://github.com/markdown-it/markdown-it-sup) (MIT License)
|
||||
- [markdown-it-front-matter](https://github.com/craigdmckenna/markdown-it-front-matter) (MIT License)
|
||||
- [markdown-it-imsize](https://github.com/tatsy/markdown-it-imsize) (Unknown) (Thanks @Kinka for help)
|
||||
- [mermaid 7.0.0](https://github.com/knsv/mermaid) (MIT License)
|
||||
- [MathJax](https://www.mathjax.org/) (Apache-2.0)
|
||||
- [showdown](https://github.com/showdownjs/showdown) (Unknown)
|
||||
|
@ -196,6 +196,7 @@ VNote中,几乎一切都是可以定制的,例如背景颜色、字体以及
|
||||
- [markdown-it-sub](https://github.com/markdown-it/markdown-it-sub) (MIT License)
|
||||
- [markdown-it-sup](https://github.com/markdown-it/markdown-it-sup) (MIT License)
|
||||
- [markdown-it-front-matter](https://github.com/craigdmckenna/markdown-it-front-matter) (MIT License)
|
||||
- [markdown-it-imsize](https://github.com/tatsy/markdown-it-imsize) (Unknown) (Thanks @Kinka for help)
|
||||
- [mermaid 7.0.0](https://github.com/knsv/mermaid) (MIT License)
|
||||
- [MathJax](https://www.mathjax.org/) (Apache-2.0)
|
||||
- [showdown](https://github.com/showdownjs/showdown) (Unknown)
|
||||
|
@ -96,6 +96,8 @@ if (VMarkdownitOption.metadata) {
|
||||
|
||||
mdit = mdit.use(window.markdownitFootnote);
|
||||
|
||||
mdit = mdit.use(window["markdown-it-imsize.js"]);
|
||||
|
||||
var mdHasTocSection = function(markdown) {
|
||||
var n = markdown.search(/(\n|^)\[toc\]/i);
|
||||
return n != -1;
|
||||
|
@ -27,3 +27,7 @@ Vitaly Puzrin
|
||||
# [markddown-it-front-matter](https://github.com/craigdmckenna/markdown-it-front-matter)
|
||||
v0.1.2
|
||||
Craig McKenna
|
||||
|
||||
# [markdown-it-imsize](https://github.com/tatsy/markdown-it-imsize)
|
||||
v2.0.1
|
||||
Tatsuya Yatagawa
|
||||
|
2
src/utils/markdown-it/markdown-it-imsize.min.js
vendored
Normal file
2
src/utils/markdown-it/markdown-it-imsize.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -653,6 +653,7 @@ QString VUtils::generateHtmlTemplate(const QString &p_template,
|
||||
extraFile = "<script src=\"qrc" + VNote::c_markdownitExtraFile + "\"></script>\n" +
|
||||
"<script src=\"qrc" + VNote::c_markdownitAnchorExtraFile + "\"></script>\n" +
|
||||
"<script src=\"qrc" + VNote::c_markdownitTaskListExtraFile + "\"></script>\n" +
|
||||
"<script src=\"qrc" + VNote::c_markdownitImsizeExtraFile + "\"></script>\n" +
|
||||
"<script src=\"qrc" + VNote::c_markdownitFootnoteExtraFile + "\"></script>\n";
|
||||
|
||||
const MarkdownitOption &opt = g_config->getMarkdownitOption();
|
||||
|
@ -40,6 +40,7 @@ const QString VNote::c_markdownitSubExtraFile = ":/utils/markdown-it/markdown-it
|
||||
const QString VNote::c_markdownitSupExtraFile = ":/utils/markdown-it/markdown-it-sup.min.js";
|
||||
const QString VNote::c_markdownitFootnoteExtraFile = ":/utils/markdown-it/markdown-it-footnote.min.js";
|
||||
const QString VNote::c_markdownitFrontMatterExtraFile = ":/utils/markdown-it/markdown-it-front-matter.js";
|
||||
const QString VNote::c_markdownitImsizeExtraFile = ":/utils/markdown-it/markdown-it-imsize.min.js";
|
||||
|
||||
const QString VNote::c_showdownJsFile = ":/resources/showdown.js";
|
||||
const QString VNote::c_showdownExtraFile = ":/utils/showdown/showdown.min.js";
|
||||
|
@ -51,6 +51,7 @@ public:
|
||||
static const QString c_markdownitSupExtraFile;
|
||||
static const QString c_markdownitFootnoteExtraFile;
|
||||
static const QString c_markdownitFrontMatterExtraFile;
|
||||
static const QString c_markdownitImsizeExtraFile;
|
||||
|
||||
// Showdown
|
||||
static const QString c_showdownJsFile;
|
||||
|
@ -214,5 +214,6 @@
|
||||
<file>resources/mathjax_preview_template.html</file>
|
||||
<file>utils/dom-to-image/dom-to-image.js</file>
|
||||
<file>utils/markdown-it/markdown-it-front-matter.js</file>
|
||||
<file>utils/markdown-it/markdown-it-imsize.min.js</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@ -131,7 +131,7 @@ void VPreviewManager::fetchImageLinksFromRegions(QVector<VElementRegion> p_image
|
||||
QTextDocument *doc = m_editor->document();
|
||||
|
||||
for (int i = 0; i < p_imageRegions.size(); ++i) {
|
||||
VElementRegion ® = p_imageRegions[i];
|
||||
const VElementRegion ® = p_imageRegions[i];
|
||||
QTextBlock block = doc->findBlock(reg.m_startPos);
|
||||
if (!block.isValid()) {
|
||||
continue;
|
||||
@ -140,7 +140,13 @@ void VPreviewManager::fetchImageLinksFromRegions(QVector<VElementRegion> p_image
|
||||
int blockStart = block.position();
|
||||
int blockEnd = blockStart + block.length() - 1;
|
||||
QString text = block.text();
|
||||
Q_ASSERT(reg.m_endPos <= blockEnd);
|
||||
|
||||
// Since the image links update signal is emitted after a timer, during which
|
||||
// the content may be changed.
|
||||
if (reg.m_endPos > blockEnd) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ImageLinkInfo info(reg.m_startPos,
|
||||
reg.m_endPos,
|
||||
blockStart,
|
||||
|
Loading…
x
Reference in New Issue
Block a user