ckeditor loses it's content after save and re-open

291 views
Skip to first unread message

Oscar Farg

unread,
Jun 13, 2014, 9:21:40 AM6/13/14
to hippo-c...@googlegroups.com
Hi,

I'm having a strange problem with ckeditor, when I edit the content from a ckeditor plugin (or directly from the console) and save the document using the normal save button in the document menu it save's the content of the ckeditor in the repository. I see the changes I made when i check all three copies of the content node in the console.

However when I start editing the document again the content that is shown in the ckeditor isn't the content from the repository. It shows the content before the first edit.

So tho put is in chronological order:

1. Edit document (insert data from plugin)
2. Save document
3. Reopen document.
4. The content is now the same as it was before step 1.

Am I forgetting something? I Implemented an AbstractDialog to open from the ckeditor, maybe i should flush the model or something after closing the dialog? 

Met vriendelijke groet | Kind regards,
Oscar Farg

KeesTM Internetbureau

  • Middelstegracht 89s
  • 2322 TT Leiden
  • 071 - 51 333 71


Volg Kees op
g+
f
w

Mathijs den Burger

unread,
Jun 13, 2014, 11:45:14 AM6/13/14
to hippo-c...@googlegroups.com
Hi Oscar,

Short answer: try calling editor.updateElement() [1] on the client side after your dialog has been closed. 

In 7.9.0, the CMS listens to 'change' events of CKEditor and then call updateElement. Maybe your dialog does not generate such a change event?

This should be be necessary anymore in the latest CMS tag (2.26.02), so you can also try to use that in your 7.9.0 project (e.g. in your project's root pom, add:

  <properties>
    <hippo.cms.version>2.26.02</hippo.cms.version>
  </properties>

Long answer: you may be hitting a bug/suboptimal implementation in 7.9.0. By default CKEditor updates the submitted textarea field automatically on form submit (i.e. when hitting the 'Save' button of a document), but since Wicket overrides the form.submit method CKEditor cannot remove those callbacks anymore. Old callbacks therefore will keep lingering around, and may interfere with the new callbacks. This has been fixed in CMS7-7993 [2], so editor.updateElement is now always called on form submit. That fix is part of CMS tag 2.26.02.

hope this helps,
Mathijs

--
Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
 
To post to this group, send email to hippo-c...@googlegroups.com
RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
---
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-communi...@googlegroups.com.
Visit this group at http://groups.google.com/group/hippo-community.
For more options, visit https://groups.google.com/d/optout.

Oscar Farg

unread,
Jun 17, 2014, 11:10:58 AM6/17/14
to hippo-c...@googlegroups.com
I think that I'm encountering a different bug.

 In my case the HTML content gets saved correctly in the repository but somehow disappears after reopening the document. If i don't reopen everything goes well. It even show's the correct content in the frontend of the website. But when I open the document to edit it again the content isn't visible anymore.

I uploaded a short screencast to show what I mean: https://www.dropbox.com/s/ewpe523cp7ribfc/flickrpicker-bug.ogv

To me it looks like the ckeditor retrieves it's content from a different place (maybe caching?) then the rest of the CMS because everywhere else it's showing the correct content. Even when I add another picture it shows both pictures in the compare view with one as removed and one as added.



Met vriendelijke groet | Kind regards,
Oscar Farg

KeesTM Internetbureau

  • Middelstegracht 89s
  • 2322 TT Leiden
  • 071 - 51 333 71


Volg Kees op
g+
f
w


Mathijs den Burger

unread,
Jun 17, 2014, 11:38:04 AM6/17/14
to hippo-c...@googlegroups.com
On Tue, Jun 17, 2014 at 5:10 PM, Oscar Farg <os...@kees-tm.nl> wrote:
I think that I'm encountering a different bug.

 In my case the HTML content gets saved correctly in the repository but somehow disappears after reopening the document. If i don't reopen everything goes well. It even show's the correct content in the frontend of the website. But when I open the document to edit it again the content isn't visible anymore.

I uploaded a short screencast to show what I mean: https://www.dropbox.com/s/ewpe523cp7ribfc/flickrpicker-bug.ogv

To me it looks like the ckeditor retrieves it's content from a different place (maybe caching?) then the rest of the CMS because everywhere else it's showing the correct content. Even when I add another picture it shows both pictures in the compare view with one as removed and one as added.

Which HTML element does your plugin add exactly? Could it be that the advanced content filter in CKEditor does not allow that element and removes it when CKEditor loads the content again? In that case the element should also be removed when you switch to source mode and back to WYSIWYG mode again.

Mathijs

Oscar Farg

unread,
Jun 18, 2014, 2:48:42 AM6/18/14
to hippo-c...@googlegroups.com
I'm adding an <img />-tag. You're right about the switching back and forward between source and wysiwyg. That also removes the tag.





Met vriendelijke groet | Kind regards,
Oscar Farg

KeesTM Internetbureau

  • Middelstegracht 89s
  • 2322 TT Leiden
  • 071 - 51 333 71


Volg Kees op
g+
f
w


Mathijs den Burger

unread,
Jun 18, 2014, 4:00:23 AM6/18/14
to hippo-c...@googlegroups.com
That's indeed the advanced content filter [1] kicking in. Since your plugin adds an 'img' element, it should tell CKEditor this element is allowed content. Something like:

  editor.ui.addButton('MyButton', {
    label: 'My Button'
    command: 'mycommand',
    allowedContent: 'img[!src,alt]',
    requiredContent: 'img[!src]'
  });

The 'PickImage' button of the 'hippopicker' plugin is, by default, the only plugin that defines the 'img' tag as allowed content. However, that plugin also sets various meta-data attributes (like 'data-uuid' and 'data-type') and requires these attributes to be present. In your current situation, CKEditor there thinks that an img tag without those attributes (like the one added by your plugin) is not allowed and strips it.

hope this helps,
Mathijs

Oscar Farg

unread,
Jun 18, 2014, 4:10:51 AM6/18/14
to hippo-c...@googlegroups.com
Thanks,

I was just about to respond that I found the solution (same as yours).
I found this page http://docs.ckeditor.com/#!/guide/plugin_sdk_integration_with_acf with a bit more detailed instructions.
 
Thanks for the help.

Met vriendelijke groet | Kind regards,
Oscar Farg

KeesTM Internetbureau

  • Middelstegracht 89s
  • 2322 TT Leiden
  • 071 - 51 333 71


Volg Kees op
g+
f
w


Mathijs den Burger

unread,
Jun 18, 2014, 4:55:54 AM6/18/14
to hippo-c...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages