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

initial values for .editable-fields #247

Open
trendschau opened this Issue Jun 23, 2014 · 0 comments

Comments

Projects
None yet
3 participants
@trendschau

trendschau commented Jun 23, 2014

I struggled upon a small problem: If you start with an empty .editable-field, the .editable-field is much smaller due to the missing html-tags

<p><br class="_moz"></p>

So if you start to write something, everything jumps a bit around. You can reproduce this in your demo (latest firefox), if you delete the initial content and then start to write (e.g. the multiple-editor-demo).

I think it's quite a common usecase, as you always start with an empty sheet. My solution so far is to fill up all the empty .editable-fields before I load the medium-script, something like this:

<script>
    var fillEditor = document.getElementsByClassName('editable');
        numberEditors = fillEditor.length;
    for(var i = 0; i < numberEditors; i++)
    {
        var fill = fillEditor[i].innerHTML;
        fill = (fill.trim) ? fill.trim() : fill.replace(/^\s+/,'');
        if(fill == '')
        {
            fillEditor[i].innerHTML = '<p><br style="_moz"></p>';
        }
    }   
</script>

The solution is quite dirty, but it works. Or did I miss something and there is a better solution already?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment