This proof of concept demonstrates the integration of Obsidian's native markdown editor into the TaskNotes task edit modal, specifically for the "details" section.
File: src/editor/EmbeddableMarkdownEditor.ts
A reusable wrapper around Obsidian's internal ScrollableMarkdownEditor that provides:
- Full CodeMirror editing capabilities
- Live preview markdown rendering
- Syntax highlighting
- Wikilink autocomplete
- All standard Obsidian editing features
Based on: Fevol's implementation (https://gist.github.com/Fevol/caa478ce303e69eabede7b12b2323838)
Key Features:
- Configurable placeholder text
- Event handlers for
onChange,onEnter,onEscape,onSubmit,onBlur,onPaste - Proper cleanup/destroy methods
- Fallback handling if initialization fails
File: src/modals/TaskEditModal.ts
Modified the edit modal to:
- Import the
EmbeddableMarkdownEditorclass - Override
createDetailsSection()method to create the markdown editor instead of a plain textarea - Add proper lifecycle management (destroy editor on modal close)
- Include fallback to textarea if editor creation fails
File: styles/task-modal.css
Added styling for:
- Editor container with borders and rounded corners
- Min/max height constraints (200px - 400px)
- Scrollable content area
- Placeholder text styling
- Proper padding and font sizing
- When editing a task: The edit modal now shows a full markdown editor for the details field
- Editor features: Users can:
- Write markdown with live preview
- Create wikilinks with
[[syntax - Use all standard Obsidian editing shortcuts
- See syntax highlighting
- Copy/paste rich content
- Data handling: Content changes are automatically synced to the
this.detailsfield - Cleanup: Editor is properly destroyed when the modal closes
ScrollableMarkdownEditorWidgetEditorViewapp.embedRegistry.embedByExtension.md()
These APIs may change in future Obsidian versions without notice.
- Requires
monkey-aroundpackage (already in dependencies) - Tested with Obsidian 1.5.8+
- Uses
@ts-ignorecomments for internal API access
- Plugin extensions not included: Other plugins' CodeMirror extensions won't automatically load in this editor
- Internal API dependency: Future Obsidian updates may break this functionality
- No read mode: The editor is always in edit mode (no toggle between reading/editing)
To test this implementation:
- Build the plugin:
npm run build - Reload Obsidian
- Open any task's edit modal
- The "Details" section should now show a full markdown editor
- Try:
- Writing markdown text
- Creating wikilinks with
[[ - Using keyboard shortcuts
- Pasting content
- Scrolling in the editor area
Possible improvements:
- Add toggle button to switch between simple textarea and rich editor
- Make the editor height adjustable/resizable
- Add option in settings to enable/disable rich editor
- Include specific plugin extensions (e.g., vim mode, syntax highlighting themes)
- Add keyboard shortcut hints/documentation
src/editor/EmbeddableMarkdownEditor.ts(NEW)src/modals/TaskEditModal.ts(MODIFIED)styles/task-modal.css(MODIFIED)
Implementation based on work by:
- Fevol - Original embeddable markdown editor implementation
- mgmeyers - Original concept from Kanban plugin
MIT (consistent with TaskNotes plugin license)