RichText removing iframe in old documents

We are having an issue with YouTube iframes being removed when pressing edit on an already-published document.

Thanks to this post RichText removing iframe - BRX 15, I have solved half our issue. We can now successfully add new documents with YouTube iframes and edit them later.

The problem is that old documents made before the fix continue to have the old issue. I am comfortable writing an updater script but cannot find what I have to update.

Please help.

Are you sure it is related to old documents and not some specific documents with different cleaner configuration? There shouldn’t be any difference in old vs new as far as I know…

Hello @machak, thank you for your assistance. The issue occurs with instances of the same doctype. This happens locally and on a test server.

As an illustration, I created an instance of a ‘news’ document on a test server before deploying the fix. After deploying the fix, the test document continued to have the same problem, while new instances of the ‘news’ doctype didn’t.

HAve you tried logging out and logging in again. The only thing I can think of is that when you open a document it initializes the editor instance for that document. That should be reset when you log out. Though it should also be reset when you close the document for editing, so it’s a bit of a stretch.

Hi @jasper.floor, thanks for the suggestion. I have just double-checked by using Incognito mode, but the issue continues.

If it helps, here is a screen recording Recording #7. ‘Test 1’ was created before deploying the fix. ‘Test 2’ was created after deploying the fix.

I agree with Marijan that if they are the same doctype there should be no difference in behavior. Obviously there is. Without a closer look at your documents/doctypes this become difficult to diagnose. Are the compounds also of the same type? best to check that in the console.

Hi @jasper.floor, apologies for not getting back sooner. The doctype and field are the same. I put a side-by-side capture together for the two instances you Recording #9.

Here is the doctype configuration https://github.com/NHS-digital-website/hippo/blob/0862ba0520356ff2fad4144f26044576b982f115/repository-data/application/src/main/resources/hcm-config/namespaces/website/news.yaml

The only thing I find in the recording #9, is that the draft node of the misbehaving document does not contain the youtube code. I tested this and that does seem to explain the behavior. So I would suggest deleting existing draft nodes. If you want to be thorough delete both draft and unpublished versions (assuming you have no unpublished changes) but I think deleting draft will likely be enough.

Thanks, @jasper.floor. I’ll follow this route and post the outcome in a few days.

Hi @jasper.floor. I may have misunderstood your last message, but deleting the draft node does not solve the issue for me.

I made a video to show you what I am seeing Recording #12.

Hi @Geoffrey,

I’ve actually managed to reproduce the behavior now. I am still at a loss to explain it. I will try to do some investigation.

Thank you, @jasper.floor.

I’ve found it I think. The ckeditor.config.appended.json on /hippo:namespaces/hippostd/html/editor:templates/_default_ is broken. Specifically the toolbargroups element. It should be like:

toolbarGroups: [{
		name: 'document'
	},
	{
		items: ['PickImage']]
}

Notice I added some curly braces.

I will admit to having had to ask a colleague who pointed out the unbalanced json. I was deep in code trying to figure out why the code was broken. The code is fine, but it really could give a warning about the broken json config.

Though please take a good look again yourself, because looking at it now I feel the snippet I pasted is still unbalanced.

Hi @jasper.floor, thank you very much. I am testing this at the moment. I will let you know how it’s gone.

Thanks for all the help @jasper.floor and @machak. It’s working correctly now.

The final JSON was { "toolbarGroups": [{"name": "document","groups": ["PickImage"]}], ...}

1 Like