@aicayzer/inkkit 0.3.5 → 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/dist/chunks/{core-BjnsFL5-.js → core-DtLNFuDg.js} +4381 -3841
- package/dist/chunks/{highlight-Caqd0kqu.js → highlight-wulvkYDg.js} +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +1 -1
- package/dist/editor.d.ts +13 -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 +1 -1
- package/dist/style.css +24 -0
- package/dist/types.d.ts +9 -0
- package/package.json +1 -1
|
@@ -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. */
|
|
@@ -187,6 +190,9 @@ export declare class InkKitEditor {
|
|
|
187
190
|
private readonly events;
|
|
188
191
|
/** The host's extra link schemes, in lower case. */
|
|
189
192
|
private readonly linkSchemes;
|
|
193
|
+
/** The formats the host offered, in its order. */
|
|
194
|
+
private readonly offered;
|
|
195
|
+
private readonly formatList;
|
|
190
196
|
/** How many of each state event the host has been sent. */
|
|
191
197
|
private readonly sentEvents;
|
|
192
198
|
private constructor();
|
|
@@ -237,6 +243,8 @@ export declare class InkKitEditor {
|
|
|
237
243
|
* `events.error`, unless a host call such as `keyDown` is waiting for it. */
|
|
238
244
|
private forPerson;
|
|
239
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[];
|
|
240
248
|
/** Whether the person can edit. A read-only editor still permits selection, copying and find. */
|
|
241
249
|
get editable(): boolean;
|
|
242
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
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as registerDiagram, r as InkKitError, t as InkKitEditor } from "./chunks/core-
|
|
1
|
+
import { n as registerDiagram, r as InkKitError, t as InkKitEditor } from "./chunks/core-DtLNFuDg.js";
|
|
2
2
|
//#region node_modules/.pnpm/dompurify@3.4.17/node_modules/dompurify/dist/purify.es.mjs
|
|
3
3
|
/*! @license DOMPurify 3.4.17 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.17/LICENSE */
|
|
4
4
|
function _OverloadYield(e, d) {
|
package/dist/style.css
CHANGED
|
@@ -912,6 +912,30 @@
|
|
|
912
912
|
color: inherit;
|
|
913
913
|
}
|
|
914
914
|
|
|
915
|
+
.inkkit-root .ProseMirror u {
|
|
916
|
+
text-decoration-line: underline;
|
|
917
|
+
text-decoration-thickness: var(--inkkit-underline-thickness, auto);
|
|
918
|
+
text-underline-offset: var(--inkkit-underline-offset, auto);
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
/* Shifted rather than vertically aligned, so a line holding them keeps its
|
|
922
|
+
height. A footnote reference is also a `sup` and keeps its own style. */
|
|
923
|
+
.inkkit-root .ProseMirror sup:not([data-inkkit-footnote-reference]),
|
|
924
|
+
.inkkit-root .ProseMirror sub {
|
|
925
|
+
position: relative;
|
|
926
|
+
font-size: var(--inkkit-script-size, 0.75em);
|
|
927
|
+
line-height: 0;
|
|
928
|
+
vertical-align: baseline;
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
.inkkit-root .ProseMirror sup:not([data-inkkit-footnote-reference]) {
|
|
932
|
+
top: calc(var(--inkkit-superscript-shift, 0.5em) * -1);
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
.inkkit-root .ProseMirror sub {
|
|
936
|
+
bottom: calc(var(--inkkit-subscript-shift, 0.25em) * -1);
|
|
937
|
+
}
|
|
938
|
+
|
|
915
939
|
.inkkit-root .ProseMirror .inkkit-callout {
|
|
916
940
|
--_inkkit-callout-color: var(--_inkkit-accent);
|
|
917
941
|
border-inline-start: 3px solid var(--_inkkit-callout-color);
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
/** `md` is Markdown; `txt` is literal text, shown and saved as typed. */
|
|
2
2
|
export type DocumentFormat = 'md' | 'txt';
|
|
3
|
+
/** What saving promises for a format. `exact` saves the file exactly. `structure` keeps the
|
|
4
|
+
* structure and marks and replaces fonts, colors and sizes with Inkkit's style. `lossy` is a
|
|
5
|
+
* conversion that drops something and says what. */
|
|
6
|
+
export type FormatPromise = 'exact' | 'structure' | 'lossy';
|
|
7
|
+
/** A format the host offered at mount, with what saving it promises. */
|
|
8
|
+
export interface OfferedFormat {
|
|
9
|
+
format: DocumentFormat;
|
|
10
|
+
promise: FormatPromise;
|
|
11
|
+
}
|
|
3
12
|
/** What every adapter call receives, to tell which document, load and call it belongs to. The
|
|
4
13
|
* operation ID is opaque and differs for each call from one editor. */
|
|
5
14
|
export interface DocumentContext {
|