Webapp customisation

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.
aleh.haidash
Posts: 32
Joined: Tue May 26, 2015 10:28 am

Webapp customisation

Post by aleh.haidash » Thu May 10, 2018 9:13 am

Hello.
We use Oxygen Webapp 19.1 as dita editor. We faced with some issues connected with customization it for our needs:
1) How we can remove actions from context menu (for example Edit reference Image) ?

2) We catch exception connected with dirty status. We use dirty listener with call server operation

Code: Select all


goog.events.listen(editor, sync.api.Editor.EventTypes.DIRTY_STATUS_CHANGED, function(e) { 
new sync.ops.ServerOperation("webapp.extention.action.NotifyDirty", editor.getController()).doOperation(function(){}, {
isDirty: e.isDirty
}, null);
}
When we try to call some oxygen actions, that remove selected offset (for example Join Cell Above, paste text from external source), we got exception Image with next stacktrace

Code: Select all


workspace-f31af6f40d.js:1393 Uncaught Error: Reference sentinel not found for position: {"nodeId":"44","sentinelType":0,"distance":0}
at Function.sync.caret.ContentIterator.fromRelativeContentPosition (VM566 workspace-f31af6f40d.js:1393)
at sync.position.RelativeContentPosition.toHTMLPosition (VM566 workspace-f31af6f40d.js:1426)
at sync.select.SavedSelection.restore (VM566 workspace-f31af6f40d.js:1548)
at sync.select.SelectionHandler.getCurrentSelection (VM566 workspace-f31af6f40d.js:1934)
at Object.sync.select.getSelection (VM566 workspace-f31af6f40d.js:1545)
at sync.ops.ServerOperation.doOperation (VM566 workspace-f31af6f40d.js:2120)
at sync.Editor.<anonymous> (VM570 plugins.js:53)
at sync.Editor.goog.events.EventTarget.fireListeners (VM566 workspace-f31af6f40d.js:234)
at Function.goog.events.EventTarget.dispatchEventInternal_ (VM566 workspace-f31af6f40d.js:236)
at sync.Editor.goog.events.EventTarget.dispatchEvent (VM566 workspace-f31af6f40d.js:231)
.
Where plugins.js:53 - new sync.ops.ServerOperation from prev code block.

3) We need to add new attribute to selected node in "xml mode". It works fine in author mode:

Code: Select all


documentController.beginCompoundEdit();
documentController.removeAttribute(tag.getName(), element);
documentController.setAttribute(tag.getName(), newAttr, element);
documentController.insertXMLFragment("", element.getStartOffset());
documentController.endCompoundEdit();
if we use xml mode, attribute was added. But is notshowed in xml mode. We need to reload xml mode (go back to author and open xml mode again). Could you provide possible way to insert attribute in xml mode(using current offset/caret position), or reload document in xml mode or api for getting current mode?


Could you help us with these issues? We hope you have a solution, since we don't want to hardcode these problems.
Thanks.
Best Regards,
Aleh

cristi_talau
Posts: 293
Joined: Thu Sep 04, 2014 4:22 pm

Re: Webapp customisation

Post by cristi_talau » Thu May 10, 2018 7:31 pm

Hello,

1. The Action has the ID: 'Author/EditReference' . You can remove it as in this tutorial: https://www.oxygenxml.com/maven/com/oxy ... ction.html .

2. You can try to invoke the API method instead: sync.api.ActionsManager#invokeOperation (https://www.oxygenxml.com/maven/com/oxy ... nager.html) . It seems that you are executing your (background) operation in parallel with another operation performed by the user. You may consider setting the opt_background parameter of the method that I mentioned above.

3.The text page is synchronised with the server-side model only when switching to/from the Author View. Unfortunately, we also do not have API for the text page. Did you add actions on the toolbar in text-mode also? How does the user get to insert that attribute? I would suggest modifying the text and then it will be synchronised to the server model when the user switches to Author mode or saves.

Best,
Cristian

aleh.haidash
Posts: 32
Joined: Tue May 26, 2015 10:28 am

Re: Webapp customisation

Post by aleh.haidash » Fri May 11, 2018 8:40 am

Hello.
Thank you for your quick response.
I'll check 1) and 2). I thinks it'll help.

About 3) I use external operation. I handle it in js and then call ServerOperation.
I would suggest modifying the text and then it will be synchronised to the server model when the user switches to Author mode or saves.
I want to do like this, but I need your help: how can I insert attribute in current selected node in xml mode using js or java? Is it possible for now?

Thanks.
Best Regards,
Aleh

cristi_talau
Posts: 293
Joined: Thu Sep 04, 2014 4:22 pm

Re: Webapp customisation

Post by cristi_talau » Mon May 14, 2018 1:25 pm

Hello,

Unfortunately, we do not have a high-level API for the text page. We use CodeMirror in that page, so you can use its API to modify the content (e.g. http://codemirror.net/doc/manual.html#replaceSelection).

Best,
Cristian

aleh.haidash
Posts: 32
Joined: Tue May 26, 2015 10:28 am

Re: Webapp customisation

Post by aleh.haidash » Fri May 25, 2018 11:28 am

2. You can try to invoke the API method instead: sync.api.ActionsManager#invokeOperation (https://www.oxygenxml.com/maven/com/oxy ... nager.html) . It seems that you are executing your (background) operation in parallel with another operation performed by the user. You may consider setting the opt_background parameter of the method that I mentioned above.
Hello
Unfortunately I receive this issue again if I try to call next operation(I think without active selection)

Code: Select all

editor.getActionsManager().invokeOperation('SetReadOnlyStatusOperation', {'read-only': state},callback)
I tried to call with param opt_background, but it didn't help me.

Stacktrace

Code: Select all

	sync.caret.ContentIterator.fromRelativeContentPosition
http://192.168.94.211:8080/oxygen-editor/app/workspace-1f234a0d74.js:1395:154
sync.position.RelativeContentPosition.prototype.toHTMLPosition
http://192.168.94.211:8080/oxygen-editor/app/workspace-1f234a0d74.js:1428:406
sync.select.SavedSelection.prototype.restore
http://192.168.94.211:8080/oxygen-editor/app/workspace-1f234a0d74.js:1550:90
sync.select.SelectionHandler.prototype.getCurrentSelection
http://192.168.94.211:8080/oxygen-editor/app/workspace-1f234a0d74.js:1937:489
sync.select.getSelection
http://192.168.94.211:8080/oxygen-editor/app/workspace-1f234a0d74.js:1547:74
sync.ops.ServerOperation.prototype.doOperation
http://192.168.94.211:8080/oxygen-editor/app/workspace-1f234a0d74.js:2145:279
sync.actions.ActionsManager.prototype.invokeOperation/this.opsQueue_<
http://192.168.94.211:8080/oxygen-editor/app/workspace-1f234a0d74.js:1557:236
goog.Promise.prototype.addChildPromise_/d.child</d.onFulfilled<
http://192.168.94.211:8080/oxygen-editor/app/workspace-1f234a0d74.js:749:187
goog.Promise.invokeCallback_
http://192.168.94.211:8080/oxygen-editor/app/workspace-1f234a0d74.js:757:79
goog.Promise.prototype.executeCallback_
http://192.168.94.211:8080/oxygen-editor/app/workspace-1f234a0d74.js:756:180
goog.Promise.prototype.executeCallbacks_
http://192.168.94.211:8080/oxygen-editor/app/workspace-1f234a0d74.js:755:135
goog.async.run.processWorkQueue
http://192.168.94.211:8080/oxygen-editor/app/workspace-1f234a0d74.js:735:97
How I can resolve this issue? Or maybe Can you help me with setting empty selection for root node of document?

Thanks.
Best Regards,
Aleh

aleh.haidash
Posts: 32
Joined: Tue May 26, 2015 10:28 am

Re: Webapp customisation

Post by aleh.haidash » Fri May 25, 2018 11:59 am

I want to add that I call

Code: Select all

editor.getActionsManager().invokeOperation('ro.sync.ecss.extensions.commons.operations.ReloadContentOperation', {}, callback);
maybe this operation delete selection or something else.

but I catch error with selection if I call this 2 operation next order ReloadContentOperation -> SetReadOnlyStatusOperation.

Thanks
Best Regards,
Aleh

mihai_coanda
Posts: 13
Joined: Wed Jul 20, 2016 8:22 am

Re: Webapp customisation

Post by mihai_coanda » Tue May 29, 2018 3:52 pm

Hello,

I am trying to reproduce your issue using the 19.1 build from our website by running the following code in the browser's console:

Code: Select all


workspace.currentEditor.getActionsManager().invokeOperation('ro.sync.ecss.extensions.commons.operations.ReloadContentOperation', {}, goog.nullFunction);

workspace.currentEditor.getActionsManager().invokeOperation('SetReadOnlyStatusOperation', {'read-only': true},goog.nullFunction)
This call works as expected and we cannot reproduce the issue you are experiencing.

In order to support you in overcoming this issue we first need to reproduce it on our side. It would be great if you could provide us a code snippet that we can execute in the browser's console and reproduce the issue.

Another point of interest would be if you constantly reproduce this issue each time you call your code or is it some special scenario in which you do. If this issue appears in only certain scenarios we would need a step by step scenario.

Regards,
Michael

Post Reply