I have implemented tiny mce html editor in my webpage.
I works fine.But now i want detect white space exists in return value of the editor.
I need to validate that.
Please help me to solve this issue.
Here the code i have tried on submit click for validation.
if (tinymce.activeEditor.getContent() == '') {
alert("Enter text");
}
This condition doesn't work if i enter only white spaces in my editor.
I need to validate the white spaces also.Please help me.
Thanks.
The idea will be to trim the white spaces first. Please note tested
var cleanStr = $.trim(tinymce.activeEditor.getContent());
if (cleanStr == '') {
alert("Enter text");
}
Related
I have jrxml report, which gets exported into .docx format,
I have static text resources (.properties) with "\n" or "<br>" signs in values, like so:
In jasperreports 'preview' tab it looks ok:
But when .docx format is used...:
I figured out that when you paste pilcrow/paragraph (by pressing enter key) in word itself,
justified alignment works ok,
but with <br> or \n jasper inserts new line (shift enter equivalent) and it breaks everything.
May be someone knows what could be done.
Thanks!
Found the solution:
To brake row I use tab/newline ( <br> via HTML or \t\n via Java),
Text before tab/newline is aligned to the left border, text after is still justified well along the page.
I've been using TinyMCE (v4 at the moment, but this question is valid for v5 as well) as an editor for content that is eventually turned into Word documents.
Pressing shift + enter on TinyMCE inserts a line break <br /> rather than a return (i.e., creating a new <p>). Is there any way to make shift + enter behave just as enter? In other words, is there any way to disable shift + enter?
If anyone's interested as to why I'm asking:
To make it as similar to editing text on Word as possible, I made it so that <p> elements have no margins at all. This way, the document looks the same on the editor and on Word. Line breaks look the same on the editor, but when converted to Word, their behaviour is different when the text orientation is set to justified. Lines ending with a line break get stretched to the full width of the document; lines ending with a return don't get stretched at all. That's the behaviour I'd like to have.
TinyMCE has APIs you can use to be notified when a key is pressed and you can look at that event to see if Shift + Enter has been pressed. The code to do this can go in your configuration:
setup: function(editor) {
editor.on('keydown', function (event) {
if (event.keyCode == 13 && event.shiftKey) {
console.log(event);
event.preventDefault();
event.stopPropagation();
return false;
}
});
}
Here is a complete TinyMCE Fiddle: http://fiddle.tinymce.com/LQgaab
My PHP generates a Word document, but it will not render carriage returns. My CKEditor translates a carriage return into either,
<br>, or <div>asdf</div>
When the Word document is created, it will display those HTML tags, so I strip them out. What replacement code, character, ascii, or tag can I use so that when the page is rendered, it shows the text like it did in the Editor?
Current example - if you have the text "Don't jump off the" [then hit Enter, so that the next word is below it]...
"cliff." Instead, currently, that gets saved into SQL as:
Don't jump off the <br>cliff.
Don't jump off the <div>cliff</div>.
...depending on which browser is used. In the msWord output, any tags left in the content [exceptions to strip_tags function] get displayed literally in msWord. Or, if I replace the tags with ASCII
it displays that literally, too. Not sure if this helps, but this is defined at the top of my php report_generator.php file:
require_once '/var/www/PhpWord/src/PhpWord/Autoloader.php';
\PhpOffice\PhpWord\Autoloader::register();
include "/var/www/ncpcphp/NCPC_PHP_Functions.php";
DEFINE("WRITEtoFDOCS", "NO");
DEFINE("FDOCSDIRECTORY", "Contract Attachments");
DEFINE("MIMETYPE","application/vnd.openxmlformats-officedocument.wordprocessingml.document" );
Help - what can I use to cause the output to show the carriage return?
Thank you, Cindy. Your answer is a piece of the solution. My CKEditor saves carriage returns as either
<br>, <br />, or <div></div>
depending on which browser is used Chrome[div] or Firefox[br] - that goes into my msSQL. Yet, if my editor has turned-on an "Enter filter" [keycode-13] in order to prevent someone from enter-editing a [[Placeholder]] (ckeditor read-onlyplugin) then saved editor text strips out the Enter. So, I did this: kept in the enter filter because it is necessary, then after the text carriage returns are saved as br's or div's, when I run my report generator, I replace
<br>, <br />, and <div></div>
with "\n" like you said. Then I explode the text variable like this:
$show_cad = explode("\n", $show_cad);
foreach($show_cad as $line) {
$section->addText(htmlspecialchars($line));
}
The code in the editor needed to filter out the Enters only when Enter is pressed in the [[Placeholder]] plug in is more complex, and I got largely from CKEditor themselves. They request that I do not post their full solutions, but if you like I could show you pieces of it. Basically, I had to register the Placeholder widget. Then when Enter is pressed, it checks if the context is with Placeholder. If so, filter the Enter [then it disappears from the saved editor text], but if Enter is pressed elsewhere, it gets saved and used properly.
Thank you for your help!
am tring to input my each text line in private message colored, i use this code it is showing colored text but adding a space before text. how can i remove that space
on *:INPUT:?:{
say 4 $strip($1-)
halt
}
and also now commands like
/clear
is not working .. showing in read but its not working
on input events are sensible
if you dont know how it works, dont mess with it, since it may mess with all your scripts
try this
on *:input:?:{
if (!$inpaste) && (!$ctrlenter) && ($left($1,1) != /) {
command here
haltdef
}
}
by the way, this event must be on top of all on input events to work
I'm almost left with no time but facing a problem with DataDynamics.ActiveReports.
I have to replace some text for 500 reports so automating the task through code at run time.
The major problem I'm facing is on replacing text the original bold wont changes to normal font. center justified text will be left justified also Arial Narrow text changes to Arial.
Is there any way to replace text without disturbing the original format.
Here is the piece of code:
var textBox = (DataDynamics.ActiveReports.RichTextBox)reportSection.Controls[controlIdx];
if (textBox.Text.Contains("Babu"))
{
MessageBox.Show(textBox.Text);
var modifiedtext = (DataDynamics.ActiveReports.RichTextBox)reportSection.Controls[controlIdx];
modifiedtext.Text = modifiedtext.Text.Replace("Babu", "Mannu");
MessageBox.Show(modifiedtext.Text);
}
The modified report has a format different than the original. How to fix this issue??
its richtext, not plain text.
every rich text has a formatting associated with it.
try editing the original rtf that you are loading into the rtb control. This is what I would recommend.
Or, another approach could be to use richtextbox.rtf.replac instead of richtextbox.text.
At what time of the report processing are you doing this?