Skip to content

Commit

Permalink
🔖 v1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Achuan-2 committed Oct 10, 2024
1 parent f65d6aa commit d8a8726
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## v1.0.2/ 2024.10.10
- 支持格式刷字体大小

## v1.0.0/ 2024.10.10 🎉 第一次提交
- 支持格式刷功能
- 已知bug:不支持数学公式格式刷
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion README_zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
## 功能介绍

- 进入格式刷模式:选中文字,在悬浮工具栏点击「格式刷」按钮即可复制样式(支持叠加的样式),之后选中其他文字后自动快速添加复制的样式
- 支持的行内样式:无样式、背景色、文字颜色、加粗、行内代码、键盘样式、下划线、删除线、上标、下标、高亮等
- 支持的行内样式:无样式、字体大小、背景色、文字颜色、加粗、行内代码、键盘样式、下划线、删除线、上标、下标、高亮等
- 退出格式刷模式:按Esc建即可

![](https://fastly.jsdelivr.net/gh/Achuan-2/PicBed/assets/思源笔记格式刷插件-2024-10-10.gif)

## 已知bug
- 暂不支持数学公式格式刷
- 格式刷复制的样式无颜色,要刷的文字已有颜色,不会替换其颜色
- 不支持文字大小

2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
18 changes: 12 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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 });
}
}
Expand Down Expand Up @@ -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", {
Expand All @@ -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");
Expand All @@ -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) => {
Expand Down Expand Up @@ -180,8 +188,6 @@ export default class PluginSample extends Plugin {
}

onLayoutReady() {
this.loadData(STORAGE_NAME);
console.log(`frontend: ${getFrontend()}; backend: ${getBackend()}`);
}

onunload() {
Expand Down

0 comments on commit d8a8726

Please sign in to comment.