Skip to main content
Known Participant
January 18, 2011
Question

Non-editable spans

  • January 18, 2011
  • 1 reply
  • 1111 views

Hi

I have blocks of editable TLF text, and inside these I have portions of text that should remain unedited no matter what (the might have a different styling so that the user can know they're different).

All editing actions should be prevented: Cut, paste, insertion of characters, deletion of characters using del or backspace, etc. No matter what happened before the editing attempt: The cursor might have been placed inside the locked region using the arrow keys or using the mouse, or a portion of text might have been selected, (etc).

In short: each locked region/span must remain unchanged.

Is there an easy solution? Or at least a perfect one?

Ideally there would editable="true/false" for span elements.

Tobi

This topic has been closed for replies.

1 reply

Adobe Employee
January 18, 2011

I agree, an editable property built into the FlowElements would be great. We haven't had time to do this yet. But I think there is a way for you to do it from an application.

All user changes go through the EditManager as operations. The EditManager sends out events when an operation is executed. The flowOperationBegin event is sent before the operation is executed, and the flowOperationEnd is sent afterwards. The application can listen for the flowOperationBegin event, and look inside it for the operation. The operation has what is being done to the text, and also has the range that it applies to. The application has the ability to either cancel the operation, by calling preventDefault on the event, or it can change the operation by sending back a different application in the event.

I would suggest implementing your own editable property by intercepting the operations. You can add a user style to indicate which elements are not editable. User styles can be set in TLF 1.0 using the ApplyElementUserStyle operation, or in TLF 2.0 user styles are built right into the TextLayoutFormat object.

Hope this helps,

- robin

tobi3Author
Known Participant
January 19, 2011

Thank you very much for the reply!

I had planned to consider preventDefault() , probably the best route.

Just a few questions regarding how to mark the span elements that should remain unchanged:

Which attribute would I use in order to apply a user style to a span? Did I understand this correctly: I'd use any attribute name that's not defined, eg nonEditable="" . But what if TLF will define a "nonEditable" attribute in the future? In order to avoid this risk would it be possible to use something like this?:

(The namespace would be declared on an ancestor element, not on the span.)

  <span xmlns:myown="http://example.com/tlf-extensions" myown:nonEditable="true">...

Tobi

Adobe Employee
January 20, 2011

User defined attributes inherit just as the built-in formatting attributes inherit, so defining them on an ancestor element will work fine. The name can be anything you want -- I think it can be anything that can go in a string, and is a legal character for an XML attribute.

As to namespaces on attributes, they are not preserved on roundtrip. So you can use a namespace and it won't hurt, but the namespace won't be applied to the FlowElement attributes, because FlowElement attributes don't have namespaces. I'd suggest just prepending a unique name onto the front or the string for the attribute, maybe something like what your namespace is now.

- robin