-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(visual-engine): add text adaptation (#54)
* chore(visual-engine): add text adaptation * v1.4.1
- Loading branch information
Showing
14 changed files
with
198 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"npmClient": "yarn", | ||
"useWorkspaces": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { AnaliseTextFn } from '@readapt/text-engine' | ||
import { Settings } from '@readapt/settings' | ||
|
||
import { generateHtmlElementStyles } from './adaptHtmlElementStyle' | ||
import { buildAdaptTextContentForText } from './adaptTextContent' | ||
import { generateTextContentStyles } from './adaptTextContentStyle' | ||
import { adaptShadeAlternateLinesForText } from './adaptShadeAlternateLines' | ||
|
||
const adaptHtmlText = | ||
(analyse: AnaliseTextFn) => | ||
(htmlText: string, settings: Settings): string => { | ||
// General Settings do not require text analyse | ||
let settingsStyles = generateHtmlElementStyles(settings) | ||
|
||
// Settings with text analyse | ||
const adaptTextContent = buildAdaptTextContentForText(analyse) | ||
|
||
const liaisonsPhonemes = new Set<string>() | ||
const langStyles = generateTextContentStyles(settings, '', liaisonsPhonemes) | ||
settingsStyles += langStyles | ||
|
||
if (settings.shadeAlternateLinesActive) { | ||
const { className, style } = adaptShadeAlternateLinesForText(settings.shadeAlternateLinesOpacity) | ||
|
||
return `<div> | ||
<style> | ||
${settingsStyles} | ||
${style} | ||
</style> | ||
<span class="readapt-content ${className}"> | ||
${adaptTextContent(htmlText, settings, liaisonsPhonemes)} | ||
</span> | ||
</div>` | ||
} | ||
|
||
return `<div> | ||
<style> | ||
${settingsStyles} | ||
</style> | ||
<span class="readapt-content"> | ||
${adaptTextContent(htmlText, settings, liaisonsPhonemes)} | ||
</span> | ||
</div>` | ||
} | ||
|
||
export { adaptHtmlText } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters