YAFLogo

BWG
  • BWG
  • 100% (Exalted)
  • YAF Lover Topic Starter
2 years ago
Hi,

It looks as though most html tags in messages are stripped out by default. Is there a way to allow specific ones? I've tried using config.allowedContent in Scripts\ckeditor\config.js to enable a subset of tags (e.g. table tr th td because I want to render html tables) but it doesn't seem to make any difference. 

Am I doing something wrong or does everything have to be done via BBCcode extenstions? If it is BBCode extensions is there one for html tables?

BWG

Sponsor
tha_watcha
  • tha_watcha
  • 100% (Exalted)
  • YAF.NET Project Lead 🤴 YAF Version: 4.0.0 rc 2
2 years ago
No you dont do anything wrong. By default the editor takes only bbcode input. html tags are always been removed.

The only solution would be to create a bbcode extension for table, td and tr tags. And if you want to show the table inside the editor as table that would also require some bbcode converting. If this is needed i can build a solution for that.

BWG
  • BWG
  • 100% (Exalted)
  • YAF Lover Topic Starter
2 years ago
A regex BBCode plugin via the UI to enable tables (table, th, tr, td ) would be awesome!

As an interim I'm looking at adding some simple rules to BBCode.cs. For example:

ruleEngine.AddRule(new SingleRegexReplaceRule("<table>", "[table]", Options));
tha_watcha
  • tha_watcha
  • 100% (Exalted)
  • YAF.NET Project Lead 🤴 YAF Version: 4.0.0 rc 2
a year ago

A regex BBCode plugin via the UI to enable tables (table, th, tr, td ) would be awesome!

As an interim I'm looking at adding some simple rules to BBCode.cs. For example:

ruleEngine.AddRule(new SingleRegexReplaceRule(&quot;&lt;table&gt;&quot;, &quot;[table]&quot;, Options));

Originally Posted by: BWG 

No That wont work. you need to create a rule that converts bbcode to html. I made the changes in the repository.

There is now a table button  in the editor toolbar to create a table

 tableProperties.png You have insufficient rights to see the content.

You can also right click on an existing table and add/ remove rows and or columns.

pS: to make the button appear you need to go to Host  > Host Settings > Editors > Editor Toolbar Full and a the "Table" button.

BWG
  • BWG
  • 100% (Exalted)
  • YAF Lover Topic Starter
a year ago
Thanks. It works well.*

Just out of interest why have html tags been disallowed in YAF? Is it for security reasons or because of CKeditor? The version of YAF I was running previously used TinyMCE as the editor but I assume that is no longer an option because of licensing issues.

* A potential problem has appeared. At times there's a huge amount of white space before the table due to empty p tags being inserted. I haven't had time to look into it further but I have seen this issue on previous versions of YAF when pasting in html table with TinyMCE.  

tha_watcha
  • tha_watcha
  • 100% (Exalted)
  • YAF.NET Project Lead 🤴 YAF Version: 4.0.0 rc 2
a year ago

Just out of interest why have html tags been disallowed in YAF? Is it for security reasons or because of CKeditor? The version of YAF I was running previously used TinyMCE as the editor but I assume that is no longer an option because of licensing issues. 

Originally Posted by: BWG 

Well the main goal was to stream line everything. Instead of having multiple editors its better to have one with the best expierence and optimized for yaf, and thats why i choose CKEditor.

Originally the idea was to switch completly to html. But there are too many disavantages from using html over bbcode..

  • Editing an Maintaining the html code
  • Security Concerns
  • Larger Message Storage in the db

* A potential problem has appeared. At times there's a huge amount of white space before the table due to empty p tags being inserted. I haven't had time to look into it further but I have seen this issue on previous versions of YAF when pasting in html table with TinyMCE.  

Originally Posted by: BWG 

Well i guess thats needs improvement from pasting html tables to bbode tables. Can you post the pasted content as text file here, or the original source ?!

BWG
  • BWG
  • 100% (Exalted)
  • YAF Lover Topic Starter
a year ago

Just out of interest why have html tags been disallowed in YAF? Is it for security reasons or because of CKeditor? The version of YAF I was running previously used TinyMCE as the editor but I assume that is no longer an option because of licensing issues. 

Originally Posted by: tha_watcha 

Well the main goal was to stream line everything. Instead of having multiple editors its better to have one with the best expierence and optimized for yaf, and thats why i choose CKEditor.

Originally the idea was to switch completly to html. But there are too many disavantages from using html over bbcode..

  • Editing an Maintaining the html code
  • Security Concerns
  • Larger Message Storage in the db

* A potential problem has appeared. At times there's a huge amount of white space before the table due to empty p tags being inserted. I haven't had time to look into it further but I have seen this issue on previous versions of YAF when pasting in html table with TinyMCE.  

Originally Posted by: BWG 

Well i guess thats needs improvement from pasting html tables to bbode tables. Can you post the pasted content as text file here, or the original source ?!

Originally Posted by: BWG 

Thanks for the explanation about BBCode and editors etc. 👍

I've now had time to investigate the "problem" with BBCode tables. The empty space appears if the BBCode for the table is pasted directly into the WYSIWYG window rather than source. I've had a look at the data in SQL server and there isn't an obvious difference. 

I've found that modifying yafsrc\YetAnotherForum.NET\Pages\PostMessage.ascx.cs as follows fixes the issue:

Current code:

HtmlHelper.StripHtml(BBCodeHelper.EncodeCodeBlocks(this.forumEditor.Text)),

Updated code:

string messageText = this.forumEditor.Text;

 HtmlHelper.StripHtml(BBCodeHelper.EncodeCodeBlocks(messageText)),

 

chtsec
  • chtsec
  • 50.8% (Neutral)
  • YAF Forumling YAF Version: 3.1
a year ago
Great.