Skip to content

HtmlEditor - Table Support #14724

@San4es

Description

@San4es

The Problem

Tables are a common element of modern web documents. Our HTML/Markdown Editor does not support tables.

The Proposed Solution

Prior to DevExtreme v20.2, our HtmlEditor was based on the Quill engine v1.x. It does not support tables out-of-the-box. Quill v2.x supports basic table operations, but it has not yet been released. Quill v2 has been in the development stage for the last 2 years. We decided to fork it to have full control over further development and provide an API and UI to support tables. You can find our fork here: https://github.com/DevExpress/devextreme-quill.

The HtmlEditor can now render basic table layouts. You can format tables and their elements, and use the new API listed below to modify them.

Proposed API:

Get the Table Module Instance

const tables = editorInstance.getModule('tables');

The methods mentioned below are applied to the table/row/cell according to the text cursor position.

Manage Tables

tables.getTable(): [table, row, cell, offset]
tables.insertTable(rows: number, columns: number)
tables.deleteTable()

Manage Rows

tables.insertRow(offset: number) // offset > 0 : insertRowBelow ? insertRowAbove
tables.insertRowAbove()
tables.insertRowBelow()
tables.deleteRow()

Manage Columns

tables.insertColumn(offset: number) // offset > 0 : insertColumnRight ? insertColumnLeft
tables.insertColumnLeft()
tables.insertColumnRight()
tables.deleteColumn()

Toolbar Integration

The following toolbar items were added:

  • insertTable
  • insertRowAbove
  • insertRowBelow
  • insertColumnLeft
  • insertColumnRight
  • deleteColumn
  • deleteRow
  • deleteTable

You can specify them declaratively...

<dx-html-editor>
    <dxo-toolbar>
        <dxi-item formatName="addTable"></dxi-item>
        <dxi-item formatName="deleteTable"></dxi-item>
    </dxo-toolbar>
</dx-html-editor>

... or as a configuration object:

new HtmlEditor(element, {
    toolbar: {
        items: ['addTable', 'deleteTable']
    }
});

UI Design

image

Breaking Changes

Refer to the following breaking change ticket to see how to use new versions of the Quill scripts: HtmlEditor - the "quill" dependency replaced by "devextreme-quill".

Try It

Online Demos

jQuery

Angular

Vue

React

Installation

Follow the installation guide on the release page and leave feedback on this topic.

We Need Your Feedback

Take a Quick Poll

Does the table support feature meet your needs?

Get Notified of Updates

Subscribe to this thread or to our Facebook and Twitter accounts for updates on this topic.

Metadata

Metadata

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions