Skip to content

initial values for .editable-fields #247

Open
@trendschau

Description

@trendschau

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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions