Skip to content
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

Richtext loses content after saving - Windows #209

Open
juergmessmer opened this issue Jun 20, 2015 · 5 comments
Open

Richtext loses content after saving - Windows #209

juergmessmer opened this issue Jun 20, 2015 · 5 comments
Assignees
Milestone

Comments

@juergmessmer
Copy link
Member

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.

@juergmessmer juergmessmer added this to the Release 1.5 milestone Jun 20, 2015
@sabberworm
Copy link
Member

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

On 20.06.2015, at 13:44, Jürg Messmer [email protected] 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.

@sabberworm sabberworm changed the title Richtext looses content after saving - Windows / possibly Word content related Richtext loses content after saving - Windows / possibly Word content related Jun 22, 2015
@juergmessmer
Copy link
Member Author

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 tgressly changed the title Richtext loses content after saving - Windows / possibly Word content related Richtext loses content after saving - Windows Aug 24, 2015
@tgressly
Copy link
Member

Clients keep reporting this issue.

@juergmessmer
Copy link
Member Author

juergmessmer commented May 20, 2018

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:

  • why does ensureWidget not "include" didPrepareWidget?
  • is there a way to make this richtext handling simpler and safe at the same time?

@juergmessmer
Copy link
Member Author

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

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

No branches or pull requests

3 participants