Insert a field with a particular style

Hello,

I'm trying to add a MERGEFIELD field with a particular style in my document.

At this point the only things I'm able to do is apply the style to the field if the user select a part of the text, not when only the cursor is placed.

document.applyStyle always apply my style to the whole line.

Is there a way to do that ?

let styleJson = {
type: 'Character',
name: 'ElementStyle',
characterFormat: {
fontSize: 44,
fontColor: '#2F5496',
bold: true
}
}

editor.createStyle(JSON.stringify(styleJson))
editor.applyStyle('ElementStyle')

editor.insertField('MERGEFIELD ' + code + ' \\* MERGEFORMAT','{{' + label + '}}')

Thanks,
Tuan

1 Reply

SM Suriya Murugan Syncfusion Team January 25, 2021 09:39 AM UTC

Hi Tuan, 
 
Syncfusion Greetings! 
 
We need some clarification regarding your requirement. 
 
Can you please confirm whether your requirement is to apply created character style only to the field which you inserted and the text which will insert after field don’t consider that style or any other? Please share the requested details that will helpful for us to proceed further and provide you solution at earliest. 
 
 
Regards, 
 
Suriya M 


Loader.
Up arrow icon