@fileverse-dev/ddoc 7.1.4 → 7.1.6-pages.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/dist/headless-editor-utils.es.js +1 -1
- package/dist/{index-CVNy0PTp.mjs → index-BAKPQr5N.mjs} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.es.js +6953 -6612
- package/dist/package/components/editor-utils.d.ts +1 -0
- package/dist/package/components/page-sheets.d.ts +20 -0
- package/dist/package/extensions/code-block/components/code-block-node-view.d.ts +1 -1
- package/dist/package/extensions/code-block/gutter-spacers.d.ts +4 -0
- package/dist/package/extensions/code-block/render-mermaid-html.d.ts +3 -1
- package/dist/package/extensions/d-block/dblock-collapse.d.ts +1 -0
- package/dist/package/extensions/page-break/page-break.d.ts +7 -0
- package/dist/package/extensions/pagination/collect-leaves.d.ts +19 -0
- package/dist/package/extensions/pagination/index.d.ts +18 -0
- package/dist/package/extensions/pagination/line-split.d.ts +19 -0
- package/dist/package/extensions/pagination/meta.d.ts +15 -0
- package/dist/package/extensions/pagination/page-grid.d.ts +28 -0
- package/dist/package/extensions/pagination/page-store.d.ts +14 -0
- package/dist/package/extensions/pagination/pagination-view.d.ts +71 -0
- package/dist/package/extensions/pagination/place.d.ts +69 -0
- package/dist/package/extensions/pagination/print-break-node.d.ts +9 -0
- package/dist/package/extensions/pagination/print.d.ts +29 -0
- package/dist/package/extensions/pagination/scheduler.d.ts +47 -0
- package/dist/package/extensions/pagination/spacers.d.ts +9 -0
- package/dist/package/extensions/resizable-media/media-ratio.d.ts +3 -0
- package/dist/package/extensions/resizable-media/use-media-ratio.d.ts +4 -0
- package/dist/package/hooks/use-export-headless-editor-content.d.ts +3 -0
- package/dist/package/hooks/use-pagination-sync.d.ts +15 -0
- package/dist/package/hooks/use-tab-editor.d.ts +8 -0
- package/dist/package/types.d.ts +13 -0
- package/dist/package/utils/handle-print.d.ts +11 -1
- package/dist/package/utils/zoom.d.ts +3 -1
- package/dist/style.css +1 -1
- package/dist/{use-headless-editor-rSxRep1e.mjs → use-headless-editor-TswbjzW2.mjs} +11325 -9644
- package/package.json +1 -1
|
@@ -38,6 +38,7 @@ export declare const IMG_UPLOAD_SETTINGS: {
|
|
|
38
38
|
errorMsg: string;
|
|
39
39
|
};
|
|
40
40
|
};
|
|
41
|
+
export declare function shortcutAction(event: Pick<KeyboardEvent, 'key' | 'metaKey' | 'ctrlKey' | 'altKey' | 'shiftKey'>, isMac: boolean): 'pageBreak' | 'link' | null;
|
|
41
42
|
/**
|
|
42
43
|
* `Editor#setOptions({ editorProps })` replaces the whole `editorProps`
|
|
43
44
|
* object rather than merging it — tiptap merges top-level options but
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { Editor } from '@tiptap/react';
|
|
3
|
+
import { PageGrid } from '../extensions/pagination/page-grid';
|
|
4
|
+
import { PageStart } from '../extensions/pagination/place';
|
|
5
|
+
|
|
6
|
+
export declare function visibleSheetRange(a: {
|
|
7
|
+
scrollTop: number;
|
|
8
|
+
viewportHeight: number;
|
|
9
|
+
originTop: number;
|
|
10
|
+
scale: number;
|
|
11
|
+
cycle: number;
|
|
12
|
+
pageCount: number;
|
|
13
|
+
}): [first: number, last: number];
|
|
14
|
+
export declare function maskBoundaries(first: number, last: number, pageStarts: PageStart[]): number[];
|
|
15
|
+
export declare function PageSheets({ editor, grid, canvasStyle, deskStyle, }: {
|
|
16
|
+
editor: Editor | null;
|
|
17
|
+
grid: PageGrid;
|
|
18
|
+
canvasStyle?: React.CSSProperties;
|
|
19
|
+
deskStyle?: React.CSSProperties;
|
|
20
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { NodeViewProps } from '@tiptap/react';
|
|
2
2
|
|
|
3
|
-
export default function CodeBlockNodeView({ node, updateAttributes, editor, deleteNode, }: NodeViewProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export default function CodeBlockNodeView({ node, updateAttributes, editor, deleteNode, innerDecorations, }: NodeViewProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export declare const MERMAID_SVG_TAGS: string[];
|
|
2
2
|
export declare const MERMAID_SVG_ATTRS: string[];
|
|
3
|
-
export declare function renderMermaidBlocks(html: string
|
|
3
|
+
export declare function renderMermaidBlocks(html: string, options?: {
|
|
4
|
+
skip?: (pre: HTMLElement) => boolean;
|
|
5
|
+
}): Promise<string>;
|
|
@@ -22,6 +22,7 @@ export interface DBlockRenderMeta {
|
|
|
22
22
|
interface DBlockCollapsePluginState {
|
|
23
23
|
decorations: DecorationSet;
|
|
24
24
|
structureSignature: string;
|
|
25
|
+
expandAll: boolean;
|
|
25
26
|
}
|
|
26
27
|
export declare const getDBlockRenderMeta: (node: ProseMirrorNode, pos: number) => DBlockRenderMeta;
|
|
27
28
|
export declare const getHeadingLinkSlug: (node: ProseMirrorNode, pos: number) => string | null;
|
|
@@ -10,6 +10,13 @@ declare module '@tiptap/core' {
|
|
|
10
10
|
* Add a page break
|
|
11
11
|
*/
|
|
12
12
|
setPageBreak: () => ReturnType;
|
|
13
|
+
/**
|
|
14
|
+
* Page break for the keyboard shortcut: at the caret in a top-level
|
|
15
|
+
* paragraph or heading, otherwise after the enclosing top-level block
|
|
16
|
+
* (or the selected block). False in a code block or with nothing to
|
|
17
|
+
* anchor to (AllSelection, top-level gap cursor)
|
|
18
|
+
*/
|
|
19
|
+
insertPageBreakAtCaret: () => ReturnType;
|
|
13
20
|
/**
|
|
14
21
|
* Remove a page break
|
|
15
22
|
*/
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { EditorView } from '@tiptap/pm/view';
|
|
2
|
+
import { Leaf } from './place';
|
|
3
|
+
|
|
4
|
+
export declare const SPACER_CLASS = "ddoc-page-spacer";
|
|
5
|
+
export declare function collapsedMargin(a: number, b: number): number;
|
|
6
|
+
export declare function spacerDisplacement(s: {
|
|
7
|
+
height: number;
|
|
8
|
+
marginAbove: number;
|
|
9
|
+
marginBelow: number;
|
|
10
|
+
}): number;
|
|
11
|
+
export type BoxEdge = {
|
|
12
|
+
top: number;
|
|
13
|
+
marginTop: number;
|
|
14
|
+
blocksCollapse: boolean;
|
|
15
|
+
};
|
|
16
|
+
export declare function leadingOffset(chain: BoxEdge[]): number;
|
|
17
|
+
export declare const effectiveTopMargin: (el: HTMLElement) => number;
|
|
18
|
+
export declare const effectiveBottomMargin: (el: HTMLElement) => number;
|
|
19
|
+
export declare function collectLeaves(view: EditorView, textHeight: number): Leaf[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Extension } from '@tiptap/core';
|
|
2
|
+
import { PAGINATION_META, paginationPluginKey, PaginationMeta } from './meta';
|
|
3
|
+
import { PaginationOptions, PaginationStorage } from './pagination-view';
|
|
4
|
+
|
|
5
|
+
export { PAGINATION_META, paginationPluginKey };
|
|
6
|
+
export type { PaginationMeta, PaginationOptions, PaginationStorage };
|
|
7
|
+
export type { PassInfo } from './pagination-view';
|
|
8
|
+
declare module '@tiptap/core' {
|
|
9
|
+
interface Commands<ReturnType> {
|
|
10
|
+
pagination: {
|
|
11
|
+
setPagination: (options: PaginationOptions) => ReturnType;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
interface Storage {
|
|
15
|
+
pagination: PaginationStorage;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export declare const Pagination: Extension<Record<string, never>, PaginationStorage>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { EditorView } from '@tiptap/pm/view';
|
|
2
|
+
import { Line } from './place';
|
|
3
|
+
|
|
4
|
+
export type Rect = {
|
|
5
|
+
top: number;
|
|
6
|
+
bottom: number;
|
|
7
|
+
left: number;
|
|
8
|
+
right: number;
|
|
9
|
+
};
|
|
10
|
+
export declare function groupLineRects(rects: Rect[], scale: number): Rect[];
|
|
11
|
+
export declare function measureLines(view: EditorView, el: HTMLElement, args: {
|
|
12
|
+
from: number;
|
|
13
|
+
to: number;
|
|
14
|
+
originTop: number;
|
|
15
|
+
bottom: number;
|
|
16
|
+
scale: number;
|
|
17
|
+
range: Range;
|
|
18
|
+
shiftAt?: (top: number) => number;
|
|
19
|
+
}): Line[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PluginKey, Transaction } from '@tiptap/pm/state';
|
|
2
|
+
import { Mapping } from '@tiptap/pm/transform';
|
|
3
|
+
import { DecorationSet, EditorView } from '@tiptap/pm/view';
|
|
4
|
+
import { Spacer } from './place';
|
|
5
|
+
|
|
6
|
+
export declare const PAGINATION_META = "ddocPagination";
|
|
7
|
+
export declare const paginationPluginKey: PluginKey<DecorationSet>;
|
|
8
|
+
export type PaginationMeta = {
|
|
9
|
+
enabled: boolean;
|
|
10
|
+
} | {
|
|
11
|
+
spacers: Spacer[];
|
|
12
|
+
};
|
|
13
|
+
export declare const refuses: (tr: Transaction) => boolean;
|
|
14
|
+
export declare const dispatchMeta: (view: EditorView, meta: PaginationMeta) => void;
|
|
15
|
+
export declare function spacerMapping(tr: Transaction): Mapping;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { PageSetup } from '../../types';
|
|
2
|
+
|
|
3
|
+
export declare const PAGE_MARGIN = 96;
|
|
4
|
+
export declare const PAGE_GAP = 16;
|
|
5
|
+
export declare const PRINT_BOTTOM_SLACK = 20;
|
|
6
|
+
export type Orientation = 'portrait' | 'landscape';
|
|
7
|
+
export declare const getPaperPx: (paper: PageSetup["paper"], orientation?: Orientation) => {
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
};
|
|
11
|
+
export declare const getPagesBaseWidth: (pageSetup: PageSetup, orientation?: Orientation) => number;
|
|
12
|
+
export declare class PageGrid {
|
|
13
|
+
readonly width: number;
|
|
14
|
+
readonly height: number;
|
|
15
|
+
readonly textWidth: number;
|
|
16
|
+
readonly textHeight: number;
|
|
17
|
+
constructor(paper: PageSetup['paper'], orientation?: Orientation);
|
|
18
|
+
private get cycle();
|
|
19
|
+
pageAt(y: number): number;
|
|
20
|
+
contentTopOf(page: number): number;
|
|
21
|
+
contentBottomOf(page: number): number;
|
|
22
|
+
}
|
|
23
|
+
export declare const isPagesActive: ({ pageSetup, isWideEnough, isSplitViewActive, isVersionHistory, }: {
|
|
24
|
+
pageSetup?: PageSetup;
|
|
25
|
+
isWideEnough: boolean;
|
|
26
|
+
isSplitViewActive: boolean;
|
|
27
|
+
isVersionHistory: boolean;
|
|
28
|
+
}) => boolean;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PageStart, Placement } from './place';
|
|
2
|
+
|
|
3
|
+
export type PageState = {
|
|
4
|
+
enabled: boolean;
|
|
5
|
+
pageCount: number | null;
|
|
6
|
+
pageStarts: PageStart[];
|
|
7
|
+
placement: Placement | null;
|
|
8
|
+
};
|
|
9
|
+
export declare const DISABLED_PAGE_STATE: PageState;
|
|
10
|
+
export declare function createPageStore(): {
|
|
11
|
+
get: () => PageState;
|
|
12
|
+
set(next: Partial<PageState>): void;
|
|
13
|
+
subscribe(cb: () => void): () => void;
|
|
14
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { EditorState, Transaction } from '@tiptap/pm/state';
|
|
2
|
+
import { DecorationSet, EditorView } from '@tiptap/pm/view';
|
|
3
|
+
import { PageSetup } from '../../types';
|
|
4
|
+
import { Orientation } from './page-grid';
|
|
5
|
+
import { createPageStore } from './page-store';
|
|
6
|
+
import { Placement } from './place';
|
|
7
|
+
|
|
8
|
+
export type PaginationOptions = {
|
|
9
|
+
pageSetup?: PageSetup;
|
|
10
|
+
orientation?: Orientation;
|
|
11
|
+
zoom?: number;
|
|
12
|
+
enabled: boolean;
|
|
13
|
+
running: boolean;
|
|
14
|
+
};
|
|
15
|
+
export type PaginationStorage = {
|
|
16
|
+
pageSetup?: PageSetup;
|
|
17
|
+
orientation?: Orientation;
|
|
18
|
+
zoom?: number;
|
|
19
|
+
enabled: boolean;
|
|
20
|
+
running: boolean;
|
|
21
|
+
failed: boolean;
|
|
22
|
+
onError?: (error: unknown) => void;
|
|
23
|
+
store: ReturnType<typeof createPageStore>;
|
|
24
|
+
flush(): Placement | null;
|
|
25
|
+
lastPass: PassInfo | null;
|
|
26
|
+
isIdle(): boolean;
|
|
27
|
+
};
|
|
28
|
+
export type PassInfo = {
|
|
29
|
+
count: number;
|
|
30
|
+
timings: {
|
|
31
|
+
collect: number;
|
|
32
|
+
place: number;
|
|
33
|
+
emit: number;
|
|
34
|
+
};
|
|
35
|
+
dispatched: boolean;
|
|
36
|
+
dispatches: number;
|
|
37
|
+
};
|
|
38
|
+
export declare const controllers: WeakMap<PaginationStorage, PaginationView>;
|
|
39
|
+
export declare class PaginationView {
|
|
40
|
+
private view;
|
|
41
|
+
private storage;
|
|
42
|
+
private scheduler;
|
|
43
|
+
private observer;
|
|
44
|
+
private heights;
|
|
45
|
+
private guard;
|
|
46
|
+
private force;
|
|
47
|
+
private edits;
|
|
48
|
+
private spacersBefore;
|
|
49
|
+
private lastBottom;
|
|
50
|
+
private passCount;
|
|
51
|
+
private dispatchCount;
|
|
52
|
+
constructor(view: EditorView, storage: PaginationStorage);
|
|
53
|
+
sync(): void;
|
|
54
|
+
noteEdit(tr: Transaction, before: DecorationSet): void;
|
|
55
|
+
update(view: EditorView, prev: EditorState): void;
|
|
56
|
+
flush(): void;
|
|
57
|
+
isIdle(): boolean;
|
|
58
|
+
destroy(): void;
|
|
59
|
+
private start;
|
|
60
|
+
private stop;
|
|
61
|
+
private trigger;
|
|
62
|
+
private onFonts;
|
|
63
|
+
private onCompositionEnd;
|
|
64
|
+
private onResize;
|
|
65
|
+
private caretOverflows;
|
|
66
|
+
private observeChildren;
|
|
67
|
+
private run;
|
|
68
|
+
private pass;
|
|
69
|
+
private record;
|
|
70
|
+
private fail;
|
|
71
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { PageGrid } from './page-grid';
|
|
2
|
+
|
|
3
|
+
export type Line = {
|
|
4
|
+
top: number;
|
|
5
|
+
bottom: number;
|
|
6
|
+
startPos: number;
|
|
7
|
+
};
|
|
8
|
+
export type Cell = {
|
|
9
|
+
lines: Line[];
|
|
10
|
+
bottom: number;
|
|
11
|
+
atoms?: {
|
|
12
|
+
top: number;
|
|
13
|
+
bottom: number;
|
|
14
|
+
}[];
|
|
15
|
+
};
|
|
16
|
+
export type Leaf = {
|
|
17
|
+
kind: 'text';
|
|
18
|
+
pos: number;
|
|
19
|
+
top: number;
|
|
20
|
+
bottom: number;
|
|
21
|
+
marginTop: number;
|
|
22
|
+
spacerPos: number;
|
|
23
|
+
spacerCollapse: number;
|
|
24
|
+
isHeading: boolean;
|
|
25
|
+
lines: Line[];
|
|
26
|
+
} | {
|
|
27
|
+
kind: 'atomic';
|
|
28
|
+
pos: number;
|
|
29
|
+
top: number;
|
|
30
|
+
bottom: number;
|
|
31
|
+
marginTop: number;
|
|
32
|
+
spacerPos: number;
|
|
33
|
+
spacerCollapse: number;
|
|
34
|
+
row?: {
|
|
35
|
+
tableId: number;
|
|
36
|
+
isHeader: boolean;
|
|
37
|
+
headerHeight: number;
|
|
38
|
+
};
|
|
39
|
+
cells?: Cell[];
|
|
40
|
+
} | {
|
|
41
|
+
kind: 'forced';
|
|
42
|
+
pos: number;
|
|
43
|
+
};
|
|
44
|
+
export type PrintBreak = {
|
|
45
|
+
kind: 'before';
|
|
46
|
+
pos: number;
|
|
47
|
+
} | {
|
|
48
|
+
kind: 'inText';
|
|
49
|
+
pos: number;
|
|
50
|
+
};
|
|
51
|
+
export type PageStart = {
|
|
52
|
+
kind: 'before' | 'inText' | 'continued';
|
|
53
|
+
pos: number;
|
|
54
|
+
};
|
|
55
|
+
export type Spacer = {
|
|
56
|
+
kind: 'block' | 'inText';
|
|
57
|
+
pos: number;
|
|
58
|
+
height: number;
|
|
59
|
+
page: number;
|
|
60
|
+
print: boolean;
|
|
61
|
+
header?: number;
|
|
62
|
+
};
|
|
63
|
+
export type Placement = {
|
|
64
|
+
breaks: PrintBreak[];
|
|
65
|
+
pageStarts: PageStart[];
|
|
66
|
+
pageCount: number;
|
|
67
|
+
spacers: Spacer[];
|
|
68
|
+
};
|
|
69
|
+
export declare function place(leaves: Leaf[], grid: PageGrid): Placement;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Node as PMNode, Schema } from '@tiptap/pm/model';
|
|
2
|
+
import { PageStart, PrintBreak } from './place';
|
|
3
|
+
|
|
4
|
+
export declare const buildPrintSchema: (live: Schema) => Schema;
|
|
5
|
+
export declare const REPEAT_HEADER = "data-print-repeat-header";
|
|
6
|
+
export declare const serializeWithBreaks: (liveDoc: PMNode, printSchema: Schema, breaks: PrintBreak[], pageStarts: PageStart[], blockAttrs?: {
|
|
7
|
+
pos: number;
|
|
8
|
+
attrs: Record<string, string>;
|
|
9
|
+
}[]) => string;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/core';
|
|
2
|
+
import { EditorView } from '@tiptap/pm/view';
|
|
3
|
+
import { DdocProps, PageSetup } from '../../types';
|
|
4
|
+
import { ContentPrintOptions } from '../../utils/handle-print';
|
|
5
|
+
import { PageGrid } from './page-grid';
|
|
6
|
+
import { Placement } from './place';
|
|
7
|
+
|
|
8
|
+
export type PagesPrintBreaks = Placement & {
|
|
9
|
+
pageFirstText: string[];
|
|
10
|
+
};
|
|
11
|
+
export declare function getPrintBreaks(view: EditorView, grid: PageGrid): PagesPrintBreaks;
|
|
12
|
+
export declare function resolvePrintPlacement(editor: Editor, isPagesActive: boolean): Placement | undefined;
|
|
13
|
+
export declare function buildPrintHtml(args: {
|
|
14
|
+
editor: Editor;
|
|
15
|
+
pageSetup?: PageSetup;
|
|
16
|
+
orientation?: 'portrait' | 'landscape';
|
|
17
|
+
isPagesActive: boolean;
|
|
18
|
+
ipfsImageFetchFn?: DdocProps['ipfsImageFetchFn'];
|
|
19
|
+
fetchV1ImageFn?: DdocProps['fetchV1ImageFn'];
|
|
20
|
+
debugMarkers?: boolean;
|
|
21
|
+
placement?: Placement;
|
|
22
|
+
}): Promise<{
|
|
23
|
+
html: string;
|
|
24
|
+
options: ContentPrintOptions;
|
|
25
|
+
}>;
|
|
26
|
+
export type PrintInputs = Omit<Parameters<typeof buildPrintHtml>[0], 'editor' | 'placement'>;
|
|
27
|
+
export declare function setPrintInputs(editor: Editor, get: (() => PrintInputs) | null): void;
|
|
28
|
+
export declare function getPrintInputs(editor: Editor): PrintInputs | undefined;
|
|
29
|
+
export declare function printPagesTab(editor: Editor): Promise<boolean>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Transaction } from '@tiptap/pm/state';
|
|
2
|
+
import { ResolvedPos } from '@tiptap/pm/model';
|
|
3
|
+
import { Placement, Spacer } from './place';
|
|
4
|
+
|
|
5
|
+
export declare const MAX_WAIT_MS = 1000;
|
|
6
|
+
export declare const SETTLE_CAP = 4;
|
|
7
|
+
export declare function createSettleGuard(cap?: number): {
|
|
8
|
+
next(signature: string): "continue" | "stop";
|
|
9
|
+
repeats(signature: string): boolean;
|
|
10
|
+
reset(): void;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* True when every step is an inline edit inside one and the same textblock
|
|
14
|
+
* that holds no inText spacer, is not a repeated table header and is not in
|
|
15
|
+
* a row or columns block split inside its cells. Spacer
|
|
16
|
+
* positions refer to the doc before `trs`.
|
|
17
|
+
* Transactions without steps are ignored; no doc changes at all returns true.
|
|
18
|
+
*/
|
|
19
|
+
export declare function editStaysInOneTextblock(trs: readonly Transaction[], spacers: Spacer[]): boolean;
|
|
20
|
+
type Deps = {
|
|
21
|
+
run(): void;
|
|
22
|
+
isComposing(): boolean;
|
|
23
|
+
raf?: (cb: () => void) => number;
|
|
24
|
+
cancelRaf?: (id: number) => void;
|
|
25
|
+
};
|
|
26
|
+
export declare class PassScheduler {
|
|
27
|
+
private deps;
|
|
28
|
+
private timer;
|
|
29
|
+
private frame;
|
|
30
|
+
private deferred;
|
|
31
|
+
private deadline;
|
|
32
|
+
private destroyed;
|
|
33
|
+
private raf;
|
|
34
|
+
private cancelRaf;
|
|
35
|
+
constructor(deps: Deps);
|
|
36
|
+
onEdit(_trs: readonly Transaction[]): void;
|
|
37
|
+
now(): void;
|
|
38
|
+
isPending(): boolean;
|
|
39
|
+
flush(): void;
|
|
40
|
+
compositionEnd(): void;
|
|
41
|
+
destroy(): void;
|
|
42
|
+
private fire;
|
|
43
|
+
private clearTimer;
|
|
44
|
+
private clearFrame;
|
|
45
|
+
}
|
|
46
|
+
export declare function caretInTallLeaf($head: ResolvedPos, placement: Placement | null): boolean;
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Node as PMNode } from '@tiptap/pm/model';
|
|
2
|
+
import { DecorationSet } from '@tiptap/pm/view';
|
|
3
|
+
import { Spacer } from './place';
|
|
4
|
+
|
|
5
|
+
export declare function spacerKey(s: Spacer): string;
|
|
6
|
+
export declare function inTextSpacerHeight(key: unknown): number | null;
|
|
7
|
+
export declare function rowSpacerHeader(key: unknown): number;
|
|
8
|
+
export declare function buildSpacerDecorations(doc: PMNode, spacers: Spacer[]): DecorationSet;
|
|
9
|
+
export declare function spacersMatch(current: DecorationSet, next: Spacer[], doc: PMNode): boolean;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Editor, JSONContent } from '@tiptap/react';
|
|
2
2
|
import { DdocExportModalProps } from '../components/export-modal';
|
|
3
|
+
import { PageSetup } from '../types';
|
|
3
4
|
import { UseHeadlessEditorProps } from './use-headless-editor';
|
|
4
5
|
|
|
5
6
|
import * as Y from 'yjs';
|
|
@@ -8,6 +9,8 @@ export interface HeadlessEditorExportOption {
|
|
|
8
9
|
content: string;
|
|
9
10
|
fileName?: string;
|
|
10
11
|
initialFormat?: HeadlessEditorExportFormat;
|
|
12
|
+
pageSetup?: PageSetup;
|
|
13
|
+
orientation?: 'portrait' | 'landscape';
|
|
11
14
|
}
|
|
12
15
|
export declare const useExportHeadlessEditorContent: (props?: UseHeadlessEditorProps & {
|
|
13
16
|
onExportError?: (error: unknown) => void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/react';
|
|
2
|
+
import { PageSetup } from '../types';
|
|
3
|
+
import { Orientation } from '../extensions/pagination/page-grid';
|
|
4
|
+
import { PrintInputs } from '../extensions/pagination/print';
|
|
5
|
+
|
|
6
|
+
type Inputs = {
|
|
7
|
+
pageSetup?: PageSetup;
|
|
8
|
+
orientation?: Orientation;
|
|
9
|
+
zoom: number;
|
|
10
|
+
isPagesMode: boolean;
|
|
11
|
+
onPagesError?: (error: unknown) => void;
|
|
12
|
+
printInputs: () => PrintInputs;
|
|
13
|
+
};
|
|
14
|
+
export declare function usePaginationSync(editor: Editor | null, { pageSetup, orientation, zoom, isPagesMode, onPagesError, printInputs, }: Inputs): void;
|
|
15
|
+
export {};
|
|
@@ -8,6 +8,14 @@ import { EditorWidthStore } from '../utils/editor-width-store';
|
|
|
8
8
|
import { CollabConnectionConfig, CollaborationProps } from '../sync-local/types';
|
|
9
9
|
|
|
10
10
|
import * as Y from 'yjs';
|
|
11
|
+
/** The Pages layout's page count, or null when Pages is off or has no pass. */
|
|
12
|
+
export declare function getExactPageCount(editor: Editor): number | null;
|
|
13
|
+
/**
|
|
14
|
+
* Reports the layout's page count whenever it changes; calls onInexact when
|
|
15
|
+
* the exact count goes away (Pages off, or a failed pass).
|
|
16
|
+
*/
|
|
17
|
+
export declare function subscribePagesCount(editor: Editor, onCount: (pages: number) => void, onInexact: () => void): () => void;
|
|
18
|
+
export declare const printTab: (editor: Editor, isPresentationMode: boolean | undefined, slides: string[]) => void | Promise<void>;
|
|
11
19
|
export declare const TAB_EDITOR_ATTRIBUTES: Record<string, string>;
|
|
12
20
|
interface UseTabEditorArgs {
|
|
13
21
|
ydoc: Y.Doc;
|
package/dist/package/types.d.ts
CHANGED
|
@@ -114,6 +114,13 @@ export interface DocumentStyling {
|
|
|
114
114
|
* @example "portrait" | "landscape"
|
|
115
115
|
*/
|
|
116
116
|
orientation?: 'portrait' | 'landscape';
|
|
117
|
+
/**
|
|
118
|
+
* Page setup
|
|
119
|
+
* @description Pages shows the document as paper sheets that print page for
|
|
120
|
+
* page; Pageless is one continuous canvas. Absent means Pageless.
|
|
121
|
+
* @example { mode: "pages", paper: "a4" }
|
|
122
|
+
*/
|
|
123
|
+
pageSetup?: PageSetup;
|
|
117
124
|
/**
|
|
118
125
|
* Custom CSS
|
|
119
126
|
* @description The author's escape hatch for styling the document beyond the
|
|
@@ -126,6 +133,10 @@ export interface DocumentStyling {
|
|
|
126
133
|
*/
|
|
127
134
|
customCSS?: string;
|
|
128
135
|
}
|
|
136
|
+
export type PageSetup = {
|
|
137
|
+
mode: 'pages' | 'pageless';
|
|
138
|
+
paper: 'a4' | 'letter';
|
|
139
|
+
};
|
|
129
140
|
export type DdocStats = {
|
|
130
141
|
words: number;
|
|
131
142
|
characters: number;
|
|
@@ -281,6 +292,8 @@ export interface DdocProps extends CommentAccountProps {
|
|
|
281
292
|
*/
|
|
282
293
|
enableFanficTemplate?: boolean;
|
|
283
294
|
onError?: (error: string) => void;
|
|
295
|
+
/** Pages mode pagination failed; the editor renders as one column. */
|
|
296
|
+
onPagesError?: (error: unknown) => void;
|
|
284
297
|
/** Active-tab stats. Fires with all four fields whenever one changes. */
|
|
285
298
|
onStatsChange?: (stats: DdocStats) => void;
|
|
286
299
|
/** @deprecated Use onStatsChange. */
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { PageSetup } from '../types';
|
|
2
|
+
|
|
1
3
|
interface PageCounter {
|
|
2
4
|
getPageCount: (content: string) => Promise<number>;
|
|
3
5
|
destroy: () => void;
|
|
@@ -5,5 +7,13 @@ interface PageCounter {
|
|
|
5
7
|
export declare const splitContentIntoPrintSections: (content: string) => string[];
|
|
6
8
|
export declare const createPageCounter: () => PageCounter;
|
|
7
9
|
export declare const handlePrint: (slides: string[]) => void;
|
|
8
|
-
export
|
|
10
|
+
export type ContentPrintOptions = {
|
|
11
|
+
pageSetup?: PageSetup;
|
|
12
|
+
orientation?: 'portrait' | 'landscape';
|
|
13
|
+
rootStyle?: Partial<Record<'fontFamily' | 'fontSize' | 'lineHeight' | 'letterSpacing' | 'wordSpacing', string>>;
|
|
14
|
+
};
|
|
15
|
+
export declare const mountContentPrintHost: (content: string, options?: ContentPrintOptions) => {
|
|
16
|
+
cleanup: () => void;
|
|
17
|
+
};
|
|
18
|
+
export declare const handleContentPrint: (content: string, options?: ContentPrintOptions) => void;
|
|
9
19
|
export {};
|
|
@@ -3,6 +3,7 @@ export declare const ZOOM_PRESET_SCALES: readonly number[];
|
|
|
3
3
|
export declare const FIT_MIN_SCALE = 0.5;
|
|
4
4
|
export declare const FIT_MAX_SCALE = 2;
|
|
5
5
|
export declare const FIT_GUTTER = 24;
|
|
6
|
+
export declare const PAGE_NUMBER_GUTTER = 24;
|
|
6
7
|
export declare const COMMENT_COLUMN_WIDTH: number;
|
|
7
8
|
export declare const normalizeZoomLevel: (value: string | undefined | null) => ZoomLevel;
|
|
8
9
|
export declare const resolveZoomScale: (level: ZoomLevel, fitScale: number) => number;
|
|
@@ -21,8 +22,9 @@ export declare const canChangeZoom: (value: string | undefined, onChange: unknow
|
|
|
21
22
|
export declare const FIT_RAIL_WIDTH = 181;
|
|
22
23
|
export declare const FIT_LANDSCAPE_RAIL_WIDTH = 182;
|
|
23
24
|
export declare const LANDSCAPE_ROW_MARGIN = 24;
|
|
24
|
-
export declare const getFitReservedWidth: ({ hasLeftRail, isCommentColumnVisible, isLandscape, }: {
|
|
25
|
+
export declare const getFitReservedWidth: ({ hasLeftRail, isCommentColumnVisible, isLandscape, isPagesMode, }: {
|
|
25
26
|
hasLeftRail: boolean;
|
|
26
27
|
isCommentColumnVisible: boolean;
|
|
27
28
|
isLandscape?: boolean;
|
|
29
|
+
isPagesMode?: boolean;
|
|
28
30
|
}) => number;
|