|
| 1 | +/** |
| 2 | + * CKEditor dataview nodes can be converted to a output view or an editor view via downcasting |
| 3 | + * * Upcasting is converting to the platonic ckeditor version. |
| 4 | + * * Downcasting is converting to the output version. |
| 5 | + */ |
| 6 | +import { type RootElement } from 'ckeditor5/src/engine.js'; |
| 7 | +import { Autoformat } from "@ckeditor/ckeditor5-autoformat"; |
| 8 | +import { Plugin } from "ckeditor5/src/core.js"; |
| 9 | +import { Widget } from 'ckeditor5/src/widget.js'; |
| 10 | +import '../footnote.css'; |
| 11 | +export default class FootnoteEditing extends Plugin { |
| 12 | + static get requires(): readonly [typeof Widget, typeof Autoformat]; |
| 13 | + /** |
| 14 | + * The root element of the document. |
| 15 | + */ |
| 16 | + get rootElement(): RootElement; |
| 17 | + init(): void; |
| 18 | + /** |
| 19 | + * This method broadly deals with deletion of text and elements, and updating the model |
| 20 | + * accordingly. In particular, the following cases are handled: |
| 21 | + * 1. If the footnote section gets deleted, all footnote references are removed. |
| 22 | + * 2. If a delete operation happens in an empty footnote, the footnote is deleted. |
| 23 | + */ |
| 24 | + private _handleDelete; |
| 25 | + /** |
| 26 | + * Clear the children of the provided footnoteContent element, |
| 27 | + * leaving an empty paragraph behind. This allows users to empty |
| 28 | + * a footnote without deleting it. modelWriter is passed in to |
| 29 | + * batch these changes with the ones that instantiated them, |
| 30 | + * such that the set can be undone with a single action. |
| 31 | + */ |
| 32 | + private _clearContents; |
| 33 | + /** |
| 34 | + * Removes a footnote and its references, and renumbers subsequent footnotes. When a footnote's |
| 35 | + * id attribute changes, it's references automatically update from a dispatcher event in converters.js, |
| 36 | + * which triggers the `updateReferenceIds` method. modelWriter is passed in to batch these changes with |
| 37 | + * the ones that instantiated them, such that the set can be undone with a single action. |
| 38 | + */ |
| 39 | + private _removeFootnote; |
| 40 | + /** |
| 41 | + * Deletes all references to the footnote with the given id. If no id is provided, |
| 42 | + * all references are deleted. modelWriter is passed in to batch these changes with |
| 43 | + * the ones that instantiated them, such that the set can be undone with a single action. |
| 44 | + */ |
| 45 | + private _removeReferences; |
| 46 | + /** |
| 47 | + * Updates all references for a single footnote. This function is called when |
| 48 | + * the index attribute of an existing footnote changes, which happens when a footnote |
| 49 | + * with a lower index is deleted. batch is passed in to group these changes with |
| 50 | + * the ones that instantiated them. |
| 51 | + */ |
| 52 | + private _updateReferenceIndices; |
| 53 | + /** |
| 54 | + * Reindexes footnotes such that footnote references occur in order, and reorders |
| 55 | + * footnote items in the footer section accordingly. batch is passed in to group changes with |
| 56 | + * the ones that instantiated them. |
| 57 | + */ |
| 58 | + private _orderFootnotes; |
| 59 | +} |
0 commit comments