@yurikilian/lex4 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/__tests__/setup.d.ts +1 -0
- package/dist/__tests__/setup.d.ts.map +1 -0
- package/dist/components/DocumentView.d.ts +10 -0
- package/dist/components/DocumentView.d.ts.map +1 -0
- package/dist/components/EditorSidebar.d.ts +12 -0
- package/dist/components/EditorSidebar.d.ts.map +1 -0
- package/dist/components/HeaderFooterActions.d.ts +16 -0
- package/dist/components/HeaderFooterActions.d.ts.map +1 -0
- package/dist/components/HeaderFooterToggle.d.ts +8 -0
- package/dist/components/HeaderFooterToggle.d.ts.map +1 -0
- package/dist/components/HistorySidebar.d.ts +3 -0
- package/dist/components/HistorySidebar.d.ts.map +1 -0
- package/dist/components/Lex4Editor.d.ts +10 -0
- package/dist/components/Lex4Editor.d.ts.map +1 -0
- package/dist/components/PageBody.d.ts +26 -0
- package/dist/components/PageBody.d.ts.map +1 -0
- package/dist/components/PageFooter.d.ts +18 -0
- package/dist/components/PageFooter.d.ts.map +1 -0
- package/dist/components/PageHeader.d.ts +18 -0
- package/dist/components/PageHeader.d.ts.map +1 -0
- package/dist/components/PageView.d.ts +21 -0
- package/dist/components/PageView.d.ts.map +1 -0
- package/dist/components/Toolbar.d.ts +3 -0
- package/dist/components/Toolbar.d.ts.map +1 -0
- package/dist/components/index.d.ts +12 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/constants/dimensions.d.ts +25 -0
- package/dist/constants/dimensions.d.ts.map +1 -0
- package/dist/constants/index.d.ts +3 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/constants/page-layout.d.ts +11 -0
- package/dist/constants/page-layout.d.ts.map +1 -0
- package/dist/context/document-context.d.ts +108 -0
- package/dist/context/document-context.d.ts.map +1 -0
- package/dist/context/document-provider.d.ts +10 -0
- package/dist/context/document-provider.d.ts.map +1 -0
- package/dist/context/document-reducer.d.ts +8 -0
- package/dist/context/document-reducer.d.ts.map +1 -0
- package/dist/context/index.d.ts +5 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/engine/index.d.ts +7 -0
- package/dist/engine/index.d.ts.map +1 -0
- package/dist/engine/measure.d.ts +15 -0
- package/dist/engine/measure.d.ts.map +1 -0
- package/dist/engine/overflow.d.ts +28 -0
- package/dist/engine/overflow.d.ts.map +1 -0
- package/dist/engine/paginate.d.ts +12 -0
- package/dist/engine/paginate.d.ts.map +1 -0
- package/dist/engine/reflow.d.ts +22 -0
- package/dist/engine/reflow.d.ts.map +1 -0
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/use-header-footer.d.ts +10 -0
- package/dist/hooks/use-header-footer.d.ts.map +1 -0
- package/dist/hooks/use-overflow-detection.d.ts +11 -0
- package/dist/hooks/use-overflow-detection.d.ts.map +1 -0
- package/dist/hooks/use-pagination.d.ts +22 -0
- package/dist/hooks/use-pagination.d.ts.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/lex4-editor.cjs +3774 -0
- package/dist/lex4-editor.cjs.map +1 -0
- package/dist/lex4-editor.js +3774 -0
- package/dist/lex4-editor.js.map +1 -0
- package/dist/lexical/commands/format-commands.d.ts +14 -0
- package/dist/lexical/commands/format-commands.d.ts.map +1 -0
- package/dist/lexical/commands/index.d.ts +4 -0
- package/dist/lexical/commands/index.d.ts.map +1 -0
- package/dist/lexical/commands/list-commands.d.ts +25 -0
- package/dist/lexical/commands/list-commands.d.ts.map +1 -0
- package/dist/lexical/editor-setup.d.ts +10 -0
- package/dist/lexical/editor-setup.d.ts.map +1 -0
- package/dist/lexical/index.d.ts +8 -0
- package/dist/lexical/index.d.ts.map +1 -0
- package/dist/lexical/plugins/active-editor-plugin.d.ts +16 -0
- package/dist/lexical/plugins/active-editor-plugin.d.ts.map +1 -0
- package/dist/lexical/plugins/font-plugin.d.ts +19 -0
- package/dist/lexical/plugins/font-plugin.d.ts.map +1 -0
- package/dist/lexical/plugins/height-limit-plugin.d.ts +15 -0
- package/dist/lexical/plugins/height-limit-plugin.d.ts.map +1 -0
- package/dist/lexical/plugins/history-capture-plugin.d.ts +8 -0
- package/dist/lexical/plugins/history-capture-plugin.d.ts.map +1 -0
- package/dist/lexical/plugins/index.d.ts +9 -0
- package/dist/lexical/plugins/index.d.ts.map +1 -0
- package/dist/lexical/plugins/overflow-plugin.d.ts +22 -0
- package/dist/lexical/plugins/overflow-plugin.d.ts.map +1 -0
- package/dist/lexical/plugins/page-boundary-plugin.d.ts +9 -0
- package/dist/lexical/plugins/page-boundary-plugin.d.ts.map +1 -0
- package/dist/lexical/plugins/paragraph-indent-plugin.d.ts +7 -0
- package/dist/lexical/plugins/paragraph-indent-plugin.d.ts.map +1 -0
- package/dist/lexical/plugins/paste-plugin.d.ts +9 -0
- package/dist/lexical/plugins/paste-plugin.d.ts.map +1 -0
- package/dist/lexical/plugins/tab-indent-plugin.d.ts +9 -0
- package/dist/lexical/plugins/tab-indent-plugin.d.ts.map +1 -0
- package/dist/lexical/theme.d.ts +7 -0
- package/dist/lexical/theme.d.ts.map +1 -0
- package/dist/style.css +1065 -0
- package/dist/types/document.d.ts +40 -0
- package/dist/types/document.d.ts.map +1 -0
- package/dist/types/editor-props.d.ts +19 -0
- package/dist/types/editor-props.d.ts.map +1 -0
- package/dist/types/history.d.ts +43 -0
- package/dist/types/history.d.ts.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/page.d.ts +26 -0
- package/dist/types/page.d.ts.map +1 -0
- package/dist/utils/debug.d.ts +41 -0
- package/dist/utils/debug.d.ts.map +1 -0
- package/dist/utils/editor-state-utils.d.ts +48 -0
- package/dist/utils/editor-state-utils.d.ts.map +1 -0
- package/dist/utils/history-manager.d.ts +26 -0
- package/dist/utils/history-manager.d.ts.map +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/package.json +80 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { SerializedEditorState } from 'lexical';
|
|
2
|
+
export type PageCounterMode = 'none' | 'header' | 'footer' | 'both';
|
|
3
|
+
export interface PageChromeTemplate {
|
|
4
|
+
headerState: SerializedEditorState | null;
|
|
5
|
+
footerState: SerializedEditorState | null;
|
|
6
|
+
headerHeight: number;
|
|
7
|
+
footerHeight: number;
|
|
8
|
+
}
|
|
9
|
+
/** State for a single page in the document */
|
|
10
|
+
export interface PageState {
|
|
11
|
+
id: string;
|
|
12
|
+
bodyState: SerializedEditorState | null;
|
|
13
|
+
headerState: SerializedEditorState | null;
|
|
14
|
+
footerState: SerializedEditorState | null;
|
|
15
|
+
headerHeight: number;
|
|
16
|
+
footerHeight: number;
|
|
17
|
+
/** Incremented on external body state changes (reflow/undo) to force editor remount */
|
|
18
|
+
bodySyncVersion: number;
|
|
19
|
+
/** Incremented on external header state changes (copy/clear) to force editor remount */
|
|
20
|
+
headerSyncVersion: number;
|
|
21
|
+
/** Incremented on external footer state changes (copy/clear) to force editor remount */
|
|
22
|
+
footerSyncVersion: number;
|
|
23
|
+
}
|
|
24
|
+
/** Top-level document state */
|
|
25
|
+
export interface Lex4Document {
|
|
26
|
+
pages: PageState[];
|
|
27
|
+
headerFooterEnabled: boolean;
|
|
28
|
+
pageCounterMode: PageCounterMode;
|
|
29
|
+
defaultHeaderState: SerializedEditorState | null;
|
|
30
|
+
defaultFooterState: SerializedEditorState | null;
|
|
31
|
+
defaultHeaderHeight: number;
|
|
32
|
+
defaultFooterHeight: number;
|
|
33
|
+
}
|
|
34
|
+
/** Creates a default empty page */
|
|
35
|
+
export declare function createEmptyPage(id?: string): PageState;
|
|
36
|
+
/** Creates a new page that inherits header/footer chrome from a document default template. */
|
|
37
|
+
export declare function createPageFromTemplate(template?: PageChromeTemplate): PageState;
|
|
38
|
+
/** Creates a default empty document */
|
|
39
|
+
export declare function createEmptyDocument(): Lex4Document;
|
|
40
|
+
//# sourceMappingURL=document.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../src/types/document.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAErD,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEpE,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,qBAAqB,GAAG,IAAI,CAAC;IAC1C,WAAW,EAAE,qBAAqB,GAAG,IAAI,CAAC;IAC1C,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,8CAA8C;AAC9C,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,qBAAqB,GAAG,IAAI,CAAC;IACxC,WAAW,EAAE,qBAAqB,GAAG,IAAI,CAAC;IAC1C,WAAW,EAAE,qBAAqB,GAAG,IAAI,CAAC;IAC1C,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,uFAAuF;IACvF,eAAe,EAAE,MAAM,CAAC;IACxB,wFAAwF;IACxF,iBAAiB,EAAE,MAAM,CAAC;IAC1B,wFAAwF;IACxF,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,+BAA+B;AAC/B,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,eAAe,EAAE,eAAe,CAAC;IACjC,kBAAkB,EAAE,qBAAqB,GAAG,IAAI,CAAC;IACjD,kBAAkB,EAAE,qBAAqB,GAAG,IAAI,CAAC;IACjD,mBAAmB,EAAE,MAAM,CAAC;IAC5B,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAED,mCAAmC;AACnC,wBAAgB,eAAe,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAYtD;AAED,8FAA8F;AAC9F,wBAAgB,sBAAsB,CAAC,QAAQ,CAAC,EAAE,kBAAkB,GAAG,SAAS,CAQ/E;AAED,uCAAuC;AACvC,wBAAgB,mBAAmB,IAAI,YAAY,CAUlD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Lex4Document } from './document';
|
|
2
|
+
/** Public props for the Lex4Editor component */
|
|
3
|
+
export interface Lex4EditorProps {
|
|
4
|
+
/** Initial document state. Defaults to a single empty page. */
|
|
5
|
+
initialDocument?: Lex4Document;
|
|
6
|
+
/** Called whenever the document state changes */
|
|
7
|
+
onDocumentChange?: (doc: Lex4Document) => void;
|
|
8
|
+
/** Initial header/footer toggle state. Defaults to false. */
|
|
9
|
+
headerFooterEnabled?: boolean;
|
|
10
|
+
/** Called when the header/footer toggle changes */
|
|
11
|
+
onHeaderFooterToggle?: (enabled: boolean) => void;
|
|
12
|
+
/** Whether the editor is read-only */
|
|
13
|
+
readOnly?: boolean;
|
|
14
|
+
/** Capture undo/redo shortcuts at the window level, even when focus is outside the document. Defaults to true. */
|
|
15
|
+
captureHistoryShortcutsOnWindow?: boolean;
|
|
16
|
+
/** Additional CSS class for the editor root element */
|
|
17
|
+
className?: string;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=editor-props.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-props.d.ts","sourceRoot":"","sources":["../../src/types/editor-props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,gDAAgD;AAChD,MAAM,WAAW,eAAe;IAC9B,+DAA+D;IAC/D,eAAe,CAAC,EAAE,YAAY,CAAC;IAE/B,iDAAiD;IACjD,gBAAgB,CAAC,EAAE,CAAC,GAAG,EAAE,YAAY,KAAK,IAAI,CAAC;IAE/C,6DAA6D;IAC7D,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B,mDAAmD;IACnD,oBAAoB,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAElD,sCAAsC;IACtC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,kHAAkH;IAClH,+BAA+B,CAAC,EAAE,OAAO,CAAC;IAE1C,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Lex4Document } from './document';
|
|
2
|
+
export type HistorySource = 'body' | 'header' | 'footer' | 'toolbar' | 'document' | 'overflow' | 'history';
|
|
3
|
+
export type HistoryRegion = 'document' | 'body' | 'header' | 'footer';
|
|
4
|
+
export interface CaretPosition {
|
|
5
|
+
pageId: string;
|
|
6
|
+
region: Exclude<HistoryRegion, 'document'>;
|
|
7
|
+
}
|
|
8
|
+
export interface CaretSelectionPoint {
|
|
9
|
+
key: string;
|
|
10
|
+
offset: number;
|
|
11
|
+
type: 'text' | 'element';
|
|
12
|
+
}
|
|
13
|
+
export interface CaretSelection {
|
|
14
|
+
anchor: CaretSelectionPoint;
|
|
15
|
+
focus: CaretSelectionPoint;
|
|
16
|
+
anchorTextOffset: number;
|
|
17
|
+
focusTextOffset: number;
|
|
18
|
+
format: number;
|
|
19
|
+
style: string;
|
|
20
|
+
}
|
|
21
|
+
export interface HistoryActionDescriptor {
|
|
22
|
+
label: string;
|
|
23
|
+
source: HistorySource;
|
|
24
|
+
pageId?: string;
|
|
25
|
+
region?: HistoryRegion;
|
|
26
|
+
}
|
|
27
|
+
export interface HistoryEntry extends HistoryActionDescriptor {
|
|
28
|
+
id: string;
|
|
29
|
+
snapshot: Lex4Document;
|
|
30
|
+
undoSnapshot: Lex4Document;
|
|
31
|
+
timestamp: string;
|
|
32
|
+
caretPosition: CaretPosition | null;
|
|
33
|
+
caretSelection: CaretSelection | null;
|
|
34
|
+
undoCaretPosition: CaretPosition | null;
|
|
35
|
+
undoCaretSelection: CaretSelection | null;
|
|
36
|
+
}
|
|
37
|
+
export interface HistoryState {
|
|
38
|
+
baseSnapshot: Lex4Document;
|
|
39
|
+
baseCaretPosition: CaretPosition | null;
|
|
40
|
+
entries: HistoryEntry[];
|
|
41
|
+
cursor: number;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/types/history.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,MAAM,MAAM,aAAa,GACrB,MAAM,GACN,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,UAAU,GACV,UAAU,GACV,SAAS,CAAC;AAEd,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEtE,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC;CAC5C;AAED,MAAM,WAAW,mBAAmB;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,mBAAmB,CAAC;IAC5B,KAAK,EAAE,mBAAmB,CAAC;IAC3B,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,aAAa,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB;AAED,MAAM,WAAW,YAAa,SAAQ,uBAAuB;IAC3D,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,YAAY,CAAC;IACvB,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,aAAa,GAAG,IAAI,CAAC;IACpC,cAAc,EAAE,cAAc,GAAG,IAAI,CAAC;IACtC,iBAAiB,EAAE,aAAa,GAAG,IAAI,CAAC;IACxC,kBAAkB,EAAE,cAAc,GAAG,IAAI,CAAC;CAC3C;AAED,MAAM,WAAW,YAAY;IAC3B,YAAY,EAAE,YAAY,CAAC;IAC3B,iBAAiB,EAAE,aAAa,GAAG,IAAI,CAAC;IACxC,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;CAChB"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type { Lex4Document, PageCounterMode, PageState } from './document';
|
|
2
|
+
export { createEmptyPage, createEmptyDocument } from './document';
|
|
3
|
+
export type { Lex4EditorProps } from './editor-props';
|
|
4
|
+
export type { PageDimensions, PageLayout, BlockMeasurement, PageAssignment, } from './page';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAClE,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,YAAY,EACV,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,cAAc,GACf,MAAM,QAAQ,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Page layout computation types */
|
|
2
|
+
export interface PageDimensions {
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
marginTop: number;
|
|
6
|
+
marginBottom: number;
|
|
7
|
+
marginLeft: number;
|
|
8
|
+
marginRight: number;
|
|
9
|
+
}
|
|
10
|
+
export interface PageLayout {
|
|
11
|
+
headerHeight: number;
|
|
12
|
+
footerHeight: number;
|
|
13
|
+
bodyHeight: number;
|
|
14
|
+
contentWidth: number;
|
|
15
|
+
}
|
|
16
|
+
export interface BlockMeasurement {
|
|
17
|
+
nodeKey: string;
|
|
18
|
+
height: number;
|
|
19
|
+
type: string;
|
|
20
|
+
}
|
|
21
|
+
export interface PageAssignment {
|
|
22
|
+
pageIndex: number;
|
|
23
|
+
blockKeys: string[];
|
|
24
|
+
totalHeight: number;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=page.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../src/types/page.ts"],"names":[],"mappings":"AAAA,oCAAoC;AAEpC,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lex4 Debug Logger
|
|
3
|
+
*
|
|
4
|
+
* Zero-cost when disabled. Enable in the browser console:
|
|
5
|
+
*
|
|
6
|
+
* localStorage.setItem('lex4:debug', '*') // all channels
|
|
7
|
+
* localStorage.setItem('lex4:debug', 'overflow,reducer') // specific channels
|
|
8
|
+
* window.__LEX4_DEBUG__ = true // all channels (session only)
|
|
9
|
+
*
|
|
10
|
+
* Disable:
|
|
11
|
+
* localStorage.removeItem('lex4:debug')
|
|
12
|
+
* window.__LEX4_DEBUG__ = false
|
|
13
|
+
*
|
|
14
|
+
* Channels:
|
|
15
|
+
* reducer — every dispatched action and resulting state
|
|
16
|
+
* overflow — overflow detection, measurement, split decisions
|
|
17
|
+
* registry — editor registry register/unregister/get
|
|
18
|
+
* page — page creation, initial state loading, body changes
|
|
19
|
+
* toolbar — formatting command dispatches
|
|
20
|
+
* header — header height changes, content changes
|
|
21
|
+
* footer — footer height changes, content changes
|
|
22
|
+
* focus — editor focus changes, active editor/page tracking
|
|
23
|
+
*/
|
|
24
|
+
export type DebugChannel = 'reducer' | 'overflow' | 'registry' | 'page' | 'toolbar' | 'header' | 'footer' | 'focus';
|
|
25
|
+
declare global {
|
|
26
|
+
interface Window {
|
|
27
|
+
__LEX4_DEBUG__?: boolean | string;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Log a debug message on the given channel.
|
|
32
|
+
* No-ops instantly when the channel is disabled.
|
|
33
|
+
*/
|
|
34
|
+
export declare function debug(channel: DebugChannel, message: string, ...data: unknown[]): void;
|
|
35
|
+
/**
|
|
36
|
+
* Log a warning on the given channel.
|
|
37
|
+
*/
|
|
38
|
+
export declare function debugWarn(channel: DebugChannel, message: string, ...data: unknown[]): void;
|
|
39
|
+
/** Short-id helper: first 8 chars of a UUID for readable logs */
|
|
40
|
+
export declare function shortId(id: string): string;
|
|
41
|
+
//# sourceMappingURL=debug.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../src/utils/debug.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,MAAM,MAAM,YAAY,GACpB,SAAS,GACT,UAAU,GACV,UAAU,GACV,MAAM,GACN,SAAS,GACT,QAAQ,GACR,QAAQ,GACR,OAAO,CAAC;AAaZ,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,cAAc,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;KACnC;CACF;AA2BD;;;GAGG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAYtF;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAY1F;AAED,iEAAiE;AACjE,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAE1C"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { SerializedEditorState, SerializedLexicalNode } from 'lexical';
|
|
2
|
+
/**
|
|
3
|
+
* Utilities for splitting and merging Lexical editor states.
|
|
4
|
+
*
|
|
5
|
+
* A SerializedEditorState has shape:
|
|
6
|
+
* { root: { children: [...], type: "root", ... } }
|
|
7
|
+
*
|
|
8
|
+
* Content flow between pages is achieved by manipulating
|
|
9
|
+
* the root.children array — extracting, splitting, merging
|
|
10
|
+
* top-level block nodes.
|
|
11
|
+
*/
|
|
12
|
+
/** Extract all top-level nodes from a serialized editor state */
|
|
13
|
+
export declare function getTopLevelNodes(state: SerializedEditorState | null): SerializedLexicalNode[];
|
|
14
|
+
/** Count top-level nodes in a serialized editor state */
|
|
15
|
+
export declare function countTopLevelNodes(state: SerializedEditorState | null): number;
|
|
16
|
+
/**
|
|
17
|
+
* Create a SerializedEditorState from a list of top-level nodes.
|
|
18
|
+
* Uses a standard root wrapper.
|
|
19
|
+
*/
|
|
20
|
+
export declare function createEditorStateFromNodes(nodes: SerializedLexicalNode[]): SerializedEditorState;
|
|
21
|
+
/**
|
|
22
|
+
* Split a serialized editor state at a given node index.
|
|
23
|
+
*
|
|
24
|
+
* Returns [before, after] where:
|
|
25
|
+
* - before contains nodes 0..splitIndex-1
|
|
26
|
+
* - after contains nodes splitIndex..end
|
|
27
|
+
*/
|
|
28
|
+
export declare function splitEditorState(state: SerializedEditorState | null, splitIndex: number): [SerializedEditorState | null, SerializedEditorState | null];
|
|
29
|
+
/**
|
|
30
|
+
* Merge two serialized editor states by concatenating their top-level nodes.
|
|
31
|
+
* Returns a new state with all nodes from both states.
|
|
32
|
+
*/
|
|
33
|
+
export declare function mergeEditorStates(stateA: SerializedEditorState | null, stateB: SerializedEditorState | null): SerializedEditorState | null;
|
|
34
|
+
/**
|
|
35
|
+
* Append nodes to the end of a serialized editor state.
|
|
36
|
+
*/
|
|
37
|
+
export declare function appendNodes(state: SerializedEditorState | null, nodes: SerializedLexicalNode[]): SerializedEditorState;
|
|
38
|
+
/**
|
|
39
|
+
* Remove the last N nodes from a serialized editor state.
|
|
40
|
+
* Returns [trimmedState, removedNodes].
|
|
41
|
+
*/
|
|
42
|
+
export declare function removeLastNodes(state: SerializedEditorState | null, count: number): [SerializedEditorState | null, SerializedLexicalNode[]];
|
|
43
|
+
/**
|
|
44
|
+
* Remove the first N nodes from a serialized editor state.
|
|
45
|
+
* Returns [removedNodes, remainingState].
|
|
46
|
+
*/
|
|
47
|
+
export declare function removeFirstNodes(state: SerializedEditorState | null, count: number): [SerializedLexicalNode[], SerializedEditorState | null];
|
|
48
|
+
//# sourceMappingURL=editor-state-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-state-utils.d.ts","sourceRoot":"","sources":["../../src/utils/editor-state-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAE5E;;;;;;;;;GASG;AAEH,iEAAiE;AACjE,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,IAAI,GAAG,qBAAqB,EAAE,CAG7F;AAED,yDAAyD;AACzD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,qBAAqB,GAAG,IAAI,GAAG,MAAM,CAE9E;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,qBAAqB,EAAE,GAC7B,qBAAqB,CAWvB;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,qBAAqB,GAAG,IAAI,EACnC,UAAU,EAAE,MAAM,GACjB,CAAC,qBAAqB,GAAG,IAAI,EAAE,qBAAqB,GAAG,IAAI,CAAC,CAiB9D;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,qBAAqB,GAAG,IAAI,EACpC,MAAM,EAAE,qBAAqB,GAAG,IAAI,GACnC,qBAAqB,GAAG,IAAI,CAQ9B;AAED;;GAEG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,qBAAqB,GAAG,IAAI,EACnC,KAAK,EAAE,qBAAqB,EAAE,GAC7B,qBAAqB,CAGvB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,qBAAqB,GAAG,IAAI,EACnC,KAAK,EAAE,MAAM,GACZ,CAAC,qBAAqB,GAAG,IAAI,EAAE,qBAAqB,EAAE,CAAC,CAazD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,qBAAqB,GAAG,IAAI,EACnC,KAAK,EAAE,MAAM,GACZ,CAAC,qBAAqB,EAAE,EAAE,qBAAqB,GAAG,IAAI,CAAC,CAazD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Lex4Document } from '../types/document';
|
|
2
|
+
import { CaretPosition, CaretSelection, HistoryActionDescriptor, HistoryState } from '../types/history';
|
|
3
|
+
export declare const MAX_HISTORY_ACTIONS = 100;
|
|
4
|
+
export declare function createHistoryState(document: Lex4Document, baseCaretPosition?: CaretPosition | null): HistoryState;
|
|
5
|
+
export declare function getHistorySnapshot(history: HistoryState, cursor?: number): Lex4Document;
|
|
6
|
+
export declare function clearHistoryState(document: Lex4Document, baseCaretPosition?: CaretPosition | null): HistoryState;
|
|
7
|
+
export declare function recordHistoryEntry(history: HistoryState, nextDocument: Lex4Document, descriptor: HistoryActionDescriptor, undoSnapshot: Lex4Document, caretPosition: CaretPosition | null, caretSelection: CaretSelection | null, undoCaretPosition: CaretPosition | null, undoCaretSelection: CaretSelection | null): HistoryState;
|
|
8
|
+
export declare function undoHistory(history: HistoryState): {
|
|
9
|
+
history: HistoryState;
|
|
10
|
+
document: Lex4Document;
|
|
11
|
+
caretPosition: CaretPosition | null;
|
|
12
|
+
caretSelection: CaretSelection | null;
|
|
13
|
+
} | null;
|
|
14
|
+
export declare function redoHistory(history: HistoryState): {
|
|
15
|
+
history: HistoryState;
|
|
16
|
+
document: Lex4Document;
|
|
17
|
+
caretPosition: CaretPosition | null;
|
|
18
|
+
caretSelection: CaretSelection | null;
|
|
19
|
+
} | null;
|
|
20
|
+
export declare function jumpToHistoryEntry(history: HistoryState, entryIndex: number): {
|
|
21
|
+
history: HistoryState;
|
|
22
|
+
document: Lex4Document;
|
|
23
|
+
caretPosition: CaretPosition | null;
|
|
24
|
+
caretSelection: CaretSelection | null;
|
|
25
|
+
} | null;
|
|
26
|
+
//# sourceMappingURL=history-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history-manager.d.ts","sourceRoot":"","sources":["../../src/utils/history-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,uBAAuB,EAEvB,YAAY,EACb,MAAM,kBAAkB,CAAC;AAE1B,eAAO,MAAM,mBAAmB,MAAM,CAAC;AA4BvC,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,YAAY,EACtB,iBAAiB,GAAE,aAAa,GAAG,IAAW,GAC7C,YAAY,CAOd;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAiB,GAAG,YAAY,CAM/F;AAED,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,YAAY,EACtB,iBAAiB,GAAE,aAAa,GAAG,IAAW,GAC7C,YAAY,CAEd;AAED,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,YAAY,EACrB,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,uBAAuB,EACnC,YAAY,EAAE,YAAY,EAC1B,aAAa,EAAE,aAAa,GAAG,IAAI,EACnC,cAAc,EAAE,cAAc,GAAG,IAAI,EACrC,iBAAiB,EAAE,aAAa,GAAG,IAAI,EACvC,kBAAkB,EAAE,cAAc,GAAG,IAAI,GACxC,YAAY,CA4Bd;AAED,wBAAgB,WAAW,CACzB,OAAO,EAAE,YAAY,GACpB;IACD,OAAO,EAAE,YAAY,CAAC;IACtB,QAAQ,EAAE,YAAY,CAAC;IACvB,aAAa,EAAE,aAAa,GAAG,IAAI,CAAC;IACpC,cAAc,EAAE,cAAc,GAAG,IAAI,CAAC;CACvC,GAAG,IAAI,CAiBP;AAED,wBAAgB,WAAW,CACzB,OAAO,EAAE,YAAY,GACpB;IACD,OAAO,EAAE,YAAY,CAAC;IACtB,QAAQ,EAAE,YAAY,CAAC;IACvB,aAAa,EAAE,aAAa,GAAG,IAAI,CAAC;IACpC,cAAc,EAAE,cAAc,GAAG,IAAI,CAAC;CACvC,GAAG,IAAI,CAiBP;AAED,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,MAAM,GACjB;IACD,OAAO,EAAE,YAAY,CAAC;IACtB,QAAQ,EAAE,YAAY,CAAC;IACvB,aAAa,EAAE,aAAa,GAAG,IAAI,CAAC;IACpC,cAAc,EAAE,cAAc,GAAG,IAAI,CAAC;CACvC,GAAG,IAAI,CAgBP"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { measureBlockHeights, totalBlockHeight } from '../engine/measure';
|
|
2
|
+
export { getTopLevelNodes, countTopLevelNodes, createEditorStateFromNodes, splitEditorState, mergeEditorStates, appendNodes, removeLastNodes, removeFirstNodes, } from './editor-state-utils';
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,0BAA0B,EAC1B,gBAAgB,EAChB,iBAAiB,EACjB,WAAW,EACX,eAAe,EACf,gBAAgB,GACjB,MAAM,sBAAsB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@yurikilian/lex4",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/yurikilian/lex4.git",
|
|
8
|
+
"directory": "packages/editor"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://yurikilian.github.io/lex4/",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/yurikilian/lex4/issues"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"react",
|
|
16
|
+
"editor",
|
|
17
|
+
"lexical",
|
|
18
|
+
"document",
|
|
19
|
+
"paginated",
|
|
20
|
+
"a4",
|
|
21
|
+
"word-processor",
|
|
22
|
+
"rich-text"
|
|
23
|
+
],
|
|
24
|
+
"description": "A paginated document editor — reusable React library built on Meta Lexical",
|
|
25
|
+
"type": "module",
|
|
26
|
+
"main": "./dist/lex4-editor.cjs",
|
|
27
|
+
"module": "./dist/lex4-editor.js",
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"import": "./dist/lex4-editor.js",
|
|
32
|
+
"require": "./dist/lex4-editor.cjs",
|
|
33
|
+
"types": "./dist/index.d.ts"
|
|
34
|
+
},
|
|
35
|
+
"./style.css": "./dist/style.css"
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"dist"
|
|
39
|
+
],
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
42
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@lexical/clipboard": "^0.22.0",
|
|
46
|
+
"@lexical/history": "^0.22.0",
|
|
47
|
+
"@lexical/html": "^0.22.0",
|
|
48
|
+
"@lexical/list": "^0.22.0",
|
|
49
|
+
"@lexical/react": "^0.22.0",
|
|
50
|
+
"@lexical/rich-text": "^0.22.0",
|
|
51
|
+
"@lexical/selection": "^0.22.0",
|
|
52
|
+
"@lexical/utils": "^0.22.0",
|
|
53
|
+
"lexical": "^0.22.0",
|
|
54
|
+
"lucide-react": "^1.8.0"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@testing-library/jest-dom": "^6.0.0",
|
|
58
|
+
"@testing-library/react": "^16.0.0",
|
|
59
|
+
"@types/react": "^18.3.0",
|
|
60
|
+
"@types/react-dom": "^18.3.0",
|
|
61
|
+
"@vitejs/plugin-react": "^4.3.0",
|
|
62
|
+
"autoprefixer": "^10.4.0",
|
|
63
|
+
"jsdom": "^25.0.0",
|
|
64
|
+
"postcss": "^8.4.0",
|
|
65
|
+
"react": "^18.3.0",
|
|
66
|
+
"react-dom": "^18.3.0",
|
|
67
|
+
"tailwindcss": "^3.4.0",
|
|
68
|
+
"typescript": "^5.5.0",
|
|
69
|
+
"vite": "^5.4.0",
|
|
70
|
+
"vite-plugin-dts": "^4.0.0",
|
|
71
|
+
"vitest": "^2.0.0"
|
|
72
|
+
},
|
|
73
|
+
"scripts": {
|
|
74
|
+
"dev": "vite",
|
|
75
|
+
"build": "tsc --noEmit && vite build",
|
|
76
|
+
"test": "vitest run",
|
|
77
|
+
"test:watch": "vitest",
|
|
78
|
+
"lint": "tsc --noEmit"
|
|
79
|
+
}
|
|
80
|
+
}
|