@aicayzer/inkkit 0.0.18 → 0.1.1

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.
Files changed (90) hide show
  1. package/NOTICE +4 -2
  2. package/README.md +11 -7
  3. package/dist/THIRD-PARTY-NOTICES.txt +2742 -0
  4. package/dist/chunks/core-CYp5ONPO.js +56519 -0
  5. package/dist/chunks/highlight-BW9W8PtS.js +14122 -0
  6. package/dist/core.d.ts +2 -5
  7. package/dist/core.js +2 -2
  8. package/dist/editor.d.ts +229 -47
  9. package/dist/index.js +5 -3
  10. package/dist/style.css +231 -202
  11. package/dist/types.d.ts +143 -18
  12. package/package.json +16 -13
  13. package/dist/autolink.d.ts +0 -1
  14. package/dist/autolink.js +0 -18
  15. package/dist/callouts.d.ts +0 -25
  16. package/dist/callouts.js +0 -288
  17. package/dist/clipboard.d.ts +0 -11
  18. package/dist/clipboard.js +0 -261
  19. package/dist/code-fences.d.ts +0 -8
  20. package/dist/code-fences.js +0 -171
  21. package/dist/comments.d.ts +0 -76
  22. package/dist/comments.js +0 -545
  23. package/dist/cursor.d.ts +0 -2
  24. package/dist/cursor.js +0 -40
  25. package/dist/decorations.d.ts +0 -2
  26. package/dist/decorations.js +0 -67
  27. package/dist/dialect.d.ts +0 -9
  28. package/dist/dialect.js +0 -446
  29. package/dist/drop-placement.d.ts +0 -19
  30. package/dist/drop-placement.js +0 -47
  31. package/dist/editor.js +0 -2673
  32. package/dist/files.d.ts +0 -40
  33. package/dist/files.js +0 -133
  34. package/dist/highlight.d.ts +0 -1
  35. package/dist/highlight.js +0 -136
  36. package/dist/html-import.d.ts +0 -13
  37. package/dist/html-import.js +0 -477
  38. package/dist/image-blocks.d.ts +0 -86
  39. package/dist/image-blocks.js +0 -329
  40. package/dist/images.d.ts +0 -51
  41. package/dist/images.js +0 -398
  42. package/dist/inline-highlight.d.ts +0 -6
  43. package/dist/inline-highlight.js +0 -112
  44. package/dist/labels.d.ts +0 -36
  45. package/dist/labels.js +0 -34
  46. package/dist/link-safety.d.ts +0 -17
  47. package/dist/link-safety.js +0 -29
  48. package/dist/linked-syntax.d.ts +0 -48
  49. package/dist/linked-syntax.js +0 -320
  50. package/dist/literals.d.ts +0 -20
  51. package/dist/literals.js +0 -216
  52. package/dist/mermaid.d.ts +0 -28
  53. package/dist/mermaid.js +0 -404
  54. package/dist/outline.d.ts +0 -22
  55. package/dist/outline.js +0 -79
  56. package/dist/paste-html.d.ts +0 -31
  57. package/dist/paste-html.js +0 -462
  58. package/dist/paste.d.ts +0 -33
  59. package/dist/paste.js +0 -591
  60. package/dist/portable-files.d.ts +0 -10
  61. package/dist/portable-files.js +0 -36
  62. package/dist/preserve.d.ts +0 -38
  63. package/dist/preserve.js +0 -1396
  64. package/dist/print.d.ts +0 -7
  65. package/dist/print.js +0 -406
  66. package/dist/reference-clipboard.d.ts +0 -8
  67. package/dist/reference-clipboard.js +0 -201
  68. package/dist/references.d.ts +0 -16
  69. package/dist/references.js +0 -418
  70. package/dist/scroll.d.ts +0 -15
  71. package/dist/scroll.js +0 -27
  72. package/dist/search.d.ts +0 -15
  73. package/dist/search.js +0 -202
  74. package/dist/selection.d.ts +0 -1
  75. package/dist/selection.js +0 -59
  76. package/dist/source.d.ts +0 -16
  77. package/dist/source.js +0 -57
  78. package/dist/spreadsheet.d.ts +0 -8
  79. package/dist/spreadsheet.js +0 -289
  80. package/dist/table-alignment.d.ts +0 -2
  81. package/dist/table-alignment.js +0 -46
  82. package/dist/tables.d.ts +0 -27
  83. package/dist/tables.js +0 -344
  84. package/dist/tasks.d.ts +0 -3
  85. package/dist/tasks.js +0 -51
  86. package/dist/text-ranges.d.ts +0 -29
  87. package/dist/text-ranges.js +0 -256
  88. package/dist/types.js +0 -8
  89. package/dist/wiki-view.d.ts +0 -21
  90. package/dist/wiki-view.js +0 -78
package/dist/core.d.ts CHANGED
@@ -1,7 +1,4 @@
1
1
  export { InkKitEditor } from './editor.js';
2
- export type { EditorEvents, EditorOptions, TextInputPreferences, CommandState, EditingMode, CaretState, Mark, Block, FormatCommand, Keymap, } from './editor.js';
3
- export type { TableCommand, TableOptions } from './tables.js';
4
- export type { Heading } from './outline.js';
2
+ export type { EditorEvents, EditorOptions, TextInputPreferences, CommandState, EditingMode, CaretState, Mark, Block, FormatCommand, FormatOptions, KeyInput, ImageInsertion, ShortcutName, Keymap, } from './editor.js';
5
3
  export { InkKitError } from './types.js';
6
- export type { DocumentFormat, DocumentContext, DocumentInput, DocumentSnapshot, EditorErrorCode, ImageAdapter, WikiLinkReference, WikiLinkAdapter, FileReference, FileContext, FilePresentation, FileAdapter, CapturedImage, PortableImage, ClipboardInput, ClipboardOutput, ClipboardImage, ClipboardDiagram, PrintableDocument, PrintableWarning, TextRange, ReadableTextSnapshot, TextRect, ViewportInsets, ViewportOptions, ViewportSnapshot, } from './types.js';
7
- export type { EditorLabels } from './labels.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';
package/dist/core.js CHANGED
@@ -1,2 +1,2 @@
1
- export { InkKitEditor } from './editor.js';
2
- export { InkKitError } from './types.js';
1
+ import { r as InkKitError, t as InkKitEditor } from "./chunks/core-CYp5ONPO.js";
2
+ export { InkKitEditor, InkKitError };
package/dist/editor.d.ts CHANGED
@@ -1,8 +1,7 @@
1
- import { type EditorLabels } from './labels.js';
2
- import { type TableCommand, type TableOptions } from './tables.js';
3
- import { type DocumentInput, type DocumentSnapshot, type ImageAdapter, type FileAdapter, type WikiLinkAdapter, type ClipboardInput, type ClipboardOutput, type PrintableDocument, type TextRange, type ReadableTextSnapshot, type TextRect, type ViewportOptions, type ViewportSnapshot } from './types.js';
4
- import { type Heading } from './outline.js';
1
+ 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 } from './types.js';
2
+ /** An inline format that `CaretState` can report. */
5
3
  export type Mark = 'bold' | 'italic' | 'strikethrough' | 'highlight' | 'code' | 'link';
4
+ /** The kind of block that holds the start of the selection. Any other block reports `paragraph`. */
6
5
  export type Block = {
7
6
  type: 'paragraph';
8
7
  } | {
@@ -17,44 +16,84 @@ export type Block = {
17
16
  } | {
18
17
  type: 'taskList';
19
18
  };
19
+ /** `source` shows the Markdown or literal text in a textarea. A TXT document is always `source`. */
20
20
  export type EditingMode = 'source' | 'formatted';
21
+ /** The formatting at the selection, for host toolbars. */
21
22
  export interface CaretState {
23
+ /** At a caret, the marks the next typed text takes. For a range, every mark found in it. */
22
24
  marks: Mark[];
23
25
  block: Block;
24
26
  /** One quote holds the whole selection; the block is what sits inside it. */
25
27
  quoted: boolean;
26
28
  }
27
- export type FormatCommand = 'heading' | 'paragraph' | 'bold' | 'italic' | 'strikethrough' | 'highlight' | 'code' | 'codeBlock' | 'quote' | 'bulletList' | 'orderedList' | 'taskList' | 'link';
28
- /** Host bindings by documented formatting, history or table shortcut name. */
29
- export type Keymap = Record<string, string[]>;
29
+ declare const formatCommands: readonly ['heading1', 'heading2', 'heading3', 'heading4', 'heading5', 'heading6', 'paragraph', 'bold', 'italic', 'strikethrough', 'highlight', 'code', 'codeBlock', 'quote', 'bulletList', 'orderedList', 'taskList', 'link'];
30
+ /** A command for `format`. */
31
+ export type FormatCommand = (typeof formatCommands)[number];
32
+ /** `destination` goes only with `link`, and `language` only with `codeBlock`. */
33
+ export interface FormatOptions {
34
+ destination?: string;
35
+ language?: string;
36
+ }
37
+ /** A key press for `keyDown`. An omitted modifier is not held. */
38
+ export interface KeyInput {
39
+ key: string;
40
+ code?: string;
41
+ metaKey?: boolean;
42
+ ctrlKey?: boolean;
43
+ altKey?: boolean;
44
+ shiftKey?: boolean;
45
+ }
46
+ /** An image to insert by the reference its adapter already stored it under. */
47
+ export interface ImageInsertion {
48
+ reference: string;
49
+ alt: string;
50
+ title?: string;
51
+ }
52
+ /** A name in `Keymap`: every format command except `link`, history, and every table command. */
53
+ export type ShortcutName = Exclude<FormatCommand, 'link'> | 'undo' | 'redo' | `table${Capitalize<TableCommand>}`;
54
+ /** Host bindings in ProseMirror key notation, by shortcut name. */
55
+ export type Keymap = Partial<Record<ShortcutName, readonly string[]>>;
56
+ /** Every `ShortcutName`. */
57
+ export declare const shortcutNames: readonly ShortcutName[];
58
+ /** Hints for the browser's input features. A field left out leaves the behavior to the browser. */
30
59
  export interface TextInputPreferences {
31
60
  spellcheck?: boolean;
32
61
  autocorrect?: boolean;
33
62
  autocapitalize?: 'off' | 'none' | 'on' | 'sentences' | 'words' | 'characters';
34
63
  }
64
+ /** Mount options. Adapters, `labels` and `rendering` are fixed at mount; the rest can change. */
35
65
  export interface EditorOptions {
66
+ /** Shows, imports and exports images. Without it and `files`, image Markdown stays literal. */
36
67
  images?: ImageAdapter;
68
+ /** Resolves path images and `![[name]]` embeds into images, audio, video, PDFs and file cards. */
37
69
  files?: FileAdapter;
70
+ /** Resolves and opens `[[wiki links]]`. Without it they stay literal. */
38
71
  wikiLinks?: WikiLinkAdapter;
72
+ /** Defaults to true. See `setEditable`. */
39
73
  editable?: boolean;
40
74
  textInput?: TextInputPreferences;
75
+ /** Replaces built-in text and accessible names. */
41
76
  labels?: Partial<EditorLabels>;
77
+ /** See `setKeymap`. */
42
78
  keymap?: Keymap;
43
79
  rendering?: {
80
+ /** Defaults to true. */
44
81
  codeHighlighting?: boolean;
82
+ /** Defaults to true. */
45
83
  diagramPreview?: boolean;
46
84
  };
47
85
  }
48
- export interface CommandState {
49
- documentId: string;
50
- generation: number;
51
- revision: number;
86
+ /** What the editor can do now. Availability is the state at the time of the call, not a promise. */
87
+ export interface CommandState extends DocumentVersion {
52
88
  format: 'md' | 'txt';
53
89
  mode: EditingMode;
54
90
  editable: boolean;
91
+ /** Text composition (IME) is in progress. */
55
92
  composing: boolean;
93
+ /** An image import is running. */
56
94
  pending: boolean;
57
95
  caret: CaretState;
96
+ /** Present when the selection is in a table. `rows` includes the header row. */
58
97
  table?: {
59
98
  row: number;
60
99
  column: number;
@@ -76,25 +115,34 @@ export interface CommandState {
76
115
  table: Record<TableCommand, boolean>;
77
116
  };
78
117
  }
118
+ /** The host's handlers, passed to `mount`. Only `changed` is required. */
79
119
  export interface EditorEvents {
80
- changed(markdown: string, generation: number): void;
81
- stateChanged(state: CaretState): void;
120
+ /** The document's text changed. Not sent for a load, a reload or a refused edit. */
121
+ changed(snapshot: DocumentSnapshot): void;
122
+ /** Availability or the caret changed, and once after each load. */
82
123
  commandStateChanged?(state: CommandState): void;
83
- openLink(href: string): void;
84
- copy(text: string): void;
85
- error?(error: Error): void;
124
+ /** A primary click with Mod on a link. Without it, links don't open. */
125
+ openLink?(href: string): void;
126
+ /** The Copy button on a code block was clicked. Without this handler, no button is drawn. */
127
+ copy?(text: string): void;
128
+ /** A failure that no call is waiting for, such as one in an edit the person made. */
129
+ error?(error: InkKitError): void;
130
+ /** The person copied or cut a selection that holds an image or a diagram. Resolve after the
131
+ * native clipboard write succeeds; a cut removes the selection only then. */
86
132
  clipboard?(content: ClipboardOutput): void | Promise<void>;
87
133
  }
134
+ /** Every member of `EditorEvents`. The type check below fails to compile when one is left out. */
135
+ export declare const editorEvents: readonly ["changed", "commandStateChanged", "openLink", "copy", "error", "clipboard"];
136
+ /**
137
+ * The editor. Create it with `InkKitEditor.mount`, load a document, and read it back with
138
+ * `snapshot`. The reference is https://github.com/aicayzer/inkkit/blob/main/docs/api.md.
139
+ */
88
140
  export declare class InkKitEditor {
89
- private readonly events;
90
141
  private readonly options;
91
142
  private editor;
92
143
  private lastMarkdown;
93
- private documentId;
94
144
  private formatType;
95
- private revision;
96
- private documentEpoch;
97
- private operationSequence;
145
+ private readonly session;
98
146
  private exportControllers;
99
147
  private plainComposing;
100
148
  private plainSearch;
@@ -109,7 +157,6 @@ export declare class InkKitEditor {
109
157
  private mode;
110
158
  private sourcePreservations;
111
159
  private sourceTexts;
112
- private outlineEpoch;
113
160
  private ready;
114
161
  private destroyed;
115
162
  private preservation?;
@@ -118,46 +165,105 @@ export declare class InkKitEditor {
118
165
  private root;
119
166
  private ownsRootClass;
120
167
  private clickHandler?;
168
+ private auxClickHandler?;
169
+ private untrackLinkModifier?;
121
170
  private footnoteKeyHandler?;
122
171
  private copyHandler?;
123
172
  private originalSource;
124
- private generation;
125
173
  private reportingSuppressed;
126
174
  private loading;
127
175
  private readonly textIdentity;
176
+ private call?;
128
177
  private textScope?;
129
178
  private viewportContainer?;
130
179
  private viewportInsets;
131
180
  private writable;
132
181
  private inputPreferences;
133
- private policyEpoch;
134
182
  private literalKeys;
135
183
  private configuredKeys;
136
184
  private readOnlyKeys;
137
185
  private changePlugin;
138
186
  private keys;
187
+ private readonly events;
188
+ /** How many of each state event the host has been sent. */
189
+ private readonly sentEvents;
139
190
  private constructor();
140
191
  private context;
192
+ /** The generation of the loaded document, for the composition check of native input. */
193
+ private get generation();
194
+ /** What `changed` reports for the document's new text. */
195
+ private changeSnapshot;
141
196
  private cancelExports;
197
+ /** Runs asynchronous output work for the document `captured` describes, and throws
198
+ * `stale-document` when the document, its revision or the editing mode changed meanwhile. */
142
199
  private exportContent;
200
+ /** Throws unless the document `captured` describes is still current, alive, not composing and
201
+ * has no import pending. */
202
+ private assertCaptured;
203
+ /** Throws unless a deferred cut can still remove what it copied: the document, its revision,
204
+ * the editing mode and editability are as they were when the cut started. */
205
+ private assertCut;
206
+ /** What file and wiki-link views capture: the adapter context, and whether the same load is
207
+ * still current. Edits do not make their work stale. */
208
+ private adapterCapture;
143
209
  private mediaPolicy;
144
210
  private assertAlive;
211
+ private assertReady;
212
+ /** Checks, in order, that the editor is alive, that `expectedGeneration` is a generation, and
213
+ * that the document is loaded, current, not composing and has no import pending. */
145
214
  private assertCurrent;
146
215
  private assertMutation;
216
+ /**
217
+ * Runs one facade call, so that its failure reaches the caller once and coded, and a failed call
218
+ * changes nothing and sends nothing. An edit that the preservation check refuses during the call
219
+ * is thrown, not sent to `events.error`. When the call fails with a refusal or another coded
220
+ * failure, every step it took is undone: the document, selection and history return to their
221
+ * state before the call, and the state events it raised are dropped. An `internal` failure keeps
222
+ * what happened and sends its events, since the editor's state can no longer be trusted to match.
223
+ * Anything else thrown arrives as an `InkKitError`. A call made inside another runs as part of
224
+ * it. Promises reject instead of throwing.
225
+ */
226
+ private facadeCall;
227
+ /** Sends a finished call's state events in order. Each event reports the whole of its state, so
228
+ * once a call made from one of the host's handlers has sent a newer event of a kind, the call's
229
+ * remaining events of that kind are out of date and are dropped. */
230
+ private deliver;
231
+ /** What a failed call puts back. */
232
+ private restorePoint;
233
+ private finish;
234
+ /** Reports a refused edit to the facade call that made it, or else to `events.error`. */
235
+ private refuse;
236
+ /** Reports a failure no call is waiting for. */
237
+ private report;
238
+ /** Runs a facade method for something the person did, such as a shortcut. Its failure goes to
239
+ * `events.error`, unless a host call such as `keyDown` is waiting for it. */
240
+ private forPerson;
147
241
  private get composing();
242
+ /** Whether the person can edit. A read-only editor still permits selection, copying and find. */
148
243
  get editable(): boolean;
244
+ /** Turns editing on or off for both surfaces. Throws `composition` during text composition. */
149
245
  setEditable(editable: boolean): void;
246
+ /** Replaces the input hints. A field left out leaves the browser's behavior. Throws `composition`
247
+ * during text composition. */
150
248
  setTextInputPreferences(preferences: TextInputPreferences): void;
151
249
  private applyInputPolicy;
152
250
  private publishCommandState;
251
+ /** What the editor can do now, for enabling host controls. Unlike `snapshot`, it works during
252
+ * composition. */
153
253
  commandState(expectedGeneration?: number): CommandState;
254
+ /** An image adapter shows and exports an inserted reference, and so does a file adapter. */
255
+ private get canInsertImages();
154
256
  private canQuote;
155
257
  private policyPlugin;
156
258
  private get literalSurface();
259
+ /** `formatted` or `source`. A TXT document is always `source`. */
157
260
  get editingMode(): EditingMode;
158
261
  private currentText;
262
+ /** Switches between formatted and source editing. Returns false when the mode is already set, and
263
+ * for TXT. */
159
264
  setEditingMode(mode: EditingMode, expectedGeneration?: number): boolean;
160
265
  private updateSurface;
266
+ /** Replaces the complete source as one undo step. Returns false for identical source. */
161
267
  replaceSource(text: string, expectedGeneration?: number): boolean;
162
268
  private applySource;
163
269
  /**
@@ -176,10 +282,16 @@ export declare class InkKitEditor {
176
282
  /** Brings the formatted document up to the source that was typed. */
177
283
  private settleSource;
178
284
  private commitSource;
285
+ /** Returns whether a history step applied. */
179
286
  undo(expectedGeneration?: number): boolean;
287
+ /** Returns whether a history step applied. */
180
288
  redo(expectedGeneration?: number): boolean;
181
289
  private replaceLiteralSelection;
290
+ /** The complete current text, which is what a host saves. It throws rather than return partial
291
+ * text. */
182
292
  snapshot(expectedGeneration?: number): DocumentSnapshot;
293
+ /** The whole document as standalone HTML for printing. Rejects rather than return partial
294
+ * output. */
183
295
  printableSnapshot(expectedGeneration?: number): Promise<PrintableDocument>;
184
296
  /**
185
297
  * The document to export. Source typed in the source editor has not reached
@@ -187,20 +299,46 @@ export declare class InkKitEditor {
187
299
  * read from the text stands in without touching history.
188
300
  */
189
301
  private exportDocument;
190
- clipboardSnapshot(all?: boolean): Promise<ClipboardOutput>;
191
- paste(input: ClipboardInput): Promise<void>;
302
+ /** Prepares the document or the selection for the native clipboard. Rejects with `stale-document`
303
+ * if the document changes first. */
304
+ clipboardSnapshot(scope?: ClipboardScope, expectedGeneration?: number): Promise<ClipboardOutput>;
305
+ /** Pastes content the host read from the native clipboard. Capture it once; don't read the
306
+ * clipboard again while this runs. */
307
+ paste(input: ClipboardInput, expectedGeneration?: number): Promise<void>;
308
+ /** Shows or hides author comments. Presentation only: the revision, history and dirty state don't
309
+ * change. */
192
310
  setCommentsVisible(visible: boolean): void;
193
- pasteAsPlainText(text: string): void;
194
- table(command: TableCommand, options?: TableOptions): boolean;
311
+ /** Inserts `text` literally at the selection and returns whether the document changed. */
312
+ pasteAsPlainText(text: string, expectedGeneration?: number): boolean;
313
+ private insertPlainText;
314
+ /** Runs a table command and returns whether it applied. False in source and TXT modes, outside a
315
+ * table for commands that need one, and at a boundary a move can't cross. */
316
+ table(command: TableCommand, options?: TableOptions, expectedGeneration?: number): boolean;
317
+ /** Cancels pending work and releases the editor. It never rejects. Afterwards every other member
318
+ * throws `destroyed`. */
195
319
  destroy(): Promise<void>;
196
320
  private keymapPlugin;
197
321
  private copySourceSelection;
322
+ /** Builds the editor in `root`. It has no document until `loadDocument`. Rejects with
323
+ * `invalid-argument` for a bad root, handler or option. */
198
324
  static mount(root: HTMLElement, events: EditorEvents, options?: EditorOptions): Promise<InkKitEditor>;
325
+ /** Replaces the document. The generation must be greater than the loaded one. A failed load
326
+ * changes nothing. */
199
327
  loadDocument(input: DocumentInput): void;
200
- reloadDocument(input: DocumentInput): void;
328
+ /** Moves focus off whichever of InkKit's text surfaces holds it; other focus is left alone. */
329
+ private releaseFocus;
330
+ /** Replaces the document with a newer version of it, keeping the selection, focus, scroll
331
+ * position and Markdown editing mode. With `expectedGeneration`, the loaded document must be
332
+ * that generation. */
333
+ reloadDocument(input: DocumentInput, expectedGeneration?: number): void;
334
+ /** Names the scroll container and the host chrome that overlaps the editor. It replaces earlier
335
+ * settings. */
201
336
  setViewport(options: ViewportOptions): void;
337
+ /** The visible rectangle, the insets and the scroll offsets. */
202
338
  viewport(): ViewportSnapshot;
203
339
  private readableScope;
340
+ /** The readable text and selection. Ranges from it go stale when the document, its revision or
341
+ * the mode changes. */
204
342
  textSnapshot(expectedGeneration?: number): ReadableTextSnapshot;
205
343
  private validateTextRange;
206
344
  selectTextRange(range: TextRange, options?: {
@@ -212,38 +350,52 @@ export declare class InkKitEditor {
212
350
  * `written` is false for history steps and source replacement, which restore or supply a
213
351
  * document that may hold comment text the formatted editor would refuse to accept typed. */
214
352
  private assertPreserved;
353
+ /** Replaces `range` with literal text as one undo step. Returns whether the text changed. */
215
354
  replaceTextRange(range: TextRange, text: string): boolean;
216
- textRangeRects(range: TextRange): readonly TextRect[];
355
+ /** Measures ranges in client coordinates, with one array of rectangles for each. It measures only
356
+ * when called. */
217
357
  textRangesRects(ranges: readonly TextRange[]): readonly (readonly TextRect[])[];
358
+ /** The ranges of the snapshot that are inside the viewport now. */
218
359
  visibleTextRanges(snapshotId: string): readonly TextRange[];
360
+ /** Scrolls `range` into the viewport, unfolding a callout that holds it. */
219
361
  revealTextRange(range: TextRange): void;
220
362
  private revealRects;
221
363
  private revealCurrentSelection;
222
364
  private revealLiteralSelection;
223
365
  private load;
224
- find(text: string, expectedGeneration?: number): void;
366
+ /** Selects the next match and returns whether there was one. */
367
+ find(text: string, expectedGeneration?: number): boolean;
368
+ /** Replaces the selected match, or the next one, and returns whether text changed. */
225
369
  replace(search: string, replacement: string, expectedGeneration?: number): boolean;
370
+ /** Replaces every non-overlapping match once and returns how many. */
226
371
  replaceAll(search: string, replacement: string, expectedGeneration?: number): number;
227
372
  private replaceMatches;
228
373
  private outlineContext;
374
+ /** The outline in document order. Entries go stale when the document changes. */
229
375
  headings(expectedGeneration?: number): readonly Heading[];
376
+ /** Moves to `heading`. Returns true, or throws `stale-document` for a stale entry. */
230
377
  navigateHeading(heading: Heading): boolean;
231
- /** Buffered native typing follows the same input rules as direct typing. */
378
+ /** Buffered native typing: input rules apply as if its last character were typed after the rest. */
232
379
  insertText(text: string, generation: number): boolean;
233
- /** Let existing keymaps handle buffered editing commands before native fallback. */
234
- keyDown(key: string, code: string, metaKey: boolean, ctrlKey: boolean, altKey: boolean, shiftKey: boolean, generation: number): boolean;
235
- focus(): void;
236
- /** Binds keys, in ProseMirror's names, to the formatting each shortcut runs. Walked in the table's
237
- * order, so a key given to two shortcuts lands the same way every time. */
380
+ /**
381
+ * A key the host's native input received, run through InkKit's key handling. Returns whether
382
+ * InkKit handled it; when it did, the host must not also handle it natively.
383
+ */
384
+ keyDown(input: KeyInput, expectedGeneration: number): boolean;
385
+ focus(expectedGeneration?: number): void;
386
+ /** Moves focus off InkKit's text surfaces. Focus anywhere else, such as in a host control or a
387
+ * control InkKit draws, is left alone. */
388
+ blur(expectedGeneration?: number): void;
389
+ /** 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 way every
391
+ * time. */
238
392
  setKeymap(keymap: Keymap): void;
239
393
  /** Dropped files land as one paragraph per path at the drop point: in place of an empty block, after
240
394
  * the top-level block otherwise, so a list or quote is not opened up by them. */
241
- insertPaths(paths: string[], x: number, y: number): void;
242
- insertImages(images: {
243
- path: string;
244
- alt: string;
245
- title?: string;
246
- }[], x?: number, y?: number): void;
395
+ insertPaths(paths: string[], at: ClientPoint, expectedGeneration?: number): boolean;
396
+ /** Inserts images by reference, at the selection or the drop point `at`. Returns false when it
397
+ * does nothing. */
398
+ insertImages(images: ImageInsertion[], at?: ClientPoint, expectedGeneration?: number): boolean;
247
399
  private insertInline;
248
400
  private insertBlocks;
249
401
  private withMarkRunSelected;
@@ -251,8 +403,38 @@ export declare class InkKitEditor {
251
403
  private list;
252
404
  private quote;
253
405
  private unquote;
254
- format(command: FormatCommand, arg?: string | number): void;
255
- editReferenceDefinition(label: string, destination: string, title?: string): boolean;
256
- insertFootnote(label?: string): void;
257
- navigateFootnote(target: 'definition' | 'reference'): boolean;
406
+ /** Changes the selected textblocks' type, keeping everything they hold. */
407
+ private textblockType;
408
+ /**
409
+ * The authored Markdown of the textblocks at `positions`, found by saving
410
+ * the document once with each block's content replaced by a numbered mark
411
+ * no one writes. The saved text between the marks is the current text
412
+ * between those blocks, so what lies between the same pieces of the current
413
+ * text is each block's source.
414
+ */
415
+ private authoredSources;
416
+ /** Returns whether the document or the marks the next typed text takes changed. */
417
+ format(command: FormatCommand, options?: FormatOptions, expectedGeneration?: number): boolean;
418
+ /**
419
+ * Refuses a link destination that is empty, that opens anything but a web, mail or phone address,
420
+ * or that the Markdown writer cannot save so that it reads back the same.
421
+ */
422
+ private checkDestination;
423
+ /**
424
+ * With a destination, sets the link: on the whole link that holds the caret or the selection,
425
+ * keeping its title, or else on the selection. A reference link's shared definition is edited
426
+ * instead. Without one, removes that whole link, or every link in the selection. Marks waiting
427
+ * for the next typed text stay waiting.
428
+ */
429
+ private link;
430
+ /** Changes the destination, and optionally the title, of the shared definition for `label`.
431
+ * Returns false when no definition has that label. */
432
+ editReferenceDefinition(label: string, destination: string, title?: string, expectedGeneration?: number): boolean;
433
+ /** Inserts a footnote reference, and a definition when the label has none, and returns whether
434
+ * it did: formatted Markdown only. */
435
+ insertFootnote(label?: string, expectedGeneration?: number): boolean;
436
+ /** Moves to the definition, or the first reference, of the footnote at the caret. Returns whether
437
+ * there was one. */
438
+ navigateFootnote(target: 'definition' | 'reference', expectedGeneration?: number): boolean;
258
439
  }
440
+ export {};
package/dist/index.js CHANGED
@@ -1,3 +1,5 @@
1
- import { registerMermaid } from './mermaid.js';
2
- registerMermaid(async () => (await import('mermaid')).default);
3
- export * from './core.js';
1
+ import { n as registerMermaid, r as InkKitError, t as InkKitEditor } from "./chunks/core-CYp5ONPO.js";
2
+ //#region src/index.ts
3
+ registerMermaid(async () => (await import("mermaid")).default);
4
+ //#endregion
5
+ export { InkKitEditor, InkKitError };