TinyMCE is used in one of my projects as it was meant to be used; a WYSIWYG HTML editor.
I created a number of plug-ins for it that inserts certain fragments of text into the HTML and all is working fine. The plug-ins use TinyMCE's createMenuButton to create a menu button and tinyMCE.activeEditor.execCommand('mceInsertContent', ...) to do the inserting.
Now I need to add an editor for plain text in the same project. The text-only editor would also need to be able to insert those same fragments of text into plain <textarea> or <input type="text"> inputs.
Rather than duplicating code, I'd like to re-use the plug-ins written for TinyMCE.
Is there any way to either use TinyMCE as a plain text editor or use just the individual plug-ins?
I'm using TinyMCE 3 and can't upgrade to 4 due to missing essential features.
You could use the editor "as is", but strip the html tags afterwards.
Related
I’m using quill editor in my template and the editor’s content is bound via [(ngModel)] to a variable in my component which is basically a text with some html tags in it. What I discovered is that if I change the variable’s value the quill editor formats its text and replaces all occurrences of the <div> tag with <p>. In my case this turned out to be very useful and I’d like to understand how this works and how to emulate this behavior in my Angular component to use it for formatting other text values? Is there a way to dynamically pass text to Quill and then get back the formatted value, e. g. via a method call on the editor?
I've just installed CKeditor rich text WYSIWYG editor on a site I'm building and it seems to be working ok except for the fact that it inserts text into my mysql database as encoded html rather than regular html and then when the browser outputs this text it converts the encoded data into regular html that then displays in the browser showing the html tags and none of the styling!?
eg I type:
"This is text"
into the editor and it then inserts
<p>This is text</p>
into the database. Then when the page is called the browser converts the above and outouts the following on the page:
<p>This is text</p>
obviously I just want "This is text" to display on the page.
Does anyone know why this is happening/how to solve it please?
Any suggestions would be most welcome.
Cheers
If you don't want CKEditor to create paragraphs for you, set config.autoParagraph to false. Additionally you may want to change enter key behaviour with config.enterMode set to CKEDITOR.ENTER_BR.
And regarding disappearing styles...
EDIT: OK, it seems I missed your point.
So your website is displaying HTML markup instead of HTML while rendering out what you typed?
Then the problem is your server side rather than CKEditor. You can verify in your console that CKEDITOR.instances.yourInstance.getData() yields the correct, unescaped HTML:
<p>This is text</p> // Right!
If it is so, and I strongly believe it is, CKEditor's just fine and this is your server app that is converting special chars into entities (i.e. like PHP htmlspecialchars) while saving to database. You didn't mention what kind of framework/language you use there, so I can just tell you that it is to secure user input to prevent cross-site scripting, breaking layouts etc. and all popular frameworks allow you to disable that feature for a particular field. Simply refer to documentation.
Modern templating languages tend to autoescape html input. For example, in DTL it would be displayed correctly in the template by simply using
{{ object.field_name|safe }}
This is a desired action, since user input is considered untrusted and may be considered malicious.
The browser is not parsing HTML, so on the page displaying (or in the php file) try using {! !} instead of {{ }}.
If you are using laravel, then you should use {!! $variable !!}.
For Laravel 7, 8, and 9 - foreaxample if there is a varable called- $student
and student varable holds "This is Text" in paragraph you must call the varable using singla culy brace front and back, inside two
I need a plugin, which can show in another color words in HTML (and PHP) code. For example
<span class='domain'>this is domain</span>
and i need this result
<span class='domain'>this is domain</span>
Is it possible?
And what if I have text and htm in echo?
You can go to Notepad++ and there Settings -> Style Configurations and from left side HTML and then modify the colors the way you like them!
Netbeans also have a customizable html editor that can do this job.
Go
Tools>Option>Font & Color
In the syntax tab select HTML as Language and make the appropriate changes
Is there any rich text editor available that can generate "AS3 Compatible" codes?
I want to add this to the web admin, where user can set the font size and color of the text and it should generate as3 compatible code like:
<p><font size="12" color="#000000">Welcome to</font> <font size="30" color="#ffffff">My Website</font></p>
I used the CKEditor, but it generates like this:
<p><span style="font-size:12px; color:#000000">Welcome to</span></p>
I am assigning this value in my textfield with txt.htmlText.
If there is not any such text editor available, is there any way to render the above "span style" in the as3 textfield?
Although you say that you've been using CKEditor, it seems that you haven't configured it correctly.
Check this sample: http://nightly.ckeditor.com/latest/ckeditor/_samples/output_for_flash.html
As nowadays CSS is common practice, I guess it'll be hard to find an editor that will spit old style html. Flash only supports a handful of html tags. So you might want to use the CKEditor output, strip the style part, scour it for tags that flash would support and inject those back into the html.
[edit] I found something related here
I currently have a textarea control on a page. The user will enter text into the control. The content of the control is bespoke code.
I want to (from code) be able to apply formatting (color / bold / italic / font) to different parts of the text- very much like visual studio.
Like visual studio, and any other IDE, i dont want the user to have control over formatting the textarea- most editors i see give a control which the user can change style.
Any thoughts would be much appreciated.
I'm guessing you're talking about a WYSIWYG editor for a textarea. You should try using TinyMCE or CKEditor. These editors use a html attribute called 'contentEditable'. So by setting this attribute to true (e.g. <p contentEditable="true"></p>) they can then use the content editable javascript methods to edit it, providing an interface that calls the javascript of course. You can read a little about contentEditable and the similar attribute designMode here on WebMonkey.