Menu

disable editing on node?

Wouter
2007-09-20
2013-04-09
  • Wouter

    Wouter - 2007-09-20

    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

     
    • Max Stepanov

      Max Stepanov - 2007-09-20

      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

       
    • Wouter

      Wouter - 2007-09-21

      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=\&quot;non-edit\&quot;> 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

       
    • Max Stepanov

      Max Stepanov - 2007-09-21

      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

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.