Skip to content

Tables in the Vue 3 Editor ​

@erag/text-editor-vue includes table tools that a Vue 3 app enables with the table toolbar keyword in its :init object. The Table menu and toolbar button cover inserting a grid, row and column operations, cell merging and splitting, and property dialogs, while the resulting <table> HTML stays in sync with v-model.

You can show or hide the Table menu through menubar customization.


Inserting Tables ​

Click the Table icon in the toolbar or navigate to Table → Insert table in the menubar. A grid selector allows you to choose row and column dimensions (e.g. 3x3, 4x5).

vue
<script setup lang="ts">
import { shallowRef } from 'vue';
import { Editor, type EditorInit } from '@erag/text-editor-vue';

const content = shallowRef('');
const config: EditorInit = {
    tableGridSize: 10,
    toolbar: 'undo redo | blocks | bold italic | table | code',
};
</script>

<template>
    <Editor v-model="content" :init="config" />
</template>

tableGridSize controls the maximum row and column count offered by the visual picker. Its default is 10.


Table Operations ​

When a table or table cell is focused inside the editor canvas, the Table menu unlocks full operations:

  • Row Operations: Insert row above, Insert row below, Delete row.
  • Column Operations: Insert column before, Insert column after, Delete column.
  • Table Deletion: Delete entire table.
  • Cell Operations: Cell properties, merge cells, and split cells.
  • Table Properties: Width, cell padding, borders, colors, and alignment through the properties dialog.

Table-only actions remain disabled until the current selection is inside a table. Press Tab or Shift+Tab inside a cell to move forward or backward through table cells. In lists, those keys indent and outdent instead; see lists and indentation.

Table alignment is applied with table margins so left, center, and right remain visually distinct across editor widths. Cell properties separately support horizontal left/center/right alignment and vertical top/middle/bottom alignment.