CKEditor 5 customize mentions output with custom text

18 views Asked by At

I followed the example for generating "custom output" found in the CKEditor documentation but it is not working as expected for me, I'm trying to insert/render the Id and other key called 'datatypeid' into ck editor as shown in pic, if I select any id I want to display datatypeid with that id

enter image description here

enter image description here

here is my code

[13:31] Jeyakumar, Jeyan (External) Actual {Repo Agent Name}

Required {Repo Agent Name}(+0)

feedItems= [{

    "id": "{xuf_date_2}",

    "name": "xuf_date_5",

    "DataTypeId": 1

},{

    "id": "@Barely Stinson",

    "name": "xuf_date_5",

    "DataTypeId": 3

}]
  editor.conversion.for('downcast').elementToElement({    
   model: 'mention',     view: (modelElement, { writer }) => {  
    const mentionLabel = `${modelElement.getAttribute('data-user-id')} (${modelElement.getAttribute('data-mention')})`;      
    const aElement = writer.createAttributeElement('a', {          
        class: 'mention',            
        'data-user-id': modelElement.getAttribute('data-user-id'),
        'data-mention':modelElement.getAttribute('data-mention'),            
         href: 'javascript:void(0)',        
        }, {            
          priority: 20,            
          id: modelElement.getAttribute('id'),        
         });        
         writer.insertText(mentionLabel, aElement);        
         return aElement;     },     converterPriority: 'high', });```

 this possible? Does anyone have any examples they could point me to?
0

There are 0 answers