Skip to content

Commit

Permalink
feat: generate text and insert it into the document
Browse files Browse the repository at this point in the history
Signed-off-by: Elizabeth Danzberger <lizzy712
  • Loading branch information
elzody committed Dec 12, 2024
1 parent 9bc4bc6 commit fd56add
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions src/mixins/assistant.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { translate as t } from '@nextcloud/l10n'

const GENERATE_TEXT = 'core:text2text'
const GENERATE_IMAGE = 'core:text2image'

export default {
data() {
return {
Expand All @@ -10,35 +16,36 @@ export default {
{
label: t('richdocuments', 'Insert into document'),
title: t('richdocuments', 'Insert into document'),
onClick: () => this.sendAIContent(this.task),
onClick: () => this.handleTask(this.task),
},
],
}
},
methods: {
async openAssistant() {
this.task = await OCA.Assistant.openAssistantForm({
this.task = await window.OCA.Assistant.openAssistantForm({
appId: 'richdocuments',
customId: 'richdocuments:' + this.fileid,
isInsideViewer: true,
actionButtons: this.buttons,
})
},
sendAIContent(task) {
handleTask(task) {
switch (task.type) {
case GENERATE_TEXT:
this.sendPostMessage('Action_Paste', {
Mimetype: 'text/plain;charset=utf-8',
Data: task.output.output,
})

this.insertAIText(task.output.output)
break
case GENERATE_IMAGE:
break
default:
break
}

console.log({ aiGeneratedContent: task })
},
insertAIText(text) {
this.sendPostMessage('Action_Paste', {
Mimetype: 'text/plain;charset=utf-8',
Data: text,
})
},
},
}

0 comments on commit fd56add

Please sign in to comment.