这些是在用V1的时候积累的JS,利用 悬浮窗 而不是窗口分割来进行工作,绝对是效率加倍的
而且每个节点都可以被悬浮窗打开,大大增加了大纲文件的可用性
很多节点就可以一直保持折叠状态,想看的时候可以直接悬浮窗口打开
然后到下一层依然如此
如果还有用V1的小伙伴,也可以试试这个JS,真的好用
/*--------------默认宽度(Chat写)----------*/
pluginManager.register("fixedDialogWidth", {
DEFAULT_DIALOG_WIDTH: 1001, // 设置默认宽度为 500px
after_hover_popup(_, dialog) {
dialog.$view.width(this.DEFAULT_DIALOG_WIDTH);
},
run() {}
});
/*-------折叠节点悬浮窗打开_____________________(与链接一样的操作方式,让折叠起来的节点的内容在悬浮窗中显示)-------*/
pluginManager.register("dlg_open", {
run() {
function close(i, n=200) {
e = !1,
setTimeout((()=>{
e || (t = !1,
P.hover.close(i.topicData.ky))
}
), n, "hide-hover-popup")
}
let ckey = "shiftKey ctrlKey";
const n = "[nel=dom].node-foldup";
mouseKeyEvt({
selector: n,
key: ckey,
async callback({pageX: n, pageY: a}) {
if (jutil.browser.isMobile())
return;
if ("no" === P.config.topictableHoverPreview && $(this).is("#topic-table-rows *"))
return;
if (await jsleep(10),
!this._mousemove)
return;
const s = this;
this._mousemove = !1,
e = !0;
let r = isEmpty(P.config.hoverSeconds) ? .15 : parseFloat(P.config.hoverSeconds);
ckey && (r = 0),
delayAction((async()=>{
const cur_node_ky = $(this).attr("ky");
var cur_node_data=P.memory.get(cur_node_ky);
P.hover.closeAll(this);
const m_dialog = P.hover.popup(cur_node_data);
if (!m_dialog)
return;
this.dialog = m_dialog;
let pos = "right-middle";
let port = $("[ky=" + cur_node_ky + "] .icon-circle.node-btn");
m_dialog.$view.snapTo(pos, port);
let right_side = m_dialog.$view.offset().left+150;
let left_side = m_dialog.$view.offset().left+20;
let cursor_x = (n>right_side)?right_side:(n<left_side)?left_side:n+5;
m_dialog.$view.offset({
left: cursor_x,
});
m_dialog.$view.offset().left + m_dialog.$view.width() > $(window).width() && m_dialog.$view.offset({
left: $(window).width() - m_dialog.$view.width()
});
const l = $(this).parents(".node,.topic-table-row")
, d = l.width() + l.offset().left;
m_dialog.$view.offset().left > d && m_dialog.$view.offset({
left: d
}),
until((()=>m_dialog.$view && m_dialog.$view.offset().top + m_dialog.$view.height() > $(window).height()), (()=>{
m_dialog.$view.offset({
top: $(window).height() - m_dialog.$view.height() - 15
})
}
), 3e3),
until((()=>m_dialog.$view && m_dialog.$view.offset().top < 0), (()=>{
m_dialog.$view.offset({
top: 3
})
}
), 3e3),
m_dialog.$view.attr("theKy", cur_node_data.ky),
m_dialog.$view.on("mouseenter", (function() {
e = !0;
}
)).on("mouseleave", (function() {
close(m_dialog);
}
))
}
), 1e3 * r)
}
}),
EVT(n, {
mousemove_dlgopenMoveTrue() {
$(this).css("cursor", "context-menu"),
this._mousemove = !0
},
mouseleave_dlgopenPreventPreview(e) {
t === e.target && (t = !1),
this.dialog && close(this.dialog)
},
mousedown_dlgopenHidePreview(e) {
t === e.target && (t = !1),
this.dialog && close(this.dialog, 0)
}
})
}
});
/*---------------------悬浮窗口打开--------------------*/
NHook.add({
//在菜单中添加“悬浮窗口打开”
after_nodemenu_run() {
plugin.menu.addItems("node", {
hoverPreview: {
label: "悬浮窗口打开",
icon2: "content_copy",
hotkey: "cmd+p",
action() {
plugin.hover.popup(this.nv.data, true);
}
}
});
},
//添加快捷键 Ctrl+P 或 Command+P 打开悬浮窗口
after_hotkey_run() {
plugin.hotkey.add("cmd+p:悬浮窗口打开", e => {
if ($(e.target).is(".node-text")) {
plugin.hover.popup(e.target.nv.data);
} else {
const nv = $("#roam-main-wrap .node-top:first").nv();
plugin.hover.popup(nv.data, true)
}
});
}
});
/*-------------------定时导出--------------------------*/
pluginManager.register("autoExport", {
autoExport01(){
plugin.exports.multi({
type: "fulljson"});
},
dsExport(){
//设置时间,默认导出时间是每小时导出一次
const n = 1;//如果需要修改导出时间,修改这里的1,1代表1小时,如果要改成3小时,就把1换成3;
const times =n * 3600 * 10000 ;
setInterval("plugin.autoExport.autoExport01()",times);
},
run(){
plugin.autoExport.dsExport();
}
})
/*-----------------------悬浮窗管理--------------------*/
NHook.add({
after_hotkey_run() {
plugin.hotkey.add("cmd+alt+x:关闭悬浮窗",(e=>{
for (let i in P.hover.dialogs){
P.hover.dialogs[i].close()
P.hover.close(i,1)
}
}
));
plugin.hotkey.add("cmd+alt+down:最小化悬浮窗",(e=>{
for (let i in P.hover.dialogs){
P.dlgmgr.minimize(P.hover.dialogs[i])
}
}
));
plugin.hotkey.add("cmd+alt+n:最大化悬浮窗",(e=>{
for (let i in P.hover.dialogs){
P.dlgmgr.maximize(P.hover.dialogs[i])
}
}
));
plugin.hotkey.add("cmd+alt+up:恢复悬浮窗",(e=>{
for (let i in P.hover.dialogs){
P.dlgmgr.restore(P.hover.dialogs[i])
}
}
));
}
});
/*-------------------临时折叠展开--------------------------*/
pluginManager.register("tmpFoldup", {
foldup(nv) {
const sh = nv.isShadow;
nv.isShadow = true;
nv.foldup();
nv.isShadow = sh;
},
expand(nv) {
const sh = nv.isShadow;
nv.isShadow = true;
nv.expand();
nv.isShadow = sh;
},
after_nodemenu_run() {
plugin.menu.addItems("node", {
tmpFoldup: {
label: "临时折叠",
icon: "minus",
cond() { return !this.nv.isFoldup() && !this.nv.$node.is(".node-foldup") },
action() { plugin.tmpFoldup.foldup(this.nv); }
},
tmpExpand: {
label: "临时展开",
icon: "plus",
cond() { return this.nv.isFoldup() || this.nv.$node.is(".node-foldup") },
action() { plugin.tmpFoldup.expand(this.nv); }
}
});
}
});
收藏的用户(0)
X
正在加载信息~
最新回复 (0)