FluidTYPO3 / flux

TYPO3 extension Flux: Dynamic Fluid FlexForms
https://fluidtypo3.org
145 stars 214 forks source link

[BUG][TYPO3-8.6.1] flux:field.text with CKEdit #1388

Closed ghost closed 7 years ago

ghost commented 7 years ago

Hi,

first of all please excuse my poor english due to it not being my native language. I hope you can get what i am pointing at nonetheless.

With an Update to Version 8.6.1 and activating CKEdit as RTE the editor shows a pretty unwanted behavior. On every save-action there are empty lines added around every line-end. This results in multiple

&nbsc;

with an exponential growth. This problem only occurs within flux-forms. When adding a rte-field with FlexForms everything works as intended.

Example with Flux (adding tons of empty lines):

<flux:field.text
    name="text"
    label="SomeLabel"
    required="true"
    enableRichText="true"
/>

Example with Flexform (working as intended):

<TCEforms>
    <label>SomeLabel</label>
    <config>
        <type>text</type>
        <cols>48</cols>
        <rows>4</rows>
        <enableRichtext>1</enableRichtext>
    </config>
    <defaultExtras>richtext[*]:rte_transform[]</defaultExtras>
</TCEforms>

I am not sure what transformations are applied to the flux-field-content but since it only occurs with the usage of flux i guess that the bug is not related to the core and i hope you have the time to have a look at it soon. Please tell me what additional information you need or what further steps i could take to better assist you.

Kind regards Patric

edit: using flux 8.1.0 from ter

ghost commented 7 years ago

This behavior is still showing up on typo3 8.7 with the latest development-branch of flux.

chfoidl commented 7 years ago

I ran into the same problem today. I was using TYPO3 8.7.0 and latest flux release.

By looking at the TCA configuration for the default content elements of TYPO3 i noticed that there is additional configuration for content elements which use the RTE. The TCA configuration for the type text for example shows the following configuration in typo3/sysext/frontend/Configuration/TCA/tt_content.php:1354:

'columnsOverrides' => [
    'bodytext' => [
        'config' => [
            'enableRichtext' => true,
            'richtextConfiguration' => 'default'
        ]
    ]
]

I was able to fix the problem in flux by adding the above configuration to the buildConfiguration() function in Classes/Form/Field/Text.php like so:

if (true === $this->getEnableRichText()) {
    $configuration['enableRichtext'] = true;
    $configuration['richtextConfiguration'] = 'default';
}

Just add it before $configuration is returned.

ghost commented 7 years ago

Hi,

thanks a lot for your investigation and the fix for the problem. This saved my weekend ;)

$configuration['richtextConfiguration'] = 'default';

This also explains why RTE-fields added by flexforms ignore the typoscript-settings for the configuration.

Let's hope that namelesscoder will find a way for this to reach the next release.

edit: too fast concerning the config issue. this setting gets ignored as well. but this is another issue.

ilomedia commented 7 years ago

Had the same problem with both TYPO3 8.6 + rte_htmlarea and TYPO8.7 + CKEditor so i don't think it is related to the RTE but to the TYPO3 core (nevertheless flux should take it into account)

beware that CKEditor allows to have different RTE configuration depending on the field (see below) and that hard coding "default" does not seem to be the best solution (but it fixes this problem indeed)

RTE.tt_content.types.textmedia.bodytext.preset = full RTE.config.tx_news_domain_model_news.bodytext.preset = default

ghost commented 7 years ago

The config is another issue then the empty lines and is completely messy with any kind of flexform-rte-fields and is definitely a core issue. the empty lines on the other hand have only shown up in flux and the problem gets fixed by setting $configuration['enableRichtext'] = true; as stated above.

maryisdead commented 7 years ago

Is the richtextConfiguration issue reported somewhere? Can't find anything about it.

ghost commented 7 years ago

There was a post on the german forums, reporting this issue, where someone wanted to create the issue. It seems like that never happened.

forum-thread: https://forum.typo3.org/index.php/t/215825/

I am pretty busy atm and cant take look into the issues atm. I hope i have the time tomorrow.

codeKerl commented 7 years ago

Hi, is there another solution in sight? The solution stated above works for me, because the Editor (CK in my Case) doesn't save the <p>&nbsp;</p> Blocks to the Database. ~But while editing they are still there. That might confuse the Editors.~ edit TheNaderio is right. This behaviour occurs only in unsaved, older contentelements. New elements are saved correctly!

I did a little research and maybe I have found something. The standard Typo3 'text' element ('bodytext' column in DB) has no empty lines between closing tag and new opening tag. The 'fluicontent-content' element ('pi_flexform' column) has these empty lines. I think the Editor takes these lines (while re-editing) and interprets them as empty paragraphs. Without the fix the empty paragraphs, get saved to the DB. Again with empty lines before and after. So on re-re-editing there are two new empty paragraphs and so on...

A solution might be to prevent these empty lines. I have no idea where to do this, if this is an easy fix, or if it's even possible.

Edit: Typo3 8.7.1 / Flux 8.2.1 / CKEditor

TheNaderio commented 7 years ago

The solution stated above works for me, because the Editor (CK in my Case) doesn't save the <p>&nbsp;</p> Blocks to the Database. But while editing they are still there. That might confuse the Editors.

I added $configuration['enableRichtext'] = true; directly into the if (true === $this->getEnableRichText() && true === empty($defaultExtras)) {} statement, and my content is saved correctly AND i can edit it without the empty lines.

manishjaingit commented 7 years ago

Hello, I have the same problem TYPO8.7.1 + CKEditor so i don't think it is related to the RTE but to the TYPO3 core (nevertheless flux should take it into account)

I have this in TYPOscript but does not work for me, can any one know about it.

RTE.tt_content.types.textmedia.bodytext.preset = full RTE.config.tx_news_domain_model_news.bodytext.preset = default

spackmat commented 7 years ago

I can confirm the solution, @TheNaderio suggested. I patched Classes/Form/Field/Text.php accordingly and the empty paragraphs are not created anymore. No need to hardcode $configuration['richtextConfiguration'] = 'default';, too, as it was suggested earlier.

olegkarun commented 7 years ago

Who know why flux:field.text don't want get my custom YAML config. All tt_content's RTE get my custom settings instead flexform - custom fluidcontent elements

/* https://docs.typo3.org/typo3cms/extensions/core/Changelog/8.6/Feature-79216-AddYAMLConfigurationForCKEditorRTE.html */
.. ext_localconf.php
$GLOBALS['TYPO3_CONF_VARS']['RTE']['Presets']['hit_custom'] = 'EXT:huskytheme/Configuration/RTE/Custom.yaml';
.. my TSconfig
RTE.default.preset = hit_custmom

Have influence for all RTE instead flexform, why?

cedricziel commented 7 years ago

@olegkarun You particular problem is that the flexforms for fluidcontent are entirely created by flux and dont tage you PageTS into account.

For the rest: I've pushed a fix in #1426 - could you please test it and report your results there?

codeKerl commented 7 years ago

@cedricziel your patch seems to address the problem of @olegkarun. After patching my files, the problem with the empty lines reappeared. So far only the fix posted from patricsmn (18 Apr.) did the trick (later refined by @TheNaderio). In my opinion it's based in my assumption from 5 May.

Your fix takes the RTE configuration 'default' into account, but I didn't try it with a custom one. But I'will. Maybe @olegkarun can tell you something about that, but the problem discussed in this thread seems to be still unsolved.

olegkarun commented 7 years ago

@codeKerl issue with empty line just solved with hard code in flux. More info here https://stackoverflow.com/questions/44844329/fluxfield-text-ckeditor-add-new-empty-p-p-in-backend-every-save-action

cweiske commented 7 years ago

TYPO3 8.0 dropped defaultExtras. RTE is enabled with the richtextEnabled TCA config now, see https://git.typo3.org/Packages/TYPO3.CMS.git/blob/HEAD:/typo3/sysext/core/Documentation/Changelog/8.6/Deprecation-79341-TCARichtextConfigurationInDefaultExtrasDropped.rst

"Normal" TCA gets automatically migrated, but since this here is dynamically created this migrator does not work.

That core change was in commit https://git.typo3.org/Packages/TYPO3.CMS.git/commit/00677ce4cc5731d6adb621d011caca7fcbd34274

NamelessCoder commented 7 years ago

@cweiske It was dropped in 8.6 (I assume it's just a typo). Doesn't matter if it had been 8.0 though since our minimum is now 8.7 and we can remove our defaultExtras.

Kleisli commented 7 years ago

Do you plan to release a 8.7 tag of flux? I think its a pity that this is fixed for over 3 months now, but I can't include it in my composer.json..

dahaupt commented 7 years ago

@NamelessCoder I would also appreciate a new release to get this working with Typo3 ^8.7 :)

zoranilic commented 7 years ago

One suggestion before this is added to a new Flux version. Override the "FluidTYPO3\Flux\Form\Field\Text" class and extend it with your class in your extension and just add this method inside:

public function buildConfiguration()
    {
        $configuration = parent::buildConfiguration();
        if(true === $this->getEnableRichText() && true === empty($defaultExtras)) {
            $configuration['enableRichtext'] = true;
            $configuration['defaultExtras'] = '';
        }
        return $configuration;
    }

This will do the trick.

RKlingler commented 7 years ago

Hi, it seems like multiple issues are being discussed here. I was actually lead here by https://github.com/FluidTYPO3/fluidcontent/issues/422 which describes my problem accurately.

Is my understanding correct, that in its current development version CK editor presets now also work with Flux templates? If so, when can we expect this fix/feature to be released?

I'm currently updating a site that uses both, Flux and a customized RTE quite extensively.

codeKerl commented 6 years ago

@RKlingler: That's correct! But a colleague of mine had this problem again, while copying old RTE-content into the new CK-Editor.

r12r commented 6 years ago

There is still no 8.7 tag. How you handle this problem in composer projects?

luzat commented 6 years ago

@r12r:

  1. You could install from GitHub: First, add the repository to composer.json ("repositories":[{"type":"vcs","url":"https://github.com/FluidTYPO3/flux.git"}]), next either composer require fluidtypo3/flux:dev-development for the branch (breaks easily) or use a specific commit that already contains the fix (e.g. composer require fluidtypo3/flux:dev-development#00100eee7ea4c6386ec0ab297a5c23fef3689962).

  2. To just get a fix (probably the best solution): Extend FluidTYPO3\Flux\Form\Field\Text (class MyText extends \FluidTYPO3\Flux\Form\Field\Text { … }) and override buildConfiguration as in the comment above and XCLASS Text:

$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\FluidTYPO3\Flux\Form\Field\Text::class] = ['className' => \Vendor\Field\MyText::class];
  1. You could also fork flux and cherry-pick patches, add your own repository as in 1. and use a tag from that until it's tagged here.
r12r commented 6 years ago

@luzat Thomas, the xclass solution works very well. Thanks!

tagdo commented 6 years ago

Hi there, i solved the problem specified at top as Sethorax described, by adding the following code in Text.php: public function buildConfiguration() { ... if (true === $this->getEnableRichText()) { $configuration['enableRichtext'] = true; $configuration['richtextConfiguration'] = 'default'; } ... }

But my system will be updated by composer, so if i change anything in extension-directories class-file it will be overwritten on next composer update. Can somebody tell me how i can solve this problem by adding the code in external file by using composer?

NamelessCoder commented 6 years ago

Please use the development branch. Or follow the advice above and use XCLASS if for some reason you cannot use the development branch.

Locking issue since it was closed almost one year ago.