Can someone help? I've googled it a lot and couldn't find an answer. Is there a way to show/hide non-printable characters on the CKEditor, like there is on word? I couldn't find any plugin for it :/
In short, there is no way to do it or at least it is not easy.
Now the longer version. If you are talking about the Pilcrow character then it is possible to show it in CKEditor by using HTML entities ¶ or ¶ but please note this character is NOT non-printable by any means and in order to make it non-printable you would need to write a code which handles it and this is not easy. First of all you would need write a code (can be done as CKEditor plugin) which inserts Pilcrows on Enter and removes them wherever data is sent to server. So far so good but since this is a normal character (from CKEditor content area POV) you would need to handle all situations in which this character can be removed while typing, styling and modifying entered text and this is next to impossible.
As an alternative you could try having a code which inserts e.g. spans with PilcRow as a background image. While it would be easier to handle spans than plain character you would still need to handle all situations in which this span should or should not be removed while typing, deleting text, styling etc. and again this is very hard to do.
Related
Usually we replace tabs to spaces in editors while coding.
What is the exact need for that?
Is it for because the OS handles \t in the files?
I am really not very sure of this. Kindly clarify
Tabs don't have fixed width, its width depends on IDE (editor) settings. It is usually set to have width 4 spaces, but it doesn't have to be. There probably wouldn' be any problem if you use only tabs and don't use spaces, but this will never happen. You can bet, you will always want to move some text by only one extra space to the right. Then you will be mixing spaces and tabs together and that's what brings trouble. It might look correct in your IDE, but then you will want to do some change in vim editor for example, where there will be different tab size set. Indentation of the code won't be what would you expect. Also when you send some code to your co-worker, he might use different IDE with different settings and he will again see wrongly aligned code. On the other hand with spaces only you see what see the others.
Im using CKEditor as a part of Grocery Crud (this is a php codeignihter crud setup), which uses CKEditor (3.6.5) to edit text fields.
So the problem im having is, some special characters (like Ā) gets somewhat stripped from CKEditor (this happens in the latest version too). Can someone help me make sure these special characters gets treated correctly (specially if there is any flags that i can set maybe)?
To test, just open up a CKEditor anywhere (use the Full demo on the CKEditor website), click the "source" button (to see html mode), then paste the following in the editor: Ā. Then click the source button again (to see the wysiwyg mode) and you will see a Letter A with a line above it. Then click the source again (to see html mode) and you will see that the characters you entered Ā have been replaced by the Letter A with the line above it.
Any thoughts about keeping CKEditor from stripping out the character codes?
The above only happens for some special characters (ones that uses decimal or hex codes) and not others which is a bit strange. And some character codes (that uses hex/decimal) get changed to some other codes (that has non hex/decimal alternatives, which is strange but atleast you end up with the same result).
Alright, let me answer my own question.
You need to add the following to the config:
config.entities_processNumerical = true;
In the case of grocery crud, this is done on the following file: /assets/grocery_crud/texteditor/ckeditor/config.js
More doccumentation can be found here: http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html#.entities_processNumerical
To be fair though, im surprised this is not enabled by default. Not quite sure why.
I am using CK editor 4.4.6.
It seem on the first instance of pressing shift + enter, the editor inserts an invisible character. Upon submission, the character saves as a question mark. I can't see the character in the form submission when viewing the debug in the browser or the source code in the WYSIWYG editor itself. I do however notice when I press the right arrow that the cursor pauses at this character even though I can't see it. The page is being served in UTF-8.
This character is zero-width-space and is used by CKEditor to workaround Safari's and Blink's problems with placing selection inside empty inline tags or around them or in couple of other positions.
However, this character should never end up in data. It's used only internally and it is removed when getting data from editor. So, if you can find it in your database it means that you either get data from editor incorrectly, or you encounter some bug in the mechanism I described. In the latter is true please report a bug on http://dev.ckeditor.com, but please also describe how you reproduce it.
Looks like the editor is inserting character 8203.
What's HTML character code 8203?
I don't want to mess with the editor script at the moment so I'm just stripping out that character in the future on form/ajax post.
This is maybe a weird request but hear me out:
I have a huge database at my shop containing product codes, like 87 445 G 6 which I need to check for availability on a supplier's website. The problem is, the supplier's website consists of a web form in which I have to enter the code without spaces, so imagine that I have to manually delete spaces every time I paste a code or write it manually without.
I can't edit the database from which I copy the codes.
I wonder if some sort of plugin, script, or trick can be used directly in browser on the supplier's web form, or some software to modify how the windows clipboard works, maybe some option to copy text without spaces. Using Windows XP.
The OP has probably moved on, but for anyone else looking here, my approach was to tackle this from the windows clipboard side.
For background: I keep a list of my credit card info in Keepass. Sometimes (poorly coded) shopping cart checkout forms don't like spaces in between card numbers. I like storing them with spaces since it's easier to read off that way.
There's various Windows clipboard utilites out there, but it took me a while to find one that could do some processing on the clipboard contents and pasting it out - Clipboard Help and Spell
The program has a way to "save" a bunch of text transformations, and even assign the action to a hotkey.
For reference, my "Find and Replace" action is to find "\s" (without quotes) and leave the Replace textbox empty. "\s" will match whitespace character.
Use the javascript console
You could use the javascript console for your browser to edit the textarea after you paste.
Using Google Chrome (or Firefox)
Paste your text in the text area.
Right click the text area and click Inspect Element
Look at the id for the element
Now switch to the console view
then run these lines (making sure to replace with 'the-id' with your id)
var my_text_area = document.getElementById('the-id'); // Put your id in here
my_text_area.value = my_text_area.value.replace(/ /g,"") // Deletes just spaces
It's even simpler if you have access to jQuery:
$('#the-id').val($('#the-id').val().replace(/ /g, ""))
The replace function is simply using regular expressions to convert spaces to nothing. If you want to replace all whitespace (including newlines) you would use .replace(/\s/g,"").
For firefox, the names are the same but the UI is a little bit different.
Use greasemonkey
You can either write a greasemonkey plugin or try to find one that fits your needs.
I have a situation with edit control and I need some guidance. The text editor functions normally in most cases but in other cases, depending on the last few characters before typing and based on the characters typed, the last few characters must be replaced with different characters.
The solution that looks obvious to me is to have a character buffer, GetWindowText() just before the contents are changed, add the characters typed into the buffer, manipulate the buffer if necessary and then SetWimdowText().
I know the edit control has its own buffer. So is this the right approach to have my own buffer or are there ways I can share the buffer with it etc? The editor might not have more than 4MB worth of characters.
I need this to work on Windows 7 and XP, not keen on older ones.I use MFC.
Thanks for your help.
You don't need your own buffer and indeed it would be dangerous to have one since it will likely get out of synchronisation.
But you don't need to set the entire edit text at once. From the documentation:
Also, if an edit control is multiline, get and set part of the control's text by calling the CEdit member functions GetLine, SetSel, GetSel, and ReplaceSel.
ReplaceSel is what you are looking for I think. Although this text talks about multiline edit controls, SetSel, ReplaceSel etc. work fine with single line edit controls.