FR: Enhance EmbeddableMarkdownEditor and create MetadataEditor infrastructure #433
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR addresses the feature request to improve the
EmbeddableMarkdownEditorimplementation and create aMetadataEditorinfrastructure based on patterns from obsidian-better-properties.Problem Statement
The original issues were:
MarkdownEditor.tswas not properly implemented even though it was functionalMetadataEditorwithin theEmbeddableMarkdownEditorChanges Made
1. EmbeddableMarkdownEditor Enhancements
The markdown editor has been significantly improved following best practices from obsidian-better-properties:
New Features
filePathparameter to enable proper link rendering ([[wikilinks]])onFocus- Triggered when editor gains focusonEditorClick- Custom click event handleronEscape- Escape key handler (previously commented out)focusoption to control initial focus statefilteredExtensionsarray to exclude specific CodeMirror extensionsImplementation Improvements
Constructor<MarkdownScrollableEditView>type from obsidian-typingsUsage Example
2. MetadataEditor Infrastructure
Created a complete
MetadataEditorpatching infrastructure that can be optionally integrated:New Module:
src/services/MetadataEditor/Core Functions:
resolveMetadataEditorPrototype(plugin)- Extracts MetadataEditor prototype from apppatchMetadataEditor(plugin)- Applies patches using monkey-aroundload()andsynchronize()methodsDesign Principles:
Integration Example
See
src/services/MetadataEditor/INTEGRATION_EXAMPLE.tsfor complete integration patterns including settings toggle.3. Bug Fixes
Fixed unrelated TypeScript error in
MultiSuggest.tswhere tag sorting needed proper type handling.Documentation
Comprehensive documentation has been added:
Testing
Backward Compatibility
All changes are fully backward compatible:
filePathparameter is optional (defaults to empty string)onChangecallback signature is extended (old usage still works)Files Changed
Modified:
src/services/MarkdownEditor.ts- Enhanced implementationsrc/components/AddOrEditTaskRC.tsx- Updated to use new APIsrc/services/MultiSuggest.ts- Fixed type errorAdded:
src/services/MetadataEditor/- Complete module with 4 filesENHANCEMENT_SUMMARY.md- Comprehensive documentationReferences
Next Steps
The MetadataEditor infrastructure is ready for use when needed. To enable it, follow the integration examples in
INTEGRATION_EXAMPLE.ts. The enhanced EmbeddableMarkdownEditor is already active and improves the task editing experience with better link rendering and focus management.Original prompt
Fixes #432
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.