@embedpdf/web 3.0.0-next.12 → 3.0.0-next.13
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/index.cjs +761 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +233 -1
- package/dist/index.d.ts +233 -1
- package/dist/index.js +751 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -616,5 +616,237 @@ interface IndexedDbByteStoreOptions {
|
|
|
616
616
|
/** Open (creating on first use) one IndexedDB object store keyed by id. */
|
|
617
617
|
declare function indexedDbByteStore(dbName: string, opts?: IndexedDbByteStoreOptions): ByteStore;
|
|
618
618
|
//#endregion
|
|
619
|
-
|
|
619
|
+
//#region src/rich-text-editor.d.ts
|
|
620
|
+
/**
|
|
621
|
+
* Rich text editor binding — the ONE contentEditable mechanics module for a
|
|
622
|
+
* FreeText annotation, shared by every framework adapter (React, Angular,
|
|
623
|
+
* Vue, Svelte…) so editing can never drift between them:
|
|
624
|
+
*
|
|
625
|
+
* • render a rich document (runs of style deltas over a body) into the
|
|
626
|
+
* element as paragraphs of inline-styled spans
|
|
627
|
+
* • serialise the element back into runs on `input` — inline styles only,
|
|
628
|
+
* never computed styles, so the editor cannot invent properties
|
|
629
|
+
* • map the DOM selection to flat offsets over the plain projection (and
|
|
630
|
+
* back), and keep the caret through a model-driven re-render
|
|
631
|
+
* • hold re-renders during IME composition, paste as plain text, forward
|
|
632
|
+
* Cmd/Ctrl+B/I/U as commands
|
|
633
|
+
*
|
|
634
|
+
* The browser owns typing; this module only translates. The POLICY — what a
|
|
635
|
+
* command does to the document, when to commit, what a family maps to —
|
|
636
|
+
* belongs to the host (the annotation plugin), reached through the
|
|
637
|
+
* structural {@link RichTextEditorHost}: @embedpdf/web imports no plugin,
|
|
638
|
+
* per the layering law. The return shape is a Svelte action; the other
|
|
639
|
+
* frameworks call the same two functions from their effects.
|
|
640
|
+
*
|
|
641
|
+
* Offsets: positions in the plain projection — paragraphs joined by `\r`,
|
|
642
|
+
* runs concatenated, a hard break inside a run is a `\r` too. The same
|
|
643
|
+
* arithmetic the core's run algebra uses.
|
|
644
|
+
*
|
|
645
|
+
* Known limits (by design, recorded in the plan): the browser's native undo
|
|
646
|
+
* stack does not span a host-driven restyle; DOM line wrapping approximates
|
|
647
|
+
* the engine's layout, the appearance stream is the truth.
|
|
648
|
+
*/
|
|
649
|
+
type RichTextEditorDecoration = 'underline' | 'line-through' | 'word';
|
|
650
|
+
type RichTextEditorScript = 'normal' | 'sub' | 'super';
|
|
651
|
+
type RichTextEditorAlign = 'left' | 'center' | 'right' | 'justify';
|
|
652
|
+
/** A run's style delta — the engine's `RichTextRunStyle`, structurally. */
|
|
653
|
+
interface RichTextEditorStyle {
|
|
654
|
+
family?: string;
|
|
655
|
+
weight?: number;
|
|
656
|
+
italic?: boolean;
|
|
657
|
+
size?: number;
|
|
658
|
+
color?: string;
|
|
659
|
+
decoration?: RichTextEditorDecoration[];
|
|
660
|
+
script?: RichTextEditorScript;
|
|
661
|
+
letterSpacing?: number;
|
|
662
|
+
horizontalScale?: number;
|
|
663
|
+
unknown?: string;
|
|
664
|
+
}
|
|
665
|
+
interface RichTextEditorRun {
|
|
666
|
+
text: string;
|
|
667
|
+
style?: RichTextEditorStyle;
|
|
668
|
+
}
|
|
669
|
+
interface RichTextEditorParagraph {
|
|
670
|
+
align?: RichTextEditorAlign;
|
|
671
|
+
dir?: 'ltr' | 'rtl';
|
|
672
|
+
runs: RichTextEditorRun[];
|
|
673
|
+
}
|
|
674
|
+
/** The document the editor renders and produces (the engine's input shape). */
|
|
675
|
+
interface RichTextEditorDocument {
|
|
676
|
+
paragraphs: RichTextEditorParagraph[];
|
|
677
|
+
}
|
|
678
|
+
interface RichTextEditorRange {
|
|
679
|
+
start: number;
|
|
680
|
+
end: number;
|
|
681
|
+
}
|
|
682
|
+
type RichTextEditorCommand = 'bold' | 'italic' | 'underline';
|
|
683
|
+
/** What the binding needs from the plugin — structural, no plugin import. */
|
|
684
|
+
interface RichTextEditorHost {
|
|
685
|
+
/** The element's content changed by typing: here is the serialised document. */
|
|
686
|
+
onInput(doc: RichTextEditorDocument): void;
|
|
687
|
+
/** The selection inside the editor moved (null: the editor has none). */
|
|
688
|
+
onSelectionChange(range: RichTextEditorRange | null): void;
|
|
689
|
+
/** A keyboard command the host applies to the current selection. */
|
|
690
|
+
onCommand(command: RichTextEditorCommand): void;
|
|
691
|
+
/** The CSS family list for a PDF family ("Helvetica" → a web stack, a
|
|
692
|
+
* registered family → itself, mounted as a @font-face). */
|
|
693
|
+
cssFontFamily(family: string): string;
|
|
694
|
+
}
|
|
695
|
+
interface RichTextEditorProps {
|
|
696
|
+
document: RichTextEditorDocument;
|
|
697
|
+
/** Screen px per content unit (the page scale): sizes are content points. */
|
|
698
|
+
scale: number;
|
|
699
|
+
}
|
|
700
|
+
interface RichTextEditorBinding {
|
|
701
|
+
update(props: RichTextEditorProps): void;
|
|
702
|
+
/** The current selection as flat offsets, or null when not in the editor. */
|
|
703
|
+
selection(): RichTextEditorRange | null;
|
|
704
|
+
/** Place the selection (after the host restyled the document). */
|
|
705
|
+
select(range: RichTextEditorRange): void;
|
|
706
|
+
detach(): void;
|
|
707
|
+
}
|
|
708
|
+
interface EditorStyle {
|
|
709
|
+
marginTop?: string;
|
|
710
|
+
lineHeight?: string;
|
|
711
|
+
fontWeight: string;
|
|
712
|
+
fontStyle: string;
|
|
713
|
+
textDecoration: string;
|
|
714
|
+
textDecorationLine?: string;
|
|
715
|
+
color: string;
|
|
716
|
+
fontSize: string;
|
|
717
|
+
fontFamily: string;
|
|
718
|
+
verticalAlign: string;
|
|
719
|
+
letterSpacing: string;
|
|
720
|
+
textAlign: string;
|
|
721
|
+
direction: string;
|
|
722
|
+
}
|
|
723
|
+
interface EditorNode {
|
|
724
|
+
nodeType: number;
|
|
725
|
+
nodeName: string;
|
|
726
|
+
nodeValue?: string | null;
|
|
727
|
+
childNodes: ArrayLike<EditorNode>;
|
|
728
|
+
parentNode?: EditorNode | null;
|
|
729
|
+
style?: EditorStyle;
|
|
730
|
+
}
|
|
731
|
+
interface EditorElement extends EditorNode {
|
|
732
|
+
style: EditorStyle;
|
|
733
|
+
appendChild(node: EditorNode): unknown;
|
|
734
|
+
}
|
|
735
|
+
interface EditorDocumentFactory {
|
|
736
|
+
createElement(tag: string): EditorElement;
|
|
737
|
+
createTextNode(text: string): EditorNode;
|
|
738
|
+
}
|
|
739
|
+
interface EditorRoot extends EditorNode {
|
|
740
|
+
ownerDocument: EditorDocumentFactory | null;
|
|
741
|
+
appendChild(node: EditorNode): unknown;
|
|
742
|
+
replaceChildren?(...nodes: EditorNode[]): void;
|
|
743
|
+
removeChild?(node: EditorNode): unknown;
|
|
744
|
+
firstChild?: EditorNode | null;
|
|
745
|
+
}
|
|
746
|
+
/** The inline style declarations a span carries, as a style delta. Only what
|
|
747
|
+
* the span itself sets: an unset property means "inherit", never a value. */
|
|
748
|
+
declare function styleDeltaOf(style: EditorStyle | undefined, scale: number): RichTextEditorStyle;
|
|
749
|
+
/** Render a document into the element: one block per paragraph, one span per
|
|
750
|
+
* styled run, `<br>` for a hard break, a placeholder `<br>` at the end of a
|
|
751
|
+
* block that is empty or ends on a break so the caret has a home. */
|
|
752
|
+
declare function renderRichText(root: EditorRoot, doc: RichTextEditorDocument, options: {
|
|
753
|
+
scale: number;
|
|
754
|
+
cssFontFamily: (family: string) => string;
|
|
755
|
+
}): void;
|
|
756
|
+
/** Keep the baseline adjustment on the first block after Enter clones it. */
|
|
757
|
+
declare function applyFirstLineShift(root: EditorNode, shift: number | undefined): void;
|
|
758
|
+
/** The element's content as a document. Inline styles (and the semantic
|
|
759
|
+
* b/i/u/sub/sup tags a browser may insert) only. */
|
|
760
|
+
declare function serializeRichText(root: EditorNode, scale: number): RichTextEditorDocument;
|
|
761
|
+
interface EditorPosition {
|
|
762
|
+
node: EditorNode;
|
|
763
|
+
offset: number;
|
|
764
|
+
}
|
|
765
|
+
/** The flat offset of a DOM position (a node and an offset within it). */
|
|
766
|
+
declare function offsetOfPosition(root: EditorNode, position: EditorPosition): number;
|
|
767
|
+
/** The DOM position of a flat offset: inside a text node when one covers it,
|
|
768
|
+
* else the empty block / the slot after a hard break the offset names. */
|
|
769
|
+
declare function positionOfOffset(root: EditorNode, offset: number): EditorPosition | null;
|
|
770
|
+
/** Bind one contentEditable element. Returns the Svelte-action-shaped handle. */
|
|
771
|
+
declare function attachRichTextEditor(el: HTMLElement, host: RichTextEditorHost, initial: RichTextEditorProps): RichTextEditorBinding;
|
|
772
|
+
//#endregion
|
|
773
|
+
//#region src/web-font.d.ts
|
|
774
|
+
/**
|
|
775
|
+
* Mount a registered font for the DOM: the engine lays text out with the
|
|
776
|
+
* font's bytes, the browser needs the same face as a `@font-face` so the
|
|
777
|
+
* live editor and the vector renderer show the glyphs the appearance stream
|
|
778
|
+
* will bake. The family name is the font's KEY — the CSS family the
|
|
779
|
+
* annotation plugin emits for a registered font (`cssFontFamily`) — so
|
|
780
|
+
* mounting under the key is what makes the two agree.
|
|
781
|
+
*
|
|
782
|
+
* Returns the unmount. Idempotent per (document, key): a second mount of a
|
|
783
|
+
* key already in the document's font set is a no-op that still returns an
|
|
784
|
+
* unmount of its own (the face leaves when the LAST holder unmounts).
|
|
785
|
+
*/
|
|
786
|
+
declare function mountWebFont(key: string, data: ArrayBuffer | Uint8Array, options?: {
|
|
787
|
+
document?: Document;
|
|
788
|
+
weight?: number | string;
|
|
789
|
+
style?: 'normal' | 'italic';
|
|
790
|
+
}): Promise<() => void>;
|
|
791
|
+
//#endregion
|
|
792
|
+
//#region src/web-font-metrics.d.ts
|
|
793
|
+
/**
|
|
794
|
+
* Acrobat's line model, stated in CSS — private to the rich text binding.
|
|
795
|
+
*
|
|
796
|
+
* The engine lays a line out the way Acrobat does: the line box is the
|
|
797
|
+
* face's ascent + descent (its `hhea` metrics) + a constant 0.2 × size of
|
|
798
|
+
* leading, with the baseline at the ascent and the leading entirely below.
|
|
799
|
+
* The standard 14 carry no font program, so the engine uses the metrics of
|
|
800
|
+
* Acrobat's bundled substitutes (Helvetica 0.83/0.17, Times 0.784/0.216,
|
|
801
|
+
* Courier 0.627/0.373); any other face — a registered font, an embedded
|
|
802
|
+
* one — uses its own `hhea` table.
|
|
803
|
+
*
|
|
804
|
+
* Canvas provides browser metrics, which can be rounded or differ from the
|
|
805
|
+
* font program's metrics. They approximate the registered font's line model;
|
|
806
|
+
* standard families use the engine's known values below. CSS still chooses
|
|
807
|
+
* wrapping and combines mixed runs differently from the engine.
|
|
808
|
+
*
|
|
809
|
+
* One thing CSS cannot express: it centres a line's leading (half above the
|
|
810
|
+
* glyphs), and the substitute face's ascent differs from the engine's, so
|
|
811
|
+
* the first baseline can land lower by the half-leading plus that ascent
|
|
812
|
+
* gap. The binding compensates using the body's face and size; mixed runs
|
|
813
|
+
* remain approximate.
|
|
814
|
+
*/
|
|
815
|
+
interface WebFontMetrics {
|
|
816
|
+
/** Ascent above the baseline, per em. */
|
|
817
|
+
ascent: number;
|
|
818
|
+
/** Descent below the baseline, per em. */
|
|
819
|
+
descent: number;
|
|
820
|
+
}
|
|
821
|
+
/** A face's approximate CSS line model. */
|
|
822
|
+
interface LineModel {
|
|
823
|
+
ascent: number;
|
|
824
|
+
descent: number;
|
|
825
|
+
/** Unitless CSS line height: ascent + descent + Acrobat's 0.2 leading. */
|
|
826
|
+
lineHeight: number;
|
|
827
|
+
}
|
|
828
|
+
/**
|
|
829
|
+
* The browser's own ascent and descent for a CSS family list, per em,
|
|
830
|
+
* measured through a canvas. `null` when the platform cannot measure
|
|
831
|
+
* (no canvas, no `fontBoundingBoxAscent`). Reads the currently resolved face
|
|
832
|
+
* on every call, including while the intended font is loading.
|
|
833
|
+
*/
|
|
834
|
+
declare function webFontMetrics(cssFamily: string, doc?: Document | undefined, face?: {
|
|
835
|
+
weight?: number | string;
|
|
836
|
+
style?: string;
|
|
837
|
+
}): WebFontMetrics | null;
|
|
838
|
+
/**
|
|
839
|
+
* The standard families' engine metrics, or a browser approximation for
|
|
840
|
+
* other families. `measure` is injectable for tests and resolved face styles.
|
|
841
|
+
*/
|
|
842
|
+
declare function lineModelFor(cssFamily: string, measure?: (cssFamily: string) => WebFontMetrics | null): LineModel;
|
|
843
|
+
/**
|
|
844
|
+
* Screen px to raise a box's first line by so its baseline matches the
|
|
845
|
+
* engine's: CSS puts half the leading above the glyphs and draws them with
|
|
846
|
+
* the browser's face, whose ascent differs from the engine's for the
|
|
847
|
+
* standard families. `fontSize` in screen px.
|
|
848
|
+
*/
|
|
849
|
+
declare function firstLineShiftFor(cssFamily: string, fontSize: number, measure?: (cssFamily: string) => WebFontMetrics | null): number;
|
|
850
|
+
//#endregion
|
|
851
|
+
export { type ActionsUiAdapterShape, type ActionsUiEffectContext, type ActionsUiOrigin, type AnchorTarget, type AnchoredPlacement, type AnchoredPoint, type AnchoredPosition, type AnchoredRect, type AttachSelectionHandleOptions, type ByteStore, type ClipboardSelectionSource, type DefaultActionsUiAdapterOptions, type EditorDocumentFactory, type EditorElement, type EditorNode, type EditorPosition, type EditorRoot, type EditorStyle, type IndexedDbByteStoreOptions, type LineModel, type ObjectUrlImageSource, type PaintedImageCallbacks, type PickFileOptions, type RichTextEditorAlign, type RichTextEditorBinding, type RichTextEditorCommand, type RichTextEditorDecoration, type RichTextEditorDocument, type RichTextEditorHost, type RichTextEditorParagraph, type RichTextEditorProps, type RichTextEditorRange, type RichTextEditorRun, type RichTextEditorScript, type RichTextEditorStyle, type SelectionClipboardOptions, type SelectionHandleSession, type StageGestureHost, type StageGestureOptions, type StageGestureSink, type StagePointerKind, type StageSurfaceHost, type StageSurfaceHub, type StageSurfaceOptions, type StageSurfaceSample, type StageWheelSample, type SvgCursorOptions, type ViewProjector, type WebFontMetrics, type WebPlatformFeedback, type WheelSample, applyFirstLineShift, attachRichTextEditor, attachSelectionHandle, bindPaintedImage, computeReleaseVelocity, copySelection, createDefaultActionsUiAdapter, createStageGestureController, createStageSurface, firstLineShiftFor, indexedDbByteStore, lineModelFor, mountWebFont, observeClientGeometry, offsetOfPosition, pickFile, pickImageFile, positionAnchoredRect, positionOfOffset, projectAnchoredTarget, renderRichText, sanitizeExternalUri, saveFile, serializeRichText, styleDeltaOf, svgCursor, vibrationFeedback, webFontMetrics, wheelZoomFactor, wireSelectionClipboard, wkFeedback };
|
|
620
852
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -616,5 +616,237 @@ interface IndexedDbByteStoreOptions {
|
|
|
616
616
|
/** Open (creating on first use) one IndexedDB object store keyed by id. */
|
|
617
617
|
declare function indexedDbByteStore(dbName: string, opts?: IndexedDbByteStoreOptions): ByteStore;
|
|
618
618
|
//#endregion
|
|
619
|
-
|
|
619
|
+
//#region src/rich-text-editor.d.ts
|
|
620
|
+
/**
|
|
621
|
+
* Rich text editor binding — the ONE contentEditable mechanics module for a
|
|
622
|
+
* FreeText annotation, shared by every framework adapter (React, Angular,
|
|
623
|
+
* Vue, Svelte…) so editing can never drift between them:
|
|
624
|
+
*
|
|
625
|
+
* • render a rich document (runs of style deltas over a body) into the
|
|
626
|
+
* element as paragraphs of inline-styled spans
|
|
627
|
+
* • serialise the element back into runs on `input` — inline styles only,
|
|
628
|
+
* never computed styles, so the editor cannot invent properties
|
|
629
|
+
* • map the DOM selection to flat offsets over the plain projection (and
|
|
630
|
+
* back), and keep the caret through a model-driven re-render
|
|
631
|
+
* • hold re-renders during IME composition, paste as plain text, forward
|
|
632
|
+
* Cmd/Ctrl+B/I/U as commands
|
|
633
|
+
*
|
|
634
|
+
* The browser owns typing; this module only translates. The POLICY — what a
|
|
635
|
+
* command does to the document, when to commit, what a family maps to —
|
|
636
|
+
* belongs to the host (the annotation plugin), reached through the
|
|
637
|
+
* structural {@link RichTextEditorHost}: @embedpdf/web imports no plugin,
|
|
638
|
+
* per the layering law. The return shape is a Svelte action; the other
|
|
639
|
+
* frameworks call the same two functions from their effects.
|
|
640
|
+
*
|
|
641
|
+
* Offsets: positions in the plain projection — paragraphs joined by `\r`,
|
|
642
|
+
* runs concatenated, a hard break inside a run is a `\r` too. The same
|
|
643
|
+
* arithmetic the core's run algebra uses.
|
|
644
|
+
*
|
|
645
|
+
* Known limits (by design, recorded in the plan): the browser's native undo
|
|
646
|
+
* stack does not span a host-driven restyle; DOM line wrapping approximates
|
|
647
|
+
* the engine's layout, the appearance stream is the truth.
|
|
648
|
+
*/
|
|
649
|
+
type RichTextEditorDecoration = 'underline' | 'line-through' | 'word';
|
|
650
|
+
type RichTextEditorScript = 'normal' | 'sub' | 'super';
|
|
651
|
+
type RichTextEditorAlign = 'left' | 'center' | 'right' | 'justify';
|
|
652
|
+
/** A run's style delta — the engine's `RichTextRunStyle`, structurally. */
|
|
653
|
+
interface RichTextEditorStyle {
|
|
654
|
+
family?: string;
|
|
655
|
+
weight?: number;
|
|
656
|
+
italic?: boolean;
|
|
657
|
+
size?: number;
|
|
658
|
+
color?: string;
|
|
659
|
+
decoration?: RichTextEditorDecoration[];
|
|
660
|
+
script?: RichTextEditorScript;
|
|
661
|
+
letterSpacing?: number;
|
|
662
|
+
horizontalScale?: number;
|
|
663
|
+
unknown?: string;
|
|
664
|
+
}
|
|
665
|
+
interface RichTextEditorRun {
|
|
666
|
+
text: string;
|
|
667
|
+
style?: RichTextEditorStyle;
|
|
668
|
+
}
|
|
669
|
+
interface RichTextEditorParagraph {
|
|
670
|
+
align?: RichTextEditorAlign;
|
|
671
|
+
dir?: 'ltr' | 'rtl';
|
|
672
|
+
runs: RichTextEditorRun[];
|
|
673
|
+
}
|
|
674
|
+
/** The document the editor renders and produces (the engine's input shape). */
|
|
675
|
+
interface RichTextEditorDocument {
|
|
676
|
+
paragraphs: RichTextEditorParagraph[];
|
|
677
|
+
}
|
|
678
|
+
interface RichTextEditorRange {
|
|
679
|
+
start: number;
|
|
680
|
+
end: number;
|
|
681
|
+
}
|
|
682
|
+
type RichTextEditorCommand = 'bold' | 'italic' | 'underline';
|
|
683
|
+
/** What the binding needs from the plugin — structural, no plugin import. */
|
|
684
|
+
interface RichTextEditorHost {
|
|
685
|
+
/** The element's content changed by typing: here is the serialised document. */
|
|
686
|
+
onInput(doc: RichTextEditorDocument): void;
|
|
687
|
+
/** The selection inside the editor moved (null: the editor has none). */
|
|
688
|
+
onSelectionChange(range: RichTextEditorRange | null): void;
|
|
689
|
+
/** A keyboard command the host applies to the current selection. */
|
|
690
|
+
onCommand(command: RichTextEditorCommand): void;
|
|
691
|
+
/** The CSS family list for a PDF family ("Helvetica" → a web stack, a
|
|
692
|
+
* registered family → itself, mounted as a @font-face). */
|
|
693
|
+
cssFontFamily(family: string): string;
|
|
694
|
+
}
|
|
695
|
+
interface RichTextEditorProps {
|
|
696
|
+
document: RichTextEditorDocument;
|
|
697
|
+
/** Screen px per content unit (the page scale): sizes are content points. */
|
|
698
|
+
scale: number;
|
|
699
|
+
}
|
|
700
|
+
interface RichTextEditorBinding {
|
|
701
|
+
update(props: RichTextEditorProps): void;
|
|
702
|
+
/** The current selection as flat offsets, or null when not in the editor. */
|
|
703
|
+
selection(): RichTextEditorRange | null;
|
|
704
|
+
/** Place the selection (after the host restyled the document). */
|
|
705
|
+
select(range: RichTextEditorRange): void;
|
|
706
|
+
detach(): void;
|
|
707
|
+
}
|
|
708
|
+
interface EditorStyle {
|
|
709
|
+
marginTop?: string;
|
|
710
|
+
lineHeight?: string;
|
|
711
|
+
fontWeight: string;
|
|
712
|
+
fontStyle: string;
|
|
713
|
+
textDecoration: string;
|
|
714
|
+
textDecorationLine?: string;
|
|
715
|
+
color: string;
|
|
716
|
+
fontSize: string;
|
|
717
|
+
fontFamily: string;
|
|
718
|
+
verticalAlign: string;
|
|
719
|
+
letterSpacing: string;
|
|
720
|
+
textAlign: string;
|
|
721
|
+
direction: string;
|
|
722
|
+
}
|
|
723
|
+
interface EditorNode {
|
|
724
|
+
nodeType: number;
|
|
725
|
+
nodeName: string;
|
|
726
|
+
nodeValue?: string | null;
|
|
727
|
+
childNodes: ArrayLike<EditorNode>;
|
|
728
|
+
parentNode?: EditorNode | null;
|
|
729
|
+
style?: EditorStyle;
|
|
730
|
+
}
|
|
731
|
+
interface EditorElement extends EditorNode {
|
|
732
|
+
style: EditorStyle;
|
|
733
|
+
appendChild(node: EditorNode): unknown;
|
|
734
|
+
}
|
|
735
|
+
interface EditorDocumentFactory {
|
|
736
|
+
createElement(tag: string): EditorElement;
|
|
737
|
+
createTextNode(text: string): EditorNode;
|
|
738
|
+
}
|
|
739
|
+
interface EditorRoot extends EditorNode {
|
|
740
|
+
ownerDocument: EditorDocumentFactory | null;
|
|
741
|
+
appendChild(node: EditorNode): unknown;
|
|
742
|
+
replaceChildren?(...nodes: EditorNode[]): void;
|
|
743
|
+
removeChild?(node: EditorNode): unknown;
|
|
744
|
+
firstChild?: EditorNode | null;
|
|
745
|
+
}
|
|
746
|
+
/** The inline style declarations a span carries, as a style delta. Only what
|
|
747
|
+
* the span itself sets: an unset property means "inherit", never a value. */
|
|
748
|
+
declare function styleDeltaOf(style: EditorStyle | undefined, scale: number): RichTextEditorStyle;
|
|
749
|
+
/** Render a document into the element: one block per paragraph, one span per
|
|
750
|
+
* styled run, `<br>` for a hard break, a placeholder `<br>` at the end of a
|
|
751
|
+
* block that is empty or ends on a break so the caret has a home. */
|
|
752
|
+
declare function renderRichText(root: EditorRoot, doc: RichTextEditorDocument, options: {
|
|
753
|
+
scale: number;
|
|
754
|
+
cssFontFamily: (family: string) => string;
|
|
755
|
+
}): void;
|
|
756
|
+
/** Keep the baseline adjustment on the first block after Enter clones it. */
|
|
757
|
+
declare function applyFirstLineShift(root: EditorNode, shift: number | undefined): void;
|
|
758
|
+
/** The element's content as a document. Inline styles (and the semantic
|
|
759
|
+
* b/i/u/sub/sup tags a browser may insert) only. */
|
|
760
|
+
declare function serializeRichText(root: EditorNode, scale: number): RichTextEditorDocument;
|
|
761
|
+
interface EditorPosition {
|
|
762
|
+
node: EditorNode;
|
|
763
|
+
offset: number;
|
|
764
|
+
}
|
|
765
|
+
/** The flat offset of a DOM position (a node and an offset within it). */
|
|
766
|
+
declare function offsetOfPosition(root: EditorNode, position: EditorPosition): number;
|
|
767
|
+
/** The DOM position of a flat offset: inside a text node when one covers it,
|
|
768
|
+
* else the empty block / the slot after a hard break the offset names. */
|
|
769
|
+
declare function positionOfOffset(root: EditorNode, offset: number): EditorPosition | null;
|
|
770
|
+
/** Bind one contentEditable element. Returns the Svelte-action-shaped handle. */
|
|
771
|
+
declare function attachRichTextEditor(el: HTMLElement, host: RichTextEditorHost, initial: RichTextEditorProps): RichTextEditorBinding;
|
|
772
|
+
//#endregion
|
|
773
|
+
//#region src/web-font.d.ts
|
|
774
|
+
/**
|
|
775
|
+
* Mount a registered font for the DOM: the engine lays text out with the
|
|
776
|
+
* font's bytes, the browser needs the same face as a `@font-face` so the
|
|
777
|
+
* live editor and the vector renderer show the glyphs the appearance stream
|
|
778
|
+
* will bake. The family name is the font's KEY — the CSS family the
|
|
779
|
+
* annotation plugin emits for a registered font (`cssFontFamily`) — so
|
|
780
|
+
* mounting under the key is what makes the two agree.
|
|
781
|
+
*
|
|
782
|
+
* Returns the unmount. Idempotent per (document, key): a second mount of a
|
|
783
|
+
* key already in the document's font set is a no-op that still returns an
|
|
784
|
+
* unmount of its own (the face leaves when the LAST holder unmounts).
|
|
785
|
+
*/
|
|
786
|
+
declare function mountWebFont(key: string, data: ArrayBuffer | Uint8Array, options?: {
|
|
787
|
+
document?: Document;
|
|
788
|
+
weight?: number | string;
|
|
789
|
+
style?: 'normal' | 'italic';
|
|
790
|
+
}): Promise<() => void>;
|
|
791
|
+
//#endregion
|
|
792
|
+
//#region src/web-font-metrics.d.ts
|
|
793
|
+
/**
|
|
794
|
+
* Acrobat's line model, stated in CSS — private to the rich text binding.
|
|
795
|
+
*
|
|
796
|
+
* The engine lays a line out the way Acrobat does: the line box is the
|
|
797
|
+
* face's ascent + descent (its `hhea` metrics) + a constant 0.2 × size of
|
|
798
|
+
* leading, with the baseline at the ascent and the leading entirely below.
|
|
799
|
+
* The standard 14 carry no font program, so the engine uses the metrics of
|
|
800
|
+
* Acrobat's bundled substitutes (Helvetica 0.83/0.17, Times 0.784/0.216,
|
|
801
|
+
* Courier 0.627/0.373); any other face — a registered font, an embedded
|
|
802
|
+
* one — uses its own `hhea` table.
|
|
803
|
+
*
|
|
804
|
+
* Canvas provides browser metrics, which can be rounded or differ from the
|
|
805
|
+
* font program's metrics. They approximate the registered font's line model;
|
|
806
|
+
* standard families use the engine's known values below. CSS still chooses
|
|
807
|
+
* wrapping and combines mixed runs differently from the engine.
|
|
808
|
+
*
|
|
809
|
+
* One thing CSS cannot express: it centres a line's leading (half above the
|
|
810
|
+
* glyphs), and the substitute face's ascent differs from the engine's, so
|
|
811
|
+
* the first baseline can land lower by the half-leading plus that ascent
|
|
812
|
+
* gap. The binding compensates using the body's face and size; mixed runs
|
|
813
|
+
* remain approximate.
|
|
814
|
+
*/
|
|
815
|
+
interface WebFontMetrics {
|
|
816
|
+
/** Ascent above the baseline, per em. */
|
|
817
|
+
ascent: number;
|
|
818
|
+
/** Descent below the baseline, per em. */
|
|
819
|
+
descent: number;
|
|
820
|
+
}
|
|
821
|
+
/** A face's approximate CSS line model. */
|
|
822
|
+
interface LineModel {
|
|
823
|
+
ascent: number;
|
|
824
|
+
descent: number;
|
|
825
|
+
/** Unitless CSS line height: ascent + descent + Acrobat's 0.2 leading. */
|
|
826
|
+
lineHeight: number;
|
|
827
|
+
}
|
|
828
|
+
/**
|
|
829
|
+
* The browser's own ascent and descent for a CSS family list, per em,
|
|
830
|
+
* measured through a canvas. `null` when the platform cannot measure
|
|
831
|
+
* (no canvas, no `fontBoundingBoxAscent`). Reads the currently resolved face
|
|
832
|
+
* on every call, including while the intended font is loading.
|
|
833
|
+
*/
|
|
834
|
+
declare function webFontMetrics(cssFamily: string, doc?: Document | undefined, face?: {
|
|
835
|
+
weight?: number | string;
|
|
836
|
+
style?: string;
|
|
837
|
+
}): WebFontMetrics | null;
|
|
838
|
+
/**
|
|
839
|
+
* The standard families' engine metrics, or a browser approximation for
|
|
840
|
+
* other families. `measure` is injectable for tests and resolved face styles.
|
|
841
|
+
*/
|
|
842
|
+
declare function lineModelFor(cssFamily: string, measure?: (cssFamily: string) => WebFontMetrics | null): LineModel;
|
|
843
|
+
/**
|
|
844
|
+
* Screen px to raise a box's first line by so its baseline matches the
|
|
845
|
+
* engine's: CSS puts half the leading above the glyphs and draws them with
|
|
846
|
+
* the browser's face, whose ascent differs from the engine's for the
|
|
847
|
+
* standard families. `fontSize` in screen px.
|
|
848
|
+
*/
|
|
849
|
+
declare function firstLineShiftFor(cssFamily: string, fontSize: number, measure?: (cssFamily: string) => WebFontMetrics | null): number;
|
|
850
|
+
//#endregion
|
|
851
|
+
export { type ActionsUiAdapterShape, type ActionsUiEffectContext, type ActionsUiOrigin, type AnchorTarget, type AnchoredPlacement, type AnchoredPoint, type AnchoredPosition, type AnchoredRect, type AttachSelectionHandleOptions, type ByteStore, type ClipboardSelectionSource, type DefaultActionsUiAdapterOptions, type EditorDocumentFactory, type EditorElement, type EditorNode, type EditorPosition, type EditorRoot, type EditorStyle, type IndexedDbByteStoreOptions, type LineModel, type ObjectUrlImageSource, type PaintedImageCallbacks, type PickFileOptions, type RichTextEditorAlign, type RichTextEditorBinding, type RichTextEditorCommand, type RichTextEditorDecoration, type RichTextEditorDocument, type RichTextEditorHost, type RichTextEditorParagraph, type RichTextEditorProps, type RichTextEditorRange, type RichTextEditorRun, type RichTextEditorScript, type RichTextEditorStyle, type SelectionClipboardOptions, type SelectionHandleSession, type StageGestureHost, type StageGestureOptions, type StageGestureSink, type StagePointerKind, type StageSurfaceHost, type StageSurfaceHub, type StageSurfaceOptions, type StageSurfaceSample, type StageWheelSample, type SvgCursorOptions, type ViewProjector, type WebFontMetrics, type WebPlatformFeedback, type WheelSample, applyFirstLineShift, attachRichTextEditor, attachSelectionHandle, bindPaintedImage, computeReleaseVelocity, copySelection, createDefaultActionsUiAdapter, createStageGestureController, createStageSurface, firstLineShiftFor, indexedDbByteStore, lineModelFor, mountWebFont, observeClientGeometry, offsetOfPosition, pickFile, pickImageFile, positionAnchoredRect, positionOfOffset, projectAnchoredTarget, renderRichText, sanitizeExternalUri, saveFile, serializeRichText, styleDeltaOf, svgCursor, vibrationFeedback, webFontMetrics, wheelZoomFactor, wireSelectionClipboard, wkFeedback };
|
|
620
852
|
//# sourceMappingURL=index.d.ts.map
|