@aicayzer/inkkit 0.1.1 → 0.1.3
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-CYp5ONPO.js → core-Bvj0PMMi.js} +13036 -11587
- package/dist/chunks/{highlight-BW9W8PtS.js → highlight-yHFoKkKz.js} +1 -1
- package/dist/core.d.ts +2 -1
- package/dist/core.js +1 -1
- package/dist/editor.d.ts +29 -7
- package/dist/index.js +1 -1
- package/dist/style.css +67 -5
- package/dist/types.d.ts +36 -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-Bvj0PMMi.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,4 +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, DocumentContext, DocumentInput, DocumentSnapshot, DocumentVersion, EditorErrorCode, ImageAdapter, 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, EditorLabels, Heading, TableCommand, TableOptions, BlockMoveDirection, DocumentContext, DocumentInput, DocumentSnapshot, DocumentVersion, EditorErrorCode, ImageAdapter, 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
|
+
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-Bvj0PMMi.js";
|
|
2
2
|
export { InkKitEditor, InkKitError };
|
package/dist/editor.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
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
3
|
/** An inline format that `CaretState` can report. */
|
|
3
4
|
export type Mark = 'bold' | 'italic' | 'strikethrough' | 'highlight' | 'code' | 'link';
|
|
4
5
|
/** The kind of block that holds the start of the selection. Any other block reports `paragraph`. */
|
|
@@ -49,22 +50,27 @@ export interface ImageInsertion {
|
|
|
49
50
|
alt: string;
|
|
50
51
|
title?: string;
|
|
51
52
|
}
|
|
52
|
-
/** A name in `Keymap`: every format command except `link`, history, and every table
|
|
53
|
-
|
|
53
|
+
/** A name in `Keymap`: every format command except `link`, history, block moves, and every table
|
|
54
|
+
* command. */
|
|
55
|
+
export type ShortcutName = Exclude<FormatCommand, 'link'> | 'undo' | 'redo' | 'moveBlockUp' | 'moveBlockDown' | `table${Capitalize<TableCommand>}`;
|
|
54
56
|
/** Host bindings in ProseMirror key notation, by shortcut name. */
|
|
55
57
|
export type Keymap = Partial<Record<ShortcutName, readonly string[]>>;
|
|
56
58
|
/** Every `ShortcutName`. */
|
|
57
59
|
export declare const shortcutNames: readonly ShortcutName[];
|
|
58
|
-
/** Hints for the browser's input features. A field left out
|
|
60
|
+
/** Hints for the browser's input features, and smart punctuation. A field left out takes its default. */
|
|
59
61
|
export interface TextInputPreferences {
|
|
60
62
|
spellcheck?: boolean;
|
|
61
63
|
autocorrect?: boolean;
|
|
62
64
|
autocapitalize?: 'off' | 'none' | 'on' | 'sentences' | 'words' | 'characters';
|
|
65
|
+
/** Typing a quote or `--` gives a curly quote or a dash, in formatted mode. Off unless true. */
|
|
66
|
+
smartPunctuation?: boolean;
|
|
63
67
|
}
|
|
64
68
|
/** Mount options. Adapters, `labels` and `rendering` are fixed at mount; the rest can change. */
|
|
65
69
|
export interface EditorOptions {
|
|
66
70
|
/** Shows, imports and exports images. Without it and `files`, image Markdown stays literal. */
|
|
67
71
|
images?: ImageAdapter;
|
|
72
|
+
/** Opt-in block suggestions on an empty line. Fixed at mount. */
|
|
73
|
+
slashMenu?: SlashMenuOptions;
|
|
68
74
|
/** Resolves path images and `![[name]]` embeds into images, audio, video, PDFs and file cards. */
|
|
69
75
|
files?: FileAdapter;
|
|
70
76
|
/** Resolves and opens `[[wiki links]]`. Without it they stay literal. */
|
|
@@ -113,6 +119,8 @@ export interface CommandState extends DocumentVersion {
|
|
|
113
119
|
editReferenceDefinition: boolean;
|
|
114
120
|
format: Record<FormatCommand, boolean>;
|
|
115
121
|
table: Record<TableCommand, boolean>;
|
|
122
|
+
moveBlockUp: boolean;
|
|
123
|
+
moveBlockDown: boolean;
|
|
116
124
|
};
|
|
117
125
|
}
|
|
118
126
|
/** The host's handlers, passed to `mount`. Only `changed` is required. */
|
|
@@ -160,6 +168,7 @@ export declare class InkKitEditor {
|
|
|
160
168
|
private ready;
|
|
161
169
|
private destroyed;
|
|
162
170
|
private preservation?;
|
|
171
|
+
private carried?;
|
|
163
172
|
private pasteController;
|
|
164
173
|
private plain;
|
|
165
174
|
private root;
|
|
@@ -182,6 +191,8 @@ export declare class InkKitEditor {
|
|
|
182
191
|
private literalKeys;
|
|
183
192
|
private configuredKeys;
|
|
184
193
|
private readOnlyKeys;
|
|
194
|
+
private suggestions?;
|
|
195
|
+
private suggestionBase?;
|
|
185
196
|
private changePlugin;
|
|
186
197
|
private keys;
|
|
187
198
|
private readonly events;
|
|
@@ -243,7 +254,7 @@ export declare class InkKitEditor {
|
|
|
243
254
|
get editable(): boolean;
|
|
244
255
|
/** Turns editing on or off for both surfaces. Throws `composition` during text composition. */
|
|
245
256
|
setEditable(editable: boolean): void;
|
|
246
|
-
/** Replaces the input
|
|
257
|
+
/** Replaces the input preferences. A field left out takes its default. Throws `composition`
|
|
247
258
|
* during text composition. */
|
|
248
259
|
setTextInputPreferences(preferences: TextInputPreferences): void;
|
|
249
260
|
private applyInputPolicy;
|
|
@@ -254,6 +265,7 @@ export declare class InkKitEditor {
|
|
|
254
265
|
/** An image adapter shows and exports an inserted reference, and so does a file adapter. */
|
|
255
266
|
private get canInsertImages();
|
|
256
267
|
private canQuote;
|
|
268
|
+
private historyInputPlugin;
|
|
257
269
|
private policyPlugin;
|
|
258
270
|
private get literalSurface();
|
|
259
271
|
/** `formatted` or `source`. A TXT document is always `source`. */
|
|
@@ -314,6 +326,10 @@ export declare class InkKitEditor {
|
|
|
314
326
|
/** Runs a table command and returns whether it applied. False in source and TXT modes, outside a
|
|
315
327
|
* table for commands that need one, and at a boundary a move can't cross. */
|
|
316
328
|
table(command: TableCommand, options?: TableOptions, expectedGeneration?: number): boolean;
|
|
329
|
+
/** Moves the blocks at the selection one place up or down in their list, quote, callout, footnote
|
|
330
|
+
* or note, as one undo step. Returns whether they moved: false in source and TXT modes, in a
|
|
331
|
+
* table, and when they are already first or last. */
|
|
332
|
+
moveBlock(direction: BlockMoveDirection, expectedGeneration?: number): boolean;
|
|
317
333
|
/** Cancels pending work and releases the editor. It never rejects. Afterwards every other member
|
|
318
334
|
* throws `destroyed`. */
|
|
319
335
|
destroy(): Promise<void>;
|
|
@@ -345,6 +361,9 @@ export declare class InkKitEditor {
|
|
|
345
361
|
focus?: boolean;
|
|
346
362
|
reveal?: boolean;
|
|
347
363
|
}): void;
|
|
364
|
+
/** Whether two documents are the same note. A move of blocks that read alike, such as a setext
|
|
365
|
+
* heading and the same heading written with `#`, gives an equal document with other source. */
|
|
366
|
+
private sameDocument;
|
|
348
367
|
/** Throws when a document reached by an edit, after every appended normalisation, cannot be
|
|
349
368
|
* saved as preserved Markdown. Dispatch and the replacement commands share this check.
|
|
350
369
|
* `written` is false for history steps and source replacement, which restore or supply a
|
|
@@ -387,8 +406,9 @@ export declare class InkKitEditor {
|
|
|
387
406
|
* control InkKit draws, is left alone. */
|
|
388
407
|
blur(expectedGeneration?: number): void;
|
|
389
408
|
/** Replaces every binding. Keys are in ProseMirror's notation. A key given to two shortcuts goes
|
|
390
|
-
* to the later one, in the order history, formatting, tables, so it lands the same
|
|
391
|
-
* time.
|
|
409
|
+
* to the later one, in the order history, formatting, block moves, tables, so it lands the same
|
|
410
|
+
* way every time. A table binding passes a key it shares with a block move to the move outside
|
|
411
|
+
* a table. */
|
|
392
412
|
setKeymap(keymap: Keymap): void;
|
|
393
413
|
/** Dropped files land as one paragraph per path at the drop point: in place of an empty block, after
|
|
394
414
|
* the top-level block otherwise, so a list or quote is not opened up by them. */
|
|
@@ -413,6 +433,8 @@ export declare class InkKitEditor {
|
|
|
413
433
|
* text is each block's source.
|
|
414
434
|
*/
|
|
415
435
|
private authoredSources;
|
|
436
|
+
private chooseWiki;
|
|
437
|
+
private chooseSlash;
|
|
416
438
|
/** Returns whether the document or the marks the next typed text takes changed. */
|
|
417
439
|
format(command: FormatCommand, options?: FormatOptions, expectedGeneration?: number): boolean;
|
|
418
440
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as registerMermaid, r as InkKitError, t as InkKitEditor } from "./chunks/core-
|
|
1
|
+
import { n as registerMermaid, r as InkKitError, t as InkKitEditor } from "./chunks/core-Bvj0PMMi.js";
|
|
2
2
|
//#region src/index.ts
|
|
3
3
|
registerMermaid(async () => (await import("mermaid")).default);
|
|
4
4
|
//#endregion
|
package/dist/style.css
CHANGED
|
@@ -125,9 +125,13 @@
|
|
|
125
125
|
}
|
|
126
126
|
.inkkit-root .inkkit-table-controls button {
|
|
127
127
|
display: grid;
|
|
128
|
+
/* The icon is larger than the grabbers' short side, so the track itself is
|
|
129
|
+
centered; otherwise it overflows to one side. */
|
|
130
|
+
place-content: center;
|
|
128
131
|
place-items: center;
|
|
129
132
|
box-sizing: border-box;
|
|
130
133
|
margin: 0;
|
|
134
|
+
padding: 0;
|
|
131
135
|
border: 0;
|
|
132
136
|
color: var(--_inkkit-muted);
|
|
133
137
|
background: Canvas;
|
|
@@ -569,9 +573,13 @@
|
|
|
569
573
|
top: 6px;
|
|
570
574
|
right: 6px;
|
|
571
575
|
display: grid;
|
|
576
|
+
place-content: center;
|
|
572
577
|
place-items: center;
|
|
578
|
+
box-sizing: border-box;
|
|
573
579
|
width: 26px;
|
|
574
580
|
height: 24px;
|
|
581
|
+
margin: 0;
|
|
582
|
+
padding: 0;
|
|
575
583
|
border: 0;
|
|
576
584
|
border-radius: 6px;
|
|
577
585
|
background: color-mix(in srgb, CanvasText 10%, transparent);
|
|
@@ -646,15 +654,22 @@
|
|
|
646
654
|
.inkkit-root .ProseMirror li[data-item-type='task'] {
|
|
647
655
|
list-style: none;
|
|
648
656
|
position: relative;
|
|
657
|
+
/* The box is centered on the first line: 1lh is the line height the item's
|
|
658
|
+
text uses, including when it is normal, and --inkkit-checkbox-offset
|
|
659
|
+
moves the box down for a font whose lines look off-center. */
|
|
660
|
+
--_inkkit-task-size: calc(var(--inkkit-font-size, 15px) * 0.933);
|
|
661
|
+
--_inkkit-task-top: calc(
|
|
662
|
+
(1lh - var(--_inkkit-task-size)) / 2 + var(--inkkit-checkbox-offset, 0px)
|
|
663
|
+
);
|
|
649
664
|
}
|
|
650
665
|
|
|
651
666
|
.inkkit-root .ProseMirror li[data-item-type='task']::before {
|
|
652
667
|
content: '';
|
|
653
668
|
position: absolute;
|
|
654
669
|
left: calc(var(--inkkit-font-size, 15px) * -1.667);
|
|
655
|
-
top:
|
|
656
|
-
width:
|
|
657
|
-
height:
|
|
670
|
+
top: var(--_inkkit-task-top);
|
|
671
|
+
width: var(--_inkkit-task-size);
|
|
672
|
+
height: var(--_inkkit-task-size);
|
|
658
673
|
box-sizing: border-box;
|
|
659
674
|
border: 1.5px solid color-mix(in srgb, CanvasText 35%, transparent);
|
|
660
675
|
border-radius: 4px;
|
|
@@ -674,8 +689,7 @@
|
|
|
674
689
|
content: '';
|
|
675
690
|
position: absolute;
|
|
676
691
|
left: calc(var(--inkkit-font-size, 15px) * -1.333);
|
|
677
|
-
top: 0.
|
|
678
|
-
margin-top: calc(var(--inkkit-font-size, 15px) * 0.133);
|
|
692
|
+
top: calc(var(--_inkkit-task-top) + var(--inkkit-font-size, 15px) * 0.133);
|
|
679
693
|
width: calc(var(--inkkit-font-size, 15px) * 0.2);
|
|
680
694
|
height: calc(var(--inkkit-font-size, 15px) * 0.467);
|
|
681
695
|
border: solid Canvas;
|
|
@@ -939,3 +953,51 @@
|
|
|
939
953
|
var(--inkkit-focus-offset, -2px)
|
|
940
954
|
);
|
|
941
955
|
}
|
|
956
|
+
|
|
957
|
+
.inkkit-root .inkkit-suggestions {
|
|
958
|
+
position: fixed;
|
|
959
|
+
z-index: 100;
|
|
960
|
+
box-sizing: border-box;
|
|
961
|
+
width: var(--inkkit-menu-width, 240px);
|
|
962
|
+
max-width: calc(100vw - 8px);
|
|
963
|
+
max-height: 264px;
|
|
964
|
+
overflow-y: auto;
|
|
965
|
+
overscroll-behavior: contain;
|
|
966
|
+
padding: 4px;
|
|
967
|
+
border-radius: var(--inkkit-menu-radius, 8px);
|
|
968
|
+
background: var(--inkkit-menu-background, light-dark(#fff, #252529));
|
|
969
|
+
color: var(--inkkit-menu-text, CanvasText);
|
|
970
|
+
box-shadow: var(--inkkit-menu-shadow, 0 4px 18px #0003);
|
|
971
|
+
font: 14px / 24px var(--inkkit-font-family, system-ui, sans-serif);
|
|
972
|
+
}
|
|
973
|
+
.inkkit-root .inkkit-suggestions [role='option'] {
|
|
974
|
+
box-sizing: border-box;
|
|
975
|
+
height: 32px;
|
|
976
|
+
display: flex;
|
|
977
|
+
align-items: center;
|
|
978
|
+
gap: 8px;
|
|
979
|
+
padding: 4px 8px;
|
|
980
|
+
border-radius: 4px;
|
|
981
|
+
cursor: default;
|
|
982
|
+
white-space: nowrap;
|
|
983
|
+
overflow: hidden;
|
|
984
|
+
}
|
|
985
|
+
.inkkit-root .inkkit-suggestions [aria-selected='true'] {
|
|
986
|
+
background: var(--inkkit-menu-highlight, light-dark(#e8e8ed, #414146));
|
|
987
|
+
}
|
|
988
|
+
.inkkit-root .inkkit-suggestion-glyph {
|
|
989
|
+
display: inline-block;
|
|
990
|
+
flex: 0 0 22px;
|
|
991
|
+
text-align: center;
|
|
992
|
+
font-size: 12px;
|
|
993
|
+
}
|
|
994
|
+
.inkkit-root .inkkit-suggestion-glyph::before {
|
|
995
|
+
content: attr(data-glyph);
|
|
996
|
+
}
|
|
997
|
+
.inkkit-root .inkkit-suggestions-status {
|
|
998
|
+
position: absolute;
|
|
999
|
+
width: 1px;
|
|
1000
|
+
height: 1px;
|
|
1001
|
+
clip-path: inset(50%);
|
|
1002
|
+
overflow: hidden;
|
|
1003
|
+
}
|
package/dist/types.d.ts
CHANGED
|
@@ -74,6 +74,8 @@ export interface WikiLinkReference {
|
|
|
74
74
|
}
|
|
75
75
|
/** Resolves and opens wiki links. The host owns lookup, permissions and navigation. */
|
|
76
76
|
export interface WikiLinkAdapter {
|
|
77
|
+
/** Matches note names for a typed `[[` query. Late answers are ignored. */
|
|
78
|
+
suggest?(query: string, context: FileContext): Promise<readonly string[]>;
|
|
77
79
|
/** Whether the target is missing, for presentation only. */
|
|
78
80
|
resolve?(reference: WikiLinkReference, context: DocumentContext): {
|
|
79
81
|
missing?: boolean;
|
|
@@ -228,6 +230,26 @@ export interface ViewportSnapshot {
|
|
|
228
230
|
}
|
|
229
231
|
/** Built-in editor text. Hosts can override individual labels at mount time. */
|
|
230
232
|
export interface EditorLabels {
|
|
233
|
+
suggestions: string;
|
|
234
|
+
suggestionsEmpty: string;
|
|
235
|
+
suggestionsLoading: string;
|
|
236
|
+
slashHeading1: string;
|
|
237
|
+
slashHeading2: string;
|
|
238
|
+
slashHeading3: string;
|
|
239
|
+
slashBulletList: string;
|
|
240
|
+
slashOrderedList: string;
|
|
241
|
+
slashTaskList: string;
|
|
242
|
+
slashQuote: string;
|
|
243
|
+
slashCodeBlock: string;
|
|
244
|
+
slashTable: string;
|
|
245
|
+
slashCallout: string;
|
|
246
|
+
slashDivider: string;
|
|
247
|
+
slashDiagram: string;
|
|
248
|
+
slashNote: string;
|
|
249
|
+
slashTip: string;
|
|
250
|
+
slashImportant: string;
|
|
251
|
+
slashWarning: string;
|
|
252
|
+
slashCaution: string;
|
|
231
253
|
formattedEditor: string;
|
|
232
254
|
plainTextEditor: string;
|
|
233
255
|
sourceEditor: string;
|
|
@@ -272,6 +294,8 @@ export interface Heading extends Readonly<DocumentVersion> {
|
|
|
272
294
|
}
|
|
273
295
|
/** A command for `table`. `insert` makes a table; the others work on the table at the selection. */
|
|
274
296
|
export type TableCommand = 'insert' | 'addRowBefore' | 'addRowAfter' | 'addColumnBefore' | 'addColumnAfter' | 'deleteRow' | 'deleteColumn' | 'deleteTable' | 'alignLeft' | 'alignCenter' | 'alignRight' | 'moveRowUp' | 'moveRowDown' | 'moveColumnLeft' | 'moveColumnRight' | 'sortRows' | 'exit';
|
|
297
|
+
/** Where `moveBlock` moves the blocks at the selection. */
|
|
298
|
+
export type BlockMoveDirection = 'up' | 'down';
|
|
275
299
|
/** Each option belongs to one command; any other combination is refused. */
|
|
276
300
|
export interface TableOptions {
|
|
277
301
|
/** `insert`: 1 to 100, counting the header row. Defaults to 3. */
|
|
@@ -285,3 +309,15 @@ export interface TableOptions {
|
|
|
285
309
|
/** `sortRows`. Defaults to `text`. */
|
|
286
310
|
comparison?: 'text' | 'number';
|
|
287
311
|
}
|
|
312
|
+
export type SlashCommandName = 'heading1' | 'heading2' | 'heading3' | 'bulletList' | 'orderedList' | 'taskList' | 'quote' | 'codeBlock' | 'table' | 'callout' | 'divider' | 'diagram';
|
|
313
|
+
export interface SlashCommand {
|
|
314
|
+
name: string;
|
|
315
|
+
keywords?: readonly string[];
|
|
316
|
+
/** Returns Markdown to insert in place of the trigger. Undefined cancels the action. */
|
|
317
|
+
action(context: DocumentContext): string | undefined | Promise<string | undefined>;
|
|
318
|
+
}
|
|
319
|
+
export interface SlashMenuOptions {
|
|
320
|
+
enabled?: boolean;
|
|
321
|
+
commands?: readonly SlashCommandName[];
|
|
322
|
+
customCommands?: readonly SlashCommand[];
|
|
323
|
+
}
|