Skip to content

Commit

Permalink
fix: 调整cherryMarkdown toc样式 兼容打印样式
Browse files Browse the repository at this point in the history
fix: 修复 convertImageToDataUri not func
  • Loading branch information
Zzhenping committed Jul 10, 2024
1 parent acfd651 commit 13cc0b1
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 12 deletions.
9 changes: 9 additions & 0 deletions static/cherry/cherry-markdown.css
Original file line number Diff line number Diff line change
Expand Up @@ -1961,6 +1961,15 @@ div[data-type=codeBlock] .token.inserted {
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 {
right: 0.75em;
left: auto;
Expand Down
2 changes: 1 addition & 1 deletion static/cherry/cherry-markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -54950,7 +54950,7 @@
style: ['position: absolute', 'bottom: 30px', 'top: 30px', 'left: 0', 'right: 0', 'overflow: hidden'].join(';')
});
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', {
style: 'user-select:none;'
Expand Down
17 changes: 16 additions & 1 deletion static/cherry/drawio_demo/EditorUi.js
Original file line number Diff line number Diff line change
Expand Up @@ -5745,7 +5745,7 @@ EditorUi.prototype.convertImages = function (svgRoot, callback, imageCache, conv
for (var i = 0; i < images.length; i++) {
(mxUtils.bind(this, function (img) {
var src = converter.convert(img.getAttribute(srcAttr));

console.log(src)
// Data URIs are pass-through
if (src != null && src.substring(0, 5) != 'data:') {
var tmp = cache[src];
Expand Down Expand Up @@ -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) {
var data = canvas.toDataURL('image/' + format);

Expand Down
20 changes: 11 additions & 9 deletions static/css/markdown.css
Original file line number Diff line number Diff line change
Expand Up @@ -545,18 +545,20 @@ iframe.cherry-dialog-iframe {

.manual-article.cherry-markdown .toc {
position: fixed;
right: 0;
width: 200px;
margin-top: -70px;
right: 50px;
width: 260px;
font-size: 12px;
overflow: auto;
margin-right: 50px;
border: 1px solid #e8e8e8;
padding: 10px;
border-radius: 6px;
}

@media screen and (min-width: 840px) {
.markdown-article {
margin-right: 200px !important;
}
}
/*@media screen and (min-width: 840px) {*/
/* .markdown-article {*/
/* margin-right: 200px !important;*/
/* }*/
/*}*/

.markdown-article-head {
width: unset !important;
Expand Down
6 changes: 5 additions & 1 deletion static/js/kancloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ function renderPage($data) {
$("#article-info").text($data.doc_info);
$("#view_count").text("阅读次数:" + $data.view_count);
$("#doc_id").val($data.doc_id);
checkMarkdownTocElement();
if ($data.page) {
loadComment($data.page, $data.doc_id);
} else {
Expand All @@ -154,7 +155,7 @@ function renderPage($data) {
$("#view_container").removeClass("theme__dark theme__green theme__light theme__red theme__default")
$("#view_container").addClass($data.markdown_theme)
}
checkMarkdownTocElement();

}

/***
Expand Down Expand Up @@ -442,6 +443,9 @@ function loadCopySnippets() {

function checkMarkdownTocElement() {
let toc = $(".markdown-toc-list");
if ($(".toc").length) {
toc = $(".toc");
}
let articleComment = $("#articleComment");
if (toc.length) {
$(".wiki-bottom-left").css("width", "calc(100% - 260px)");
Expand Down

0 comments on commit 13cc0b1

Please sign in to comment.