-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1887 from epam/fix-colspan-rowspan
[SlateEditor] Fix colspan / rowspan & add merged cells to example
- Loading branch information
Showing
8 changed files
with
442 additions
and
46 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
92 changes: 92 additions & 0 deletions
92
uui-editor/src/__tests__/__snapshots__/migration.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`migrate should migrate content correctly 1`] = ` | ||
Array [ | ||
Object { | ||
"children": Array [ | ||
Object { | ||
"text": "All queries and requests for should be sent initially to [email protected]. | ||
", | ||
}, | ||
], | ||
"data": Object {}, | ||
"type": "paragraph", | ||
}, | ||
Object { | ||
"children": Array [ | ||
Object { | ||
"children": Array [ | ||
Object { | ||
"children": Array [ | ||
Object { | ||
"children": Array [ | ||
Object { | ||
"text": "Country", | ||
}, | ||
], | ||
"data": Object {}, | ||
"type": "paragraph", | ||
}, | ||
], | ||
"type": "table_header_cell", | ||
}, | ||
Object { | ||
"children": Array [ | ||
Object { | ||
"children": Array [ | ||
Object { | ||
"text": "Name and address of supervisory authority", | ||
}, | ||
], | ||
"data": Object {}, | ||
"type": "paragraph", | ||
}, | ||
], | ||
"type": "table_header_cell", | ||
}, | ||
], | ||
"data": Object {}, | ||
"type": "table_row", | ||
}, | ||
Object { | ||
"children": Array [ | ||
Object { | ||
"children": Array [ | ||
Object { | ||
"children": Array [ | ||
Object { | ||
"text": "Belgium", | ||
}, | ||
], | ||
"data": Object {}, | ||
"type": "paragraph", | ||
}, | ||
Object { | ||
"children": Array [ | ||
Object { | ||
"text": "Data Protection Authority | ||
", | ||
}, | ||
], | ||
"data": Object {}, | ||
"type": "paragraph", | ||
}, | ||
], | ||
"colSpan": 2, | ||
"type": "table_cell", | ||
}, | ||
], | ||
"data": Object {}, | ||
"type": "table_row", | ||
}, | ||
], | ||
"data": Object { | ||
"cellSizes": Array [ | ||
112, | ||
288, | ||
], | ||
}, | ||
"type": "table", | ||
}, | ||
] | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
export const initialValue = { | ||
object: 'value', | ||
document: { | ||
object: 'document', | ||
data: {}, | ||
nodes: [ | ||
{ | ||
object: 'block', | ||
type: 'paragraph', | ||
data: {}, | ||
nodes: [ | ||
{ | ||
object: 'text', | ||
text: 'All queries and requests for should be sent initially to [email protected].\r', | ||
marks: [], | ||
}, | ||
], | ||
}, | ||
{ | ||
object: 'block', | ||
type: 'paragraph', | ||
data: {}, | ||
nodes: [ | ||
{ | ||
object: 'block', | ||
type: 'table', | ||
data: { | ||
cellSizes: [ | ||
112, | ||
288, | ||
], | ||
}, | ||
nodes: [ | ||
{ | ||
object: 'block', | ||
type: 'table_row', | ||
data: {}, | ||
nodes: [ | ||
{ | ||
object: 'block', | ||
type: 'table_header_cell', | ||
data: {}, | ||
nodes: [ | ||
{ | ||
object: 'block', | ||
type: 'paragraph', | ||
data: {}, | ||
nodes: [ | ||
{ | ||
object: 'text', | ||
text: 'Country', | ||
marks: [], | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
object: 'block', | ||
type: 'table_header_cell', | ||
data: {}, | ||
nodes: [ | ||
{ | ||
object: 'block', | ||
type: 'paragraph', | ||
data: {}, | ||
nodes: [ | ||
{ | ||
object: 'text', | ||
text: 'Name and address of supervisory authority', | ||
marks: [], | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
object: 'block', | ||
type: 'table_row', | ||
data: {}, | ||
nodes: [ | ||
{ | ||
object: 'block', | ||
type: 'table_cell', | ||
data: { colSpan: 2 }, | ||
nodes: [ | ||
{ | ||
object: 'block', | ||
type: 'paragraph', | ||
data: {}, | ||
nodes: [ | ||
{ | ||
object: 'text', | ||
text: 'Belgium', | ||
marks: [], | ||
}, | ||
|
||
], | ||
}, | ||
{ | ||
object: 'block', | ||
type: 'paragraph', | ||
data: {}, | ||
nodes: [ | ||
{ | ||
object: 'text', | ||
text: 'Data Protection Authority\r', | ||
marks: [], | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
|
||
], | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { TTableCellElement } from '@udecode/plate-table'; | ||
import { migrateSchema, migrateTableCell } from '../migration'; | ||
import { initialValue } from './data'; | ||
|
||
describe('migrate', () => { | ||
it('should migrate content correctly', () => { | ||
const migrated = migrateSchema(initialValue); | ||
|
||
expect(migrated).toMatchSnapshot(); | ||
}); | ||
|
||
it('should migrate table cell correctly', () => { | ||
const element: TTableCellElement = { | ||
type: 'table-cell', | ||
colSpan: 2, | ||
rowSpan: 1, | ||
data: { | ||
colSpan: 3, | ||
rowSpan: 2, | ||
}, | ||
attributes: {}, | ||
children: [], | ||
}; | ||
|
||
const migrated = migrateTableCell(element); | ||
|
||
expect(migrated).toEqual({ | ||
type: 'table-cell', | ||
colSpan: 3, | ||
rowSpan: 2, | ||
attributes: {}, | ||
children: [], | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters