mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-31 19:51:36 +08:00
fix(build): missing typings
This commit is contained in:
parent
271a7494f8
commit
bf34816950
@ -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",
|
||||
|
7
sample/ckeditor.d.ts
vendored
Normal file
7
sample/ckeditor.d.ts
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
declare global {
|
||||
interface Window {
|
||||
editor: ClassicEditor;
|
||||
}
|
||||
}
|
||||
import { ClassicEditor } from 'ckeditor5';
|
||||
import 'ckeditor5/ckeditor5.css';
|
6
src/augmentation.d.ts
vendored
Normal file
6
src/augmentation.d.ts
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
import type { Footnotes } from './index.js';
|
||||
declare module '@ckeditor/ckeditor5-core' {
|
||||
interface PluginsMap {
|
||||
[Footnotes.pluginName]: Footnotes;
|
||||
}
|
||||
}
|
31
src/constants.d.ts
vendored
Normal file
31
src/constants.d.ts
vendored
Normal file
@ -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;
|
||||
};
|
6
src/footnote-editing/auto-formatting.d.ts
vendored
Normal file
6
src/footnote-editing/auto-formatting.d.ts
vendored
Normal file
@ -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;
|
5
src/footnote-editing/converters.d.ts
vendored
Normal file
5
src/footnote-editing/converters.d.ts
vendored
Normal file
@ -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;
|
59
src/footnote-editing/footnote-editing.d.ts
vendored
Normal file
59
src/footnote-editing/footnote-editing.d.ts
vendored
Normal file
@ -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;
|
||||
}
|
7
src/footnote-editing/schema.d.ts
vendored
Normal file
7
src/footnote-editing/schema.d.ts
vendored
Normal file
@ -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;
|
7
src/footnote-ui.d.ts
vendored
Normal file
7
src/footnote-ui.d.ts
vendored
Normal file
@ -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>;
|
||||
}
|
7
src/footnotes.d.ts
vendored
Normal file
7
src/footnotes.d.ts
vendored
Normal file
@ -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];
|
||||
}
|
5
src/index.d.ts
vendored
Normal file
5
src/index.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
import './augmentation.js';
|
||||
export { default as Footnotes } from './footnotes.js';
|
||||
export declare const icons: {
|
||||
insertFootnoteIcon: string;
|
||||
};
|
21
src/insert-footnote-command.d.ts
vendored
Normal file
21
src/insert-footnote-command.d.ts
vendored
Normal file
@ -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;
|
||||
}
|
27
src/utils.d.ts
vendored
Normal file
27
src/utils.d.ts
vendored
Normal file
@ -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;
|
Loading…
x
Reference in New Issue
Block a user