stilo-editor 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +226 -2
- package/dist/characters--8h5uTeF.js +854 -0
- package/dist/content.css +398 -0
- package/dist/core/drop.d.ts +6 -0
- package/dist/core/editor.d.ts +120 -0
- package/dist/core/errors.d.ts +6 -0
- package/dist/core/events.d.ts +19 -0
- package/dist/core/extension-manager.d.ts +57 -0
- package/dist/core/extension.d.ts +48 -0
- package/dist/core/helpers/active.d.ts +33 -0
- package/dist/core/helpers/block-style.d.ts +25 -0
- package/dist/core/helpers/input-rules.d.ts +28 -0
- package/dist/core/helpers/lists.d.ts +20 -0
- package/dist/core/helpers/marks.d.ts +52 -0
- package/dist/core/helpers/nodes.d.ts +26 -0
- package/dist/core/helpers/parse-rules.d.ts +8 -0
- package/dist/core/helpers/word-count.d.ts +14 -0
- package/dist/core/html/css.d.ts +106 -0
- package/dist/core/html/parse.d.ts +7 -0
- package/dist/core/html/paste/base-styles.d.ts +7 -0
- package/dist/core/html/paste/google-docs.d.ts +7 -0
- package/dist/core/html/paste/index.d.ts +9 -0
- package/dist/core/html/paste/table-widths.d.ts +7 -0
- package/dist/core/html/paste/word.d.ts +8 -0
- package/dist/core/html/sanitize.d.ts +49 -0
- package/dist/core/html/serialize.d.ts +31 -0
- package/dist/core/types.d.ts +107 -0
- package/dist/extensions/blockquote/index.d.ts +15 -0
- package/dist/extensions/bold/index.d.ts +17 -0
- package/dist/extensions/bullet-list/index.d.ts +9 -0
- package/dist/extensions/clear-formatting/index.d.ts +12 -0
- package/dist/extensions/code/index.d.ts +15 -0
- package/dist/extensions/code-block/index.d.ts +24 -0
- package/dist/extensions/default-extensions/index.d.ts +57 -0
- package/dist/extensions/document/index.d.ts +17 -0
- package/dist/extensions/drop-cursor/index.d.ts +15 -0
- package/dist/extensions/gap-cursor/index.d.ts +6 -0
- package/dist/extensions/hard-break/index.d.ts +11 -0
- package/dist/extensions/heading/index.d.ts +25 -0
- package/dist/extensions/highlight/index.d.ts +24 -0
- package/dist/extensions/history/index.d.ts +21 -0
- package/dist/extensions/horizontal-rule/index.d.ts +11 -0
- package/dist/extensions/image/image-view.d.ts +27 -0
- package/dist/extensions/image/index.d.ts +29 -0
- package/dist/extensions/index.d.ts +36 -0
- package/dist/extensions/italic/index.d.ts +16 -0
- package/dist/extensions/line-height/index.d.ts +18 -0
- package/dist/extensions/link/index.d.ts +23 -0
- package/dist/extensions/list-item/index.d.ts +16 -0
- package/dist/extensions/move-block/index.d.ts +17 -0
- package/dist/extensions/ordered-list/index.d.ts +12 -0
- package/dist/extensions/paragraph/index.d.ts +14 -0
- package/dist/extensions/placeholder/index.d.ts +13 -0
- package/dist/extensions/search/index.d.ts +55 -0
- package/dist/extensions/strike/index.d.ts +16 -0
- package/dist/extensions/subscript/index.d.ts +16 -0
- package/dist/extensions/superscript/index.d.ts +17 -0
- package/dist/extensions/table/index.d.ts +70 -0
- package/dist/extensions/task-item/index.d.ts +24 -0
- package/dist/extensions/task-item/task-item-view.d.ts +24 -0
- package/dist/extensions/task-list/index.d.ts +11 -0
- package/dist/extensions/text/index.d.ts +12 -0
- package/dist/extensions/text-align/index.d.ts +18 -0
- package/dist/extensions/text-case/index.d.ts +14 -0
- package/dist/extensions/text-style/font-size.d.ts +21 -0
- package/dist/extensions/text-style/index.d.ts +30 -0
- package/dist/extensions/underline/index.d.ts +15 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +1 -0
- package/dist/src-CV6pgfTS.js +2662 -0
- package/dist/style.css +1395 -0
- package/dist/ui/components/character-picker.d.ts +22 -0
- package/dist/ui/components/characters.d.ts +10 -0
- package/dist/ui/components/color-button.d.ts +23 -0
- package/dist/ui/components/dropdown.d.ts +34 -0
- package/dist/ui/components/find-bar.d.ts +24 -0
- package/dist/ui/components/font-size-input.d.ts +21 -0
- package/dist/ui/components/icon-menu.d.ts +20 -0
- package/dist/ui/components/icon.d.ts +3 -0
- package/dist/ui/components/link-bubble.d.ts +19 -0
- package/dist/ui/components/link-popover.d.ts +20 -0
- package/dist/ui/components/popover.d.ts +27 -0
- package/dist/ui/components/shortcut.d.ts +11 -0
- package/dist/ui/components/status-bar.d.ts +19 -0
- package/dist/ui/components/table-actions.d.ts +25 -0
- package/dist/ui/components/table-handles.d.ts +16 -0
- package/dist/ui/components/table-menu.d.ts +21 -0
- package/dist/ui/i18n/en.d.ts +3 -0
- package/dist/ui/i18n/it.d.ts +3 -0
- package/dist/ui/i18n/types.d.ts +4 -0
- package/dist/ui/index.d.ts +23 -0
- package/dist/ui/toolbar/fonts.d.ts +8 -0
- package/dist/ui/toolbar/items.d.ts +33 -0
- package/dist/ui/toolbar/palette.d.ts +6 -0
- package/dist/ui/toolbar/toolbar.d.ts +28 -0
- package/dist/ui/toolbar/types.d.ts +150 -0
- package/dist/ui.css +996 -0
- package/dist/ui.js +2350 -0
- package/package.json +96 -4
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { Extension } from '../../core/extension';
|
|
2
|
+
import { type DropCursorOptions } from '../drop-cursor';
|
|
3
|
+
import { type HeadingOptions } from '../heading';
|
|
4
|
+
import { type HistoryOptions } from '../history';
|
|
5
|
+
import { type ImageOptions } from '../image';
|
|
6
|
+
import { type PlaceholderOptions } from '../placeholder';
|
|
7
|
+
import { type SearchOptions } from '../search';
|
|
8
|
+
/**
|
|
9
|
+
* Options of {@link defaultExtensions}, by extension name: `false` disables the extension, an object
|
|
10
|
+
* configures it. Extensions without options accept only `false`.
|
|
11
|
+
*/
|
|
12
|
+
export interface DefaultExtensionsOptions {
|
|
13
|
+
doc?: false;
|
|
14
|
+
text?: false;
|
|
15
|
+
paragraph?: false;
|
|
16
|
+
heading?: false | Partial<HeadingOptions>;
|
|
17
|
+
blockquote?: false;
|
|
18
|
+
codeBlock?: false;
|
|
19
|
+
horizontalRule?: false;
|
|
20
|
+
image?: false | Partial<ImageOptions>;
|
|
21
|
+
table?: false;
|
|
22
|
+
hardBreak?: false;
|
|
23
|
+
bulletList?: false;
|
|
24
|
+
orderedList?: false;
|
|
25
|
+
listItem?: false;
|
|
26
|
+
taskList?: false;
|
|
27
|
+
taskItem?: false;
|
|
28
|
+
bold?: false;
|
|
29
|
+
italic?: false;
|
|
30
|
+
underline?: false;
|
|
31
|
+
strike?: false;
|
|
32
|
+
subscript?: false;
|
|
33
|
+
superscript?: false;
|
|
34
|
+
code?: false;
|
|
35
|
+
link?: false;
|
|
36
|
+
textStyle?: false;
|
|
37
|
+
textAlign?: false;
|
|
38
|
+
lineHeight?: false;
|
|
39
|
+
highlight?: false;
|
|
40
|
+
clearFormatting?: false;
|
|
41
|
+
textCase?: false;
|
|
42
|
+
history?: false | Partial<HistoryOptions>;
|
|
43
|
+
moveBlock?: false;
|
|
44
|
+
placeholder?: false | Partial<PlaceholderOptions>;
|
|
45
|
+
search?: false | Partial<SearchOptions>;
|
|
46
|
+
dropCursor?: false | Partial<DropCursorOptions>;
|
|
47
|
+
gapCursor?: false;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The default extension set (docs/ARCHITECTURE.md §6.3). M1 extensions are added here as they
|
|
51
|
+
* are implemented.
|
|
52
|
+
*
|
|
53
|
+
* ```ts
|
|
54
|
+
* new Editor({ element, extensions: [defaultExtensions({ bold: false })] });
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function defaultExtensions(options?: DefaultExtensionsOptions): Extension[];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Command } from 'prosemirror-state';
|
|
2
|
+
declare module '../../core/types' {
|
|
3
|
+
interface Commands {
|
|
4
|
+
/**
|
|
5
|
+
* Selects the text from `from` to `to` (document positions; `to` defaults to `from`, a
|
|
6
|
+
* cursor). A position outside text moves to the nearest text position. Returns `false` when
|
|
7
|
+
* a position is outside the document.
|
|
8
|
+
*/
|
|
9
|
+
select: (from: number, to?: number) => Command;
|
|
10
|
+
/** Selects the node that starts at `pos`. Returns `false` when there is no selectable node. */
|
|
11
|
+
selectNode: (pos: number) => Command;
|
|
12
|
+
/** Selects the whole document. */
|
|
13
|
+
selectAll: () => Command;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/** The top-level `doc` node: one or more blocks. Provides the selection commands. */
|
|
17
|
+
export declare const Document: (options?: Partial<Record<string, never>> | undefined) => import("../..").Extension<Record<string, never>>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Options of {@link DropCursor}. */
|
|
2
|
+
export interface DropCursorOptions {
|
|
3
|
+
/** CSS color of the cursor. `false` = no inline color; style with `class`. Default: `'currentColor'`. */
|
|
4
|
+
color: string | false;
|
|
5
|
+
/** Width in pixels. Default: `1`. */
|
|
6
|
+
width: number;
|
|
7
|
+
/** Extra CSS class of the cursor element. No default. */
|
|
8
|
+
class?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Shows a line where a dragged item would be dropped, docs/SPEC.md F-012.
|
|
12
|
+
*
|
|
13
|
+
* Wraps `prosemirror-dropcursor`; everything is handled by the package.
|
|
14
|
+
*/
|
|
15
|
+
export declare const DropCursor: (options?: Partial<DropCursorOptions> | undefined) => import("../..").Extension<DropCursorOptions>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a gap cursor where no text cursor can go, docs/SPEC.md F-012.
|
|
3
|
+
*
|
|
4
|
+
* Wraps `prosemirror-gapcursor`; everything is handled by the package.
|
|
5
|
+
*/
|
|
6
|
+
export declare const GapCursor: (options?: Partial<Record<string, never>> | undefined) => import("../..").Extension<Record<string, never>>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Command } from 'prosemirror-state';
|
|
2
|
+
declare module '../../core/types' {
|
|
3
|
+
interface Commands {
|
|
4
|
+
/** Inserts a hard break (`<br>`) at the cursor. */
|
|
5
|
+
setHardBreak: () => Command;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The `hardBreak` node (`<br>`), docs/SPEC.md F-305.
|
|
10
|
+
*/
|
|
11
|
+
export declare const HardBreak: (options?: Partial<Record<string, never>> | undefined) => import("../..").Extension<Record<string, never>>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Command } from 'prosemirror-state';
|
|
2
|
+
declare module '../../core/types' {
|
|
3
|
+
interface Commands {
|
|
4
|
+
/** Turns the selected textblocks into a heading of the given level. */
|
|
5
|
+
setHeading: (attrs: {
|
|
6
|
+
level: HeadingLevel;
|
|
7
|
+
}) => Command;
|
|
8
|
+
/** Toggles the heading level: removes it when the whole selection matches, otherwise sets it. */
|
|
9
|
+
toggleHeading: (attrs: {
|
|
10
|
+
level: HeadingLevel;
|
|
11
|
+
}) => Command;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/** A heading level. */
|
|
15
|
+
export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
16
|
+
/** Options of {@link Heading}. */
|
|
17
|
+
export interface HeadingOptions {
|
|
18
|
+
/** Allowed levels. Default: all six. */
|
|
19
|
+
levels: HeadingLevel[];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The `heading` node (`<h1>`…`<h6>`, with `style` for its alignment and line height),
|
|
23
|
+
* docs/SPEC.md F-302.
|
|
24
|
+
*/
|
|
25
|
+
export declare const Heading: (options?: Partial<HeadingOptions> | undefined) => import("../..").Extension<HeadingOptions>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Command } from 'prosemirror-state';
|
|
2
|
+
/** Attributes of the `highlight` mark. */
|
|
3
|
+
export interface HighlightAttributes {
|
|
4
|
+
/** Background color; omitted or `null` for a plain `<mark>` (the browser's yellow). */
|
|
5
|
+
color?: string | null;
|
|
6
|
+
}
|
|
7
|
+
declare module '../../core/types' {
|
|
8
|
+
interface Commands {
|
|
9
|
+
/** Highlights the selection. Returns `false` when `color` is not a valid CSS color. */
|
|
10
|
+
setHighlight: (attributes?: HighlightAttributes) => Command;
|
|
11
|
+
/** Removes the highlight from the selection. */
|
|
12
|
+
unsetHighlight: () => Command;
|
|
13
|
+
/**
|
|
14
|
+
* Removes the highlight if the whole selection is highlighted (with `attributes.color` when
|
|
15
|
+
* `attributes` is given), otherwise sets it.
|
|
16
|
+
*/
|
|
17
|
+
toggleHighlight: (attributes?: HighlightAttributes) => Command;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The `highlight` mark (`<mark>`, or `<mark style="background-color: x">` with a color),
|
|
22
|
+
* docs/SPEC.md F-209. Also parsed from a `background-color` style.
|
|
23
|
+
*/
|
|
24
|
+
export declare const Highlight: (options?: Partial<Record<string, never>> | undefined) => import("../..").Extension<Record<string, never>>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Command } from 'prosemirror-state';
|
|
2
|
+
declare module '../../core/types' {
|
|
3
|
+
interface Commands {
|
|
4
|
+
/** Undoes the last change. */
|
|
5
|
+
undo: () => Command;
|
|
6
|
+
/** Redoes the last undone change. */
|
|
7
|
+
redo: () => Command;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/** Options of {@link History}. */
|
|
11
|
+
export interface HistoryOptions {
|
|
12
|
+
/** Maximum number of undo steps kept (approximately). Default: 100. */
|
|
13
|
+
depth: number;
|
|
14
|
+
/** Changes closer in time than this (ms) and adjacent are grouped in one step. Default: 500. */
|
|
15
|
+
newGroupDelay: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Undo/redo with `prosemirror-history`, docs/SPEC.md F-101, F-102. Swappable: another extension
|
|
19
|
+
* (e.g. collaboration) may provide `undo`/`redo` instead.
|
|
20
|
+
*/
|
|
21
|
+
export declare const History: (options?: Partial<HistoryOptions> | undefined) => import("../..").Extension<HistoryOptions>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Command } from 'prosemirror-state';
|
|
2
|
+
declare module '../../core/types' {
|
|
3
|
+
interface Commands {
|
|
4
|
+
/** Inserts a horizontal rule at the cursor. */
|
|
5
|
+
setHorizontalRule: () => Command;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The `horizontalRule` node (`<hr>`), docs/SPEC.md F-304.
|
|
10
|
+
*/
|
|
11
|
+
export declare const HorizontalRule: (options?: Partial<Record<string, never>> | undefined) => import("../..").Extension<Record<string, never>>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Node } from 'prosemirror-model';
|
|
2
|
+
import type { EditorView, NodeView } from 'prosemirror-view';
|
|
3
|
+
/** The HTML attributes of an `image` node, in output order, without the empty ones. */
|
|
4
|
+
export declare function imageAttributes(node: Node): Record<string, string>;
|
|
5
|
+
/**
|
|
6
|
+
* The `image` node in the editor: the `<img>` inside a `span.stilo-image` with two side handles,
|
|
7
|
+
* shown while the image is selected (docs/SPEC.md F-607). Dragging a handle changes the width
|
|
8
|
+
* and keeps the aspect ratio; releasing it sets `width` and `height` in one transaction.
|
|
9
|
+
*/
|
|
10
|
+
export declare class ImageView implements NodeView {
|
|
11
|
+
private readonly view;
|
|
12
|
+
private readonly getPos;
|
|
13
|
+
readonly dom: HTMLElement;
|
|
14
|
+
private readonly img;
|
|
15
|
+
private node;
|
|
16
|
+
constructor(node: Node, view: EditorView, getPos: () => number | undefined);
|
|
17
|
+
update(node: Node): boolean;
|
|
18
|
+
/** The handles handle their own pointer events: ProseMirror must not select or drag. */
|
|
19
|
+
stopEvent(event: Event): boolean;
|
|
20
|
+
/** The view changes only the inline width of the `<img>` while a handle is dragged. */
|
|
21
|
+
ignoreMutation(): boolean;
|
|
22
|
+
private render;
|
|
23
|
+
private createHandle;
|
|
24
|
+
private startResize;
|
|
25
|
+
/** Sets `width` and `height`; attribute steps keep the image selected. */
|
|
26
|
+
private setSize;
|
|
27
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Editor } from '../../core/editor';
|
|
2
|
+
declare module '../../core/types' {
|
|
3
|
+
interface EditorEvents {
|
|
4
|
+
/**
|
|
5
|
+
* A pasted image file was not inserted: larger than `maxInlineBytes` (`tooLarge`), or not a
|
|
6
|
+
* PNG, JPEG, GIF or WebP image (`unsupportedType`).
|
|
7
|
+
*/
|
|
8
|
+
imageRejected: {
|
|
9
|
+
editor: Editor;
|
|
10
|
+
file: File;
|
|
11
|
+
reason: 'tooLarge' | 'unsupportedType';
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/** Options of {@link Image}. */
|
|
16
|
+
export interface ImageOptions {
|
|
17
|
+
/** Largest image file, in bytes, that paste inserts as a data URL. Default: 5 MB. */
|
|
18
|
+
maxInlineBytes: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The `image` node (`<img src alt title width height>`, inline), docs/SPEC.md F-601, with the
|
|
22
|
+
* paste of image files (F-603, F-608) and the resize handles (F-607).
|
|
23
|
+
*
|
|
24
|
+
* Paste: when the clipboard has HTML, ProseMirror pastes it (an image copied from a web page keeps
|
|
25
|
+
* its URL); otherwise each image file becomes an `image` with a base64 `data:` URL, in place of
|
|
26
|
+
* the selection at the time the files have been read. A file larger than `maxInlineBytes` or of
|
|
27
|
+
* another type is skipped and reported with the `imageRejected` event.
|
|
28
|
+
*/
|
|
29
|
+
export declare const Image: (options?: Partial<ImageOptions> | undefined) => import("../..").Extension<ImageOptions>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export { Blockquote } from './blockquote';
|
|
2
|
+
export { Bold } from './bold';
|
|
3
|
+
export { BulletList } from './bullet-list';
|
|
4
|
+
export { ClearFormatting } from './clear-formatting';
|
|
5
|
+
export { Code } from './code';
|
|
6
|
+
export { CodeBlock, type CodeBlockAttributes } from './code-block';
|
|
7
|
+
export { type DefaultExtensionsOptions, defaultExtensions } from './default-extensions';
|
|
8
|
+
export { Document } from './document';
|
|
9
|
+
export { DropCursor, type DropCursorOptions } from './drop-cursor';
|
|
10
|
+
export { GapCursor } from './gap-cursor';
|
|
11
|
+
export { HardBreak } from './hard-break';
|
|
12
|
+
export { Heading, type HeadingLevel, type HeadingOptions } from './heading';
|
|
13
|
+
export { Highlight, type HighlightAttributes } from './highlight';
|
|
14
|
+
export { History, type HistoryOptions } from './history';
|
|
15
|
+
export { HorizontalRule } from './horizontal-rule';
|
|
16
|
+
export { Image, type ImageOptions } from './image';
|
|
17
|
+
export { Italic } from './italic';
|
|
18
|
+
export { LineHeight } from './line-height';
|
|
19
|
+
export { Link, type LinkAttributes } from './link';
|
|
20
|
+
export { ListItem } from './list-item';
|
|
21
|
+
export { MoveBlock } from './move-block';
|
|
22
|
+
export { OrderedList } from './ordered-list';
|
|
23
|
+
export { Paragraph } from './paragraph';
|
|
24
|
+
export { Placeholder, type PlaceholderOptions } from './placeholder';
|
|
25
|
+
export { getSearchResults, Search, type SearchOptions, type SearchResults, type SearchTerm, } from './search';
|
|
26
|
+
export { Strike } from './strike';
|
|
27
|
+
export { Subscript } from './subscript';
|
|
28
|
+
export { Superscript } from './superscript';
|
|
29
|
+
export { getTableHeaders, type InsertTableOptions, Table, type TableHeaders, } from './table';
|
|
30
|
+
export { TaskItem } from './task-item';
|
|
31
|
+
export { TaskList } from './task-list';
|
|
32
|
+
export { Text } from './text';
|
|
33
|
+
export { TextAlign, type TextAlignment } from './text-align';
|
|
34
|
+
export { type LetterCase, TextCase } from './text-case';
|
|
35
|
+
export { type FontSizeUnit, getFontSize, TextStyle, toFontSize } from './text-style';
|
|
36
|
+
export { Underline } from './underline';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Command } from 'prosemirror-state';
|
|
2
|
+
declare module '../../core/types' {
|
|
3
|
+
interface Commands {
|
|
4
|
+
/** Adds italic to the selection. */
|
|
5
|
+
setItalic: () => Command;
|
|
6
|
+
/** Removes italic from the selection. */
|
|
7
|
+
unsetItalic: () => Command;
|
|
8
|
+
/** Removes italic if the whole selection is italic, otherwise adds it. */
|
|
9
|
+
toggleItalic: () => Command;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The `italic` mark (`<em>`), docs/SPEC.md F-202. Also parsed from `<i>` and an italic
|
|
14
|
+
* `font-style`.
|
|
15
|
+
*/
|
|
16
|
+
export declare const Italic: (options?: Partial<Record<string, never>> | undefined) => import("../..").Extension<Record<string, never>>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Command } from 'prosemirror-state';
|
|
2
|
+
declare module '../../core/types' {
|
|
3
|
+
interface Commands {
|
|
4
|
+
/**
|
|
5
|
+
* Sets the line height of the selected paragraphs and headings: a number (`1.5`) or a
|
|
6
|
+
* percentage (`'150%'`). `false` for another value, or when no selected block has one.
|
|
7
|
+
*/
|
|
8
|
+
setLineHeight: (lineHeight: number | string) => Command;
|
|
9
|
+
/** Removes the line height of the selected paragraphs and headings. */
|
|
10
|
+
unsetLineHeight: () => Command;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Line spacing of paragraphs and headings (docs/SPEC.md F-312): the commands. The `lineHeight`
|
|
15
|
+
* attribute itself belongs to the `paragraph` and `heading` nodes, so content keeps its line
|
|
16
|
+
* spacing without this extension.
|
|
17
|
+
*/
|
|
18
|
+
export declare const LineHeight: (options?: Partial<Record<string, never>> | undefined) => import("../..").Extension<Record<string, never>>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Command } from 'prosemirror-state';
|
|
2
|
+
/** Attributes of the `link` mark. */
|
|
3
|
+
export interface LinkAttributes {
|
|
4
|
+
href: string;
|
|
5
|
+
/** `'_blank'` opens the link in a new tab; omitted or `null` for none. */
|
|
6
|
+
target?: '_blank' | null;
|
|
7
|
+
}
|
|
8
|
+
declare module '../../core/types' {
|
|
9
|
+
interface Commands {
|
|
10
|
+
/**
|
|
11
|
+
* Links the selection, or updates the whole link at the cursor. Returns `false` when `href`
|
|
12
|
+
* is empty or not allowed, or with a cursor outside a link.
|
|
13
|
+
*/
|
|
14
|
+
setLink: (attributes: LinkAttributes) => Command;
|
|
15
|
+
/** Removes links from the selection, or the whole link at the cursor. */
|
|
16
|
+
unsetLink: () => Command;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The `link` mark (`<a href target rel>`), docs/SPEC.md F-206. `rel="noopener noreferrer
|
|
21
|
+
* nofollow"` is written when `target="_blank"`. No shortcut: `Mod-k` belongs to the link popover.
|
|
22
|
+
*/
|
|
23
|
+
export declare const Link: (options?: Partial<Record<string, never>> | undefined) => import("../..").Extension<Record<string, never>>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Command } from 'prosemirror-state';
|
|
2
|
+
declare module '../../core/types' {
|
|
3
|
+
interface Commands {
|
|
4
|
+
/** Splits the list item at the cursor; in an empty item, lifts it out of the list. */
|
|
5
|
+
splitListItem: () => Command;
|
|
6
|
+
/** Nests the selected list items one level deeper. */
|
|
7
|
+
sinkListItem: () => Command;
|
|
8
|
+
/** Lifts the selected list items one level up (out of the list at the top level). */
|
|
9
|
+
liftListItem: () => Command;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The `listItem` node (`<li>`), docs/SPEC.md F-403, F-404. Required by `BulletList` and
|
|
14
|
+
* `OrderedList`.
|
|
15
|
+
*/
|
|
16
|
+
export declare const ListItem: (options?: Partial<Record<string, never>> | undefined) => import("../..").Extension<Record<string, never>>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Command } from 'prosemirror-state';
|
|
2
|
+
declare module '../../core/types' {
|
|
3
|
+
interface Commands {
|
|
4
|
+
/** Moves the block (or list item) at the selection one place up among its siblings. */
|
|
5
|
+
moveBlockUp: () => Command;
|
|
6
|
+
/** Moves the block (or list item) at the selection one place down among its siblings. */
|
|
7
|
+
moveBlockDown: () => Command;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Move block up / down among siblings (F-309).
|
|
12
|
+
*
|
|
13
|
+
* The movable unit is the innermost ancestor that is a list or container:
|
|
14
|
+
* the children of that ancestor covered by the selection.
|
|
15
|
+
* Uses the "move the neighbor" approach to keep the selection intact.
|
|
16
|
+
*/
|
|
17
|
+
export declare const MoveBlock: (options?: Partial<Record<string, never>> | undefined) => import("../..").Extension<Record<string, never>>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Command } from 'prosemirror-state';
|
|
2
|
+
declare module '../../core/types' {
|
|
3
|
+
interface Commands {
|
|
4
|
+
/** Wraps the selection in an ordered list, lifts it out, or converts another list type. */
|
|
5
|
+
toggleOrderedList: () => Command;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The `orderedList` node (`<ol start="n">`, `start` omitted when 1), docs/SPEC.md F-402, F-405.
|
|
10
|
+
* Requires `ListItem`.
|
|
11
|
+
*/
|
|
12
|
+
export declare const OrderedList: (options?: Partial<Record<string, never>> | undefined) => import("../..").Extension<Record<string, never>>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Command } from 'prosemirror-state';
|
|
2
|
+
declare module '../../core/types' {
|
|
3
|
+
interface Commands {
|
|
4
|
+
/** Turns the selected textblocks into paragraphs. */
|
|
5
|
+
setParagraph: () => Command;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The `paragraph` node (`<p>`, with `style` for its alignment and line height). Priority 1000
|
|
10
|
+
* makes it the first block node, which ProseMirror uses as the default block. `<div>` needs no
|
|
11
|
+
* parse rule: ProseMirror treats it as a block wrapper and wraps its loose inline content in
|
|
12
|
+
* paragraphs (the `div` fallback of docs/ARCHITECTURE.md §7.1).
|
|
13
|
+
*/
|
|
14
|
+
export declare const Paragraph: (options?: Partial<Record<string, never>> | undefined) => import("../..").Extension<Record<string, never>>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Options of {@link Placeholder}. */
|
|
2
|
+
export interface PlaceholderOptions {
|
|
3
|
+
/** The hint text shown when the document is empty. Default: `''` (no placeholder). */
|
|
4
|
+
placeholder: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Shows a hint text when the document is empty, docs/SPEC.md F-011.
|
|
8
|
+
*
|
|
9
|
+
* The empty paragraph gets a node decoration with `class="stilo-placeholder"` and
|
|
10
|
+
* `data-placeholder="<the text>"`. "Empty" follows `Editor.isEmpty`: one child,
|
|
11
|
+
* a `paragraph`, with content size 0.
|
|
12
|
+
*/
|
|
13
|
+
export declare const Placeholder: (options?: Partial<PlaceholderOptions> | undefined) => import("../..").Extension<PlaceholderOptions>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type Command } from 'prosemirror-state';
|
|
2
|
+
import type { Editor } from '../../core/editor';
|
|
3
|
+
declare module '../../core/types' {
|
|
4
|
+
interface Commands {
|
|
5
|
+
/** Searches for `term` and highlights the matches; an empty `text` clears the search. */
|
|
6
|
+
setSearch: (term: SearchTerm) => Command;
|
|
7
|
+
/** Clears the search and its highlights. */
|
|
8
|
+
clearSearch: () => Command;
|
|
9
|
+
/** Selects the next match after the selection, wrapping at the end of the document. */
|
|
10
|
+
findNext: () => Command;
|
|
11
|
+
/** Selects the match before the selection, wrapping at the start of the document. */
|
|
12
|
+
findPrevious: () => Command;
|
|
13
|
+
/** Replaces the selected match with `replacement` and selects the next one. */
|
|
14
|
+
replaceNext: (replacement: string) => Command;
|
|
15
|
+
/** Replaces every match with `replacement`, in one undoable step. */
|
|
16
|
+
replaceAll: (replacement: string) => Command;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/** What {@link Search} looks for. */
|
|
20
|
+
export interface SearchTerm {
|
|
21
|
+
/** The text to find, taken literally. */
|
|
22
|
+
text: string;
|
|
23
|
+
/** Default: `false`. */
|
|
24
|
+
caseSensitive?: boolean;
|
|
25
|
+
/** Matches only whole words. Default: `false`. */
|
|
26
|
+
wholeWord?: boolean;
|
|
27
|
+
}
|
|
28
|
+
/** Options of {@link Search}. */
|
|
29
|
+
export interface SearchOptions {
|
|
30
|
+
/** Highlights at most the first this many matches; all are counted. Default: 1000. */
|
|
31
|
+
maxMatches: number;
|
|
32
|
+
}
|
|
33
|
+
/** The matches of the active search, from {@link getSearchResults}. */
|
|
34
|
+
export interface SearchResults {
|
|
35
|
+
/** The number of matches in the document. */
|
|
36
|
+
count: number;
|
|
37
|
+
/** `true` when only the first `maxMatches` matches are highlighted. */
|
|
38
|
+
limited: boolean;
|
|
39
|
+
/** The 1-based index of the selected match; 0 when the selection is not a match. */
|
|
40
|
+
current: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The matches of the active search of `editor`: how many there are, whether only some are
|
|
44
|
+
* highlighted, and which one is selected. All zero without a search or without the
|
|
45
|
+
* {@link Search} extension.
|
|
46
|
+
*/
|
|
47
|
+
export declare function getSearchResults(editor: Editor): SearchResults;
|
|
48
|
+
/**
|
|
49
|
+
* Find and replace, docs/SPEC.md F-902 (ADR 0004). Matching follows `SearchQuery` of
|
|
50
|
+
* `prosemirror-search` (literal text, case, whole word); the matches get
|
|
51
|
+
* `class="stilo-search-match"`, the selected one also `stilo-search-match--current`.
|
|
52
|
+
* Setting a search scans and counts the whole document once; later edits rescan only the
|
|
53
|
+
* changed textblocks.
|
|
54
|
+
*/
|
|
55
|
+
export declare const Search: (options?: Partial<SearchOptions> | undefined) => import("../..").Extension<SearchOptions>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Command } from 'prosemirror-state';
|
|
2
|
+
declare module '../../core/types' {
|
|
3
|
+
interface Commands {
|
|
4
|
+
/** Adds strike-through to the selection. */
|
|
5
|
+
setStrike: () => Command;
|
|
6
|
+
/** Removes strike-through from the selection. */
|
|
7
|
+
unsetStrike: () => Command;
|
|
8
|
+
/** Removes strike-through if the whole selection is struck through, otherwise adds it. */
|
|
9
|
+
toggleStrike: () => Command;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The `strike` mark (`<s>`), docs/SPEC.md F-204. Also parsed from `<del>`, `<strike>` and a
|
|
14
|
+
* `text-decoration: line-through`.
|
|
15
|
+
*/
|
|
16
|
+
export declare const Strike: (options?: Partial<Record<string, never>> | undefined) => import("../..").Extension<Record<string, never>>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Command } from 'prosemirror-state';
|
|
2
|
+
declare module '../../core/types' {
|
|
3
|
+
interface Commands {
|
|
4
|
+
/** Makes the selection subscript (replacing superscript). */
|
|
5
|
+
setSubscript: () => Command;
|
|
6
|
+
/** Removes subscript from the selection. */
|
|
7
|
+
unsetSubscript: () => Command;
|
|
8
|
+
/** Removes subscript if the whole selection is subscript, otherwise adds it. */
|
|
9
|
+
toggleSubscript: () => Command;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The `subscript` mark (`<sub>`), docs/SPEC.md F-207. Also parsed from `vertical-align: sub`.
|
|
14
|
+
* Subscript and superscript exclude each other through the mark group `script`.
|
|
15
|
+
*/
|
|
16
|
+
export declare const Subscript: (options?: Partial<Record<string, never>> | undefined) => import("../..").Extension<Record<string, never>>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Command } from 'prosemirror-state';
|
|
2
|
+
declare module '../../core/types' {
|
|
3
|
+
interface Commands {
|
|
4
|
+
/** Makes the selection superscript (replacing subscript). */
|
|
5
|
+
setSuperscript: () => Command;
|
|
6
|
+
/** Removes superscript from the selection. */
|
|
7
|
+
unsetSuperscript: () => Command;
|
|
8
|
+
/** Removes superscript if the whole selection is superscript, otherwise adds it. */
|
|
9
|
+
toggleSuperscript: () => Command;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The `superscript` mark (`<sup>`), docs/SPEC.md F-207. Also parsed from
|
|
14
|
+
* `vertical-align: super`. Subscript and superscript exclude each other through the mark group
|
|
15
|
+
* `script`.
|
|
16
|
+
*/
|
|
17
|
+
export declare const Superscript: (options?: Partial<Record<string, never>> | undefined) => import("../..").Extension<Record<string, never>>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type Command } from 'prosemirror-state';
|
|
2
|
+
import { type Editor } from '../../core/editor';
|
|
3
|
+
declare module '../../core/types' {
|
|
4
|
+
interface Commands {
|
|
5
|
+
/**
|
|
6
|
+
* Inserts a table in place of the selection, the cursor in its first cell. `false` inside a
|
|
7
|
+
* table, or for `rows` / `cols` that are not whole numbers ≥ 1.
|
|
8
|
+
*/
|
|
9
|
+
insertTable: (options?: InsertTableOptions) => Command;
|
|
10
|
+
/** Deletes the table around the selection. */
|
|
11
|
+
deleteTable: () => Command;
|
|
12
|
+
/** Adds a row above the selected cells. */
|
|
13
|
+
addRowBefore: () => Command;
|
|
14
|
+
/** Adds a row below the selected cells. */
|
|
15
|
+
addRowAfter: () => Command;
|
|
16
|
+
/** Deletes the rows of the selected cells; `false` when they are all the rows. */
|
|
17
|
+
deleteRow: () => Command;
|
|
18
|
+
/** Adds a column left of the selected cells. */
|
|
19
|
+
addColumnBefore: () => Command;
|
|
20
|
+
/** Adds a column right of the selected cells. */
|
|
21
|
+
addColumnAfter: () => Command;
|
|
22
|
+
/** Deletes the columns of the selected cells; `false` when they are all the columns. */
|
|
23
|
+
deleteColumn: () => Command;
|
|
24
|
+
/** Merges the selected cells into one (a rectangle of at least two cells). */
|
|
25
|
+
mergeCells: () => Command;
|
|
26
|
+
/** Splits a merged cell back into single cells. */
|
|
27
|
+
splitCell: () => Command;
|
|
28
|
+
/** Turns the first row into header cells (`<th>`), or back. */
|
|
29
|
+
toggleHeaderRow: () => Command;
|
|
30
|
+
/** Turns the first column into header cells (`<th>`), or back. */
|
|
31
|
+
toggleHeaderColumn: () => Command;
|
|
32
|
+
/**
|
|
33
|
+
* Selects the cells of the row of the cell around `pos` (default: the selection's head);
|
|
34
|
+
* `false` outside a table.
|
|
35
|
+
*/
|
|
36
|
+
selectRow: (pos?: number) => Command;
|
|
37
|
+
/** Selects the cells of the column of the cell around `pos`, as `selectRow`. */
|
|
38
|
+
selectColumn: (pos?: number) => Command;
|
|
39
|
+
/** Selects every cell of the table around `pos`, as `selectRow`. */
|
|
40
|
+
selectTable: (pos?: number) => Command;
|
|
41
|
+
/** Moves the cursor to the next cell; in the last cell, adds a row first. */
|
|
42
|
+
goToNextCell: () => Command;
|
|
43
|
+
/** Moves the cursor to the previous cell. */
|
|
44
|
+
goToPreviousCell: () => Command;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/** Options of the `insertTable` command. */
|
|
48
|
+
export interface InsertTableOptions {
|
|
49
|
+
/** Number of rows, header row included. Default: 3. */
|
|
50
|
+
rows?: number;
|
|
51
|
+
/** Number of columns. Default: 3. */
|
|
52
|
+
cols?: number;
|
|
53
|
+
/** Makes the first row of header cells (`<th>`). Default: `true`. */
|
|
54
|
+
withHeaderRow?: boolean;
|
|
55
|
+
}
|
|
56
|
+
/** Whether the first row and the first column of a table are made of header cells. */
|
|
57
|
+
export interface TableHeaders {
|
|
58
|
+
row: boolean;
|
|
59
|
+
column: boolean;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Whether the first row and the first column of the table around the selection are made of
|
|
63
|
+
* header cells; `null` outside a table. For a UI showing the state of the header toggles.
|
|
64
|
+
*/
|
|
65
|
+
export declare function getTableHeaders(editor: Editor): TableHeaders | null;
|
|
66
|
+
/**
|
|
67
|
+
* The `table`, `tableRow`, `tableCell` and `tableHeader` nodes (`<table><tbody><tr><td|th>`),
|
|
68
|
+
* on `prosemirror-tables`, docs/SPEC.md F-501…F-507. Column widths: docs/decisions/0005.
|
|
69
|
+
*/
|
|
70
|
+
export declare const Table: (options?: Partial<Record<string, never>> | undefined) => import("../..").Extension<Record<string, never>>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type Command } from 'prosemirror-state';
|
|
2
|
+
declare module '../../core/types' {
|
|
3
|
+
interface Commands {
|
|
4
|
+
/**
|
|
5
|
+
* Splits the task item at the cursor: the text keeps the item's state, a new empty item is
|
|
6
|
+
* unchecked. In an empty item, lifts it.
|
|
7
|
+
*/
|
|
8
|
+
splitTaskItem: () => Command;
|
|
9
|
+
/** Nests the selected task items one level deeper. */
|
|
10
|
+
sinkTaskItem: () => Command;
|
|
11
|
+
/** Lifts the selected task items one level up (out of the list at the top level). */
|
|
12
|
+
liftTaskItem: () => Command;
|
|
13
|
+
/**
|
|
14
|
+
* Checks the selected task items, or unchecks them when all are checked. `false` outside a
|
|
15
|
+
* task item and in a code block.
|
|
16
|
+
*/
|
|
17
|
+
toggleTaskChecked: () => Command;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The `taskItem` node (`<li data-checked="true|false">`), docs/SPEC.md F-406. Required by
|
|
22
|
+
* `TaskList`. In the editor, a node view draws the checkbox (`TaskItemView`).
|
|
23
|
+
*/
|
|
24
|
+
export declare const TaskItem: (options?: Partial<Record<string, never>> | undefined) => import("../..").Extension<Record<string, never>>;
|