Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ghost opened this issue Apr 3, 2017 · 27 comments
Closed

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

ghost opened this issue Apr 3, 2017 · 27 comments

Comments

@ghost
Copy link

ghost commented Apr 3, 2017

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 ghost changed the title Bug in flux:field.text with CKEdit [BUG] flux:field.text with CKEdit Apr 3, 2017
@ghost ghost changed the title [BUG] flux:field.text with CKEdit [BUG][TYPO3-8.6.1] flux:field.text with CKEdit Apr 3, 2017
@ghost
Copy link
Author

ghost commented Apr 10, 2017

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

@chfoidl
Copy link

chfoidl commented Apr 11, 2017

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
Copy link
Author

ghost commented Apr 12, 2017

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
Copy link

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
Copy link
Author

ghost commented Apr 18, 2017

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
Copy link

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

@ghost
Copy link
Author

ghost commented Apr 27, 2017

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
Copy link

codeKerl commented May 5, 2017

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
Copy link

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
Copy link

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
Copy link

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
Copy link

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 added a commit to cedricziel/flux that referenced this issue Jun 27, 2017
Enables switching the CKEditor configuration based on the current field.

This option falls back to `default` and can be overriden through TypoScript:

```
plugin.tx_flux.settings.flexform.richtextConfiguration = MySite
```

Closes: FluidTYPO3#1388
@cedricziel
Copy link
Member

@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
Copy link

@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
Copy link

@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 pushed a commit to mogic-le/flux that referenced this issue Jul 24, 2017
Enables switching the CKEditor configuration based on the current field.

This option falls back to `default` and can be overriden through TypoScript:

```
plugin.tx_flux.settings.flexform.richtextConfiguration = MySite
```

Resolves: FluidTYPO3#1388
@cweiske
Copy link
Contributor

cweiske commented Jul 24, 2017

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

cweiske pushed a commit to mogic-le/flux that referenced this issue Jul 24, 2017
Enables switching the CKEditor configuration based on the current field.

This option falls back to `default` and can be overriden through TypoScript:

```
plugin.tx_flux.settings.flexform.richtextConfiguration = MySite
```

Resolves: FluidTYPO3#1388
cweiske added a commit to mogic-le/flux that referenced this issue Jul 27, 2017
Enables switching the CKEditor configuration based on the current field.

This option falls back to the system-wide flux RTE PageTSconfig:

    RTE.tx_flux.preset

If that one is not set, TYPO3's default RTE PageTSconfig is used:

    RTE.default.preset

Resolves: FluidTYPO3#1388
cweiske added a commit to mogic-le/flux that referenced this issue Jul 27, 2017
Enables switching the CKEditor configuration based on the current field.

This option falls back to the system-wide flux RTE PageTSconfig:

    RTE.tx_flux.preset

If that one is not set, TYPO3's default RTE PageTSconfig is used:

    RTE.default.preset

Resolves: FluidTYPO3#1388
cweiske added a commit to mogic-le/flux that referenced this issue Jul 27, 2017
Enables switching the CKEditor configuration based on the current field.

This option falls back to the system-wide flux RTE PageTSconfig:

    RTE.tx_flux.preset

If that one is not set, TYPO3's default RTE PageTSconfig is used:

    RTE.default.preset

Resolves: FluidTYPO3#1388
cweiske added a commit to mogic-le/flux that referenced this issue Jul 27, 2017
Enables switching the CKEditor configuration based on the current field.

This option falls back to the system-wide flux RTE PageTSconfig:

    RTE.tx_flux.preset

If that one is not set, TYPO3's default RTE PageTSconfig is used:

    RTE.default.preset

Resolves: FluidTYPO3#1388
cweiske added a commit to mogic-le/flux that referenced this issue Jul 27, 2017
Enables switching the CKEditor configuration based on the current field.

This option falls back to the system-wide flux RTE PageTSconfig:

    RTE.tx_flux.preset

If that one is not set, TYPO3's default RTE PageTSconfig is used:

    RTE.default.preset

Resolves: FluidTYPO3#1388
cweiske added a commit to mogic-le/flux that referenced this issue Jul 27, 2017
Enables switching the CKEditor configuration based on the current field.

This option falls back to the system-wide flux RTE PageTSconfig:

    RTE.tx_flux.preset

If that one is not set, TYPO3's default RTE PageTSconfig is used:

    RTE.default.preset

Resolves: FluidTYPO3#1388
@NamelessCoder
Copy link
Member

@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.

pfaffenrodt pushed a commit to pfaffenrodt/flux that referenced this issue Aug 31, 2017
Enables switching the CKEditor configuration based on the current field.

If empty, the page-wide RTE preset from PageTSconfig is used:

    RTE.default.preset

Resolves: FluidTYPO3#1388

(cherry picked from commit 00100ee)
@Kleisli
Copy link

Kleisli commented Oct 10, 2017

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
Copy link

dahaupt commented Oct 10, 2017

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

@zoranilic
Copy link
Contributor

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
Copy link

Hi, it seems like multiple issues are being discussed here. I was actually lead here by FluidTYPO3/fluidcontent#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
Copy link

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

@r12r
Copy link
Contributor

r12r commented Apr 30, 2018

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

@luzat
Copy link
Contributor

luzat commented Apr 30, 2018

@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
Copy link
Contributor

r12r commented Apr 30, 2018

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

@tagdo
Copy link

tagdo commented May 29, 2018

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?

@FluidTYPO3 FluidTYPO3 locked as resolved and limited conversation to collaborators May 29, 2018
@NamelessCoder
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests