Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(build): missing typings
Elian Doranbf34816950cc
diff --git a/package.json b/package.jsonindex 287a410050..85211b4e81 100644--- a/package.json+++ b/package.json@@ -1,6 +1,6 @@{"name": "@triliumnext/ckeditor5-footnotes",- "version": "0.0.4-hotfix9",+ "version": "0.0.4-hotfix10","description": "A plugin for CKEditor 5 to allow footnotes.","keywords": ["ckeditor",diff --git a/sample/ckeditor.d.ts b/sample/ckeditor.d.tsnew file mode 100644index 0000000000..e838419a20--- /dev/null+++ b/sample/ckeditor.d.ts@@ -0,0 +1,7 @@+declare global {+ interface Window {+ editor: ClassicEditor;+ }+}+import { ClassicEditor } from 'ckeditor5';+import 'ckeditor5/ckeditor5.css';diff --git a/src/augmentation.d.ts b/src/augmentation.d.tsnew file mode 100644index 0000000000..bb312b5df3--- /dev/null+++ b/src/augmentation.d.ts@@ -0,0 +1,6 @@+import type { Footnotes } from './index.js';+declare module '@ckeditor/ckeditor5-core' {+ interface PluginsMap {+ [Footnotes.pluginName]: Footnotes;+ }+}diff --git a/src/constants.d.ts b/src/constants.d.tsnew file mode 100644index 0000000000..1166112835--- /dev/null+++ b/src/constants.d.ts@@ -0,0 +1,31 @@+export declare const TOOLBAR_COMPONENT_NAME = "footnote";+export declare const DATA_FOOTNOTE_ID = "data-footnote-id";+export declare const ELEMENTS: {+ footnoteItem: string;+ footnoteReference: string;+ footnoteSection: string;+ footnoteContent: string;+ footnoteBackLink: string;+};+export declare const CLASSES: {+ footnoteContent: string;+ footnoteItem: string;+ footnoteReference: string;+ footnoteSection: string;+ footnoteBackLink: string;+ footnotes: string;+ hidden: string;+};+export declare const COMMANDS: {+ insertFootnote: string;+};+export declare const ATTRIBUTES: {+ footnoteContent: string;+ footnoteId: string;+ footnoteIndex: string;+ footnoteItem: string;+ footnoteReference: string;+ footnoteSection: string;+ footnoteBackLink: string;+ footnoteBackLinkHref: string;+};diff --git a/src/footnote-editing/auto-formatting.d.ts b/src/footnote-editing/auto-formatting.d.tsnew file mode 100644index 0000000000..c0df6413c2--- /dev/null+++ b/src/footnote-editing/auto-formatting.d.ts@@ -0,0 +1,6 @@+import { type Editor } from 'ckeditor5/src/core.js';+import { type Element } from 'ckeditor5/src/engine.js';+/**+ * Adds functionality to support creating footnotes using markdown syntax, e.g. `[^1]`.+ */+export declare const addFootnoteAutoformatting: (editor: Editor, rootElement: Element) => void;diff --git a/src/footnote-editing/converters.d.ts b/src/footnote-editing/converters.d.tsnew file mode 100644index 0000000000..f7926d167b--- /dev/null+++ b/src/footnote-editing/converters.d.ts@@ -0,0 +1,5 @@+import { type Editor } from 'ckeditor5/src/core.js';+/**+ * Defines methods for converting between model, data view, and editing view representations of each element type.+ */+export declare const defineConverters: (editor: Editor) => void;diff --git a/src/footnote-editing/footnote-editing.d.ts b/src/footnote-editing/footnote-editing.d.tsnew file mode 100644index 0000000000..f2825e1dca--- /dev/null+++ b/src/footnote-editing/footnote-editing.d.ts@@ -0,0 +1,59 @@+/**+ * CKEditor dataview nodes can be converted to a output view or an editor view via downcasting+ * * Upcasting is converting to the platonic ckeditor version.+ * * Downcasting is converting to the output version.+ */+import { type RootElement } from 'ckeditor5/src/engine.js';+import { Autoformat } from "@ckeditor/ckeditor5-autoformat";+import { Plugin } from "ckeditor5/src/core.js";+import { Widget } from 'ckeditor5/src/widget.js';+import '../footnote.css';+export default class FootnoteEditing extends Plugin {+ static get requires(): readonly [typeof Widget, typeof Autoformat];+ /**+ * The root element of the document.+ */+ get rootElement(): RootElement;+ init(): void;+ /**+ * This method broadly deals with deletion of text and elements, and updating the model+ * accordingly. In particular, the following cases are handled:+ * 1. If the footnote section gets deleted, all footnote references are removed.+ * 2. If a delete operation happens in an empty footnote, the footnote is deleted.+ */+ private _handleDelete;+ /**+ * Clear the children of the provided footnoteContent element,+ * leaving an empty paragraph behind. This allows users to empty+ * a footnote without deleting it. modelWriter is passed in to+ * batch these changes with the ones that instantiated them,+ * such that the set can be undone with a single action.+ */+ private _clearContents;+ /**+ * Removes a footnote and its references, and renumbers subsequent footnotes. When a footnote's+ * id attribute changes, it's references automatically update from a dispatcher event in converters.js,+ * which triggers the `updateReferenceIds` method. modelWriter is passed in to batch these changes with+ * the ones that instantiated them, such that the set can be undone with a single action.+ */+ private _removeFootnote;+ /**+ * Deletes all references to the footnote with the given id. If no id is provided,+ * all references are deleted. modelWriter is passed in to batch these changes with+ * the ones that instantiated them, such that the set can be undone with a single action.+ */+ private _removeReferences;+ /**+ * Updates all references for a single footnote. This function is called when+ * the index attribute of an existing footnote changes, which happens when a footnote+ * with a lower index is deleted. batch is passed in to group these changes with+ * the ones that instantiated them.+ */+ private _updateReferenceIndices;+ /**+ * Reindexes footnotes such that footnote references occur in order, and reorders+ * footnote items in the footer section accordingly. batch is passed in to group changes with+ * the ones that instantiated them.+ */+ private _orderFootnotes;+}diff --git a/src/footnote-editing/schema.d.ts b/src/footnote-editing/schema.d.tsnew file mode 100644index 0000000000..c7d9308eb2--- /dev/null+++ b/src/footnote-editing/schema.d.ts@@ -0,0 +1,7 @@+import type { Schema } from 'ckeditor5/src/engine.js';+/**+ * Declares the custom element types used by the footnotes plugin.+ * See here for the meanings of each rule:+ * https://ckeditor.com/docs/ckeditor5/latest/api/module_engine_model_schema-SchemaItemDefinition.html#member-isObject+ */+export declare const defineSchema: (schema: Schema) => void;diff --git a/src/footnote-ui.d.ts b/src/footnote-ui.d.tsnew file mode 100644index 0000000000..f0589c6b8a--- /dev/null+++ b/src/footnote-ui.d.ts@@ -0,0 +1,7 @@+import { Plugin } from 'ckeditor5/src/core.js';+import { type ListDropdownItemDefinition } from '@ckeditor/ckeditor5-ui';+import { Collection } from '@ckeditor/ckeditor5-utils';+export default class FootnoteUI extends Plugin {+ init(): void;+ getDropdownItemsDefinitions(): Collection<ListDropdownItemDefinition>;+}diff --git a/src/footnotes.d.ts b/src/footnotes.d.tsnew file mode 100644index 0000000000..501fa31d69--- /dev/null+++ b/src/footnotes.d.ts@@ -0,0 +1,7 @@+import { Plugin } from 'ckeditor5/src/core.js';+import FootnoteEditing from './footnote-editing/footnote-editing.js';+import FootnoteUI from './footnote-ui.js';+export default class Footnotes extends Plugin {+ static get pluginName(): "Footnotes";+ static get requires(): readonly [typeof FootnoteEditing, typeof FootnoteUI];+}diff --git a/src/index.d.ts b/src/index.d.tsnew file mode 100644index 0000000000..a6d636908a--- /dev/null+++ b/src/index.d.ts@@ -0,0 +1,5 @@+import './augmentation.js';+export { default as Footnotes } from './footnotes.js';+export declare const icons: {+ insertFootnoteIcon: string;+};diff --git a/src/insert-footnote-command.d.ts b/src/insert-footnote-command.d.tsnew file mode 100644index 0000000000..f29c40f23d--- /dev/null+++ b/src/insert-footnote-command.d.ts@@ -0,0 +1,21 @@+import { Command } from 'ckeditor5/src/core.js';+export default class InsertFootnoteCommand extends Command {+ /**+ * Creates a footnote reference with the given index, and creates a matching+ * footnote if one doesn't already exist. Also creates the footnote section+ * if it doesn't exist. If `footnoteIndex` is 0 (or not provided), the added+ * footnote is given the next unused index--e.g. 7, if 6 footnotes exist so far.+ */+ execute({ footnoteIndex }?: {+ footnoteIndex?: number;+ }): void;+ /**+ * Called automatically when changes are applied to the document. Sets `isEnabled`+ * to determine whether footnote creation is allowed at the current location.+ */+ refresh(): void;+ /**+ * Returns the footnote section if it exists, or creates on if it doesn't.+ */+ private _getFootnoteSection;+}diff --git a/src/utils.d.ts b/src/utils.d.tsnew file mode 100644index 0000000000..a96965e0bc--- /dev/null+++ b/src/utils.d.ts@@ -0,0 +1,27 @@+import { type Editor } from 'ckeditor5/src/core.js';+import { Element, Text, TextProxy, ViewElement } from 'ckeditor5/src/engine.js';+/**+ * Returns an array of all descendant elements of+ * the root for which the provided predicate returns true.+ */+export declare const modelQueryElementsAll: (editor: Editor, rootElement: Element, predicate?: (item: Element) => boolean) => Array<Element>;+/**+ * Returns an array of all descendant text nodes and text proxies of+ * the root for which the provided predicate returns true.+ */+export declare const modelQueryTextAll: (editor: Editor, rootElement: Element, predicate?: (item: Text | TextProxy) => boolean) => Array<Text | TextProxy>;+/**+ * Returns the first descendant element of the root for which the provided+ * predicate returns true, or null if no such element is found.+ */+export declare const modelQueryElement: (editor: Editor, rootElement: Element, predicate?: (item: Element) => boolean) => Element | null;+/**+ * Returns the first descendant text node or text proxy of the root for which the provided+ * predicate returns true, or null if no such element is found.+ */+export declare const modelQueryText: (editor: Editor, rootElement: Element, predicate?: (item: Text | TextProxy) => boolean) => Text | TextProxy | null;+/**+ * Returns the first descendant element of the root for which the provided+ * predicate returns true, or null if no such element is found.+ */+export declare const viewQueryElement: (editor: Editor, rootElement: ViewElement, predicate?: (item: ViewElement) => boolean) => ViewElement | null;