Skip to content

Commit

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

## v1.0.4 / 2024.10.10
- 更改逻辑,添加样式前,先清除所有样式
- 启动格式刷更改鼠标光标
- 启动格式刷自动关闭工具栏
## v1.0.3 / 2024.10.10
- 完善README
## v1.0.2 / 2024.10.10
Expand Down
1 change: 0 additions & 1 deletion README_zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
## 🐛已知bug

- 暂不支持数学公式格式刷(暂时不知道怎么解决)
- 格式刷复制的样式无颜色,要刷的文字已有颜色,不会替换其颜色(即逻辑是添加样式,而不是完全替换样式)
- 格式刷链接样式会产生null行内链接。


Expand Down
Binary file added assets/formatPainter_mouse2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.3 ",
"version": "1.0.4 ",
"minAppVersion": "3.0.12",
"backends": [
"windows",
Expand Down
11 changes: 1 addition & 10 deletions src/i18n/en_US.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
{
"addTopBarIcon": "Add a top bar icon by plugin",
"cancel": "Cancel",
"save": "Save",
"byeMenu": "Bye, Menu!",

"helloPlugin": "Hello, Plugin!",
"byePlugin": "Bye, Plugin!",
"showDialog": "Show dialog",
"getTab": "Print out all opened custom tabs in the debugger",
"removedData": "Data deleted",
"confirmRemove": "Confirm to delete the data in ${name}?",
"insertQuote": "Insert Emoji",
"removeSpace": "Remove Space",
"tips": "Format Painter ",
"enable": "Enabled Format Painter ",
"disable": "Disabled Format Painter "
Expand Down
10 changes: 0 additions & 10 deletions src/i18n/zh_CN.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
{
"addTopBarIcon": "使用插件添加一个顶栏按钮",
"cancel": "取消",
"save": "保存",
"byeMenu": "再见,菜单!",
"helloPlugin": "你好,插件!",
"byePlugin": "再见,插件!",
"showDialog": "弹出一个对话框",
"getTab": "在日志中打印出已打开的所有自定义页签",
"removedData": "数据已删除",
"confirmRemove": "确认删除 ${name} 中的数据?",
"insertQuote": "插入表情",
"removeSpace": "移除空格",
"tips": "格式刷",
"enable": "格式刷已启用",
"disable": "格式刷已关闭"
Expand Down
22 changes: 0 additions & 22 deletions src/index.scss

This file was deleted.

26 changes: 20 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
IProtyle,
Toolbar
} from "siyuan";
import "./index.scss";


const STORAGE_NAME = "menu-config";
const TAB_TYPE = "custom_tab";
Expand Down Expand Up @@ -64,8 +64,24 @@ export default class PluginSample extends Plugin {
// console.log("选中无样式文字");
}
this.formatPainterEnable = true;
document.body.dataset.formatPainterEnable ="true";
// console.log(this.formatData);
fetchPost("/api/notification/pushErrMsg", { "msg": this.i18n.enable, "timeout": 7000 });
this.protyle.toolbar.range.collapse(true);
// 关闭toolbar
// 选择所有具有 .protyle-toolbar 类的元素
const toolbarElements = document.querySelectorAll('.protyle-toolbar');

// 遍历选中的元素
toolbarElements.forEach(element => {
// 检查元素是否没有 .fn__none 类
if (!element.classList.contains('fn__none')) {
// 如果没有 .fn__none 类,则添加它
element.classList.add('fn__none');
}
});


}
}
}
Expand All @@ -89,11 +105,7 @@ export default class PluginSample extends Plugin {
// console.log(this.protyle.toolbar.range.toString());
// Apply the stored format to the selected text
// 如果都为空
if (!this.formatData) {
this.protyle.toolbar.setInlineMark(this.protyle, "clear", "range");
selection.removeAllRanges();
return;
}
this.protyle.toolbar.setInlineMark(this.protyle, "clear", "range");
if (this.formatData.datatype) {
this.protyle.toolbar.setInlineMark(this.protyle, this.formatData.datatype, "range");
}
Expand Down Expand Up @@ -151,7 +163,9 @@ export default class PluginSample extends Plugin {
if (event.key === "Escape") {
if (this.formatPainterEnable) {
this.formatPainterEnable = false;
document.body.dataset.formatPainterEnable = "false";
this.formatData = null;
document.body.style.cursor = "auto"; // 恢复默认光标
fetchPost("/api/notification/pushMsg", { "msg": this.i18n.disable, "timeout": 7000 });
}
}
Expand Down

0 comments on commit d79651d

Please sign in to comment.