@contember/react-slate-editor-base 2.0.0-alpha.24 → 2.0.0-alpha.26
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/dist/development/src/plugins/element/tables/TableHtmlDeserializer.cjs +36 -0
- package/dist/development/src/plugins/element/tables/TableHtmlDeserializer.cjs.map +1 -0
- package/dist/development/src/plugins/element/tables/TableHtmlDeserializer.js +36 -0
- package/dist/development/src/plugins/element/tables/TableHtmlDeserializer.js.map +1 -0
- package/dist/development/src/plugins/element/tables/withTables.cjs +2 -0
- package/dist/development/src/plugins/element/tables/withTables.cjs.map +1 -1
- package/dist/development/src/plugins/element/tables/withTables.js +2 -0
- package/dist/development/src/plugins/element/tables/withTables.js.map +1 -1
- package/dist/production/src/plugins/element/tables/TableHtmlDeserializer.cjs +36 -0
- package/dist/production/src/plugins/element/tables/TableHtmlDeserializer.cjs.map +1 -0
- package/dist/production/src/plugins/element/tables/TableHtmlDeserializer.js +36 -0
- package/dist/production/src/plugins/element/tables/TableHtmlDeserializer.js.map +1 -0
- package/dist/production/src/plugins/element/tables/withTables.cjs +2 -0
- package/dist/production/src/plugins/element/tables/withTables.cjs.map +1 -1
- package/dist/production/src/plugins/element/tables/withTables.js +2 -0
- package/dist/production/src/plugins/element/tables/withTables.js.map +1 -1
- package/dist/types/plugins/element/tables/TableHtmlDeserializer.d.ts +3 -0
- package/dist/types/plugins/element/tables/TableHtmlDeserializer.d.ts.map +1 -0
- package/dist/types/plugins/element/tables/withTables.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/plugins/element/tables/TableHtmlDeserializer.ts +37 -0
- package/src/plugins/element/tables/withTables.ts +3 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/react-slate-editor-base",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "2.0.0-alpha.
|
|
4
|
+
"version": "2.0.0-alpha.26",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"main": "./dist/production/index.js",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"directory": "packages/react-slate-editor-base"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@contember/react-binding": "2.0.0-alpha.
|
|
37
|
-
"@contember/utilities": "2.0.0-alpha.
|
|
36
|
+
"@contember/react-binding": "2.0.0-alpha.26",
|
|
37
|
+
"@contember/utilities": "2.0.0-alpha.26",
|
|
38
38
|
"@radix-ui/primitive": "^1.1.0",
|
|
39
39
|
"@radix-ui/react-slot": "^1.1.0",
|
|
40
40
|
"is-hotkey": "^0.2.0",
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { HtmlDeserializerPlugin } from '../../../types'
|
|
2
|
+
import { tableCellElementType } from './TableCellElement'
|
|
3
|
+
import { tableElementType } from './TableElement'
|
|
4
|
+
import { tableRowElementType } from './TableRowElement'
|
|
5
|
+
|
|
6
|
+
export const tableHTMLDeserializer: HtmlDeserializerPlugin = {
|
|
7
|
+
processBlockPaste: ({ element, next, cumulativeTextAttrs }) => {
|
|
8
|
+
if (element.tagName === 'TABLE') {
|
|
9
|
+
return [
|
|
10
|
+
{
|
|
11
|
+
type: tableElementType,
|
|
12
|
+
children: next(element.childNodes, cumulativeTextAttrs),
|
|
13
|
+
},
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (element.tagName === 'TR') {
|
|
18
|
+
return [
|
|
19
|
+
{
|
|
20
|
+
type: tableRowElementType,
|
|
21
|
+
children: next(element.childNodes, cumulativeTextAttrs),
|
|
22
|
+
},
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (element.tagName === 'TD' || element.tagName === 'TH') {
|
|
27
|
+
return [
|
|
28
|
+
{
|
|
29
|
+
type: tableCellElementType,
|
|
30
|
+
children: next(element.childNodes, cumulativeTextAttrs),
|
|
31
|
+
},
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return null
|
|
36
|
+
},
|
|
37
|
+
}
|
|
@@ -3,6 +3,7 @@ import { ContemberEditor } from '../../../editor'
|
|
|
3
3
|
import { isTableCellElement, TableCellElement, tableCellElementPlugin } from './TableCellElement'
|
|
4
4
|
import { getTableElementColumnCount, getTableElementRowCount, isTableElement, TableElement, tableElementPlugin } from './TableElement'
|
|
5
5
|
import { getTableCellCoordinates, selectTableCellContents } from './TableElementSelection'
|
|
6
|
+
import { tableHTMLDeserializer } from './TableHtmlDeserializer'
|
|
6
7
|
import { TableModifications } from './TableModifications'
|
|
7
8
|
import { isTableRowElement, TableRowElement, tableRowElementPlugin } from './TableRowElement'
|
|
8
9
|
import { ElementRenderer } from '../../../types'
|
|
@@ -24,6 +25,8 @@ export const withTables = ({ renderTable, renderTableCell, renderTableRow }: {
|
|
|
24
25
|
editor.registerElement(tableCellElementPlugin({ render: renderTableCell }))
|
|
25
26
|
editor.registerElement(tableRowElementPlugin({ render: renderTableRow }))
|
|
26
27
|
|
|
28
|
+
editor.htmlDeserializer.registerPlugin(tableHTMLDeserializer)
|
|
29
|
+
|
|
27
30
|
Object.assign<Editor, Partial<Editor>>(editor, {
|
|
28
31
|
insertBreak: () => {
|
|
29
32
|
const closestBlockEntry = ContemberEditor.closestBlockEntry(editor)
|