Skip to content

Commit

Permalink
Migrate to vue 3
Browse files Browse the repository at this point in the history
Signed-off-by: Raimund Schlüßler <[email protected]>
  • Loading branch information
raimund-schluessler committed Apr 2, 2022
1 parent 944098f commit c67495e
Show file tree
Hide file tree
Showing 8 changed files with 429 additions and 327 deletions.
639 changes: 370 additions & 269 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"@nextcloud/l10n": "^1.2.3",
"@nextcloud/logger": "^2.0.0",
"@nextcloud/router": "^2.0.0",
"@vue/compat": "^3.2.31",
"debounce": "1.2.1",
"emoji-mart-vue-fast": "^10.2.1",
"escape-html": "^1.0.3",
Expand All @@ -59,7 +60,7 @@
"tributejs": "^5.1.3",
"v-click-outside": "^3.0.1",
"v-tooltip": "^2.0.3",
"vue": "^2.6.14",
"vue": "^3.2.31",
"vue-color": "^2.7.1",
"vue-material-design-icons": "^5.0.0",
"vue-multiselect": "^2.1.6",
Expand Down Expand Up @@ -107,7 +108,7 @@
"url-loader": "^4.1.0",
"vue-eslint-parser": "^8.0.1",
"vue-jest": "^3.0.5",
"vue-loader": "^15.9.1",
"vue-loader": "^17.0.0",
"vue-styleguidist": "^4.44.27",
"vue-template-compiler": "^2.6.14",
"webpack": "^5.71.0",
Expand Down
2 changes: 1 addition & 1 deletion src/components/AppNavigationItem/AppNavigationItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ Just set the `pinned` prop.
<!-- never show the icon over the collapsible if mobile -->
<div :class="{ 'icon-loading-small': loading, [icon]: icon && isIconShown }"
class="app-navigation-entry-icon">
<slot v-show="!loading && isIconShown" name="icon" />
<slot v-if="!loading && isIconShown" name="icon" />
</div>
<span v-if="!editingActive" class="app-navigation-entry__title" :title="title">
{{ title }}
Expand Down
4 changes: 2 additions & 2 deletions src/mixins/actionGlobal.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
import Vue from 'vue'
import { warn } from 'vue'

export default {
before() {
// all actions requires a valid text content
// if none, forbid the component mount and throw error
if (!this.$slots.default || this.text.trim() === '') {
Vue.util.warn(`${this.$options.name} cannot be empty and requires a meaningful text content`, this)
warn(`${this.$options.name} cannot be empty and requires a meaningful text content`, this)
this.$destroy()
this.$el.remove()
}
Expand Down
8 changes: 4 additions & 4 deletions src/mixins/isMobile/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
*/

import { IsMobileState } from '../../utils/IsMobileState'
// import { IsMobileState } from '../../utils/IsMobileState'

export default {
data() {
Expand All @@ -29,11 +29,11 @@ export default {
}
},
mounted() {
IsMobileState.$on('changed', this.onIsMobileChanged)
this.isMobile = IsMobileState.isMobile
// IsMobileState.$on('changed', this.onIsMobileChanged)
// this.isMobile = IsMobileState.isMobile
},
beforeDestroy() {
IsMobileState.$off('changed', this.onIsMobileChanged)
// IsMobileState.$off('changed', this.onIsMobileChanged)
},
methods: {
onIsMobileChanged(val) {
Expand Down
44 changes: 22 additions & 22 deletions src/mixins/richEditor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import escapeHtml from 'escape-html'
import Linkify from '../../utils/Linkify'
import stripTags from 'striptags'
import Vue from 'vue'
// import Vue from 'vue'

import MentionBubble from '../../components/RichContenteditable/MentionBubble'

Expand Down Expand Up @@ -126,27 +126,27 @@ export default {
* @return {string} the rendered html
*/
renderComponentHtml(propsData, component) {
const View = Vue.extend(component)
const Item = new View({
propsData,
})

// Prepare mountpoint
const wrapper = document.createElement('div')
const mount = document.createElement('div')
wrapper.style.display = 'none'
wrapper.appendChild(mount)
document.body.appendChild(wrapper)

// Mount and get raw html
Item.$mount(mount)
const renderedHtml = wrapper.innerHTML

// Destroy
Item.$destroy()
wrapper.remove()

return renderedHtml
// const View = Vue.extend(component)
// const Item = new View({
// propsData,
// })

// // Prepare mountpoint
// const wrapper = document.createElement('div')
// const mount = document.createElement('div')
// wrapper.style.display = 'none'
// wrapper.appendChild(mount)
// document.body.appendChild(wrapper)

// // Mount and get raw html
// Item.$mount(mount)
// const renderedHtml = wrapper.innerHTML

// // Destroy
// Item.$destroy()
// wrapper.remove()

// return renderedHtml
},
},
}
50 changes: 25 additions & 25 deletions src/utils/IsMobileState.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,29 @@
*
*/

import Vue from 'vue'
// import { createApp } from 'vue'

export const IsMobileState = new Vue({
data() {
return {
isMobile: false,
}
},
watch: {
isMobile(val) {
this.$emit('changed', val)
},
},
created() {
window.addEventListener('resize', this.handleWindowResize)
this.handleWindowResize()
},
beforeDestroy() {
window.removeEventListener('resize', this.handleWindowResize)
},
methods: {
handleWindowResize() {
this.isMobile = document.documentElement.clientWidth < 1024
},
},
})
// export const IsMobileState = createApp({
// data() {
// return {
// isMobile: false,
// }
// },
// watch: {
// isMobile(val) {
// this.$emit('changed', val)
// },
// },
// created() {
// window.addEventListener('resize', this.handleWindowResize)
// this.handleWindowResize()
// },
// beforeDestroy() {
// window.removeEventListener('resize', this.handleWindowResize)
// },
// methods: {
// handleWindowResize() {
// this.isMobile = document.documentElement.clientWidth < 1024
// },
// },
// })
4 changes: 2 additions & 2 deletions src/utils/ValidateSlot.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
import Vue from 'vue'
import { warn } from 'vue'

/**
* Validate children of a vue component
Expand All @@ -45,7 +45,7 @@ const ValidateSlot = (slots, allowed, vm) => {
// only warn when html elment or forbidden component
// sometimes text nodes are present which are hardly removeable by the developer and spam the warnings
if (isHtmlElement || isForbiddenComponent) {
Vue.util.warn(`${isHtmlElement ? node.tag : node.componentOptions.tag} is not allowed inside the ${vm.$options.name} component`, vm)
warn(`${isHtmlElement ? node.tag : node.componentOptions.tag} is not allowed inside the ${vm.$options.name} component`, vm)
}

// cleanup
Expand Down

0 comments on commit c67495e

Please sign in to comment.