@aicayzer/inkkit 0.1.0 → 0.1.2

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-vtCr4MBS.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-Dyg5rJLT.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
@@ -1,4 +1,4 @@
1
1
  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
- 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';
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';
package/dist/core.js CHANGED
@@ -1,2 +1,2 @@
1
- import { r as InkKitError, t as InkKitEditor } from "./chunks/core-vtCr4MBS.js";
1
+ import { r as InkKitError, t as InkKitEditor } from "./chunks/core-Dyg5rJLT.js";
2
2
  export { InkKitEditor, InkKitError };
package/dist/editor.d.ts CHANGED
@@ -1,4 +1,4 @@
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';
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, type BlockMoveDirection } from './types.js';
2
2
  /** An inline format that `CaretState` can report. */
3
3
  export type Mark = 'bold' | 'italic' | 'strikethrough' | 'highlight' | 'code' | 'link';
4
4
  /** The kind of block that holds the start of the selection. Any other block reports `paragraph`. */
@@ -49,17 +49,20 @@ export interface ImageInsertion {
49
49
  alt: string;
50
50
  title?: string;
51
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>}`;
52
+ /** A name in `Keymap`: every format command except `link`, history, block moves, and every table
53
+ * command. */
54
+ export type ShortcutName = Exclude<FormatCommand, 'link'> | 'undo' | 'redo' | 'moveBlockUp' | 'moveBlockDown' | `table${Capitalize<TableCommand>}`;
54
55
  /** Host bindings in ProseMirror key notation, by shortcut name. */
55
56
  export type Keymap = Partial<Record<ShortcutName, readonly string[]>>;
56
57
  /** Every `ShortcutName`. */
57
58
  export declare const shortcutNames: readonly ShortcutName[];
58
- /** Hints for the browser's input features. A field left out leaves the behavior to the browser. */
59
+ /** Hints for the browser's input features, and smart punctuation. A field left out takes its default. */
59
60
  export interface TextInputPreferences {
60
61
  spellcheck?: boolean;
61
62
  autocorrect?: boolean;
62
63
  autocapitalize?: 'off' | 'none' | 'on' | 'sentences' | 'words' | 'characters';
64
+ /** Typing a quote or `--` gives a curly quote or a dash, in formatted mode. Off unless true. */
65
+ smartPunctuation?: boolean;
63
66
  }
64
67
  /** Mount options. Adapters, `labels` and `rendering` are fixed at mount; the rest can change. */
65
68
  export interface EditorOptions {
@@ -113,6 +116,8 @@ export interface CommandState extends DocumentVersion {
113
116
  editReferenceDefinition: boolean;
114
117
  format: Record<FormatCommand, boolean>;
115
118
  table: Record<TableCommand, boolean>;
119
+ moveBlockUp: boolean;
120
+ moveBlockDown: boolean;
116
121
  };
117
122
  }
118
123
  /** The host's handlers, passed to `mount`. Only `changed` is required. */
@@ -160,6 +165,7 @@ export declare class InkKitEditor {
160
165
  private ready;
161
166
  private destroyed;
162
167
  private preservation?;
168
+ private carried?;
163
169
  private pasteController;
164
170
  private plain;
165
171
  private root;
@@ -243,7 +249,7 @@ export declare class InkKitEditor {
243
249
  get editable(): boolean;
244
250
  /** Turns editing on or off for both surfaces. Throws `composition` during text composition. */
245
251
  setEditable(editable: boolean): void;
246
- /** Replaces the input hints. A field left out leaves the browser's behavior. Throws `composition`
252
+ /** Replaces the input preferences. A field left out takes its default. Throws `composition`
247
253
  * during text composition. */
248
254
  setTextInputPreferences(preferences: TextInputPreferences): void;
249
255
  private applyInputPolicy;
@@ -254,6 +260,7 @@ export declare class InkKitEditor {
254
260
  /** An image adapter shows and exports an inserted reference, and so does a file adapter. */
255
261
  private get canInsertImages();
256
262
  private canQuote;
263
+ private historyInputPlugin;
257
264
  private policyPlugin;
258
265
  private get literalSurface();
259
266
  /** `formatted` or `source`. A TXT document is always `source`. */
@@ -314,6 +321,10 @@ export declare class InkKitEditor {
314
321
  /** Runs a table command and returns whether it applied. False in source and TXT modes, outside a
315
322
  * table for commands that need one, and at a boundary a move can't cross. */
316
323
  table(command: TableCommand, options?: TableOptions, expectedGeneration?: number): boolean;
324
+ /** Moves the blocks at the selection one place up or down in their list, quote, callout, footnote
325
+ * or note, as one undo step. Returns whether they moved: false in source and TXT modes, in a
326
+ * table, and when they are already first or last. */
327
+ moveBlock(direction: BlockMoveDirection, expectedGeneration?: number): boolean;
317
328
  /** Cancels pending work and releases the editor. It never rejects. Afterwards every other member
318
329
  * throws `destroyed`. */
319
330
  destroy(): Promise<void>;
@@ -345,6 +356,9 @@ export declare class InkKitEditor {
345
356
  focus?: boolean;
346
357
  reveal?: boolean;
347
358
  }): void;
359
+ /** Whether two documents are the same note. A move of blocks that read alike, such as a setext
360
+ * heading and the same heading written with `#`, gives an equal document with other source. */
361
+ private sameDocument;
348
362
  /** Throws when a document reached by an edit, after every appended normalisation, cannot be
349
363
  * saved as preserved Markdown. Dispatch and the replacement commands share this check.
350
364
  * `written` is false for history steps and source replacement, which restore or supply a
@@ -387,8 +401,9 @@ export declare class InkKitEditor {
387
401
  * control InkKit draws, is left alone. */
388
402
  blur(expectedGeneration?: number): void;
389
403
  /** 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. */
404
+ * to the later one, in the order history, formatting, block moves, tables, so it lands the same
405
+ * way every time. A table binding passes a key it shares with a block move to the move outside
406
+ * a table. */
392
407
  setKeymap(keymap: Keymap): void;
393
408
  /** Dropped files land as one paragraph per path at the drop point: in place of an empty block, after
394
409
  * the top-level block otherwise, so a list or quote is not opened up by them. */
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as registerMermaid, r as InkKitError, t as InkKitEditor } from "./chunks/core-vtCr4MBS.js";
1
+ import { n as registerMermaid, r as InkKitError, t as InkKitEditor } from "./chunks/core-Dyg5rJLT.js";
2
2
  //#region src/index.ts
3
3
  registerMermaid(async () => (await import("mermaid")).default);
4
4
  //#endregion
package/dist/style.css CHANGED
@@ -125,9 +125,13 @@
125
125
  }
126
126
  .inkkit-root .inkkit-table-controls button {
127
127
  display: grid;
128
+ /* The icon is larger than the grabbers' short side, so the track itself is
129
+ centered; otherwise it overflows to one side. */
130
+ place-content: center;
128
131
  place-items: center;
129
132
  box-sizing: border-box;
130
133
  margin: 0;
134
+ padding: 0;
131
135
  border: 0;
132
136
  color: var(--_inkkit-muted);
133
137
  background: Canvas;
@@ -569,9 +573,13 @@
569
573
  top: 6px;
570
574
  right: 6px;
571
575
  display: grid;
576
+ place-content: center;
572
577
  place-items: center;
578
+ box-sizing: border-box;
573
579
  width: 26px;
574
580
  height: 24px;
581
+ margin: 0;
582
+ padding: 0;
575
583
  border: 0;
576
584
  border-radius: 6px;
577
585
  background: color-mix(in srgb, CanvasText 10%, transparent);
@@ -646,15 +654,22 @@
646
654
  .inkkit-root .ProseMirror li[data-item-type='task'] {
647
655
  list-style: none;
648
656
  position: relative;
657
+ /* The box is centered on the first line: 1lh is the line height the item's
658
+ text uses, including when it is normal, and --inkkit-checkbox-offset
659
+ moves the box down for a font whose lines look off-center. */
660
+ --_inkkit-task-size: calc(var(--inkkit-font-size, 15px) * 0.933);
661
+ --_inkkit-task-top: calc(
662
+ (1lh - var(--_inkkit-task-size)) / 2 + var(--inkkit-checkbox-offset, 0px)
663
+ );
649
664
  }
650
665
 
651
666
  .inkkit-root .ProseMirror li[data-item-type='task']::before {
652
667
  content: '';
653
668
  position: absolute;
654
669
  left: calc(var(--inkkit-font-size, 15px) * -1.667);
655
- top: 0.32em;
656
- width: calc(var(--inkkit-font-size, 15px) * 0.933);
657
- height: calc(var(--inkkit-font-size, 15px) * 0.933);
670
+ top: var(--_inkkit-task-top);
671
+ width: var(--_inkkit-task-size);
672
+ height: var(--_inkkit-task-size);
658
673
  box-sizing: border-box;
659
674
  border: 1.5px solid color-mix(in srgb, CanvasText 35%, transparent);
660
675
  border-radius: 4px;
@@ -674,8 +689,7 @@
674
689
  content: '';
675
690
  position: absolute;
676
691
  left: calc(var(--inkkit-font-size, 15px) * -1.333);
677
- top: 0.32em;
678
- margin-top: calc(var(--inkkit-font-size, 15px) * 0.133);
692
+ top: calc(var(--_inkkit-task-top) + var(--inkkit-font-size, 15px) * 0.133);
679
693
  width: calc(var(--inkkit-font-size, 15px) * 0.2);
680
694
  height: calc(var(--inkkit-font-size, 15px) * 0.467);
681
695
  border: solid Canvas;
package/dist/types.d.ts CHANGED
@@ -272,6 +272,8 @@ export interface Heading extends Readonly<DocumentVersion> {
272
272
  }
273
273
  /** A command for `table`. `insert` makes a table; the others work on the table at the selection. */
274
274
  export type TableCommand = 'insert' | 'addRowBefore' | 'addRowAfter' | 'addColumnBefore' | 'addColumnAfter' | 'deleteRow' | 'deleteColumn' | 'deleteTable' | 'alignLeft' | 'alignCenter' | 'alignRight' | 'moveRowUp' | 'moveRowDown' | 'moveColumnLeft' | 'moveColumnRight' | 'sortRows' | 'exit';
275
+ /** Where `moveBlock` moves the blocks at the selection. */
276
+ export type BlockMoveDirection = 'up' | 'down';
275
277
  /** Each option belongs to one command; any other combination is refused. */
276
278
  export interface TableOptions {
277
279
  /** `insert`: 1 to 100, counting the header row. Defaults to 3. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aicayzer/inkkit",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "A preserving Markdown editor for offline web views and the web",
5
5
  "license": "MIT",
6
6
  "type": "module",