🇮🇳India @pravat231

Account created on 4 February 2011, almost 14 years ago
#

Recent comments

🇮🇳India pravat231

Thanks @jon for your reply. Fortunately I was able to solve this use case using

data.processor.toView(newElement);
data.toModel(newViewFragment);
model.insertContent(modelFragment, range);
🇮🇳India pravat231

Hi @Jons / @Wim,

Any idea how to get this feature done in CKEditor5 in my existing CKEditor4 this below code is helping in selecting the whole sentence if I choose any word from the whole sentence wrapped with <text-format-custom> tag;

e.g. This <text-format-custom type="***">is test sentence to show the</text-format-custom> example.

In this above sample text If I select only "show" then as it was wrapped with <text-format-custom> tag then it will select the whole sentence "is test sentence to show the"

CKeditor4 Working Code

    const selection = editor.getSelection();
    const selectedElement = selection.getSelectedElement();

    if (selectedElement && selectedElement.is('text-format-custom')) {
      return selectedElement;
    }

    const range = selection.getRanges(true)[0];

    if (range) {
      range.shrink(CKEDITOR.SHRINK_TEXT);
      return editor.elementPath(range.getCommonAncestor()).contains('text-format-custom', 1);
    }
🇮🇳India pravat231

Hello @jons,

With Drupal 9.5 and CKEditor 5 plugin creation process, automatically this <text-format-custom type> is coming under allowed tags. And even I tried disabling the Limit allowed HTML tags and Correct faulty & chopped off HTML

Now I am able to see these custom tags with attributes in my ckeditor properly saved. But its not coming in my page. Do I need to add any ckeditor plugin JS file.

Regards,
Pravat

🇮🇳India pravat231

Hi @jons @Wim Leers

Thank you so much for sharing your experience. It helped me to resolve my issue. All my editor issues resolved. And I am able to save these custom tags with attributes. e.g. <text-format-custom type="xss">

But I am facing only one issue now, after saving these data. These custom tags with attribute not coming in my Drupal pages. All other tags <b> <hr> all these tags are coming even If try to save only <text-format-custom> then its showing in my saved pages but <text-format-custom type="xss"> these tags are stripped before loading into the pages.

May I know how to solve this issue for the Drupal pages not to strip these tags with attributes?

🇮🇳India pravat231

Instead of calling the ajax.success directly, we should call with Promise which would solve the problem. This patch will solve your problem. patch created from this version 8.x-1.x

Production build 0.71.5 2024