/** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license */ /** * @module table/tableediting */ import { Plugin, type Editor } from 'ckeditor5/src/core'; import type { PositionOffset, SlotFilter } from 'ckeditor5/src/engine'; import TableUtils from '../src/tableutils'; import '../theme/tableediting.css'; /** * The table editing feature. */ export default class TableEditing extends Plugin { /** * Handlers for creating additional slots in the table. */ private _additionalSlots; /** * @inheritDoc */ static get pluginName(): 'TableEditing'; /** * @inheritDoc */ static get requires(): readonly [typeof TableUtils]; /** * @inheritDoc */ constructor(editor: Editor); /** * @inheritDoc */ init(): void; /** * Registers downcast handler for the additional table slot. */ registerAdditionalSlot(slotHandler: AdditionalSlot): void; } /** * By default, only the `tableRow` elements from the `table` model are downcast inside the `` and * all other elements are pushed outside the table. This handler allows creating additional slots inside * the table for other elements. * * Take this model as an example: * * ```xml *
* ... * ... * ... *
* ``` * * By default, downcasting result will be: * * ```xml * * * ... * ... * *
* ... * ``` * * To allow the `tableColumnGroup` element at the end of the table, use the following configuration: * * ```ts * const additionalSlot = { * filter: element => element.is( 'element', 'tableColumnGroup' ), * positionOffset: 'end' * } * ``` * * Now, the downcast result will be: * * ```xml * * * ... * ... * * ... *
* ``` */ export interface AdditionalSlot { /** * Filter for elements that should be placed inside given slot. */ filter: SlotFilter; /** * Position of the slot within the table. */ positionOffset: PositionOffset; }