@aicayzer/inkkit 0.3.0 → 0.3.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.
@@ -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-DrVCeBzK.js";
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-Dx4gTiUo.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.js CHANGED
@@ -1,2 +1,2 @@
1
- import { r as InkKitError, t as InkKitEditor } from "./chunks/core-DrVCeBzK.js";
1
+ import { r as InkKitError, t as InkKitEditor } from "./chunks/core-Dx4gTiUo.js";
2
2
  export { InkKitEditor, InkKitError };
package/dist/editor.d.ts CHANGED
@@ -50,9 +50,9 @@ export interface ImageInsertion {
50
50
  alt: string;
51
51
  title?: string;
52
52
  }
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>}`;
53
+ /** A name in `Keymap`: every format command except `link`, history, block moves, list indentation,
54
+ * and every table command. */
55
+ export type ShortcutName = Exclude<FormatCommand, 'link'> | 'undo' | 'redo' | 'moveBlockUp' | 'moveBlockDown' | 'indent' | 'outdent' | `table${Capitalize<TableCommand>}`;
56
56
  /** Host bindings in ProseMirror key notation, by shortcut name. */
57
57
  export type Keymap = Partial<Record<ShortcutName, readonly string[]>>;
58
58
  /** Every `ShortcutName`. */
@@ -65,7 +65,7 @@ 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` and `rendering` are fixed at mount; the rest can change. */
68
+ /** Mount options. Adapters, `labels`, `linkSchemes` and `rendering` are fixed at mount; the rest can change. */
69
69
  export interface EditorOptions {
70
70
  /** Shows, imports and exports images. Without it and `files`, image Markdown stays literal. */
71
71
  images?: ImageAdapter;
@@ -82,6 +82,9 @@ export interface EditorOptions {
82
82
  labels?: Partial<EditorLabels>;
83
83
  /** See `setKeymap`. */
84
84
  keymap?: Keymap;
85
+ /** Schemes beyond `http`, `https`, `mailto` and `tel` that links may use, such as `things`.
86
+ * Fixed at mount. */
87
+ linkSchemes?: readonly string[];
85
88
  rendering?: {
86
89
  /** Defaults to true. */
87
90
  codeHighlighting?: boolean;
@@ -114,6 +117,7 @@ export interface CommandState extends DocumentVersion {
114
117
  replace: boolean;
115
118
  replaceSource: boolean;
116
119
  insertImages: boolean;
120
+ appendImages: boolean;
117
121
  insertPaths: boolean;
118
122
  insertFootnote: boolean;
119
123
  editReferenceDefinition: boolean;
@@ -196,12 +200,15 @@ export declare class InkKitEditor {
196
200
  private inputPreferences;
197
201
  private literalKeys;
198
202
  private configuredKeys;
203
+ private indentKeys;
199
204
  private readOnlyKeys;
200
205
  private suggestions?;
201
206
  private suggestionBase?;
202
207
  private changePlugin;
203
208
  private keys;
204
209
  private readonly events;
210
+ /** The host's extra link schemes, in lower case. */
211
+ private readonly linkSchemes;
205
212
  /** How many of each state event the host has been sent. */
206
213
  private readonly sentEvents;
207
214
  private constructor();
@@ -343,6 +350,7 @@ export declare class InkKitEditor {
343
350
  * throws `destroyed`. */
344
351
  destroy(): Promise<void>;
345
352
  private keymapPlugin;
353
+ private indentPlugin;
346
354
  private copySourceSelection;
347
355
  /** Builds the editor in `root`. It has no document until `loadDocument`. Rejects with
348
356
  * `invalid-argument` for a bad root, handler or option. */
@@ -414,10 +422,18 @@ export declare class InkKitEditor {
414
422
  /** Moves focus off InkKit's text surfaces. Focus anywhere else, such as in a host control or a
415
423
  * control InkKit draws, is left alone. */
416
424
  blur(expectedGeneration?: number): void;
425
+ /**
426
+ * Resolves wiki links and file embeds again, all of them or those whose `target` is named, after
427
+ * something they point to changed. A file keeps its card until the new answer differs. Changes no
428
+ * document state, so it works in a read-only editor and during composition. Source and TXT modes
429
+ * draw no references, and they resolve afresh when formatted mode returns.
430
+ */
431
+ refreshReferences(targets?: readonly string[], expectedGeneration?: number): void;
417
432
  /** Replaces every binding. Keys are in ProseMirror's notation. A key given to two shortcuts goes
418
433
  * to the later one, in the order history, formatting, block moves, tables, so it lands the same
419
434
  * way every time. A table binding passes a key it shares with a block move to the move outside
420
- * a table. */
435
+ * a table. List indentation keys apply after all of these, and after the table keys the editor
436
+ * keeps for itself. */
421
437
  setKeymap(keymap: Keymap): void;
422
438
  /** Dropped files land as one paragraph per path at the drop point: in place of an empty block, after
423
439
  * the top-level block otherwise, so a list or quote is not opened up by them. */
@@ -425,6 +441,11 @@ export declare class InkKitEditor {
425
441
  /** Inserts images by reference, at the selection or the drop point `at`. Returns false when it
426
442
  * does nothing. */
427
443
  insertImages(images: ImageInsertion[], at?: ClientPoint, expectedGeneration?: number): boolean;
444
+ /** Adds images as the last blocks of the document and leaves everything else as it is: no focus,
445
+ * no scrolling, and the selection stays on the text it covered. For a host that attaches images
446
+ * to a document the person is not editing at that moment. Returns false when it does nothing. */
447
+ appendImages(images: ImageInsertion[], expectedGeneration?: number): boolean;
448
+ private imageBlocks;
428
449
  private insertInline;
429
450
  private insertBlocks;
430
451
  private withMarkRunSelected;
@@ -447,8 +468,9 @@ export declare class InkKitEditor {
447
468
  /** Returns whether the document or the marks the next typed text takes changed. */
448
469
  format(command: FormatCommand, options?: FormatOptions, expectedGeneration?: number): boolean;
449
470
  /**
450
- * Refuses a link destination that is empty, that opens anything but a web, mail or phone address,
451
- * or that the Markdown writer cannot save so that it reads back the same.
471
+ * Refuses a link destination that is empty, that opens anything but a web, mail or phone address
472
+ * or a scheme the host listed, or that the Markdown writer cannot save so that it reads back the
473
+ * same.
452
474
  */
453
475
  private checkDestination;
454
476
  /**
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as registerMermaid, r as InkKitError, t as InkKitEditor } from "./chunks/core-DrVCeBzK.js";
1
+ import { n as registerMermaid, r as InkKitError, t as InkKitEditor } from "./chunks/core-Dx4gTiUo.js";
2
2
  //#region src/index.ts
3
3
  registerMermaid(async () => (await import("mermaid")).default);
4
4
  //#endregion
package/dist/style.css CHANGED
@@ -301,9 +301,10 @@
301
301
  content: '';
302
302
  display: block;
303
303
  position: absolute;
304
- top: -2px;
305
- width: 20px;
306
- border-top: 2px solid var(--_inkkit-accent);
304
+ top: 0;
305
+ width: 2px;
306
+ height: 1lh;
307
+ background: var(--_inkkit-accent);
307
308
  animation: inkkit-gapcursor-blink 1.1s steps(2, start) infinite;
308
309
  }
309
310
  @keyframes inkkit-gapcursor-blink {
@@ -497,13 +498,26 @@
497
498
  pointer-events: none;
498
499
  }
499
500
 
500
- /* The selection plugin draws the selection over the text alone; the engine's own fills the margins too. */
501
+ /* The selection plugin draws the selection over the text alone; the engine's own fills the margins too.
502
+ The surface needs its own rule: the descendant selector does not reach the surface itself, and WebKit paints that as full-width bars. */
503
+ .inkkit-root .ProseMirror.inkkit-painted-selection::selection,
501
504
  .inkkit-root .ProseMirror.inkkit-painted-selection ::selection {
502
505
  background: transparent;
503
506
  }
504
507
 
505
- .inkkit-root ::highlight(inkkit-selection) {
506
- background-color: color-mix(in srgb, var(--_inkkit-accent) 30%, transparent);
508
+ .inkkit-root ::highlight(inkkit-selection),
509
+ .inkkit-root ::selection {
510
+ background: var(
511
+ --inkkit-inactive-selection-background,
512
+ light-dark(#d4d4d4, #555)
513
+ );
514
+ }
515
+ .inkkit-root.inkkit-selection-active ::highlight(inkkit-selection),
516
+ .inkkit-root.inkkit-selection-active ::selection {
517
+ background: var(
518
+ --inkkit-selection-background,
519
+ color-mix(in srgb, var(--_inkkit-accent) 30%, transparent)
520
+ );
507
521
  }
508
522
 
509
523
  .inkkit-root .ProseMirror > :first-child {
@@ -552,16 +566,29 @@
552
566
  font-weight: 700;
553
567
  }
554
568
 
555
- .inkkit-root .ProseMirror a {
569
+ .inkkit-root .ProseMirror a,
570
+ .inkkit-root .inkkit-wiki-link {
556
571
  color: var(--_inkkit-accent);
557
572
  text-decoration: none;
558
573
  text-underline-offset: 2px;
559
574
  }
560
575
 
561
- .inkkit-root .ProseMirror a:hover {
576
+ .inkkit-root .ProseMirror a:hover,
577
+ .inkkit-root .inkkit-wiki-link:hover {
562
578
  text-decoration: underline;
563
579
  }
564
580
 
581
+ /* A missing target differs by its line, not only its color, which forced colors replace. */
582
+ .inkkit-root .inkkit-wiki-link[data-missing] {
583
+ text-decoration: underline dashed;
584
+ }
585
+
586
+ @media (forced-colors: active) {
587
+ .inkkit-root .inkkit-wiki-link {
588
+ color: LinkText;
589
+ }
590
+ }
591
+
565
592
  /* Held Mod opens a link on click; an empty address opens nothing. */
566
593
  .inkkit-root.inkkit-link-modifier .ProseMirror a[href]:not([href='']),
567
594
  .inkkit-root.inkkit-link-modifier .inkkit-wiki-link {
package/dist/types.d.ts CHANGED
@@ -26,7 +26,7 @@ export interface DocumentSnapshot extends DocumentInput, DocumentVersion {
26
26
  dirty: boolean;
27
27
  }
28
28
  /** The closed list of failure codes. The API reference describes each one. */
29
- export declare const editorErrorCodes: readonly ['not-ready', 'destroyed', 'stale-document', 'composition', 'operation-pending', 'read-only', 'invalid-argument', 'invalid-range', 'preservation', 'image-unavailable', 'diagram-unavailable', 'file-unavailable', 'clipboard-unavailable', 'internal'];
29
+ export declare const editorErrorCodes: readonly ['not-ready', 'destroyed', 'stale-document', 'composition', 'operation-pending', 'read-only', 'invalid-argument', 'invalid-range', 'preservation', 'image-unavailable', 'diagram-unavailable', 'file-unavailable', 'clipboard-unavailable', 'slash-command-failed', 'internal'];
30
30
  export type EditorErrorCode = (typeof editorErrorCodes)[number];
31
31
  /** Every failure InkKit reports. Hosts branch on `code`; `message` is for logs. When the failure
32
32
  * started elsewhere, such as in an adapter, the host clipboard or the renderer, `cause` holds the
@@ -67,9 +67,13 @@ export interface ImageAdapter {
67
67
  }>;
68
68
  /** The stored bytes and type of `reference`, for portable clipboard and print output. */
69
69
  exportImage(reference: string, context: DocumentContext): Promise<PortableImage>;
70
+ /** Called for a context-menu request on an image. Inkkit selects the image first. */
71
+ contextMenu?(reference: string, point: ClientPoint, context: DocumentContext): void;
70
72
  }
71
73
  /** A wiki link as authored. */
72
74
  export interface WikiLinkReference {
75
+ /** The link's Markdown as the document holds it, such as `[[Plan|Plan]]`. */
76
+ raw: string;
73
77
  /** The note name, with escapes removed. Empty for a link such as `[[#Heading]]`. */
74
78
  target: string;
75
79
  fragment?: string;
@@ -93,6 +97,8 @@ export interface FileReference {
93
97
  reference: string;
94
98
  /** `path` for `![alt](destination)`, `wiki` for `![[name]]`. */
95
99
  kind: 'path' | 'wiki';
100
+ /** The embed's Markdown as the document holds it, such as `![alt](a\_b.png)`. */
101
+ raw: string;
96
102
  /** The reference without its fragment. Use it to find the file. */
97
103
  target: string;
98
104
  /** Everything after the separating `#`, such as `t=10` or `page=3`. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aicayzer/inkkit",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "A preserving Markdown editor for offline web views and the web",
5
5
  "license": "MIT",
6
6
  "type": "module",