rapila / cms-base

The rapila cms’ internals. Please file all issues here if they’re not directly related to a plugin or the sample site.
http://www.rapi.la
3 stars 1 forks source link

Richtext loses content after saving - Windows #209

Open juergmessmer opened 9 years ago

juergmessmer commented 9 years ago

If texts are pasted into the richtext editor, it happens - for some people frequently - that the content is lost after saving.

It looks like it's related to paste Word content, sometimes with the plugin “Insert as text” or the tool ”remove formats”. We tried to reproduce the problem using our Windows environment on the Mac. It might happen when the editor is not loaded yet properly. Though it's hard to clearly reproduce, a few clients always encounter this problem and find it very bothersome!

Since this problem seems to be a recent one and since we introduced resource consolidation also fairly recently, and since there are issues reported related to resource consolidation (https://github.com/rapila/cms-base/issues/208), it's good to check and exclude this possibility.

Maybe an update of CKEditor might help too.

sabberworm commented 9 years ago

It might happen because the html is not well-formed.

On 20.06.2015, at 13:44, Jürg Messmer notifications@github.com wrote:

If texts are pasted into the richtext editor, it happens - for some people frequently - that the content is lost after saving.

It looks like it's related to paste Word content, sometimes with the plugin “Insert as text” or the tool ”remove formats”. We tried to reproduce the problem using our Windows environment on the Mac. It might happen when the editor is not loaded yet properly. Though it's hard to clearly reproduce, a few clients always encounter this problem and find it very bothersome!

Since this problem seems to be a recent one and since we introduced resource consolidation also fairly recently, and since there are issues reported related to resource consolidation (#208), it's good to check and exclude this possibility.

Maybe an update of CKEditor might help too.

— Reply to this email directly or view it on GitHub.

juergmessmer commented 8 years ago

This happened to me too on a Mac Firefox, editing a Richtext of Notes/News module - just writing plain text, not importing formatted html.

tgressly commented 8 years ago

Clients keep reporting this issue.

juergmessmer commented 6 years ago

This is definitely still an issue (across os) that I've been following up but have not found a solution yet (nor a sufficient understanding).

In some widgets we handle it like this:

Widget.types['some_detail'] = {
    initialize: function() {
            this.text_body = this._element.find('div.text_body');
                this.handle('opened', function() {
            this.init_textarea();
        });
        this.handle('saving', function(event, data) {
            data.body = _this.text_body_editor.get_data();
        }.bind(_this));
    },

    fill_data: function() {
        this.init_textarea();
        this.loadData(function(data) {
            this.text_body.ensureWidget(function(widget) {
                widget.set_data(data.Body);
            });
        });
    },

    init_textarea: function() {
        var _this = this;
        if(!this.text_body.didPrepareWidget()) {
            this.text_body.attr('data-widget-session', this.settings.richtext_session).prepareWidget(function(rich_text_widget) {
                _this.text_body_editor = rich_text_widget;
                jQuery.extend(rich_text_widget.settings, _this.settings.richtext_settings);
            }, jQuery.noop);
        }
    },
};

It looks like it works, though doubts remain. Recently we discussed this (as far as I remember) and (i) did implement it in a simple way, and it seemed to work well, nice and easy!

Widget.types['other_detail']= {
    initialize: function() {
    },

    prepare: function() {
        var _this = this;
        this.text_widget = this._element.find('.text-widget').attr('data-widget-session', this.settings.richtext_session);
        this.text_widget.prepareWidget(function(text_widget) {
            _this.handle('saving', function(event, data) {
                data.text = text_widget.get_data();
            });
        }.bind(this));
    },

    fill_data: function() {
        this.loadData(function(data) {
            this.text_widget.ensureWidget(function(widget) {
                widget.set_data(data.Text);
            });
        });
    },
};

Now I tested this strategy thoroughly and found out that it works "all the time" except when the widget is loaded the first time (first time opened, after logout and clear caches etc.). It feels like it's loaded properly, but then cleared again. Most probably the widget is not prepared yet.

For it's simplicity and "semantic correctness" I like this strategy: 1. Prepare, 2. Ensure. But: it doesn't work the way I'd like it to work.

Since I don't understand Javascript well enough, here my questions:

juergmessmer commented 6 years ago

Naivly speaking: make fill_data (loadData) wait until the - in this case - relevant richtext widget is prepared?