A Mendix Studio Pro extension that adds Markdown document support with a rich text editor.
This extension demonstrates how to build custom document types in Mendix Studio Pro using the Web Extensibility API. It registers a new Markdown document type and provides a tab-based editor with MDXEditor for rich editing capabilities.
- Custom Document Type: Registers Markdown documents in the Mendix model
- Rich Editor: Full-featured Markdown editor with toolbar
src/main/index.ts- Extension entry point, registers document type and editorsrc/ui/editor.tsx- React component for the editor tabsrc/components/markdown-canvas/- MDXEditor integration with save functionality
- Custom Blob Documents API: Registers and manages Markdown documents
- UI Editors API: Registers the editor as a tab interface
The extension uses esbuild for fast bundling with custom plugins:
The build process defines entry points that map to the manifest.json configuration:
// build-extension.mjs
const entryPoints = [
{ in: 'src/main/index.ts', out: 'main' }, // → main.js
{ in: 'src/ui/editor.tsx', out: 'editor' } // → editor.js
]These correspond to the manifest:
{
"mendixComponent": {
"entryPoints": {
"main": "main.js",
"ui": {
"editor": "editor.js"
}
}
}
}CSS files are automatically bundled using the bundleCssPlugin:
- Collection: All imported CSS files are collected during build
- Bundling: Combined into a single
style.cssfile in the output - Injection: Can auto-inject stylesheets into the document head
- Import: Simply import CSS in your TypeScript files:
import "../main/style.css"; import "../components/markdown-canvas/markdown-canvas.css";
- TypeScript Compilation: Type checking with
tsc --noEmit - esbuild Bundling: Code splitting, tree shaking, asset optimization
- CSS Bundling: Combines all CSS into single file
- Manifest Copy: Copies
src/manifest.jsonto output - App Deployment: Copies built extension to Mendix app directory
npm run build # Production build
npm run build:dev # Development with watch modeUpdate build-extension.mjs to point to your Mendix app directory:
const appDir = "path/to/your/mendix/app"await studioPro.app.model.customBlobDocuments.registerDocumentType<MarkdownDocument>({
type: 'mendixdocumenter.MarkdownDocument',
readableTypeName: 'Markdown',
defaultContent: { content: '' }
});await studioPro.ui.editors.registerEditorForCustomDocument({
documentType: 'mendixdocumenter.MarkdownDocument',
editorEntryPoint: 'editor',
editorKind: 'tab',
iconLight: markdownLightThemeIcon,
iconDark: markdownDarkThemeIcon
});studioPro.app.model.customBlobDocuments.updateDocumentContent(documentId, {
content: newContent
});MIT