stilo-editor 0.0.0-stage → 0.1.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 +172 -2
- package/dist/characters--8h5uTeF.js +854 -0
- package/dist/content.css +161 -0
- package/dist/core/drop.d.ts +6 -0
- package/dist/core/editor.d.ts +108 -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 +43 -0
- package/dist/core/helpers/active.d.ts +33 -0
- package/dist/core/helpers/input-rules.d.ts +21 -0
- package/dist/core/helpers/lists.d.ts +12 -0
- package/dist/core/helpers/marks.d.ts +38 -0
- package/dist/core/helpers/nodes.d.ts +14 -0
- package/dist/core/helpers/parse-rules.d.ts +8 -0
- package/dist/core/html/css.d.ts +91 -0
- package/dist/core/html/parse.d.ts +7 -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/default-extensions/index.d.ts +46 -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 +24 -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/index.d.ts +27 -0
- package/dist/extensions/italic/index.d.ts +16 -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/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/text/index.d.ts +12 -0
- package/dist/extensions/text-style/index.d.ts +14 -0
- package/dist/extensions/underline/index.d.ts +15 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +1 -0
- package/dist/src-3tAxKI0c.js +1316 -0
- package/dist/style.css +797 -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 +25 -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/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 +19 -0
- package/dist/ui/toolbar/items.d.ts +12 -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 +87 -0
- package/dist/ui.css +635 -0
- package/dist/ui.js +1292 -0
- package/package.json +86 -4
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTML sanitization with DOMPurify. See docs/ARCHITECTURE.md §8 and docs/SPEC.md NFR-2.
|
|
3
|
+
*
|
|
4
|
+
* Implementation requirements:
|
|
5
|
+
*
|
|
6
|
+
* - Use a **Stilo-owned DOMPurify instance**, created lazily with `DOMPurify(window)` and cached
|
|
7
|
+
* per `window` (WeakMap). Never add hooks to the default DOMPurify export: it may be shared
|
|
8
|
+
* with the host application. No DOM access at module top level.
|
|
9
|
+
* - Config: `ALLOWED_TAGS`, `ALLOWED_ATTR` below, `ALLOW_DATA_ATTR: false`. Unknown tags are
|
|
10
|
+
* unwrapped with their content kept (DOMPurify default).
|
|
11
|
+
* - One `uponSanitizeAttribute` hook filters attribute values; when the filter returns `null`
|
|
12
|
+
* the attribute is removed (`keepAttr = false`), otherwise `attrValue` is replaced:
|
|
13
|
+
* - `style` → `sanitizeStyle(value)` from `./css`;
|
|
14
|
+
* - `class` → only tokens matching `^language-[\w-]+$`, joined with a space;
|
|
15
|
+
* - `href` → kept (trimmed) if {@link isAllowedHref};
|
|
16
|
+
* - `src` → kept (trimmed) if {@link isAllowedImageSrc};
|
|
17
|
+
* - `target` → kept only if exactly `_blank`;
|
|
18
|
+
* - any other allowed attribute → unchanged.
|
|
19
|
+
*/
|
|
20
|
+
/** Tags kept by the sanitizer. */
|
|
21
|
+
export declare const ALLOWED_TAGS: readonly string[];
|
|
22
|
+
/** Attributes kept by the sanitizer (values further filtered by the hook). */
|
|
23
|
+
export declare const ALLOWED_ATTR: readonly string[];
|
|
24
|
+
/** Schemes allowed in `href`. */
|
|
25
|
+
export declare const LINK_PROTOCOLS: readonly string[];
|
|
26
|
+
/** Schemes allowed in `img src` (besides the data URLs matched by {@link IMAGE_DATA_URL}). */
|
|
27
|
+
export declare const IMAGE_PROTOCOLS: readonly string[];
|
|
28
|
+
/** Image data URLs allowed in `img src`. No SVG. */
|
|
29
|
+
export declare const IMAGE_DATA_URL: RegExp;
|
|
30
|
+
/**
|
|
31
|
+
* Extracts the lowercased URL scheme (`"https"` for `https://x`), or `null` for relative URLs
|
|
32
|
+
* and fragments. Whitespace and control characters (U+0000–U+001F) are removed first, because
|
|
33
|
+
* browsers ignore them inside schemes (`java\tscript:` is `javascript:`).
|
|
34
|
+
*/
|
|
35
|
+
export declare function urlScheme(url: string): string | null;
|
|
36
|
+
/** Whether a URL is allowed in `href`: relative, fragment, or scheme in {@link LINK_PROTOCOLS}. */
|
|
37
|
+
export declare function isAllowedHref(url: string): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Whether a URL is allowed in `img src`: non-empty relative URL, scheme in
|
|
40
|
+
* {@link IMAGE_PROTOCOLS}, or a `data:` URL matching {@link IMAGE_DATA_URL}.
|
|
41
|
+
*/
|
|
42
|
+
export declare function isAllowedImageSrc(url: string): boolean;
|
|
43
|
+
/** Sanitizes HTML and returns it as a string. Used for paste (`transformPastedHTML`). */
|
|
44
|
+
export declare function sanitizeToString(html: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* Sanitizes HTML and returns a detached `<body>` element (DOMPurify `RETURN_DOM: true`), which
|
|
47
|
+
* avoids a serialize/parse round trip. Used by `parseHTML`.
|
|
48
|
+
*/
|
|
49
|
+
export declare function sanitizeToDOM(html: string): HTMLElement;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { DOMSerializer, type Fragment, type Schema } from 'prosemirror-model';
|
|
2
|
+
/** Options of {@link serializeHTML}. */
|
|
3
|
+
export interface SerializeOptions {
|
|
4
|
+
/** Unwrap the single paragraph of list items. Default: `true`. */
|
|
5
|
+
compactParagraphs?: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Canonical post-processing of serialized HTML, in place (docs/ARCHITECTURE.md §8.1): styles
|
|
9
|
+
* rewritten with `sanitizeStyle`, and with `compactParagraphs` (default) the single paragraph of
|
|
10
|
+
* list items unwrapped (docs/decisions/0001).
|
|
11
|
+
*/
|
|
12
|
+
export declare function canonicalizeDOM(root: Element | DocumentFragment, options?: SerializeOptions): void;
|
|
13
|
+
/**
|
|
14
|
+
* Serializes a fragment (usually `doc.content`) to a canonical HTML string
|
|
15
|
+
* (docs/ARCHITECTURE.md §7): `DOMSerializer.fromSchema(schema).serializeFragment()` into a
|
|
16
|
+
* container element of a detached document (`document.implementation.createHTMLDocument('')`),
|
|
17
|
+
* then the container's `innerHTML`. Before that:
|
|
18
|
+
*
|
|
19
|
+
* - every `style` attribute is rewritten with `sanitizeStyle`: ProseMirror sets styles through
|
|
20
|
+
* `style.cssText`, and the browser re-serializes them (trailing `;`, `rgb()` colors);
|
|
21
|
+
* - with `compactParagraphs` (default), a `<p>` without attributes that is the only child of a
|
|
22
|
+
* {@link COMPACT_CONTAINERS} element is replaced by its content (docs/decisions/0001).
|
|
23
|
+
*
|
|
24
|
+
* Post-processing is now handled by {@link canonicalizeDOM}.
|
|
25
|
+
*/
|
|
26
|
+
export declare function serializeHTML(schema: Schema, fragment: Fragment, options?: SerializeOptions): string;
|
|
27
|
+
/**
|
|
28
|
+
* A `DOMSerializer` for the clipboard (`clipboardSerializer` prop): same output as
|
|
29
|
+
* `DOMSerializer.fromSchema(schema)`, post-processed with `canonicalizeDOM`.
|
|
30
|
+
*/
|
|
31
|
+
export declare function createClipboardSerializer(schema: Schema, options?: SerializeOptions): DOMSerializer;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { Command, Transaction } from 'prosemirror-state';
|
|
2
|
+
import type { Editor } from './editor';
|
|
3
|
+
import type { Extension } from './extension';
|
|
4
|
+
/**
|
|
5
|
+
* Registry of all editor commands. Each extension adds its own entries through module
|
|
6
|
+
* augmentation:
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* declare module '../../core/types' {
|
|
10
|
+
* interface Commands {
|
|
11
|
+
* toggleBold: () => Command;
|
|
12
|
+
* }
|
|
13
|
+
* }
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export interface Commands {
|
|
17
|
+
}
|
|
18
|
+
/** Name of a registered command. */
|
|
19
|
+
export type CommandName = keyof Commands;
|
|
20
|
+
/** A function that receives command arguments and returns a ProseMirror command. */
|
|
21
|
+
export type CommandFactory = (...args: never[]) => Command;
|
|
22
|
+
/** The command factories an extension provides. */
|
|
23
|
+
export type CommandFactories = {
|
|
24
|
+
[K in CommandName]: Commands[K];
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* An executable command: same arguments as its factory, returns whether the command applied.
|
|
28
|
+
* `can(...args)` runs it without dispatching: whether it would apply.
|
|
29
|
+
*/
|
|
30
|
+
export type CommandRunner<A extends unknown[]> = ((...args: A) => boolean) & {
|
|
31
|
+
can: (...args: A) => boolean;
|
|
32
|
+
};
|
|
33
|
+
/** Executable commands, by name. */
|
|
34
|
+
export type CommandRunners = {
|
|
35
|
+
[K in CommandName]: Commands[K] extends (...args: infer A) => Command ? CommandRunner<A> : never;
|
|
36
|
+
};
|
|
37
|
+
/** ProseMirror JSON representation of a document or node. */
|
|
38
|
+
export interface JSONContent {
|
|
39
|
+
type: string;
|
|
40
|
+
attrs?: Record<string, unknown>;
|
|
41
|
+
content?: JSONContent[];
|
|
42
|
+
marks?: Array<{
|
|
43
|
+
type: string;
|
|
44
|
+
attrs?: Record<string, unknown>;
|
|
45
|
+
}>;
|
|
46
|
+
text?: string;
|
|
47
|
+
}
|
|
48
|
+
/** Options of the {@link Editor} constructor. */
|
|
49
|
+
export interface EditorOptions {
|
|
50
|
+
/** Container element; the editor appends its own DOM inside it. */
|
|
51
|
+
element: HTMLElement;
|
|
52
|
+
/** Extensions to load. Nested arrays (e.g. `defaultExtensions()`) are flattened. */
|
|
53
|
+
extensions: Array<Extension | Extension[]>;
|
|
54
|
+
/** Initial HTML content. Default: empty document. */
|
|
55
|
+
content?: string;
|
|
56
|
+
/** Whether the content is editable. Default: `true`. */
|
|
57
|
+
editable?: boolean;
|
|
58
|
+
/** Focus the editor after creation. Default: `false`. */
|
|
59
|
+
autofocus?: boolean | 'start' | 'end';
|
|
60
|
+
/** `aria-label` of the editable area. */
|
|
61
|
+
ariaLabel?: string;
|
|
62
|
+
/**
|
|
63
|
+
* Write a list item (and, from M2, a table cell) whose only content is one paragraph without
|
|
64
|
+
* attributes without its `<p>`: `<li>text</li>`. `false` keeps ProseMirror's standard output,
|
|
65
|
+
* `<li><p>text</p></li>`. Default: `true`. See docs/decisions/0001-tight-list-items.md.
|
|
66
|
+
*/
|
|
67
|
+
compactParagraphs?: boolean;
|
|
68
|
+
}
|
|
69
|
+
/** Options of `setHTML` / `setJSON`. */
|
|
70
|
+
export interface SetContentOptions {
|
|
71
|
+
/**
|
|
72
|
+
* `false` (default): replace the content with one undoable transaction.
|
|
73
|
+
* `true`: create a fresh state; history and all plugin states start from scratch.
|
|
74
|
+
*/
|
|
75
|
+
resetHistory?: boolean;
|
|
76
|
+
/** Emit the `input` event. Default: `true`. */
|
|
77
|
+
emitInput?: boolean;
|
|
78
|
+
}
|
|
79
|
+
/** Events emitted by the {@link Editor}. */
|
|
80
|
+
export interface EditorEvents {
|
|
81
|
+
/** Every applied transaction. */
|
|
82
|
+
transaction: {
|
|
83
|
+
editor: Editor;
|
|
84
|
+
transaction: Transaction;
|
|
85
|
+
};
|
|
86
|
+
/** The document changed. `transaction` is `null` when the state was replaced (`resetHistory`). */
|
|
87
|
+
input: {
|
|
88
|
+
editor: Editor;
|
|
89
|
+
transaction: Transaction | null;
|
|
90
|
+
};
|
|
91
|
+
/** The selection changed while the document did not. */
|
|
92
|
+
selectionchange: {
|
|
93
|
+
editor: Editor;
|
|
94
|
+
transaction: Transaction;
|
|
95
|
+
};
|
|
96
|
+
focus: {
|
|
97
|
+
editor: Editor;
|
|
98
|
+
event: FocusEvent;
|
|
99
|
+
};
|
|
100
|
+
blur: {
|
|
101
|
+
editor: Editor;
|
|
102
|
+
event: FocusEvent;
|
|
103
|
+
};
|
|
104
|
+
destroy: {
|
|
105
|
+
editor: Editor;
|
|
106
|
+
};
|
|
107
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Command } from 'prosemirror-state';
|
|
2
|
+
declare module '../../core/types' {
|
|
3
|
+
interface Commands {
|
|
4
|
+
/** Turns the selected textblocks into a blockquote. */
|
|
5
|
+
setBlockquote: () => Command;
|
|
6
|
+
/** Removes the blockquote from the selected textblocks. */
|
|
7
|
+
unsetBlockquote: () => Command;
|
|
8
|
+
/** Removes the blockquote if active, otherwise adds it. */
|
|
9
|
+
toggleBlockquote: () => Command;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The `blockquote` node (`<blockquote>`), docs/SPEC.md F-303.
|
|
14
|
+
*/
|
|
15
|
+
export declare const Blockquote: (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
|
+
/** Adds bold to the selection. */
|
|
5
|
+
setBold: () => Command;
|
|
6
|
+
/** Removes bold from the selection. */
|
|
7
|
+
unsetBold: () => Command;
|
|
8
|
+
/** Removes bold if the whole selection is bold, otherwise adds it. */
|
|
9
|
+
toggleBold: () => Command;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The `bold` mark (`<strong>`), docs/SPEC.md F-201. Also parsed from `<b>` (except the Google Docs
|
|
14
|
+
* wrapper `<b style="font-weight: normal">`) and from a bold `font-weight` style.
|
|
15
|
+
* Reference extension: every extension has this shape.
|
|
16
|
+
*/
|
|
17
|
+
export declare const Bold: (options?: Partial<Record<string, never>> | undefined) => import("../..").Extension<Record<string, never>>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Command } from 'prosemirror-state';
|
|
2
|
+
declare module '../../core/types' {
|
|
3
|
+
interface Commands {
|
|
4
|
+
/** Wraps the selection in a bullet list, lifts it out, or converts another list type. */
|
|
5
|
+
toggleBulletList: () => Command;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
/** The `bulletList` node (`<ul>`), docs/SPEC.md F-401, F-405. Requires `ListItem`. */
|
|
9
|
+
export declare const BulletList: (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
|
+
/** Removes every formatting mark (all marks except links) from the selection. */
|
|
5
|
+
clearFormatting: () => Command;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The `clearFormatting` command, docs/SPEC.md F-212: removes the marks of the `formatting`
|
|
10
|
+
* group (docs/ARCHITECTURE.md §7.2), so links stay.
|
|
11
|
+
*/
|
|
12
|
+
export declare const ClearFormatting: (options?: Partial<Record<string, never>> | undefined) => import("../..").Extension<Record<string, never>>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Command } from 'prosemirror-state';
|
|
2
|
+
declare module '../../core/types' {
|
|
3
|
+
interface Commands {
|
|
4
|
+
/** Adds inline code to the selection. */
|
|
5
|
+
setCode: () => Command;
|
|
6
|
+
/** Removes inline code from the selection. */
|
|
7
|
+
unsetCode: () => Command;
|
|
8
|
+
/** Removes inline code if the whole selection is code, otherwise adds it. */
|
|
9
|
+
toggleCode: () => Command;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The `code` mark (`<code>`), docs/SPEC.md F-205.
|
|
14
|
+
*/
|
|
15
|
+
export declare const Code: (options?: Partial<Record<string, never>> | undefined) => import("../..").Extension<Record<string, never>>;
|
|
@@ -0,0 +1,46 @@
|
|
|
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 PlaceholderOptions } from '../placeholder';
|
|
6
|
+
/**
|
|
7
|
+
* Options of {@link defaultExtensions}, by extension name: `false` disables the extension, an object
|
|
8
|
+
* configures it. Extensions without options accept only `false`.
|
|
9
|
+
*/
|
|
10
|
+
export interface DefaultExtensionsOptions {
|
|
11
|
+
doc?: false;
|
|
12
|
+
text?: false;
|
|
13
|
+
paragraph?: false;
|
|
14
|
+
heading?: false | Partial<HeadingOptions>;
|
|
15
|
+
blockquote?: false;
|
|
16
|
+
horizontalRule?: false;
|
|
17
|
+
hardBreak?: false;
|
|
18
|
+
bulletList?: false;
|
|
19
|
+
orderedList?: false;
|
|
20
|
+
listItem?: false;
|
|
21
|
+
bold?: false;
|
|
22
|
+
italic?: false;
|
|
23
|
+
underline?: false;
|
|
24
|
+
strike?: false;
|
|
25
|
+
subscript?: false;
|
|
26
|
+
superscript?: false;
|
|
27
|
+
code?: false;
|
|
28
|
+
link?: false;
|
|
29
|
+
textStyle?: false;
|
|
30
|
+
highlight?: false;
|
|
31
|
+
clearFormatting?: false;
|
|
32
|
+
history?: false | Partial<HistoryOptions>;
|
|
33
|
+
moveBlock?: false;
|
|
34
|
+
placeholder?: false | Partial<PlaceholderOptions>;
|
|
35
|
+
dropCursor?: false | Partial<DropCursorOptions>;
|
|
36
|
+
gapCursor?: false;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The default extension set (docs/ARCHITECTURE.md §6.3). M1 extensions are added here as they
|
|
40
|
+
* are implemented.
|
|
41
|
+
*
|
|
42
|
+
* ```ts
|
|
43
|
+
* new Editor({ element, extensions: [defaultExtensions({ bold: false })] });
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
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,24 @@
|
|
|
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>`), docs/SPEC.md F-302.
|
|
23
|
+
*/
|
|
24
|
+
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
|
+
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 { type DefaultExtensionsOptions, defaultExtensions } from './default-extensions';
|
|
7
|
+
export { Document } from './document';
|
|
8
|
+
export { DropCursor, type DropCursorOptions } from './drop-cursor';
|
|
9
|
+
export { GapCursor } from './gap-cursor';
|
|
10
|
+
export { HardBreak } from './hard-break';
|
|
11
|
+
export { Heading, type HeadingLevel, type HeadingOptions } from './heading';
|
|
12
|
+
export { Highlight, type HighlightAttributes } from './highlight';
|
|
13
|
+
export { History, type HistoryOptions } from './history';
|
|
14
|
+
export { HorizontalRule } from './horizontal-rule';
|
|
15
|
+
export { Italic } from './italic';
|
|
16
|
+
export { Link, type LinkAttributes } from './link';
|
|
17
|
+
export { ListItem } from './list-item';
|
|
18
|
+
export { MoveBlock } from './move-block';
|
|
19
|
+
export { OrderedList } from './ordered-list';
|
|
20
|
+
export { Paragraph } from './paragraph';
|
|
21
|
+
export { Placeholder, type PlaceholderOptions } from './placeholder';
|
|
22
|
+
export { Strike } from './strike';
|
|
23
|
+
export { Subscript } from './subscript';
|
|
24
|
+
export { Superscript } from './superscript';
|
|
25
|
+
export { Text } from './text';
|
|
26
|
+
export { TextStyle } from './text-style';
|
|
27
|
+
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,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>`). Priority 1000 makes it the first block node, which ProseMirror
|
|
10
|
+
* uses as the default block. `<div>` needs no parse rule: ProseMirror treats it as a block
|
|
11
|
+
* wrapper and wraps its loose inline content in paragraphs (the `div` fallback of
|
|
12
|
+
* 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,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>>;
|