From 641ec0485350a7d64ca513339f7c1149948bb9d4 Mon Sep 17 00:00:00 2001 From: Georgy K <36447502+Lykoi18@users.noreply.github.com> Date: Tue, 25 Apr 2023 15:38:20 +0400 Subject: [PATCH] Fix publish action (#93) --- .github/workflows/publish.yml | 12 +- modules/keyboard.js | 5 +- test/unit/modules/keyboard.js | 244 ++++++++++++++++++++++++++++++++++ 3 files changed, 248 insertions(+), 13 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 63bf242742..0b582f92f7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -20,9 +20,6 @@ jobs: - name: Build uses: ./.github/actions/quill/steps/build - - name: Get artifact - uses: ./.github/actions/quill/common/get-artifact - - uses: actions/setup-node@v3 with: node-version: '18' @@ -33,14 +30,6 @@ jobs: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} run: npm publish --access=public - - name: Setup NPM tags for 1.5.x - if: startsWith(inputs.version, '1.5') - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - run: | - npm dist-tag add devextreme-quill@${{ inputs.version }} 22_1 - npm dist-tag add devextreme-quill@${{ inputs.version }} 22_2 - - name: Setup NPM tags for 1.6.x if: startsWith(inputs.version, '1.6') env: @@ -48,3 +37,4 @@ jobs: run: | npm dist-tag add devextreme-quill@${{ inputs.version }} 22_1 npm dist-tag add devextreme-quill@${{ inputs.version }} 22_2 + npm dist-tag add devextreme-quill@${{ inputs.version }} 23_1 diff --git a/modules/keyboard.js b/modules/keyboard.js index 0bbba9404c..f13ca0de60 100644 --- a/modules/keyboard.js +++ b/modules/keyboard.js @@ -460,8 +460,9 @@ Keyboard.DEFAULTS = { }, tab: { key: 'tab', - handler(range, context) { - if (context.format.table) return true; + handler(range, { format }) { + if (format.tableCellLine || format.tableHeaderCellLine || + format.tableHeaderCell || format.table) return true; this.quill.history.cutoff(); const delta = new Delta() .retain(range.index) diff --git a/test/unit/modules/keyboard.js b/test/unit/modules/keyboard.js index aa56494a71..61afbc82e6 100644 --- a/test/unit/modules/keyboard.js +++ b/test/unit/modules/keyboard.js @@ -1,4 +1,7 @@ import Keyboard, { SHORTKEY, normalize } from '../../../modules/keyboard'; +import { Range } from '../../../core/selection'; +import Quill from '../../../core/quill'; +import TableLite from '../../../modules/table/lite'; describe('Keyboard', function () { describe('match', function () { @@ -257,4 +260,245 @@ describe('Keyboard', function () { quillMock.root.addEventListener = nativeAddEventListener; }); }); + + describe('tab navigation on main table', function () { + const markup = ` + + + + + + + + + + + + + + + + + + + + +

head1

head2

head3

data1

data2

data3

data1

data2

data3

+ `; + + it('should select next cell on tab click', function () { + const quill = this.initialize(Quill, markup, this.container, { + modules: { + table: true, + }, + }); + quill.setSelection(18); + const keydownEvent = new KeyboardEvent('keydown', { + key: 'tab', + }); + + quill.root.dispatchEvent(keydownEvent); + expect(quill.getSelection()).toEqual(new Range(24)); + }); + + it('should select next cell in second row if cursor in the last cell of first row on tab click', function () { + const quill = this.initialize(Quill, markup, this.container, { + modules: { + table: true, + }, + }); + quill.setSelection(30); + const keydownEvent = new KeyboardEvent('keydown', { + key: 'tab', + }); + + quill.root.dispatchEvent(keydownEvent); + expect(quill.getSelection()).toEqual(new Range(36)); + }); + + it('should select previous cell on tab + shift click', function () { + const quill = this.initialize(Quill, markup, this.container, { + modules: { + table: true, + }, + }); + quill.setSelection(31); + const keydownEvent = new KeyboardEvent('keydown', { + key: 'tab', + shiftKey: true, + }); + + quill.root.dispatchEvent(keydownEvent); + expect(quill.getSelection()).toEqual(new Range(29)); + }); + + it('should select previous cell on first row if cursor in the first cell of second row on tab + shift click', function () { + const quill = this.initialize(Quill, markup, this.container, { + modules: { + table: true, + }, + }); + quill.setSelection(38); + const keydownEvent = new KeyboardEvent('keydown', { + key: 'tab', + shiftKey: true, + }); + + quill.root.dispatchEvent(keydownEvent); + expect(quill.getSelection()).toEqual(new Range(35)); + }); + + it('should select next cell in header on tab click', function () { + const quill = this.initialize(Quill, markup, this.container, { + modules: { + table: true, + }, + }); + quill.setSelection(0); + const keydownEvent = new KeyboardEvent('keydown', { + key: 'tab', + }); + + quill.root.dispatchEvent(keydownEvent); + expect(quill.getSelection()).toEqual(new Range(6)); + }); + + it('should select previous cell in header on tab + shift click', function () { + const quill = this.initialize(Quill, markup, this.container, { + modules: { + table: true, + }, + }); + quill.setSelection(8); + const keydownEvent = new KeyboardEvent('keydown', { + key: 'tab', + shiftKey: true, + }); + + quill.root.dispatchEvent(keydownEvent); + expect(quill.getSelection()).toEqual(new Range(5)); + }); + }); + + describe('tab navigation on lite table', function () { + beforeAll(function () { + Quill.register({ 'modules/table': TableLite }, true); + }); + const markup = ` + + + + + + + + + + + + + + + + + + + + +

head1

head2

head3

data1

data2

data3

data1

data2

data3

+ `; + + it('should select next cell on tab click', function () { + const quill = this.initialize(Quill, markup, this.container, { + modules: { + table: true, + }, + }); + quill.setSelection(18); + const keydownEvent = new KeyboardEvent('keydown', { + key: 'tab', + }); + + quill.root.dispatchEvent(keydownEvent); + expect(quill.getSelection()).toEqual(new Range(24)); + }); + + it('should select next cell in second row if cursor in the last cell of first row on tab click', function () { + const quill = this.initialize(Quill, markup, this.container, { + modules: { + table: true, + }, + }); + quill.setSelection(30); + const keydownEvent = new KeyboardEvent('keydown', { + key: 'tab', + }); + + quill.root.dispatchEvent(keydownEvent); + expect(quill.getSelection()).toEqual(new Range(36)); + }); + + it('should select previous cell on tab + shift click', function () { + const quill = this.initialize(Quill, markup, this.container, { + modules: { + table: true, + }, + }); + quill.setSelection(31); + const keydownEvent = new KeyboardEvent('keydown', { + key: 'tab', + shiftKey: true, + }); + + quill.root.dispatchEvent(keydownEvent); + expect(quill.getSelection()).toEqual(new Range(29)); + }); + + it('should select previous cell on first row if cursor in the first cell of second row on tab + shift click', function () { + const quill = this.initialize(Quill, markup, this.container, { + modules: { + table: true, + }, + }); + quill.setSelection(38); + const keydownEvent = new KeyboardEvent('keydown', { + key: 'tab', + shiftKey: true, + }); + + quill.root.dispatchEvent(keydownEvent); + expect(quill.getSelection()).toEqual(new Range(35)); + }); + + it('should select next cell in header on tab click', function () { + const quill = this.initialize(Quill, markup, this.container, { + modules: { + table: true, + }, + }); + quill.setSelection(0); + const keydownEvent = new KeyboardEvent('keydown', { + key: 'tab', + }); + + quill.root.dispatchEvent(keydownEvent); + expect(quill.getSelection()).toEqual(new Range(6)); + }); + + it('should select previous cell in header on tab + shift click', function () { + const quill = this.initialize(Quill, markup, this.container, { + modules: { + table: true, + }, + }); + quill.setSelection(8); + const keydownEvent = new KeyboardEvent('keydown', { + key: 'tab', + shiftKey: true, + }); + + quill.root.dispatchEvent(keydownEvent); + expect(quill.getSelection()).toEqual(new Range(5)); + }); + }); });