|
3 | 3 | * SPDX-License-Identifier: AGPL-3.0-or-later |
4 | 4 | */ |
5 | 5 |
|
| 6 | +import { t } from '@nextcloud/l10n' |
6 | 7 | import debounce from 'debounce' |
7 | | -import { computed, markRaw, nextTick, onBeforeUnmount, ref, watch } from 'vue' |
| 8 | +import { computed, defineCustomElement, markRaw, nextTick, onBeforeUnmount, ref, watch } from 'vue' |
| 9 | +import { getLinkWithPicker } from '@nextcloud/vue/components/NcRichText' |
| 10 | +import PageIcon from '../components/Icon/PageIcon.vue' |
8 | 11 | import { useCollectivesStore } from '../stores/collectives.js' |
9 | 12 | import { usePagesStore } from '../stores/pages.js' |
10 | 13 | import { useRootStore } from '../stores/root.js' |
@@ -81,13 +84,35 @@ export function useEditor(davContent) { |
81 | 84 | return |
82 | 85 | } |
83 | 86 |
|
| 87 | + // Define PageIcon as custom web component |
| 88 | + if (!window.customElements.get('page-icon')) { |
| 89 | + const PageIconCE = defineCustomElement({ |
| 90 | + ...PageIcon, |
| 91 | + props: { |
| 92 | + ...PageIcon.props, |
| 93 | + size: { |
| 94 | + type: Number, |
| 95 | + default: 20, |
| 96 | + }, |
| 97 | + }, |
| 98 | + }, { shadowRoot: false }) |
| 99 | + customElements.define('page-icon', PageIconCE) |
| 100 | + } |
| 101 | + |
84 | 102 | editorPromise = window.OCA.Text.createEditor({ |
85 | 103 | el: editorEl.value, |
86 | 104 | fileId: page.id, |
87 | 105 | filePath: `/${pagesStore.pageFilePath(page)}`, |
88 | 106 | readOnly: false, |
89 | 107 | shareToken: rootStore.shareTokenParam || null, |
90 | 108 | autofocus: false, |
| 109 | + menubarLinkCustomAction: { |
| 110 | + label: t('collectives', 'Link to page'), |
| 111 | + icon: 'page-icon', |
| 112 | + action: () => { |
| 113 | + return getLinkWithPicker('collectives-ref-pages', false) |
| 114 | + }, |
| 115 | + }, |
91 | 116 | onCreate: ({ markdown }) => { |
92 | 117 | updateEditorContentDebounced(markdown) |
93 | 118 | }, |
|
0 commit comments