Skip to content

Commit

Permalink
Merge pull request #148 from obgnail/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
obgnail authored Sep 7, 2023
2 parents 443a8bd + b7c3441 commit 15a6868
Show file tree
Hide file tree
Showing 11 changed files with 842 additions and 33 deletions.
46 changes: 29 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,24 @@
| 8 | fence_enhance | 一键复制代码,折叠代码 ||
| 9 | commander | 命令行环境 ||
| 10 | mindmap | 根据文档大纲一键生成思维导图 ||
| 11 | read_only | 只读模式 ||
| 12 | blur | 模糊模式 ||
| 13 | kanban | 看板 ||
| 14 | file_counter | 显示目录下的文件数 ||
| 15 | outline | 以表格、图片、代码块形式的大纲 ||
| 16 | auto_number | 章节、表格、图片、代码块等自动编号 ||
| 17 | datatables | 表格增强(搜索、过滤、分页、排序等) ||
| 18 | resize_table | 调整表格行高列宽 ||
| 19 | resize_image | 调整图片显示大小 ||
| 20 | export_enhance | 导出 html 时避免图片丢失 ||
| 21 | go_top | 一键到文章顶部 ||
| 22 | truncate_text | 暂时隐藏内容,提高大文件渲染性能 ||
| 23 | custom | 用户自定义命令(高级) ||
| 24 | plugin_updater | 一键更新插件 ||
| 25 | right_click_menu | 右键菜单统一管理、调用插件 ||
| 26 | mermaid_replace | 替换 mermaid 组件 | × |
| 27 | old_window_tab | 标签页管理(已废弃) | × |
| 11 | markmap | 提供 markmap 支持 ||
| 12 | read_only | 只读模式 ||
| 13 | blur | 模糊模式 ||
| 14 | kanban | 看板 ||
| 15 | file_counter | 显示目录下的文件数 ||
| 16 | outline | 以表格、图片、代码块形式的大纲 ||
| 17 | auto_number | 章节、表格、图片、代码块等自动编号 ||
| 18 | datatables | 表格增强(搜索、过滤、分页、排序等) ||
| 19 | resize_table | 调整表格行高列宽 ||
| 20 | resize_image | 调整图片显示大小 ||
| 21 | export_enhance | 导出 html 时避免图片丢失 ||
| 22 | go_top | 一键到文章顶部 ||
| 23 | truncate_text | 暂时隐藏内容,提高大文件渲染性能 ||
| 24 | custom | 用户自定义命令(高级) ||
| 25 | plugin_updater | 一键更新插件 ||
| 26 | right_click_menu | 右键菜单统一管理、调用插件 ||
| 27 | mermaid_replace | 替换 mermaid 组件 | × |
| 28 | old_window_tab | 标签页管理(已废弃) | × |

> 如果各位有其他的需求,或发现 BUG,欢迎提 issue。如果能给我颗 star ⭐ 就更好了 : )
Expand Down Expand Up @@ -316,6 +317,17 @@ const BUILTIN = [



### markmap:提供 markmap 支持

使用方式:

- 方式一:右键菜单 -> 启用插件 -> markmap
- 方式二:直接点击右下角的 markmap 按钮

![markmap](assets/markmap.gif)



### read_only:只读模式

只读模式下文档不可编辑。
Expand Down
Binary file added assets/markmap.gif
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/datatables/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class datatablesPlugin extends global._basePlugin {
}

html = () => {
this.utils.insertScript("./plugin/datatables/resource/datatables.min.js", () => {
this.utils.insertScript("./plugin/datatables/resource/datatables.min.js").then(() => {
console.log("datatables.min.js has inserted")
})
}
Expand Down
56 changes: 53 additions & 3 deletions plugin/global/core/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ class utils {
quickOpenNode.parentNode.insertBefore(div, quickOpenNode.nextSibling);
}

static insertScript = (filepath, then) => {
static insertScript = filepath => {
const jsFilepath = this.joinPath(filepath);
$.getScript(`file:///${jsFilepath}`).then(then);
return $.getScript(`file:///${jsFilepath}`);
}

static getUUID() {
Expand Down Expand Up @@ -257,13 +257,63 @@ class utils {
truncatePlugin && truncatePlugin.rollback(target);
}

static dragFixedModal = (handleElement, moveElement, withMetaKey = true) => {
static resizeFixedModal = (
handleElement, resizeElement,
resizeWidth = true, resizeHeight = true,
onMouseDown = null, onMouseMove = null, onMouseUp = null
) => {
// 鼠标按下时记录当前鼠标位置和 div 的宽高
const radix = 10;
let startX, startY, startWidth, startHeight;
handleElement.addEventListener("mousedown", ev => {
startX = ev.clientX;
startY = ev.clientY;
startWidth = parseInt(document.defaultView.getComputedStyle(resizeElement).width, radix);
startHeight = parseInt(document.defaultView.getComputedStyle(resizeElement).height, radix);
onMouseDown && onMouseDown();
document.addEventListener("mousemove", mousemove);
document.addEventListener("mouseup", mouseup);
ev.stopPropagation();
ev.preventDefault();
}, true);

// 鼠标移动时计算宽高差值并设置 div 的新宽高
function mousemove(e) {
requestAnimationFrame(() => {
let deltaX = e.clientX - startX;
let deltaY = e.clientY - startY;
if (onMouseMove) {
const result = onMouseMove(deltaX, deltaY);
if (result) {
deltaX = result.deltaX;
deltaY = result.deltaY;
}
}
if (resizeWidth) {
resizeElement.style.width = startWidth + deltaX + "px";
}
if (resizeHeight) {
resizeElement.style.height = startHeight + deltaY + "px";
}
})
}

// 鼠标松开时取消事件监听
function mouseup() {
document.removeEventListener("mousemove", mousemove);
document.removeEventListener("mouseup", mouseup);
onMouseUp && onMouseUp();
}
}

static dragFixedModal = (handleElement, moveElement, withMetaKey = true, onMouseDown = null) => {
handleElement.addEventListener("mousedown", ev => {
if (withMetaKey && !this.metaKeyPressed(ev) || ev.button !== 0) return;
ev.stopPropagation();
const rect = moveElement.getBoundingClientRect();
const shiftX = ev.clientX - rect.left;
const shiftY = ev.clientY - rect.top;
onMouseDown && onMouseDown();

const onMouseMove = ev => {
if (withMetaKey && !this.metaKeyPressed(ev) || ev.button !== 0) return;
Expand Down
12 changes: 12 additions & 0 deletions plugin/global/settings/settings.default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,18 @@ NAME = "思维导图"
CLICKABLE = true


############### markmap ###############
[markmap]
# 启用插件
ENABLE = true
# 在右键菜单中展示的名称
NAME = "markmap"
# 是否在右键菜单中可点击
CLICKABLE = true
# 在左下角添加一个快捷按钮
USE_BUTTON = true


############### auto_number ###############
[auto_number]
# 启用插件
Expand Down
22 changes: 12 additions & 10 deletions plugin/go_top.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ class goTopPlugin extends global._basePlugin {
position: fixed;
right: 30px;
bottom: 50px;
z-index: 99999;
z-index: 9998;
font-size: 28px;
text-align: center;
color: ${this.config.COLOR};
}
#${this.config.DIV_ID} .roll-item {
#${this.config.DIV_ID} .action-item {
width: 35px;
height: 35px;
margin-top: 10px;
Expand All @@ -21,11 +21,11 @@ class goTopPlugin extends global._basePlugin {
border-radius: 4px;
}
#${this.config.DIV_ID} .roll-item:hover {
#${this.config.DIV_ID} .action-item:hover {
background-color: ${this.config.HOVER_COLOR};
}
#${this.config.DIV_ID} .roll-item .fa {
#${this.config.DIV_ID} .action-item i {
display: block;
line-height: 35px;
}
Expand All @@ -37,19 +37,21 @@ class goTopPlugin extends global._basePlugin {
const wrap = document.createElement("div");
wrap.id = this.config.DIV_ID;
wrap.innerHTML = `
<div class="roll-item" action="go-top"><i class="fa fa-angle-up"></i></div>
<div class="roll-item" action="go-bottom"><i class="fa fa-angle-down"></i></div>`;
<div class="action-item" action="go-top"><i class="fa fa-angle-up"></i></div>
<div class="action-item" action="go-bottom"><i class="fa fa-angle-down"></i></div>`;
this.utils.insertDiv(wrap);
}

process = () => {
document.getElementById(this.config.DIV_ID).addEventListener("click", ev => {
const target = ev.target.closest(".roll-item");
const target = ev.target.closest(".action-item");
if (target) {
const action = target.getAttribute("action");
this.call(action);
ev.preventDefault();
ev.stopPropagation();
if (action) {
this.call(action);
ev.preventDefault();
ev.stopPropagation();
}
}
});
}
Expand Down
Loading

0 comments on commit 15a6868

Please sign in to comment.