mirror of
https://github.com/doocs/md.git
synced 2024-11-24 19:10:34 +08:00
fix: update font size options
修复字体大小错误
This commit is contained in:
parent
f79b8711c3
commit
64c06a8a5d
@ -136,6 +136,7 @@ let app = new Vue({
|
|||||||
this.wxRenderer.setOptions({
|
this.wxRenderer.setOptions({
|
||||||
fonts: fonts
|
fonts: fonts
|
||||||
});
|
});
|
||||||
|
this.currentFont = fonts;
|
||||||
this.refresh();
|
this.refresh();
|
||||||
},
|
},
|
||||||
sizeChanged(size) {
|
sizeChanged(size) {
|
||||||
@ -146,18 +147,22 @@ let app = new Vue({
|
|||||||
this.wxRenderer.setOptions({
|
this.wxRenderer.setOptions({
|
||||||
theme: theme
|
theme: theme
|
||||||
});
|
});
|
||||||
|
this.currentSize = size;
|
||||||
this.refresh();
|
this.refresh();
|
||||||
},
|
},
|
||||||
colorChanged(color) {
|
colorChanged(color) {
|
||||||
let theme = setColor(color);
|
let theme = setFontSize(this.currentSize.replace('px', ''));
|
||||||
|
theme = setColorWithCustomTemplate(theme, color);
|
||||||
this.wxRenderer.setOptions({
|
this.wxRenderer.setOptions({
|
||||||
theme: theme
|
theme: theme
|
||||||
});
|
});
|
||||||
|
this.currentColor = color;
|
||||||
this.refresh();
|
this.refresh();
|
||||||
},
|
},
|
||||||
cssChanged() {
|
cssChanged() {
|
||||||
let json = css2json(this.cssEditor.getValue(0));
|
let json = css2json(this.cssEditor.getValue(0));
|
||||||
let theme = customCssWithTemplate(json, this.currentColor);
|
let theme = setFontSize(this.currentSize.replace('px', ''));
|
||||||
|
theme = customCssWithTemplate(json, this.currentColor, theme);
|
||||||
this.wxRenderer.setOptions({
|
this.wxRenderer.setOptions({
|
||||||
theme: theme
|
theme: theme
|
||||||
});
|
});
|
||||||
|
@ -11,6 +11,17 @@ function setColorWithTemplate(template) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
let setColorWithCustomTemplate = function setColorWithCustomTemplate(template, color) {
|
||||||
|
let custom_theme = JSON.parse(JSON.stringify(template));
|
||||||
|
custom_theme.block.h1['border-bottom'] = `2px solid ${color}`;
|
||||||
|
custom_theme.block.h2['background'] = color;
|
||||||
|
custom_theme.block.h3['border-left'] = `3px solid ${color}`;
|
||||||
|
custom_theme.block.h4['color'] = color;
|
||||||
|
custom_theme.inline.strong['color'] = color;
|
||||||
|
return custom_theme;
|
||||||
|
}
|
||||||
|
|
||||||
// 设置自定义字体大小
|
// 设置自定义字体大小
|
||||||
function setFontSizeWithTemplate(template) {
|
function setFontSizeWithTemplate(template) {
|
||||||
return function (fontSize) {
|
return function (fontSize) {
|
||||||
@ -21,14 +32,13 @@ function setFontSizeWithTemplate(template) {
|
|||||||
custom_theme.block.h4['font-size'] = `${fontSize}px`;
|
custom_theme.block.h4['font-size'] = `${fontSize}px`;
|
||||||
return custom_theme;
|
return custom_theme;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let setColor = setColorWithTemplate(default_theme);
|
let setColor = setColorWithTemplate(default_theme);
|
||||||
let setFontSize = setFontSizeWithTemplate(default_theme);
|
let setFontSize = setFontSizeWithTemplate(default_theme);
|
||||||
|
|
||||||
function customCssWithTemplate(jsonString, color) {
|
function customCssWithTemplate(jsonString, color, theme) {
|
||||||
let custom_theme = JSON.parse(JSON.stringify(default_theme));
|
let custom_theme = JSON.parse(JSON.stringify(theme));
|
||||||
// block
|
// block
|
||||||
custom_theme.block.h1['border-bottom'] = `2px solid ${color}`;
|
custom_theme.block.h1['border-bottom'] = `2px solid ${color}`;
|
||||||
custom_theme.block.h2['background'] = color;
|
custom_theme.block.h2['background'] = color;
|
||||||
|
Loading…
Reference in New Issue
Block a user