diff --git a/app/Services/PdfMaker/Design.php b/app/Services/PdfMaker/Design.php index cb42ebbb7cea..9c5fff50464a 100644 --- a/app/Services/PdfMaker/Design.php +++ b/app/Services/PdfMaker/Design.php @@ -347,7 +347,7 @@ class Design extends BaseDesign $items = $this->transformLineItems($this->entity->line_items, $type); - // $this->processMarkdownOnLineItems($items); + $this->processMarkdownOnLineItems($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 feeba76772ff..1869849f29f7 100644 --- a/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php +++ b/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php @@ -333,9 +333,6 @@ document.addEventListener('DOMContentLoaded', function() { public function processMarkdownOnLineItems(array &$items) { - // Use setting to determinate if parsing should be done. - // 'parse_markdown_on_pdfs' - foreach ($items as $key => $item) { foreach ($item as $variable => $value) { $item[$variable] = DesignHelpers::parseMarkdownToHtml($value ?? ''); diff --git a/app/Services/PdfMaker/PdfMakerUtilities.php b/app/Services/PdfMaker/PdfMakerUtilities.php index ae18d5fb3eb3..8ce5622896cf 100644 --- a/app/Services/PdfMaker/PdfMakerUtilities.php +++ b/app/Services/PdfMaker/PdfMakerUtilities.php @@ -91,31 +91,19 @@ trait PdfMakerUtilities foreach ($children as $child) { $contains_html = false; - if (isset($child['content'])) { - // Commented cause it keeps adding
at the end, if markdown parsing is turned on. - // Should update with 'parse_markdown_on_pdfs' setting. - - $child['content'] = nl2br($child['content']); - } - - // "/\/[a-z]*>/i" -> checks for HTML-like tags: - // => true - // => true - // => false - if (isset($child['content'])) { if (isset($child['is_empty']) && $child['is_empty'] === true) { continue; } - $contains_html = preg_match("/\/[a-z]*>/i", $child['content'], $m) != 0; + $contains_html = preg_match('#(?<=<)\w+(?=[^<]*?>)#', $child['content'], $m) != 0; } if ($contains_html) { - // If the element contains the HTML, we gonna display it as is. DOMDocument, is going to - // encode it for us, preventing any errors on the backend due processing stage. + // If the element contains the HTML, we gonna display it as is. Backend is going to + // encode it for us, preventing any errors on the processing stage. // Later, we decode this using Javascript so it looks like it's normal HTML being injected. - // To get all elements that need frontend decoding, we use 'data-ref' property. + // To get all elements that need frontend decoding, we use 'data-state' property. $_child = $this->document->createElement($child['element'], ''); $_child->setAttribute('data-state', 'encoded-html'); diff --git a/database/migrations/2021_07_21_115919_update_designs.php b/database/migrations/2021_07_29_115919_update_designs.php similarity index 100% rename from database/migrations/2021_07_21_115919_update_designs.php rename to database/migrations/2021_07_29_115919_update_designs.php diff --git a/resources/views/pdf-designs/bold.html b/resources/views/pdf-designs/bold.html index aafb61539c11..54434dd3778d 100644 --- a/resources/views/pdf-designs/bold.html +++ b/resources/views/pdf-designs/bold.html @@ -20,7 +20,7 @@ p { margin: 0; padding: 0; - page-break-after: always; + /* page-break-after: always; */ } .header-wrapper { @@ -242,6 +242,14 @@ display: none } } + + /** Markdown-specific styles. **/ + #product-table h3, + #task-table h3, + #delivery-note-table h3 { + font-size: 1rem; + margin-bottom: 0; + } diff --git a/resources/views/pdf-designs/business.html b/resources/views/pdf-designs/business.html index b6bac291c6f1..3d5c61ee45a5 100644 --- a/resources/views/pdf-designs/business.html +++ b/resources/views/pdf-designs/business.html @@ -235,6 +235,14 @@ #footer { margin-top: 30px; } + + /** Markdown-specific styles. **/ + #product-table h3, + #task-table h3, + #delivery-note-table h3 { + font-size: 1rem; + margin-bottom: 0; + } diff --git a/resources/views/pdf-designs/clean.html b/resources/views/pdf-designs/clean.html index 21bc1beab143..0cfb96bd705a 100644 --- a/resources/views/pdf-designs/clean.html +++ b/resources/views/pdf-designs/clean.html @@ -193,6 +193,14 @@ #footer { margin-top: 30px; } + + /** Markdown-specific styles. **/ + #product-table h3, + #task-table h3, + #delivery-note-table h3 { + font-size: 1rem; + margin-bottom: 0; + } diff --git a/resources/views/pdf-designs/creative.html b/resources/views/pdf-designs/creative.html index 1229d9898ab0..18a537b3bdce 100644 --- a/resources/views/pdf-designs/creative.html +++ b/resources/views/pdf-designs/creative.html @@ -195,6 +195,14 @@ #footer { margin-top: 30px; } + + /** Markdown-specific styles. **/ + #product-table h3, + #task-table h3, + #delivery-note-table h3 { + font-size: 1rem; + margin-bottom: 0; + } diff --git a/resources/views/pdf-designs/elegant.html b/resources/views/pdf-designs/elegant.html index 06b6b66a7a69..d0591b5c5d58 100644 --- a/resources/views/pdf-designs/elegant.html +++ b/resources/views/pdf-designs/elegant.html @@ -193,6 +193,14 @@ #footer { margin-top: 30px; } + + /** Markdown-specific styles. **/ + #product-table h3, + #task-table h3, + #delivery-note-table h3 { + font-size: 1rem; + margin-bottom: 0; + } diff --git a/resources/views/pdf-designs/hipster.html b/resources/views/pdf-designs/hipster.html index 6a87a6633788..3d15e1c4adc7 100644 --- a/resources/views/pdf-designs/hipster.html +++ b/resources/views/pdf-designs/hipster.html @@ -204,6 +204,14 @@ #footer { margin-top: 30px; } + + /** Markdown-specific styles. **/ + #product-table h3, + #task-table h3, + #delivery-note-table h3 { + font-size: 1rem; + margin-bottom: 0; + } diff --git a/resources/views/pdf-designs/modern.html b/resources/views/pdf-designs/modern.html index 5d6192dd47cb..dbc154858259 100644 --- a/resources/views/pdf-designs/modern.html +++ b/resources/views/pdf-designs/modern.html @@ -22,7 +22,7 @@ p { margin: 0; padding: 0; - page-break-after: always; + /* page-break-after: always; */ } .header-container { @@ -261,6 +261,14 @@ display: none } } + + /** Markdown-specific styles. **/ + #product-table h3, + #task-table h3, + #delivery-note-table h3 { + font-size: 1rem; + margin-bottom: 0; + }
diff --git a/resources/views/pdf-designs/plain.html b/resources/views/pdf-designs/plain.html index 264b727f9400..439ff565e912 100644 --- a/resources/views/pdf-designs/plain.html +++ b/resources/views/pdf-designs/plain.html @@ -171,6 +171,14 @@ [data-ref="totals_table-outstanding"] { color: var(--primary-color) } + + /** Markdown-specific styles. **/ + #product-table h3, + #task-table h3, + #delivery-note-table h3 { + font-size: 1rem; + margin-bottom: 0; + } diff --git a/resources/views/pdf-designs/playful.html b/resources/views/pdf-designs/playful.html index df145165cb46..55a4023a8fbd 100644 --- a/resources/views/pdf-designs/playful.html +++ b/resources/views/pdf-designs/playful.html @@ -240,8 +240,15 @@ #footer { margin-top: 1rem; } - + /** Markdown-specific styles. **/ + #product-table h3, + #task-table h3, + #delivery-note-table h3 { + font-size: 1rem; + margin-bottom: 0; + } +