Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update index.js #48

Merged
merged 1 commit into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
3. 打开文件夹 A,将源码的 plugin 文件夹粘贴进该文件夹下。
4. 打开文件 `A/window.html`。搜索文件内容 `<script src="./app/window/frame.js" defer="defer"></script>` 或者 `<script src="./appsrc/window/frame.js" defer="defer"></script>`,并在 **后面** 加入 `<script src="./plugin/index.js" defer="defer"></script>`。保存。
5. 重启 Typora。
6. 验证:点击鼠标右键,弹出右键菜单栏,如果能看到【启动插件】栏目,说明一切顺利。
6. 验证:在正文区域点击鼠标右键,弹出右键菜单栏,如果能看到【启动插件】栏目,说明一切顺利。



Expand Down
7 changes: 6 additions & 1 deletion plugin/collapse_paragraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,12 @@
list.forEach(ele => trigger(ele, collapsed));
})

module.exports = {config};
module.exports = {
config,
Meta: {
"trigger": trigger,
}
};

console.log("collapse_paragraph.js had been injected");
})()
23 changes: 21 additions & 2 deletions plugin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,108 +3,126 @@ window.onload = () => {
global._plugins = [
{
name: "标签页管理",
fixed_name: "window_tab",
src: "./plugin/window_tab.js",
enable: true,
clickable: false,
},
{
name: "全局多关键字搜索",
fixed_name: "search_multi",
src: "./plugin/search_multi.js",
enable: true,
clickable: true,
},
{
name: "多关键字高亮",
fixed_name: "multi_highlighter",
src: "./plugin/multi_highlighter/index.js",
enable: false,
clickable: true,
},
{
name: "表格大小调整",
fixed_name: "resize_table",
src: "./plugin/resize_table.js",
enable: true,
clickable: false,
},
{
name: "只读模式",
fixed_name: "read_only",
src: "./plugin/read_only.js",
enable: true,
clickable: true,
},
{
name: "文档大纲",
fixed_name: "outline",
src: "./plugin/outline.js",
enable: true,
clickable: true,
},
{
name: "文段截断",
fixed_name: "truncate_text",
src: "./plugin/truncate_text.js",
enable: true,
clickable: true,
},
{
name: "图片大小调整",
fixed_name: "resize_image",
src: "./plugin/resize_image.js",
enable: true,
clickable: false,
},
{
name: "命令行环境",
fixed_name: "commander",
src: "./plugin/commander.js",
enable: true,
clickable: true,
},
{
name: "代码块增强",
fixed_name: "fence_enhance",
src: "./plugin/fence_enhance.js",
enable: true,
clickable: false,
},
{
name: "一键到顶",
fixed_name: "go_top",
src: "./plugin/go_top.js",
enable: true,
clickable: true,
},
{
name: "文件计数",
fixed_name: "file_counter",
src: "./plugin/file_counter.js",
enable: true,
clickable: false,
},
{
name: "章节折叠",
fixed_name: "collapse_paragraph",
src: "./plugin/collapse_paragraph.js",
enable: true,
clickable: false,
},
{
name: "中英文混排优化",
fixed_name: "md_padding",
src: "./plugin/md_padding/index.js",
enable: true,
clickable: true,
},
{
name: "mermaid替换",
fixed_name: "mermaid_replace",
src: "./plugin/mermaid_replace/index.js",
enable: true,
enable: false,
clickable: false,
},
{
name: "自动编号",
fixed_name: "auto_number",
src: "./plugin/auto_number.js",
enable: true,
clickable: false,
},
{
name: "右键菜单",
fixed_name: "right_click_menu",
src: "./plugin/right_click_menu.js",
enable: true,
clickable: false,
},
{
name: "测试专用",
fixed_name: "test",
src: "./plugin/test.js",
enable: false,
clickable: false,
Expand All @@ -123,10 +141,11 @@ window.onload = () => {
const promise = new Promise((resolve, reject) => {
_fs.access(filepath, err => {
if (!err) {
const {config, Call, CallArgs} = reqnode(filepath);
const {config, Call, CallArgs, Meta} = reqnode(filepath);
plugin.config = config || null;
plugin.call = Call || null;
plugin.call_args = CallArgs || null;
plugin.meta = Meta || null;
resolve(plugin);
} else {
plugin.enable = false;
Expand Down