namespace wcf\system\html\output\node;
+use wcf\data\unfurl\url\UnfurlUrl;
use wcf\system\html\AbstractHtmlProcessor;
use wcf\system\html\node\AbstractHtmlNodeProcessor;
use wcf\system\html\node\HtmlNodeUnfurlLink;
'enableUgc' => $enableUgc,
]);
+ $parentParagraph = null;
+ if ($this->getUnfurlUrl($attribute)->hasFetchedContent() && $element->parentNode->nodeName === 'p') {
+ $parentParagraph = $element->parentNode;
+ $parentParagraph->parentNode->insertBefore($element, $parentParagraph);
+ }
+
$htmlNodeProcessor->renameTag($element, $tagName);
+
+ if ($parentParagraph !== null && !$parentParagraph->hasChildNodes()) {
+ /** @var \DOMElement $parentParagraph */
+ $parentParagraph->remove();
+ }
}
}
}
*/
public function replaceTag(array $data)
{
- /** @var \wcf\data\unfurl\url\UnfurlUrl $object */
- $object = MessageEmbeddedObjectManager::getInstance()->getObject('com.woltlab.wcf.unfurlUrl', $data['urlId']);
+ return $this->getUnfurlUrl($data['urlId'])->render($data['enableUgc']);
+ }
- return $object->render($data['enableUgc']);
+ /**
+ * @since 6.0
+ */
+ protected function getUnfurlUrl(int $id): UnfurlUrl
+ {
+ return MessageEmbeddedObjectManager::getInstance()->getObject('com.woltlab.wcf.unfurlUrl', $id);
}
}
.unfurlUrlCard {
background-color: var(--wcfContentBackground);
border-radius: 3px;
- box-shadow: 0 0 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
+ box-shadow:
+ 0 0 3px rgba(0, 0, 0, 0.12),
+ 0 1px 2px rgba(0, 0, 0, 0.24);
color: var(--wcfContentText);
display: inline-block;
- margin: 10px 0;
+ margin: 1em 0 0 0;
max-width: 100%;
overflow: hidden;
position: relative;