• Stars
    star
    144
  • Rank 255,590 (Top 6 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 3 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Generate a TOC of any page anywhere to quickly access the page's content.

中文 | English

logseq-plugin-tocgen

生成任一页面/块的目录,通过它你可以快速访问页面/块内容。同时提供了滚动回页面顶部和底部的功能。注意目录是根据块层级来生成的。

功能展示

  • 自动与内容同步
  • Shift 点击可在侧边栏打开
  • 多种展开收起方式
  • 按住 Alt 点击箭头可展开收起全部子孙
  • 实时追踪编辑位置并在目录上高亮展示
  • 完美支持嵌入块、嵌入页
  • 可在目录上通过拖拽来管理文档结构
  • 跟随主编辑页面变化的动态目录
  • 会跟随页面内容滚动的固定高度目录
  • 通过页面菜单或工具栏快速在侧边栏打开目录
  • 快速回到页面顶部、底部的按钮(可选)
  • 切换页面时自动回到顶部或页面离开时的位置(可选设置)

具体设置可打开插件设置查看。

使用展示

场景零,右键菜单

image

via_context_menu.mp4

场景一,动态目录

demo.mp4

场景二,页面内目录

demo

支持生成嵌入块/页面的目录

demo

上面的演示用到了 Another Embed 插件,推荐大家尝试。缩短 namespace 的效果的脚本是我写的 custom.js 的一部分,代码可在这里获取。

使用示例

如果你想生成一个随当前浏览页面变动而变动的 TOC,你可以传*作为页面名。推荐。

{{renderer :tocgen2, *}}

指定目录高度,这样目录内容就会随页面内容滚动了。高度单位符合CSS规范。`auto` 代表不固定高度,高度取决于内容。
{{renderer :tocgen2, *, auto}}
{{renderer :tocgen2, *, 300px}}
为块所在的页面生成TOC。
{{renderer :tocgen2}}
{{renderer :tocgen2, [[]]}}

为某一页面创建一个TOC,可以用 "[[" 辅助查找想要的页面。
{{renderer :tocgen2, pagename}}
{{renderer :tocgen2, [[pagename]]}}

你也可以为某一页面块创建一个TOC,直接将块引用粘贴进来就好。
{{renderer :tocgen2, ((block-reference))}}

可以指定要生成几级。
{{renderer :tocgen2, [[]], auto, 2}}
{{renderer :tocgen2, [[pagename]], auto, 2}}
{{renderer :tocgen2, ((block-reference)), auto, 2}}

如果你想在TOC中只包含H1-Hn(h)这种heading,即markdown的`#`至`######`,
或者指定任何内容都可以作为heading使用(any),
那么你可以再通过一个参数来详细指定。
{{renderer :tocgen2, [[page name]], auto, 1, h}}
{{renderer :tocgen2, [[page name]], auto, 1, any}}

如果有某一块你不想列入 TOC 之中,那么你可以通过为其指定一个 toc:: no 块属性。

自定义样式

你可以通过以下几个 CSS 类来自定义样式,kef-tocgen-page 对应页面,kef-tocgen-block 对应块,.kef-tocgen-active-block 对应编辑中的块。参照 Logseq 自定义样式的文档操作,将内容放在custom.css中即可。

.kef-tocgen-page {
  cursor: pointer;
  line-height: 2;
}
.kef-tocgen-block {
  line-height: 1.7;
}
.kef-tocgen-active-block {
  font-size: 1.1em;
  font-weight: 600;
}

你也可以通过kef-tocgen-noactivepage来自定义动态 TOC(见使用示例)在没有检测到活动页面时的内容与样式。

.kef-tocgen-noactivepage::before {
  content: "🈚️";
}

Buy me a coffee

如果您认为我所开发的软件对您有所帮助,并且愿意给予肯定和支持,不妨扫描下方的二维码进行打赏。感谢您的支持与关注。

wx ap

More Repositories

1

logseq-plugin-wrap

Create your own wrappings with optional key bindings for selected text, a set of useful defaults is also provided.
JavaScript
109
star
2

logseq-plugin-media-ts

This plugin can generate timestamps for video, audio and Bilibili video, it takes you to the corresponding video/audio position when clicked.
JavaScript
90
star
3

logseq-plugin-luckysheet

Embed Luckysheet (spreadsheet) into Logseq.
JavaScript
90
star
4

logseq-plugin-doc

Show page in a more document like look and provide quick exporting.
JavaScript
89
star
5

logseq-plugin-kanban-board

Draggable, editable Kanban view.
JavaScript
59
star
6

logseq-long-form

A long form editing experience for Logseq.
54
star
7

logseq-plugin-weread-sync

配合 Chrome 插件“微信读书 LS 同步助手”使用,同步微信读书数据。
JavaScript
50
star
8

logseq-plugin-smartsearch

Triggers an input that helps you search various types of data.
JavaScript
39
star
9

logseq-plugin-ol

Ordered lists, flat or nested, multiple formats ordered lists.
JavaScript
35
star
10

logseq-plugin-batch-op

Perform queries on the current graph and batch process on the results.
JavaScript
34
star
11

logseq-plugin-charspacing

Add space between Chinese and ASCII characters to make document look nicer.
JavaScript
34
star
12

logseq-plugin-smart-typing

Enrich the editing experience in Logseq, automatically match all kinds of parentheses, quotation marks and mathematical equations. Support for matching Chinese punctuation marks.
JavaScript
28
star
13

logseq-plugin-days

Generate a calendar with all days related to a topic highlighted. A topic is either a page or a block.
JavaScript
27
star
14

logseq-plugin-reminder

System notification for Scheduled and Deadline.
JavaScript
25
star
15

logseq-plugin-another-embed

This plugin provides 2 extra ways to embed blocks/pages.
JavaScript
22
star
16

logseq-plugin-favorite-tree

A hierarchical favorites in the left sidebar.
TypeScript
18
star
17

logseq-plugin-tabbed-sidebar

Alternative sidebar that's organized in tabs.
TypeScript
14
star
18

react-hoc-query

HOC to help you query restful data
JavaScript
12
star
19

logseq-plugin-drawit

SD WebUI frontend for Logseq.
TypeScript
10
star
20

chrome-weread-sync

配合Logseq WeRead Sync插件使用,同步微信读书数据。
JavaScript
9
star
21

func.js

An ES6 library offering some functional features.
JavaScript
9
star
22

asyncflow

An expressive, capable and easy to use async flow library based on node-fibers.
JavaScript
9
star
23

logseq-plugin-hierarchy-jump

Identifies the current page's hierarchy and offer a quicker navigation.
TypeScript
7
star
24

logseq-hierarchy-jump

Identifies the current page's hierarchy and offer a quicker navigation.
7
star
25

mtj

A MTJ clojure wrapper and core.matrix implementation.
Clojure
6
star
26

fgen

A file generator library to be used to generate project structures, file templates and/or snippets. Templates are based on mustache.
JavaScript
6
star
27

logseq-media-ts

Create timestamps for audio and video to facilitate your learning and meeting reviews.
5
star
28

logseq-plugin-linker

Dynamically replaces a link's path. It allows you to store big files (like video) outside of Logseq.
TypeScript
5
star
29

xtabs

A cross tabulation library simulating R's API.
JavaScript
5
star
30

orca-note

A note taking application that is good both for outlining and long-form writing.
5
star
31

logseq-plugin-math-editor

Easier editing of math formulas.
TypeScript
4
star
32

logseq-l10n

L10N framework for Logseq plugins.
TypeScript
4
star
33

logseq-plugin-task-reminder

A pomodoro timer for your tasks.
TypeScript
4
star
34

mistery

Mistery - A game kind demo
JavaScript
4
star
35

cljspark

Clojure wrapper for Spark.
Clojure
3
star
36

vim-snippets

My Vim snippets.
2
star
37

streamline-express

An Express 3.x patch for using streamline.
JavaScript
2
star
38

ng-conf-template

HTML
2
star
39

util-streams

Various Node.js streams I use
JavaScript
2
star
40

reactutils

Common utilities for React based apps
TypeScript
2
star
41

genapp

A customizable generator application.
JavaScript
2
star
42

cljasyncflow

A future/promise model async flow based on core.async.
Clojure
1
star
43

simple-flux

Simple Flux implementation inspired by RiotControl
JavaScript
1
star
44

jsutils

Utilities for JavaScript.
TypeScript
1
star
45

react-hoc-timerfuncs

Timer functions provided via props that auto clear themselves at unmount
JavaScript
1
star
46

quickclick

Simple heuristic to ensure quick click events on recent mobile browsers
JavaScript
1
star