An Open-Source AI Editor That Fixes the Markdown-to-WeChat Formatting Nightmare
Over the past two years, I have been deeply involved in AI Agents and large model applications, such as the JitKnow AI knowledge base, JitWord collaborative AI documents, and Pxcharts super tables. At the same time, I have been continuously sharing high-quality, practical AI open-source projects from GitHub that can truly be implemented and solve real problems.
Recently, based on the JitWord collaborative AI document SDK, I wrote an open-source WeChat Official Account editor — wx-editor.
Project Introduction
The WeChat Article AI Editor is a content creation workbench for WeChat Official Accounts built with Vue 3 + Vite + TypeScript + Pinia + JitWord SDK. It integrates AI-assisted creation, rich text editing, style block layout, theme switching, mobile preview, WeChat-compatible export, image upload processing, and local draft management into a single lightweight front-end application.
It is suitable for the following groups:
- WeChat Official Account Creators: Quickly generate titles, summaries, outlines, and extended content, and format with one click.
- New Media Editors: Unify article styles and reduce style loss after copying to the Official Account backend.
- Brand Operations Teams: Accumulate fixed themes, style blocks, and content templates.
- Knowledge Content Teams: Edit long articles, tutorials, code blocks, and graphic content, and retain version snapshots.
Of course, this project still has many areas for optimization, and I look forward to everyone's contributions.
Without further ado, here are the open-source addresses:
wx-editor: https://github.com/jitOffice/wx-editor
JitWord SDK: https://github.com/jitOffice/jitword-sdk
Why This Project Was Made
Writing this tool is not actually to replace the existing WeChat formatting tools on the market, but from the perspective of a programmer creating content, to be able to convert Markdown technical articles into technical articles that display well on WeChat Official Accounts with one click, while also supporting multiple theme switches to meet the preferences of different technical bloggers.
The document editing part is implemented based on JitWord, with WeChat Official Account scenario capabilities added on top. The goal is to allow creators to complete the following in one workbench:
Draft Article → AI Assistance → Rich Text Editing → Theme Formatting → Preview Check → Copy to Official Account Backend
Core Highlights
AI Writing Assistant
Supports inserting AI results into the editor as structured rich text, and provides style wrappers such as information cards, key quotes, tips/reminders, step checklists, and summary cards.
JitWord Rich Text Editor Integration
- Loads the localized JitWord SDK artifact by default.
- Supports automatic degradation to a basic
contenteditableeditor if JitWord initialization fails. - Isolates lifecycle differences such as SDK initialization, content read/write, HTML insertion, and destruction through
EditorAdapter. - Handles compatibility for the default upload endpoint inside the third-party SDK to avoid
/upload/free404 errors during local development.
WeChat Official Account Style Blocks and Theme System
- Built-in common WeChat Official Account style blocks: cards, quotes, tips, steps, summaries, dividers, code blocks, etc.
- Supports theme switching, with preview and editing content remaining consistent.
- Style blocks are centered on WeChat-compatible HTML and inline styles to reduce style loss after copying.
- Markdown divider syntax
---,***,___is automatically mapped to editor-supported dividers.
WeChat-Compatible Export
- HTML cleaning and security filtering.
- Style inlining, adapted for pasting into the Official Account backend.
- Automatically supplements common WeChat Official Account compatibility styles.
- Pre-publish checks for potential issues like non-HTTPS links and local images.
- One-click copy to the Official Account backend, prioritizing the Clipboard API and automatically degrading on failure.
Dual-Mode Image Upload Strategy
The project has a built-in image upload strategy that balances local editing experience and WeChat Official Account publishing compatibility:
- Image hosting configured: Uploads to ImgBB or a custom image hosting interface, returning an online HTTPS image link.
- Image hosting not configured: Defaults to base64 insertion within the editor, without initiating any remote requests, to avoid local 404 errors.
- Upload failure: Automatically degrades to base64 within the editor, ensuring the user's editing is not interrupted.
- Before copying to Official Account: If base64/blob local images are detected, it will require configuring image hosting and converting them to online URLs to ensure normal display in the Official Account backend.
Local-First Data Management
- Automatic saving of local drafts.
- IndexedDB persistence for article content.
- localStorage saves AI and image hosting configurations.
- Supports version snapshots to reduce the risk of misoperation.
- MVP functions can run completely without a backend dependency.
Feature Overview
| Module | Capabilities |
|---|---|
| Creation Workbench | Three-column layout, title editing, save status, word count, GitHub link |
| Editor | JitWord SDK, local fallback editor, HTML insertion, image paste/drag/upload |
| AI Assistant | Polish, continue writing, titles, summaries, outlines, formatting suggestions, styled insertion |
| Style Center | Theme switching, style block insertion, dividers, quotes, code blocks, card layouts |
| WeChat Preview | Mobile Official Account preview, real-time theme sync, compatibility issue tips |
| Export & Copy | HTML cleaning, style inlining, local image detection, copy to clipboard |
| Image Processing | ImgBB, custom image hosting, base64 fallback, SDK default upload interception |
| Data Management | Pinia state, local drafts, version snapshots, IndexedDB persistence |
Tech Stack
| Type | Technology |
|---|---|
| Frontend Framework | Vue 3, Composition API, <script setup> |
| Build Tool | Vite 5 |
| Type System | TypeScript 5 |
| State Management | Pinia |
| Rich Text Editing | JitWord SDK localized integration + native fallback editor |
| Styling Solution | Global CSS, theme presets, WeChat-compatible inline styles |
| Testing Framework | Vitest, jsdom |
| Storage Solution | IndexedDB, localStorage |
Local Deployment Tutorial
Environment Requirements
Recommended:
- Node.js 18+
- npm 9+
Install Dependencies
npm install
Start Development Server
npm run dev
Since the project base path is configured as /wx-editor/, please access the development environment at:
http://localhost:5173/wx-editor/
If Vite automatically assigns a different port, please refer to the terminal output and keep the access path as /wx-editor/.
Run Tests
npm run test
Production Build
npm run build
The build output will be in:
wx-editor/
Preview Build Artifacts
npm run preview
When previewing, also access:
http://localhost:4173/wx-editor/
Environment Variables Introduction
The following variables can be configured in .env or on the deployment platform.
AI Configuration
| Variable Name | Description | Default Value |
|---|---|---|
VITE_DEEPSEEK_API_KEY |
DeepSeek API Key | Empty |
VITE_DEEPSEEK_API_BASE |
OpenAI-compatible API address | https://api.deepseek.com/chat/completions |
VITE_DEEPSEEK_MODEL |
Model name | deepseek-chat |
Note: If the API Key is not configured, the AI service will use local mock output, making it convenient to experience the product flow in an environment without a backend.
Image Upload Configuration
| Variable Name | Description | Default Value |
|---|---|---|
VITE_IMGBB_API_KEY |
ImgBB API Key | Empty |
VITE_IMAGE_UPLOAD_ENDPOINT |
Custom image upload interface | Empty |
VITE_IMAGE_UPLOAD_FIELD |
File field name for the custom upload interface | file |
The custom upload interface needs to support multipart/form-data and return a parsable image URL. The project is compatible with common return structures, such as url, data.url, data.display_url, etc.
Directory Structure
.
├── public/
│ └── vendor/jitword/ # JitWord local SDK resources
├── scripts/
│ └── download-jitword-assets.mjs # JitWord resource download script
├── src/
│ ├── components/ # Workbench components
│ │ ├── EditorShell.vue # Main editor area
│ │ ├── RightPanel.vue # AI, preview, version, configuration panels
│ │ └── SidebarPanel.vue # Theme, style block, draft entry
│ ├── data/
│ │ ├── blockTemplates.ts # Style block templates
│ │ └── themePresets.ts # WeChat Official Account theme presets
│ ├── services/
│ │ ├── aiService.ts # AI commands and content generation
│ │ ├── editorCommands.ts # Editor command encapsulation
│ │ ├── imageHostingService.ts # Image upload and base64 fallback
│ │ ├── indexedDbStorage.ts # IndexedDB storage
│ │ ├── jitwordAdapter.ts # JitWord SDK adapter layer
│ │ ├── runtimeConfig.ts # Runtime configuration read/write
│ │ └── wechatExporter.ts # WeChat-compatible export engine
│ ├── stores/
│ │ └── articleStore.ts # Draft, version, theme state
│ ├── App.vue # Application shell
│ ├── main.ts # Application entry
│ ├── styles.css # Global styles
│ └── types.ts # Shared type definitions
├── tests/ # Unit tests
│ ├── aiService.test.ts
│ ├── imageHostingService.test.ts
│ └── wechatExporter.test.ts
├── wx-editor/ # Build output directory
├── vite.config.ts # Vite configuration
├── package.json
└── prd.md # Product requirements and technical plan
Core Architecture
graph TD
User["Creator"] --> App["Vue App"]
App --> Editor["JitWord Adapter Layer"]
App --> Store["Pinia State"]
App --> AI["AI Service"]
App --> Exporter["WeChat Export Engine"]
Store --> Storage["IndexedDB / localStorage"]
AI --> Model["DeepSeek / OpenAI-compatible API"]
Exporter --> Clipboard["Clipboard / Official Account Backend"]
Editor --> Image["Image Upload / base64 Fallback"]
Editor Adapter Layer
src/services/jitwordAdapter.ts is the core adapter layer of the project, responsible for:
- Loading JitWord scripts and styles.
- Finding the JitWord global variable and initializing the editor.
- Unifying editor APIs such as
getHTML,setHTML,insertHTML,destroy. - Binding paste, drag, and file selection image uploads.
- Intercepting the default request behavior of JitWord's built-in upload button to
/upload/free. - Degrading to a basic editor if SDK loading fails or rendering is abnormal.
WeChat Export Engine
src/services/wechatExporter.ts is responsible for converting editor content into HTML more suitable for pasting into the WeChat Official Account backend:
- Cleans dangerous tags and attributes.
- Preserves safe
data:image/*;base64images. - Supplements WeChat-compatible styles for titles, paragraphs, quotes, code blocks, dividers, etc.
- Removes old inline colors that would hinder theme switching.
- Checks for publishing risks like local images and non-HTTPS links.
Image Upload Strategy
src/services/imageHostingService.ts implements a unified image upload entry:
Select Image
↓
Is image hosting configured?
├─ Yes: Upload to custom interface or ImgBB
│ ├─ Success: Use HTTPS URL
│ └─ Failure: Fallback to base64 within the editor
└─ No: Directly convert to base64, no request sent
This ensures smooth image insertion during local development and in environments without a backend, while still allowing conversion to online URLs via image hosting configuration before copying to the Official Account.
Future Iteration Roadmap (for reference)
- Real LLM Streaming Output: Enhance the AI assistant interaction experience.
- More Official Account Components: QR codes, author cards, cover images, product cards, event CTAs.
- Asset Library Management: Reuse brand images, fixed copy, and templates.
- Version Comparison: Support viewing differences before and after AI modifications.
- Team Collaboration: Combine JitWord collaboration capabilities to explore multi-person editing and team spaces.
- Stronger WeChat Compatibility Testing: Cover more copy-paste scenarios in the Official Account backend.
Contribution Guide
Issues and Pull Requests are welcome. It is recommended to focus on the following directions before contributing:
- Adding new WeChat Official Account style blocks and themes.
- Improving WeChat compatibility export rules.
- Optimizing the JitWord SDK adapter layer.
- Enhancing AI prompts and result insertion experience.
- Adding more unit tests.
This project is built based on the open-source version of the JitWord collaborative AI document engine.
Open Source Addresses:
wx-editor: https://github.com/jitOffice/wx-editor
JitWord SDK: https://github.com/jitOffice/jitword-sdk
In the future, more valuable AI document products and tools will be built based on jitword. If you have any good ideas or suggestions, feel free to leave a comment in the message area for discussion~