Skip to content

Commit

Permalink
Merge pull request #7524 from unfoldingWord/bugfix-mcleanb-fixChapter…
Browse files Browse the repository at this point in the history
…AlignmentOnPrint

bug fix / fix chapter justification for ltr languages.
  • Loading branch information
PhotoNomad0 authored Aug 14, 2023
2 parents 30831db + 750d0c3 commit 6e1cd7b
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 10 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# Changelog


## [v3.5.0](https://github.com/unfoldingWord/translationCore/tree/v3.5.0) (2023-7-31)

**Implemented enhancements:**

- Add Print Preview and Pdf generation for projects [\#7456](https://github.com/unfoldingWord/translationCore/issues/7456)
- Update to use Electronite v22.0.3 and add support for Mac Universal Builds [\#7443](https://github.com/unfoldingWord/translationCore/issues/7443)
- Added the SIL Charis font [\#7506](https://github.com/unfoldingWord/translationCore/issues/7506)
- Add support for navigating by reference to Translation Notes/Words [\#7502](https://github.com/unfoldingWord/translationCore/issues/7502)
- EPIC: Support changing Greek Original Lang (e.g. SR Greek version of UGNT) [\#7458](https://github.com/unfoldingWord/translationCore/issues/7458)
- Add ability to use QA server [\#7449](https://github.com/unfoldingWord/translationCore/issues/7449)

**Fixed bugs:**

- Export with alignments fails in tCore with empty verses [\#7511](https://github.com/unfoldingWord/translationCore/issues/7511)
- Fix for git creating new projects with default branch of main instead of master [\#7487](https://github.com/unfoldingWord/translationCore/issues/7487)
- Fix to update original language data in alignment data when project is opened [\#7474](https://github.com/unfoldingWord/translationCore/issues/7474)
- When User changes GLs, make sure the Original Language for appropriate org is shown in Scripture Pane [\#7470](https://github.com/unfoldingWord/translationCore/issues/7470)


## [v3.4.0](https://github.com/unfoldingWord/translationCore/tree/v3.4.0) (2022-9-22)

**Implemented enhancements:**
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "translationCore",
"productName": "translationCore",
"version": "3.5.0",
"version": "3.5.1",
"minCompatibleVersion": "3.4.0",
"manifestVersion": "8",
"description": "A bridge between TS and TM",
Expand Down
6 changes: 4 additions & 2 deletions src/assets/previewTemplate.css
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,10 @@ div.periphBody {
.xt {font-weight: bold}

.chapter {
padding-left: %PS0.25%em;
float: right;
/* for rtl: padding-left: %PS0.25%em; */
%CHAPTER_PADDING%: %PS0.25%em;
/* for rtl: float: right; */
float: %CHAPTER_FLOAT%;
vertical-align: top;
margin-top:0;
margin-bottom: 0;
Expand Down
23 changes: 18 additions & 5 deletions src/js/components/PreviewContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function replacePageSizes(previewStyleTemplate, factor) {
let template = previewStyleTemplate;
const startStr = '%PS';
const units = '';
const fractionDigits = 0;
const fractionDigits = 2;
const endStr = '%';
template = scaleVariablesInTemplate(template, startStr, endStr, factor, fractionDigits, units);

Expand Down Expand Up @@ -143,9 +143,10 @@ function replacePixelSizes(previewStyleTemplate, factor) {
* @param {string} projectFont
* @param {number} baseSizePx
* @param {number} scale - scale to apply to everything
* @param {string} textDirection - direction for text (e.g. 'ltr' or 'rtl'
* @returns {string} - returns new html
*/
function convertPrintPreviewHtml(html, projectFont, baseSizePx, scale=1) {
function convertPrintPreviewHtml(html, projectFont, baseSizePx, scale=1, textDirection = 'ltr') {
let publicBase;

if (isProduction) {
Expand All @@ -161,6 +162,18 @@ function convertPrintPreviewHtml(html, projectFont, baseSizePx, scale=1) {
previewStyleTemplate = replaceFontSizes(previewStyleTemplate, baseSizePx*scale/7);
previewStyleTemplate = replacePageSizes(previewStyleTemplate, scale);
previewStyleTemplate = replacePixelSizes(previewStyleTemplate, scale);

let CHAPTER_PADDING = 'padding-left';
let CHAPTER_FLOAT = 'right';

if (textDirection === 'ltr') {
CHAPTER_PADDING = 'padding-right';
CHAPTER_FLOAT = 'left';
}

previewStyleTemplate = previewStyleTemplate.replace('%CHAPTER_PADDING%', CHAPTER_PADDING);
previewStyleTemplate = previewStyleTemplate.replace('%CHAPTER_FLOAT%', CHAPTER_FLOAT);

const startStyleStr = '<style>';
const startStylePos = html.indexOf(startStyleStr);
const endStyleStr = '</style>';
Expand Down Expand Up @@ -273,11 +286,11 @@ function PreviewContent({

useEffect(() => {
if (html && submitPreview && !running) {
const html_ = convertPrintPreviewHtml(html, projectFont, fontSize);
const html_ = convertPrintPreviewHtml(html, projectFont, fontSize, 1, textDirection);
onRefresh && onRefresh(html_);
setSubmitPreview(false);
}
}, [html, submitPreview, running, projectFont, onRefresh, fontSize]);
}, [html, submitPreview, running, projectFont, onRefresh, fontSize, textDirection]);

useEffect(() => {
if ( !submitPreview ) {
Expand Down Expand Up @@ -354,7 +367,7 @@ function PreviewContent({
setScale(scale_ + '');

if (onRefresh) {
const html_ = convertPrintPreviewHtml(html, projectFont, fontSize, scale_);
const html_ = convertPrintPreviewHtml(html, projectFont, fontSize, scale_, textDirection);
onRefresh && onRefresh(html_);
}
}
Expand Down

0 comments on commit 6e1cd7b

Please sign in to comment.