Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: insert text and images generated with nextcloud assistant #10730

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions browser/src/control/Control.JSDialogBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -2053,6 +2053,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'},
elzody marked this conversation as resolved.
Show resolved Hide resolved
{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 @@ -1929,6 +1933,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 @@ -1991,6 +2002,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' });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so how does this work? What is the expected response to this message?

We'll need to update the documentation afterwards.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't expect any response, the integrator can handle it with whatever they want. Our integration is inserting text for example: nextcloud/richdocuments#4333

@pedropintosilva The smart picker is also not documented.

};
// 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 @@ -125,6 +126,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 @@ -1388,6 +1388,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 @@ -161,6 +162,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
Loading