fix(editor): custom image width parsing, fix image paste, add AI submenu features
This commit is contained in:
@@ -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) {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user