@aicayzer/inkkit 0.3.4 → 0.3.6
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/NOTICE +7 -7
- package/dist/THIRD-PARTY-NOTICES-FULL.txt +47 -3033
- package/dist/THIRD-PARTY-NOTICES.txt +47 -0
- package/dist/chunks/{core-BRAgrHC7.js → core-DtLNFuDg.js} +7701 -9645
- package/dist/chunks/{highlight-C4gIww13.js → highlight-wulvkYDg.js} +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +1 -1
- package/dist/editor.d.ts +14 -5
- package/dist/formats/index.d.ts +6 -0
- package/dist/formats/markdown.d.ts +4 -0
- package/dist/formats/text.d.ts +4 -0
- package/dist/formats/types.d.ts +84 -0
- package/dist/index.js +32790 -2
- package/dist/style.css +91 -3
- package/dist/types.d.ts +9 -0
- package/package.json +2 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as Decoration, c as PluginKey, d as __toESM, i as $prose, o as DecorationSet, s as Plugin, u as __commonJSMin } from "./core-
|
|
1
|
+
import { a as Decoration, c as PluginKey, d as __toESM, i as $prose, o as DecorationSet, s as Plugin, u as __commonJSMin } from "./core-DtLNFuDg.js";
|
|
2
2
|
//#region node_modules/.pnpm/highlight.js@11.11.2/node_modules/highlight.js/es/languages/arduino.js
|
|
3
3
|
/** @type LanguageFn */
|
|
4
4
|
function cPlusPlus(hljs) {
|
package/dist/core.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { InkKitEditor } from './editor.js';
|
|
2
2
|
export type { EditorEvents, EditorOptions, TextInputPreferences, CommandState, EditingMode, CaretState, Mark, Block, FormatCommand, FormatOptions, KeyInput, ImageInsertion, ShortcutName, Keymap, } from './editor.js';
|
|
3
3
|
export { InkKitError } from './types.js';
|
|
4
|
-
export type { DocumentFormat, EditorLabels, Heading, TableCommand, TableOptions, BlockMoveDirection, DocumentContext, DocumentInput, DocumentSnapshot, DocumentVersion, EditorErrorCode, ImageAdapter, ImageImportContext, WikiLinkReference, WikiLinkAdapter, FileReference, ClientPoint, FileContext, FilePresentation, FileAdapter, CapturedImage, PortableImage, ClipboardInput, ClipboardOutput, ClipboardScope, ClipboardImage, ClipboardDiagram, PrintableDocument, PrintableWarning, TextRange, ReadableTextSnapshot, TextRect, ViewportInsets, ViewportOptions, ViewportSnapshot, } from './types.js';
|
|
4
|
+
export type { DocumentFormat, FormatPromise, OfferedFormat, EditorLabels, Heading, TableCommand, TableOptions, BlockMoveDirection, DocumentContext, DocumentInput, DocumentSnapshot, DocumentVersion, EditorErrorCode, ImageAdapter, ImageImportContext, WikiLinkReference, WikiLinkAdapter, FileReference, ClientPoint, FileContext, FilePresentation, FileAdapter, CapturedImage, PortableImage, ClipboardInput, ClipboardOutput, ClipboardScope, ClipboardImage, ClipboardDiagram, PrintableDocument, PrintableWarning, TextRange, ReadableTextSnapshot, TextRect, ViewportInsets, ViewportOptions, ViewportSnapshot, } from './types.js';
|
|
5
5
|
export type { SlashMenuOptions, SlashCommandName, SlashCommand } from './types.js';
|
package/dist/core.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { r as InkKitError, t as InkKitEditor } from "./chunks/core-
|
|
1
|
+
import { r as InkKitError, t as InkKitEditor } from "./chunks/core-DtLNFuDg.js";
|
|
2
2
|
export { InkKitEditor, InkKitError };
|
package/dist/editor.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SlashMenuOptions } from './types.js';
|
|
2
|
-
import { InkKitError, type ClientPoint, type DocumentInput, type DocumentSnapshot, type ImageAdapter, type FileAdapter, type WikiLinkAdapter, type ClipboardInput, type ClipboardOutput, type ClipboardScope, type DocumentVersion, type PrintableDocument, type TextRange, type ReadableTextSnapshot, type TextRect, type ViewportOptions, type ViewportSnapshot, type EditorLabels, type Heading, type TableCommand, type TableOptions, type BlockMoveDirection } from './types.js';
|
|
2
|
+
import { InkKitError, type ClientPoint, type DocumentFormat, type DocumentInput, type DocumentSnapshot, type ImageAdapter, type FileAdapter, type WikiLinkAdapter, type ClipboardInput, type ClipboardOutput, type ClipboardScope, type DocumentVersion, type PrintableDocument, type TextRange, type ReadableTextSnapshot, type TextRect, type ViewportOptions, type ViewportSnapshot, type EditorLabels, type Heading, type TableCommand, type TableOptions, type BlockMoveDirection, type OfferedFormat } from './types.js';
|
|
3
3
|
/** An inline format that `CaretState` can report. */
|
|
4
|
-
export type Mark = 'bold' | 'italic' | 'strikethrough' | 'highlight' | 'code' | 'link';
|
|
4
|
+
export type Mark = 'bold' | 'italic' | 'strikethrough' | 'highlight' | 'underline' | 'superscript' | 'subscript' | 'code' | 'link';
|
|
5
5
|
/** The kind of block that holds the start of the selection. Any other block reports `paragraph`. */
|
|
6
6
|
export type Block = {
|
|
7
7
|
type: 'paragraph';
|
|
@@ -27,7 +27,7 @@ export interface CaretState {
|
|
|
27
27
|
/** One quote holds the whole selection; the block is what sits inside it. */
|
|
28
28
|
quoted: boolean;
|
|
29
29
|
}
|
|
30
|
-
declare const formatCommands: readonly ['heading1', 'heading2', 'heading3', 'heading4', 'heading5', 'heading6', 'paragraph', 'bold', 'italic', 'strikethrough', 'highlight', 'code', 'codeBlock', 'quote', 'bulletList', 'orderedList', 'taskList', 'toggleTask', 'link'];
|
|
30
|
+
declare const formatCommands: readonly ['heading1', 'heading2', 'heading3', 'heading4', 'heading5', 'heading6', 'paragraph', 'bold', 'italic', 'strikethrough', 'highlight', 'underline', 'superscript', 'subscript', 'code', 'codeBlock', 'quote', 'bulletList', 'orderedList', 'taskList', 'toggleTask', 'link'];
|
|
31
31
|
/** A command for `format`. */
|
|
32
32
|
export type FormatCommand = (typeof formatCommands)[number];
|
|
33
33
|
/** `destination` goes only with `link`, and `language` only with `codeBlock`. */
|
|
@@ -65,8 +65,11 @@ export interface TextInputPreferences {
|
|
|
65
65
|
/** Typing a quote or `--` gives a curly quote or a dash, in formatted mode. Off unless true. */
|
|
66
66
|
smartPunctuation?: boolean;
|
|
67
67
|
}
|
|
68
|
-
/** Mount options. Adapters, `labels`, `linkSchemes` and `rendering` are fixed at mount;
|
|
68
|
+
/** Mount options. Adapters, `formats`, `labels`, `linkSchemes` and `rendering` are fixed at mount;
|
|
69
|
+
* the rest can change. */
|
|
69
70
|
export interface EditorOptions {
|
|
71
|
+
/** The formats the host offers, listed by `formats`. Defaults to `['md', 'txt']`. Fixed at mount. */
|
|
72
|
+
formats?: readonly DocumentFormat[];
|
|
70
73
|
/** Shows, imports and exports images. Without it and `files`, image Markdown stays literal. */
|
|
71
74
|
images?: ImageAdapter;
|
|
72
75
|
/** Opt-in block suggestions on an empty line. Fixed at mount. */
|
|
@@ -94,7 +97,7 @@ export interface EditorOptions {
|
|
|
94
97
|
}
|
|
95
98
|
/** What the editor can do now. Availability is the state at the time of the call, not a promise. */
|
|
96
99
|
export interface CommandState extends DocumentVersion {
|
|
97
|
-
format:
|
|
100
|
+
format: DocumentFormat;
|
|
98
101
|
mode: EditingMode;
|
|
99
102
|
editable: boolean;
|
|
100
103
|
/** Text composition (IME) is in progress. */
|
|
@@ -157,6 +160,7 @@ export declare class InkKitEditor {
|
|
|
157
160
|
private readonly text;
|
|
158
161
|
private readonly geometry;
|
|
159
162
|
private readonly search;
|
|
163
|
+
private readonly diagrams;
|
|
160
164
|
private readonly output;
|
|
161
165
|
private readonly clipboard;
|
|
162
166
|
private lastMarkdown;
|
|
@@ -186,6 +190,9 @@ export declare class InkKitEditor {
|
|
|
186
190
|
private readonly events;
|
|
187
191
|
/** The host's extra link schemes, in lower case. */
|
|
188
192
|
private readonly linkSchemes;
|
|
193
|
+
/** The formats the host offered, in its order. */
|
|
194
|
+
private readonly offered;
|
|
195
|
+
private readonly formatList;
|
|
189
196
|
/** How many of each state event the host has been sent. */
|
|
190
197
|
private readonly sentEvents;
|
|
191
198
|
private constructor();
|
|
@@ -236,6 +243,8 @@ export declare class InkKitEditor {
|
|
|
236
243
|
* `events.error`, unless a host call such as `keyDown` is waiting for it. */
|
|
237
244
|
private forPerson;
|
|
238
245
|
private get composing();
|
|
246
|
+
/** The formats the host offered at mount, in its order, with what saving each promises. */
|
|
247
|
+
get formats(): readonly OfferedFormat[];
|
|
239
248
|
/** Whether the person can edit. A read-only editor still permits selection, copying and find. */
|
|
240
249
|
get editable(): boolean;
|
|
241
250
|
/** Turns editing on or off for both surfaces. Throws `composition` during text composition. */
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { DocumentFormat } from '../types';
|
|
2
|
+
import type { FormatHandler } from './types';
|
|
3
|
+
export type { FormatHandler, FormatSource, FormatOutput } from './types';
|
|
4
|
+
/** Every format Inkkit can open, and the list a host is offered when it chooses none. */
|
|
5
|
+
export declare const documentFormats: readonly ["md", "txt"];
|
|
6
|
+
export declare const formatHandlers: Readonly<Record<DocumentFormat, FormatHandler>>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { FormatHandler } from './types';
|
|
2
|
+
/** Literal text, edited only on the literal surface and saved as typed. It reaches no Markdown
|
|
3
|
+
* parsing or preservation; `test/formats/boundary.test.ts` checks its imports. */
|
|
4
|
+
export declare const textFormat: FormatHandler;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { Ctx } from '@milkdown/kit/ctx';
|
|
2
|
+
import type { Fragment, Node as ProseNode } from '@milkdown/kit/prose/model';
|
|
3
|
+
import type { DiagramStore } from '../mermaid';
|
|
4
|
+
import type { ClipboardInput, ClipboardOutput, DocumentContext, DocumentFormat, DocumentSnapshot, DocumentVersion, EditorLabels, FileAdapter, FormatPromise, ImageAdapter, PrintableDocument } from '../types';
|
|
5
|
+
/** What a format keeps from reading a text, to save edits to the document it read. */
|
|
6
|
+
export interface FormatSource {
|
|
7
|
+
/** The document read from the text. */
|
|
8
|
+
readonly baseline: ProseNode;
|
|
9
|
+
/** The text to save for `doc`, which is `baseline` after edits. `carried` holds nodes that block
|
|
10
|
+
* moves carried. Absent for a format that saves its literal surface's text. */
|
|
11
|
+
serialize?(doc: ProseNode, carried?: WeakSet<ProseNode>): string;
|
|
12
|
+
}
|
|
13
|
+
/** What a format's output reads from the editor. Each call reads the current value, and
|
|
14
|
+
* `context()` names a new operation, so call it only when an adapter needs it. */
|
|
15
|
+
export interface FormatOutput {
|
|
16
|
+
ctx(): Ctx;
|
|
17
|
+
element(): HTMLTextAreaElement;
|
|
18
|
+
sourceMode(): boolean;
|
|
19
|
+
exportDocument(text: string): ProseNode;
|
|
20
|
+
images(): ImageAdapter | undefined;
|
|
21
|
+
files(): FileAdapter | undefined;
|
|
22
|
+
linkSchemes(): ReadonlySet<string>;
|
|
23
|
+
context(): DocumentContext;
|
|
24
|
+
diagrams(): DiagramStore;
|
|
25
|
+
root(): HTMLElement;
|
|
26
|
+
remember<T extends {
|
|
27
|
+
text: string;
|
|
28
|
+
html: string;
|
|
29
|
+
}>(output: T, markdown: string, content: Fragment, privateSource?: boolean): T;
|
|
30
|
+
}
|
|
31
|
+
export type PrintableContent = Pick<PrintableDocument, 'html' | 'styles' | 'assets' | 'warnings'>;
|
|
32
|
+
export interface PrintRequest {
|
|
33
|
+
/** The snapshot's text. */
|
|
34
|
+
readonly text: string;
|
|
35
|
+
/** The document to print, which holds source typed but not yet settled. */
|
|
36
|
+
readonly doc: ProseNode;
|
|
37
|
+
readonly signal: AbortSignal;
|
|
38
|
+
readonly output: FormatOutput;
|
|
39
|
+
}
|
|
40
|
+
export interface ClipboardRequest {
|
|
41
|
+
readonly snapshot: DocumentSnapshot;
|
|
42
|
+
/** The whole document, rather than the selection. */
|
|
43
|
+
readonly all: boolean;
|
|
44
|
+
readonly version: DocumentVersion;
|
|
45
|
+
readonly output: FormatOutput;
|
|
46
|
+
/** Runs asynchronous output work, and throws `stale-document` when the document, its revision or
|
|
47
|
+
* the editing mode changed meanwhile. */
|
|
48
|
+
run<T>(operation: (signal: AbortSignal) => Promise<T>): Promise<T>;
|
|
49
|
+
/** Throws unless the captured document is still current. */
|
|
50
|
+
assertCurrent(): void;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Everything that differs between document formats. The editor sets one handler on each load and
|
|
54
|
+
* reads its fields directly, so a keystroke does no lookup.
|
|
55
|
+
*/
|
|
56
|
+
export interface FormatHandler {
|
|
57
|
+
readonly format: DocumentFormat;
|
|
58
|
+
readonly promise: FormatPromise;
|
|
59
|
+
/** The person edits only the literal surface: there is no formatted mode, and no format, table
|
|
60
|
+
* or block commands. */
|
|
61
|
+
readonly literalOnly: boolean;
|
|
62
|
+
/** A source mode exists beside formatted mode. */
|
|
63
|
+
readonly sourceMode: boolean;
|
|
64
|
+
/** The label that names the literal surface. */
|
|
65
|
+
readonly literalLabel: keyof Pick<EditorLabels, 'plainTextEditor' | 'sourceEditor'>;
|
|
66
|
+
/** `headings` lists the document's headings. */
|
|
67
|
+
readonly headings: boolean;
|
|
68
|
+
/** Copying from the literal surface is left to the browser. */
|
|
69
|
+
readonly nativeCopy: boolean;
|
|
70
|
+
/** Text inserted on the literal surface keeps its own line endings, rather than taking the
|
|
71
|
+
* document's. */
|
|
72
|
+
readonly keepsInsertedLineEndings: boolean;
|
|
73
|
+
/** Reads loaded text into the formatted document. Throws when it cannot be shown. */
|
|
74
|
+
load(ctx: Ctx, text: string): FormatSource;
|
|
75
|
+
/** Reads text from the literal surface into the formatted document. */
|
|
76
|
+
parse(ctx: Ctx, text: string): FormatSource;
|
|
77
|
+
/** The document that output reads while text from the literal surface has not reached the
|
|
78
|
+
* formatted document, or `undefined` to read the formatted document. */
|
|
79
|
+
pendingExport(ctx: Ctx, text: string): ProseNode | undefined;
|
|
80
|
+
/** The text that a paste on the literal surface inserts. */
|
|
81
|
+
literalPaste(input: ClipboardInput): string;
|
|
82
|
+
print(request: PrintRequest): Promise<PrintableContent>;
|
|
83
|
+
clipboard(request: ClipboardRequest): Promise<ClipboardOutput>;
|
|
84
|
+
}
|