@aicayzer/inkkit 0.6.1 → 0.7.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.
- package/dist/chunks/{core-CbHV2KPY.js → core-Bn6QiQSD.js} +10233 -9810
- package/dist/chunks/{highlight-C-9lbVMU.js → highlight-CVL-YhFo.js} +1 -1
- package/dist/core.d.ts +2 -1
- package/dist/core.js +2 -2
- package/dist/editor.d.ts +20 -1
- package/dist/index.js +2 -2
- package/dist/link-address.d.ts +11 -0
- package/dist/types.d.ts +39 -1
- package/package.json +3 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as DecorationSet, f as __commonJSMin, l as Plugin, o as $prose, p as __toESM, s as Decoration, u as PluginKey } from "./core-Bn6QiQSD.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,6 +1,7 @@
|
|
|
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
|
|
4
|
+
export { normalizeLinkAddress, canOpenLink } from './link-address.js';
|
|
5
|
+
export type { DocumentFormat, TextDocumentFormat, TextDocumentInput, RichTextDocumentInput, TextDocumentSnapshot, RichTextDocumentSnapshot, RichTextDocument, RichTextBlock, RichTextListItem, RichTextTableCell, RichTextInline, RichTextMark, FormatLoss, FormatLossCode, ConvertedDocument, FormatPromise, OfferedFormat, EditorLabels, Heading, TableCommand, TableOptions, BlockMoveDirection, DocumentContext, DocumentInput, DocumentSnapshot, DocumentVersion, EditorErrorCode, ImageAdapter, ImageImportContext, WikiLinkReference, WikiLinkAdapter, FileReference, ClientPoint, FileContext, FilePresentation, FileAdapter, CapturedImage, PortableImage, ClipboardInput, ClipboardOutput, ClipboardScope, ClipboardImage, ClipboardDiagram, PrintableDocument, PrintableWarning, TextRange, FindState, FindSession, ReadableTextSnapshot, TextRect, ViewportInsets, ViewportOptions, ViewportSnapshot, } from './types.js';
|
|
5
6
|
export type { SlashMenuOptions, SlashCommandName, SlashCommand } from './types.js';
|
|
6
7
|
export type { DiagnosticReport, DiagnosticEvent, DiagnosticState, DiagnosticPresentation, } from './diagnostics.js';
|
package/dist/core.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { InkKitEditor, InkKitError };
|
|
1
|
+
import { a as InkKitError, n as normalizeLinkAddress, r as InkKitEditor, t as canOpenLink } from "./chunks/core-Bn6QiQSD.js";
|
|
2
|
+
export { InkKitEditor, InkKitError, canOpenLink, normalizeLinkAddress };
|
package/dist/editor.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type DiagnosticReport } from './diagnostics.js';
|
|
2
2
|
import type { SlashMenuOptions } from './types.js';
|
|
3
|
-
import { InkKitError, type ClientPoint, type DocumentFormat, type DocumentInput, type DocumentSnapshot, type ConvertedDocument, type TextDocumentFormat, 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, type OfferedFormat } from './types.js';
|
|
3
|
+
import { InkKitError, type ClientPoint, type DocumentFormat, type DocumentInput, type DocumentSnapshot, type ConvertedDocument, type TextDocumentFormat, type ImageAdapter, type FileAdapter, type WikiLinkAdapter, type ClipboardInput, type ClipboardOutput, type ClipboardScope, type DocumentVersion, type PrintableDocument, type TextRange, type ReadableTextSnapshot, type FindSession, type FindState, type TextRect, type ViewportOptions, type ViewportSnapshot, type EditorLabels, type Heading, type TableCommand, type TableOptions, type BlockMoveDirection, type OfferedFormat } from './types.js';
|
|
4
4
|
/** An inline format that `CaretState` can report. */
|
|
5
5
|
export type Mark = 'bold' | 'italic' | 'strikethrough' | 'highlight' | 'underline' | 'superscript' | 'subscript' | 'code' | 'link';
|
|
6
6
|
/** The kind of block that holds the start of the selection. Any other block reports `paragraph`. */
|
|
@@ -27,6 +27,10 @@ export interface CaretState {
|
|
|
27
27
|
block: Block;
|
|
28
28
|
/** One quote holds the whole selection; the block is what sits inside it. */
|
|
29
29
|
quoted: boolean;
|
|
30
|
+
/** The address of the link at the caret or, for a range, of the first link in it, as the
|
|
31
|
+
* document holds it. Present exactly when `marks` includes `'link'`. For a reference link, it
|
|
32
|
+
* is the address its definition gives. A host's Link sheet starts from it. */
|
|
33
|
+
href?: string;
|
|
30
34
|
/** In an RTF document, the alignment of the paragraph that holds the start of the selection. */
|
|
31
35
|
align?: 'left' | 'center' | 'right' | 'justify';
|
|
32
36
|
}
|
|
@@ -178,6 +182,9 @@ export declare class InkKitEditor<F extends DocumentFormat = TextDocumentFormat>
|
|
|
178
182
|
private ownsRootClass;
|
|
179
183
|
private activation;
|
|
180
184
|
private reportingSuppressed;
|
|
185
|
+
/** A reload keeps each find session's query; a load starts without one. */
|
|
186
|
+
private reloading;
|
|
187
|
+
private readonly findSessions;
|
|
181
188
|
private loading;
|
|
182
189
|
private call?;
|
|
183
190
|
private writable;
|
|
@@ -268,6 +275,7 @@ export declare class InkKitEditor<F extends DocumentFormat = TextDocumentFormat>
|
|
|
268
275
|
setTextInputPreferences(preferences: TextInputPreferences): void;
|
|
269
276
|
private applyInputPolicy;
|
|
270
277
|
private publishCommandState;
|
|
278
|
+
private refreshFindSessions;
|
|
271
279
|
/** What the editor can do now, for enabling host controls. Unlike `snapshot`, it works during
|
|
272
280
|
* composition. */
|
|
273
281
|
commandState(expectedGeneration?: number): CommandState;
|
|
@@ -289,6 +297,11 @@ export declare class InkKitEditor<F extends DocumentFormat = TextDocumentFormat>
|
|
|
289
297
|
undo(expectedGeneration?: number): boolean;
|
|
290
298
|
/** Returns whether a history step applied. */
|
|
291
299
|
redo(expectedGeneration?: number): boolean;
|
|
300
|
+
/** Drops the steps that `undo` took off the history, so `redo` has nothing to bring back. For a
|
|
301
|
+
* host that adds content after an undo and must not let a redo resurrect what was undone.
|
|
302
|
+
* Returns whether a redo was available. The document, selection, revision and undo steps stay
|
|
303
|
+
* as they are, and no `changed` event is sent. */
|
|
304
|
+
discardUndone(expectedGeneration?: number): boolean;
|
|
292
305
|
/** The complete current document, which is what a host saves. It throws rather than return a
|
|
293
306
|
* partial document. */
|
|
294
307
|
snapshot(expectedGeneration?: number): DocumentSnapshot<F>;
|
|
@@ -379,6 +392,12 @@ export declare class InkKitEditor<F extends DocumentFormat = TextDocumentFormat>
|
|
|
379
392
|
replace(search: string, replacement: string, expectedGeneration?: number): boolean;
|
|
380
393
|
/** Replaces every non-overlapping match once and returns how many. */
|
|
381
394
|
replaceAll(search: string, replacement: string, expectedGeneration?: number): number;
|
|
395
|
+
/**
|
|
396
|
+
* Opens a find session, which keeps a query and reports its match count and position to
|
|
397
|
+
* `onChange` whenever they change. Open one session per editor: the editor has one set of
|
|
398
|
+
* highlights.
|
|
399
|
+
*/
|
|
400
|
+
findSession(onChange: (state: FindState) => void): FindSession;
|
|
382
401
|
private outlineContext;
|
|
383
402
|
/** The outline in document order. Entries go stale when the document changes. */
|
|
384
403
|
headings(expectedGeneration?: number): readonly Heading[];
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as InkKitError, i as registerDiagram, n as normalizeLinkAddress, r as InkKitEditor, t as canOpenLink } from "./chunks/core-Bn6QiQSD.js";
|
|
2
2
|
//#region node_modules/.pnpm/dompurify@3.4.17/node_modules/dompurify/dist/purify.es.mjs
|
|
3
3
|
/*! @license DOMPurify 3.4.17 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.17/LICENSE */
|
|
4
4
|
function _OverloadYield(e, d) {
|
|
@@ -32790,4 +32790,4 @@ function renderPele(source) {
|
|
|
32790
32790
|
//#region src/index.ts
|
|
32791
32791
|
registerDiagram(renderPele);
|
|
32792
32792
|
//#endregion
|
|
32793
|
-
export { InkKitEditor, InkKitError };
|
|
32793
|
+
export { InkKitEditor, InkKitError, canOpenLink, normalizeLinkAddress };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The address a Link field should write for what the person typed, or `undefined` when it is not
|
|
3
|
+
* a web, mail or phone address. See the reference, which describes each rule.
|
|
4
|
+
*/
|
|
5
|
+
export declare function normalizeLinkAddress(input: string): string | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* Whether a host may open `address` for the person. Only `http`, `https`, `mailto` and `tel`
|
|
8
|
+
* qualify, whatever the letter case. An address with no scheme, an unknown scheme such as
|
|
9
|
+
* `javascript:` or `file:`, or a control character does not.
|
|
10
|
+
*/
|
|
11
|
+
export declare function canOpenLink(address: string): boolean;
|
package/dist/types.d.ts
CHANGED
|
@@ -120,7 +120,7 @@ export interface RichTextDocumentSnapshot extends RichTextDocumentInput, Documen
|
|
|
120
120
|
dirty: boolean;
|
|
121
121
|
}
|
|
122
122
|
/** The closed list of failure codes. The API reference describes each one. */
|
|
123
|
-
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'];
|
|
123
|
+
export declare const editorErrorCodes: readonly ['not-ready', 'destroyed', 'stale-document', 'composition', 'operation-pending', 'read-only', 'invalid-argument', 'invalid-range', 'preservation', 'image-unavailable', 'image-unsupported', 'diagram-unavailable', 'file-unavailable', 'clipboard-unavailable', 'slash-command-failed', 'internal'];
|
|
124
124
|
export type EditorErrorCode = (typeof editorErrorCodes)[number];
|
|
125
125
|
/** Every failure InkKit reports. Hosts branch on `code`; `message` is for logs. When the failure
|
|
126
126
|
* started elsewhere, such as in an adapter, the host clipboard or the renderer, `cause` holds the
|
|
@@ -310,6 +310,44 @@ export interface ReadableTextSnapshot extends DocumentVersion {
|
|
|
310
310
|
text: string;
|
|
311
311
|
selection: TextRange;
|
|
312
312
|
}
|
|
313
|
+
/** What a find session shows: how many matches the query has and which one the selection is on. */
|
|
314
|
+
export interface FindState extends DocumentVersion {
|
|
315
|
+
/** The query, or an empty string when there is none. */
|
|
316
|
+
query: string;
|
|
317
|
+
/** The position, from 1, of the match that the selection covers exactly, or 0 when the selection
|
|
318
|
+
* is not on a match. */
|
|
319
|
+
current: number;
|
|
320
|
+
/** The number of matches. */
|
|
321
|
+
total: number;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* A find bar's state and commands: the query, the match count, the match the selection is on, and
|
|
325
|
+
* navigation that wraps. Open one with `InkKitEditor.findSession`.
|
|
326
|
+
*/
|
|
327
|
+
export interface FindSession {
|
|
328
|
+
/** The current state. It does not call the change handler. */
|
|
329
|
+
state(expectedGeneration?: number): FindState;
|
|
330
|
+
/** Sets the query, highlights its matches and selects one. A new query selects the first match
|
|
331
|
+
* at or after the selection, or the last one before it with `direction: 'previous'`. With the
|
|
332
|
+
* same query, the selection moves to the next or previous match and wraps at the ends; without
|
|
333
|
+
* a direction, a selection on a match stays there. Returns whether there is a match. */
|
|
334
|
+
find(query: string, options?: {
|
|
335
|
+
direction?: 'next' | 'previous';
|
|
336
|
+
}, expectedGeneration?: number): boolean;
|
|
337
|
+
/** Moves to the next match, wrapping at the end. Returns whether there is a match. */
|
|
338
|
+
next(expectedGeneration?: number): boolean;
|
|
339
|
+
/** Moves to the previous match, wrapping at the start. Returns whether there is a match. */
|
|
340
|
+
previous(expectedGeneration?: number): boolean;
|
|
341
|
+
/** Replaces the selected match, or the next one, and selects the match after it. Returns whether
|
|
342
|
+
* the text changed. A match that already reads as the replacement is skipped without a change. */
|
|
343
|
+
replace(query: string, replacement: string, expectedGeneration?: number): boolean;
|
|
344
|
+
/** Replaces every match and returns how many were replaced. */
|
|
345
|
+
replaceAll(query: string, replacement: string, expectedGeneration?: number): number;
|
|
346
|
+
/** Clears the query and the highlights. */
|
|
347
|
+
clear(expectedGeneration?: number): void;
|
|
348
|
+
/** Stops the session: it clears the highlights and its handler is not called again. */
|
|
349
|
+
close(): void;
|
|
350
|
+
}
|
|
313
351
|
/** A rectangle in CSS pixels in the web view's client coordinate space. */
|
|
314
352
|
export interface TextRect {
|
|
315
353
|
left: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aicayzer/inkkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "A preserving Markdown editor for offline web views and the web",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -55,6 +55,8 @@
|
|
|
55
55
|
"test:package": "node scripts/test-package.mjs",
|
|
56
56
|
"check": "pnpm typecheck && pnpm test && pnpm build && pnpm test:docs && pnpm test:package",
|
|
57
57
|
"test:browser": "playwright test --project=chromium",
|
|
58
|
+
"test:playground": "playwright test --config playwright.playground.config.ts --project=chromium",
|
|
59
|
+
"measure:browser": "playwright test --config playwright.measure.config.ts",
|
|
58
60
|
"test:built-playground": "playwright test --config playwright.built.config.ts"
|
|
59
61
|
},
|
|
60
62
|
"devDependencies": {
|