-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: julia.kirschenheuter <julia.kirschenheuter@nextcloud.com>
- Loading branch information
1 parent
b83be2f
commit a1dc138
Showing
2 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<template> | ||
<div class="container-suggestions"> | ||
<NcButton type="tertiary" | ||
size="normal" | ||
@click="$callChooseLocalAttachment"> | ||
<template #icon> | ||
<Document :size="20" /> | ||
</template> | ||
{{ t('text', 'Add image') }} | ||
</NcButton> | ||
|
||
<NcButton ref="suggestButtonFile" | ||
type="tertiary" | ||
size="normal" | ||
@click="$callChooseLocalAttachment"> | ||
<template #icon> | ||
<Document :size="20" /> | ||
</template> | ||
{{ t('text', 'Link to file') }} | ||
</NcButton> | ||
|
||
<NcButton type="tertiary" | ||
size="normal" | ||
@click="insertTable"> | ||
<template #icon> | ||
<Table :size="20" /> | ||
</template> | ||
{{ t('text', 'Insert Table') }} | ||
</NcButton> | ||
|
||
<NcButton type="tertiary" | ||
size="normal" | ||
@click="linkPicker"> | ||
<template #icon> | ||
<Shape :size="20" /> | ||
</template> | ||
{{ t('text', 'Smart Picker') }} | ||
</NcButton> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { NcButton } from '@nextcloud/vue' | ||
import { Document, Table, Shape } from './icons.js' | ||
import { useActionChooseLocalAttachmentMixin } from './Editor/MediaHandler.provider.js' | ||
import { getLinkWithPicker } from '@nextcloud/vue/dist/Components/NcRichText.js' | ||
import { useEditorMixin } from './Editor.provider.js' | ||
export default { | ||
name: 'SuggestionsBar', | ||
components: { | ||
Table, | ||
Document, | ||
NcButton, | ||
Shape, | ||
}, | ||
mixins: [ | ||
useActionChooseLocalAttachmentMixin, | ||
useEditorMixin, | ||
], | ||
methods: { | ||
linkPicker() { | ||
getLinkWithPicker(null, true) | ||
.then(link => { | ||
const chain = this.$editor.chain() | ||
if (this.$editor.view.state?.selection.empty) { | ||
chain.focus().insertPreview(link).run() | ||
} else { | ||
chain.setLink({ href: link }).focus().run() | ||
} | ||
}) | ||
.catch(error => { | ||
console.error('Smart picker promise rejected', error) | ||
}) | ||
}, | ||
insertTable() { | ||
this.$editor.chain().focus().insertTable()?.run() | ||
}, | ||
}, | ||
} | ||
</script> | ||
<style scoped lang="scss"> | ||
.container-suggestions { | ||
display: flex; | ||
justify-content: center; | ||
align-items: flex-end; | ||
align-content: flex-end; | ||
position: sticky; | ||
} | ||
</style> |