Page 1 of 1

Author mode - custom action - insert fragment before caret

Posted: Thu Aug 27, 2009 2:25 pm
by honyk
Hello,

I've tried to make custom action for inserting non-breaking space entity in my DocBook document. I've used default ro.sync.ecss.extensions.commons.operations.InsertFragmentOperation with attribute 'fragment' set to ' '. It places entity, but after caret, not before it. This method offers three placement values, but only if XPath is specified. Can this be used somehow or do I have to write my own plugin? What I need is placing entity before caret so writing can continue without extra cursor moving step.

Jan

Re: Author mode - custom action - insert fragment before caret

Posted: Thu Aug 27, 2009 3:50 pm
by sorin_ristache
The fragment is inserted at the cursor location. What value did you set for the insertPosition parameter?


Regards,
Sorin

Re: Author mode - custom action - insert fragment before caret

Posted: Thu Aug 27, 2009 4:05 pm
by honyk
insertLocation as well as insertPosition are empty. I've also tried insertPosition set to Before, but as it is written in note:
'If the XPath expression is not defined this argument is ignored'.
To tell the truth, it is not very clear if by XPath it is meant insetLocation value or XPath Expression (When this XPath expression is true) from textbox above. Anyway, both are empty in my case.

Re: Author mode - custom action - insert fragment before caret

Posted: Thu Aug 27, 2009 5:01 pm
by sorin_ristache
It is about the insertLocation parameter. If there is no XPath expression set in insertLocation then an insert position relative to a node specified as insert location does not make sense.


Regards,
Sorin

Re: Author mode - custom action - insert fragment before caret

Posted: Fri Aug 28, 2009 9:23 am
by honyk
Thanks, so back to my original question, is there any settings which could be used to insert my fragment ' ' before caret? If XPath is necessary, how to construct it for position somewhere in text? I think self::text() is not sufficient (Oxygen complains 'self::text()' has no result).

Re: Author mode - custom action - insert fragment before caret

Posted: Fri Aug 28, 2009 12:32 pm
by sorin_ristache
The action for inserting a fragment of text in the Author document just inserts the fragment at the cursor location, that is the cursor is replaced with the inserted fragment and after that the cursor is placed at the end of the fragment. What do you mean before caret? Can you give an example?


Regards,
Sorin

Re: Author mode - custom action - insert fragment before caret

Posted: Fri Aug 28, 2009 2:05 pm
by honyk
Ok, one image is better than hundreds of words:
Image
Image
If   fragment is inserted, cursor (caret) is placed into entity, not after fragment, just before Euro sign in this case.

Re: Author mode - custom action - insert fragment before caret

Posted: Fri Aug 28, 2009 2:26 pm
by sorin_ristache
The default action InsertFragmentOperation places the cursor between the two markers. If you want to place the cursor after the markers you can create your own version of InsertFragmentOperation by modifying the original one included in Author SDK and adding a call authorAccess.getEditorAccess().setCaretPosition(). You find the current position with authorAccess.getEditorAccess().getCaretPosition().


Regards,
Sorin