diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d41e9d..1920a52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## v1.0.2/ 2024.10.10 +- 支持格式刷字体大小 + ## v1.0.0/ 2024.10.10 🎉 第一次提交 - 支持格式刷功能 - 已知bug:不支持数学公式格式刷 diff --git a/README.md b/README.md index 88f9d25..3e2ab83 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ## Feature Introduction - Enter Format Painter Mode: Select text, click the "Format Painter" button on the floating toolbar to copy styles (supports layered styles), then select other text to automatically and quickly apply the copied styles. - - Supported inline styles: no style, background color, text color, bold, inline code, keyboard style, underline, strikethrough, superscript, subscript, highlight, etc. + - Supported inline styles: no style, fontsize, background color, text color, bold, inline code, keyboard style, underline, strikethrough, superscript, subscript, highlight, etc. - Exit Format Painter Mode: Press the Esc key. ## Known Bugs diff --git a/README_zh_CN.md b/README_zh_CN.md index 517e5cb..6abc8cf 100644 --- a/README_zh_CN.md +++ b/README_zh_CN.md @@ -3,7 +3,7 @@ ## 功能介绍 - 进入格式刷模式:选中文字,在悬浮工具栏点击「格式刷」按钮即可复制样式(支持叠加的样式),之后选中其他文字后自动快速添加复制的样式 - - 支持的行内样式:无样式、背景色、文字颜色、加粗、行内代码、键盘样式、下划线、删除线、上标、下标、高亮等 + - 支持的行内样式:无样式、字体大小、背景色、文字颜色、加粗、行内代码、键盘样式、下划线、删除线、上标、下标、高亮等 - 退出格式刷模式:按Esc建即可 ![](https://fastly.jsdelivr.net/gh/Achuan-2/PicBed/assets/思源笔记格式刷插件-2024-10-10.gif) @@ -11,4 +11,5 @@ ## 已知bug - 暂不支持数学公式格式刷 - 格式刷复制的样式无颜色,要刷的文字已有颜色,不会替换其颜色 +- 不支持文字大小 diff --git a/plugin.json b/plugin.json index 831e242..f9e26f9 100644 --- a/plugin.json +++ b/plugin.json @@ -2,7 +2,7 @@ "name": "siyuan-plugin-formatPainter", "author": "Achuan-2", "url": "https://github.com/Achuan-2/siyuan-plugin-formatPainter", - "version": "1.0.1", + "version": "1.0.2 ", "minAppVersion": "3.0.12", "backends": [ "windows", diff --git a/src/index.ts b/src/index.ts index b551eac..edb49c0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -21,7 +21,6 @@ export default class PluginSample extends Plugin { private formatData: { datatype: string, style: string } | null = null; private protyle: IProtyle; onload() { - console.log(this.app); this.data[STORAGE_NAME] = { readonlyText: "Readonly" }; this.protyleOptions = { toolbar: ["block-ref", @@ -65,7 +64,7 @@ export default class PluginSample extends Plugin { // console.log("选中无样式文字"); } this.formatPainterEnable = true; - console.log(this.formatData); + // console.log(this.formatData); fetchPost("/api/notification/pushErrMsg", { "msg": this.i18n.enable, "timeout": 7000 }); } } @@ -101,7 +100,8 @@ export default class PluginSample extends Plugin { if (this.formatData.style) { // console.log(this.formatData.style); // this.protyle.toolbar.setInlineMark(this.protyle, "text", "range", { "type": "style1", "color": this.formatData.style }); - const { backgroundColor, color } = parseStyle(this.formatData.style); + const { backgroundColor, color, fontSize } = parseStyle(this.formatData.style); + // console.log(backgroundColor, color, fontSize); if (backgroundColor) { this.protyle.toolbar.setInlineMark(this.protyle, "text", "range", { @@ -116,6 +116,13 @@ export default class PluginSample extends Plugin { "color": color }); } + + if (fontSize) { + this.protyle.toolbar.setInlineMark(this.protyle, "text", "range", { + "type": "fontSize", + "color": fontSize + }); + } } // console.log("Format applied to selected text"); @@ -136,7 +143,8 @@ export default class PluginSample extends Plugin { return { backgroundColor: styleObject['background-color'], - color: styleObject['color'] + color: styleObject['color'], + fontSize: styleObject['font-size'] }; } document.addEventListener('keydown', (event) => { @@ -180,8 +188,6 @@ export default class PluginSample extends Plugin { } onLayoutReady() { - this.loadData(STORAGE_NAME); - console.log(`frontend: ${getFrontend()}; backend: ${getBackend()}`); } onunload() {