自定义小部件

您所在的位置:网站首页 酷安神器小部件下载 自定义小部件

自定义小部件

2024-05-22 23:42| 来源: 网络整理| 查看: 265

可以在三个可以显示自定义内容的位置创建自定义窗口小部件。

位置是:

左窗格 中央窗格 右窗格 示例-字数小部件

创建类型为JS frontend的代码笔记,并为其添加widget标签。

/* * This defines a custom widget which displays number of words and characters in a current text note. * To be activated for a given note, add label 'wordCount' to the note, you can also make it inheritable and thus activate it for the whole subtree. * * See it in action in "Books" and its subtree. */ const TPL = ` Word count: ; Character count: chunk !== ''); let words; if (chunks.length === 1 && chunks[0] === '') { words = 0; } else { words = chunks.length; } const characters = chunks.join('').length; return {words, characters}; } async entitiesReloadedEvent({loadResults}) { if (loadResults.isNoteContentReloaded(this.noteId)) { this.refresh(); } } } module.exports = new WordCountWidget();

进行更改后,必须重新启动Trilium,以便可以重新构建布局。

示例截图

在底部,您可以看到生成的小部件:



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3