Comments (26)
reopenClosedFiles 多次尝试发现,反复打开,会有一部分失效,一部分成功,比如:第一次我打开 2 个 tab . 第二次打开确实保留了打开的历史记录。关闭后再第三次打开没了。而且很多情况下打开不生效. typora 设置是
打开指定目录
.
reopenClosedFiles 的功能是【打开上次退出时尚未关闭的标签页】,因此:
只有在 alt+F4、直接点击右上角【X】按钮等情况,才会生效。如果你是挨个关闭标签,直到关闭最后一个标签导致关闭 Typora,那么就会判定你已经关闭了所有标签,下次打开 Typora 时就不会恢复。
其实这个插件只有 20+ 行代码,我给你加了一下注释,你可以读一下
class reopenClosedFilesPlugin extends BaseCustomPlugin {
init = () => {
this.windowTabBarPlugin = null;
this.saveFile = this.utils.joinPath("./plugin/custom/plugins/reopenClosedFiles/remain.json");
}
hotkey = () => [this.config.hotkey]
process = () => {
this.utils.addEventListener(this.utils.eventType.allPluginsHadInjected, async () => {
this.windowTabBarPlugin = this.utils.getPlugin("window_tab");
if (!this.windowTabBarPlugin) return;
// 确保文件存在,不存在则创建
await this.ensureFile();
if (this.config.auto_reopen_when_init) {
// 刚打开 Typora 并且当前是空文件(并不是打开特定文件)时,恢复保存的标签
this.utils.loopDetector(() => File && !this.utils.getFilePath(), this.callback, 20, 200, false);
}
})
// 在关闭 Typora 之前,将现在的所有标签存起来
this.utils.addEventListener(this.utils.eventType.beforeUnload, () => this.windowTabBarPlugin && this.windowTabBarPlugin.saveTabs(this.saveFile));
}
ensureFile = async () => await this.utils.Package.FsExtra.ensureFile(this.saveFile);
callback = () => this.windowTabBarPlugin && this.windowTabBarPlugin.openSaveTabs(this.saveFile);
}
module.exports = {
plugin: reopenClosedFilesPlugin,
};
from typora_plugin.
你好,您的需求已经实现。
添加了 reopenClosedFiles 插件,其配置在 custom_plugin.toml 中:
############### reopenClosedFiles ###############
[reopenClosedFiles]
# 右键菜单中展示的名称
name = "打开上次退出时尚未关闭的标签页"
# 是否启用此自定义插件(此插件仅在window_tab启用时生效)
enable = true
# 插件配置
[reopenClosedFiles.config]
# 打开Typora自动打开
# 注意:只当双击typora.exe打开Typora时生效(打开特定文件时,自动打开上次退出时尚未关闭的标签页,明显不符合用户预期)
auto_reopen_when_init = true
# 快捷键
hotkey = ""
麻烦测试一下。有问题请在下面留言。
from typora_plugin.
注:如果你想快速打开之前关闭的文件,可以使用 toolbar 插件:
- ctrl + j
- 输入【his+空格+你要搜索的文件名】
- 上下键选中文件,最后回车即可。
toolbar 插件专为键盘党设计,所有的插件功能皆可通过键盘调用
from typora_plugin.
好的!
typora version: 1.7.5
typora_plugin version: 1.5.11
os : Windows 11
测试结果:
-
reopenClosedFiles 不生效, 将默认配置设置到user.toml 后重启, 打开两个文件tab后关闭typora 然后再打开无效果. 尝试过以管理员身份打开,以及基础尝试等均无效果.
from typora_plugin.
reopenClosedFiles 多次尝试发现,反复打开,会有一部分失效,一部分成功, 比如:第一次我打开2个tab . 第二次打开确实保留了打开的历史记录. 关闭后再第三次打开没了. 而且很多情况下打开不生效. typora设置是打开指定目录
.
from typora_plugin.
ctrl+j 搜索框是多功能搜索,目前支持功能:
- tab:切换标签页
- plu:使用插件
- his:打开最新文件
- ops:执行操作
- mode:切换模式
- theme:临时更换主题
暂时没有 has
这个功能。
使用方法:
例如:
- 在搜索框键入
plu sear
(注意中间有空格),就能搜索到关键字包含sear
的插件, - 在搜索框键入
plu
(注意包含空格),就会展示所有的插件 - 在搜索框键入
his docker
,就能搜索最近打开文件中,包含docker
的文件 - 其他 tab、ops、mode 同理
from typora_plugin.
from typora_plugin.
https://github.com/obgnail/typora_plugin/assets/28957658/c77f08c1-8828-4835-af2b-f576b6d63ce0
这个是我的演示录屏.
from typora_plugin.
一个个来,先看看 toolbar 插件。
- his 的功能是【重新打开最近关闭的文件】。你先搜索一下
his
(含空格),应该会弹出最近关闭的 20 个文件 - tab 的功能是:切换标签页(会过滤掉当前的标签)
- 麻烦试试 tab、plu、ops、mode、theme 功能有没有问题
from typora_plugin.
from typora_plugin.
一个个来,先看看 toolbar 插件。
- his 的功能是【重新打开最近关闭的文件】。你先搜索一下
his
(含空格),应该会弹出最近关闭的 20 个文件- tab 的功能是:切换标签页(会过滤掉当前的标签)
- 麻烦试试 tab、plu、ops、mode、theme 功能有没有问题
结果:
from typora_plugin.
reopenClosedFilesPlugin 的有时候不生效的问题我已经复现,并且解决了。
麻烦测一下 toolbar 有没有问题,问题解决后,我等会发一个 hotfix 版本。
from typora_plugin.
键入 his
没有弹出任何内容,是吗?
from typora_plugin.
键入
his
没有弹出任何内容,是吗?
是的,我确保了remain.json 里面有记录的情况下去 his doc
并没有提示检索结果
from typora_plugin.
reopenClosedFilesPlugin 的有时候不生效的问题,其实只要把
this.utils.loopDetector(() => File && !this.utils.getFilePath(), this.callback, 20, 200, false);
的 200 改成 2000,就解决了(200 是 timeout,200ms 太短了,Typora 来不及完成初始化页面导致的)
from typora_plugin.
reopenClosedFilesPlugin 的有时候不生效的问题,其实只要把
this.utils.loopDetector(() => File && !this.utils.getFilePath(), this.callback, 20, 200, false);的 200 改成 2000,就解决了(200 是 timeout,200ms 太短了,Typora 来不及完成初始化页面导致的)
验证了,确实是.
from typora_plugin.
@pro911 我知道了,你看一下你发的视频,his 会过滤掉当前的文件,你换一个标签就可以搜到了
class RecentFileTool extends baseToolInterface {
name = () => "his"
translate = () => "打开最近文件"
getRecentFile = async () => {
if (!File.isNode) return;
const file = await JSBridge.invoke("setting.getRecentFiles");
const fileJson = JSON.parse(file || "{}");
const files = fileJson["files"] || [];
const folders = fileJson["folders"] || [];
const result = [];
for (const file of files) {
if (file["path"]) {
result.push({showName: file.path, fixedName: file.path, meta: "file"});
}
}
for (const folder of folders) {
if (folder["path"]) {
result.push({showName: folder.path, fixedName: folder.path, meta: "folder"});
}
}
return result
}
search = async input => {
let files = await this.getRecentFile();
if (!files || files.length === 0) return;
const current = this.utils.getFilePath();
files = files.filter(file => file.showName !== current); // 小细节:去掉当前的文件
return this.baseSearch(input, files, ["fixedName"])
}
callback = (fixedName, meta) => {
if (meta === "file") {
this.utils.openFile(fixedName);
} else if (meta === "folder") {
this.utils.openFolder(fixedName);
}
}
}
from typora_plugin.
好像还是没有效果.
from typora_plugin.
from typora_plugin.
坏了,那应该是 Typora 1.7 改接口了 😂
我现在在 1.6 版本。麻烦能帮我测试一下吗?
- ctrl+j
- 键入
mode debug
- 选中【调试模式】
- 切换到【控制台】标签,看看有没有报错,
- 如果没有,在控制台输入
await JSBridge.invoke("setting.getRecentFiles")
看看有没有值输出
from typora_plugin.
重新打开软件,打开debug模式 好像没有报错,而且可以获取到文件和目录. 如图:
我在家晚上不知道是vpn繁忙还是网络运营商屏蔽,访问github老断网, 你注意下邮件,我可以给你发邮件.
from typora_plugin.
from typora_plugin.
@pro911 如果可以的话,麻烦邮件沟通
from typora_plugin.
花了些时间,改善了 toolbar 的查询体验,现在:
- 支持【交集查询】、【差集查询】,实现高精度查询
- 添加混合查找功能 all,实现高广度查询
举例:
his node learn
:查找最近打开的文件,要求文件标题【包含 node 和 learn 两个关键字】plu multi -search
:查找插件,要求插件名【包含 multi 关键字,但是不包含 search 关键字】tab -messing
:查找所有打开的标签页,要求标签页名称【不包含 messing 关键字】his close -win -mark 标签
:查找最近打开的文件,要求文件标题【包含 close、标签,不包含 win、mark】
from typora_plugin.
from typora_plugin.
好的,已经验证过了,都正常,只是his 检索中文的时候需要结束后再打一个空格才会匹配内容,没有其他的问题.
https://github.com/obgnail/typora_plugin/assets/28957658/e72af40d-4694-451d-a01b-83aa0899942f
from typora_plugin.
Related Issues (20)
- 上传文章到CSDN,提示开始上传后就没动静了,实际上未上传成功 HOT 6
- 希望添加一款大纲目录插件 HOT 5
- 按钮和更新功能异常 HOT 8
- callouts问题 HOT 3
- 资源管理插件不应该把.gitignore文件也放入 HOT 3
- window_tab 问题-切换tab页时内容没有切换 HOT 4
- 可否开发一个微信公众号文章一键复制功能插件 HOT 1
- 能否支持wavedrom HOT 5
- 标题序号问题 HOT 2
- 折叠代码是否能有记忆功能? HOT 1
- 想要一份主题CSS样式,我的主题很混乱 HOT 2
- [features request]图片标题显示(类似word中的题注功能) HOT 5
- 如何关闭` \ ` 自动出现标题提示 HOT 3
- 问题反馈:出现无法正常键入中文但是英文键入的情况。 HOT 7
- 是否可以在插件自动增加的图片序号中编辑相应的图片标题? HOT 13
- 为啥导出增强插件偶尔不见了? HOT 3
- 能添加自动补全功能吗(针对latex) HOT 2
- 找不到修改markdown格式警报的地方(软件内) HOT 2
- auto_number插件设置enable = false了还是还是会生效 HOT 3
- 能否提供typora代码块方案切换功能。 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typora_plugin.