fix: 调整cherryMarkdown toc样式 兼容打印样式

fix: 修复 convertImageToDataUri not func
This commit is contained in:
zhanzhenping 2024-07-10 16:15:17 +08:00
parent acfd651be8
commit 13cc0b1e3b
5 changed files with 42 additions and 12 deletions

View File

@ -1961,6 +1961,15 @@ div[data-type=codeBlock] .token.inserted {
transform: rotate(-2deg); transform: rotate(-2deg);
} }
.whole-article-wrap > div {
display: flex;
flex-direction: column;
}
.whole-article-wrap > div > .markdown-article {
width: calc(100% - 260px);
}
[data-code-block-theme=coy] div[data-type=codeBlock] pre[class*=language-]:after { [data-code-block-theme=coy] div[data-type=codeBlock] pre[class*=language-]:after {
right: 0.75em; right: 0.75em;
left: auto; left: auto;

View File

@ -54950,7 +54950,7 @@
style: ['position: absolute', 'bottom: 30px', 'top: 30px', 'left: 0', 'right: 0', 'overflow: hidden'].join(';') style: ['position: absolute', 'bottom: 30px', 'top: 30px', 'left: 0', 'right: 0', 'overflow: hidden'].join(';')
}); });
this.foot = createElement('div', 'cherry-dialog--foot', { this.foot = createElement('div', 'cherry-dialog--foot', {
style: ['height: 30px', 'line-height: 30px', 'padding-left: 10px', 'padding-right: 10px', 'position: absolute', 'bottom: 0', 'left: 0', 'right: 0'].join(';') style: ['height: 30px', 'line-height: 18px', 'padding-left: 10px', 'padding-right: 10px', 'position: absolute', 'bottom: 0', 'left: 0', 'right: 0'].join(';')
}); });
this.headTitle = createElement('span', 'cherry-dialog--title', { this.headTitle = createElement('span', 'cherry-dialog--title', {
style: 'user-select:none;' style: 'user-select:none;'

View File

@ -5745,7 +5745,7 @@ EditorUi.prototype.convertImages = function (svgRoot, callback, imageCache, conv
for (var i = 0; i < images.length; i++) { for (var i = 0; i < images.length; i++) {
(mxUtils.bind(this, function (img) { (mxUtils.bind(this, function (img) {
var src = converter.convert(img.getAttribute(srcAttr)); var src = converter.convert(img.getAttribute(srcAttr));
console.log(src)
// Data URIs are pass-through // Data URIs are pass-through
if (src != null && src.substring(0, 5) != 'data:') { if (src != null && src.substring(0, 5) != 'data:') {
var tmp = cache[src]; var tmp = cache[src];
@ -6059,6 +6059,21 @@ EditorUi.prototype.getBaseFilename = function () {
}; };
EditorUi.prototype.convertImageToDataUri = function (src, call) {
let img = new Image();
img.src = src;
img.onload = function() {
let canvas = document.createElement('canvas');
canvas.width = img.width;
canvas.height = img.height;
let ctx = canvas.getContext('2d');
ctx.drawImage(img, 0, 0);
let base64 = canvas.toDataURL('image/png');
call(base64)
};
}
EditorUi.prototype.createImageDataUri = function (canvas, xml, format) { EditorUi.prototype.createImageDataUri = function (canvas, xml, format) {
var data = canvas.toDataURL('image/' + format); var data = canvas.toDataURL('image/' + format);

View File

@ -545,18 +545,20 @@ iframe.cherry-dialog-iframe {
.manual-article.cherry-markdown .toc { .manual-article.cherry-markdown .toc {
position: fixed; position: fixed;
right: 0; right: 50px;
width: 200px; width: 260px;
margin-top: -70px; font-size: 12px;
overflow: auto; overflow: auto;
margin-right: 50px; border: 1px solid #e8e8e8;
padding: 10px;
border-radius: 6px;
} }
@media screen and (min-width: 840px) { /*@media screen and (min-width: 840px) {*/
.markdown-article { /* .markdown-article {*/
margin-right: 200px !important; /* margin-right: 200px !important;*/
} /* }*/
} /*}*/
.markdown-article-head { .markdown-article-head {
width: unset !important; width: unset !important;

View File

@ -141,6 +141,7 @@ function renderPage($data) {
$("#article-info").text($data.doc_info); $("#article-info").text($data.doc_info);
$("#view_count").text("阅读次数:" + $data.view_count); $("#view_count").text("阅读次数:" + $data.view_count);
$("#doc_id").val($data.doc_id); $("#doc_id").val($data.doc_id);
checkMarkdownTocElement();
if ($data.page) { if ($data.page) {
loadComment($data.page, $data.doc_id); loadComment($data.page, $data.doc_id);
} else { } else {
@ -154,7 +155,7 @@ function renderPage($data) {
$("#view_container").removeClass("theme__dark theme__green theme__light theme__red theme__default") $("#view_container").removeClass("theme__dark theme__green theme__light theme__red theme__default")
$("#view_container").addClass($data.markdown_theme) $("#view_container").addClass($data.markdown_theme)
} }
checkMarkdownTocElement();
} }
/*** /***
@ -442,6 +443,9 @@ function loadCopySnippets() {
function checkMarkdownTocElement() { function checkMarkdownTocElement() {
let toc = $(".markdown-toc-list"); let toc = $(".markdown-toc-list");
if ($(".toc").length) {
toc = $(".toc");
}
let articleComment = $("#articleComment"); let articleComment = $("#articleComment");
if (toc.length) { if (toc.length) {
$(".wiki-bottom-left").css("width", "calc(100% - 260px)"); $(".wiki-bottom-left").css("width", "calc(100% - 260px)");