You are not logged in.
Hi.
Okay... this post may be long... but try to read the whole post and come with feedback (positive and negative)
I would like to be able to protect some html against being edited, and some not possible to be deleted.
For example:
Let say you let your users insert premade code into the editor using a custom made dialog ...
Let say the user inserted a DIV with one H3 tag and one table with one cell.
Then say you want a rules like this:
The user should be able to edit text widthin the H3 tag.
The user should be able to edit text widthin the TD tag of the TABLE.
The user should not be able to delete H3 tag.
The user should not be able to delete TABLE.
The user should be able to delete the DIV tag, but then also deleting all content widthin that tag.
The user should not be able to insert tags or text within the DIV tag and outside the H3 or TABLE tag.
Could maybe be implemented by using this within the tags:
xinhaedit="no"
which means that editing directly inside tag is not allowed, but editing within sub tags may be allowed (which depends if xinhaedit="no" are used on subtags or not)
xinhadelete="no"
Which means deletion of that single tag is not allowed directly, but should be deleted if parent tag are.
And then if the developers writes some code to obey the rules .... well it might work.... and should opt for some new possibilities...
Se example code below.... and if you have some thoughts about this ...well.....
<div xinhaedit="no" class="someclass">
<h3 xinhadelete="no">Title here</h3>
<table xinhadelete="no" width="100%" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td>
<p>Text here</p>
</td>
</tr>
</tbody>
</table>
</div>
Another more practical example could be this:
Let say you wanted your CMS users to be able to insert code like this in their pages (see link below):
(Move the mouse-pointer over the tabs in the page and you will see a cool effect)
http://scripts.chitika.net/eminimalls/468x180.html
This is ONE of the cool and practical stuff I want implemented in my CMS system.
I have looked a the source of the above minitab example and made a much simpler, yet effective crossbrowser version.
In order to use this code I need to create a custom dialog where my site-admins can enter tab-text as well as content for each of the tabs.
But to make this work nicely then I should be able to protect the inserted code from being altered from within Xinha. If one of my users inserted my custom minitab then if he laiter on want to change it, he would have to delete the whole minitab in Xinha or even better, be able to right-click somewhere inside the minitab and get a context-menu where he can select "edit minitab". Clicking "edit-minitab" should display the current minitab values in the custom made dialog.
Hope you see the potential of this. I mean here the benefit of being able to protect some of the HTML in Xinha.
Hope this was not too far out and that other can comment on this idea of protecting some of the HTML, and comment if this way of protecting HTML tags are doable or if there are other better ways of doing it.
**** ADD ON ****
When I digged around www I found a description of the javascript function below here:
( http://www.quirksmode.org/dom/ )
getAttribute('attribute-name-here')
I tested this against the custom attributes (xinhadelete and xinhaedit) in a TABLE, DIV and H3 tag, and it works nicely in newer IE, FF, OP, NE...
I do not know the inner workings of xinha, but could it not be possible to create an internal function xinha to be called when editing and deleting a HTML element.
This function could use the getAttribute function and test against the value of xinhadelete and xinhaedit, and return the proper value depending on what user are trying to do.
Some message handling would also be required I guess if user are trying to delete an element which are not deletable, or edit an element which are not editable.
**** END ADD ON ****
(Note: I know about the "contenteditable" stuff in IE. That is not an option for me. It does not well because I do not want the content of i.e a DIV shall be editable when an enduser are browsing the pages.)
What do you think?
Best regards
Offline
I don't think it would be possible. If it were, it would be
1. very difficult to implement
2. very slow
3. very unreliable
new plugins are always welcome however, knock yourself out ;-)
James Sleeman
Offline
I implemented a workaround for my implementation once I realized that Xinha would corrupt the HTML for embedded Quicktime players. If there is anything I don't want to have someone edit, or have Xinha corrupt, I can place "stopeditor"in a comment before my HTML.
<!-- stopeditor -->
After the code I want to hide or protect, I place "begineditor" in a comment in the HTML.
<!-- begineditor -->
When the file is opened, before the code is sent to Xinha, the commented "stopeditor" is changed to an opening comment with the word "editorstopped."
<!-- editorstopped
The commented "begineditor" becomes "editorstarted" and the closing part of the quote.
editorstarted -->
So, while the HTML is in the editor, everything between the two comments becomes commented. When I save, the comments are switched back, so the protected HTML is no longer commented out.
It probably isn't the best solution, but it works well for what I needed.
Last edited by mharrisonline (2005-12-02 01:56:11)
Offline