1. Add "Text (formatted)" to a user - leave all settings at default
  2. Edit account
  3. Add text to field - Save account
  4. Edit account change to restricted html, text disappears, add new text - Save account
  5. Edit account change to Basic Html, text disappears, add new text - Save account
  6. Can't view text the updated text.

Comments

boyan.borisov’s picture

Assigned: Unassigned » boyan.borisov
Issue tags: +DrupalCampLDN
boyan.borisov’s picture

Assigned: boyan.borisov » Unassigned
boyan.borisov’s picture

Issue tags: +JS

It works if you disabled the javascript. So it should be a javascript issue.

boyan.borisov’s picture

Issue tags: -JS +JavaScript
idebr’s picture

swentel’s picture

So, lot's of issues it seems with ckeditor and textfields - see https://www.drupal.org/node/971632
Looks like ckeditor by default isn't designed to work with them ..

Why do we even attach an editor to it anyway ? It feels very weird to me. But it also makes little sense on a storage level because you're limited to 255 chars by default.

So, there are a couple of options

- remove text formatted - might be little hard since we do allow it in D7 as well
- do not attach ckeditor to textfields - if you really want one, use long, the use case just makes more sense on a textarea input.

swentel’s picture

Assigned: Unassigned » swentel

Talked with alexpott - The idea is that we would add a configuration option to the Editor plugin that allows us to tell whether an editor works on a textfield input or not.

Working on a patch for proof of concept.

swentel’s picture

Status: Active » Needs review
Issue tags: +Needs manual testing
StatusFileSize
new3.41 KB

This adds 'supports_textfields' to the annotation.

wim leers’s picture

Component: text.module » editor.module
Issue tags: +Needs tests
StatusFileSize
new719 bytes

Why do we even attach an editor to it anyway ? It feels very weird to me. But it also makes little sense on a storage level because you're limited to 255 chars by default.

Exactly.

What about this alternative approach? I don't think it ever makes sense to attach a rich text editor to something that cannot even fit a rich text. So then I think we can take this simpler approach.

The last submitted patch, 8: 2442255-8.patch, failed testing.

wim leers’s picture

StatusFileSize
new842 bytes

Something like this would easily allow contrib to still support #base_type => textfield.

swentel’s picture

StatusFileSize
new4.14 KB

So something like this ?

What's the best way to test this ? assertRaw on javascript settings ?

wim leers’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/editor/src/Annotation/Editor.php
    @@ -62,4 +62,11 @@ class Editor extends Plugin {
    +   * A list of element types this editor supports.
    

    s/editor/text editor/

  2. +++ b/core/modules/editor/src/Annotation/Editor.php
    @@ -62,4 +62,11 @@ class Editor extends Plugin {
    +   * @var array
    

    string[]

  3. +++ b/core/modules/editor/src/Annotation/Editor.php
    index 1631ec9..9d0f77e 100644
    --- a/core/modules/editor/src/EditorInterface.php
    
    +++ b/core/modules/editor/src/EditorInterface.php
    @@ -79,4 +79,12 @@ public function getImageUploadSettings();
    +  public function getSupportedElementTypes();
    
    +++ b/core/modules/editor/src/Element.php
    index 71cfbef..73844a0 100644
    --- a/core/modules/editor/src/Entity/Editor.php
    

    Why do this at the config entity level?

    If you grep the code base for is_xss_safe, you'll see how that other annotation is handled, IMO it should be handled similarly.

RE: how to test: see EditorLoadingTest. You'll want to add a "Text (formatted)" field to e.g. the "page" bundle (not "article", because that's already used for the existing tests). And then something like:

    $this->drupalLogin($this->privilegedUser);
    $this->drupalGet('node/add/bundle');
    list( , $editor_settings_present, $editor_js_present, $body, $format_selector) = $this->getThingsToCheck();
    $this->assertFalse($editor_settings_present, 'No Text Editor module settings.');
    $this->assertFalse($editor_js_present, 'No Text Editor JavaScript.');
    $textfield = … some xpath.
    $this->assertTrue(count($textfield) === 1, 'A textfield exists.');
    $this->assertTrue(count($format_selector) === 1, 'A single text format selector exists on the page.');

… to test the case of a text editor like CKEditor, which does not support #type => textfield. But you'll probably want to test the inverse too: a text editor that does support that.

The last submitted patch, 12: 2442255-12.patch, failed testing.

swentel’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new9.36 KB
new13.99 KB

Test patch - will fix the rest of the review after this comes back

The last submitted patch, 15: 2442255-14-fail.patch, failed testing.

The last submitted patch, 15: 2442255-14.patch, failed testing.

swentel’s picture

StatusFileSize
new13.1 KB
new13.66 KB

re: 13

1. Fixed
2. Fixed
3. Ok, makes sense (fixes the fail in the previous patch as well at the same time)
4. Tests added: tests unicorn which supports textfields, ckeditor which doesn't.

The last submitted patch, 18: 2442255-18.patch, failed testing.

wim leers’s picture

Status: Needs review » Needs work

Mostly nitpicks, one more problematic thing.

  1. +++ b/core/modules/editor/src/EditorInterface.php
    @@ -44,6 +44,14 @@ public function getFilterFormat();
       /**
    +   * Set the text editor plugin ID.
    +   *
    +   * @return \Drupal\editor\EditorInterface
    +   *   The called editor entity.
    +   */
    +  public function setEditor($editor);
    

    Missing @param docs.

    Also: good catch (that that was missing).

  2. +++ b/core/modules/editor/src/Entity/Editor.php
    @@ -81,6 +81,7 @@ public function __construct(array $values, $entity_type) {
    +    $definition = $plugin->getPluginDefinition();
    

    This is now obsolete.

  3. +++ b/core/modules/editor/src/Tests/EditorLoadingTest.php
    @@ -21,7 +23,7 @@ class EditorLoadingTest extends WebTestBase {
    -  public static $modules = array('filter', 'editor', 'editor_test', 'node');
    +  public static $modules = array('filter', 'editor', 'editor_test', 'node', 'ckeditor');
    

    The editor module's tests specifically don't depend on ckeditor module. I'm afraid that means you'll have to introduce another dummy text editor, besides the Unicorn one. The upside: you get to pick a funky name! :D

  4. +++ b/core/modules/editor/src/Tests/EditorLoadingTest.php
    @@ -63,16 +65,42 @@ protected function setUp() {
    +    // Create textfield.
    

    Create a formatted text field, which uses an <input type="text">.

  5. +++ b/core/modules/editor/src/Tests/EditorLoadingTest.php
    @@ -63,16 +65,42 @@ protected function setUp() {
    +    entity_create('field_storage_config', array(
    

    FieldStorageconfig::create(

  6. +++ b/core/modules/editor/src/Tests/EditorLoadingTest.php
    @@ -63,16 +65,42 @@ protected function setUp() {
    +    entity_create('field_config', array(
    

    FieldConfig::create(

  7. +++ b/core/modules/editor/src/Tests/EditorLoadingTest.php
    @@ -160,7 +188,7 @@ public function testLoading() {
    -    // Create an "article" node that users the full_html text format, then try
    +    // Create an "article" node that uses the full_html text format, then try
    

    Hah :)

  8. +++ b/core/modules/editor/src/Tests/EditorLoadingTest.php
    @@ -183,7 +211,62 @@ public function testLoading() {
    +  public function testSupportedElementTypes() {
    +
    +    // Associate the unicorn text editor with the "Full HTML" text format.
    

    Extraneous blank line.

  9. +++ b/core/modules/editor/tests/modules/src/Plugin/Editor/UnicornEditor.php
    @@ -19,7 +19,10 @@
    + *   supported_element_types = {
    + *     "textarea", "textfield"
    + *   }
    

    I think we usually put these on multiple lines?

larowlan’s picture

Assigned: swentel » larowlan

timezones++
working on nits, will re-assign to swentel when done

larowlan’s picture

Assigned: larowlan » swentel
Status: Needs work » Needs review
StatusFileSize
new7.65 KB
new15.33 KB

introducing T-Rex editor :)
fixes #21

swentel’s picture

Status: Needs review » Needs work

The last submitted patch, 22: text-formatted-2442255.22.patch, failed testing.

larowlan’s picture

Assigned: swentel » larowlan

fixing fails

larowlan’s picture

Assigned: larowlan » swentel
Status: Needs work » Needs review
StatusFileSize
new1.33 KB
new16.4 KB

you need to summon the t-rex

larowlan’s picture

Issue summary: View changes
StatusFileSize
new30.4 KB

embedding @swentel's image

rteijeiro’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new94.65 KB
new102.22 KB
new36.53 KB
new88.94 KB

Looks good to me! RTBC?

Text Field Settings BEFORE

Text Field Settings AFTER

Text Field Content

Text Field Content Saved

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

This issue addresses a critical bug and is allowed per https://www.drupal.org/core/beta-changes. Committed 7af2ce7 and pushed to 8.0.x. Thanks!

  • alexpott committed 7af2ce7 on 8.0.x
    Issue #2442255 by swentel, larowlan, rteijeiro, Wim Leers: Changing text...
wim leers’s picture

Issue tags: +Hilarious patch of the month

swentel++
larowlan++

  1. +++ b/core/modules/editor/src/Tests/EditorLoadingTest.php
    @@ -47,6 +50,10 @@ class EditorLoadingTest extends WebTestBase {
    +    // Let there be T-rex.
    

    :D

  2. +++ b/core/modules/editor/src/Tests/EditorLoadingTest.php
    @@ -47,6 +50,10 @@ class EditorLoadingTest extends WebTestBase {
    +    \Drupal::state()->set('editor_test_give_me_a_trex_thanks', TRUE);
    

    :D

  3. +++ b/core/modules/editor/tests/modules/config/schema/editor_test.schema.yml
    @@ -7,3 +7,11 @@ editor.settings.unicorn:
    +editor.settings.trex:
    +  type: mapping
    +  label: 'T-Rex settings'
    +  mapping:
    +    stumpy_arms:
    +      type: boolean
    +      label: 'Stumpy arms'
    

    <3

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.