quill-table-up 3.1.0 → 3.1.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
|
@@ -388,7 +388,7 @@ describe('set contents', () => {
|
|
|
388
388
|
{ insert: '2' },
|
|
389
389
|
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'background-color: red; border-bottom-color: red;' } }, insert: '\n' },
|
|
390
390
|
{ insert: '3' },
|
|
391
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: red;
|
|
391
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: red;' } }, insert: '\n' },
|
|
392
392
|
{ insert: '4' },
|
|
393
393
|
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '2', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: red;' } }, insert: '\n' },
|
|
394
394
|
{ insert: '5' },
|
|
@@ -682,8 +682,8 @@ describe('set cell attribute', () => {
|
|
|
682
682
|
${createTaleColHTML(2)}
|
|
683
683
|
<tbody>
|
|
684
684
|
<tr data-row-id="1">
|
|
685
|
-
<td colspan="1" data-col-id="1" data-row-id="1" rowspan="1" style="border-color: red;
|
|
686
|
-
<div data-col-id="1" data-colspan="1" data-row-id="1" data-rowspan="1" data-style="border-color: red;
|
|
685
|
+
<td colspan="1" data-col-id="1" data-row-id="1" rowspan="1" style="border-color: red;">
|
|
686
|
+
<div data-col-id="1" data-colspan="1" data-row-id="1" data-rowspan="1" data-style="border-color: red;">
|
|
687
687
|
<p>1</p>
|
|
688
688
|
</div>
|
|
689
689
|
</td>
|
|
@@ -719,7 +719,7 @@ describe('set cell attribute', () => {
|
|
|
719
719
|
{ insert: { 'table-up-col': { tableId: '1', colId: '1', full: true, width: 50 } } },
|
|
720
720
|
{ insert: { 'table-up-col': { tableId: '1', colId: '2', full: true, width: 50 } } },
|
|
721
721
|
{ insert: '1' },
|
|
722
|
-
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: red;
|
|
722
|
+
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '1', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: red;' } }, insert: '\n' },
|
|
723
723
|
{ insert: '2' },
|
|
724
724
|
{ attributes: { 'table-up-cell-inner': { tableId: '1', rowId: '1', colId: '2', rowspan: 1, colspan: 1, tag: 'td', wrapTag: 'tbody', style: 'border-color: red;' } }, insert: '\n' },
|
|
725
725
|
{ insert: '3' },
|
|
@@ -1568,8 +1568,8 @@ describe('undo cell attribute', () => {
|
|
|
1568
1568
|
${createTaleColHTML(2)}
|
|
1569
1569
|
<tbody>
|
|
1570
1570
|
<tr data-row-id="1">
|
|
1571
|
-
<td colspan="1" data-col-id="1" data-row-id="1" rowspan="1" style="border-color: red;
|
|
1572
|
-
<div data-col-id="1" data-colspan="1" data-row-id="1" data-rowspan="1" data-style="border-color: red;
|
|
1571
|
+
<td colspan="1" data-col-id="1" data-row-id="1" rowspan="1" style="border-color: red;">
|
|
1572
|
+
<div data-col-id="1" data-colspan="1" data-row-id="1" data-rowspan="1" data-style="border-color: red;">
|
|
1573
1573
|
<p>1</p>
|
|
1574
1574
|
</div>
|
|
1575
1575
|
</td>
|
|
@@ -7,6 +7,21 @@ import { TableUp } from '../../table-up';
|
|
|
7
7
|
const Delta = Quill.import('delta');
|
|
8
8
|
|
|
9
9
|
export const normalizeHTML = (html: string | { html: string }) => typeof html === 'object' ? html.html : html.replaceAll(/\n\s*/g, '');
|
|
10
|
+
export function normalizeStyle(style: string) {
|
|
11
|
+
if (!style) return '';
|
|
12
|
+
return style
|
|
13
|
+
.split(';')
|
|
14
|
+
.map(style => style.trim())
|
|
15
|
+
.filter(Boolean)
|
|
16
|
+
.map((style) => {
|
|
17
|
+
const [property, value] = style.split(':').map(s => s.trim());
|
|
18
|
+
return property && value ? `${property}:${value}` : '';
|
|
19
|
+
})
|
|
20
|
+
.filter(Boolean)
|
|
21
|
+
.toSorted()
|
|
22
|
+
.join(';');
|
|
23
|
+
}
|
|
24
|
+
|
|
10
25
|
export function sortAttributes(element: HTMLElement) {
|
|
11
26
|
const attributes = Array.from(element.attributes);
|
|
12
27
|
const sortedAttributes = attributes.toSorted((a, b) => a.name.localeCompare(b.name));
|
|
@@ -100,6 +115,14 @@ expect.extend({
|
|
|
100
115
|
}
|
|
101
116
|
|
|
102
117
|
sortAttributes(dom);
|
|
118
|
+
|
|
119
|
+
// normalize style attributes to handle different order
|
|
120
|
+
for (const node of Array.from(dom.querySelectorAll('[style]'))) {
|
|
121
|
+
const styleAttr = node.getAttribute('style');
|
|
122
|
+
if (styleAttr) {
|
|
123
|
+
node.setAttribute('style', normalizeStyle(styleAttr));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
103
126
|
}
|
|
104
127
|
|
|
105
128
|
if (this.equals(receivedDOM.innerHTML, expectedDOM.innerHTML)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"3.2.3","results":[[":__tests__/unit/utils.test-d.ts",{"duration":0,"failed":false}],[":__tests__/unit/table-clipboard.test.ts",{"duration":
|
|
1
|
+
{"version":"3.2.3","results":[[":__tests__/unit/utils.test-d.ts",{"duration":0,"failed":false}],[":__tests__/unit/table-clipboard.test.ts",{"duration":5764.352499999999,"failed":true}],[":__tests__/unit/table-redo-undo.test.ts",{"duration":7413.697700000001,"failed":true}],[":__tests__/unit/table-hack.test.ts",{"duration":2512.8070000000002,"failed":false}],[":__tests__/unit/table-cell-merge.test.ts",{"duration":3206.3629,"failed":false}],[":__tests__/unit/table-insert.test.ts",{"duration":4597.281199999999,"failed":true}],[":__tests__/unit/table-blots.test.ts",{"duration":2687.4262,"failed":true}],[":__tests__/unit/utils.test.ts",{"duration":732.1670999999997,"failed":false}],[":__tests__/unit/table-caption.test.ts",{"duration":1031.1293,"failed":true}],[":__tests__/unit/table-remove.test.ts",{"duration":2594.6331,"failed":true}]]}
|