0

When I'm trying to save the html (like below) it is removing the font-family which has quotes, if I do without quotes it works fine but we need quotes for that font family (the color style is un-touched)

Input:

<div style='font-family: "Ravi Prakash"; color: #ff0000;'>
This is the Heading
</div>

Saved:

<div style="color: #ff0000;">
This is the Heading
</div>
  • 1
    Are you using rich text area field? I tried and it works.Maybe you can explain specifically what you want to achieve. – unidha May 24 '17 at 5:44
  • Yes, I'm using Froala editor for Rich Text Area. – Surya Chandra Rao Gandreddi May 24 '17 at 5:59
  • Is this related to Salesforce?When you tag Remote Action , do you mean you are trying to save this HTML using Remote Action? – unidha May 24 '17 at 6:01
  • 1
    hmm... as I wrote, when I sending the data to the RemoteAction ... it is removing that. In the DebugLogs I saw the data just before saving and I see there is no font-family after it was saved. – Surya Chandra Rao Gandreddi May 24 '17 at 6:02
  • What is the field type for value that you want to save into, is Rich Text Area? – unidha May 24 '17 at 6:03
1

I am not sure whether this will help you.This is what I experiment it.If you can see it in debug log , I assume the value is successfully passed to the controller but it is not update to the database.So this is what I did, and I check the value is saved in the database.

List<Opportunity> lst =[Select Id, Rich_Text__c from Opportunity where Id='00690000002F4sD'];

Opportunity opp = lst[0];
String str='<div style=\'font-family: "Ravi Prakash"; color: #ff0000;\'>This is the Heading</div>';
opp.Rich_Text__c =str.escapeHtml4();

update opp;

Based on this, you might want to check String class and use relevant method at your string value. In this case I use escapeHtml4().

  • It saving as &lt;p&gt;&lt;span style=&#39;color: #ff0000; font-family: &quot;Ravi Prakash&quot;, cursive;&#39;&gt;Creating Topics...!!&lt;/span&gt;&lt;/p&gt; – Surya Chandra Rao Gandreddi May 24 '17 at 13:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.