@ai-matrx/office 0.0.0 → 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.
@@ -0,0 +1,109 @@
1
+ import { IDocumentData, DocumentFlavor, PageOrientType } from '@univerjs/core';
2
+
3
+ /**
4
+ * The ONE page geometry every Matrx cloud document is laid out with.
5
+ *
6
+ * Univer lays a document out inside `documentStyle.pageSize`. With no pageSize
7
+ * the docs renderer has no page box at all: text never wraps (it runs off the
8
+ * right edge) and the vertical extent is unbounded, so the docs viewport
9
+ * reports nothing to scroll — the wheel is swallowed and the page sits frozen
10
+ * at the top. Every writer of a Univer snapshot MUST stamp this style.
11
+ *
12
+ * Consumers: `DocumentEditor` (new empty doc), `markdown-to-univer-doc`
13
+ * (markdown import), and `sanitizeUniverDocSnapshot` (recovery for snapshots
14
+ * that reached storage without it — notably `origin='agent'` writes).
15
+ */
16
+
17
+ type DocumentStyle = NonNullable<IDocumentData["documentStyle"]>;
18
+ /** Univer lays documents out in 96-dpi CSS pixels: one inch is 96 units. */
19
+ declare const PX_PER_INCH = 96;
20
+ /** Paper sizes the Page setup dialog offers, in 96-dpi pixels, portrait (width x height). */
21
+ declare const PAPER_SIZES: {
22
+ readonly Letter: {
23
+ readonly width: 816;
24
+ readonly height: 1056;
25
+ readonly label: "Letter (8.5 x 11 in)";
26
+ };
27
+ readonly Legal: {
28
+ readonly width: 816;
29
+ readonly height: 1344;
30
+ readonly label: "Legal (8.5 x 14 in)";
31
+ };
32
+ readonly Tabloid: {
33
+ readonly width: 1056;
34
+ readonly height: 1632;
35
+ readonly label: "Tabloid (11 x 17 in)";
36
+ };
37
+ readonly Executive: {
38
+ readonly width: 696;
39
+ readonly height: 1008;
40
+ readonly label: "Executive (7.25 x 10.5 in)";
41
+ };
42
+ readonly Statement: {
43
+ readonly width: 528;
44
+ readonly height: 816;
45
+ readonly label: "Statement (5.5 x 8.5 in)";
46
+ };
47
+ readonly A3: {
48
+ readonly width: 1123;
49
+ readonly height: 1587;
50
+ readonly label: "A3 (11.69 x 16.54 in)";
51
+ };
52
+ readonly A4: {
53
+ readonly width: 794;
54
+ readonly height: 1124;
55
+ readonly label: "A4 (8.27 x 11.69 in)";
56
+ };
57
+ readonly A5: {
58
+ readonly width: 559;
59
+ readonly height: 794;
60
+ readonly label: "A5 (5.83 x 8.27 in)";
61
+ };
62
+ };
63
+ type PaperSizeName = keyof typeof PAPER_SIZES;
64
+ /** A real page, like Google Docs: Letter, one-inch margins (624px of text), paginated. */
65
+ declare const DEFAULT_DOCUMENT_PAGE_STYLE: DocumentStyle;
66
+ /** Fresh copy — Univer mutates the style it is handed. */
67
+ declare function defaultDocumentPageStyle(): DocumentStyle;
68
+ /**
69
+ * The squeezed geometry every document was stamped with until 2026-10-15: A4 at 72 dpi (595 x 842)
70
+ * with 90/72 margins, in Univer's pageless flavour, so the text column was ~415px with no paper.
71
+ * Pageless was never offered then, so this exact shape is always the old default, never a choice.
72
+ */
73
+ declare function isLegacySqueezedPageStyle(style: DocumentStyle | undefined): boolean;
74
+ /** What the Page setup dialog edits. Margins are in inches, like Google's. */
75
+ interface PageSetupValues {
76
+ pageless: boolean;
77
+ orientation: "portrait" | "landscape";
78
+ paper: PaperSizeName;
79
+ marginTop: number;
80
+ marginBottom: number;
81
+ marginLeft: number;
82
+ marginRight: number;
83
+ /** Paper colour, hex. Always a light colour so the black ink stays readable. */
84
+ pageColor: string;
85
+ }
86
+ declare const PAGE_COLORS: readonly ["#ffffff", "#fff8e7", "#f3f3f3", "#e8f0fe", "#e6f4ea", "#fef7e0"];
87
+ declare const DEFAULT_PAGE_COLOR: "#ffffff";
88
+ /** Key on `documentStyle` carrying the paper colour (Univer paints it from the host's surface theme). */
89
+ declare const PAGE_COLOR_KEY = "matrxPageColor";
90
+ /** The dialog's values, read from a document's style (missing parts fall back to the default page). */
91
+ declare function pageSetupFromStyle(style: DocumentStyle | undefined): PageSetupValues;
92
+ /** Params for Univer's `docs.command.page-setup` (pageSize is the as-printed size: swapped when landscape). */
93
+ declare function pageSetupCommandParams(v: PageSetupValues): {
94
+ documentFlavor: DocumentFlavor;
95
+ pageOrient: PageOrientType;
96
+ pageSize: {
97
+ width: 816 | 1056 | 1344 | 1632 | 1008 | 1587 | 794 | 1124;
98
+ height: 816 | 1056 | 696 | 528 | 1123 | 794 | 559;
99
+ } | {
100
+ width: 816 | 1056 | 696 | 528 | 1123 | 794 | 559;
101
+ height: 816 | 1056 | 1344 | 1632 | 1008 | 1587 | 794 | 1124;
102
+ };
103
+ marginTop: number;
104
+ marginBottom: number;
105
+ marginLeft: number;
106
+ marginRight: number;
107
+ };
108
+
109
+ export { DEFAULT_DOCUMENT_PAGE_STYLE as D, PAGE_COLORS as P, DEFAULT_PAGE_COLOR as a, PAGE_COLOR_KEY as b, PAPER_SIZES as c, PX_PER_INCH as d, type PageSetupValues as e, type PaperSizeName as f, defaultDocumentPageStyle as g, pageSetupFromStyle as h, isLegacySqueezedPageStyle as i, pageSetupCommandParams as p };
@@ -0,0 +1,109 @@
1
+ import { IDocumentData, DocumentFlavor, PageOrientType } from '@univerjs/core';
2
+
3
+ /**
4
+ * The ONE page geometry every Matrx cloud document is laid out with.
5
+ *
6
+ * Univer lays a document out inside `documentStyle.pageSize`. With no pageSize
7
+ * the docs renderer has no page box at all: text never wraps (it runs off the
8
+ * right edge) and the vertical extent is unbounded, so the docs viewport
9
+ * reports nothing to scroll — the wheel is swallowed and the page sits frozen
10
+ * at the top. Every writer of a Univer snapshot MUST stamp this style.
11
+ *
12
+ * Consumers: `DocumentEditor` (new empty doc), `markdown-to-univer-doc`
13
+ * (markdown import), and `sanitizeUniverDocSnapshot` (recovery for snapshots
14
+ * that reached storage without it — notably `origin='agent'` writes).
15
+ */
16
+
17
+ type DocumentStyle = NonNullable<IDocumentData["documentStyle"]>;
18
+ /** Univer lays documents out in 96-dpi CSS pixels: one inch is 96 units. */
19
+ declare const PX_PER_INCH = 96;
20
+ /** Paper sizes the Page setup dialog offers, in 96-dpi pixels, portrait (width x height). */
21
+ declare const PAPER_SIZES: {
22
+ readonly Letter: {
23
+ readonly width: 816;
24
+ readonly height: 1056;
25
+ readonly label: "Letter (8.5 x 11 in)";
26
+ };
27
+ readonly Legal: {
28
+ readonly width: 816;
29
+ readonly height: 1344;
30
+ readonly label: "Legal (8.5 x 14 in)";
31
+ };
32
+ readonly Tabloid: {
33
+ readonly width: 1056;
34
+ readonly height: 1632;
35
+ readonly label: "Tabloid (11 x 17 in)";
36
+ };
37
+ readonly Executive: {
38
+ readonly width: 696;
39
+ readonly height: 1008;
40
+ readonly label: "Executive (7.25 x 10.5 in)";
41
+ };
42
+ readonly Statement: {
43
+ readonly width: 528;
44
+ readonly height: 816;
45
+ readonly label: "Statement (5.5 x 8.5 in)";
46
+ };
47
+ readonly A3: {
48
+ readonly width: 1123;
49
+ readonly height: 1587;
50
+ readonly label: "A3 (11.69 x 16.54 in)";
51
+ };
52
+ readonly A4: {
53
+ readonly width: 794;
54
+ readonly height: 1124;
55
+ readonly label: "A4 (8.27 x 11.69 in)";
56
+ };
57
+ readonly A5: {
58
+ readonly width: 559;
59
+ readonly height: 794;
60
+ readonly label: "A5 (5.83 x 8.27 in)";
61
+ };
62
+ };
63
+ type PaperSizeName = keyof typeof PAPER_SIZES;
64
+ /** A real page, like Google Docs: Letter, one-inch margins (624px of text), paginated. */
65
+ declare const DEFAULT_DOCUMENT_PAGE_STYLE: DocumentStyle;
66
+ /** Fresh copy — Univer mutates the style it is handed. */
67
+ declare function defaultDocumentPageStyle(): DocumentStyle;
68
+ /**
69
+ * The squeezed geometry every document was stamped with until 2026-10-15: A4 at 72 dpi (595 x 842)
70
+ * with 90/72 margins, in Univer's pageless flavour, so the text column was ~415px with no paper.
71
+ * Pageless was never offered then, so this exact shape is always the old default, never a choice.
72
+ */
73
+ declare function isLegacySqueezedPageStyle(style: DocumentStyle | undefined): boolean;
74
+ /** What the Page setup dialog edits. Margins are in inches, like Google's. */
75
+ interface PageSetupValues {
76
+ pageless: boolean;
77
+ orientation: "portrait" | "landscape";
78
+ paper: PaperSizeName;
79
+ marginTop: number;
80
+ marginBottom: number;
81
+ marginLeft: number;
82
+ marginRight: number;
83
+ /** Paper colour, hex. Always a light colour so the black ink stays readable. */
84
+ pageColor: string;
85
+ }
86
+ declare const PAGE_COLORS: readonly ["#ffffff", "#fff8e7", "#f3f3f3", "#e8f0fe", "#e6f4ea", "#fef7e0"];
87
+ declare const DEFAULT_PAGE_COLOR: "#ffffff";
88
+ /** Key on `documentStyle` carrying the paper colour (Univer paints it from the host's surface theme). */
89
+ declare const PAGE_COLOR_KEY = "matrxPageColor";
90
+ /** The dialog's values, read from a document's style (missing parts fall back to the default page). */
91
+ declare function pageSetupFromStyle(style: DocumentStyle | undefined): PageSetupValues;
92
+ /** Params for Univer's `docs.command.page-setup` (pageSize is the as-printed size: swapped when landscape). */
93
+ declare function pageSetupCommandParams(v: PageSetupValues): {
94
+ documentFlavor: DocumentFlavor;
95
+ pageOrient: PageOrientType;
96
+ pageSize: {
97
+ width: 816 | 1056 | 1344 | 1632 | 1008 | 1587 | 794 | 1124;
98
+ height: 816 | 1056 | 696 | 528 | 1123 | 794 | 559;
99
+ } | {
100
+ width: 816 | 1056 | 696 | 528 | 1123 | 794 | 559;
101
+ height: 816 | 1056 | 1344 | 1632 | 1008 | 1587 | 794 | 1124;
102
+ };
103
+ marginTop: number;
104
+ marginBottom: number;
105
+ marginLeft: number;
106
+ marginRight: number;
107
+ };
108
+
109
+ export { DEFAULT_DOCUMENT_PAGE_STYLE as D, PAGE_COLORS as P, DEFAULT_PAGE_COLOR as a, PAGE_COLOR_KEY as b, PAPER_SIZES as c, PX_PER_INCH as d, type PageSetupValues as e, type PaperSizeName as f, defaultDocumentPageStyle as g, pageSetupFromStyle as h, isLegacySqueezedPageStyle as i, pageSetupCommandParams as p };
package/package.json CHANGED
@@ -1 +1,106 @@
1
- {"name":"@ai-matrx/office","version":"0.0.0","description":"Name reservation only; no usable API. Do not adopt.","license":"MIT","repository":{"type":"git","url":"git+https://github.com/AI-Matrix-Engine/aidream.git","directory":"apps/shared/office"},"files":["README.md","LICENSE"],"publishConfig":{"access":"public"}}
1
+ {
2
+ "name": "@ai-matrx/office",
3
+ "version": "0.1.0",
4
+ "description": "The AI Matrx Office layer: the editors' shared command and menu model, the Google and Microsoft ribbon model, page setup, the Office record types and the configured product hosts. Sheets, Docs and the other products arrive as sections of this one package.",
5
+ "type": "module",
6
+ "main": "./dist/core.cjs",
7
+ "module": "./dist/core.js",
8
+ "types": "./dist/core.d.ts",
9
+ "license": "MIT",
10
+ "keywords": [
11
+ "office",
12
+ "editor",
13
+ "ribbon",
14
+ "menu-bar",
15
+ "page-setup",
16
+ "ai-matrx"
17
+ ],
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/AI-Matrix-Engine/aidream.git",
21
+ "directory": "apps/shared/office"
22
+ },
23
+ "homepage": "https://github.com/AI-Matrix-Engine/aidream/tree/main/apps/shared/office#readme",
24
+ "bugs": {
25
+ "url": "https://github.com/AI-Matrix-Engine/aidream/issues"
26
+ },
27
+ "files": [
28
+ "dist",
29
+ "README.md",
30
+ "LICENSE",
31
+ "CHANGELOG.md"
32
+ ],
33
+ "exports": {
34
+ "./core": {
35
+ "import": {
36
+ "types": "./dist/core.d.ts",
37
+ "default": "./dist/core.js"
38
+ },
39
+ "require": {
40
+ "types": "./dist/core.d.cts",
41
+ "default": "./dist/core.cjs"
42
+ }
43
+ },
44
+ "./core/page-setup-apply": {
45
+ "import": {
46
+ "types": "./dist/core-page-setup-apply.d.ts",
47
+ "default": "./dist/core-page-setup-apply.js"
48
+ },
49
+ "require": {
50
+ "types": "./dist/core-page-setup-apply.d.cts",
51
+ "default": "./dist/core-page-setup-apply.cjs"
52
+ }
53
+ },
54
+ "./package.json": "./package.json"
55
+ },
56
+ "dependencies": {
57
+ "@univerjs/core": "1.0.4",
58
+ "@ai-matrx/kit": "latest"
59
+ },
60
+ "peerDependencies": {
61
+ "react": ">=18.0.0"
62
+ },
63
+ "devDependencies": {
64
+ "@arethetypeswrong/cli": "^0.18.5",
65
+ "@types/node": "^26.6.2",
66
+ "@types/react": "19.3.0",
67
+ "publint": "^0.3.24",
68
+ "react": "^19.3.0",
69
+ "tsup": "^8.5.1",
70
+ "typescript": "^6.0.3",
71
+ "vitest": "^5.0.1"
72
+ },
73
+ "publishConfig": {
74
+ "access": "public",
75
+ "registry": "https://registry.npmjs.org/"
76
+ },
77
+ "engines": {
78
+ "node": ">=20"
79
+ },
80
+ "sideEffects": false,
81
+ "matrx": {
82
+ "charter": "The Office layer: shared editor chrome model, products' sections.",
83
+ "owns": [
84
+ "office editors' command, menu and ribbon model",
85
+ "office page setup",
86
+ "office record types",
87
+ "office product hosts"
88
+ ],
89
+ "mustNotOwn": [
90
+ "files and sharing (file-actions, sharing)",
91
+ "table data (records)",
92
+ "the app shell (shell)"
93
+ ],
94
+ "layer": 7
95
+ },
96
+ "scripts": {
97
+ "build": "pnpm clean && tsup && node ../scripts/check-node-env-not-inlined.mjs",
98
+ "clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
99
+ "check:package": "pnpm build && node ../scripts/check-exports-agreement.mjs && publint && pnpm verify:tarball && node ../scripts/check-tarball-relative-imports.mjs --self-test && node ../scripts/check-tarball-relative-imports.mjs --pack .",
100
+ "typecheck": "tsc -p tsconfig.json --noEmit",
101
+ "test": "vitest run",
102
+ "test:watch": "vitest",
103
+ "verify:tarball": "node ./scripts/verify-tarball.mjs"
104
+ },
105
+ "gitHead": "9e0559b49bd2083d13ffe88f1cafa04124c14c95"
106
+ }