@aicayzer/inkkit 0.0.17 → 0.1.0

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 (81) hide show
  1. package/NOTICE +4 -2
  2. package/README.md +12 -6
  3. package/dist/THIRD-PARTY-NOTICES.txt +2742 -0
  4. package/dist/chunks/core-vtCr4MBS.js +56503 -0
  5. package/dist/chunks/highlight-Daj2fv_u.js +14122 -0
  6. package/dist/core.d.ts +4 -0
  7. package/dist/core.js +2 -0
  8. package/dist/editor.d.ts +261 -48
  9. package/dist/index.d.ts +1 -7
  10. package/dist/index.js +5 -2
  11. package/dist/style.css +242 -221
  12. package/dist/types.d.ts +143 -18
  13. package/package.json +26 -15
  14. package/dist/autolink.d.ts +0 -1
  15. package/dist/autolink.js +0 -18
  16. package/dist/callouts.d.ts +0 -26
  17. package/dist/callouts.js +0 -311
  18. package/dist/clipboard.d.ts +0 -11
  19. package/dist/clipboard.js +0 -261
  20. package/dist/code-fences.d.ts +0 -8
  21. package/dist/code-fences.js +0 -166
  22. package/dist/comments.d.ts +0 -55
  23. package/dist/comments.js +0 -494
  24. package/dist/decorations.d.ts +0 -2
  25. package/dist/decorations.js +0 -67
  26. package/dist/dialect.d.ts +0 -9
  27. package/dist/dialect.js +0 -358
  28. package/dist/editor.js +0 -2441
  29. package/dist/files.d.ts +0 -40
  30. package/dist/files.js +0 -133
  31. package/dist/highlight.d.ts +0 -1
  32. package/dist/highlight.js +0 -136
  33. package/dist/image-blocks.d.ts +0 -71
  34. package/dist/image-blocks.js +0 -286
  35. package/dist/images.d.ts +0 -51
  36. package/dist/images.js +0 -398
  37. package/dist/inline-highlight.d.ts +0 -6
  38. package/dist/inline-highlight.js +0 -112
  39. package/dist/labels.d.ts +0 -36
  40. package/dist/labels.js +0 -34
  41. package/dist/linked-syntax.d.ts +0 -48
  42. package/dist/linked-syntax.js +0 -320
  43. package/dist/literals.d.ts +0 -19
  44. package/dist/literals.js +0 -211
  45. package/dist/mermaid.d.ts +0 -8
  46. package/dist/mermaid.js +0 -321
  47. package/dist/outline.d.ts +0 -22
  48. package/dist/outline.js +0 -79
  49. package/dist/paste-html.d.ts +0 -23
  50. package/dist/paste-html.js +0 -441
  51. package/dist/paste.d.ts +0 -26
  52. package/dist/paste.js +0 -482
  53. package/dist/portable-files.d.ts +0 -10
  54. package/dist/portable-files.js +0 -36
  55. package/dist/preserve.d.ts +0 -21
  56. package/dist/preserve.js +0 -757
  57. package/dist/print.d.ts +0 -7
  58. package/dist/print.js +0 -409
  59. package/dist/reference-clipboard.d.ts +0 -8
  60. package/dist/reference-clipboard.js +0 -201
  61. package/dist/references.d.ts +0 -14
  62. package/dist/references.js +0 -368
  63. package/dist/search.d.ts +0 -15
  64. package/dist/search.js +0 -202
  65. package/dist/selection.d.ts +0 -1
  66. package/dist/selection.js +0 -59
  67. package/dist/source.d.ts +0 -16
  68. package/dist/source.js +0 -57
  69. package/dist/spreadsheet.d.ts +0 -3
  70. package/dist/spreadsheet.js +0 -275
  71. package/dist/table-alignment.d.ts +0 -2
  72. package/dist/table-alignment.js +0 -46
  73. package/dist/tables.d.ts +0 -27
  74. package/dist/tables.js +0 -322
  75. package/dist/tasks.d.ts +0 -3
  76. package/dist/tasks.js +0 -51
  77. package/dist/text-ranges.d.ts +0 -29
  78. package/dist/text-ranges.js +0 -256
  79. package/dist/types.js +0 -8
  80. package/dist/wiki-view.d.ts +0 -21
  81. package/dist/wiki-view.js +0 -78
package/dist/core.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export { InkKitEditor } from './editor.js';
2
+ export type { EditorEvents, EditorOptions, TextInputPreferences, CommandState, EditingMode, CaretState, Mark, Block, FormatCommand, FormatOptions, KeyInput, ImageInsertion, ShortcutName, Keymap, } from './editor.js';
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';
package/dist/core.js ADDED
@@ -0,0 +1,2 @@
1
+ import { r as InkKitError, t as InkKitEditor } from "./chunks/core-vtCr4MBS.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,34 +115,48 @@ 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;
101
149
  private literalMatch?;
102
150
  private beforePlainInput?;
151
+ private pendingSource?;
152
+ private typedSteps;
153
+ private undoneSteps;
154
+ private formattedUndone;
155
+ private lastSourceInput;
156
+ private syncingSource;
103
157
  private mode;
104
158
  private sourcePreservations;
105
159
  private sourceTexts;
106
- private outlineEpoch;
107
160
  private ready;
108
161
  private destroyed;
109
162
  private preservation?;
@@ -112,67 +165,180 @@ export declare class InkKitEditor {
112
165
  private root;
113
166
  private ownsRootClass;
114
167
  private clickHandler?;
168
+ private auxClickHandler?;
169
+ private untrackLinkModifier?;
115
170
  private footnoteKeyHandler?;
116
171
  private copyHandler?;
117
172
  private originalSource;
118
- private generation;
119
173
  private reportingSuppressed;
120
174
  private loading;
121
175
  private readonly textIdentity;
176
+ private call?;
122
177
  private textScope?;
123
178
  private viewportContainer?;
124
179
  private viewportInsets;
125
180
  private writable;
126
181
  private inputPreferences;
127
- private policyEpoch;
128
182
  private literalKeys;
129
183
  private configuredKeys;
130
184
  private readOnlyKeys;
131
185
  private changePlugin;
132
186
  private keys;
187
+ private readonly events;
188
+ /** How many of each state event the host has been sent. */
189
+ private readonly sentEvents;
133
190
  private constructor();
134
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;
135
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. */
136
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;
137
209
  private mediaPolicy;
138
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. */
139
214
  private assertCurrent;
140
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;
141
241
  private get composing();
242
+ /** Whether the person can edit. A read-only editor still permits selection, copying and find. */
142
243
  get editable(): boolean;
244
+ /** Turns editing on or off for both surfaces. Throws `composition` during text composition. */
143
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. */
144
248
  setTextInputPreferences(preferences: TextInputPreferences): void;
145
249
  private applyInputPolicy;
146
250
  private publishCommandState;
251
+ /** What the editor can do now, for enabling host controls. Unlike `snapshot`, it works during
252
+ * composition. */
147
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();
148
256
  private canQuote;
149
257
  private policyPlugin;
150
258
  private get literalSurface();
259
+ /** `formatted` or `source`. A TXT document is always `source`. */
151
260
  get editingMode(): EditingMode;
152
261
  private currentText;
262
+ /** Switches between formatted and source editing. Returns false when the mode is already set, and
263
+ * for TXT. */
153
264
  setEditingMode(mode: EditingMode, expectedGeneration?: number): boolean;
154
265
  private updateSurface;
266
+ /** Replaces the complete source as one undo step. Returns false for identical source. */
155
267
  replaceSource(text: string, expectedGeneration?: number): boolean;
156
268
  private applySource;
269
+ /**
270
+ * Takes typed source without parsing it. Parsing, preservation and replacing
271
+ * the formatted document cost as much as a document load, so they wait for
272
+ * the next thing that needs them.
273
+ */
274
+ private deferSource;
275
+ private rememberTypedStep;
276
+ private showTypedSource;
277
+ /**
278
+ * Undoes or redoes typed source that the formatted document has not taken
279
+ * in, on the text alone. Returns whether there was a step to take.
280
+ */
281
+ private stepTypedSource;
282
+ /** Brings the formatted document up to the source that was typed. */
283
+ private settleSource;
284
+ private commitSource;
285
+ /** Returns whether a history step applied. */
157
286
  undo(expectedGeneration?: number): boolean;
287
+ /** Returns whether a history step applied. */
158
288
  redo(expectedGeneration?: number): boolean;
159
289
  private replaceLiteralSelection;
290
+ /** The complete current text, which is what a host saves. It throws rather than return partial
291
+ * text. */
160
292
  snapshot(expectedGeneration?: number): DocumentSnapshot;
293
+ /** The whole document as standalone HTML for printing. Rejects rather than return partial
294
+ * output. */
161
295
  printableSnapshot(expectedGeneration?: number): Promise<PrintableDocument>;
162
- clipboardSnapshot(all?: boolean): Promise<ClipboardOutput>;
163
- paste(input: ClipboardInput): Promise<void>;
296
+ /**
297
+ * The document to export. Source typed in the source editor has not reached
298
+ * the formatted document, which would merge its undo steps, so a document
299
+ * read from the text stands in without touching history.
300
+ */
301
+ private exportDocument;
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. */
164
310
  setCommentsVisible(visible: boolean): void;
165
- pasteAsPlainText(text: string): void;
166
- 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`. */
167
319
  destroy(): Promise<void>;
168
320
  private keymapPlugin;
169
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. */
170
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. */
171
327
  loadDocument(input: DocumentInput): void;
172
- 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. */
173
336
  setViewport(options: ViewportOptions): void;
337
+ /** The visible rectangle, the insets and the scroll offsets. */
174
338
  viewport(): ViewportSnapshot;
175
339
  private readableScope;
340
+ /** The readable text and selection. Ranges from it go stale when the document, its revision or
341
+ * the mode changes. */
176
342
  textSnapshot(expectedGeneration?: number): ReadableTextSnapshot;
177
343
  private validateTextRange;
178
344
  selectTextRange(range: TextRange, options?: {
@@ -180,48 +346,95 @@ export declare class InkKitEditor {
180
346
  reveal?: boolean;
181
347
  }): void;
182
348
  /** Throws when a document reached by an edit, after every appended normalisation, cannot be
183
- * saved as preserved Markdown. Dispatch and the replacement commands share this check. */
349
+ * saved as preserved Markdown. Dispatch and the replacement commands share this check.
350
+ * `written` is false for history steps and source replacement, which restore or supply a
351
+ * document that may hold comment text the formatted editor would refuse to accept typed. */
184
352
  private assertPreserved;
353
+ /** Replaces `range` with literal text as one undo step. Returns whether the text changed. */
185
354
  replaceTextRange(range: TextRange, text: string): boolean;
186
- textRangeRects(range: TextRange): readonly TextRect[];
355
+ /** Measures ranges in client coordinates, with one array of rectangles for each. It measures only
356
+ * when called. */
187
357
  textRangesRects(ranges: readonly TextRange[]): readonly (readonly TextRect[])[];
358
+ /** The ranges of the snapshot that are inside the viewport now. */
188
359
  visibleTextRanges(snapshotId: string): readonly TextRange[];
360
+ /** Scrolls `range` into the viewport, unfolding a callout that holds it. */
189
361
  revealTextRange(range: TextRange): void;
190
362
  private revealRects;
191
363
  private revealCurrentSelection;
192
364
  private revealLiteralSelection;
193
365
  private load;
194
- 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. */
195
369
  replace(search: string, replacement: string, expectedGeneration?: number): boolean;
370
+ /** Replaces every non-overlapping match once and returns how many. */
196
371
  replaceAll(search: string, replacement: string, expectedGeneration?: number): number;
197
372
  private replaceMatches;
198
373
  private outlineContext;
374
+ /** The outline in document order. Entries go stale when the document changes. */
199
375
  headings(expectedGeneration?: number): readonly Heading[];
376
+ /** Moves to `heading`. Returns true, or throws `stale-document` for a stale entry. */
200
377
  navigateHeading(heading: Heading): boolean;
201
- /** 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. */
202
379
  insertText(text: string, generation: number): boolean;
203
- /** Let existing keymaps handle buffered editing commands before native fallback. */
204
- keyDown(key: string, code: string, metaKey: boolean, ctrlKey: boolean, altKey: boolean, shiftKey: boolean, generation: number): boolean;
205
- focus(): void;
206
- /** Binds keys, in ProseMirror's names, to the formatting each shortcut runs. Walked in the table's
207
- * 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. */
208
392
  setKeymap(keymap: Keymap): void;
209
393
  /** Dropped files land as one paragraph per path at the drop point: in place of an empty block, after
210
394
  * the top-level block otherwise, so a list or quote is not opened up by them. */
211
- insertPaths(paths: string[], x: number, y: number): void;
212
- insertImages(images: {
213
- path: string;
214
- alt: string;
215
- title?: string;
216
- }[], 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;
399
+ private insertInline;
217
400
  private insertBlocks;
218
401
  private withMarkRunSelected;
219
402
  private toggleInlineCode;
220
403
  private list;
221
404
  private quote;
222
405
  private unquote;
223
- format(command: FormatCommand, arg?: string | number): void;
224
- editReferenceDefinition(label: string, destination: string, title?: string): boolean;
225
- insertFootnote(label?: string): void;
226
- 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;
227
439
  }
440
+ export {};
package/dist/index.d.ts CHANGED
@@ -1,7 +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';
5
- 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';
1
+ export * from './core.js';
package/dist/index.js CHANGED
@@ -1,2 +1,5 @@
1
- export { InkKitEditor } from './editor.js';
2
- export { InkKitError } from './types.js';
1
+ import { n as registerMermaid, r as InkKitError, t as InkKitEditor } from "./chunks/core-vtCr4MBS.js";
2
+ //#region src/index.ts
3
+ registerMermaid(async () => (await import("mermaid")).default);
4
+ //#endregion
5
+ export { InkKitEditor, InkKitError };