UNPKG

2.25 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/tablecaption/tablecaptionediting
7 */
8import { Plugin, type Editor } from 'ckeditor5/src/core';
9import { Element } from 'ckeditor5/src/engine';
10/**
11 * The table caption editing plugin.
12 */
13export 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 {@link module:engine/model/element~Element#toJSON JSONified} caption
35 * of a table model element.
36 *
37 * See {@link #_saveCaption}.
38 *
39 * @internal
40 * @param tableModelElement The model element the caption should be returned for.
41 * @returns The model caption element or `null` if there is none.
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}