UNPKG

2.35 kBTypeScriptView Raw
1/**
2 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4 */
5/**
6 * @module table/tableediting
7 */
8import { Plugin, type Editor } from 'ckeditor5/src/core';
9import type { PositionOffset, SlotFilter } from 'ckeditor5/src/engine';
10import TableUtils from '../src/tableutils';
11import '../theme/tableediting.css';
12/**
13 * The table editing feature.
14 */
15export default class TableEditing extends Plugin {
16 /**
17 * Handlers for creating additional slots in the table.
18 */
19 private _additionalSlots;
20 /**
21 * @inheritDoc
22 */
23 static get pluginName(): 'TableEditing';
24 /**
25 * @inheritDoc
26 */
27 static get requires(): readonly [typeof TableUtils];
28 /**
29 * @inheritDoc
30 */
31 constructor(editor: Editor);
32 /**
33 * @inheritDoc
34 */
35 init(): void;
36 /**
37 * Registers downcast handler for the additional table slot.
38 */
39 registerAdditionalSlot(slotHandler: AdditionalSlot): void;
40}
41/**
42 * By default, only the `tableRow` elements from the `table` model are downcast inside the `<table>` and
43 * all other elements are pushed outside the table. This handler allows creating additional slots inside
44 * the table for other elements.
45 *
46 * Take this model as an example:
47 *
48 * ```xml
49 * <table>
50 * <tableRow>...</tableRow>
51 * <tableRow>...</tableRow>
52 * <tableColumnGroup>...</tableColumnGroup>
53 * </table>
54 * ```
55 *
56 * By default, downcasting result will be:
57 *
58 * ```xml
59 * <table>
60 * <tbody>
61 * <tr>...</tr>
62 * <tr>...</tr>
63 * </tbody>
64 * </table>
65 * <colgroup>...</colgroup>
66 * ```
67 *
68 * To allow the `tableColumnGroup` element at the end of the table, use the following configuration:
69 *
70 * ```ts
71 * const additionalSlot = {
72 * filter: element => element.is( 'element', 'tableColumnGroup' ),
73 * positionOffset: 'end'
74 * }
75 * ```
76 *
77 * Now, the downcast result will be:
78 *
79 * ```xml
80 * <table>
81 * <tbody>
82 * <tr>...</tr>
83 * <tr>...</tr>
84 * </tbody>
85 * <colgroup>...</colgroup>
86 * </table>
87 * ```
88 */
89export interface AdditionalSlot {
90 /**
91 * Filter for elements that should be placed inside given slot.
92 */
93 filter: SlotFilter;
94 /**
95 * Position of the slot within the table.
96 */
97 positionOffset: PositionOffset;
98}
99
\No newline at end of file