Non-editable custom object

Last post 11-05-2004, 4:49 PM by skipl. 3 replies.
Sort Posts: Previous Next
  •  11-05-2004, 3:13 PM 2322

    Non-editable custom object

    I'm looking for some help in making objects within the editor non-editable. 
    I've got a custom button on the toolbar that inserts a DIV object into the editor text.  This DIV is merely a placeholder within the editor and will be the target of later processing (outside of the editor).  I'd like to allow sizing of this DIV, but not editing. 
     
    I've had partial success by using ContentEditable attribute.  By setting this attribute false, it prevents editing within the DIV, but it still shows the text-entry border (thick hatched border) clicked while active.  Worse, if I include any container tags within the DIV, any click will show the text-entry border.  When this border is displayed, any insert from the toolbar goes into my placeholder object rather than on the page.
     
    Do you know of any way I can prevent ALL editing of a single object within the editor?
     
    To reproduce the behavior, paste the following as HTML into the editor then see what happens when you click twice on the object.
        <DIV contentEditable=false>Placeholder Object</DIV>
     
    Alternatively, paste this snippet into the editor as HTML and click (just once) on the words:
        <DIV contentEditable=false><b>Placeholder Object</b></DIV>
     
  •  11-05-2004, 3:26 PM 2323 in reply to 2322

    Re: Non-editable custom object

    skipl,

     
    try the following solution:
     
    <DIV contentEditable=false UNSELECTABLE="ON">Placeholder Object</DIV>

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  11-05-2004, 3:35 PM 2324 in reply to 2323

    Re: Non-editable custom object

    Thanks for the quick reply.

     
    Adding the UNSELECTABLE attribute makes it so you can't select the object at all, which also means you can't size the object.  What I'd like to have is the content within the object unselectable, and the object itself not editable.  That is, sizing handles on the object itself, but nothing else.
  •  11-05-2004, 4:49 PM 2325 in reply to 2324

    Re: Non-editable custom object

    OK.  I think I got it sorted out. 
     
    You need the UNSELECTABLE attribute on every element inside the containing object, and CONTENTEDITABLE="false" set on the outside container, plus you have to trap the onmousedown event of the outside element and force the editor to control select the object.
     
    The following code works alright, but I'd be interested in suggestions.
     

    <div id="outerObj" CONTENTEDITABLE="false" onmousedown="selectObject('YourEditorID', this);">
        <div UNSELECTABLE="ON">Some text</div>
    </div>
    <script language="javascript">
    function selectObject(editorID, oObj)
    {
       var editor = document.getElementById(editorID);

       var r = editor.document.body.createControlRange();

        r.add(oObj);

        r.select();

    }

    </script>
     
View as RSS news feed in XML