13177 Fixed multi-span

This commit is contained in:
Daniel Maya 2024-03-25 11:22:33 +01:00
parent 6576b22870
commit b95f47a59c
1 changed files with 24 additions and 0 deletions

View File

@ -1859,6 +1859,30 @@ class Item extends CachedModel
$save = array_merge($dataModelEncode, $dataEncode); $save = array_merge($dataModelEncode, $dataEncode);
if (!empty($save['label'])) { if (!empty($save['label'])) {
// Multi-span problem with TinyMCE. Do not delete.
$dom = new \DOMDocument();
$dom->loadHTML(io_safe_output($save['label']));
// XPath object.
$xpath = new \DOMXPath($dom);
// Find all span tags with style attribute.
$span_nodes = $xpath->query('//span[@style]');
if ($span_nodes->length > 1) {
$style = '';
foreach ($span_nodes as $span) {
$style .= $span->getAttribute('style');
}
$last_span = $span_nodes[($span_nodes->length - 1)];
// Set style.
$last_span->setAttribute('style', $style);
$save['label'] = io_safe_input($dom->saveHTML());
}
$save['label'] = io_safe_output(io_safe_input(str_replace("'", "\'", $save['label']))); $save['label'] = io_safe_output(io_safe_input(str_replace("'", "\'", $save['label'])));
} }