getgrav / grav-premium-issues

Official Grav Premium Issues repository to report problems or ask questions regarding the Premium products offered.
https://getgrav.org/premium
7 stars 2 forks source link

[nextgen-editor] feature request: rtl (dir attribute) support in div shortcode #311

Open yankl opened 1 year ago

yankl commented 1 year ago

It would be very useful for those of us who work with RTL languages to have the ability to set the dir attribute of a div element.

At first glance it seems easy enough to add to the shortcode core: In this file, instead of

 $this->shortcode->getHandlers()->add('div', static function(ShortcodeInterface $sc) {
            $id = $sc->getParameter('id');
            $class = $sc->getParameter('class');
            $style = $sc->getParameter('style');

            $id_output = $id ? ' id="' . $id . '" ': '';
            $class_output = $class ? ' class="' . $class . '"' : '';
            $style_output = $style ? ' style="' . $style . '"' : '';

            return '<div ' . $id_output . $class_output . $style_output . '>' . $sc->getContent() . '</div>';
        });

you could have

 $this->shortcode->getHandlers()->add('div', static function(ShortcodeInterface $sc) {
            $id = $sc->getParameter('id');
            $class = $sc->getParameter('class');
            $style = $sc->getParameter('style');
            $dir = $sc->getParameter('dir');

            $id_output = $id ? ' id="' . $id . '" ': '';
            $class_output = $class ? ' class="' . $class . '"' : '';
            $style_output = $style ? ' style="' . $style . '"' : '';
            $dir_output = $dir ? ' dir="' . $dir . '"' : '';

            return '<div ' . $id_output . $class_output . $style_output . $dir_output . '>' . $sc->getContent() . '</div>';
        });

(I haven't tested this code.) Or maybe I could override this shortcode on my own site. However, it seems to me that even in this case, the Nextgen Editor erases these efforts.

When in Expert Mode, if I create a div in shortcode with a dir attribute, save, and then switch to Nextgen Editor, and save again, the dir attribute disappears. So it seems that to have a hope of using this editor and having such a shortcode, there would first have to be some kind of support built in to the Nextgen Editor. Is this correct?