nuvra 0.4.1 → 0.6.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.
Files changed (62) hide show
  1. package/README.md +241 -19
  2. package/dist/compare.vue.d.ts +19 -0
  3. package/dist/components/document-editor.vue.d.ts +59 -3
  4. package/dist/components/editor-canvas.vue.d.ts +9 -7
  5. package/dist/components/editor-changes.vue.d.ts +18 -0
  6. package/dist/components/editor-collaborators.vue.d.ts +17 -0
  7. package/dist/components/editor-comments.vue.d.ts +32 -0
  8. package/dist/components/editor-footnote-form.vue.d.ts +19 -0
  9. package/dist/components/editor-outline.vue.d.ts +36 -0
  10. package/dist/components/editor-slash-menu.vue.d.ts +13 -0
  11. package/dist/components/editor-toolbar.vue.d.ts +24 -1
  12. package/dist/core/collaboration.d.ts +25 -0
  13. package/dist/core/comments.d.ts +26 -0
  14. package/dist/core/dates.d.ts +8 -0
  15. package/dist/core/diff.d.ts +11 -0
  16. package/dist/core/document-templates.d.ts +22 -0
  17. package/dist/core/docx/export.d.ts +19 -0
  18. package/dist/core/docx/import.d.ts +19 -0
  19. package/dist/core/docx/zip.d.ts +23 -0
  20. package/dist/core/engine/dom.d.ts +40 -3
  21. package/dist/core/engine/editing.d.ts +11 -0
  22. package/dist/core/engine/engine.d.ts +161 -3
  23. package/dist/core/engine/input-rules.d.ts +3 -1
  24. package/dist/core/engine/marks.d.ts +50 -1
  25. package/dist/core/engine/schema.d.ts +9 -2
  26. package/dist/core/export.d.ts +13 -5
  27. package/dist/core/footnotes.d.ts +15 -0
  28. package/dist/core/icons.d.ts +1 -1
  29. package/dist/core/labels.d.ts +6 -2
  30. package/dist/core/locales/uz-cyrl.d.ts +3 -0
  31. package/dist/core/locales/uz.d.ts +72 -1
  32. package/dist/core/numbers.d.ts +19 -0
  33. package/dist/core/outline.d.ts +44 -0
  34. package/dist/core/page.d.ts +12 -2
  35. package/dist/core/pagination.d.ts +25 -3
  36. package/dist/core/pdf.d.ts +43 -0
  37. package/dist/core/signature.d.ts +15 -0
  38. package/dist/core/slash-commands.d.ts +19 -0
  39. package/dist/core/templates.d.ts +32 -0
  40. package/dist/core/transliterate.d.ts +13 -0
  41. package/dist/core/types.d.ts +1 -1
  42. package/dist/core/ui-state.d.ts +8 -0
  43. package/dist/editor.vue.d.ts +6 -2
  44. package/dist/export-B06RXLqn.js +96 -0
  45. package/dist/export-B06RXLqn.js.map +1 -0
  46. package/dist/footnotes-DBShImw7.js +11 -0
  47. package/dist/footnotes-DBShImw7.js.map +1 -0
  48. package/dist/form.vue.d.ts +39 -0
  49. package/dist/index.d.ts +28 -1
  50. package/dist/index.js +8391 -4198
  51. package/dist/index.js.map +1 -1
  52. package/dist/{page-DL7Oj2o8.js → page-DY5fdgcT.js} +10 -10
  53. package/dist/page-DY5fdgcT.js.map +1 -0
  54. package/dist/pdf-mIRjnoOP.js +70 -0
  55. package/dist/pdf-mIRjnoOP.js.map +1 -0
  56. package/dist/style.css +1 -1
  57. package/dist/zip-CpbwZtot.js +46 -0
  58. package/dist/zip-CpbwZtot.js.map +1 -0
  59. package/package.json +5 -2
  60. package/dist/export-VeTfgCEp.js +0 -117
  61. package/dist/export-VeTfgCEp.js.map +0 -1
  62. package/dist/page-DL7Oj2o8.js.map +0 -1
@@ -0,0 +1,13 @@
1
+ import type { DocumentEngine } from '../core/engine/engine';
2
+ import { type SlashCommand } from '../core/slash-commands';
3
+ interface Props {
4
+ /** Engine the commands run on. */
5
+ engine: DocumentEngine;
6
+ /** Every command the menu offers. */
7
+ commands: readonly SlashCommand[];
8
+ /** Element the menu is positioned in; it must be positioned itself. */
9
+ container: HTMLElement;
10
+ }
11
+ declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
12
+ declare const _default: typeof __VLS_export;
13
+ export default _default;
@@ -1,5 +1,6 @@
1
1
  import type { DocumentEngine } from '../core/engine/engine';
2
2
  import { type PageSettings } from '../core/page';
3
+ import type { TemplateVariable } from '../core/templates';
3
4
  import type { DocumentMenuAction } from '../core/types';
4
5
  import { type EditorUiState } from '../core/ui-state';
5
6
  interface Props {
@@ -13,6 +14,16 @@ interface Props {
13
14
  fullscreen: boolean;
14
15
  /** Whether the formatting marks (pilcrows) are shown in the document. */
15
16
  marksVisible: boolean;
17
+ /** Whether the navigation panel with the headings is open. */
18
+ outlineVisible: boolean;
19
+ /** Whether the host keeps comments (`v-model:comments`); the comment buttons are hidden otherwise. */
20
+ commentsEnabled: boolean;
21
+ /** Whether the comments panel is open. */
22
+ commentsVisible: boolean;
23
+ /** Whether edits are recorded as tracked changes. */
24
+ trackChanges: boolean;
25
+ /** Whether the tracked changes panel is open. */
26
+ changesVisible: boolean;
16
27
  /** Current page settings, edited in the page setup popover. */
17
28
  page: PageSettings;
18
29
  /** Whether the ruler is shown above the sheet. */
@@ -23,8 +34,14 @@ interface Props {
23
34
  state: EditorUiState;
24
35
  /** Whether images are being uploaded, shown on the upload button. */
25
36
  uploading: boolean;
37
+ /** Template variables offered by the variable menu; the menu is hidden without any. */
38
+ variables: ReadonlyArray<TemplateVariable>;
26
39
  }
27
- declare const __VLS_export: import("vue").DefineComponent<Props, {
40
+ declare var __VLS_626: {};
41
+ type __VLS_Slots = {} & {
42
+ default?: (props: typeof __VLS_626) => any;
43
+ };
44
+ declare const __VLS_base: import("vue").DefineComponent<Props, {
28
45
  /** Opens the link popover. */
29
46
  openLink: () => void;
30
47
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
@@ -38,5 +55,11 @@ declare const __VLS_export: import("vue").DefineComponent<Props, {
38
55
  onInsertImages?: ((files: File[]) => any) | undefined;
39
56
  "onUpdate:page"?: ((page: PageSettings) => any) | undefined;
40
57
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
58
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
41
59
  declare const _default: typeof __VLS_export;
42
60
  export default _default;
61
+ type __VLS_WithSlots<T, S> = T & {
62
+ new (): {
63
+ $slots: S;
64
+ };
65
+ };
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Hooks for editing a document together. The editor reports where the caret is and draws the carets and selections
3
+ * of other people; sending the document and the selections between them (WebSocket, WebRTC, a CRDT such as Yjs) is
4
+ * left to the application.
5
+ */
6
+ /** A selection as character positions through the document; equal positions are a caret. */
7
+ export interface SelectionOffsets {
8
+ /** Where selecting started. */
9
+ anchor: number;
10
+ /** Where the caret is. */
11
+ focus: number;
12
+ }
13
+ /** Someone else editing the same document. */
14
+ export interface Collaborator {
15
+ /** Stable id of the person or connection. */
16
+ id: string;
17
+ /** Name shown next to the caret. */
18
+ name: string;
19
+ /** CSS colour of the caret and the selection; one is picked from the id when it is left out. */
20
+ color?: string;
21
+ /** Where the person's caret or selection is, or `null` while they are not in the document. */
22
+ selection: SelectionOffsets | null;
23
+ }
24
+ /** The colour of a collaborator: their own, or a stable one derived from the id. */
25
+ export declare const collaboratorColor: (collaborator: Pick<Collaborator, "id" | "color">) => string;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Comments on parts of a document. The document HTML only keeps the anchors, `<span data-comment="id">`; the comments
3
+ * themselves are plain data the host stores next to the document with `v-model:comments`.
4
+ */
5
+ /** A reply in the thread of a comment. */
6
+ export interface DocumentCommentReply {
7
+ /** Unique id of the reply. */
8
+ id: string;
9
+ /** Text of the reply. */
10
+ text: string;
11
+ /** Name of the person who wrote it, when the host knows it. */
12
+ author?: string;
13
+ /** When it was written, as an ISO 8601 string. */
14
+ createdAt: string;
15
+ }
16
+ /** A comment anchored to a span of the document text. */
17
+ export interface DocumentComment extends DocumentCommentReply {
18
+ /** Whether the discussion is closed; resolved comments keep their anchor but are not highlighted. */
19
+ resolved?: boolean;
20
+ /** Replies in the order they were written. */
21
+ replies?: DocumentCommentReply[];
22
+ }
23
+ /** A new random id for a comment or a reply, usable as an HTML attribute value. */
24
+ export declare const createCommentId: () => string;
25
+ /** Comments in the order their anchors appear in the document; comments whose text was deleted come last. */
26
+ export declare const sortComments: (comments: readonly DocumentComment[], anchoredIds: readonly string[]) => DocumentComment[];
@@ -0,0 +1,8 @@
1
+ import type { NumberWordsLocale } from './numbers';
2
+ /** A date as `dd.mm.yyyy`, the short form of Uzbek and Russian documents. */
3
+ export declare const formatShortDate: (date: Date) => string;
4
+ /**
5
+ * A date written out as official documents do: `2026-yil 14-sentabr`, `2026 йил 14 сентябрь`, `14 сентября 2026 г.`
6
+ * or `14 September 2026`.
7
+ */
8
+ export declare const formatLongDate: (date: Date, locale?: NumberWordsLocale) => string;
@@ -0,0 +1,11 @@
1
+ /** What changed between two versions. */
2
+ export interface DocumentComparison {
3
+ /** Display HTML of the new version with insertions and deletions marked. */
4
+ html: string;
5
+ /** Number of inserted words, and of words in inserted blocks. */
6
+ insertions: number;
7
+ /** Number of deleted words, and of words in deleted blocks. */
8
+ deletions: number;
9
+ }
10
+ /** Compares two versions of a document and marks what was inserted and deleted in the new one. */
11
+ export declare const compareDocuments: (before: string, after: string) => DocumentComparison;
@@ -0,0 +1,22 @@
1
+ import type { EditorLabelKey, EditorLocaleCode } from './labels';
2
+ import type { TemplateVariable } from './templates';
3
+ /** Built-in document templates. */
4
+ export type DocumentTemplateId = 'letter' | 'order' | 'application' | 'certificate' | 'act';
5
+ /** A document template ready to be inserted into the editor. */
6
+ export interface DocumentTemplate {
7
+ /** Template identifier. */
8
+ id: DocumentTemplateId;
9
+ /** Document HTML with template variables. */
10
+ html: string;
11
+ /** Variables the template uses, with labels in the requested language. */
12
+ variables: TemplateVariable[];
13
+ }
14
+ /** Every built-in template with its menu label, in the order the menu lists them. */
15
+ export declare const DOCUMENT_TEMPLATES: ReadonlyArray<{
16
+ id: DocumentTemplateId;
17
+ label: EditorLabelKey;
18
+ }>;
19
+ /** Label of a built-in template variable in the editor's language, or `undefined` for other names. */
20
+ export declare const templateVariableLabel: (name: string, locale: EditorLocaleCode) => string | undefined;
21
+ /** A built-in document template in the editor's language, with the variables it uses. */
22
+ export declare const getDocumentTemplate: (id: DocumentTemplateId, locale?: EditorLocaleCode) => DocumentTemplate;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Writes the document as a real Word file (Office Open XML, `.docx`): paragraphs and headings with their alignment,
3
+ * indents and spacing, character formatting, links, lists, tables with merged cells, images, page breaks, the page
4
+ * setup, headers and footers with page fields, and the watermark.
5
+ */
6
+ import { type PageSettings } from '../page';
7
+ /** What the Word writer needs to know about the document. */
8
+ export interface DocxSource {
9
+ /** Clean document HTML as saved by the editor. */
10
+ html: string;
11
+ /** Document title, stored in the file properties and used by the `{title}` token. */
12
+ title: string;
13
+ /** Page size, orientation, margins, running texts and watermark. */
14
+ page: PageSettings;
15
+ }
16
+ /** MIME type of Word documents. */
17
+ export declare const DOCX_MIME = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
18
+ /** Builds a `.docx` file of the document. Images are embedded from data URLs or fetched from their address. */
19
+ export declare const buildDocx: ({ html, title, page }: DocxSource) => Promise<Blob>;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Reads a Word document (`.docx`) into editor HTML: paragraphs and headings with alignment, indents and spacing,
3
+ * character formatting, links, lists, tables with merged cells, images, page breaks, the page setup and the header
4
+ * and footer texts. The result still passes through the editor's sanitiser.
5
+ */
6
+ import { type PageSettings } from '../page';
7
+ /** What was read from a Word document. */
8
+ export interface DocxImport {
9
+ /** Document content as HTML. */
10
+ html: string;
11
+ /** Page setup of the document's last section. */
12
+ page: PageSettings;
13
+ }
14
+ /**
15
+ * Reads a `.docx` file into editor HTML and page settings.
16
+ *
17
+ * @throws Error when the file is not a Word document.
18
+ */
19
+ export declare const readDocx: (data: ArrayBuffer | Uint8Array) => Promise<DocxImport>;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Minimal ZIP container support for Office documents, without dependencies: writing stores files uncompressed, which
3
+ * every ZIP reader (Word included) accepts; reading also inflates deflated entries with the browser's
4
+ * `DecompressionStream`.
5
+ */
6
+ /** A file inside a ZIP archive. */
7
+ export interface ZipEntry {
8
+ /** Path inside the archive, with forward slashes. */
9
+ name: string;
10
+ /** File content. */
11
+ data: Uint8Array;
12
+ }
13
+ /** CRC-32 checksum of the data. */
14
+ export declare const crc32: (data: Uint8Array) => number;
15
+ /** Packs files into an uncompressed ZIP archive. */
16
+ export declare const createZip: (entries: ZipEntry[]) => Uint8Array;
17
+ /**
18
+ * Reads every file of a ZIP archive. Stored and deflated entries are supported, which covers the files Office and
19
+ * other editors write.
20
+ *
21
+ * @throws Error when the data is not a ZIP archive or uses an unsupported compression method.
22
+ */
23
+ export declare const readZip: (buffer: ArrayBuffer | Uint8Array) => Promise<Map<string, Uint8Array>>;
@@ -3,8 +3,25 @@
3
3
  * the editor root, element factories and the small structural fixes (caret placeholders, mark merging) that keep the
4
4
  * editable markup predictable.
5
5
  */
6
- /** Selector for blocks without editable text inside: rules, images and page breaks. */
7
- export declare const ATOM_SELECTOR = "hr, img, div[data-type=\"page-break\"]";
6
+ /** Attribute naming the template variable of a variable chip. */
7
+ export declare const VARIABLE_ATTRIBUTE = "data-variable";
8
+ /** Selector for template variable chips: inline atoms that hold no text in the editor. */
9
+ export declare const VARIABLE_SELECTOR = "span[data-variable]";
10
+ /** Attribute holding the text of a footnote on its reference mark. */
11
+ export declare const FOOTNOTE_ATTRIBUTE = "data-footnote";
12
+ /** Selector for footnote references: inline atoms numbered by the editor, their note text in the attribute. */
13
+ export declare const FOOTNOTE_SELECTOR = "sup[data-footnote]";
14
+ /** Selector for every inline atom: elements inside a line that behave as one character and hold no editable text. */
15
+ export declare const INLINE_ATOM_SELECTOR = "span[data-variable], sup[data-footnote]";
16
+ /** Selector for blocks without editable text inside: rules, images, page breaks and section breaks. */
17
+ export declare const ATOM_SELECTOR = "hr, img, div[data-type=\"page-break\"], div[data-type=\"section-break\"]";
18
+ /** Whether a `<div>` is one of the break blocks the document model keeps: a page break or a section break. */
19
+ export declare const isBreakBlock: (node: Node | null | undefined) => boolean;
20
+ /**
21
+ * Creates a section break: the sheets after it are turned to `orientation`. It also starts a new sheet, so it is drawn
22
+ * and printed like a page break.
23
+ */
24
+ export declare const createSectionBreak: (orientation: "portrait" | "landscape") => HTMLDivElement;
8
25
  /** Selector for blocks that hold editable inline text. */
9
26
  export declare const TEXT_BLOCK_SELECTOR = "p, h1, h2, h3, h4, h5, h6, pre";
10
27
  /** Marks the extra `<br>` that keeps an empty or break-terminated line visible; it is never serialised. */
@@ -17,6 +34,12 @@ export declare const isText: (node: Node | null | undefined) => node is Text;
17
34
  export declare const isTextBlock: (node: Node | null | undefined) => node is HTMLElement;
18
35
  /** Whether the node is an ordered or unordered list. */
19
36
  export declare const isList: (node: Node | null | undefined) => node is HTMLElement;
37
+ /** Whether the node is a template variable chip. */
38
+ export declare const isVariable: (node: Node | null | undefined) => node is HTMLElement;
39
+ /** Whether the node is a footnote reference. */
40
+ export declare const isFootnote: (node: Node | null | undefined) => node is HTMLElement;
41
+ /** Whether the node is an inline atom: a variable chip or a footnote reference. */
42
+ export declare const isInlineAtom: (node: Node | null | undefined) => node is HTMLElement;
20
43
  /** Whether the node is a block without editable text (rule, image, page break). */
21
44
  export declare const isAtom: (node: Node | null | undefined) => node is HTMLElement;
22
45
  /** Whether the node is a `<br>`, placeholder or real. */
@@ -31,13 +54,25 @@ export declare const closestTag: (node: Node | null | undefined, root: HTMLEleme
31
54
  export declare const closestTextBlock: (node: Node | null | undefined, root: HTMLElement) => HTMLElement | null;
32
55
  /** Creates an element with attributes and children in one call. */
33
56
  export declare const createElement: <K extends keyof HTMLElementTagNameMap>(tag: K, attributes?: Record<string, string>, children?: Array<Node | string>) => HTMLElementTagNameMap[K];
57
+ /**
58
+ * Creates the chip of a template variable. It holds no text, so formatting and caret positions treat it as one
59
+ * character; its label is drawn by CSS from `data-label`, and serialising writes `{{name}}` into it.
60
+ */
61
+ export declare const createVariable: (name: string) => HTMLSpanElement;
62
+ /** Longest footnote text kept, in characters. */
63
+ export declare const MAX_FOOTNOTE_LENGTH = 2000;
64
+ /**
65
+ * Creates a footnote reference. Like a variable chip it holds no text in the editor: CSS draws its number, and
66
+ * serialising writes the number into it so saved HTML reads correctly anywhere.
67
+ */
68
+ export declare const createFootnote: (text: string) => HTMLElement;
34
69
  /** Creates the placeholder `<br>` that gives empty lines their height. */
35
70
  export declare const createTrailingBreak: () => HTMLBRElement;
36
71
  /** Creates a paragraph with the given inline content and the placeholder break it needs. */
37
72
  export declare const createParagraph: (children?: Node[]) => HTMLParagraphElement;
38
73
  /** Whether the element contains text, an image or a real line break. */
39
74
  export declare const hasVisibleContent: (element: Element) => boolean;
40
- /** Whether a text block has no text and no image, holding at most one break. */
75
+ /** Whether a text block has no text, image or inline atom, holding at most one break. */
41
76
  export declare const isEmptyTextBlock: (block: Element) => boolean;
42
77
  /**
43
78
  * Keeps exactly one placeholder `<br>` where the browser needs it: in empty blocks and after a user line break at the
@@ -56,6 +91,8 @@ export declare const mergeAdjacentMarks: (scope: HTMLElement) => void;
56
91
  export declare const textBlocksWithin: (scope: ParentNode) => HTMLElement[];
57
92
  /** Text blocks touched by the range, in document order. */
58
93
  export declare const textBlocksInRange: (root: HTMLElement, range: Range) => HTMLElement[];
94
+ /** Whether a range covers no text, image, variable or real line break. */
95
+ export declare const isVisuallyEmpty: (range: Range) => boolean;
59
96
  /** Whether nothing visible precedes the point inside its block. */
60
97
  export declare const isAtBlockStart: (block: HTMLElement, container: Node, offset: number) => boolean;
61
98
  /** Whether nothing visible follows the point inside its block. */
@@ -32,6 +32,17 @@ export declare const splitAtCaret: (root: HTMLElement, range: Range) => Caret |
32
32
  export declare const insertLineBreak: (root: HTMLElement, range: Range) => Caret | null;
33
33
  /** Inserts plain text at a collapsed range, creating a paragraph if the caret sits between blocks. */
34
34
  export declare const insertTextAtCaret: (root: HTMLElement, range: Range, text: string) => Caret;
35
+ /**
36
+ * Inserts an inline atom (a variable chip or a footnote reference) at a collapsed range, creating a paragraph if the caret sits between
37
+ * blocks. Code blocks hold plain text only, so nothing is inserted there.
38
+ * @returns the caret right after the element, or `null` when it could not be inserted.
39
+ */
40
+ export declare const insertInlineAtCaret: (root: HTMLElement, range: Range, element: HTMLElement) => Caret | null;
41
+ /**
42
+ * Inline atom (variable chip or footnote reference) right before (`backward`) or right after the collapsed caret, with
43
+ * nothing visible in between, so Backspace and Delete remove it as one character in every browser.
44
+ */
45
+ export declare const adjacentInlineAtom: (root: HTMLElement, range: Range, backward: boolean) => HTMLElement | null;
35
46
  /**
36
47
  * Pastes sanitised blocks at a collapsed range. A single paragraph flows into the current line; several blocks
37
48
  * split the current block, with the first and last pasted paragraphs merging into its halves as in Word.
@@ -1,10 +1,26 @@
1
+ import { type OutlineHeading } from '../outline';
2
+ import { type TransliterationDirection } from '../transliterate';
1
3
  import { type EditorUiState } from '../ui-state';
2
4
  import { type HeadingTag, type ParagraphIndents, type SpacingSide, type TextAlign, type TextDirection } from './blocks';
3
5
  import { EditorHistory } from './history';
4
6
  import { type ListKind } from './lists';
5
7
  import { type MarkName, type StyleName, type TextCase } from './marks';
6
8
  import { SearchController, type SearchState } from './search';
9
+ import { type TextBookmark } from './selection';
7
10
  import { type TableCell } from './tables';
11
+ /** A tracked insertion or deletion; the parts of one edit are joined. */
12
+ export interface TrackedChange {
13
+ /** Id shared by the parts of the edit. */
14
+ id: string;
15
+ /** Whether text was inserted or deleted. */
16
+ type: 'insert' | 'delete';
17
+ /** Name of the author; may be empty. */
18
+ author: string;
19
+ /** When the change was made, as an ISO 8601 string. */
20
+ time: string;
21
+ /** Inserted or deleted text. */
22
+ text: string;
23
+ }
8
24
  /** Settings the host component passes when it creates the engine. */
9
25
  interface DocumentEngineOptions {
10
26
  /** Initial HTML; it is sanitised before it reaches the DOM. */
@@ -17,6 +33,11 @@ interface DocumentEngineOptions {
17
33
  placeholder: () => string;
18
34
  /** Receives image files pasted or dropped into the document; the selection is already at the target. */
19
35
  onImageFiles: (files: File[]) => void;
36
+ /**
37
+ * Label a template variable chip shows, or `undefined` for a name the host does not know. Called on every refresh,
38
+ * so labels follow the host's variable list and locale; typed `{{name}}` becomes a chip only for known names.
39
+ */
40
+ variableLabel?: (name: string) => string | undefined;
20
41
  }
21
42
  /** Events emitted by the engine, mapped to their payloads. */
22
43
  interface EngineEvents {
@@ -100,6 +121,10 @@ export declare class DocumentEngine {
100
121
  private selectedImageElement;
101
122
  /** Formatting the format painter carries until it is painted onto a selection. */
102
123
  private painterFormat;
124
+ /** Author of tracked changes while changes are tracked, otherwise `null`. */
125
+ private trackingAuthor;
126
+ /** Change the running typing group adds to, so typed characters form one insertion. */
127
+ private typingChange;
103
128
  /**
104
129
  * Takes over `root` as the editable document, loads the initial content and starts listening to its events.
105
130
  *
@@ -138,10 +163,23 @@ export declare class DocumentEngine {
138
163
  * @param options.addToHistory Record the replacement as an undo step instead of clearing the history.
139
164
  * @param options.emitUpdate Emit `update` so the host saves the new content.
140
165
  */
141
- setContent(html: string, { addToHistory, emitUpdate }?: {
166
+ setContent(html: string, { addToHistory, emitUpdate, keepSelection }?: {
142
167
  addToHistory?: boolean | undefined;
143
168
  emitUpdate?: boolean | undefined;
169
+ keepSelection?: boolean | undefined;
144
170
  }): void;
171
+ /**
172
+ * The selection as character positions through the document: `anchor` where selecting started, `focus` where the
173
+ * caret is. Positions survive changes to the markup, so they can be sent to other people editing the document.
174
+ */
175
+ getSelectionOffsets(): TextBookmark | null;
176
+ /**
177
+ * Viewport rectangles of the text between two character positions, for drawing someone else's selection; a
178
+ * collapsed position gives the rectangle of its caret line with no width.
179
+ */
180
+ getOffsetRects(offsets: TextBookmark): DOMRect[];
181
+ /** Number of character positions in the document, the largest offset a selection can have. */
182
+ private characterPositions;
145
183
  /** Switches between editing and read-only mode. */
146
184
  setEditable(editable: boolean): void;
147
185
  /** Word and character counts of the document text. */
@@ -173,7 +211,7 @@ export declare class DocumentEngine {
173
211
  private currentRange;
174
212
  /** Captures the document markup and selection for the undo history. */
175
213
  private snapshot;
176
- /** Updates the placeholder state and search results, then notifies listeners. */
214
+ /** Updates the placeholder state, variable labels and search results, then notifies listeners. */
177
215
  private refresh;
178
216
  /**
179
217
  * Runs one edit as an undo step, then normalises the document and restores the selection by text position.
@@ -187,12 +225,38 @@ export declare class DocumentEngine {
187
225
  private finishEdit;
188
226
  /** Records an undo step for a change that does not depend on the selection (checkboxes, image attributes). */
189
227
  private mutate;
190
- /** Deletes the selected content, if any, and returns a collapsed range where it started. */
228
+ /**
229
+ * Deletes the selected content, if any, and returns a collapsed range where the new content goes: where the selection
230
+ * started, or after the text marked as deleted while changes are tracked.
231
+ */
191
232
  private collapsedAfterDelete;
192
233
  /** Deletes the selection as one undo step and leaves a collapsed caret where it started. */
193
234
  private deleteSelection;
235
+ /** Whether edits are recorded as tracked changes. */
236
+ get tracksChanges(): boolean;
237
+ /** Starts or stops recording typing, deleting and pasting as tracked changes by `author`. */
238
+ setTrackChanges(enabled: boolean, author?: string): void;
239
+ /** A change mark for the next edit; typing keeps adding to one change until the caret moves. */
240
+ private nextChange;
241
+ /**
242
+ * Marks a range as deleted and returns a caret at its start or after it. A marker element keeps the end position
243
+ * while own insertions inside the range are removed for real.
244
+ */
245
+ private deleteTracked;
246
+ /** Moves a caret that sits inside deleted text to its end, so new text never becomes part of a deletion. */
247
+ private outsideDeletion;
248
+ /** Marks the text between two document positions as inserted by the tracking author. */
249
+ private markInsertedBetween;
250
+ /** Tracked insertions and deletions in document order, the parts of one edit grouped by id and kind. */
251
+ getChanges(): TrackedChange[];
252
+ /** Accepts (`true`) or rejects the tracked changes with the given id, or every change without one, as an undo step. */
253
+ resolveChanges(accept: boolean, id?: string): void;
254
+ /** Selects the text of a tracked change and scrolls it into view. */
255
+ selectChange(id: string): void;
194
256
  /** Number of characters in the document text. */
195
257
  private characterCount;
258
+ /** Text of every block as the document reads once its tracked changes are accepted: deleted text is left out. */
259
+ private blockTexts;
196
260
  /** Whether adding `extra` characters would exceed the configured maximum length. */
197
261
  private exceedsLimit;
198
262
  /** Remembers the selection; a selection moved by the user drops pending formatting and ends the typing group. */
@@ -206,6 +270,13 @@ export declare class DocumentEngine {
206
270
  private handleTextInput;
207
271
  /** Deletes selections and joins blocks at their edges itself; single characters are deleted natively. */
208
272
  private handleDeleteInput;
273
+ /**
274
+ * Marks the character, word or line next to the caret as deleted. Text that is already marked as deleted is
275
+ * stepped over, as in Word, instead of being deleted again.
276
+ */
277
+ private deleteTrackedAtCaret;
278
+ /** The range from a caret to the next character, word or line boundary in one direction. */
279
+ private extendCaret;
209
280
  /** Repairs the structure after a native edit and applies Markdown and typography rules to typed text. */
210
281
  private onInput;
211
282
  /** Browsers occasionally leave text outside paragraphs or a <div> after native edits; fix it in place. */
@@ -260,6 +331,13 @@ export declare class DocumentEngine {
260
331
  private restoreSnapshot;
261
332
  /** Inserts plain text at the selection, replacing selected content and applying pending formatting. */
262
333
  insertText(text: string): void;
334
+ /** Text of the current block before a collapsed caret, or `null` when the selection is not a caret in text. */
335
+ getTextBeforeCaret(): string | null;
336
+ /**
337
+ * Deletes the characters right before a collapsed caret, as one undo step; used by typed triggers such as the
338
+ * `/` command menu to remove what was typed.
339
+ */
340
+ deleteBeforeCaret(count: number): void;
263
341
  /** Formatting at the start of a range, or `null` when the text there is unformatted. */
264
342
  private captureFormat;
265
343
  /**
@@ -277,6 +355,15 @@ export declare class DocumentEngine {
277
355
  private setPending;
278
356
  /** Changes the letter case of the selected text. */
279
357
  changeTextCase(mode: TextCase): void;
358
+ /** Converts Uzbek text between the Latin and Cyrillic alphabet: the selection, or the whole document at a caret. */
359
+ transliterate(direction: TransliterationDirection): void;
360
+ /**
361
+ * Rewrites the amount that is selected, or the number right before the caret, with `format`; used to add an amount
362
+ * in words. Nothing changes when the text there is not an amount.
363
+ *
364
+ * @returns whether an amount was found and rewritten.
365
+ */
366
+ replaceAmount(format: (value: number) => string): boolean;
280
367
  /** Stores the format the painter carries and shows the painting cursor while it does. */
281
368
  private setPainterFormat;
282
369
  /**
@@ -308,6 +395,11 @@ export declare class DocumentEngine {
308
395
  setTextDirection(direction: TextDirection): void;
309
396
  /** Turns the selected blocks into a list of the given kind, converts another list kind, or lifts them out. */
310
397
  toggleList(kind: ListKind): void;
398
+ /**
399
+ * Switches the numbered list at the selection, together with its nested lists, between simple (1, 2, 3) and legal
400
+ * (1.1, 1.2) numbering. The setting lives on the outermost numbered list.
401
+ */
402
+ setListNumbering(style: 'default' | 'legal'): void;
311
403
  /** List items are nested or lifted; other paragraphs get indentation steps. */
312
404
  indent(direction: 1 | -1): void;
313
405
  /**
@@ -317,8 +409,74 @@ export declare class DocumentEngine {
317
409
  private insertBlock;
318
410
  /** Inserts a horizontal rule. */
319
411
  insertHorizontalRule(): void;
412
+ /** Inserts a section break: the sheets after it are turned to `orientation`, for example for a wide table. */
413
+ insertSectionBreak(orientation: 'portrait' | 'landscape'): void;
320
414
  /** Inserts a manual page break. */
321
415
  insertPageBreak(): void;
416
+ /**
417
+ * Inserts sanitised HTML at the selection as one undo step. By default it flows into the current line the way pasting
418
+ * does; with `asBlocks` the content starts on a line of its own after a non-empty paragraph, as prepared fragments
419
+ * such as signature blocks and document templates should.
420
+ */
421
+ insertContent(html: string, { asBlocks }?: {
422
+ asBlocks?: boolean | undefined;
423
+ }): void;
424
+ /** Headings written directly in the document, in document order, down to the given level. */
425
+ getOutline(depth?: number): OutlineHeading[];
426
+ /** Whether the document has a table of contents. */
427
+ get hasTableOfContents(): boolean;
428
+ /**
429
+ * Writes a table of contents: an existing one is replaced in place, keeping the selection, otherwise the table is
430
+ * inserted at the selection. Without `addToHistory` a replacement joins the previous undo step, e.g. when page
431
+ * numbers are corrected right after inserting the table.
432
+ */
433
+ setTableOfContents(html: string, { addToHistory }?: {
434
+ addToHistory?: boolean | undefined;
435
+ }): void;
436
+ /** Scrolls a heading to the top of the view and puts the caret at its start. */
437
+ goToHeading(heading: HTMLElement): void;
438
+ /**
439
+ * Inserts a footnote reference with its text at the selection, replacing selected content, as one undo step.
440
+ * @returns the new reference, or `null` when nothing could be inserted (for example in a code block).
441
+ */
442
+ insertFootnote(text: string): HTMLElement | null;
443
+ /** Changes the text of a footnote as one undo step; unchanged text records nothing. */
444
+ setFootnoteText(reference: HTMLElement, text: string): void;
445
+ /** Removes a footnote reference together with its note, as one undo step. */
446
+ removeFootnote(reference: HTMLElement): void;
447
+ /** Footnote references with their texts, in document order; the first one is number 1. */
448
+ getFootnotes(): Array<{
449
+ element: HTMLElement;
450
+ text: string;
451
+ }>;
452
+ /**
453
+ * Anchors a new comment to the selected text as one undo step.
454
+ * @returns whether text was selected and the id is valid.
455
+ */
456
+ addComment(id: string): boolean;
457
+ /** Removes the anchors of a comment, keeping their text, as one undo step. */
458
+ removeComment(id: string): void;
459
+ /** Ids of the comments anchored in the document, each once, in document order. */
460
+ getCommentIds(): string[];
461
+ /** Ids of the comments anchored around the caret or the start of the selection, innermost first. */
462
+ getCommentsAtSelection(): string[];
463
+ /** Selects the text of a comment and scrolls it into view. */
464
+ selectComment(id: string): void;
465
+ /**
466
+ * Shows resolved comments without their highlight and marks the active one. Only classes change, which saved HTML
467
+ * drops, so this is neither an edit nor an undo step.
468
+ */
469
+ decorateComments(resolved: ReadonlySet<string>, active: string | null): void;
470
+ /** Anchor elements of one comment, in document order. */
471
+ private commentAnchors;
472
+ /** Inserts the chip of a template variable at the selection; invalid names are ignored. */
473
+ insertVariable(name: string): void;
474
+ /** Names of the template variables used in the document, each once, in document order. */
475
+ getVariables(): string[];
476
+ /** Re-reads the labels of every variable chip, e.g. after the host's variable list or locale changed. */
477
+ refreshVariables(): void;
478
+ /** Writes the host's label into every chip that shows a different one; a chip of an unknown name shows `{{name}}`. */
479
+ private updateVariableLabels;
322
480
  /** Link that contains the start of the selection. */
323
481
  getActiveLink(): HTMLAnchorElement | null;
324
482
  /**
@@ -12,6 +12,8 @@ type InputRule = () => InputRuleResult;
12
12
  /**
13
13
  * Looks for a rule completed by the character that was just typed. The returned function performs the change,
14
14
  * so the caller can record an undo step first. Rules never apply inside code.
15
+ *
16
+ * @param isKnownVariable Whether a typed `{{name}}` names a template variable of the editor.
15
17
  */
16
- export declare const matchInputRule: (root: HTMLElement, range: Range, typed: string) => InputRule | null;
18
+ export declare const matchInputRule: (root: HTMLElement, range: Range, typed: string, isKnownVariable?: (name: string) => boolean) => InputRule | null;
17
19
  export {};