Changes between Initial Version and Version 1 of Ticket #13194, comment 9


Ignore:
Timestamp:
Apr 21, 2015, 3:23:53 AM (10 years ago)
Author:
ctrl
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #13194, comment 9

    initial v1  
    22> You could never rely on the empty content. User could focus the editor, remove all data and blur it. There would be an filled block after that but the placeholder should be displayed anyway.
    33
    4 This wasn't the scenario until recently. When you remove all data and blur, the content would be empty. That's why we had elegant solution based on `:empty` pseudo class.
     4This wasn't the scenario until recently. When you remove all data and blur, the content would be empty, without any <p><br></p> or only <br>. That's why we had elegant solution based on `:empty` pseudo class.
    55
    66Replying to [comment:7 Reinmar]:
    77> As for the other solutions, I think that if the `:empty` pseudoclass does not work (you could add placeholder by `::before`) and I know that browsers implemented that pseudoclass poorly, you will need to use JS. I would base it on the editor#change event and adding class to the editable element, so a placeholder can be added in the first block using `::before`.
    88
    9 But how do you check if the content is empty or not? And what exactly means empty content? For CKEditor it seems empty content is content, which contains <p><br></p>, on only <br> (in case of H1 ), or who knows what else. I'm sorry, but this just does not make any sense?
     9
     10I'm trying to imagine this approach:
     11We set the placeholder initially using JavaScript and ::before selector (and only if we don't have content already). This is already bad approach, because the user will see blank field and as soon as JavaScript initializes, the placeholder will appear. But let's continue:
     12Then, we subscribe to editor#change event and as soon as we receive it, we remove the placeholder, if the content is empty. The question is - how do we check if the content is empty? And what exactly means empty content? For CKEditor it seems empty content is content, which contains <p><br></p>, on only <br> (in case of H1 ), or who knows what else. This means on editor#change event we will have to compare the current content with the content, which CKEditor sets in case of "empty" editor, or what? I'm sorry, but all this just does not make sense?
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy