Keep YAML front matter multi-line fields consistently folded after switch to preview mode

This feature request is similar in nature to a previously resolved topic mentioned here, except I am referring to folding individual multi-line YAML fields instead of folding the entire YAML header.

Use case or problem

I would like to keep multi-line fields in YAML frontmatter consistently folded. Currently, when I switch to preview mode then revert to editor mode, any folded multi-line YAML fields I had would return to being unfolded.

Steps to reproduce

  1. Add front matter to a note with some multi-line fields as shown below:
---
aliases:
  - "My note"
  - "My sample note"
  - "Sample note"
tags:
  - "note"
  - "sample"
  - "writing"
---
  1. Fold one or more of the multi-line fields individually, for example, fold the tags field:
---
aliases:
  - "My note"
  - "My sample note"
  - "Sample note"
tags: ...
---
  1. Switch to preview mode, then back to editor mode

Expected result

Any individually folded multi-line fields in the front matter should still be folded. Multi-line fields can include YAML lists, dictionaries, or text spanning multiple lines.

Actual result

Previously folded multi-line fields are expanded

Environment

  • Operating system: Windows
  • Obsidian version: 0.12.17

Proposed solution

A new feature which allows the YAML front matter multi-line fields to remain folded even after switching back and forth from preview mode.