1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | import { Plugin, type Editor } from 'ckeditor5/src/core';
|
9 | import type { PositionOffset, SlotFilter } from 'ckeditor5/src/engine';
|
10 | import TableUtils from '../src/tableutils';
|
11 | import '../theme/tableediting.css';
|
12 |
|
13 |
|
14 |
|
15 | export default class TableEditing extends Plugin {
|
16 | |
17 |
|
18 |
|
19 | private _additionalSlots;
|
20 | |
21 |
|
22 |
|
23 | static get pluginName(): 'TableEditing';
|
24 | |
25 |
|
26 |
|
27 | static get requires(): readonly [typeof TableUtils];
|
28 | |
29 |
|
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 | */
|
89 | export 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 |