Convert `<small>` into `font-size`
authorAlexander Ebert <ebert@woltlab.com>
Thu, 13 Aug 2020 21:39:37 +0000 (23:39 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 13 Aug 2020 21:39:37 +0000 (23:39 +0200)
wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeSmall.class.php [new file with mode: 0644]

diff --git a/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeSmall.class.php b/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeSmall.class.php
new file mode 100644 (file)
index 0000000..ac127f7
--- /dev/null
@@ -0,0 +1,52 @@
+<?php
+namespace wcf\system\html\input\node;
+use wcf\system\bbcode\BBCodeHandler;
+use wcf\system\html\node\AbstractHtmlNodeProcessor;
+use wcf\util\DOMUtil;
+
+/**
+ * Converts `<small>` elements into their CSS equivalent.
+ *
+ * @author      Alexander Ebert
+ * @copyright   2001-2020 WoltLab GmbH
+ * @license     GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package     WoltLabSuite\Core\System\Html\Input\Node
+ * @since       5.3
+ */
+class HtmlInputNodeSmall extends AbstractHtmlInputNode {
+       /**
+        * @inheritDoc
+        */
+       protected $tagName = 'small';
+       
+       /**
+        * @inheritDoc
+        */
+       public function isAllowed(AbstractHtmlNodeProcessor $htmlNodeProcessor) {
+               if (BBCodeHandler::getInstance()->isAvailableBBCode('size')) {
+                       return [];
+               }
+               
+               return ['size'];
+       }
+       
+       /**
+        * @inheritDoc
+        */
+       public function process(array $elements, AbstractHtmlNodeProcessor $htmlNodeProcessor) {
+               /** @var \DOMElement $element */
+               foreach ($elements as $element) {
+                       if (DOMUtil::isRemoved($element) || !$element->parentNode) {
+                               continue;
+                       }
+                       
+                       $span = $element->ownerDocument->createElement('span');
+                       $span->setAttribute('style', "font-size: 10pt");
+                       
+                       $element->parentNode->insertBefore($span, $element);
+                       $span->appendChild($element);
+                       
+                       DOMUtil::removeNode($element, true);
+               }
+       }
+}