From 5a4e0099605220a2d3a5f63f2a6486123c9d9824 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Mon, 9 Aug 2021 16:49:12 +0200 Subject: [PATCH] nl2br on line items --- app/Services/PdfMaker/Design.php | 2 ++ .../PdfMaker/Designs/Utilities/DesignHelpers.php | 13 ++++++++++++- app/Services/PdfMaker/PdfMakerUtilities.php | 2 -- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/Services/PdfMaker/Design.php b/app/Services/PdfMaker/Design.php index 9e6c64518e61..eeafbbd2d981 100644 --- a/app/Services/PdfMaker/Design.php +++ b/app/Services/PdfMaker/Design.php @@ -348,6 +348,8 @@ class Design extends BaseDesign $items = $this->transformLineItems($this->entity->line_items, $type); + $this->processNewLines($items); + if (count($items) == 0) { return []; } diff --git a/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php b/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php index 1869849f29f7..d43465d0ed60 100644 --- a/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php +++ b/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php @@ -331,7 +331,7 @@ document.addEventListener('DOMContentLoaded', function() { return $converter->convertToHtml($markdown); } - public function processMarkdownOnLineItems(array &$items) + public function processMarkdownOnLineItems(array &$items): void { foreach ($items as $key => $item) { foreach ($item as $variable => $value) { @@ -341,4 +341,15 @@ document.addEventListener('DOMContentLoaded', function() { $items[$key] = $item; } } + + public function processNewLines(array &$items): void + { + foreach ($items as $key => $item) { + foreach ($item as $variable => $value) { + $item[$variable] = nl2br($value); + } + + $items[$key] = $item; + } + } } diff --git a/app/Services/PdfMaker/PdfMakerUtilities.php b/app/Services/PdfMaker/PdfMakerUtilities.php index 7d3ddb3dae05..c90005e43b28 100644 --- a/app/Services/PdfMaker/PdfMakerUtilities.php +++ b/app/Services/PdfMaker/PdfMakerUtilities.php @@ -94,8 +94,6 @@ trait PdfMakerUtilities if ($child['element'] !== 'script') { if (array_key_exists('process_markdown', $this->data) && $this->data['process_markdown']) { $child['content'] = $this->commonmark->convertToHtml($child['content'] ?? ''); - } else { - $child['content'] = array_key_exists('content', $child) ? nl2br($child['content']) : ''; } }