Split_element function

Having trouble installing Oxygen? Got a bug to report? Post it all here.
idak
Posts: 16
Joined: Mon Mar 18, 2013 6:29 pm

Split_element function

Post by idak »

Hi,
I use the split_element function in a paragraph but it does not work inside a bold or italics text:

Code: Select all


<p>text text text text text <i><b>text (caret position) text text</b><i> text text </p>
here is my java code:

Code: Select all


if ("p".equals(paragraphAtCaret.getName())
|| ("b".equals(paragraphAtCaret.getName()) && "p".equals(paragraphAtCaret.getParent().getName()))
|| ("i".equals(paragraphAtCaret.getName()) && "p".equals(paragraphAtCaret.getParent().getName()))
|| ("sup".equals(paragraphAtCaret.getName()) && "p".equals(paragraphAtCaret.getParent().getName()))) {

Object action = authorAccess.getEditorAccess().getActionsProvider()
.getAuthorCommonActions().get("XML_Refactoring/Split_element");
authorAccess.getEditorAccess().getActionsProvider().invokeAction(action);
}
Best Regards,
Idak,
alex_jitianu
Posts: 1010
Joined: Wed Nov 16, 2005 11:11 am

Re: Split_element function

Post by alex_jitianu »

Hello,

At first glance the problem seems to be related with the if statement. In the XML snapshot that you sent, the caret is in a b element from an i element. The if statement allows only the case when the b element is inside a p.

If the node at caret is b, i, sup you should look into the ancestors of the node at caret for a p element.

Best regards,
Alex
idak
Posts: 16
Joined: Mon Mar 18, 2013 6:29 pm

Re: Split_element function

Post by idak »

Hello Alex,
I change the if predicate but when use the the split element inside bold or italic tag it does not split a paragraph tag:

before split :

Code: Select all


<p>text text text text <b>text (caret position) bold</b> text text text text </p>
After split:

Code: Select all


<p>text text text text <b>text (caret position)</b><b> bold</b> text text text text </p>
I want have this result:

Code: Select all


<p>text text text text <b>text (caret position)</b></p><p><b> bold</b> text text text text </p>
Thanks,
Radu
Posts: 9093
Joined: Fri Jul 09, 2004 5:18 pm

Re: Split_element function

Post by Radu »

Hi,

The "Split" action you are using splits the current element located at the current position, the b element in your case. This is all it does, it is not equivalent to the Split action performed when you press ENTER in a paragraph.
But you have enough API to implement such an operation yourself:

http://www.oxygenxml.com/forum/post21668.html#p21668

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply