platform
platform copied to clipboard
feat(text-editor): add Markdown import/export support
Summary
Adds bidirectional Markdown support to the document editor, exposing the existing @hcengineering/text-markdown conversion utilities through user-facing UI.
Import:
- Enhanced
smartPaste.tsheuristics — addedblockquote,horizontal_rulenode types andstrikemark type text/markdownMIME type detection — automatically parses clipboard Markdown when browsers provide it- YAML frontmatter stripping on all import paths
- "Paste as Markdown" toolbar action — reads clipboard and force-parses as Markdown
- "Import Markdown" toolbar action — file picker for
.md/.markdownfiles - Drag-and-drop
.mdfile support — TipTap extension using async-in-sync pattern (likeimageUpload.ts)
Export:
- "Export as Markdown" toolbar action — converts editor content via
markupToMarkdown()and downloads as.mdfile
Design decisions
- No new packages — extends existing
text-editor-resources,models/text-editor, andtext-editor-assets - No new dependencies — builds entirely on
@hcengineering/text-markdown(markdownToMarkup/markupToMarkdown) - Follows existing patterns —
TextActionFunctionfor toolbar actions,Extension.create()with ProseMirror plugins for drag-and-drop, registered viaTextEditorAction(category 130) - Reuses existing icons — Code, ScaleOut, Download
Files changed
New (4):
plugins/text-editor-resources/src/components/extension/shortcuts/pasteAsMarkdown.tsplugins/text-editor-resources/src/components/extension/shortcuts/markdownFileImport.tsplugins/text-editor-resources/src/components/extension/shortcuts/markdownFileDrop.tsplugins/text-editor-resources/src/components/extension/shortcuts/exportMarkdown.ts
Modified (7):
smartPaste.ts— enhanced heuristics + MIME detection + frontmatter strippingeditor-kit.ts— registeredMarkdownFileDropExtensionin shortcuts sub-kittext-editor-resources/index.ts— wired 3 new resource functionstext-editor/plugin.ts— added 3 i18n string IDsmodels/text-editor/plugin.ts— added 3 function resource IDsmodels/text-editor/index.ts— registered 3TextEditorActiondocstext-editor-assets/lang/en.json— added 3 i18n strings
Test plan
- [ ] Paste Markdown text into editor — auto-converts headings, bold, lists, code blocks, tables
- [ ] Paste with
text/markdownMIME type — always converts (no heuristic check) - [ ] Paste text with YAML frontmatter — frontmatter is stripped
- [ ] Use "Paste as Markdown" toolbar action — reads clipboard, inserts formatted content
- [ ] Use "Import Markdown" toolbar action — opens file picker, imports
.mdfile - [ ] Drag
.mdfile into editor — content is parsed and inserted at drop position - [ ] Use "Export as Markdown" toolbar action — downloads
document.md - [ ] Roundtrip: export → import produces equivalent document
- [ ] No regressions: existing paste behavior unchanged for non-Markdown content
- [ ] Build:
rush build && rush bundlesucceeds without errors
Resolves #7017, #8090
Connected to Huly®: UBERF-16056
Hi @philoSurfer
Could you please resolve merge conflicts and fix validation errors?
At the moment CI / build (pull_request) is failed due to the following errors in rush validate:
--[ FAILURE: @hcengineering/text-editor-resources (validate) ][ 14.02 seconds ]--
Error: /home/runner/work/platform/platform/plugins/text-editor-resources/src/components/extension/shortcuts/markdownFileDrop.ts(61,32): error TS2488: Type 'FileList' must have a '[Symbol.iterator]()' method that returns an iterator.
Error: /home/runner/work/platform/platform/plugins/text-editor-resources/src/components/extension/shortcuts/markdownFileDrop.ts(78,34): error TS2488: Type 'FileList' must have a '[Symbol.iterator]()' method that returns an iterator.