@@ -89,6 +89,7 @@ prevent the user from collapsing the items.
8989 </template>
9090</NcAppNavigationItem>
9191```
92+
9293### Editable element
9394Add the prop `:editable=true` and an edit placeholder if you need it. By default
9495the placeholder is the previous title of the element.
@@ -97,13 +98,24 @@ the placeholder is the previous title of the element.
9798<NcAppNavigationItem title="Editable Item" :editable="true"
9899 editPlaceholder="your_placeholder_here" icon="icon-folder" @update:title="function(value){alert(value)}" />
99100```
101+
100102### Undo element
101103Just set the `undo` and `title` props. When clicking the undo button, an `undo` event is emitted.
102104
103105```
104106<NcAppNavigationItem :undo="true" title="Deleted important entry" @undo="alert('undo delete')" />
105107
106108```
109+
110+ ### Link element
111+ Href that start by http will be treated as external and opened in a new tab
112+ ```
113+ <div>
114+ <NcAppNavigationItem title="Files" href="/index.php/apps/files" />
115+ <NcAppNavigationItem title="Nextcloud" href="https://nextcloud.com" />
116+ </div>
117+ ```
118+
107119### Pinned element
108120Just set the `pinned` prop.
109121```
@@ -132,8 +144,9 @@ Just set the `pinned` prop.
132144 <a v-if =" !undo"
133145 class =" app-navigation-entry-link"
134146 :aria-description =" ariaDescription"
135- href =" #"
136147 :aria-expanded =" opened.toString()"
148+ :href =" href || '#'"
149+ :target =" isExternal(href) ? '_blank' : ''"
137150 @focus =" handleFocus"
138151 @blur =" handleBlur"
139152 @keydown.tab.exact =" handleTab"
@@ -296,6 +309,15 @@ export default {
296309 default: ' ' ,
297310 },
298311
312+ /**
313+ * A direct link. This will be used as the `href` attribute.
314+ * This will ignore any `to` prop being defined.
315+ */
316+ href: {
317+ type: String ,
318+ default: null ,
319+ },
320+
299321 /**
300322 * Pass in `true` if you want the matching behaviour to
301323 * be non-inclusive: https://router.vuejs.org/api/#exact
@@ -469,7 +491,7 @@ export default {
469491
470492 // This is used to decide which outer element type to use
471493 navElement () {
472- if (this .to ) {
494+ if (this .to && ! this . href ) {
473495 return {
474496 is: ' router-link' ,
475497 tag: ' div' ,
@@ -586,6 +608,14 @@ export default {
586608 this .$refs .actions .$refs .menuButton .$el .blur ()
587609 }
588610 },
611+
612+ /**
613+ * Is this an external link
614+ */
615+ isExternal (href ) {
616+ // Match any protocol
617+ return href .match (/ [a-z ] + :\/\/ / i )
618+ },
589619 },
590620}
591621 </script >
0 commit comments