Skip to content

Commit

Permalink
refactor(format): apply suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
sargreal committed Aug 22, 2024
1 parent 9ff4b38 commit def1f32
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 18 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ module.exports = {
},
// Which field types are translated (default string, text, richtext, components and dynamiczones)
// Either string or object with type and format
// Possible formats: plain, markdown, html (default plain)
// Possible formats: plain, markdown, html, jsonb (default plain)
translatedFieldTypes: [
'string',
{ type: 'block', format: 'jsonb' },
{ type: 'blocks', format: 'jsonb' },
{ type: 'text', format: 'plain' },
{ type: 'richtext', format: 'markdown' },
'component',
Expand Down
2 changes: 1 addition & 1 deletion plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ module.exports = {
// Possible formats: plain, markdown, html, jsonb (default plain)
translatedFieldTypes: [
'string',
{ type: 'block', format: 'jsonb' },
{ type: 'blocks', format: 'jsonb' },
{ type: 'text', format: 'plain' },
{ type: 'richtext', format: 'markdown' },
'component',
Expand Down
15 changes: 0 additions & 15 deletions plugin/server/services/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,20 +214,5 @@ module.exports = () => ({
return html.map(convertHtmlToBlock)
}
return convertHtmlToBlock(html)
// return html.map(h => [
// {
// type: 'paragraph',
// children: [
// {
// type: 'text',
// text: "The following HTML has been translated. It's not yet possible to convert it back to the original block structure.",
// }
// ]
// },
// {
// type: 'code',
// children: h.split('\n').map(text => ({ type: 'text', text })),
// }
// ])
},
})
3 changes: 3 additions & 0 deletions providers/libretranslate/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ module.exports = {
)
)

if (format === 'jsonb') {
return formatService.htmlToBlock(result)
}
if (format === 'markdown') {
return formatService.htmlToMarkdown(result)
}
Expand Down

0 comments on commit def1f32

Please sign in to comment.