Custom framework: copy&paste and auto id behavior
Post here questions and problems related to oXygen frameworks/document types.
-
- Posts: 280
- Joined: Thu Nov 28, 2013 9:32 am
- Location: Hamburg/Germany
- Contact:
Custom framework: copy&paste and auto id behavior
Hi,
I'm having some issues in my custom framework derived from DITA. I can't see what I'm doing differently form the standard dita framework - still there it works and in my framework it doesn't!?
1. Ids for new documents
When creating a new document from a template the ids are not generated through my own method generateUniqueIDFor - those for new elements do. I'm returning an instance of a class derived from DITAUniqueAttributesRecognizer in the following methods:
What am I missing?
2. Ids for copied elements
When adding content by copy&paste (for instance a topic) the pasted element gets no default attribute in my framework. Even when using the standard DITAExtensionsBundle it doesn't work. Thus, it seems to be no matter of my class!?
3. Rendering of copied elements
When adding content by copy&paste the new elements are not displayed correctly - just as if the default attributes are not used (all text in a single line). After saving and refresh it works. For testing I used the standard DITA css and extension bundle and had the same effect...
Any ideas, what I might be missing?
One difference I noticed is that my framwork uses an xsd rather than a dtd.
Thanks and regards,
Patrik
I'm having some issues in my custom framework derived from DITA. I can't see what I'm doing differently form the standard dita framework - still there it works and in my framework it doesn't!?
1. Ids for new documents
When creating a new document from a template the ids are not generated through my own method generateUniqueIDFor - those for new elements do. I'm returning an instance of a class derived from DITAUniqueAttributesRecognizer in the following methods:
Code: Select all
private GdvdlDitaUniqueAttributesRecognizer uniqueAttributesRecognizer;
@Override
public AuthorExtensionStateListener createAuthorExtensionStateListener() {
uniqueAttributesRecognizer = new GdvdlDitaUniqueAttributesRecognizer();
return uniqueAttributesRecognizer;
}
@Override
public ClipboardFragmentProcessor getClipboardFragmentProcessor() {
return uniqueAttributesRecognizer;
}
@Override
public UniqueAttributesRecognizer getUniqueAttributesIdentifier() {
return uniqueAttributesRecognizer;
}
2. Ids for copied elements
When adding content by copy&paste (for instance a topic) the pasted element gets no default attribute in my framework. Even when using the standard DITAExtensionsBundle it doesn't work. Thus, it seems to be no matter of my class!?
3. Rendering of copied elements
When adding content by copy&paste the new elements are not displayed correctly - just as if the default attributes are not used (all text in a single line). After saving and refresh it works. For testing I used the standard DITA css and extension bundle and had the same effect...
Any ideas, what I might be missing?
One difference I noticed is that my framwork uses an xsd rather than a dtd.
Thanks and regards,
Patrik
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Custom framework: copy&paste and auto id behavior
Hi Patrik,
But you could use our API and set a new ID on the root element when you receive the callback ro.sync.exml.workspace.api.listeners.WSEditorChangeListener.editorOpened(URL) for example or on the first "ro.sync.ecss.extensions.api.AuthorExtensionStateListener.activated(AuthorAccess)" callback.
I think I managed to reproduce this on our side with the default XSD-based DITA topics support we have. I will get back to you on this one after I look a little bit in the code.
Regards,
Radu
The unique IDs generator works only while the user is actively editing inside the document so indeed it is not called when a new document is created.1. Ids for new documents
But you could use our API and set a new ID on the root element when you receive the callback ro.sync.exml.workspace.api.listeners.WSEditorChangeListener.editorOpened(URL) for example or on the first "ro.sync.ecss.extensions.api.AuthorExtensionStateListener.activated(AuthorAccess)" callback.
Probably these are the same thing, because the default attributes are not detected on the pasted elements, the CSSs which select based on them do not match the elements.2. Ids for copied elements
3. Rendering of copied elements
I think I managed to reproduce this on our side with the default XSD-based DITA topics support we have. I will get back to you on this one after I look a little bit in the code.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Custom framework: copy&paste and auto id behavior
Hi,
One extra remark about 2 and 3, I managed to reproduce the issue only when selecting the element in the Outline tree, using "Ctrl-C" and then pasting in the visual editor at a certain offset.
When I copied the content directly in the focused editor and pasted in the same editor, I could not reproduce the behavior.
Could you tell me precisely how you are performing the copy/paste on your side?
Regards,
Radu
One extra remark about 2 and 3, I managed to reproduce the issue only when selecting the element in the Outline tree, using "Ctrl-C" and then pasting in the visual editor at a certain offset.
When I copied the content directly in the focused editor and pasted in the same editor, I could not reproduce the behavior.
Could you tell me precisely how you are performing the copy/paste on your side?
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 280
- Joined: Thu Nov 28, 2013 9:32 am
- Location: Hamburg/Germany
- Contact:
Re: Custom framework: copy&paste and auto id behavior
Hi Radu,
for 1. I will experiment witrh the callbacks you suggested. This should solve the problem...
For 2&3: Indeed. Both, the rendering and the id generation, is working when selecting the content in the author view. So that's already a workaround. However, it is much easier to precisely select an element in the outline tree - that's why we always did it this way...
Thanks and regards,
Patrik
for 1. I will experiment witrh the callbacks you suggested. This should solve the problem...
For 2&3: Indeed. Both, the rendering and the id generation, is working when selecting the content in the author view. So that's already a workaround. However, it is much easier to precisely select an element in the outline tree - that's why we always did it this way...
Thanks and regards,
Patrik
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Custom framework: copy&paste and auto id behavior
Hi Patrik,
Regards,
Radu
The bug will be fixed in Oxygen 16. As a side note you can also triple click inside an element's text content to select it, or click it in the top-level breadcrumb path.However, it is much easier to precisely select an element in the outline tree - that's why we always did it this way...
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 280
- Joined: Thu Nov 28, 2013 9:32 am
- Location: Hamburg/Germany
- Contact:
Re: Custom framework: copy&paste and auto id behavior
Hi Radu,
Thanks for the tip - this indeed is very comfortable.
Patrik
Thanks for the tip - this indeed is very comfortable.
Patrik
-
- Posts: 280
- Joined: Thu Nov 28, 2013 9:32 am
- Location: Hamburg/Germany
- Contact:
Re: Custom framework: copy&paste and auto id behavior
Hi Radu,
I just implemented the recreation for @id on new documents within AuthorExtensionStateListener.activated simply by going recursively through all elements and set all existing id-attributes. This works fine and looks good in author mode. However, when switching to text mode the ids are not changed. Is there any method I need to call to re-synchronize the author-document with the text-document?
Thanks and regards,
Patrik
I just implemented the recreation for @id on new documents within AuthorExtensionStateListener.activated simply by going recursively through all elements and set all existing id-attributes. This works fine and looks good in author mode. However, when switching to text mode the ids are not changed. Is there any method I need to call to re-synchronize the author-document with the text-document?
Thanks and regards,
Patrik
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Custom framework: copy&paste and auto id behavior
Hi Patrik,
Let me see if I understand.
So you open the XML document and it opens in the Author editing mode. This triggers your extensions listener which sets IDs where necessary. These IDs should be set using the AuthorDocumentController.setAttribute(String, AttrValue, AuthorElement) API and not by directly setting attributes on each node. The API is necessary because it creates undoable edits for each set attribute and also marks the document as modified.
Then you switch to the Text mode and although the extension has set the attributes in the Author mode the Text mode does not contain the changes?
Regards,
Radu
Let me see if I understand.
So you open the XML document and it opens in the Author editing mode. This triggers your extensions listener which sets IDs where necessary. These IDs should be set using the AuthorDocumentController.setAttribute(String, AttrValue, AuthorElement) API and not by directly setting attributes on each node. The API is necessary because it creates undoable edits for each set attribute and also marks the document as modified.
Then you switch to the Text mode and although the extension has set the attributes in the Author mode the Text mode does not contain the changes?
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 280
- Joined: Thu Nov 28, 2013 9:32 am
- Location: Hamburg/Germany
- Contact:
Re: Custom framework: copy&paste and auto id behavior
Hi Radu,
I used AuthorElement.setAttribute(String, AttrValue) rather than AuthorDocumentController.setAttribute(String, AttrValue, AuthorElement). Making the changes undoable and marking the document as modified is not necessary, however, using the document controller it's working now.
Thanks again
Patrik
I used AuthorElement.setAttribute(String, AttrValue) rather than AuthorDocumentController.setAttribute(String, AttrValue, AuthorElement). Making the changes undoable and marking the document as modified is not necessary, however, using the document controller it's working now.
Thanks again
Patrik
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Custom framework: copy&paste and auto id behavior
Hi Patrik,
Great, you should probably also call ro.sync.ecss.extensions.api.AuthorDocumentController.beginCompoundEdit() before making the first change and ro.sync.ecss.extensions.api.AuthorDocumentController.endCompoundEdit() after the last attribute change has been made in order to signal to Oxygen that this multiple change of attributes should be interpreted as one compound undoable edit (user presses Undo once and all attribute set changes are reverted).
Regards,
Radu
Great, you should probably also call ro.sync.ecss.extensions.api.AuthorDocumentController.beginCompoundEdit() before making the first change and ro.sync.ecss.extensions.api.AuthorDocumentController.endCompoundEdit() after the last attribute change has been made in order to signal to Oxygen that this multiple change of attributes should be interpreted as one compound undoable edit (user presses Undo once and all attribute set changes are reverted).
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Custom framework: copy&paste and auto id behavior
Hi Patrik,
Oxygen 16.0 also has a fix for the issue in which copy/pasting from the Outline did not preserve the default attribute values for XML documents with associated XML Schema grammars.
Regards,
Radu
Oxygen 16.0 also has a fix for the issue in which copy/pasting from the Outline did not preserve the default attribute values for XML documents with associated XML Schema grammars.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Return to “SDK-API, Frameworks - Document Types”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service