From 487b8f8caf4c0e2eecf935c3cfbc0371ee7dff6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Raimund=20Schl=C3=BC=C3=9Fler?= Date: Sat, 2 Apr 2022 17:44:26 +0200 Subject: [PATCH] Migrate to vue 3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Raimund Schlüßler --- .eslintrc.js | 18 -- cypress/component/modal.cy.ts | 11 +- cypress/component/richtext.cy.ts | 82 +++---- .../NcActionInput/NcActionInput.vue | 20 +- .../NcActionRouter/NcActionRouter.vue | 10 +- src/components/NcActions/NcActions.vue | 229 ++++++++---------- src/components/NcAppContent/NcAppContent.vue | 2 +- .../NcAppContent/NcAppDetailsToggle.vue | 2 +- .../NcAppNavigation/NcAppNavigation.vue | 9 +- .../NcAppNavigationCaption.vue | 5 +- .../NcAppNavigationItem.vue | 12 +- .../NcAppNavigationSettings.vue | 6 +- .../NcAppSettingsDialog.vue | 13 +- src/components/NcAppSidebar/NcAppSidebar.vue | 57 +++-- .../NcAppSidebar/NcAppSidebarTabs.vue | 6 +- .../NcAppSidebarTab/NcAppSidebarTab.vue | 6 +- src/components/NcAvatar/NcAvatar.vue | 2 +- src/components/NcBreadcrumb/NcBreadcrumb.vue | 19 +- .../NcBreadcrumbs/NcBreadcrumbs.vue | 179 ++++++-------- src/components/NcContent/NcContent.vue | 35 ++- src/components/NcHeaderMenu/NcHeaderMenu.vue | 2 +- src/components/NcListItem/NcListItem.vue | 13 +- src/components/NcModal/NcModal.vue | 44 ++-- .../NcRichContenteditable.vue | 10 +- .../NcCustomPickerElement.vue | 2 +- .../NcReferencePicker/NcRawLinkInput.vue | 4 +- .../NcRichText/NcReferencePicker/NcSearch.vue | 2 +- .../NcReferencePicker/referencePickerModal.js | 14 +- .../NcRichText/NcReferenceWidget.vue | 2 +- src/components/NcRichText/NcRichText.vue | 35 +-- src/components/NcRichText/autolink.js | 13 +- src/components/NcRichText/placeholder.js | 2 +- src/components/NcUserBubble/NcUserBubble.vue | 5 +- src/components/NcVNodes/NcVNodes.vue | 5 +- src/components/index.js | 82 +++---- src/index.js | 5 +- src/mixins/actionGlobal.js | 8 +- src/mixins/isFullscreen/index.js | 28 +-- src/mixins/isMobile/index.js | 25 +- src/mixins/richEditor/index.js | 11 +- src/utils/IsMobileState.js | 49 ---- src/utils/ValidateChildren.js | 4 +- src/utils/ValidateSlot.js | 4 +- styleguide.config.js | 131 +++++----- .../components/NcActions/NcActions.spec.js | 26 +- .../NcAppSidebar/NcAppSidebarTabs.spec.js | 71 +++--- .../NcRichContenteditable.spec.js | 46 ++-- .../components/NcRichText/NcRichText.spec.js | 38 +-- tests/unit/mixins/richEditor.spec.js | 17 +- vite.config.mts | 53 ++-- 50 files changed, 639 insertions(+), 835 deletions(-) delete mode 100644 src/utils/IsMobileState.js diff --git a/.eslintrc.js b/.eslintrc.js index 6b51eae605..f155eea6c4 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -14,24 +14,6 @@ module.exports = { plugins: [ 'cypress', ], - ignorePatterns: [ - 'src/components/NcAction*/*.vue', - 'src/components/NcAppContent*/*.vue', - 'src/components/NcAppNavigation*/*.vue', - 'src/components/NcAppSettings*/*.vue', - 'src/components/NcAppSidebar*/*.vue', - 'src/components/NcBreadcrumb*/*.vue', - 'src/components/NcContent/*.vue', - 'src/components/NcDashboard*/*.vue', - 'src/components/NcAvatar*/*.vue', - 'src/components/NcHeaderMenu*/*.vue', - 'src/components/NcModal*/*.vue', - 'src/components/NcRelatedResourcesPanel*/*.vue', - 'src/components/NcRich*/**/*.vue', - 'src/components/NcUserBubble*/*.vue', - 'src/components/NcVNodes*/*.vue', - 'src/utils/IsMobileState.js', - ], parserOptions: { babelOptions: { plugins: [ diff --git a/cypress/component/modal.cy.ts b/cypress/component/modal.cy.ts index 98e421f302..01ee456ebd 100644 --- a/cypress/component/modal.cy.ts +++ b/cypress/component/modal.cy.ts @@ -1,11 +1,12 @@ -import { mount } from 'cypress/vue2' +import { mount } from 'cypress/vue' import NcModal from '../../src/components/NcModal/NcModal.vue' import type { Component } from 'vue' +import { h } from 'vue' describe('NcModal', () => { it('close button is visible when content is scrolled', () => { mount(NcModal, { - propsData: { + props: { show: true, size: 'small', name: 'Name', @@ -13,10 +14,10 @@ describe('NcModal', () => { slots: { // Create two div as children, first is 100vh = overflows the content, second just gets some data attribute so we can scroll into view default: { - render: (h) => + render: () => h('div', [ - h('div', { style: 'height: 100vh;' }), - h('div', { attrs: { 'data-cy': 'bottom' } }), + h('div', { style: { height: '100vh' } }), + h('div', { 'data-cy': 'bottom' }), ]), } as Component, }, diff --git a/cypress/component/richtext.cy.ts b/cypress/component/richtext.cy.ts index 28ae7e6f77..9a156b91bb 100644 --- a/cypress/component/richtext.cy.ts +++ b/cypress/component/richtext.cy.ts @@ -1,7 +1,7 @@ // Markdown guide: https://www.markdownguide.org/basic-syntax/ // Reference tests: https://github.com/nextcloud-deps/CDMarkdownKit/tree/master/CDMarkdownKitTests -import { mount } from 'cypress/vue2' +import { mount } from 'cypress/vue' import NcRichText from '../../src/components/NcRichText/NcRichText.vue' describe('NcRichText', () => { @@ -9,7 +9,7 @@ describe('NcRichText', () => { describe('normal text', () => { it('XML-like text (escaped and unescaped)', () => { mount(NcRichText, { - propsData: { + props: { text: 'text</span>', useMarkdown: true, }, @@ -31,7 +31,7 @@ describe('NcRichText', () => { ] mount(NcRichText, { - propsData: { + props: { text: testCases.map(i => i.input).join('\n'), useMarkdown: true, }, @@ -44,7 +44,7 @@ describe('NcRichText', () => { it('ignored heading (with hash (#) syntax padded to the text)', () => { mount(NcRichText, { - propsData: { + props: { text: '#heading', useMarkdown: true, }, @@ -55,7 +55,7 @@ describe('NcRichText', () => { it('heading 1 (with equal (=) syntax on the next line)', () => { mount(NcRichText, { - propsData: { + props: { text: 'heading 1\n==', useMarkdown: true, }, @@ -66,7 +66,7 @@ describe('NcRichText', () => { it('heading 2 (with dash (-) syntax on the next line)', () => { mount(NcRichText, { - propsData: { + props: { text: 'heading 2\n--', useMarkdown: true, }, @@ -79,7 +79,7 @@ describe('NcRichText', () => { describe('bold text', () => { it('bold text (single with asterisk syntax)', () => { mount(NcRichText, { - propsData: { + props: { text: '**bold asterisk**', useMarkdown: true, }, @@ -90,7 +90,7 @@ describe('NcRichText', () => { it('bold text (single with underscore syntax)', () => { mount(NcRichText, { - propsData: { + props: { text: '__bold underscore__', useMarkdown: true, }, @@ -102,7 +102,7 @@ describe('NcRichText', () => { it('bold text (several in line with different syntax)', () => { const outputs = ['bold underscore', 'bold asterisk'] mount(NcRichText, { - propsData: { + props: { text: 'normal text __bold underscore__ normal text **bold asterisk** normal text', useMarkdown: true, }, @@ -116,7 +116,7 @@ describe('NcRichText', () => { it('bold text (between normal texts with asterisk syntax)', () => { mount(NcRichText, { - propsData: { + props: { text: 'text**bold**text', useMarkdown: true, }, @@ -127,7 +127,7 @@ describe('NcRichText', () => { it('ignored bold text (between normal texts with underscore syntax)', () => { mount(NcRichText, { - propsData: { + props: { text: 'text__bold__text', useMarkdown: true, }, @@ -139,7 +139,7 @@ describe('NcRichText', () => { it('normal text (between bold texts with asterisk syntax)', () => { const outputs = ['bold asterisk', 'bold asterisk'] mount(NcRichText, { - propsData: { + props: { text: '**bold asterisk**normal text**bold asterisk**', useMarkdown: true, }, @@ -155,7 +155,7 @@ describe('NcRichText', () => { describe('italic text', () => { it('italic text (single with asterisk syntax)', () => { mount(NcRichText, { - propsData: { + props: { text: '*italic asterisk*', useMarkdown: true, }, @@ -166,7 +166,7 @@ describe('NcRichText', () => { it('italic text (single with underscore syntax)', () => { mount(NcRichText, { - propsData: { + props: { text: '_italic underscore_', useMarkdown: true, }, @@ -178,7 +178,7 @@ describe('NcRichText', () => { it('italic text (several in line with different syntax)', () => { const outputs = ['italic underscore', 'italic asterisk'] mount(NcRichText, { - propsData: { + props: { text: 'normal text _italic underscore_ normal text *italic asterisk* normal text', useMarkdown: true, }, @@ -192,7 +192,7 @@ describe('NcRichText', () => { it('italic text (between normal texts with asterisk syntax)', () => { mount(NcRichText, { - propsData: { + props: { text: 'text*italic*text', useMarkdown: true, }, @@ -203,7 +203,7 @@ describe('NcRichText', () => { it('ignored italic text (between normal texts with underscore syntax)', () => { mount(NcRichText, { - propsData: { + props: { text: 'text_italic_text', useMarkdown: true, }, @@ -215,7 +215,7 @@ describe('NcRichText', () => { it('normal text (between italic texts with asterisk syntax)', () => { const outputs = ['italic asterisk', 'italic asterisk'] mount(NcRichText, { - propsData: { + props: { text: '*italic asterisk*normal text*italic asterisk*', useMarkdown: true, }, @@ -231,7 +231,7 @@ describe('NcRichText', () => { describe('inline code', () => { it('inline code (single with backticks syntax)', () => { mount(NcRichText, { - propsData: { + props: { text: 'normal text `inline code` normal text', useMarkdown: true, }, @@ -242,7 +242,7 @@ describe('NcRichText', () => { it('inline code (single with double backticks syntax)', () => { mount(NcRichText, { - propsData: { + props: { text: 'normal text ``inline code`` normal text', useMarkdown: true, }, @@ -253,7 +253,7 @@ describe('NcRichText', () => { it('inline code (single with triple backticks syntax)', () => { mount(NcRichText, { - propsData: { + props: { text: 'normal text ```inline code``` normal text', useMarkdown: true, }, @@ -265,7 +265,7 @@ describe('NcRichText', () => { it('inline code (several in line )', () => { const outputs = ['inline code 1', 'inline code 2'] mount(NcRichText, { - propsData: { + props: { text: 'normal text `inline code 1`normal text ``inline code 2`` normal text', useMarkdown: true, }, @@ -279,7 +279,7 @@ describe('NcRichText', () => { it('inline code (between normal texts)', () => { mount(NcRichText, { - propsData: { + props: { text: 'text`inline code`text', useMarkdown: true, }, @@ -290,7 +290,7 @@ describe('NcRichText', () => { it('inline code (with ignored bold, italic, XML-like syntax))', () => { mount(NcRichText, { - propsData: { + props: { text: '`inline code **bold text** _italic text_ text</span>`', useMarkdown: true, }, @@ -303,7 +303,7 @@ describe('NcRichText', () => { describe('multiline code', () => { it('multiline code (with triple backticks syntax)', () => { mount(NcRichText, { - propsData: { + props: { text: '```\nmultiline code\n```', useMarkdown: true, }, @@ -314,7 +314,7 @@ describe('NcRichText', () => { it('multiline code (ignored info)', () => { mount(NcRichText, { - propsData: { + props: { text: '```vue\nmultiline code\n```', useMarkdown: true, }, @@ -325,7 +325,7 @@ describe('NcRichText', () => { it('empty multiline code', () => { mount(NcRichText, { - propsData: { + props: { text: '``````', useMarkdown: true, }, @@ -336,7 +336,7 @@ describe('NcRichText', () => { it('empty multiline code (with new line)', () => { mount(NcRichText, { - propsData: { + props: { text: '```\n```', useMarkdown: true, }, @@ -347,7 +347,7 @@ describe('NcRichText', () => { it('multiline code (with several lines)', () => { mount(NcRichText, { - propsData: { + props: { text: '```\nline 1\nline 2\nline 3\n```', useMarkdown: true, }, @@ -359,7 +359,7 @@ describe('NcRichText', () => { it('multiline code (with ignored bold, italic, inline code, XML-like syntax)', () => { mount(NcRichText, { - propsData: { + props: { text: '```\n**bold text**\n_italic text_\n`inline code`\ntext</span>\n```', useMarkdown: true, }, @@ -372,7 +372,7 @@ describe('NcRichText', () => { describe('blockquote', () => { it('blockquote (with greater then (>) syntax - normal)', () => { mount(NcRichText, { - propsData: { + props: { text: '> blockquote', useMarkdown: true, }, @@ -383,7 +383,7 @@ describe('NcRichText', () => { it('blockquote (with greater then (>) syntax - escaped)', () => { mount(NcRichText, { - propsData: { + props: { text: '> blockquote', useMarkdown: true, }, @@ -394,7 +394,7 @@ describe('NcRichText', () => { it('blockquote (with bold, italic text, inline code)', () => { mount(NcRichText, { - propsData: { + props: { text: '> blockquote **bold text** _italic text_ `inline code`', useMarkdown: true, }, @@ -408,7 +408,7 @@ describe('NcRichText', () => { it('blockquote (with several lines)', () => { mount(NcRichText, { - propsData: { + props: { text: '> line 1\nline 2\n line 3', useMarkdown: true, }, @@ -419,7 +419,7 @@ describe('NcRichText', () => { it('blockquote (divided from normal text)', () => { mount(NcRichText, { - propsData: { + props: { text: 'normal text\n> line 1\nline 2\n\nnormal text', useMarkdown: true, }, @@ -430,7 +430,7 @@ describe('NcRichText', () => { it('blockquote (with several paragraphs)', () => { mount(NcRichText, { - propsData: { + props: { text: '> line 1\n>\n> line 3', useMarkdown: true, }, @@ -441,7 +441,7 @@ describe('NcRichText', () => { it('blockquote (with nested blockquote)', () => { mount(NcRichText, { - propsData: { + props: { text: '> blockquote\n>\n>> nested blockquote', useMarkdown: true, }, @@ -460,7 +460,7 @@ describe('NcRichText', () => { ] mount(NcRichText, { - propsData: { + props: { text: testCases.map(i => i.input).join('\n'), useMarkdown: true, }, @@ -481,7 +481,7 @@ describe('NcRichText', () => { ] mount(NcRichText, { - propsData: { + props: { text: testCases.map(i => i.input).join('\n'), useMarkdown: true, }, @@ -502,7 +502,7 @@ describe('NcRichText', () => { ] mount(NcRichText, { - propsData: { + props: { text: testCases.map(i => i.input).join('\n'), useMarkdown: true, }, @@ -518,7 +518,7 @@ describe('NcRichText', () => { describe('dividers', () => { it('dividers (with different syntax)', () => { mount(NcRichText, { - propsData: { + props: { text: '***\n---\n___', useMarkdown: true, }, diff --git a/src/components/NcActionInput/NcActionInput.vue b/src/components/NcActionInput/NcActionInput.vue index fa2033343c..ccac48f69c 100644 --- a/src/components/NcActionInput/NcActionInput.vue +++ b/src/components/NcActionInput/NcActionInput.vue @@ -32,41 +32,41 @@ For the `NcSelect` component, all events will be passed through. Please see the ```vue