@aicayzer/inkkit 0.0.0-stage → 0.0.2
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/NOTICE +6 -0
- package/README.md +41 -2
- package/dist/autolink.d.ts +1 -0
- package/dist/autolink.js +18 -0
- package/dist/clipboard.d.ts +11 -0
- package/dist/clipboard.js +161 -0
- package/dist/decorations.d.ts +2 -0
- package/dist/decorations.js +66 -0
- package/dist/dialect.d.ts +9 -0
- package/dist/dialect.js +292 -0
- package/dist/editor.d.ts +110 -0
- package/dist/editor.js +1149 -0
- package/dist/highlight.d.ts +1 -0
- package/dist/highlight.js +49 -0
- package/dist/images.d.ts +32 -0
- package/dist/images.js +129 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +2 -0
- package/dist/literals.d.ts +16 -0
- package/dist/literals.js +142 -0
- package/dist/paste.d.ts +23 -0
- package/dist/paste.js +417 -0
- package/dist/preserve.d.ts +16 -0
- package/dist/preserve.js +403 -0
- package/dist/reference-clipboard.d.ts +8 -0
- package/dist/reference-clipboard.js +197 -0
- package/dist/references.d.ts +14 -0
- package/dist/references.js +367 -0
- package/dist/selection.d.ts +1 -0
- package/dist/selection.js +47 -0
- package/dist/style.css +564 -0
- package/dist/tables.d.ts +7 -0
- package/dist/tables.js +80 -0
- package/dist/tasks.d.ts +3 -0
- package/dist/tasks.js +49 -0
- package/dist/types.d.ts +60 -0
- package/dist/types.js +8 -0
- package/package.json +74 -4
package/dist/editor.d.ts
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { type TableCommand } from './tables.js';
|
|
2
|
+
import { type DocumentInput, type DocumentSnapshot, type ImageAdapter, type ClipboardInput, type ClipboardOutput } from './types.js';
|
|
3
|
+
export type Mark = 'bold' | 'italic' | 'strikethrough' | 'code' | 'link';
|
|
4
|
+
export type Block = {
|
|
5
|
+
type: 'paragraph';
|
|
6
|
+
} | {
|
|
7
|
+
type: 'heading';
|
|
8
|
+
level: number;
|
|
9
|
+
} | {
|
|
10
|
+
type: 'codeBlock';
|
|
11
|
+
} | {
|
|
12
|
+
type: 'bulletList';
|
|
13
|
+
} | {
|
|
14
|
+
type: 'orderedList';
|
|
15
|
+
} | {
|
|
16
|
+
type: 'taskList';
|
|
17
|
+
};
|
|
18
|
+
export interface CaretState {
|
|
19
|
+
marks: Mark[];
|
|
20
|
+
block: Block;
|
|
21
|
+
/** One quote holds the whole selection; the block is what sits inside it. */
|
|
22
|
+
quoted: boolean;
|
|
23
|
+
}
|
|
24
|
+
export type FormatCommand = 'heading' | 'paragraph' | 'bold' | 'italic' | 'strikethrough' | 'code' | 'codeBlock' | 'quote' | 'bulletList' | 'orderedList' | 'taskList' | 'link';
|
|
25
|
+
/** The bindings the app sets, by shortcut name; each runs a format command. */
|
|
26
|
+
export type Keymap = Record<string, string[]>;
|
|
27
|
+
export interface EditorEvents {
|
|
28
|
+
changed(markdown: string, generation: number): void;
|
|
29
|
+
stateChanged(state: CaretState): void;
|
|
30
|
+
openLink(href: string): void;
|
|
31
|
+
copy(text: string): void;
|
|
32
|
+
error?(error: Error): void;
|
|
33
|
+
clipboard?(content: ClipboardOutput): void | Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
export declare class InkKitEditor {
|
|
36
|
+
private readonly events;
|
|
37
|
+
private readonly options;
|
|
38
|
+
private editor;
|
|
39
|
+
private lastMarkdown;
|
|
40
|
+
private baseline;
|
|
41
|
+
private documentId;
|
|
42
|
+
private formatType;
|
|
43
|
+
private revision;
|
|
44
|
+
private documentEpoch;
|
|
45
|
+
private operationSequence;
|
|
46
|
+
private plainComposing;
|
|
47
|
+
private plainSearch;
|
|
48
|
+
private ready;
|
|
49
|
+
private destroyed;
|
|
50
|
+
private preservation?;
|
|
51
|
+
private pasteController;
|
|
52
|
+
private plain;
|
|
53
|
+
private root;
|
|
54
|
+
private clickHandler?;
|
|
55
|
+
private footnoteKeyHandler?;
|
|
56
|
+
private copyHandler?;
|
|
57
|
+
private originalSource;
|
|
58
|
+
private generation;
|
|
59
|
+
private loading;
|
|
60
|
+
private changePlugin;
|
|
61
|
+
private keys;
|
|
62
|
+
private constructor();
|
|
63
|
+
private context;
|
|
64
|
+
private assertAlive;
|
|
65
|
+
private assertCurrent;
|
|
66
|
+
private plainSource;
|
|
67
|
+
snapshot(expectedGeneration?: number): DocumentSnapshot;
|
|
68
|
+
clipboardSnapshot(all?: boolean): Promise<ClipboardOutput>;
|
|
69
|
+
paste(input: ClipboardInput): Promise<void>;
|
|
70
|
+
pasteAsPlainText(text: string): void;
|
|
71
|
+
table(command: TableCommand, options?: {
|
|
72
|
+
rows?: number;
|
|
73
|
+
columns?: number;
|
|
74
|
+
}): boolean;
|
|
75
|
+
destroy(): Promise<void>;
|
|
76
|
+
private keymapPlugin;
|
|
77
|
+
static mount(root: HTMLElement, events: EditorEvents, options?: {
|
|
78
|
+
images?: ImageAdapter;
|
|
79
|
+
}): Promise<InkKitEditor>;
|
|
80
|
+
loadDocument(input: DocumentInput): void;
|
|
81
|
+
reloadDocument(input: DocumentInput): void;
|
|
82
|
+
private load;
|
|
83
|
+
find(text: string): void;
|
|
84
|
+
/** Buffered native typing follows the same input rules as direct typing. */
|
|
85
|
+
insertText(text: string, generation: number): boolean;
|
|
86
|
+
/** Let existing keymaps handle buffered editing commands before native fallback. */
|
|
87
|
+
keyDown(key: string, code: string, metaKey: boolean, ctrlKey: boolean, altKey: boolean, shiftKey: boolean, generation: number): boolean;
|
|
88
|
+
focus(): void;
|
|
89
|
+
/** Binds keys, in ProseMirror's names, to the formatting each shortcut runs. Walked in the table's
|
|
90
|
+
* order, so a key given to two shortcuts lands the same way every time. */
|
|
91
|
+
setKeymap(keymap: Keymap): void;
|
|
92
|
+
/** Dropped files land as one paragraph per path at the drop point: in place of an empty block, after
|
|
93
|
+
* the top-level block otherwise, so a list or quote is not opened up by them. */
|
|
94
|
+
insertPaths(paths: string[], x: number, y: number): void;
|
|
95
|
+
insertImages(images: {
|
|
96
|
+
path: string;
|
|
97
|
+
alt: string;
|
|
98
|
+
title?: string;
|
|
99
|
+
}[], x?: number, y?: number): void;
|
|
100
|
+
private insertBlocks;
|
|
101
|
+
private withMarkRunSelected;
|
|
102
|
+
private toggleInlineCode;
|
|
103
|
+
private list;
|
|
104
|
+
private quote;
|
|
105
|
+
private unquote;
|
|
106
|
+
format(command: FormatCommand, arg?: string | number): void;
|
|
107
|
+
editReferenceDefinition(label: string, destination: string, title?: string): boolean;
|
|
108
|
+
insertFootnote(label?: string): void;
|
|
109
|
+
navigateFootnote(target: 'definition' | 'reference'): boolean;
|
|
110
|
+
}
|