mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Merge pull request #6360 from beganovich/v5-601-commonmark
(v5) Markdown support on line items
This commit is contained in:
commit
d1ad3bcb26
@ -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 [];
|
||||
|
@ -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 ?? '');
|
||||
|
@ -91,31 +91,19 @@ trait PdfMakerUtilities
|
||||
foreach ($children as $child) {
|
||||
$contains_html = false;
|
||||
|
||||
if (isset($child['content'])) {
|
||||
// Commented cause it keeps adding <br> 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:
|
||||
// <my-tag></my-tag> => true
|
||||
// <my-tag /> => true
|
||||
// <my-tag> => 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');
|
||||
|
@ -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;
|
||||
}
|
||||
</style>
|
||||
|
||||
<table>
|
||||
|
@ -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;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div id="header"></div>
|
||||
|
@ -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;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div id="header"></div>
|
||||
|
@ -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;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div id="header"></div>
|
||||
|
@ -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;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div id="header"></div>
|
||||
|
@ -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;
|
||||
}
|
||||
</style>
|
||||
<div id="header"></div>
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
</style>
|
||||
|
||||
<table>
|
||||
|
@ -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;
|
||||
}
|
||||
</style>
|
||||
<div id="header"></div>
|
||||
|
||||
|
@ -240,8 +240,15 @@
|
||||
#footer {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
</style>
|
||||
|
||||
/** Markdown-specific styles. **/
|
||||
#product-table h3,
|
||||
#task-table h3,
|
||||
#delivery-note-table h3 {
|
||||
font-size: 1rem;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div id="header">
|
||||
<div style="background-color: #00968B"><!-- 1 --></div>
|
||||
|
@ -226,6 +226,14 @@
|
||||
#footer {
|
||||
margin-top: 30px;
|
||||
}
|
||||
|
||||
/** Markdown-specific styles. **/
|
||||
#product-table h3,
|
||||
#task-table h3,
|
||||
#delivery-note-table h3 {
|
||||
font-size: 1rem;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div id="header"></div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user