Module

table/converters/tablecell-post-fixer

@ckeditor/ckeditor5-table/src/converters/tablecell-post-fixer

module

Filtering

Functions

  • injectTableCellPostFixer( model, editing )

    static

    Injects a table cell post-fixer into the editing controller.

    The role of the table cell post-fixer is to ensure that the table cell contents in the editing view are properly converted.

    This post-fixer will ensure that after model changes in the editing view:

    • single paragraphs are rendered as `
    • single paragraphs with one or more attributes are rendered as <p>
    • single paragraphs in table cell with other block elements are rendered as <p>
    • paragraphs in table cells with other block elements (including other paragraphs) are rendered as <p>.

    In the model each table cell has always at least one block element inside. If no other block was defined (empty table cell) the table feature will insert empty <paragraph>. Similarly text nodes will be wrapped in paragraphs. Rendering in the data pipeline differs from rendering in the editing pipeline - text nodes in single <paragraph> are rendered in the data pipeline as direct children of the <td> or <th> elements. In other cases <paragraph> elements are rendered as <p> blocks.

    To ensure proper mappings between model and view elements and positions in the editing pipeline the table feature will always render an element in the view: <span> for single or empty <paragraph> and <p> otherwise.

    Example:

    <table>
        <tableRow>
            <tableCell><paragraph></paragraph></tableCell>
            <tableCell><paragraph>foo</paragraph></tableCell>
            <tableCell><paragraph baz="bar">foo</paragraph></tableCell>
            <tableCell><heading2>bar</heading2><paragraph>baz</paragraph></tableCell>
        </tableRow>
    </table>

    The editor will render in the data pipeline:

    <figure>
        <table>
            <tbody>
                <tr>
                    <td></td>
                    <td>foo</td>
                    <td><p baz="bar">foo</p></td>
                    <td><h3>bar</h3><p>baz</p></td>
                </tr>
            </tbody>
        </table>
    </figure>

    and in the editing view (without widget markup):

    <figure>
        <table>
            <tbody>
                <tr>
                    <td><span></span></td>
                    <td><span>foo</span></td>
                    <td><p baz="bar">foo</p></td>
                    <td><h3>bar</h3><p>baz</p></td>
                </tr>
            </tbody>
        </table>
    </figure>

    Parameters

    model : Model
    editing : EditingController