No description
Find a file
dragonish 03db39ca6f
fix(styles): fix some issues that could not be rendered in live preview
In live preview, if the heading contains tags, the decorator cannot be
rendered.

Refs: bd7e486deb
2025-04-19 20:48:22 +08:00
.gitea ci(changelog): change the action 2025-04-18 21:05:32 +08:00
.github ci(changelog): change the action 2025-04-18 21:05:32 +08:00
common merge(main): merge branch 'exp' 2025-04-19 20:29:56 +08:00
components feat: allow for easy customization of decorator styles 2025-04-18 23:35:39 +08:00
images docs(readme): add a description about custom styles 2025-04-18 23:58:21 +08:00
test/common fix(outline): fix exceptions when the heading contains links 2025-04-18 13:36:05 +08:00
.editorconfig init: repository initialisation 2025-03-08 20:39:07 +08:00
.gitattributes config(git): specify the eol of the manifest.json file 2025-03-15 20:05:28 +08:00
.gitignore init: repository initialisation 2025-03-08 20:39:07 +08:00
.mocharc.cjs feat: implement decoration for reading view 2025-03-10 14:01:36 +08:00
.npmrc init: repository initialisation 2025-03-08 20:39:07 +08:00
.versionrc.json init: repository initialisation 2025-03-08 20:39:07 +08:00
esbuild.config.mjs init: repository initialisation 2025-03-08 20:39:07 +08:00
eslint.config.mjs config(eslint): add an eslint configuration 2025-03-08 21:58:29 +08:00
LICENSE init: repository initialisation 2025-03-08 20:39:07 +08:00
main.ts feat: add new decorator position options 2025-04-09 21:45:01 +08:00
manifest.json chore(release): 1.5.0 2025-04-10 21:27:53 +08:00
package.json chore(release): 1.5.0 2025-04-10 21:27:53 +08:00
pnpm-lock.yaml chore(package): replace dependencies 2025-03-27 20:10:40 +08:00
README.md merge(main): merge branch 'exp' 2025-04-19 20:29:56 +08:00
styles.css fix(styles): fix some issues that could not be rendered in live preview 2025-04-19 20:48:22 +08:00
tsconfig.json feat(outline): add support for outline plugin 2025-03-31 13:41:04 +08:00
types.d.ts feat: add new decorator position options 2025-04-09 21:45:01 +08:00
version-bump.mjs init: repository initialisation 2025-03-08 20:39:07 +08:00
versions.json init: repository initialisation 2025-03-08 20:39:07 +08:00

Heading Decorator

Introduction

This is a plugin for Obsidian.

Implement displaying specific content around headings based on their levels.

This plugin supports optional decoration for reading view, editing view (Live Preview and Source mode) and Outline plugin. This plugin does not modify any note content, only decorates the heading section based on the existing note content.

Preview

In Live Preview:

Preview

The interaction between the decorator and the collapse button:

Collapse Button Interaction

Settings

Metadata keyword

The key name that reads the enabled status from the properties. The default value is: heading. Usage reference: Enabled status of notes.

Enabled

The plugin supports configure heading decorator for each editor mode. You can control the effect range:

  • Enabled in reading view: Allow to decorate the heading under the Reading view.
  • Enabled in live preview: Allow to decorate the heading under the Live Preview.
  • Enabled in source mode: Allow to decorate the heading under the Source mode.
  • Enabled in outline plugin: Allow to decorate the heading under the Outline plugin.

In addition, you can enable the default status of each note within the Manage subpage. It mainly works together with Enabled status of notes.

Effect

Control the display effect of the decorator.

  • Ordered: Toggle this setting to enable the decoration of headings as an ordered or unordered list.
  • Opacity: Set the opacity of the heading decorator. The value is the form of percentage.
  • Position: Set the position of the heading decorator. You can configure the content to appear before or after the heading.

Here are some examples of the differences between different positions:

Before the heading Before the heading (inside) After the heading
before before-inside after

Ordered

Similar to the effect displayed in the Preview.

You can control the counter style type and delimiter. There are two special types of counter styles:

  • Custom list styles: Set custom list styles for ordered list. Using spaces to separate entries.
  • Specified string: Set a specified string for ordered list.

For example:

Decimal numbers Custom List Styles (using Ⓐ Ⓑ Ⓒ) Specified String (using # with empty delimiter)
Decimal numbers Custom list styles Specified string

Allow zero level

For the Allow zero level setting, if the next heading is more than one level higher, the omitted level is zero instead of one. For example:

Default Allow zero level
Default Allow zero level

Based on the existing highest level

For the Based on the existing highest level setting, use the highest level of headings in the note as the base for ordered list. For example:

Default Based on the existing highest level
Default Based on the existing highest level

Ignore the single heading at the top-level

For the Ignore the single heading at the top-level setting, if the top-level has only a single heading, exclude it when building an ordered list. This setting contains Based on the existing highest level, but it deals with more "aggressive". For example:

Default Ignore the single heading at the top-level
Default Ignore the single heading at the top-level
The maximum number of ignored

For enabled: Ignore the single heading at the top-level. The maximum number of ignored headings at the top-level. For example:

Default Ignore the single heading at the top-level with default value (6) The maximum number of ignored is 1
Default Ignore the single heading at the top-level The maximum number of ignored is 1

Unordered

Directly decorate the heading according to the level. For example:

Ordered (Decimal numbers) Unordered (using H1 H2 H3 H4 H5 H6)
Ordered Unordered

Blacklist

Folder blacklist

Disables the heading decorator in notes within the specified folder. For notes that are on the blacklist, you can still use Enabled status of notes.

Note name regex blocklist

Disables the heading decorator in notes whose note name matches the specified regular expression. The format uses JavaScript regular expression, for example: /^daily.*/i. For notes that are on the blacklist, you can still use Enabled status of notes.

Enabled status of notes

This plugin allows for configure the enabled status based on specific fields in the note properties. You can individually control the enabled status of a note.

For example:

---
heading:
  reading: true  # Or yes, on, 1.
  preview: false # Or no, off, 0.
  source: false  # Fields are optional.
  outline: ~     # Other values are equivalent to undeclared.
---

You can use all to set all status:

---
heading:
  all: false
---

Or directly after the field:

---
heading: false
---

If you prefer to use Obsidian's cssclasses default property, you can also fill in cssclasses with some equivalent class names:

  • reading: enable-reading-heading/disable-reading-heading
  • preview: enable-preview-heading/disable-preview-heading
  • source: enable-source-heading/disable-source-heading
  • outline: enable-outline-heading/disable-outline-heading
  • all: enable-heading/disable-heading

Like:

---
cssclasses: disable-heading
---

Custom style

You can customize the heading decorator style by CSS classes. For decorators in the editor, .custom-heading-decorator can be used. Or for specific editor modes:

  • reading view: .reading-custom-heading-decorator.
  • live preview: .preview-custom-heading-decorator.
  • source mode: .source-custom-heading-decorator.

For the decorators in the outline, .outline-custom-heading-decorator can be used.

For the decorators in the outline, it is necessary to use .outline-custom-heading-decorator with pseudo-element keywords: .outline-custom-heading-decorator::before or .outline-custom-heading-decorator::after.

For example, make all the decorators display in green:

.custom-heading-decorator,
.outline-custom-heading-decorator::before,
.outline-custom-heading-decorator::after {
  color: green;
}

Credits

License

MIT license