I'm trying to follow a suggestion and have set a marker on the input control in my component like this.
<span (click)="onEditClick()"
[class.hidden]="editing">{{value}}</span>
<input #input
value="{{value}}"
[class.hidden]="!editing">
I noticed that clicking the span hides it and presents the input but an additional click is required to make the input control actually focused for editing. I tried to focusify it as follows.
#ViewChild("input") input: ElementRef;
onEditClick() {
this.editing = true;
this.input.nativeElement.focus();
}
It doesn't work, so I verified that the native element is set and corresponds to what I expect. It did. And since there are no errors in the console, I'm a bit stuck not knowing how to diagnose it further.
I suspect that I'm missing something rather basic that can easily be inferred from the provided description.
The problem is that the input element is still hidden when you try to set focus on it. To make sure that the input element has become visible after setting the editing property, force change detection by calling ChangeDetectorRef.detectChanges():
onEditClick() {
this.editing = true;
this.changeDetectorRef.detectChanges();
this.input.nativeElement.focus();
}
See this stackblitz for a demo.
I have a span with an ng-click="..." attribute. The ng-click slightly modifies the span's CSS within the DOM so that it is more button-like. Within my application I wish to toggle whether or not that span is clickable or not. I can make the ng-click not do anything easy enough but what I would prefer is to just remove/disable the attribute altogether. This is to avoid all "buttonizing" that the ng-click does to the element. It would also be nice if the attribute were re-enabled if the clickable variable becomes true again.
I would like a solution that avoids using $scope.$watches because my application is pretty large and watches are slow.
Thanks!
I think you can have two spans with and without ng-click attribute and based on that clickable variable you control those two spans with ng-if or ng-show
Simple solution suggested by to Achu!
Just use two spans rather than toggle the attribute on a single span.
<span ng-if="clickable" ng-click="...">Click me!</span>
<span ng-if="!clickable">Cant click me!</span>
If I were in such a situation, I would not try to enable or disable ng-click attribute. Rather, I would use some flag variable with the $scope to see if click function should perform its functionality or not like in your controller you have a method like
$scope.spanClick = function(){
if(!$scope.shouldClick){
return;//simply do nothing
}
//Do button click logic
}
*<af:commandButton text="#{res['pci.buttons.save']}"
blocking="true"
disabled="#{claimFileDetailAddBean.buttonsDisabled "}
action="#{claimFileDetailAddBean.save}"/>*
I use this html. I want; button block proceed until the end of action. How is this possible.
So you want to dynamically disable / enable your button?
In that case you can use javascript DOM
You can use the tag object.disabled=true to disable and object.disabled=true to disable.
All you have to do is making a function for it.
BTW: next time be more specific in your questions.
Is there a possibility to turn off the automatic enclosing of all written content within <p></p> in CKEditor 3.x?
I tried
CKEDITOR.config.enterMode = CKEDITOR.ENTER_BR;
but this just changes the inline linebreaks to <br /> while leaving the enclosing paragraph.
Currently writing "Test" produces this output
<p>
Test</p>
but I want it to be simply
Test
Is there a configuration property for this or would another inline editor to be better suited for this?
CKEDITOR.config.enterMode = CKEDITOR.ENTER_BR; - this works perfectly for me.
Have you tried clearing your browser cache - this is an issue sometimes.
You can also check it out with the jQuery adapter:
<script type="text/javascript" src="/js/ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="/js/ckeditor/adapters/jquery.js"></script>
<script type="text/javascript">
$(function() {
$('#your_textarea').ckeditor({
toolbar: 'Full',
enterMode : CKEDITOR.ENTER_BR,
shiftEnterMode: CKEDITOR.ENTER_P
});
});
</script>
UPDATE according to #Tomkay's comment:
Since version 3.6 of CKEditor you can configure if you want inline content to be automatically wrapped with tags like <p></p>. This is the correct setting:
CKEDITOR.config.autoParagraph = false;
Source:
http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html#.autoParagraph
Across the internet, people have noticed that setting config.enterMode to CKEDITOR.ENTER_BR removes the wrapping paragraph tags from CKEditor. It's worth noting that the setting changes the behavior of the enter key to insert line breaks rather than paragraphs, which is not desirable.
See: http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html#.enterMode "It is recommended to use the CKEDITOR.ENTER_P setting because of its semantic value and correctness."
However, the setting that is designed to remove that initial paragraph, config.autoParagraph, isn't advisable either, as it introduces "unpredictable usability issues" because the editor really wants a top-level block element.
See: http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html#.autoParagraph
The magic happens on wysiwygarea/plugin.js, line 410, where the editor selects the default block element based on config.enterMode. A config option to change the default block element would allow us to start with a div, but we'd continue getting more divs with every enter press, unless we changed the paragraph format via the menu.
See: http://docs.cksource.com/ckeditor_api/symbols/src/plugins_wysiwygarea_plugin.js.html
It would be possible to remove the wrapping paragraph tag with post-processing (either on the server or in CKEditor's getData event), but that leads us into the same problem as disabling autoParagraph: there's no top-level block.
I would rather say that there's not a good solution, but rather a handful of half-solutions, than to accept changing config.enterMode as the canonical solution.
Try this in config.js
CKEDITOR.editorConfig = function( config )
{
config.enterMode = CKEDITOR.ENTER_BR;
config.shiftEnterMode = CKEDITOR.ENTER_BR;
};
Found it!
ckeditor.js line #91 ... search for
B.config.enterMode==3?'div':'p'
change to
B.config.enterMode==3?'div':'' (NO P!)
Dump your cache and BAM!
MAKE THIS YOUR config.js file code
CKEDITOR.editorConfig = function( config ) {
// config.enterMode = 2; //disabled <p> completely
config.enterMode = CKEDITOR.ENTER_BR; // pressing the ENTER KEY input <br/>
config.shiftEnterMode = CKEDITOR.ENTER_P; //pressing the SHIFT + ENTER KEYS input <p>
config.autoParagraph = false; // stops automatic insertion of <p> on focus
};
I'm doing something I'm not proud of as workaround. In my Python servlet that actually saves to the database, I do:
if description.startswith('<p>') and description.endswith('</p>'):
description = description[3:-4]
Edit the source (or turn off rich text) and replace the p tag with a div. Then style the div any which way you want.
ckEditor won't add any wrapper element on the next submit as you've got the div in there.
(This solved my issue, I'm using Drupal and need small snippets of html which the editor always added the extra, but the rest of the time I want the wrapping p tag).
if (substr_count($this->content,'<p>') == 1)
{
$this->content = preg_replace('/<\/?p>/i', '', $this->content);
}
MAKE THIS YOUR config.js file code
CKEDITOR.editorConfig = function( config ) {
// config.enterMode = 2; //disabled <p> completely
config.enterMode = CKEDITOR.ENTER_BR // pressing the ENTER KEY input <br/>
config.shiftEnterMode = CKEDITOR.ENTER_P; //pressing the SHIFT + ENTER KEYS input <p>
config.autoParagraph = false; // stops automatic insertion of <p> on focus
};
Set such config:
CKEDITOR.config.enterMode = CKEDITOR.ENTER_BR
CKEDITOR.config.forcePasteAsPlainText = true
Well, with me in laravel, with using ckeditor, it work using simple strip_tags($var) function for output like below:
Sending value to like this to the other page: {!! strip_tags($six_answer) !!}
And/Or when outputting use the same code: {!! strip_tags($six_answer) !!}.
the result is below without any <p> tags.
In VS2015, this worked to turn the Enter key into <br>
myCKEControl.EnterMode = CKEditor.NET.EnterMode.BR
Personally, I don't care if my resulting text only has <br> and not <p>. It renders perfectly fine and it looks the way I want it to. In the end, it works.
How to prevent ctrl+v paste for flash.display.textarea()?
field.selectable = false; does not seem to work, also it disables caret/cursor
this seem to work in TextEvent listener, any comments is it too bad solution to avoid copy+paste to a field ?
if (evt.text.length >1)
evt.preventDefault () ;
A TextArea is an editable textfield. You should use another component if you want to prevent copy / paste.
The TextArea component has a textField property. Setting the mouseEnabled property of the textField should have the desired effect.
var ta:TextArea = new TextArea();
ta.textField.mouseEnabled = false;
This disables the caret cursor and prevents selection of the text.
If you can, use a different component instead of TextArea, as monkee suggested.
If you're really into protecting against copying your text data you might even want to consider drawing the text on a canvas directly so it's really impossible to grab it unless the user does OCR or something.
We have another solution for it
field.mouseChildren = false;
so it will not allow to copy the data