quill-table-up 2.3.0 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "quill-table-up",
3
3
  "type": "module",
4
- "version": "2.3.0",
5
- "packageManager": "pnpm@9.9.0",
4
+ "version": "2.3.1",
5
+ "packageManager": "pnpm@10.12.1",
6
6
  "description": "A table module for quill2.x",
7
7
  "author": "zzxming",
8
8
  "license": "MIT",
@@ -32,9 +32,9 @@
32
32
  "scripts": {
33
33
  "lint": "eslint . --cache",
34
34
  "lint:fix": "eslint . --fix",
35
- "build": "gulp --require @esbuild-kit/cjs-loader",
36
- "dev": "gulp --require @esbuild-kit/cjs-loader dev",
37
- "server": "node ./server.js",
35
+ "build": "tsx ./scripts/build.ts",
36
+ "dev": "tsx ./scripts/build.ts watch",
37
+ "server": "tsx ./scripts/start-server.ts",
38
38
  "test:unit": "vitest",
39
39
  "test:unit-ui": "vitest --ui",
40
40
  "test:e2e": "playwright test",
@@ -44,25 +44,24 @@
44
44
  "quill": "^2.0.3"
45
45
  },
46
46
  "dependencies": {
47
- "@floating-ui/dom": "^1.6.13"
47
+ "@floating-ui/dom": "^1.7.1"
48
48
  },
49
49
  "devDependencies": {
50
- "@babel/preset-env": "^7.27.1",
51
- "@esbuild-kit/cjs-loader": "^2.4.4",
52
- "@playwright/test": "^1.52.0",
50
+ "@babel/preset-env": "^7.27.2",
51
+ "@oxc-project/runtime": "^0.73.0",
52
+ "@playwright/test": "^1.53.0",
53
53
  "@rollup/plugin-babel": "^6.0.4",
54
- "@rollup/plugin-node-resolve": "^16.0.1",
55
- "@rollup/plugin-terser": "^0.4.4",
56
- "@rollup/plugin-typescript": "^11.1.6",
57
- "@types/node": "^20.17.23",
58
- "@typescript-eslint/eslint-plugin": "^8.31.1",
59
- "@typescript-eslint/parser": "^8.31.1",
60
- "@vitest/coverage-v8": "^3.1.2",
61
- "@vitest/ui": "^3.1.2",
54
+ "@rollup/plugin-typescript": "^12.1.2",
55
+ "@types/gulp": "^4.0.17",
56
+ "@types/node": "^24.0.1",
57
+ "@typescript-eslint/eslint-plugin": "^8.34.0",
58
+ "@typescript-eslint/parser": "^8.34.0",
59
+ "@vitest/coverage-v8": "^3.2.3",
60
+ "@vitest/ui": "^3.2.3",
62
61
  "@zzxming/eslint-config": "0.4.5",
63
62
  "autoprefixer": "^10.4.21",
64
- "eslint": "^9.25.0",
65
- "gulp": "^4.0.2",
63
+ "eslint": "^9.29.0",
64
+ "gulp": "^5.0.1",
66
65
  "gulp-clean-css": "^4.3.0",
67
66
  "gulp-less": "^5.0.0",
68
67
  "gulp-postcss": "^10.0.0",
@@ -70,11 +69,11 @@
70
69
  "parchment": "^3.0.0",
71
70
  "postcss-pxtorem": "^6.1.0",
72
71
  "resize-observer-polyfill": "^1.5.1",
73
- "rollup": "^4.40.1",
74
- "rollup-plugin-dts": "^6.2.1",
75
- "rollup-plugin-svg-import": "^3.0.0",
72
+ "tsdown": "^0.12.7",
76
73
  "tslib": "^2.8.1",
74
+ "tsx": "^4.20.3",
77
75
  "typescript": "~5.7.3",
78
- "vitest": "^3.1.2"
76
+ "vitest": "^3.2.3",
77
+ "ws": "^8.18.2"
79
78
  }
80
79
  }
@@ -8,32 +8,33 @@ test.beforeEach(async ({ page }) => {
8
8
 
9
9
  extendTest('test menu color picker should work correctly', async ({ page }) => {
10
10
  await createTableBySelect(page, 'container1', 3, 3);
11
- const container1Cell = page.locator('#editor1').getByRole('cell').nth(0);
11
+ const container1Cell = page.locator('#editor1 .ql-table-cell').nth(0);
12
12
  await container1Cell.click();
13
13
  await container1Cell.click({ button: 'right' });
14
14
 
15
15
  await page.locator('.table-up-menu.is-contextmenu .table-up-menu__item').filter({ hasText: 'Set background color' }).first().click();
16
- await page.waitForTimeout(1000);
17
-
18
16
  await page.locator('.table-up-tooltip .table-up-color-map .table-up-color-map__item[style="background-color: rgb(255, 255, 255);"]').first().click();
19
17
  await expect(page.locator('.table-up-menu.is-contextmenu')).toBeVisible();
20
- await expect(page.locator('#editor1').getByRole('cell').nth(0)).toHaveCSS('background-color', 'rgb(255, 255, 255)');
18
+ await expect(page.locator('#editor1 .ql-table-cell').nth(0)).toHaveCSS('background-color', 'rgb(255, 255, 255)');
19
+
20
+ await page.mouse.click(0, 0);
21
21
 
22
22
  await createTableBySelect(page, 'container2', 3, 3);
23
- const container2Cell = page.locator('#editor2').getByRole('cell').nth(0);
24
- await container2Cell.click();
23
+ await page.locator('#editor2 .ql-table-cell').nth(0).click();
24
+ await page.waitForTimeout(1000);
25
25
 
26
26
  await page.locator('#editor2 .table-up-menu .color-selector').nth(0).click();
27
27
  await page.waitForTimeout(1000);
28
28
 
29
29
  await page.locator('.table-up-tooltip .table-up-color-map .table-up-color-map__item[style="background-color: rgb(255, 255, 255);"]').first().click();
30
30
  await expect(page.locator('#editor2 .table-up-menu')).toBeVisible();
31
- await expect(page.locator('#editor2').getByRole('cell').nth(0)).toHaveCSS('background-color', 'rgb(255, 255, 255)');
31
+ await expect(page.locator('#editor2 .ql-table-cell').nth(0)).toHaveCSS('background-color', 'rgb(255, 255, 255)');
32
32
  });
33
33
 
34
34
  extendTest('test menu color picker should not have two at the same time', async ({ page }) => {
35
35
  await createTableBySelect(page, 'container2', 3, 3);
36
- await page.locator('#editor2').getByRole('cell').nth(0).click();
36
+ await page.locator('#editor2 .ql-table-cell').nth(0).click();
37
+ await page.waitForTimeout(1000);
37
38
 
38
39
  await page.locator('#editor2 .table-up-menu .color-selector').nth(0).click();
39
40
  await page.waitForTimeout(1000);
@@ -2,7 +2,7 @@ import Quill from 'quill';
2
2
  import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
3
3
  import { TableCellFormat } from '../../formats';
4
4
  import { TableUp } from '../../table-up';
5
- import { createQuillWithTableModule, createTableBodyHTML, createTableCaptionHTML, createTaleColHTML, expectDelta } from './utils';
5
+ import { createQuillWithTableModule, createTableBodyHTML, createTableCaptionHTML, createTableDeltaOps, createTaleColHTML, expectDelta } from './utils';
6
6
 
7
7
  const Delta = Quill.import('delta');
8
8
 
@@ -278,3 +278,104 @@ describe('test table child sort', () => {
278
278
  );
279
279
  });
280
280
  });
281
+
282
+ describe('test table around line', () => {
283
+ it('table around should always have a `block` line', async () => {
284
+ const quill = createQuillWithTableModule(`<p><br></p>`);
285
+ quill.setContents([
286
+ { insert: '1' },
287
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
288
+ { insert: '2' },
289
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
290
+ { insert: '3' },
291
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
292
+ { insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 100 } } },
293
+ { insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 100 } } },
294
+ { insert: { 'table-up-col': { tableId: '1', colId: '3', full: false, width: 100 } } },
295
+ { insert: 'title' },
296
+ { attributes: { 'table-up-caption': { tableId: '1', side: 'top' } }, insert: '\n' },
297
+ ]);
298
+ await vi.runAllTimersAsync();
299
+
300
+ expect(quill.root).toEqualHTML(
301
+ `
302
+ <p><br></p>
303
+ <div>
304
+ <table cellpadding="0" cellspacing="0" style="margin-right: auto; width: 300px;">
305
+ ${createTableCaptionHTML({ text: 'title' })}
306
+ ${createTaleColHTML(3, { full: false, width: 100 })}
307
+ ${createTableBodyHTML(1, 3, { isEmpty: false })}
308
+ </table>
309
+ </div>
310
+ <p><br></p>
311
+ `,
312
+ { ignoreAttrs: ['class', 'data-table-id', 'data-row-id', 'data-col-id', 'data-rowspan', 'data-colspan', 'contenteditable'] },
313
+ );
314
+ expectDelta(
315
+ new Delta([
316
+ { insert: '\ntitle' },
317
+ { attributes: { 'table-up-caption': { side: 'top' } }, insert: '\n' },
318
+ { insert: { 'table-up-col': { full: false, width: 100 } } },
319
+ { insert: { 'table-up-col': { full: false, width: 100 } } },
320
+ { insert: { 'table-up-col': { full: false, width: 100 } } },
321
+ { insert: '1' },
322
+ { attributes: { 'table-up-cell-inner': { rowspan: 1, colspan: 1 } }, insert: '\n' },
323
+ { insert: '2' },
324
+ { attributes: { 'table-up-cell-inner': { rowspan: 1, colspan: 1 } }, insert: '\n' },
325
+ { insert: '3' },
326
+ { attributes: { 'table-up-cell-inner': { rowspan: 1, colspan: 1 } }, insert: '\n' },
327
+ { insert: '\n' },
328
+ ]),
329
+ quill.getContents(),
330
+ );
331
+ });
332
+
333
+ it('table around line should allow `code-block` and `list`', async () => {
334
+ const quill = createQuillWithTableModule(`<p><br></p>`);
335
+ quill.setContents(createTableDeltaOps(3, 3, { full: false }));
336
+ quill.formatLine(0, 0, 'code-block', true);
337
+ quill.formatLine(22, 0, 'list', 'ordered');
338
+ await vi.runAllTimersAsync();
339
+ expect(quill.root).toEqualHTML(
340
+ `
341
+ <div class="ql-code-block-container" spellcheck="false"><div class="ql-code-block"><br></div></div>
342
+ <div>
343
+ <table cellpadding="0" cellspacing="0" style="margin-right: auto; width: 300px;">
344
+ ${createTaleColHTML(3, { full: false, width: 100 })}
345
+ ${createTableBodyHTML(3, 3, { isEmpty: false })}
346
+ </table>
347
+ </div>
348
+ <ol><li data-list="ordered"><span class="ql-ui" contenteditable="false"></span><br></li></ol>
349
+ `,
350
+ { ignoreAttrs: ['class', 'data-table-id', 'data-row-id', 'data-col-id', 'data-rowspan', 'data-colspan', 'contenteditable'] },
351
+ );
352
+ expectDelta(
353
+ new Delta([
354
+ { attributes: { 'code-block': 'plain' }, insert: '\n' },
355
+ { insert: { 'table-up-col': { tableId: '1', colId: '1', full: false, width: 100 } } },
356
+ { insert: { 'table-up-col': { tableId: '1', colId: '2', full: false, width: 100 } } },
357
+ { insert: { 'table-up-col': { tableId: '1', colId: '3', full: false, width: 100 } } },
358
+ { insert: '1' },
359
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
360
+ { insert: '2' },
361
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
362
+ { insert: '3' },
363
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
364
+ { insert: '4' },
365
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
366
+ { insert: '5' },
367
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
368
+ { insert: '6' },
369
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
370
+ { insert: '7' },
371
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '1', rowspan: 1, colspan: 1 } }, insert: '\n' },
372
+ { insert: '8' },
373
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '2', rowspan: 1, colspan: 1 } }, insert: '\n' },
374
+ { insert: '9' },
375
+ { attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '3', colId: '3', rowspan: 1, colspan: 1 } }, insert: '\n' },
376
+ { attributes: { list: 'ordered' }, insert: '\n' },
377
+ ]),
378
+ quill.getContents(),
379
+ );
380
+ });
381
+ });
@@ -1,7 +1,10 @@
1
+ import Quill from 'quill';
1
2
  import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
2
3
  import { TableCellInnerFormat } from '../../formats';
3
4
  import { TableUp } from '../../table-up';
4
- import { createQuillWithTableModule, createTable, createTaleColHTML } from './utils';
5
+ import { createQuillWithTableModule, createTable, createTaleColHTML, expectDelta } from './utils';
6
+
7
+ const Delta = Quill.import('delta');
5
8
 
6
9
  beforeEach(() => {
7
10
  vi.useFakeTimers();
@@ -292,4 +295,76 @@ describe('merge and split cell', () => {
292
295
  { ignoreAttrs: ['class', 'style', 'data-table-id', 'contenteditable'] },
293
296
  );
294
297
  });
298
+
299
+ it('split cell should copy style to split cells', async () => {
300
+ const quill = createQuillWithTableModule(`<p><br></p>`);
301
+ quill.setContents([
302
+ { insert: '\n' },
303
+ { insert: { 'table-up-col': { tableId: '8v36875pbr6', colId: '1vwhsx9zayhi', full: true, width: 20 } } },
304
+ { insert: { 'table-up-col': { tableId: '8v36875pbr6', colId: 'gpais2dyp87', full: true, width: 20 } } },
305
+ { insert: { 'table-up-col': { tableId: '8v36875pbr6', colId: 'xtfguzk629', full: true, width: 20 } } },
306
+ { insert: { 'table-up-col': { tableId: '8v36875pbr6', colId: '94w8b6fhy2p', full: true, width: 20 } } },
307
+ { insert: { 'table-up-col': { tableId: '8v36875pbr6', colId: 'y0epsy6odnm', full: true, width: 20 } } },
308
+ { insert: '1' },
309
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
310
+ { insert: '2' },
311
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
312
+ { insert: '3' },
313
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
314
+ { insert: '4' },
315
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
316
+ { insert: '6' },
317
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
318
+ { insert: '7' },
319
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
320
+ { insert: '8' },
321
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
322
+ { insert: '9' },
323
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
324
+ { insert: '11' },
325
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
326
+ { insert: '12' },
327
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
328
+ { insert: '13' },
329
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
330
+ { insert: '14' },
331
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
332
+ { insert: '16' },
333
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
334
+ { insert: '17' },
335
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
336
+ { insert: '18' },
337
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
338
+ { insert: '19' },
339
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 4, colspan: 4, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' },
340
+ { insert: '5' },
341
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: 'y0epsy6odnm', rowspan: 1, colspan: 1 } }, insert: '\n' },
342
+ { insert: '10' },
343
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'ogznp2n7y8b', colId: 'y0epsy6odnm', rowspan: 1, colspan: 1 } }, insert: '\n' },
344
+ { insert: '15' },
345
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: '9vw214waitk', colId: 'y0epsy6odnm', rowspan: 1, colspan: 1 } }, insert: '\n' },
346
+ { insert: '20' },
347
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'j4uarvyr86d', colId: 'y0epsy6odnm', rowspan: 1, colspan: 1 } }, insert: '\n' },
348
+ { insert: '21' },
349
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'fow0uajprzw', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1 } }, insert: '\n' },
350
+ { insert: '22' },
351
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'fow0uajprzw', colId: 'gpais2dyp87', rowspan: 1, colspan: 1 } }, insert: '\n' },
352
+ { insert: '23' },
353
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'fow0uajprzw', colId: 'xtfguzk629', rowspan: 1, colspan: 1 } }, insert: '\n' },
354
+ { insert: '24' },
355
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'fow0uajprzw', colId: '94w8b6fhy2p', rowspan: 1, colspan: 1 } }, insert: '\n' },
356
+ { insert: '25' },
357
+ { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'fow0uajprzw', colId: 'y0epsy6odnm', rowspan: 1, colspan: 1 } }, insert: '\n' },
358
+ { insert: '\n' },
359
+ ]);
360
+ await vi.runAllTimersAsync();
361
+ const tableModule = quill.getModule(TableUp.moduleName) as TableUp;
362
+ const tds = quill.scroll.descendants(TableCellInnerFormat, 0);
363
+ tableModule.splitCell([tds[0]]);
364
+ await vi.runAllTimersAsync();
365
+ expectDelta(
366
+ new Delta([{ insert: '\n' }, { insert: { 'table-up-col': { tableId: '8v36875pbr6', colId: '1vwhsx9zayhi', full: true, width: 20 } } }, { insert: { 'table-up-col': { tableId: '8v36875pbr6', colId: 'gpais2dyp87', full: true, width: 20 } } }, { insert: { 'table-up-col': { tableId: '8v36875pbr6', colId: 'xtfguzk629', full: true, width: 20 } } }, { insert: { 'table-up-col': { tableId: '8v36875pbr6', colId: '94w8b6fhy2p', full: true, width: 20 } } }, { insert: { 'table-up-col': { tableId: '8v36875pbr6', colId: 'y0epsy6odnm', full: true, width: 20 } } }, { insert: '1' }, { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' }, { insert: '2' }, { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' }, { insert: '3' }, { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' }, { insert: '4' }, { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' }, { insert: '6' }, { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' }, { insert: '7' }, { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' }, { insert: '8' }, { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' }, { insert: '9' }, { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' }, { insert: '11' }, { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' }, { insert: '12' }, { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' }, { insert: '13' }, { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' }, { insert: '14' }, { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' }, { insert: '16' }, { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' }, { insert: '17' }, { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' }, { insert: '18' }, { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' }, { insert: '19' }, { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' }, { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: 'gpais2dyp87', rowspan: 1, colspan: 1, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' }, { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: 'xtfguzk629', rowspan: 1, colspan: 1, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' }, { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: '94w8b6fhy2p', rowspan: 1, colspan: 1, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' }, { insert: '5' }, { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'zjhlbpvwjo', colId: 'y0epsy6odnm', rowspan: 1, colspan: 1 } }, insert: '\n' }, { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'ogznp2n7y8b', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' }, { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'ogznp2n7y8b', colId: 'gpais2dyp87', rowspan: 1, colspan: 1, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' }, { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'ogznp2n7y8b', colId: 'xtfguzk629', rowspan: 1, colspan: 1, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' }, { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'ogznp2n7y8b', colId: '94w8b6fhy2p', rowspan: 1, colspan: 1, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' }, { insert: '10' }, { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'ogznp2n7y8b', colId: 'y0epsy6odnm', rowspan: 1, colspan: 1 } }, insert: '\n' }, { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: '9vw214waitk', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' }, { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: '9vw214waitk', colId: 'gpais2dyp87', rowspan: 1, colspan: 1, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' }, { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: '9vw214waitk', colId: 'xtfguzk629', rowspan: 1, colspan: 1, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' }, { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: '9vw214waitk', colId: '94w8b6fhy2p', rowspan: 1, colspan: 1, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' }, { insert: '15' }, { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: '9vw214waitk', colId: 'y0epsy6odnm', rowspan: 1, colspan: 1 } }, insert: '\n' }, { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'j4uarvyr86d', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' }, { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'j4uarvyr86d', colId: 'gpais2dyp87', rowspan: 1, colspan: 1, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' }, { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'j4uarvyr86d', colId: 'xtfguzk629', rowspan: 1, colspan: 1, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' }, { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'j4uarvyr86d', colId: '94w8b6fhy2p', rowspan: 1, colspan: 1, style: 'border-color: rgb(0, 153, 255);' } }, insert: '\n' }, { insert: '20' }, { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'j4uarvyr86d', colId: 'y0epsy6odnm', rowspan: 1, colspan: 1 } }, insert: '\n' }, { insert: '21' }, { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'fow0uajprzw', colId: '1vwhsx9zayhi', rowspan: 1, colspan: 1 } }, insert: '\n' }, { insert: '22' }, { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'fow0uajprzw', colId: 'gpais2dyp87', rowspan: 1, colspan: 1 } }, insert: '\n' }, { insert: '23' }, { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'fow0uajprzw', colId: 'xtfguzk629', rowspan: 1, colspan: 1 } }, insert: '\n' }, { insert: '24' }, { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'fow0uajprzw', colId: '94w8b6fhy2p', rowspan: 1, colspan: 1 } }, insert: '\n' }, { insert: '25' }, { attributes: { 'table-up-cell-inner': { tableId: '8v36875pbr6', rowId: 'fow0uajprzw', colId: 'y0epsy6odnm', rowspan: 1, colspan: 1 } }, insert: '\n' }, { insert: '\n' }]),
367
+ quill.getContents(),
368
+ );
369
+ });
295
370
  });
@@ -1,3 +1,4 @@
1
+ import type { Parchment as TypeParchment } from 'quill';
1
2
  import Quill from 'quill';
2
3
  import { blotName } from '../utils';
3
4
  import { ContainerFormat } from './container-format';
@@ -68,11 +69,15 @@ export class TableWrapperFormat extends ContainerFormat {
68
69
  this.scroll.emitter.off(Quill.events.TEXT_CHANGE, this.insertLineAround);
69
70
  }
70
71
 
72
+ isBlockLine(blot: TypeParchment.Blot) {
73
+ return blot instanceof Parchment.BlockBlot || new Set(['list-container', 'code-block-container']).has(blot.statics.blotName);
74
+ }
75
+
71
76
  insertLineAround = () => {
72
- if (!this.prev || !(this.prev instanceof Parchment.BlockBlot)) {
77
+ if (!this.prev || !this.isBlockLine(this.prev)) {
73
78
  this.parent.insertBefore(this.scroll.create('block'), this);
74
79
  }
75
- if (!this.next || !(this.next instanceof Parchment.BlockBlot)) {
80
+ if (!this.next || !this.isBlockLine(this.next)) {
76
81
  this.parent.insertBefore(this.scroll.create('block'), this.next);
77
82
  }
78
83
  };
@@ -0,0 +1 @@
1
+ {"version":"3.2.3","results":[[":__tests__/unit/utils.test-d.ts",{"duration":0,"failed":false}],[":__tests__/unit/table-clipboard.test.ts",{"duration":4809.0661,"failed":false}],[":__tests__/unit/table-redo-undo.test.ts",{"duration":7201.539700000008,"failed":false}],[":__tests__/unit/table-hack.test.ts",{"duration":2535.698,"failed":false}],[":__tests__/unit/table-insert.test.ts",{"duration":4301.950499999992,"failed":false}],[":__tests__/unit/table-cell-merge.test.ts",{"duration":2150.3714999999997,"failed":false}],[":__tests__/unit/table-blots.test.ts",{"duration":1530.4263,"failed":false}],[":__tests__/unit/utils.test.ts",{"duration":606.7640000000001,"failed":false}],[":__tests__/unit/table-remove.test.ts",{"duration":1883.1297999999997,"failed":false}],[":__tests__/unit/table-caption.test.ts",{"duration":863.3289,"failed":false}]]}
@@ -59,6 +59,7 @@
59
59
  min-width: 100%;
60
60
  word-break: break-word;
61
61
  outline: none;
62
+ counter-reset: list-0;
62
63
  }
63
64
  }
64
65
  col {
package/src/table-up.ts CHANGED
@@ -814,10 +814,10 @@ export class TableUp {
814
814
 
815
815
  // insert delta data to create table
816
816
  const colWidth = !this.options.full ? `${Math.max(Math.floor(width / columns), tableUpSize.colMinWidthPx)}px` : `${Math.max((1 / columns) * 100, tableUpSize.colMinWidthPre)}%`;
817
- const delta: Record<string, any>[] = [
818
- { retain: range.index },
819
- { insert: '\n' },
820
- ];
817
+ const delta: Record<string, any>[] = [{ retain: range.index }];
818
+ const aroundContent = this.quill.getContents(range.index, 1);
819
+ const [, offset] = this.quill.getLine(range.index);
820
+ if (aroundContent.ops[0].insert !== '\n' && offset !== 0) delta.push({ insert: '\n' });
821
821
 
822
822
  for (let i = 0; i < columns; i++) {
823
823
  delta.push({
@@ -850,7 +850,7 @@ export class TableUp {
850
850
  }
851
851
 
852
852
  this.quill.updateContents(new Delta(delta), Quill.sources.USER);
853
- this.quill.setSelection(range.index + columns + columns * rows + 1, Quill.sources.SILENT);
853
+ this.quill.setSelection(range.index + columns, Quill.sources.SILENT);
854
854
  this.quill.focus();
855
855
  }
856
856
 
@@ -1274,6 +1274,7 @@ export class TableUp {
1274
1274
  const tableId = tableBlot.tableId;
1275
1275
  const colIndex = baseTd.getColumnIndex();
1276
1276
  const colIds = tableBlot.getColIds().slice(colIndex, colIndex + baseTd.colspan).reverse();
1277
+ const baseTdStyle = (baseTd.formats()[blotName.tableCellInner] as TableCellValue).style;
1277
1278
 
1278
1279
  let curTr = baseTr;
1279
1280
  let rowspan = baseTd.rowspan;
@@ -1284,13 +1285,17 @@ export class TableUp {
1284
1285
  for (const id of colIds) {
1285
1286
  // keep baseTd. baseTr should insert at baseTd's column index + 1
1286
1287
  if (curTr === baseTr && id === baseTd.colId) continue;
1287
- curTr.insertCell(colIndex + (curTr === baseTr ? 1 : 0), {
1288
+ const value: TableCellValue = {
1288
1289
  tableId,
1289
1290
  rowId: curTr.rowId,
1290
1291
  colId: id,
1291
1292
  rowspan: 1,
1292
1293
  colspan: 1,
1293
- });
1294
+ };
1295
+ if (baseTdStyle) {
1296
+ value.style = baseTdStyle;
1297
+ }
1298
+ curTr.insertCell(colIndex + (curTr === baseTr ? 1 : 0), value);
1294
1299
  }
1295
1300
 
1296
1301
  rowspan -= 1;