笔记
0 篇文章
生成文档树列表项 seehttps://ld246.com/article/1741359650489pc 端//第一步调用 listDocsByPath 获取文档树文档信息//fetchSyncPost('/api/filetree/listDocsByPath',{notebook:'20240723175050-336994k',path:'/20240728220858-adaleye'})//第二
监听 websocketchannel(()=>{//默认渠道名,可以根据需要修改 constchannel='siyuan-runjs';//创建 socket 客户端 createSocketClient(channel);//当收到消息时被调用 functiononReceivedMessage(event){letrequest=parseJson(event.data);letresult='';tr
监听全屏和退出全屏 seehttps://ld246.com/article/1731698559408 通过监听 window.siyuan.editorIsFullscreen 对象的变化实现//定义一个可观察的属性 window.siyuan._editorIsFullscreen=window.siyuan.editorIsFullscreen||false;Object.defineProperty
监听思源 main websocket
监听思源 mainwebsocket//seehttps://github.com/siyuan-note/siyuan/blob/1710194122495d282a51650441d9fc80804561bb/app/src/layout/Model.ts//seehttps://github.com/siyuan-note/siyuan/blob/1710194122495d282a516504
监听思源退出事件 seehttps://ld246.com/article/1734263645595//调用示例,当 callback 返回 true 时退出,返回 false 时取消退出 functionsleep(ms){returnnewPromise(resolve=>setTimeout(resolve,ms));}listenExit(async()=>{console.log('waiting');
监听打开 URL 事件 seehttps://github.com/siyuan-note/siyuan/blob/5129ad926a21176a352cf5f630e0651011bf9c83/app/src/boot/onGetConfig.ts#L167require('electron').ipcRenderer.on('siyuan-open-url',(event,url)=>{consol
监控元素出现 functionobserveElementExist(selector,callback){consthandleMutations=(mutationsList,observer)=>{for(letmutationofmutationsList){if(mutation.type==='childList'){mutation.addedNodes.forEach(node=>{i
编辑器 toolbar 被添加事件 toolbar 被添加事件(async()=>{observeToolbar((el)=>{console.log(el,'toolbar');});//监听 toolbar 被添加 functionobserveToolbar(callback){//创建一个观察者实例并传入回调函数 constobserver=newMutationObserver((mutationsLis
获取光标所在元素又名获取鼠标所在元素 functiongetCursorElement(){constselection=window.getSelection();if(selection.rangeCount>0){constrange=selection.getRangeAt(0);//获取选择范围的起始位置所在的节点 conststartContainer=range.startContaine
获取选中文字所在的元素?如果跨多个元素呢?在 JavaScript 中获取选中文字所在的元素可以通过 window.getSelection()方法来实现。此方法返回一个 Selection对象,该对象提供了有关当前文档中选定文本的信息。如果选中的文本跨越了多个元素,可以通过 Selection对象的 getRangeAt()方法来获取选定范围的信息。getRangeAt()方法返回一个 Range对
获取选中文本获取选中文本可以通过 JavaScript 的 window.getSelection()方法来实现。这个方法返回一个 Selection对象,它包含了当前文档中选定的文本信息。你可以从这个对象中获取选定的范围,并从中提取出选定的文本。下面是一个简单的示例,展示了如何获取用户选定的文本,并将其输出到控制台或页面上的某个元素中:HTML 示例代码 <!DOCTYPEhtml><htmllang="
行内自定义元素和属性
行内自定义元素和属性 seehttps://github.com/siyuan-note/siyuan/issues/13325 关联:块自定义元素和属性只能用 span,且不能嵌套,只能叠加自定义属性 custom-xxx 和 data-type 值修改或生成后,需要调用 input 事件触发比如:letmemoELement=document.querySelector(`span[data-id="${ne
请求 apifunctionfetchGet(url,callback){fetch(url).then((response)=>{if(response.headers.get("content-type")?.indexOf("application/json")>-1){returnresponse.json();}else{returnresponse.text();}}).then((res
调用 Lute 的正确方式 seehttps://github.com/siyuan-note/siyuan/issues/14310seehttps://ld246.com/article/1741527865453调用方式:getLute().Md2BlockDOM(xxxxx);封装函数如下:functiongetLute(){constsetLute=(options)=>{constlute
通过监听 siyuan.editorIsFullscreen 对象变化判断是否全屏//定义一个可观察的属性 window.siyuan._editorIsFullscreen=window.siyuan.editorIsFullscreen||false;Object.defineProperty(window.siyuan,'editorIsFullscreen',{get:function(){ret
插件开发插件开发快速指南 https://docs.siyuan-note.club/zh-Hans/guide/plugin/sy-plugin-dev-quick-start.html 后端 api 接口 https://github.com/siyuan-note/siyuan/blob/master/kernel/api/router.go
css 图片颜色反转 filter:invert(100%);
css 大全 css 选择 xlink:href 属性 seehttps://ld246.com/article/1734427196426@namespacexlink'http://www.w3.org/1999/xlink';.protyle-breadcrumb__item:has(use[xlink|href*=iconListItem]).protyle-breadcrumb__text{displ
js 获取鼠标所在元素要确定鼠标当前位于哪个元素内,JavaScript 提供了几种方法。你可以通过监听 mousemove事件并在事件处理函数中检查 event.target来得知鼠标所在的元素。此外,还可以使用 document.elementFromPoint方法来查找特定坐标下的最顶层元素。以下是两种常见的实现方式:使用 mousemove事件你可以为整个文档或某个容器添加一个 mousemove
修改新窗口大小 seehttps://github.com/siyuan-note/siyuan/blob/914c7659388e645395e70224f0d831950275eb05/app/src/window/openNewWindow.ts#L21seehttps://gitee.com/wish163/mysoft/blob/main/%E6%80%9D%E6%BA%90/%E6%80%
记录精彩的程序人生
开始使用
分类
标签