diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 08eec4e0..7e2f5c7c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,18 +3,63 @@ name: build on: [push, pull_request] jobs: - audit: + test: runs-on: ubuntu-latest strategy: matrix: - node-version: [14.x] + node-version: [14] steps: - - uses: actions/checkout@v2.3.2 + - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v2.1.1 with: node-version: ${{ matrix.node-version }} - - run: yarn install - - run: yarn run startandtest + + - uses: actions/checkout@v2.3.2 + + - name: Run tests with Cypress + uses: cypress-io/github-action@v2 + with: + cache-key: node-v${{ matrix.node }}-on-${{ runner.os }}-hash-${{ hashFiles('yarn.lock') }} + start: yarn start + wait-on: 'http://localhost:3000' + project: ./tests + browser: chrome + + - name: Export screenshots (on failure only) + uses: actions/upload-artifact@v1 + if: failure() + with: + name: cypress-screenshots + path: tests/cypress/screenshots + + - name: Export screen recordings (on failure only) + uses: actions/upload-artifact@v1 + if: failure() + with: + name: cypress-videos + path: tests/cypress/videos + + build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [14] + + steps: + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2.1.1 + with: + node-version: ${{ matrix.node-version }} + + - uses: actions/checkout@v2.3.2 + + - name: Install dependencies + run: yarn install + + - name: Build packages dependencies + run: yarn build:packages diff --git a/.gitignore b/.gitignore index 1fa3db36..fabfc461 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ yarn-error.log* .rts2_cache_umd tests/cypress/videos +/tests/cypress/screenshots diff --git a/docs/gridsome.config.js b/docs/gridsome.config.js index d91e7519..2fd650e0 100644 --- a/docs/gridsome.config.js +++ b/docs/gridsome.config.js @@ -11,7 +11,7 @@ function addStyleResource(rule) { } module.exports = { - siteName: 'tiptap', + siteName: 'tiptap 2', titleTemplate: '%s', port: 3000, plugins: [ diff --git a/docs/src/components/Demo/index.vue b/docs/src/components/Demo/index.vue index a13307ec..fc875084 100644 --- a/docs/src/components/Demo/index.vue +++ b/docs/src/components/Demo/index.vue @@ -1,24 +1,37 @@ @@ -81,6 +94,10 @@ export default { activeFile() { return this.files[this.currentIndex] }, + + githubUrl() { + return `https://github.com/ueberdosis/tiptap-next/tree/main/docs/src/demos/${this.name}` + }, }, mounted() { diff --git a/docs/src/components/Demo/style.scss b/docs/src/components/Demo/style.scss index a5ab48b4..4c8f8aba 100644 --- a/docs/src/components/Demo/style.scss +++ b/docs/src/components/Demo/style.scss @@ -10,7 +10,7 @@ border-top-left-radius: inherit; border-top-right-radius: inherit; } - + &__source { // background-color: $colorBlack; } @@ -39,13 +39,34 @@ &:hover { color: $colorWhite; background-color: rgba($colorWhite, 0.1); - } + } } - + &__code { pre { margin: 0; border-radius: 0; } } + + &__meta { + display: flex; + justify-content: space-between; + width: 100%; + padding: 1rem 1.5rem; + border: 1px solid rgba($colorBlack, 0.1); + border-top-width: 0; + border-bottom-left-radius: inherit; + border-bottom-right-radius: inherit; + } + + &__link { + text-align: right; + } + + &__error { + padding: 1rem 1.5rem; + color: $colorRed; + background-color: rgba($colorRed, 0.1); + } } \ No newline at end of file diff --git a/docs/src/demos/Basic/index.spec.js b/docs/src/demos/Examples/Basic/index.spec.js similarity index 100% rename from docs/src/demos/Basic/index.spec.js rename to docs/src/demos/Examples/Basic/index.spec.js diff --git a/docs/src/demos/Basic/index.vue b/docs/src/demos/Examples/Basic/index.vue similarity index 100% rename from docs/src/demos/Basic/index.vue rename to docs/src/demos/Examples/Basic/index.vue diff --git a/docs/src/demos/Basic/style.scss b/docs/src/demos/Examples/Basic/style.scss similarity index 100% rename from docs/src/demos/Basic/style.scss rename to docs/src/demos/Examples/Basic/style.scss diff --git a/docs/src/demos/Examples/ExportHtmlOrJson/index.spec.js b/docs/src/demos/Examples/ExportHtmlOrJson/index.spec.js new file mode 100644 index 00000000..34606b8b --- /dev/null +++ b/docs/src/demos/Examples/ExportHtmlOrJson/index.spec.js @@ -0,0 +1,64 @@ +context('export-html-or-json', () => { + beforeEach(() => { + cy.visit('/examples/export-html-or-json') + }) + + describe('export', () => { + it('should return json', () => { + cy.get('.ProseMirror').window().then(window => { + const { editor } = window + const json = editor.json() + + expect(json).to.deep.equal({ + 'type': 'document', + 'content': [ + { + 'type': 'paragraph', + 'content': [ + { + 'type': 'text', + 'text': 'You are able to export your data as ' + }, + { + 'type': 'text', + 'marks': [ + { + 'type': 'code' + } + ], + 'text': 'HTML' + }, + { + 'type': 'text', + 'text': ' or ' + }, + { + 'type': 'text', + 'marks': [ + { + 'type': 'code' + } + ], + 'text': 'JSON' + }, + { + 'type': 'text', + 'text': '.' + } + ] + } + ] + }) + }) + }) + + it('should return html', () => { + cy.get('.ProseMirror').window().then(window => { + const { editor } = window + const html = editor.html() + + expect(html).to.equal('

You are able to export your data as HTML or JSON.

') + }) + }) + }) +}) \ No newline at end of file diff --git a/docs/src/demos/Examples/ExportHtmlOrJson/index.vue b/docs/src/demos/Examples/ExportHtmlOrJson/index.vue new file mode 100644 index 00000000..c652f57a --- /dev/null +++ b/docs/src/demos/Examples/ExportHtmlOrJson/index.vue @@ -0,0 +1,93 @@ + + + + +