Skip to content

Commit

Permalink
Merge pull request #689 from obgnail/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
obgnail authored Jul 30, 2024
2 parents 3141b1b + 53604a4 commit d39a5a6
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 28 deletions.
18 changes: 13 additions & 5 deletions plugin/auto_number.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ class autoNumberPlugin extends BasePlugin {

this.base_css = `
#write { counter-reset: write-h2 Figures Tables Fences; }
#write > h1 { counter-reset: write-h2 Figures Tables Fences; }
#write > h2 { counter-reset: write-h3 Figures Tables Fences; }
#write > h1 { counter-reset: write-h2; }
#write > h2 { counter-reset: write-h3; }
#write > h3 { counter-reset: write-h4; }
#write > h4 { counter-reset: write-h5; }
#write > h5 { counter-reset: write-h6; }
Expand Down Expand Up @@ -138,7 +138,7 @@ class autoNumberPlugin extends BasePlugin {

const image_content = `
counter-increment: Figures;
content: "${this.config.NAMES.image} " counter(write-h2) "-" counter(Figures);
content: "${this.config.NAMES.image} " counter(Figures) " " attr(data-alt);
font-family: ${this.config.FONT_FAMILY};
display: block;
text-align: ${this.config.ALIGN};
Expand All @@ -150,7 +150,7 @@ class autoNumberPlugin extends BasePlugin {
this.table_css = `
#write .table-figure::after {
counter-increment: Tables;
content: "${this.config.NAMES.table} " counter(write-h2) "-" counter(Tables);
content: "${this.config.NAMES.table} " counter(Tables);
font-family: ${this.config.FONT_FAMILY};
display: block;
text-align: ${this.config.ALIGN};
Expand All @@ -163,7 +163,7 @@ class autoNumberPlugin extends BasePlugin {
}
#write .md-fences::after {
counter-increment: Fences;
content: "${this.config.NAMES.fence} " counter(write-h2) "-" counter(Fences);
content: "${this.config.NAMES.fence} " counter(Fences);
position: absolute;
width: 100%;
text-align: ${this.config.ALIGN};
Expand Down Expand Up @@ -195,6 +195,14 @@ class autoNumberPlugin extends BasePlugin {
if (this.config.ENABLE_WHEN_EXPORT) {
new exportHelper(this).process();
}
if (this.config.ENABLE_IMAGE && this.config.SHOW_IMAGE_NAME) {
this.utils.eventHub.addEventListener(this.utils.eventHub.eventType.fileEdited, () => {
const images = this.utils.entities.querySelectorAllInWrite(".md-image:not([data-alt]) > img");
for (const image of images) {
image.parentElement.dataset.alt = image.getAttribute("alt");
}
})
}
}

removeStyle = () => this.utils.removeStyle(this.css_id);
Expand Down
14 changes: 7 additions & 7 deletions plugin/global/settings/custom_plugin.default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -829,11 +829,11 @@ auto_open = true
############### scrollBookmarker ###############
[scrollBookmarker]
# 右键菜单中展示的名称
name = "书签管理器"
name = "书签管理"
# 是否启用此二级插件(此插件仅在window_tab插件启用时生效)
enable = true
# 是否在右键菜单中隐藏
hide = false
hide = true
# 在右键菜单中的出现顺序(越大越排到后面,允许负数)
order = 1
# 插件配置
Expand Down Expand Up @@ -903,11 +903,11 @@ group_lines = 3
############### imageReviewer ###############
[imageReviewer]
# 右键菜单中展示的名称
name = "图片查看器"
name = "图片查看"
# 是否启用此二级插件
enable = true
# 是否在右键菜单中隐藏
hide = false
hide = true
# 在右键菜单中的出现顺序(越大越排到后面,允许负数)
order = 1
# 插件配置
Expand Down Expand Up @@ -1055,7 +1055,7 @@ name = "格式规范检测"
# 是否启用此二级插件
enable = true
# 是否在右键菜单中隐藏
hide = false
hide = true
# 在右键菜单中的出现顺序(越大越排到后面,允许负数)
order = 1
# 插件配置
Expand Down Expand Up @@ -1108,7 +1108,7 @@ try_fix_lint_error = ["MD031", "MD047"]
# 右键菜单中展示的名称
name = "打开上次退出时尚未关闭的标签页"
# 是否启用此二级插件(此插件仅在window_tab插件启用时生效)
enable = true
enable = false
# 是否在右键菜单中隐藏
hide = false
# 在右键菜单中的出现顺序(越大越排到后面,允许负数)
Expand Down Expand Up @@ -1307,7 +1307,7 @@ proxy = ""
# 自动升级有两个策略:
# - 策略一:打开Typora一段时间后,执行一次升级流程
# - 策略二:每隔一段时间,执行一次升级流程
auto_update = true
auto_update = false
# 策略一(单位:ms,若<0,则不使用此策略)
start_update_interval = 300000 # 1000 * 60 * 5
# 策略二(单位:ms,若<0,则不使用此策略)
Expand Down
5 changes: 4 additions & 1 deletion plugin/global/settings/settings.default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,9 @@ ENABLE_IMAGE = true
ENABLE_FENCE = true
# 导出时运用样式
ENABLE_WHEN_EXPORT = true
# 展示图片的名称(若ENABLE_IMAGE为false,此选项失效)
# 注意:不建议开启此选项,会消耗较多资源
SHOW_IMAGE_NAME = false
# 编号的下标使用的字体
FONT_FAMILY = "monospace"
# 编号的下标的位置:left/right/center
Expand Down Expand Up @@ -1109,7 +1112,7 @@ LIST = [
############### pie_menu ###############
[pie_menu]
# 是否启用插件
ENABLE = true
ENABLE = false
# 在右键菜单中展示的名称
NAME = "圆盘菜单"
# 是否在右键菜单中可点击
Expand Down
10 changes: 5 additions & 5 deletions plugin/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ class helpPlugin extends BasePlugin {
about = () => {
const style = "background: linear-gradient(to right, rgba(79, 192, 141, 0.5), rgba(79, 192, 141, 0.5)) no-repeat bottom; background-size: 100% 40%; padding: 2px;"
const share = {
Weibo: "https://service.weibo.com/share/share.php?language=zh_cn&searchPic=true&title=",
Twitter: "http://twitter.com/intent/tweet?text=",
Telegram: "https://telegram.me/share/url?url=https://github.com/obgnail/typora_plugin&title=",
Twitter: "http://twitter.com/intent/tweet?text=",
Weibo: "https://service.weibo.com/share/share.php?language=zh_cn&searchPic=true&title=",
}
const p = [
`<span style="${style}">醉后不知天在水,满船清梦压星河</span>`,
`<span style="${style}">醉后不知天在水,满船清梦压星河</span>`,
"感谢您使用 Typora Plugin。我在有限的时间里设计了这款插件,虽然它并不那么美好,但正努力前行。",
"本项目遵循 MIT 协议,请自由地享受和参与开源。如果您有任何反馈或建议,可以在 <a class='plu-github'>Github</a>、<a class='plu-appinn'>Appinn</a>、<a class='plu-email'>Email</a > 找到我。",
`欢迎通过 ${Object.keys(share).map(site => `<a class="plu-share" data-site="${site}">${site}</a>`).join("、")} 推荐给你志同道合的朋友使用。`
"本项目遵循 MIT 协议,请自由地享受和参与开源。如果您有任何反馈或建议,请在 <a class='plu-github'>Github</a>、<a class='plu-appinn'>Appinn</a>、<a class='plu-email'>Email</a > 找到我。若本项目对您有用,欢迎 ⭐",
`欢迎通过 ${Object.keys(share).map(site => `<a class="plu-share" data-site="${site}">${site}</a>`).join("、")} 推荐给志同道合的朋友使用。`
]
const label = p.map(e => `<p style="font-size: 1.1em">${e}</p>`).join("");
const onclick = ev => {
Expand Down
10 changes: 0 additions & 10 deletions plugin/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
/*
本项目默认开启自动升级功能,您如果想修改代码,请按如下步骤关闭自动升级功能(自动升级会替换plugin目录,会把您的修改全部撤销掉)
1. 打开文件./plugin/global/settings/custom_plugin.user.toml
2. 添加如下内容,并保存:
[pluginUpdater]
[pluginUpdater.config]
auto_update = false
note: 尽量不要使用ES2015(ES6)以后的特性,因为低版本Typora不兼容
*/
window.addEventListener("load", () => {
const { dirname, __dirname, reqnode } = global;
const dir = dirname || __dirname;
Expand Down

0 comments on commit d39a5a6

Please sign in to comment.