@aicayzer/inkkit 0.1.2 → 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.
@@ -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-Dyg5rJLT.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-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
@@ -2,3 +2,4 @@ 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
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-Dyg5rJLT.js";
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,3 +1,4 @@
1
+ import type { SlashMenuOptions } from './types.js';
1
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';
@@ -68,6 +69,8 @@ export interface TextInputPreferences {
68
69
  export interface EditorOptions {
69
70
  /** Shows, imports and exports images. Without it and `files`, image Markdown stays literal. */
70
71
  images?: ImageAdapter;
72
+ /** Opt-in block suggestions on an empty line. Fixed at mount. */
73
+ slashMenu?: SlashMenuOptions;
71
74
  /** Resolves path images and `![[name]]` embeds into images, audio, video, PDFs and file cards. */
72
75
  files?: FileAdapter;
73
76
  /** Resolves and opens `[[wiki links]]`. Without it they stay literal. */
@@ -188,6 +191,8 @@ export declare class InkKitEditor {
188
191
  private literalKeys;
189
192
  private configuredKeys;
190
193
  private readOnlyKeys;
194
+ private suggestions?;
195
+ private suggestionBase?;
191
196
  private changePlugin;
192
197
  private keys;
193
198
  private readonly events;
@@ -428,6 +433,8 @@ export declare class InkKitEditor {
428
433
  * text is each block's source.
429
434
  */
430
435
  private authoredSources;
436
+ private chooseWiki;
437
+ private chooseSlash;
431
438
  /** Returns whether the document or the marks the next typed text takes changed. */
432
439
  format(command: FormatCommand, options?: FormatOptions, expectedGeneration?: number): boolean;
433
440
  /**
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as registerMermaid, r as InkKitError, t as InkKitEditor } from "./chunks/core-Dyg5rJLT.js";
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
@@ -953,3 +953,51 @@
953
953
  var(--inkkit-focus-offset, -2px)
954
954
  );
955
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;
@@ -287,3 +309,15 @@ export interface TableOptions {
287
309
  /** `sortRows`. Defaults to `text`. */
288
310
  comparison?: 'text' | 'number';
289
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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aicayzer/inkkit",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "A preserving Markdown editor for offline web views and the web",
5
5
  "license": "MIT",
6
6
  "type": "module",