16
Views
1
Comments
[CKEditor] CK Editor - Remove attribute when changing format tag
ckeditor
Web icon
Forge asset by CKEditor Team
Application Type
Traditional Web
Service Studio Version
10.0.1116.0

Hi there

I'm trying to block/unblock parts of a text inside CK Editor. I'm trying to do this with 2 format tags.


When I press 'Bloquear' the selected part of the text gets blocked (the attribute contenteditable is set)


but when I press 'Desbloquear', with the same text selected, nothing happens. 


Can someone guide me here?



2024-05-30 10-12-48
Anushka singh

First, you need to add custom commands to CKEditor to set and remove the contenteditable attribute. Here's how you can do it:Ensure your CKEditor is properly initialized in your application.You can add custom commands to set and remove the contenteditable attribute.The above code handles the case where the text is selected and applies/removes the contenteditable attribute. Make sure the correct element is being targeted for the attribute change. Update your CKEditor initialization code to include the new plugin: Ensure to handle edge cases, such as when no text is selected or if the selection spans multiple elements. You might need to refine the command execution logic to accommodate these scenarios.Test your implementation thoroughly to ensure that the 'Bloquear' and 'Desbloquear' buttons correctly toggle the contenteditable attribute on the selected text or elements.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.