I have a document with lots of pairs of "readonlyrange-followed-by-permissonrange".
The readonlyranges(->ROR) are Titles, the permissonranges (->PR)
are the place where the users enter their input related to the title.
The XAML source code looks like:
The current user of the richtextbox is "jmiller" so the PR is editable.
Now there is a little issue with deleting all text from the span / PR via the keyboard.
When all text is gone and the cursor is at the end of the ROR -
with text "TITLE" - one cannot enter new text into the PR again, although the
PR is still there (as proved by saving it as XAML).
I think that's because the Cursor position is considered as belonging to the
ROR, so it is not editable.
And since the PR is empty, I can't position the cursor to the start of the PR
with the mouse.
Is there a way / trick how i must arrange ROR and PR so that i can remove all contents
from the PR but have it still accepting new input?
Can I position the cursor programmatically into the empty PR
when it is at the end of the ROR (by some event handler)
or can I control, whether the end-of-ROR position is regarded as
inside or outside the ROR?
Thanks in advance
8 Answers, 1 is accepted
The behavior of the permission ranges is similar to that of comments - once you delete the content between the range start and end, it is not possible to add text between these ranges.
We will consider changing the behavior of the permission ranges. The only way to achieve the behavior you have described would be to use custom annotation ranges, similar to the PermissionRanges. Here is how they can be implemented:
and the CustomPermissionRangeEnd:
The use of custom annotations with UILayer is demonstrated in the StructuredContentEditing demo for the Silverlight version of RadRichTextBox. For more information on the approach, please refer to this forum post. Greetings,
the Telerik team
Thanks for your reply and the pointer to the custom PermissonRange.
I did a quick test replacing the Telerik PermissonRangeStart/End
tags/instances in my test document with the new Custom implementation.
With the custom implementaion, the mechansim of
protecting and unprotecting the PermissonRange
by changing the CurrentUser (letting the CurrentUser name and the name of the range
equal) doesn't seem to function anymore :-(
The custom permisson range remains readonly - even if both names resolve to 'jmiller'
and protection type is 'Individual'.
I tried to derive the custom AnnotationMarkers from PermissionRangeStart and PermissionRangeEnd instead
but this doesn't seem to do the trick either (document got invalid and was rendered/displayed as empty).
On the other hand I've seen the StructedEditing demo and where it works.
So I'll go and find out the details that make it function.
I've also got the same issue, and I like the solution you've proposed as it also allows me to add other metadata to the range as well as solving the original problem.
However, I have the same issue as Christoph - when the document is protected, you cannot edit the custom range. It would appear the "ContentProperty" attribute is being ignored, or we're missing something in the implementation.
I've checked the Structured Content Editing demo that Christoph refers to, and the implementation here is different - each custom range is wrapped in a PermissionRange. This cures the sympton, as your cursor is in the inner custom range, so you can add text (I assume the difference in behaviour is due to the "SkipPositionBefore" and "SkipPositionAfter" properties? I can't find any documentation on this, though!).
If there's a simple solution to make the example posted work with content protection, please let us know!
EDIT: Just tried inheriting from PermissionRangeStart and PermissionRangeEnd, as Christoph described. It does, however, appear to work for me...
I found a solution now, that works for me.
I derived from ProtectionRangeStart and ~End, adding a Name property.
As for the range becoming uneditable-issue (which is somewhat unpredictable:
sometimes the empty range remains editable, sometimes it seems locked)
- I decided to watch the DocumentElementRemoved event.
In the handler I take care that between the Start/End tags of interest
there always is a span.
If there is none, I insert one with a blank space as text.
Kind of a workaround that works for me.
As for the proposed solution with the dual AnnotaionsMarkers.
I tried this one as well, it is also the way it is implemented
in the StructuredEditingDemo, but I didn't get it to work
(Protection toggling worked, but having the empty range
still editable didn't, probably missed something).
In general I agree with Charles that having a documentation
espcially on the overridable Members of AnnotationMarkerBase
would be good.
Thanks all of you for your support
Providing you override the "SkipsPositionBefore" as Iva described in the exampl, it appears to solve the issue for me.
I'm glad you have successfully resolved your issues. If any of them remain or you experience new ones, do not hesitate to contact us again.
the Telerik team
I will have to make a work around for this. It would be nice if a fix were to be implemented into the API.
Enable deletion using backspace when at the end of a protected region: