YAFLogo

BWG
  • BWG
  • 100% (Exalted)
  • YAF Lover Topic Starter
2 months 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: 3.0.3
2 months 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 months 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: 3.0.3
2 months ago
Originally Posted by: BWG 

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));



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
2 months 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: 3.0.3
a month ago
Originally Posted by: BWG 

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. 



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


Originally Posted by: BWG 


* 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.  



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 month ago
Originally Posted by: tha_watcha 

Originally Posted by: BWG 

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. 



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


Originally Posted by: BWG 


* 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.  



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 ?!



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
8 days ago
Great.
YAF Logo Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved
About Us

The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

Powered by Resharper Donate with PayPal button