Skip to content

Commit

Permalink
feat: assistant button
Browse files Browse the repository at this point in the history
This is needed as we are implementing a new feature in Nextcloud which
integrates the Nextcloud AI Assistant. It will only be available if the
required wopi attribute is passed in CheckFileInfo, which currently is
only provided by Nextcloud.

Signed-off-by: Elizabeth Danzberger <[email protected]>
Change-Id: Idfbc00f46b400413053b6068b327014b5ddd7a35
  • Loading branch information
elzody authored and eszkadev committed Jan 21, 2025
1 parent 2ec5568 commit 87b7357
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 0 deletions.
1 change: 1 addition & 0 deletions browser/src/control/Control.JSDialogBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -2039,6 +2039,7 @@ L.Control.JSDialogBuilder = L.Control.extend({
'scalignmentpropertypanel': 'aligntop',
'hyperlinkdialog': 'inserthyperlink',
'remotelink': 'inserthyperlink',
'remoteaicontent': 'sdrespageobjs',
'openhyperlinkoncursor': 'inserthyperlink',
'pageformatdialog': 'pagedialog',
'backgroundcolor': 'fillcolor',
Expand Down
12 changes: 12 additions & 0 deletions browser/src/control/Control.Menubar.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ L.Control.Menubar = L.Control.extend({
{type: 'separator'},
{name: _UNO('.uno:HyperlinkDialog'), id: 'inserthyperlink', type: 'action'},
{name: _('Smart Picker'), id: 'remotelink', type: 'action'},
{name: _('AI Assistant'), id: 'remoteaicontent', type: 'action'},
{type: 'separator'},
{uno: '.uno:InsertQrCode'},
{uno: '.uno:InsertSymbol'},
Expand Down Expand Up @@ -484,6 +485,7 @@ L.Control.Menubar = L.Control.extend({
{type: 'separator'},
{name: _UNO('.uno:HyperlinkDialog'), id: 'inserthyperlink', type: 'action'},
{name: _('Smart Picker'), id: 'remotelink', type: 'action'},
{name: _('AI Assistant'), id: 'remoteaicontent', type: 'action'},
{type: 'separator'},
{uno: '.uno:InsertSymbol'},
{type: 'separator'},
Expand Down Expand Up @@ -631,6 +633,7 @@ L.Control.Menubar = L.Control.extend({
{type: 'separator'},
{name: _UNO('.uno:HyperlinkDialog'), id: 'inserthyperlink', type: 'action'},
{name: _('Smart Picker'), id: 'remotelink', type: 'action'},
{name: _('AI Assistant'), id: 'remoteaicontent', type: 'action'},
{type: 'separator'},
{uno: '.uno:InsertSymbol'},
{type: 'separator'},
Expand Down Expand Up @@ -785,6 +788,7 @@ L.Control.Menubar = L.Control.extend({
{type: 'separator'},
{name: _UNO('.uno:HyperlinkDialog'), uno: '.uno:HyperlinkDialog'},
{name: _('Smart Picker'), id: 'remotelink', type: 'action'},
{name: _('AI Assistant'), id: 'remoteaicontent', type: 'action'},
{uno: '.uno:InsertSymbol'},
{type: 'separator'},
{name: _UNO('.uno:InsertField', 'text'), type: 'menu', menu: [
Expand Down Expand Up @@ -1930,6 +1934,13 @@ L.Control.Menubar = L.Control.extend({
else
$(aItem).hide();
}

if (id === 'remoteaicontent') {
if (self._map['wopi'].EnableRemoteAIContent)
$(aItem).show();
else
$(aItem).hide();
}
});
},

Expand Down Expand Up @@ -1992,6 +2003,7 @@ L.Control.Menubar = L.Control.extend({
|| id.startsWith('zotero')
|| id === 'deletepage'
|| id === 'remotelink'
|| id === 'remoteaicontent'
|| id === 'toggledarktheme'
|| id === 'invertbackground'
|| id === 'home-search'
Expand Down
8 changes: 8 additions & 0 deletions browser/src/control/Control.NotebookbarCalc.js
Original file line number Diff line number Diff line change
Expand Up @@ -1386,6 +1386,14 @@ L.Control.NotebookbarCalc = L.Control.NotebookbarWriter.extend({
'command': 'remotelink',
'accessibility': { focusBack: true, combination: 'LR', de: null }
} : {},
(this._map['wopi'].EnableRemoteAIContent) ? {
'id': 'insert-insert-remote-ai-content',
'class': 'unoremoteaicontent',
'type': 'bigcustomtoolitem',
'text': _('Assistant'),
'command': 'remoteaicontent',
'accessibility': { focusBack: true, combination: 'RL', de: null }
} : {},
{
'type': 'container',
'children': [
Expand Down
8 changes: 8 additions & 0 deletions browser/src/control/Control.NotebookbarDraw.js
Original file line number Diff line number Diff line change
Expand Up @@ -1278,6 +1278,14 @@ L.Control.NotebookbarDraw = L.Control.NotebookbarImpress.extend({
'command': 'remotelink',
'accessibility': { focusBack: true, combination: 'RL', de: null }
} : {},
(this._map['wopi'].EnableRemoteAIContent) ? {
'id': 'insert-insert-remote-ai-content',
'class': 'unoremoteaicontent',
'type': 'bigcustomtoolitem',
'text': _('Assistant'),
'command': 'remoteaicontent',
'accessibility': { focusBack: true, combination: 'RL', de: null }
} : {},
{
'type': 'container',
'children': [
Expand Down
8 changes: 8 additions & 0 deletions browser/src/control/Control.NotebookbarImpress.js
Original file line number Diff line number Diff line change
Expand Up @@ -1290,6 +1290,14 @@ L.Control.NotebookbarImpress = L.Control.NotebookbarWriter.extend({
'command': 'hyperlinkdialog',
'accessibility': { focusBack: true, combination: 'IL', de: null }
},
(this._map['wopi'].EnableRemoteAIContent) ? {
'id': 'insert-insert-remote-ai-content',
'class': 'unoremoteaicontent',
'type': 'bigcustomtoolitem',
'text': _('Assistant'),
'command': 'remoteaicontent',
'accessibility': { focusBack: true, combination: 'RL', de: null }
} : {},
{
'id': 'insert-insert-annotation',
'type': 'bigtoolitem',
Expand Down
8 changes: 8 additions & 0 deletions browser/src/control/Control.NotebookbarWriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,14 @@ L.Control.NotebookbarWriter = L.Control.Notebookbar.extend({
'command': 'hyperlinkdialog',
'accessibility': { focusBack: false, combination: 'ZL', de: '8' }
},
(this._map['wopi'].EnableRemoteAIContent) ? {
'id': 'insert-insert-remote-ai-content',
'class': 'unoremoteaicontent',
'type': 'bigcustomtoolitem',
'text': _('Assistant'),
'command': 'remoteaicontent',
'accessibility': { focusBack: true, combination: 'RL', de: null }
} : {},
{
'id': 'insert-insert-annotation',
'type': 'bigtoolitem',
Expand Down
3 changes: 3 additions & 0 deletions browser/src/docdispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ class Dispatcher {
this.actionsMap['remotelink'] = function () {
app.map.fire('postMessage', { msgId: 'UI_PickLink' });
};
this.actionsMap['remoteaicontent'] = function () {
app.map.fire('postMessage', { msgId: 'UI_InsertAIContent' });
};
// TODO: deduplicate
this.actionsMap['hyperlinkdialog'] = function () {
app.map.showHyperlinkDialog();
Expand Down
2 changes: 2 additions & 0 deletions browser/src/map/handler/Map.WOPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ L.Map.WOPI = L.Handler.extend({
EnableInsertRemoteFile: false, /* Separate, because requires explicit integration support */
DisableInsertLocalImage: false,
EnableInsertRemoteLink: false,
EnableRemoteAIContent: false,
EnableShare: false,
HideUserList: null,
CallPythonScriptSource: null,
Expand Down Expand Up @@ -131,6 +132,7 @@ L.Map.WOPI = L.Handler.extend({
this.EnableInsertRemoteFile = !!wopiInfo['EnableInsertRemoteFile'];
this.DisableInsertLocalImage = !!wopiInfo['DisableInsertLocalImage'];
this.EnableRemoteLinkPicker = !!wopiInfo['EnableRemoteLinkPicker'];
this.EnableRemoteAIContent = !!wopiInfo['EnableRemoteAIContent'];
this.SupportsRename = !!wopiInfo['SupportsRename'];
this.UserCanRename = !!wopiInfo['UserCanRename'];
this.EnableShare = !!wopiInfo['EnableShare'];
Expand Down
1 change: 1 addition & 0 deletions wsd/DocumentBroker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1397,6 +1397,7 @@ DocumentBroker::updateSessionWithWopiInfo(const std::shared_ptr<ClientSession>&
wopiInfo->set("EnableInsertRemoteFile", wopiFileInfo->getEnableInsertRemoteFile());
wopiInfo->set("DisableInsertLocalImage", wopiFileInfo->getDisableInsertLocalImage());
wopiInfo->set("EnableRemoteLinkPicker", wopiFileInfo->getEnableRemoteLinkPicker());
wopiInfo->set("EnableRemoteAIContent", wopiFileInfo->getEnableRemoteAIContent());
wopiInfo->set("EnableShare", wopiFileInfo->getEnableShare());
wopiInfo->set("HideUserList", wopiFileInfo->getHideUserList());
wopiInfo->set("SupportsRename", wopiFileInfo->getSupportsRename());
Expand Down
1 change: 1 addition & 0 deletions wsd/wopi/WopiStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ WopiStorage::WOPIFileInfo::WOPIFileInfo(const FileInfo& fileInfo, Poco::JSON::Ob
JsonUtil::findJSONValue(object, "EnableInsertRemoteFile", _enableInsertRemoteFile);
JsonUtil::findJSONValue(object, "DisableInsertLocalImage", _disableInsertLocalImage);
JsonUtil::findJSONValue(object, "EnableRemoteLinkPicker", _enableRemoteLinkPicker);
JsonUtil::findJSONValue(object, "EnableRemoteAIContent", _enableRemoteAIContent);
JsonUtil::findJSONValue(object, "EnableShare", _enableShare);
JsonUtil::findJSONValue(object, "HideUserList", _hideUserList);
JsonUtil::findJSONValue(object, "SupportsLocks", _supportsLocks);
Expand Down
3 changes: 3 additions & 0 deletions wsd/wopi/WopiStorage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class WopiStorage : public StorageBase
bool getEnableInsertRemoteFile() const { return _enableInsertRemoteFile; }
bool getDisableInsertLocalImage() const { return _disableInsertLocalImage; }
bool getEnableRemoteLinkPicker() const { return _enableRemoteLinkPicker; }
bool getEnableRemoteAIContent() const { return _enableRemoteAIContent; }
bool getEnableShare() const { return _enableShare; }
bool getSupportsRename() const { return _supportsRename; }
bool getSupportsLocks() const { return _supportsLocks; }
Expand Down Expand Up @@ -162,6 +163,8 @@ class WopiStorage : public StorageBase
bool _disableInsertLocalImage = false;
/// If set to true, users can access the remote link picker functionality
bool _enableRemoteLinkPicker = false;
/// If set to true, users can insert remote AI-generated content
bool _enableRemoteAIContent = false;
/// If set to true, users can access the file share functionality
bool _enableShare = false;
/// If WOPI host supports locking
Expand Down

0 comments on commit 87b7357

Please sign in to comment.