Skip to content
Closed
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
45 changes: 45 additions & 0 deletions src/components/Menu/ActionFormattingHelp.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!--
- @copyright Copyright (c) 2022 Vinicius Reis <[email protected]>
-
- @author Vinicius Reis <[email protected]>
-
- @license GNU AGPL version 3 or any later version
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-->
<template>
<NcActionButton close-after-click
data-text-action-entry="formatting-help"
v-on="$listeners">
<template #icon>
<Help />
</template>
{{ t('text', 'Formatting help') }}
</NcActionButton>
</template>

<script>
import { defineComponent } from 'vue'
import { NcActionButton } from '@nextcloud/vue'
import { Help } from '../icons.js'

export default defineComponent({
name: 'ActionFormattingHelp',
components: {
NcActionButton,
Help,
},
})
</script>
15 changes: 13 additions & 2 deletions src/components/Menu/ActionList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
:aria-label="actionEntry.label"
:title="actionEntry.label"
:data-text-action-entry="actionEntry.key"
:data-text-action-active="activeKey">
:data-text-action-active="activeKey"
@update:open="onOpenChange">
<template #icon>
<component :is="icon" :key="iconKey" />
</template>
Expand All @@ -39,6 +40,7 @@
:action-entry="child"
v-on="$listeners"
@trigged="onTrigger" />
<slot v-bind="{ visible }" name="lastAction" />
</NcActions>
</template>

Expand All @@ -53,9 +55,15 @@ import { useMenuIDMixin } from './MenuBar.provider.js'

export default {
name: 'ActionList',
components: { NcActions, ActionSingle },
components: {
NcActions,
ActionSingle,
},
extends: BaseActionEntry,
mixins: [useStore, useOutlineStateMixin, useMenuIDMixin],
data: () => ({
visible: false,
}),
computed: {
currentChild() {
const {
Expand Down Expand Up @@ -98,6 +106,9 @@ export default {
},
},
methods: {
onOpenChange(val) {
this.visible = val
},
runAction() {
// nothing todo
},
Expand Down
52 changes: 52 additions & 0 deletions src/components/Menu/CharacterCount.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<template>
<NcActionText data-text-action-entry="character-count">
<template #icon>
<AlphabeticalVariant />
</template>
<template #default>
{{ countString }}
</template>
</NcActionText>
</template>

<script>
import { defineComponent } from 'vue'
import { translatePlural as n } from '@nextcloud/l10n'
import { NcActionText } from '@nextcloud/vue'
import { AlphabeticalVariant } from '../icons.js'
import { useEditorMixin } from '../Editor.provider.js'

export default defineComponent({
name: 'CharacterCount',
components: {
AlphabeticalVariant,
NcActionText,
},
mixins: [useEditorMixin],
props: {
visible: Boolean,
},
data: () => ({
wordCount: 0,
charCount: 0,
}),
computed: {
countString() {
return `${n('text', '%n word', '%n words', this.wordCount)}, ${n('text', '%n char', '%n chars', this.charCount)}`
},
},
watch: {
visible: 'refresh',
},
created() {
this.refresh()
},
methods: {
refresh() {
// characterCount is not reactive so we need this workaround
this.wordCount = this.$editor.storage.characterCount.words()
this.charCount = this.$editor.storage.characterCount.characters()
},
},
})
</script>
24 changes: 21 additions & 3 deletions src/components/Menu/MenuBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,15 @@
:aria-label="t('text', 'Editor actions')">
<ActionEntry v-for="actionEntry of visibleEntries"
v-bind="{ actionEntry }"
:key="`text-action--${actionEntry.key}`"
@call:help="showHelp" />
:key="`text-action--${actionEntry.key}`" />
<ActionList key="text-action--remain"
:action-entry="hiddenEntries">
<template #lastAction="{ visible }">
<ActionFormattingHelp @click="showHelp" />
<NcActionSeparator />
<CharacterCount v-bind="{ visible }" />
</template>
</ActionList>
</div>
<div class="text-menubar__slot">
<slot />
Expand All @@ -52,23 +59,34 @@
</template>

<script>
import { NcActionSeparator } from '@nextcloud/vue'
import { subscribe, unsubscribe } from '@nextcloud/event-bus'
import debounce from 'debounce'

import HelpModal from '../HelpModal.vue'
import actionsFullEntries from './entries.js'
import ActionEntry from './ActionEntry.js'
import ActionList from './ActionList.vue'
import { MENU_ID } from './MenuBar.provider.js'
import { DotsHorizontal } from '../icons.js'
import {
useEditorMixin,
useIsRichEditorMixin,
useIsRichWorkspaceMixin,
} from '../Editor.provider.js'
import ActionFormattingHelp from './ActionFormattingHelp.vue'
import CharacterCount from './CharacterCount.vue'

export default {
name: 'MenuBar',
components: { ActionEntry, HelpModal },
components: {
ActionList,
ActionEntry,
ActionFormattingHelp,
HelpModal,
NcActionSeparator,
CharacterCount,
},
mixins: [
useEditorMixin,
useIsRichEditorMixin,
Expand Down
2 changes: 2 additions & 0 deletions src/components/icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*
*/

import MDI_AlphabeticalVariant from 'vue-material-design-icons/AlphabeticalVariant.vue'
import MDI_Close from 'vue-material-design-icons/Close.vue'
import MDI_Check from 'vue-material-design-icons/Check.vue'
import MDI_CodeTags from 'vue-material-design-icons/CodeTags.vue'
Expand Down Expand Up @@ -89,6 +90,7 @@ export const Loading = {
},
}

export const AlphabeticalVariant = makeIcon(MDI_AlphabeticalVariant)
export const Close = makeIcon(MDI_Close)
export const Check = makeIcon(MDI_Check)
export const CodeTags = makeIcon(MDI_CodeTags)
Expand Down