翻了许久链滴帖子,找不到答案,请大佬来个解释。
不用插件,光凭 javascript 代码操作块后能否支持撤回操作
相关帖子
-
可以尝试自行写入块
protyle
的撤回栈。但是单纯 js 我连怎么访问这个都不知道。。。不过可以尝试一下
要不试试直接替换文字吧,说不定当成用户输入自己生成撤回操作了呢
1 回复 -
-
-
-
-
-
-
获取当前文档的 protyle
function getProtyle() { try { if(document.getElementById("sidebar")) return siyuan.mobile.editor.protyle; const currDoc = siyuan?.layout?.centerLayout?.children.map(item=>item.children.find(item=>item.headElement?.classList.contains('item--focus') && (item.panelElement.closest('.layout__wnd--active')||item.panelElement.closest('[data-type="wnd"]')))).find(item=>item); return currDoc?.model.editor.protyle; } catch(e) { console.error(e); return null; } }
1 回复 -
cxg318 •作者
function getProtyle() { return siyuan.layout.centerLayout.children[0].children[0].model.editor.protyle; }
谢谢大佬可以用的。我自己摸索了一个差不多的也能用。
参考自新的 API 或者回调函数的建议 · Issue #4491 · siyuan-note/siyuan (github.com)1 回复
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于