AuthorDocumentModel features
-
- Posts: 61
- Joined: Tue Oct 27, 2015 11:49 am
AuthorDocumentModel features
Post by Konstantin »
I use Webapp 18.0.0.3
I have questions about features AuthorDocumentModel.
I keep map of AuthorDocumentModel for each opened editor and thru it I get access to almost all data. I can get content, show messages on editor, setReadOnly ...
But I can't get status isDirty
I try get it thru
Code: Select all
final AuthorDocumentModel documentModel = getDocumentModel(editorUID);
WSEditor wsEditor = documentModel.getWSEditor().isModified();
The same I get for setModified(isDirty)
Is there way to get isDirty status thru AuthorDocumentModel?
Also I need get Actions and set they to Enable/Disable. The closest that I found documentModel.getActionsManager().getExtensionAction(String)
But array of actions don't contain my custom actions which I added thru JS
-
- Posts: 517
- Joined: Thu Sep 04, 2014 4:22 pm
Re: AuthorDocumentModel features
Post by cristi_talau »
We have client-side JS API for managing the "dirty" status of the editor [1]. Can you use that instead?
Best,
Cristian
[1] https://www.oxygenxml.com/maven/com/oxy ... ditor.html
-
- Posts: 61
- Joined: Tue Oct 27, 2015 11:49 am
Re: AuthorDocumentModel features
Post by Konstantin »
No I must use Java.Can you use that instead?
I have big functionality in Java and I can't divide code
-
- Posts: 517
- Joined: Thu Sep 04, 2014 4:22 pm
Re: AuthorDocumentModel features
Post by cristi_talau »
Unfortunately, the dirty flag is designed to be a client-side feature. However, we were able to make use of it in a variety of situations.
Can you describe your use-case in more details? Maybe we can find a workaround.
Best,
Cristian
-
- Posts: 61
- Joined: Tue Oct 27, 2015 11:49 am
Re: AuthorDocumentModel features
Post by Konstantin »
Code: Select all
goog.events.listen(editor, sync.api.Editor.EventTypes.DIRTY_STATUS_CHANGED, function(e) {
setDirty(e, editor, function() { });
});
function setDirty(event, editor, callback) {
new sync.ops.ServerOperation("webapp.extention.action.DirtyAction", editor.controller).doOperation(callback, {
"url": editor.options.url,
"isDirty": event.isDirty
}, null);
}
But I have problems with ReadOnly(Editable) mode in editor, because it implemented very bad. In read only mode I can use all actions (they not disabled but after using shows message that I can't use it).
And more worse when I type a text new letters show and at once hide.
It maybe not very bad but isDirty changes to true.
https://drive.google.com/open?id=0B8kWu ... 2NHY2NyQ0E
Also when I do some changes in text (not in ReadOnly) and press Undo to begin isDirty don't change to false.
Do you have plans to improve ReadOnly mode?
It is important for me and I need do something with it.
-
- Posts: 517
- Joined: Thu Sep 04, 2014 4:22 pm
Re: AuthorDocumentModel features
Post by cristi_talau »
In the upcoming release we have some improvements w.r.t dirty flag:
1. When you type in a read-only document the dirty flag is not set. However, the characters that you type will still appear for a second or so and the actions are still enabled - I registered an issue for this.
2. After making a change and pressing Undo, the dirty flag is reset to false.
We plan to have this release in August. This will include only the installation kits, so if you are developing your customization as a plugin, you will be able to use it with the new release.
I also wanted to mention the
Code: Select all
ro.sync.ecss.webapp.access.WebappAuthorEditorAccess.setReadOnly(String)
Best,
Cristian
-
- Posts: 61
- Joined: Tue Oct 27, 2015 11:49 am
-
- Posts: 61
- Joined: Tue Oct 27, 2015 11:49 am
Re: AuthorDocumentModel features
Post by Konstantin »
I have problem with refreshing after editing content.
We used this code in Applet and text in AuthorMode was refreshed
Code: Select all
final AuthorAccess authorAccess = getAccess();
final AuthorDocumentController documentController = authorAccess.getDocumentController();
documentController.beginCompoundEdit();
documentController.removeAttribute(attrName, element);
documentController.setAttribute(attrName, new AttrValue(attrValue), element);
documentController.insertXMLFragment("", element.getStartOffset());
documentController.endCompoundEdit();
If I change something in TextMode and return to AuthorMode the all my changes appear
I tried to do something like this but it does not works:
Code: Select all
authorAccess.getEditorAccess().refresh();
authorAccess.getEditorAccess().refresh(node);
-
- Posts: 61
- Joined: Tue Oct 27, 2015 11:49 am
Re: AuthorDocumentModel features
Post by Konstantin »
Code: Select all
final AuthorAccess authorAccess = authorDocumentModel.getAuthorAccess()
final AuthorDocumentController documentController = authorAccess.getDocumentController();
int currentOffset = authorAccess.getEditorAccess().getCaretOffset();
AuthorNode node = documentController.getNodeAtOffset(currentOffset);
-
- Site Admin
- Posts: 95
- Joined: Thu Jun 09, 2016 2:01 pm
Re: AuthorDocumentModel features
Post by Gabriel Titerlea »
Can you explain in more detail what you want to achieve? How are you inserting the text, how does the user initiate the action of inserting some text?Konstantin wrote:Hi
I have problem with refreshing after editing content.
We used this code in Applet and text in AuthorMode was refreshedBut in Webapp 18 text inserted in TextMode but there are no changes in AuthorMode.Code: Select all
final AuthorAccess authorAccess = getAccess();
final AuthorDocumentController documentController = authorAccess.getDocumentController();
documentController.beginCompoundEdit();
documentController.removeAttribute(attrName, element);
documentController.setAttribute(attrName, new AttrValue(attrValue), element);
documentController.insertXMLFragment("", element.getStartOffset());
documentController.endCompoundEdit();
If I change something in TextMode and return to AuthorMode the all my changes appear
I tried to do something like this but it does not works:How can I refresh content or part content from AuthorDocumentModel or AuthorAccess?Code: Select all
authorAccess.getEditorAccess().refresh();
authorAccess.getEditorAccess().refresh(node);
I'm trying to understand your use-case so that we can implement the required API.
-
- Site Admin
- Posts: 95
- Joined: Thu Jun 09, 2016 2:01 pm
Re: AuthorDocumentModel features
Post by Gabriel Titerlea »
It's not a bug. The server does not know where the client-side caret is at all times. The server receives the client-sides caret position whenever an editing action is performed (E.g. inserting text).Konstantin wrote:Else I found bug
This code return not that node which shown on AuthorMode-Breadcrumbs for closed tags, like "<p/>" (return <body> node)Code: Select all
final AuthorAccess authorAccess = authorDocumentModel.getAuthorAccess()
final AuthorDocumentController documentController = authorAccess.getDocumentController();
int currentOffset = authorAccess.getEditorAccess().getCaretOffset();
AuthorNode node = documentController.getNodeAtOffset(currentOffset);
Can you tell me what you want to achieve so that we may expose some API for your use-case?
-
- Posts: 61
- Joined: Tue Oct 27, 2015 11:49 am
Re: AuthorDocumentModel features
Post by Konstantin »
I insert different attributes and tags inside some tags.Gabriel Titerlea wrote: Can you explain in more detail what you want to achieve? How are you inserting the text, how does the user initiate the action of inserting some text?
I'm trying to understand your use-case so that we can implement the required API.
For example from "<p/>" I make "<p conkeyref="chunk_xxx/p_topic_body_p_5_1"/> " and I need refresh content and do ReferenseResolving for this.
-
- Posts: 61
- Joined: Tue Oct 27, 2015 11:49 am
Re: AuthorDocumentModel features
Post by Konstantin »
I need make something like this:Gabriel Titerlea wrote: It's not a bug. The server does not know where the client-side caret is at all times. The server receives the client-sides caret position whenever an editing action is performed (E.g. inserting text).
Can you tell me what you want to achieve so that we may expose some API for your use-case?
"<p/>" ---->>> "<p conkeyref="chunk_xxx/p_topic_body_p_5_1"/> "
-
- Site Admin
- Posts: 95
- Joined: Thu Jun 09, 2016 2:01 pm
Re: AuthorDocumentModel features
Post by Gabriel Titerlea »
Like I've previously mentioned, the server does not know where the client-side caret is. The server receives the client-sides caret position whenever an editing action is performed (E.g. inserting text or invoking an action). So I'm afraid that you can't do these changes from a different plugin. What you can do is to invoke Author Operations [1] from the client side using javascript. An operation that can help you with setting an attribute is ChangeAttributeOperation. The API for invoking this action also allows you to give it parameters:
Code: Select all
editor.getActionsManager().invokeOperation(
'ro.sync.ecss.extensions.commons.operations.ChangeAttributeOperation',
{
'name': 'conkeyref',
'value': 'chunk_xxx/p_topic_body_p_5_1'
}
);
If the default operations aren't enough for a given situation, you can develop a custom Author Operation and add it to the DITA framework [3]. Make sure you annotate this operation as being Webapp compatible:
Code: Select all
@WebappCompatible
public class InsertFragmentOperation implements AuthorOperation {
}
The advantage of using this method is that you won't need to refresh the content of the editor, it will be refreshed as needed automatically.
If you will be implementing custom actions in the DITA framework you will need to add the updated framework to Web Author [4].
About the API to send the caret position to the server. We still have not decided whether we will include such API. And if we do it will take a while until it's available.
Let me know if you have other questions,
Gabriel
[1] http://oxygenxml.com/doc/versions/18.0/ ... tions.html
[2] https://www.oxygenxml.com/maven/com/oxy ... ction.html
[3] http://oxygenxml.com/doc/versions/18.0/ ... HowTo.html
[4] https://www.oxygenxml.com/doc/versions/ ... ,framework
-
- Posts: 61
- Joined: Tue Oct 27, 2015 11:49 am
Re: AuthorDocumentModel features
Post by Konstantin »
How can I get cursors offset in JS.
As you wrote I want use:
Code: Select all
editor.getActionsManager().invokeOperation(
'ro.sync.ecss.extensions.commons.operations.ChangeAttributeOperation',
{
'params': params',
'offset': editor.offset <<--- ???
}
);
But I cant find how can I get cursor offset.
-
- Posts: 517
- Joined: Thu Sep 04, 2014 4:22 pm
Re: AuthorDocumentModel features
Post by cristi_talau »
The API for invoking an operation is:
Code: Select all
sync.api.ActionsManager.prototype.invokeOperation = function(className, params, callback, opt_selection) { ... }
We are currently working to provide more API to work with the XML DOM and selections. Can you share your use-case, so that we make sure that it is covered by the new API?
Best,
Cristian
[1] https://www.oxygenxml.com/maven/com/oxy ... ction.html
-
- Posts: 61
- Joined: Tue Oct 27, 2015 11:49 am
Re: AuthorDocumentModel features
Post by Konstantin »
I changed calling Java function which insert new content thru JS but not thru servlet as was early.
And now:
Code: Select all
int currentOffset = authorAccess.getEditorAccess().getCaretOffset();
-
- Posts: 517
- Joined: Thu Sep 04, 2014 4:22 pm
Re: AuthorDocumentModel features
Post by cristi_talau »
I wanted to let you know that we are about to release Web Author 19.1 and that we improved the handling of read-only mode.
You can already test how it works by going to our online demo server: https://www.oxygenxml.com/webapp-demo-a ... xygen.html . In order to switch the document to read-only mode you can use the DevTools to run the following code:
Code: Select all
// DO NOT USE IN PRODUCTION
workspace.currentEditor.setReadOnlyState({readOnly: true, message: 'Document is not checked out.'})
Cristian
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ 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