fix(editor): custom image width parsing, fix image paste, add AI submenu features

This commit is contained in:
2026-05-03 00:08:28 +02:00
parent d0387cd9a0
commit 54b7b4fcf1
19 changed files with 3890 additions and 3490 deletions

View File

@@ -17,7 +17,7 @@ export async function POST(request: NextRequest) {
return NextResponse.json({ error: 'Feature disabled' }, { status: 403 })
}
const { text, option, format } = await request.json()
const { text, option, format, language } = await request.json()
// Validation
if (!text || typeof text !== 'string') {
@@ -25,16 +25,19 @@ export async function POST(request: NextRequest) {
}
// Map option to refactor mode
const modeMap: Record<string, 'clarify' | 'shorten' | 'improveStyle'> = {
const modeMap: Record<string, 'clarify' | 'shorten' | 'improveStyle' | 'fix_grammar' | 'translate' | 'explain'> = {
'clarify': 'clarify',
'shorten': 'shorten',
'improve': 'improveStyle'
'improve': 'improveStyle',
'fix_grammar': 'fix_grammar',
'translate': 'translate',
'explain': 'explain'
}
const mode = modeMap[option]
if (!mode) {
return NextResponse.json(
{ error: 'Invalid option. Use: clarify, shorten, or improve' },
{ error: 'Invalid option. Use: clarify, shorten, improve, fix_grammar, translate, or explain' },
{ status: 400 }
)
}
@@ -50,7 +53,7 @@ export async function POST(request: NextRequest) {
}
// Use the ParagraphRefactorService
const result = await paragraphRefactorService.refactor(text, mode, format === 'html' ? 'html' : 'markdown')
const result = await paragraphRefactorService.refactor(text, mode, format === 'html' ? 'html' : 'markdown', language)
return NextResponse.json({
originalText: result.original,
@@ -66,3 +69,4 @@ export async function POST(request: NextRequest) {
)
}
}