📝 Add it to the doc
This commit is contained in:
@@ -32,6 +32,31 @@ const CustomTableCell = TableCell.extend({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export const tableHTML = `
|
||||||
|
<table style="width:100%">
|
||||||
|
<tr>
|
||||||
|
<th>Firstname</th>
|
||||||
|
<th>Lastname</th>
|
||||||
|
<th>Age</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Jill</td>
|
||||||
|
<td>Smith</td>
|
||||||
|
<td>50</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Eve</td>
|
||||||
|
<td>Jackson</td>
|
||||||
|
<td>94</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>John</td>
|
||||||
|
<td>Doe</td>
|
||||||
|
<td>80</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
`
|
||||||
|
|
||||||
const MenuBar = ({ editor }) => {
|
const MenuBar = ({ editor }) => {
|
||||||
if (!editor) {
|
if (!editor) {
|
||||||
return null
|
return null
|
||||||
@@ -42,6 +67,13 @@ const MenuBar = ({ editor }) => {
|
|||||||
<button onClick={() => editor.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: true }).run()}>
|
<button onClick={() => editor.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: true }).run()}>
|
||||||
insertTable
|
insertTable
|
||||||
</button>
|
</button>
|
||||||
|
<button onClick={() => editor.chain().focus().insertContent(tableHTML, {
|
||||||
|
parseOptions: {
|
||||||
|
preserveWhitespace: false,
|
||||||
|
},
|
||||||
|
}).run()}>
|
||||||
|
insertHTMLTable
|
||||||
|
</button>
|
||||||
<button onClick={() => editor.chain().focus().addColumnBefore().run()} disabled={!editor.can().addColumnBefore()}>
|
<button onClick={() => editor.chain().focus().addColumnBefore().run()} disabled={!editor.can().addColumnBefore()}>
|
||||||
addColumnBefore
|
addColumnBefore
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -16,6 +16,14 @@ editor.commands.insertContent('Example Text')
|
|||||||
// HTML
|
// HTML
|
||||||
editor.commands.insertContent('<h1>Example Text</h1>')
|
editor.commands.insertContent('<h1>Example Text</h1>')
|
||||||
|
|
||||||
|
// HTML with trim white space
|
||||||
|
editor.commands.insertContent('<h1>Example Text</h1>',
|
||||||
|
{
|
||||||
|
parseOptions: {
|
||||||
|
preserveWhitespace: false,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// JSON/Nodes
|
// JSON/Nodes
|
||||||
editor.commands.insertContent({
|
editor.commands.insertContent({
|
||||||
type: 'heading',
|
type: 'heading',
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export const insertContentAt: RawCommands['insertContentAt'] = (position, value,
|
|||||||
parseOptions: {
|
parseOptions: {
|
||||||
preserveWhitespace: 'full',
|
preserveWhitespace: 'full',
|
||||||
},
|
},
|
||||||
...(options || {})
|
...(options || {}),
|
||||||
})
|
})
|
||||||
|
|
||||||
// don’t dispatch an empty fragment because this can lead to strange errors
|
// don’t dispatch an empty fragment because this can lead to strange errors
|
||||||
|
|||||||
Reference in New Issue
Block a user