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/tablecaption/tablecaptionediting
|
7 | */
|
8 | import { Plugin, type Editor } from 'ckeditor5/src/core';
|
9 | import { Element } from 'ckeditor5/src/engine';
|
10 | /**
|
11 | * The table caption editing plugin.
|
12 | */
|
13 | export default class TableCaptionEditing extends Plugin {
|
14 | /**
|
15 | * A map that keeps saved JSONified table captions and table model elements they are
|
16 | * associated with.
|
17 | *
|
18 | * To learn more about this system, see {@link #_saveCaption}.
|
19 | */
|
20 | private _savedCaptionsMap;
|
21 | /**
|
22 | * @inheritDoc
|
23 | */
|
24 | static get pluginName(): 'TableCaptionEditing';
|
25 | /**
|
26 | * @inheritDoc
|
27 | */
|
28 | constructor(editor: Editor);
|
29 | /**
|
30 | * @inheritDoc
|
31 | */
|
32 | init(): void;
|
33 | /**
|
34 | * Returns the saved {module:engine/model/element~Element#toJSON JSONified} caption
|
35 | * of a table model element.
|
36 | *
|
37 | * See { #_saveCaption}.
|
38 | *
|
39 | *
|
40 | * for.
tableModelElement The model element the caption should be returned |
41 | * `null` if there is none.
The model caption element or |
42 | */
|
43 | _getSavedCaption(tableModelElement: Element): Element | null;
|
44 | /**
|
45 | * Saves a {@link module:engine/model/element~Element#toJSON JSONified} caption for
|
46 | * a table element to allow restoring it in the future.
|
47 | *
|
48 | * A caption is saved every time it gets hidden. The
|
49 | * user should be able to restore it on demand.
|
50 | *
|
51 | * **Note**: The caption cannot be stored in the table model element attribute because,
|
52 | * for instance, when the model state propagates to collaborators, the attribute would get
|
53 | * lost (mainly because it does not convert to anything when the caption is hidden) and
|
54 | * the states of collaborators' models would de-synchronize causing numerous issues.
|
55 | *
|
56 | * See {@link #_getSavedCaption}.
|
57 | *
|
58 | * @internal
|
59 | * @param tableModelElement The model element the caption is saved for.
|
60 | * @param caption The caption model element to be saved.
|
61 | */
|
62 | _saveCaption(tableModelElement: Element, caption: Element): void;
|
63 | }
|