Skip to content

Commit

Permalink
fix(files): create suggestions bar
Browse files Browse the repository at this point in the history
Signed-off-by: julia.kirschenheuter <julia.kirschenheuter@nextcloud.com>
  • Loading branch information
JuliaKirschenheuter committed Jan 15, 2025
1 parent b83be2f commit a1dc138
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/components/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
</template>
<ContentContainer v-show="contentLoaded"
ref="contentWrapper" />
<SuggestionsBar />
</MainContainer>
<Reader v-if="isResolvingConflict"
:content="syncError.data.outsideChange"
Expand Down Expand Up @@ -126,6 +127,7 @@ import Assistant from './Assistant.vue'
import Translate from './Modal/Translate.vue'
import { generateRemoteUrl } from '@nextcloud/router'
import { fetchNode } from '../services/WebdavClient.ts'
import SuggestionsBar from './SuggestionsBar.vue'

Check warning on line 130 in src/components/Editor.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Editor.vue#L130

Added line #L130 was not covered by tests

export default {
name: 'Editor',
Expand All @@ -141,6 +143,7 @@ export default {
Status,
Assistant,
Translate,
SuggestionsBar,

Check warning on line 146 in src/components/Editor.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Editor.vue#L146

Added line #L146 was not covered by tests
},
mixins: [
isMobile,
Expand Down
95 changes: 95 additions & 0 deletions src/components/SuggestionsBar.vue
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'

Check warning on line 47 in src/components/SuggestionsBar.vue

View check run for this annotation

Codecov / codecov/patch

src/components/SuggestionsBar.vue#L43-L47

Added lines #L43 - L47 were not covered by tests
export default {
name: 'SuggestionsBar',
components: {
Table,

Check failure on line 52 in src/components/SuggestionsBar.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Name "Table" is reserved in HTML
Document,
NcButton,
Shape,
},
mixins: [
useActionChooseLocalAttachmentMixin,
useEditorMixin,
],

Check warning on line 60 in src/components/SuggestionsBar.vue

View check run for this annotation

Codecov / codecov/patch

src/components/SuggestionsBar.vue#L49-L60

Added lines #L49 - L60 were not covered by tests
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()
},
},

Check warning on line 80 in src/components/SuggestionsBar.vue

View check run for this annotation

Codecov / codecov/patch

src/components/SuggestionsBar.vue#L62-L80

Added lines #L62 - L80 were not covered by tests
}

Check warning on line 82 in src/components/SuggestionsBar.vue

View check run for this annotation

Codecov / codecov/patch

src/components/SuggestionsBar.vue#L82

Added line #L82 was not covered by tests
</script>
<style scoped lang="scss">
.container-suggestions {
display: flex;
justify-content: center;
align-items: flex-end;
align-content: flex-end;
position: sticky;
}
</style>

0 comments on commit a1dc138

Please sign in to comment.