@aicayzer/inkkit 0.3.2 → 0.3.4

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-DTew7k7c.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-BRAgrHC7.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-DTew7k7c.js";
1
+ import { r as InkKitError, t as InkKitEditor } from "./chunks/core-BRAgrHC7.js";
2
2
  export { InkKitEditor, InkKitError };
package/dist/editor.d.ts CHANGED
@@ -27,7 +27,7 @@ export interface CaretState {
27
27
  /** One quote holds the whole selection; the block is what sits inside it. */
28
28
  quoted: boolean;
29
29
  }
30
- declare const formatCommands: readonly ['heading1', 'heading2', 'heading3', 'heading4', 'heading5', 'heading6', 'paragraph', 'bold', 'italic', 'strikethrough', 'highlight', 'code', 'codeBlock', 'quote', 'bulletList', 'orderedList', 'taskList', 'link'];
30
+ declare const formatCommands: readonly ['heading1', 'heading2', 'heading3', 'heading4', 'heading5', 'heading6', 'paragraph', 'bold', 'italic', 'strikethrough', 'highlight', 'code', 'codeBlock', 'quote', 'bulletList', 'orderedList', 'taskList', 'toggleTask', 'link'];
31
31
  /** A command for `format`. */
32
32
  export type FormatCommand = (typeof formatCommands)[number];
33
33
  /** `destination` goes only with `link`, and `language` only with `codeBlock`. */
@@ -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, list indentation,
53
+ /** A name in `Keymap`: every format command except `link`, history, link opening, block moves, list indentation,
54
54
  * and every table command. */
55
- export type ShortcutName = Exclude<FormatCommand, 'link'> | 'undo' | 'redo' | 'moveBlockUp' | 'moveBlockDown' | 'indent' | 'outdent' | `table${Capitalize<TableCommand>}`;
55
+ export type ShortcutName = Exclude<FormatCommand, 'link'> | 'undo' | 'redo' | 'moveBlockUp' | 'moveBlockDown' | 'indent' | 'outdent' | 'openLink' | `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`. */
@@ -152,60 +152,37 @@ export declare const editorEvents: readonly ["changed", "commandStateChanged", "
152
152
  export declare class InkKitEditor {
153
153
  private readonly options;
154
154
  private editor;
155
+ private readonly document;
156
+ private readonly history;
157
+ private readonly text;
158
+ private readonly geometry;
159
+ private readonly search;
160
+ private readonly output;
161
+ private readonly clipboard;
155
162
  private lastMarkdown;
156
- private formatType;
157
163
  private readonly session;
158
- private exportControllers;
159
- private plainComposing;
160
- private plainSearch;
161
- private literalMatch?;
162
- private beforePlainInput?;
163
- private pendingSource?;
164
- private typedSteps;
165
- private undoneSteps;
166
- private formattedUndone;
167
- private formattedRedoLimit?;
168
- private historyDirection?;
169
- private lastSourceInput;
170
- private syncingSource;
171
164
  private mode;
172
- private sourcePreservations;
173
- private sourceTexts;
174
165
  private ready;
175
166
  private destroyed;
176
- private preservation?;
177
- private carried?;
178
167
  private pasteController;
179
- private plain;
168
+ private source;
180
169
  private root;
181
170
  private ownsRootClass;
182
- private clickHandler?;
183
- private auxClickHandler?;
184
- private untrackLinkModifier?;
185
- private footnoteKeyHandler?;
186
- private readonly localCopies;
187
- private rememberCopy;
188
- private retainCopy;
189
- private restoreCopy;
190
- private copyHandler?;
191
- private originalSource;
171
+ private activation;
192
172
  private reportingSuppressed;
193
173
  private loading;
194
- private readonly textIdentity;
195
174
  private call?;
196
- private textScope?;
197
- private viewportContainer?;
198
- private viewportInsets;
199
175
  private writable;
200
176
  private inputPreferences;
201
177
  private literalKeys;
202
- private configuredKeys;
203
178
  private indentKeys;
204
179
  private readOnlyKeys;
205
180
  private suggestions?;
206
181
  private suggestionBase?;
207
182
  private changePlugin;
183
+ private documentChanged;
208
184
  private keys;
185
+ private readingKeys;
209
186
  private readonly events;
210
187
  /** The host's extra link schemes, in lower case. */
211
188
  private readonly linkSchemes;
@@ -217,10 +194,6 @@ export declare class InkKitEditor {
217
194
  private get generation();
218
195
  /** What `changed` reports for the document's new text. */
219
196
  private changeSnapshot;
220
- private cancelExports;
221
- /** Runs asynchronous output work for the document `captured` describes, and throws
222
- * `stale-document` when the document, its revision or the editing mode changed meanwhile. */
223
- private exportContent;
224
197
  /** Throws unless the document `captured` describes is still current, alive, not composing and
225
198
  * has no import pending. */
226
199
  private assertCaptured;
@@ -279,55 +252,27 @@ export declare class InkKitEditor {
279
252
  commandState(expectedGeneration?: number): CommandState;
280
253
  /** An image adapter shows and exports an inserted reference, and so does a file adapter. */
281
254
  private get canInsertImages();
282
- private canQuote;
283
255
  private historyInputPlugin;
284
256
  private policyPlugin;
285
257
  private get literalSurface();
286
258
  /** `formatted` or `source`. A TXT document is always `source`. */
287
259
  get editingMode(): EditingMode;
288
- private currentText;
289
260
  /** Switches between formatted and source editing. Returns false when the mode is already set, and
290
261
  * for TXT. */
291
262
  setEditingMode(mode: EditingMode, expectedGeneration?: number): boolean;
292
263
  private updateSurface;
293
264
  /** Replaces the complete source as one undo step. Returns false for identical source. */
294
265
  replaceSource(text: string, expectedGeneration?: number): boolean;
295
- private applySource;
296
- /**
297
- * Takes typed source without parsing it. Parsing, preservation and replacing
298
- * the formatted document cost as much as a document load, so they wait for
299
- * the next thing that needs them.
300
- */
301
- private deferSource;
302
- private rememberTypedStep;
303
- private showTypedSource;
304
- private setSourceValue;
305
- /**
306
- * Undoes or redoes typed source that the formatted document has not taken
307
- * in, on the text alone. Returns whether there was a step to take.
308
- */
309
- private stepTypedSource;
310
- /** Brings the formatted document up to the source that was typed. */
311
- private settleSource;
312
- private commitSource;
313
266
  /** Returns whether a history step applied. */
314
267
  undo(expectedGeneration?: number): boolean;
315
268
  /** Returns whether a history step applied. */
316
269
  redo(expectedGeneration?: number): boolean;
317
- private stepFormattedHistory;
318
- private replaceLiteralSelection;
319
270
  /** The complete current text, which is what a host saves. It throws rather than return partial
320
271
  * text. */
321
272
  snapshot(expectedGeneration?: number): DocumentSnapshot;
322
273
  /** The whole document as standalone HTML for printing. Rejects rather than return partial
323
274
  * output. */
324
275
  printableSnapshot(expectedGeneration?: number): Promise<PrintableDocument>;
325
- /**
326
- * The document to export. Source typed in the source editor has not reached
327
- * the formatted document, which would merge its undo steps, so a document
328
- * read from the text stands in without touching history.
329
- */
330
- private exportDocument;
331
276
  /** Prepares the document or the selection for the native clipboard. Rejects with `stale-document`
332
277
  * if the document changes first. */
333
278
  clipboardSnapshot(scope?: ClipboardScope, expectedGeneration?: number): Promise<ClipboardOutput>;
@@ -354,7 +299,7 @@ export declare class InkKitEditor {
354
299
  destroy(): Promise<void>;
355
300
  private keymapPlugin;
356
301
  private indentPlugin;
357
- private copySourceSelection;
302
+ private dispatchTransaction;
358
303
  /** Builds the editor in `root`. It has no document until `loadDocument`. Rejects with
359
304
  * `invalid-argument` for a bad root, handler or option. */
360
305
  static mount(root: HTMLElement, events: EditorEvents, options?: EditorOptions): Promise<InkKitEditor>;
@@ -372,7 +317,6 @@ export declare class InkKitEditor {
372
317
  setViewport(options: ViewportOptions): void;
373
318
  /** The visible rectangle, the insets and the scroll offsets. */
374
319
  viewport(): ViewportSnapshot;
375
- private readableScope;
376
320
  /** The readable text and selection. Ranges from it go stale when the document, its revision or
377
321
  * the mode changes. */
378
322
  textSnapshot(expectedGeneration?: number): ReadableTextSnapshot;
@@ -381,14 +325,6 @@ export declare class InkKitEditor {
381
325
  focus?: boolean;
382
326
  reveal?: boolean;
383
327
  }): void;
384
- /** Whether two documents are the same note. A move of blocks that read alike, such as a setext
385
- * heading and the same heading written with `#`, gives an equal document with other source. */
386
- private sameDocument;
387
- /** Throws when a document reached by an edit, after every appended normalisation, cannot be
388
- * saved as preserved Markdown. Dispatch and the replacement commands share this check.
389
- * `written` is false for history steps and source replacement, which restore or supply a
390
- * document that may hold comment text the formatted editor would refuse to accept typed. */
391
- private assertPreserved;
392
328
  /** Replaces `range` with literal text as one undo step. Returns whether the text changed. */
393
329
  replaceTextRange(range: TextRange, text: string): boolean;
394
330
  /** Measures ranges in client coordinates, with one array of rectangles for each. It measures only
@@ -398,7 +334,6 @@ export declare class InkKitEditor {
398
334
  visibleTextRanges(snapshotId: string): readonly TextRange[];
399
335
  /** Scrolls `range` into the viewport, unfolding a callout that holds it. */
400
336
  revealTextRange(range: TextRange): void;
401
- private revealRects;
402
337
  private revealCurrentSelection;
403
338
  private revealLiteralSelection;
404
339
  private load;
@@ -408,7 +343,6 @@ export declare class InkKitEditor {
408
343
  replace(search: string, replacement: string, expectedGeneration?: number): boolean;
409
344
  /** Replaces every non-overlapping match once and returns how many. */
410
345
  replaceAll(search: string, replacement: string, expectedGeneration?: number): number;
411
- private replaceMatches;
412
346
  private outlineContext;
413
347
  /** The outline in document order. Entries go stale when the document changes. */
414
348
  headings(expectedGeneration?: number): readonly Heading[];
@@ -432,8 +366,9 @@ export declare class InkKitEditor {
432
366
  * draw no references; named file answers are invalidated and resolved when formatted mode returns.
433
367
  */
434
368
  refreshReferences(targets?: readonly string[], expectedGeneration?: number): void;
369
+ private openSelectedLink;
435
370
  /** Replaces every binding. Keys are in ProseMirror's notation. A key given to two shortcuts goes
436
- * to the later one, in the order history, formatting, block moves, tables, so it lands the same
371
+ * to the later one, in the order history, link opening, formatting, block moves, tables, so it lands the same
437
372
  * way every time. A table binding passes a key it shares with a block move to the move outside
438
373
  * a table. List indentation keys apply after all of these, and after the table keys the editor
439
374
  * keeps for itself. */
@@ -448,24 +383,6 @@ export declare class InkKitEditor {
448
383
  * no scrolling, and the selection stays on the text it covered. For a host that attaches images
449
384
  * to a document the person is not editing at that moment. Returns false when it does nothing. */
450
385
  appendImages(images: ImageInsertion[], expectedGeneration?: number): boolean;
451
- private imageBlocks;
452
- private insertInline;
453
- private insertBlocks;
454
- private withMarkRunSelected;
455
- private toggleInlineCode;
456
- private list;
457
- private quote;
458
- private unquote;
459
- /** Changes the selected textblocks' type, keeping everything they hold. */
460
- private textblockType;
461
- /**
462
- * The authored Markdown of the textblocks at `positions`, found by saving
463
- * the document once with each block's content replaced by a numbered mark
464
- * no one writes. The saved text between the marks is the current text
465
- * between those blocks, so what lies between the same pieces of the current
466
- * text is each block's source.
467
- */
468
- private authoredSources;
469
386
  private chooseWiki;
470
387
  private chooseSlash;
471
388
  /** Returns whether the document or the marks the next typed text takes changed. */
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as registerMermaid, r as InkKitError, t as InkKitEditor } from "./chunks/core-DTew7k7c.js";
1
+ import { n as registerMermaid, r as InkKitError, t as InkKitEditor } from "./chunks/core-BRAgrHC7.js";
2
2
  //#region src/index.ts
3
3
  registerMermaid(async () => (await import("mermaid")).default);
4
4
  //#endregion
package/dist/style.css CHANGED
@@ -14,7 +14,7 @@
14
14
  line-height: var(--inkkit-line-height, normal);
15
15
  -webkit-font-smoothing: antialiased;
16
16
  -webkit-text-size-adjust: none;
17
- --_inkkit-accent: var(--inkkit-accent-color, #0a84ff);
17
+ --_inkkit-accent: var(--inkkit-accent-color, light-dark(#0069d1, #409cff));
18
18
  --_inkkit-text: var(--inkkit-text-color, CanvasText);
19
19
  --_inkkit-muted: var(
20
20
  --inkkit-muted-color,
@@ -347,6 +347,7 @@
347
347
  opacity: 0;
348
348
  }
349
349
  .inkkit-root .ProseMirror .inkkit-image:hover .inkkit-image-handle,
350
+ .inkkit-root .ProseMirror .inkkit-image:focus-within .inkkit-image-handle,
350
351
  .inkkit-root .ProseMirror .inkkit-image-handle:active {
351
352
  opacity: 1;
352
353
  }
@@ -730,7 +731,7 @@
730
731
  border: 1.5px solid
731
732
  var(
732
733
  --inkkit-checkbox-border-color,
733
- color-mix(in srgb, CanvasText 35%, transparent)
734
+ color-mix(in srgb, CanvasText 55%, transparent)
734
735
  );
735
736
  border-radius: 4px;
736
737
  cursor: pointer;
@@ -762,6 +763,33 @@
762
763
  color: var(--_inkkit-muted);
763
764
  }
764
765
 
766
+ /* The semantic control overlays the existing marker without entering its text. */
767
+ .inkkit-root .inkkit-task-checkbox {
768
+ position: absolute;
769
+ left: calc(var(--_inkkit-font-size) * -1.667);
770
+ top: var(--_inkkit-task-top);
771
+ width: var(--_inkkit-task-size);
772
+ height: var(--_inkkit-task-size);
773
+ cursor: pointer;
774
+ border-radius: 4px;
775
+ }
776
+
777
+ .inkkit-root .inkkit-task-checkbox:focus-visible {
778
+ outline: 2px solid var(--inkkit-focus-color, var(--_inkkit-accent));
779
+ outline-offset: 2px;
780
+ }
781
+
782
+ @media (forced-colors: active) {
783
+ .inkkit-root .ProseMirror li[data-item-type='task']::before {
784
+ border-color: CanvasText;
785
+ }
786
+ .inkkit-root
787
+ .ProseMirror
788
+ li[data-item-type='task'][data-checked='true']::after {
789
+ border-color: CanvasText;
790
+ }
791
+ }
792
+
765
793
  .inkkit-root .ProseMirror del {
766
794
  color: var(--_inkkit-muted);
767
795
  }
@@ -986,6 +1014,7 @@
986
1014
 
987
1015
  /* One ring for every control InkKit draws; the editing surfaces can be set apart. */
988
1016
  .inkkit-root button:focus-visible,
1017
+ .inkkit-root .inkkit-image-handle:focus-visible,
989
1018
  .inkkit-root .inkkit-file audio:focus-visible,
990
1019
  .inkkit-root .inkkit-file video:focus-visible {
991
1020
  outline: var(--inkkit-focus-width, 2px) solid
package/dist/types.d.ts CHANGED
@@ -249,6 +249,7 @@ export interface EditorLabels {
249
249
  slashBulletList: string;
250
250
  slashOrderedList: string;
251
251
  slashTaskList: string;
252
+ taskCheckbox: string;
252
253
  slashQuote: string;
253
254
  slashCodeBlock: string;
254
255
  slashTable: string;
@@ -292,6 +293,7 @@ export interface EditorLabels {
292
293
  fileOpen: string;
293
294
  filePreviewUnavailable: string;
294
295
  filePDFPreview: string;
296
+ imageResize: string;
295
297
  wikiMissing: string;
296
298
  /** Name of an author comment, which stays out of the readable text. */
297
299
  comment: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aicayzer/inkkit",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "A preserving Markdown editor for offline web views and the web",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -41,14 +41,14 @@
41
41
  "node": ">=26"
42
42
  },
43
43
  "scripts": {
44
- "build": "node scripts/clean-build.mjs && tsc -p tsconfig.build.json && vite build --config vite.package.config.ts && node scripts/finish-build.mjs",
44
+ "build": "node scripts/clean-build.mjs && tsc -p tsconfig.build.json && vite build --config vite.package.config.ts && node scripts/build-host-notices.ts && node scripts/finish-build.mjs",
45
45
  "typecheck": "tsc --noEmit",
46
46
  "test": "vitest run",
47
47
  "format": "prettier --write .",
48
48
  "format:check": "prettier --check .",
49
49
  "dev": "vite playground",
50
50
  "build:playground": "vite build playground --config vite.config.ts",
51
- "test:docs": "node scripts/check-api-docs.mjs",
51
+ "test:docs": "node --test scripts/api-docs/*.test.mjs && node scripts/check-api-docs.mjs",
52
52
  "test:package": "node scripts/test-package.mjs",
53
53
  "check": "pnpm typecheck && pnpm test && pnpm build && pnpm test:docs && pnpm test:package",
54
54
  "test:browser": "playwright test --project=chromium",
@@ -74,6 +74,7 @@
74
74
  "mdast-util-gfm-table": "^2.0.0",
75
75
  "mdast-util-gfm-task-list-item": "^2.0.0",
76
76
  "mdast-util-highlight-mark": "1.2.2",
77
+ "mdast-util-mdx": "3.0.0",
77
78
  "mdast-util-to-markdown": "2.2.0",
78
79
  "micromark-extension-gfm-autolink-literal": "^2.1.0",
79
80
  "micromark-extension-gfm-footnote": "^2.1.0",
@@ -81,6 +82,7 @@
81
82
  "micromark-extension-gfm-table": "^2.1.1",
82
83
  "micromark-extension-gfm-task-list-item": "^2.1.0",
83
84
  "micromark-extension-highlight-mark": "1.2.0",
85
+ "micromark-extension-mdxjs": "3.0.0",
84
86
  "micromark-util-normalize-identifier": "^2.0.1",
85
87
  "micromark-util-types": "^2.0.3",
86
88
  "prettier": "^3.9.8",