Skip to content

Commit

Permalink
🔖 v1.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Achuan-2 committed Oct 10, 2024
1 parent d79651d commit ef92fcd
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 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.5 / 2024.10.10
- 支持镂空和投影样式

## v1.0.4 / 2024.10.10
- 更改逻辑,添加样式前,先清除所有样式
- 启动格式刷更改鼠标光标
Expand Down
2 changes: 1 addition & 1 deletion README_zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
## ✨功能介绍

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

Expand Down
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.4 ",
"version": "1.0.5",
"minAppVersion": "3.0.12",
"backends": [
"windows",
Expand Down
30 changes: 18 additions & 12 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ import {


const STORAGE_NAME = "menu-config";
const TAB_TYPE = "custom_tab";
const DOCK_TYPE = "dock_tab";

export default class PluginSample extends Plugin {
private customTab: () => IModel;
private isMobile: boolean;
private formatPainterEnable = false;
private formatData: { datatype: string, style: string } | null = null;
Expand Down Expand Up @@ -87,12 +84,7 @@ export default class PluginSample extends Plugin {
}
],
};
// this.eventBus.on("click-editorcontent", ({ detail }) => {
// if (this.formatPainterEnable && this.formatData) {
// this.protyle = detail.protyle;
// }

// });
document.addEventListener('mouseup', (event) => {
if (this.formatPainterEnable) {
const selection = window.getSelection();
Expand All @@ -110,10 +102,9 @@ export default class PluginSample extends Plugin {
this.protyle.toolbar.setInlineMark(this.protyle, this.formatData.datatype, "range");
}
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, fontSize } = parseStyle(this.formatData.style);
// console.log(backgroundColor, color, fontSize);
const { backgroundColor, color, fontSize, textShadow, webkitTextStroke, webkitTextFillColor} = parseStyle(this.formatData.style);
// console.log(backgroundColor, color, fontSize, textShadow);

if (backgroundColor) {
this.protyle.toolbar.setInlineMark(this.protyle, "text", "range", {
Expand All @@ -135,6 +126,18 @@ export default class PluginSample extends Plugin {
"color": fontSize
});
}
if (textShadow) {
this.protyle.toolbar.setInlineMark(this.protyle, "text", "range", {
"type": "style4", //投影效果
"color": textShadow
});
}
if (webkitTextStroke) {
this.protyle.toolbar.setInlineMark(this.protyle, "text", "range", {
"type": "style2", //镂空效果
"color": webkitTextStroke
});
}
}

// console.log("Format applied to selected text");
Expand All @@ -156,7 +159,10 @@ export default class PluginSample extends Plugin {
return {
backgroundColor: styleObject['background-color'],
color: styleObject['color'],
fontSize: styleObject['font-size']
fontSize: styleObject['font-size'],
textShadow: styleObject['text-shadow'],
webkitTextStroke: styleObject['-webkit-text-stroke'],
webkitTextFillColor: styleObject['-webkit-text-fill-color']
};
}
document.addEventListener('keydown', (event) => {
Expand Down

0 comments on commit ef92fcd

Please sign in to comment.