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
Posted by: tha_watcha - Tuesday, 6 December 2022 10:08:49
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.
Posted by: BWG - Tuesday, 6 December 2022 14:51:57
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:
[code=markup]ruleEngine.AddRule(new SingleRegexReplaceRule("<table>", "[table]", Options));[/code]
Posted by: tha_watcha - Wednesday, 7 December 2022 11:40:52
[quote=BWG;73548]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:
[code=markup]ruleEngine.AddRule(new SingleRegexReplaceRule("<table>", "[table]", Options));[/code][/quote]
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
[attach]2286[/attach]
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.
Posted by: BWG - Wednesday, 7 December 2022 19:44:39
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.
Posted by: tha_watcha - Thursday, 8 December 2022 12:48:31
[quote=BWG;73550]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. [/quote]
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..
[list]
[*]Editing an Maintaining the html code
[*]Security Concerns
[*]Larger Message Storage in the db
[/list]
[quote=BWG;73550]
* 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. [/quote]
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 ?!
Posted by: BWG - Friday, 9 December 2022 15:21:58
[quote=tha_watcha;73551][quote=BWG;73550]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. [/quote]
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..
[list]
[*]Editing an Maintaining the html code
[*]Security Concerns
[*]Larger Message Storage in the db
[/list]
[quote=BWG;73550]
* 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. [/quote]
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 ?![/quote]
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 [i]yafsrc\YetAnotherForum.NET\Pages\PostMessage.ascx.cs[/i] as follows fixes the issue:
Current code:
[code=markup]HtmlHelper.StripHtml(BBCodeHelper.EncodeCodeBlocks(this.forumEditor.Text)),[/code]
Updated code:
[code=markup]string messageText = this.forumEditor.Text;[/code]
[code=markup] HtmlHelper.StripHtml(BBCodeHelper.EncodeCodeBlocks(messageText)),[/code]
Posted by: chtsec - Saturday, 28 January 2023 15:39:05