Skip to content

Commit f84f35f

Browse files
committed
fix(editor): add "link to page" as first link action in Text menubar
Fixes: #2332 Requires nextcloud/text#8368 Signed-off-by: Jonas <jonas@freesources.org>
1 parent bd93656 commit f84f35f

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

src/composables/useEditor.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

6+
import { t } from '@nextcloud/l10n'
67
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'
811
import { useCollectivesStore } from '../stores/collectives.js'
912
import { usePagesStore } from '../stores/pages.js'
1013
import { useRootStore } from '../stores/root.js'
@@ -81,13 +84,35 @@ export function useEditor(davContent) {
8184
return
8285
}
8386

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+
84102
editorPromise = window.OCA.Text.createEditor({
85103
el: editorEl.value,
86104
fileId: page.id,
87105
filePath: `/${pagesStore.pageFilePath(page)}`,
88106
readOnly: false,
89107
shareToken: rootStore.shareTokenParam || null,
90108
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+
},
91116
onCreate: ({ markdown }) => {
92117
updateEditorContentDebounced(markdown)
93118
},

0 commit comments

Comments
 (0)