Yes, disabling editing of specific nodes is possible.
----
control.setOverrideStyleSheet("#foo {-moz-user-input: disabled;}");
----
Also you could try to play with other mozilla-specific CSS styles. See http://developer.mozilla.org/en/docs/CSS:-moz-user-input
Best,
Max
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
That goes a long way to what I want, I needed to add some more properties:
htmlEditor.setContent("<div> editable foo </div><div id=\"non-edit\"> blah blah non-editable </div><div>bar editable</div>");
htmlEditor.setOverrideStyleSheet("#non-edit {-moz-user-input: disabled; -moz-user-modify: read-only;-moz-user-select: none;}");
With this code I cannot select it (with only input disabled you could still directly select the text and then type over).
However, in the above example, I select foo and then drag to bar, you see that only foo and bar are selected and not the non-editable part, but when I then start typing, the whole inner block gets removed, is there any way to prevent that also?
Thanx,
Wouter
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Then you need to use transaction manager to cancel certain modifications.
See example:
----
control.getTransactionManager().addTransactionListener(new ITransactionListener() {
....
public void aboutToPerformTransaction( ITransactionManager manager, ITransaction transaction) {
if(transaction instanceof IDeleteElementTransaction || transaction instanceof IDeleteRangeTransaction) {
Node/Range node = transaction.getNode()/getRange();
if(....) {
transaction.cancel();
}
}
....
});
-Max
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I was wondering whether it is possible to disable the editing of specific nodes.
So I am looking for something like
Node node = editor.getDocument().getElementById("foo");
editor.setDisableEditing(node);
Regards,
Wouter
Hi Wouter,
Yes, disabling editing of specific nodes is possible.
----
control.setOverrideStyleSheet("#foo {-moz-user-input: disabled;}");
----
Also you could try to play with other mozilla-specific CSS styles. See http://developer.mozilla.org/en/docs/CSS:-moz-user-input
Best,
Max
Hi Max,
That goes a long way to what I want, I needed to add some more properties:
htmlEditor.setContent("<div> editable foo </div><div id=\"non-edit\"> blah blah non-editable </div><div>bar editable</div>");
htmlEditor.setOverrideStyleSheet("#non-edit {-moz-user-input: disabled; -moz-user-modify: read-only;-moz-user-select: none;}");
With this code I cannot select it (with only input disabled you could still directly select the text and then type over).
However, in the above example, I select foo and then drag to bar, you see that only foo and bar are selected and not the non-editable part, but when I then start typing, the whole inner block gets removed, is there any way to prevent that also?
Thanx,
Wouter
Hi Wouter,
Then you need to use transaction manager to cancel certain modifications.
See example:
----
control.getTransactionManager().addTransactionListener(new ITransactionListener() {
....
public void aboutToPerformTransaction( ITransactionManager manager, ITransaction transaction) {
if(transaction instanceof IDeleteElementTransaction || transaction instanceof IDeleteRangeTransaction) {
Node/Range node = transaction.getNode()/getRange();
if(....) {
transaction.cancel();
}
}
....
});
-Max