@lalternative/editor 0.9.0 → 0.10.0
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/LICENSE +374 -0
- package/README.md +20 -0
- package/dist/{diff-uFiP8hD5.d.ts → diff-9dRTXeJa.d.ts} +1 -1
- package/dist/editor.css +210 -0
- package/dist/index.d.ts +141 -4
- package/dist/index.js +474 -11
- package/dist/index.js.map +1 -1
- package/dist/native.d.ts +73 -0
- package/dist/native.js +255 -0
- package/dist/native.js.map +1 -0
- package/dist/revisions.d.ts +2 -2
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { R as RichDoc } from './diff-
|
|
2
|
-
export { B as BlockChange,
|
|
1
|
+
import { R as RichDoc, a as RichNode } from './diff-9dRTXeJa.js';
|
|
2
|
+
export { B as BlockChange, b as BlockShape, C as ChangeKind, c as blocksFromDoc, d as diffBlocks, e as docFromBlocks, s as shapesFromDoc } from './diff-9dRTXeJa.js';
|
|
3
3
|
import * as react from 'react';
|
|
4
4
|
import { Editor } from '@tiptap/react';
|
|
5
|
-
import { Range, Extension } from '@tiptap/core';
|
|
5
|
+
import { Range, Extension, Editor as Editor$1 } from '@tiptap/core';
|
|
6
6
|
import { PluginKey } from '@tiptap/pm/state';
|
|
7
7
|
import { DecorationSet } from '@tiptap/pm/view';
|
|
8
8
|
|
|
@@ -327,4 +327,141 @@ declare function splitRevision(before: string, after: string): RevisionPart[];
|
|
|
327
327
|
*/
|
|
328
328
|
declare function docToMarkdown(doc: RichDoc): string;
|
|
329
329
|
|
|
330
|
-
|
|
330
|
+
declare const MIN_PASSAGE_CHARS = 12;
|
|
331
|
+
declare function canAssist(passage: string): boolean;
|
|
332
|
+
/** Thrown by a host's callback when its backend has no model or search configured. */
|
|
333
|
+
declare class WritingNotAvailableError extends Error {
|
|
334
|
+
constructor();
|
|
335
|
+
}
|
|
336
|
+
type Revise = (passage: string, instruction: string) => Promise<string>;
|
|
337
|
+
declare const defaultRevisionPresets: readonly string[];
|
|
338
|
+
declare function normalizeInstruction(instruction: string): string | null;
|
|
339
|
+
declare function proposalChanges(passage: string, proposal: string): RevisionPart[];
|
|
340
|
+
interface FoundSource {
|
|
341
|
+
title: string;
|
|
342
|
+
url: string;
|
|
343
|
+
excerpt: string;
|
|
344
|
+
}
|
|
345
|
+
type FindSources = (passage: string) => Promise<FoundSource[]>;
|
|
346
|
+
declare function hostOf(url: string): string;
|
|
347
|
+
|
|
348
|
+
interface RevisionPromptLabels {
|
|
349
|
+
title: string;
|
|
350
|
+
instruction: string;
|
|
351
|
+
placeholder: string;
|
|
352
|
+
submit: string;
|
|
353
|
+
busy: string;
|
|
354
|
+
proposal: string;
|
|
355
|
+
unchanged: string;
|
|
356
|
+
accept: string;
|
|
357
|
+
reject: string;
|
|
358
|
+
close: string;
|
|
359
|
+
}
|
|
360
|
+
declare const defaultRevisionPromptLabels: RevisionPromptLabels;
|
|
361
|
+
interface RevisionPromptProps {
|
|
362
|
+
passage: string;
|
|
363
|
+
revise: Revise;
|
|
364
|
+
/** Called with the proposal once the author accepts it; the prompt never writes on its own. */
|
|
365
|
+
onAccept: (proposal: string) => void;
|
|
366
|
+
onClose: () => void;
|
|
367
|
+
presets?: readonly string[];
|
|
368
|
+
labels?: RevisionPromptLabels;
|
|
369
|
+
formatError?: (error: unknown) => string;
|
|
370
|
+
}
|
|
371
|
+
declare function RevisionPrompt({ passage, revise, onAccept, onClose, presets, labels, formatError, }: RevisionPromptProps): react.JSX.Element;
|
|
372
|
+
|
|
373
|
+
interface SourcesPanelLabels {
|
|
374
|
+
title: string;
|
|
375
|
+
searching: string;
|
|
376
|
+
empty: string;
|
|
377
|
+
open: string;
|
|
378
|
+
insert: string;
|
|
379
|
+
close: string;
|
|
380
|
+
}
|
|
381
|
+
declare const defaultSourcesPanelLabels: SourcesPanelLabels;
|
|
382
|
+
interface SourcesPanelProps {
|
|
383
|
+
passage: string;
|
|
384
|
+
findSources: FindSources;
|
|
385
|
+
onInsert: (source: FoundSource) => void;
|
|
386
|
+
onClose: () => void;
|
|
387
|
+
/** Extra per-source actions a host adds beside insert. */
|
|
388
|
+
renderActions?: (source: FoundSource) => React.ReactNode;
|
|
389
|
+
labels?: SourcesPanelLabels;
|
|
390
|
+
formatError?: (error: unknown) => string;
|
|
391
|
+
}
|
|
392
|
+
declare function SourcesPanel({ passage, findSources, onInsert, onClose, renderActions, labels, formatError, }: SourcesPanelProps): react.JSX.Element;
|
|
393
|
+
|
|
394
|
+
interface DictationEnvironment {
|
|
395
|
+
hasGetUserMedia: boolean;
|
|
396
|
+
hasMediaRecorder: boolean;
|
|
397
|
+
}
|
|
398
|
+
declare function isDictationSupported(env?: DictationEnvironment): boolean;
|
|
399
|
+
declare function pickMimeType(isTypeSupported?: ((type: string) => boolean) | undefined): string | undefined;
|
|
400
|
+
declare function spacedTranscript(preceding: string, transcript: string): string;
|
|
401
|
+
declare function insertTranscript(editor: Editor$1, transcript: string): boolean;
|
|
402
|
+
|
|
403
|
+
type DictationState = "idle" | "recording" | "transcribing";
|
|
404
|
+
interface UseDictationOptions {
|
|
405
|
+
transcribe: (audio: Blob) => Promise<string>;
|
|
406
|
+
}
|
|
407
|
+
interface UseDictation {
|
|
408
|
+
state: DictationState;
|
|
409
|
+
supported: boolean;
|
|
410
|
+
error: Error | null;
|
|
411
|
+
start: () => Promise<void>;
|
|
412
|
+
/** Stops recording and resolves with the transcript, or null when nothing was heard. */
|
|
413
|
+
stop: () => Promise<string | null>;
|
|
414
|
+
toggle: () => Promise<string | null>;
|
|
415
|
+
}
|
|
416
|
+
declare function useDictation({ transcribe }: UseDictationOptions): UseDictation;
|
|
417
|
+
|
|
418
|
+
interface DictationLabels {
|
|
419
|
+
start: string;
|
|
420
|
+
stop: string;
|
|
421
|
+
transcribing: string;
|
|
422
|
+
unsupported: string;
|
|
423
|
+
}
|
|
424
|
+
declare const defaultDictationLabels: DictationLabels;
|
|
425
|
+
interface DictationButtonProps {
|
|
426
|
+
transcribe: (audio: Blob) => Promise<string>;
|
|
427
|
+
onTranscript: (text: string) => void;
|
|
428
|
+
onError?: (error: Error) => void;
|
|
429
|
+
labels?: DictationLabels;
|
|
430
|
+
icon?: React.ReactNode;
|
|
431
|
+
disabled?: boolean;
|
|
432
|
+
className?: string;
|
|
433
|
+
}
|
|
434
|
+
declare function DictationButton({ transcribe, onTranscript, onError, labels, icon, disabled, className, }: DictationButtonProps): react.JSX.Element;
|
|
435
|
+
|
|
436
|
+
interface Citation {
|
|
437
|
+
index: number;
|
|
438
|
+
title: string;
|
|
439
|
+
href?: string | null;
|
|
440
|
+
}
|
|
441
|
+
interface WebSource {
|
|
442
|
+
title: string;
|
|
443
|
+
url: string;
|
|
444
|
+
excerpt?: string;
|
|
445
|
+
}
|
|
446
|
+
interface ConversationTurn {
|
|
447
|
+
role: "user" | "assistant";
|
|
448
|
+
content: string;
|
|
449
|
+
/** A turn where the assistant asked back instead of answering. */
|
|
450
|
+
clarify?: boolean;
|
|
451
|
+
citations?: Citation[];
|
|
452
|
+
}
|
|
453
|
+
declare function linkMarkers(block: string, citations: Citation[]): RichNode[];
|
|
454
|
+
declare function webSourceToNodes(source: WebSource): RichNode[];
|
|
455
|
+
declare function answerToNodes(params: {
|
|
456
|
+
question: string;
|
|
457
|
+
answer: string;
|
|
458
|
+
citations: Citation[];
|
|
459
|
+
sourcesLabel: string;
|
|
460
|
+
}): RichNode[];
|
|
461
|
+
declare function headingFromQuestion(question: string): string;
|
|
462
|
+
declare function conversationToNodes(params: {
|
|
463
|
+
turns: ConversationTurn[];
|
|
464
|
+
sourcesLabel: string;
|
|
465
|
+
}): RichNode[];
|
|
466
|
+
|
|
467
|
+
export { type BlockFormat, type Citation, type ConversationTurn, type DefaultSlashId, type DefaultSlashItemsOptions, DictationButton, type DictationButtonProps, type DictationEnvironment, type DictationLabels, type DictationState, EditorScreen, type EditorScreenProps, type FindSources, type FormatLabels, type FoundSource, type InlineSuggestion, InlineSuggestions, MIN_PASSAGE_CHARS, type PlaceToolbarInput, type ReadViewportInput, type Revise, type RevisionPart, RevisionPrompt, type RevisionPromptLabels, type RevisionPromptProps, RichDoc, RichNode, type SaveLabels, type SaveState, type SelectionInfo, type SelectionRect, SelectionToolbar, type SelectionToolbarProps, SlashCommands, type SlashCommandsOptions, type SlashDescriptions, type SlashItem, type SlashLabels, SlashMenu, type SlashMenuHandle, type SlashMenuProps, SourcesPanel, type SourcesPanelLabels, type SourcesPanelProps, type SuggestionActions, type TextRange, type ToolbarAction, type ToolbarPlacement, type UseDictation, type UseDictationOptions, type ViewportMetrics, type VisualViewportLike, type WebSource, WritingNotAvailableError, answerToNodes, blockFormats, canAssist, conversationToNodes, defaultDictationLabels, defaultFormatLabels, defaultRevisionPresets, defaultRevisionPromptLabels, defaultSaveLabels, defaultSlashItems, defaultSlashLabels, defaultSourcesPanelLabels, docToMarkdown, expandToWords, filterSlashItems, headingFromQuestion, hostOf, inlineSuggestionsKey, insertTranscript, isDictationSupported, linkMarkers, normalizeInstruction, pickMimeType, placeToolbar, proposalChanges, readViewport, spacedTranscript, splitRevision, useDictation, useSelectionToolbar, useViewport, webSourceToNodes };
|