思源笔记 0 篇文章

RunJS 使用示例

//democonsole.log(siyuan);console.log(plugin);console.log(client);console.log(thisBlock);asyncfunctionmain(){constresponse=awaitclient.pushMsg({msg:"Thisisanotificationmessage",timeout:7000,});console.

刷新文档

seehttps://github.com/siyuan-note/siyuan/issues/10243protyle.reloadthis.protyleSlash=[{filter:["insertemoji\u{1F60A}","\u63D2\u5165\u8868\u60C5\u{1F60A}","crbqwx"],html:`<divclass="b3-list-item__first"

在文档树中定位文档

(siyuan?.mobile?.docks?.file||siyuan?.mobile?.files||siyuan.layout.leftDock.data.file).selectItem(notebookId,path)比如(siyuan?.mobile?.docks?.file||siyuan?.mobile?.files||siyuan.layout.leftDock.data.file

根据 paths 展开文件夹

//根据 paths 展开文件夹 functionexpandFolderByPaths(paths,box){//遍历 paths 并展开对应的文件夹 paths.forEach(asyncpath=>{//将路径按/分割,获取每个层级的 node-idconstparts=path.split('/');constfolderIds=parts.slice(1,-1);//最后一个是文件,不需要展开//逐层查

数据库使用场景

seehttps://ld246.com/article/1744171314503 数据库功能简介数据库功能有什么使用场景吗?任务管理数据库模版分享思源笔记数据库使用新思路:谈自上而下管理与自下而上积累基于思源笔记的数据库使用分享(附模板)突然发现数据库可以完全替代 Todo!太棒了!将反向链接和数据库结合的尝试大家平时是如何使用数据库的?数据库使用新方法-任务时间追踪‍

更新文档全文 api

seehttps://ld246.com/article/1744145263614 获取文档 kramdown 全文 awaitfetchSyncPost('/api/block/getBlockKramdown',{id:'文档 id'})更新文档全文(有{:id=""}在 id 不会变)awaitfetchSyncPost('/api/block/updateBlock',{"dataType":"mark

查看最新版

githubhttps://github.com/siyuan-note/siyuan/releases 链滴 https://ld246.com/member/siyuan/articles‍

调用 api 操作块支持撤回(使用 Transaction)

seehttps://ld246.com/article/1736616348929 思源笔记默认的块操作 api 不支持撤回,需要额外使用 Transaction 来实现撤回操作只更新一个块 updateTransaction​awaitupdateBlock('dom',updatedDom,blockId);protyle.getInstance().updateTransaction(blockId,u

带块 id 的剪切

带块 id 的剪切
seehttps://ld246.com/article/1744246860602 功能说明块右键菜单增加剪切块操作,剪切时不会丢掉块的 id(自带剪切会丢掉块 id)。本质还是移动操作,只不过比自带移动操作方便,支持具体移动到哪个位置(自带移动只能指定移动到哪个文档)。支持手机版不会出现重复 ID 使用说明注意:只能在块菜单中操作(你的右键可能不是块菜单)缺点:不支持撤销(官方移动也不支持撤销)代码 htt

上传文件到链滴图床

asyncfunctiongetFile(path){returnfetch("/api/file/getFile",{method:"POST",headers:{"Content-Type":"application/json",},body:JSON.stringify({path,}),}).then((response)=>{if(response.ok){//返回 Blob 对象而不是文本 r