@ai-matrx/office 0.0.0 → 0.2.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/CHANGELOG.md +21 -0
- package/README.md +27 -1
- package/dist/core-page-setup-apply.cjs +121 -0
- package/dist/core-page-setup-apply.cjs.map +1 -0
- package/dist/core-page-setup-apply.d.cts +21 -0
- package/dist/core-page-setup-apply.d.ts +21 -0
- package/dist/core-page-setup-apply.js +100 -0
- package/dist/core-page-setup-apply.js.map +1 -0
- package/dist/core.cjs +487 -0
- package/dist/core.cjs.map +1 -0
- package/dist/core.d.cts +397 -0
- package/dist/core.d.ts +397 -0
- package/dist/core.js +454 -0
- package/dist/core.js.map +1 -0
- package/dist/document-page-style-BFLrgdLI.d.cts +109 -0
- package/dist/document-page-style-BFLrgdLI.d.ts +109 -0
- package/dist/univer-history.cjs +61 -0
- package/dist/univer-history.cjs.map +1 -0
- package/dist/univer-history.d.cts +32 -0
- package/dist/univer-history.d.ts +32 -0
- package/dist/univer-history.js +40 -0
- package/dist/univer-history.js.map +1 -0
- package/dist/univer.cjs +333 -0
- package/dist/univer.cjs.map +1 -0
- package/dist/univer.d.cts +320 -0
- package/dist/univer.d.ts +320 -0
- package/dist/univer.js +317 -0
- package/dist/univer.js.map +1 -0
- package/package.json +130 -1
|
@@ -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 };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/univer/history.ts
|
|
21
|
+
var history_exports = {};
|
|
22
|
+
__export(history_exports, {
|
|
23
|
+
DOCUMENT_HISTORY_KIND: () => DOCUMENT_HISTORY_KIND,
|
|
24
|
+
WORKBOOK_HISTORY_KIND: () => WORKBOOK_HISTORY_KIND,
|
|
25
|
+
documentHistoryToggleInput: () => documentHistoryToggleInput,
|
|
26
|
+
readHistoryTab: () => readHistoryTab,
|
|
27
|
+
workbookHistoryToggleInput: () => workbookHistoryToggleInput
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(history_exports);
|
|
30
|
+
var DOCUMENT_HISTORY_KIND = "document-history";
|
|
31
|
+
var WORKBOOK_HISTORY_KIND = "workbook-history";
|
|
32
|
+
function readHistoryTab(data) {
|
|
33
|
+
if (typeof data !== "object" || data === null || Array.isArray(data)) return null;
|
|
34
|
+
const record = data;
|
|
35
|
+
const id = typeof record.id === "string" && record.id ? record.id : null;
|
|
36
|
+
if (!id) return null;
|
|
37
|
+
return { id, editable: record.editable !== false };
|
|
38
|
+
}
|
|
39
|
+
function subjectTitle(what, subject) {
|
|
40
|
+
const name = subject?.trim();
|
|
41
|
+
return name ? `${what} \xB7 ${name}` : what;
|
|
42
|
+
}
|
|
43
|
+
function documentHistoryToggleInput(documentId, editable, documentName) {
|
|
44
|
+
return {
|
|
45
|
+
kind: DOCUMENT_HISTORY_KIND,
|
|
46
|
+
key: documentId,
|
|
47
|
+
title: subjectTitle("Document history", documentName),
|
|
48
|
+
data: { id: documentId, editable },
|
|
49
|
+
followTitle: true
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function workbookHistoryToggleInput(workbookId, editable, workbookName) {
|
|
53
|
+
return {
|
|
54
|
+
kind: WORKBOOK_HISTORY_KIND,
|
|
55
|
+
key: workbookId,
|
|
56
|
+
title: subjectTitle("Workbook history", workbookName),
|
|
57
|
+
data: { id: workbookId, editable },
|
|
58
|
+
followTitle: true
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=univer-history.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/univer/history.ts"],"sourcesContent":["/**\n * A document's or a workbook's snapshot history as a canvas tab — the keys and toggle inputs the\n * editors use, and the reader the two history views use. One tab per document (`document-history`,\n * keyed by the document id) and per workbook (`workbook-history`, keyed by the workbook id).\n *\n * Pure: no React, no canvas package, no Univer. The two `defineCanvasKind` registrations stay with\n * the host app (matrx-frontend `features/canvas/host`) and lazy-load the views, so this module never\n * imports a view (the cycle the old `lib/univer/historyKinds.ts` closed).\n */\n\nexport const DOCUMENT_HISTORY_KIND = \"document-history\";\nexport const WORKBOOK_HISTORY_KIND = \"workbook-history\";\n\nexport interface HistoryTabData {\n id: string;\n editable: boolean;\n}\n\n/** Structurally the host's `ToolToggleInput` (the canvas toggle the editor's History button presses). */\nexport interface HistoryToggleInput {\n kind: string;\n key: string;\n title: string;\n data: { id: string; editable: boolean };\n followTitle: true;\n}\n\n/** A tab's data as a history subject, or null when it names no subject. */\nexport function readHistoryTab(data: unknown): HistoryTabData | null {\n if (typeof data !== \"object\" || data === null || Array.isArray(data)) return null;\n const record = data as Record<string, unknown>;\n const id = typeof record.id === \"string\" && record.id ? record.id : null;\n if (!id) return null;\n return { id, editable: record.editable !== false };\n}\n\n/** \"<what> · <subject>\", or just \"<what>\" while the subject has no name. */\nfunction subjectTitle(what: string, subject: string | null | undefined): string {\n const name = subject?.trim();\n return name ? `${what} · ${name}` : what;\n}\n\n// The tab names its subject — two open history tabs never share a title, and\n// the editor that owns the toggle keeps it in step with a rename.\nexport function documentHistoryToggleInput(documentId: string, editable: boolean, documentName?: string | null): HistoryToggleInput {\n return {\n kind: DOCUMENT_HISTORY_KIND,\n key: documentId,\n title: subjectTitle(\"Document history\", documentName),\n data: { id: documentId, editable },\n followTitle: true,\n };\n}\n\nexport function workbookHistoryToggleInput(workbookId: string, editable: boolean, workbookName?: string | null): HistoryToggleInput {\n return {\n kind: WORKBOOK_HISTORY_KIND,\n key: workbookId,\n title: subjectTitle(\"Workbook history\", workbookName),\n data: { id: workbookId, editable },\n followTitle: true,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUO,IAAM,wBAAwB;AAC9B,IAAM,wBAAwB;AAiB9B,SAAS,eAAe,MAAsC;AACnE,MAAI,OAAO,SAAS,YAAY,SAAS,QAAQ,MAAM,QAAQ,IAAI,EAAG,QAAO;AAC7E,QAAM,SAAS;AACf,QAAM,KAAK,OAAO,OAAO,OAAO,YAAY,OAAO,KAAK,OAAO,KAAK;AACpE,MAAI,CAAC,GAAI,QAAO;AAChB,SAAO,EAAE,IAAI,UAAU,OAAO,aAAa,MAAM;AACnD;AAGA,SAAS,aAAa,MAAc,SAA4C;AAC9E,QAAM,OAAO,SAAS,KAAK;AAC3B,SAAO,OAAO,GAAG,IAAI,SAAM,IAAI,KAAK;AACtC;AAIO,SAAS,2BAA2B,YAAoB,UAAmB,cAAkD;AAClI,SAAO;AAAA,IACL,MAAM;AAAA,IACN,KAAK;AAAA,IACL,OAAO,aAAa,oBAAoB,YAAY;AAAA,IACpD,MAAM,EAAE,IAAI,YAAY,SAAS;AAAA,IACjC,aAAa;AAAA,EACf;AACF;AAEO,SAAS,2BAA2B,YAAoB,UAAmB,cAAkD;AAClI,SAAO;AAAA,IACL,MAAM;AAAA,IACN,KAAK;AAAA,IACL,OAAO,aAAa,oBAAoB,YAAY;AAAA,IACpD,MAAM,EAAE,IAAI,YAAY,SAAS;AAAA,IACjC,aAAa;AAAA,EACf;AACF;","names":[]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A document's or a workbook's snapshot history as a canvas tab — the keys and toggle inputs the
|
|
3
|
+
* editors use, and the reader the two history views use. One tab per document (`document-history`,
|
|
4
|
+
* keyed by the document id) and per workbook (`workbook-history`, keyed by the workbook id).
|
|
5
|
+
*
|
|
6
|
+
* Pure: no React, no canvas package, no Univer. The two `defineCanvasKind` registrations stay with
|
|
7
|
+
* the host app (matrx-frontend `features/canvas/host`) and lazy-load the views, so this module never
|
|
8
|
+
* imports a view (the cycle the old `lib/univer/historyKinds.ts` closed).
|
|
9
|
+
*/
|
|
10
|
+
declare const DOCUMENT_HISTORY_KIND = "document-history";
|
|
11
|
+
declare const WORKBOOK_HISTORY_KIND = "workbook-history";
|
|
12
|
+
interface HistoryTabData {
|
|
13
|
+
id: string;
|
|
14
|
+
editable: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** Structurally the host's `ToolToggleInput` (the canvas toggle the editor's History button presses). */
|
|
17
|
+
interface HistoryToggleInput {
|
|
18
|
+
kind: string;
|
|
19
|
+
key: string;
|
|
20
|
+
title: string;
|
|
21
|
+
data: {
|
|
22
|
+
id: string;
|
|
23
|
+
editable: boolean;
|
|
24
|
+
};
|
|
25
|
+
followTitle: true;
|
|
26
|
+
}
|
|
27
|
+
/** A tab's data as a history subject, or null when it names no subject. */
|
|
28
|
+
declare function readHistoryTab(data: unknown): HistoryTabData | null;
|
|
29
|
+
declare function documentHistoryToggleInput(documentId: string, editable: boolean, documentName?: string | null): HistoryToggleInput;
|
|
30
|
+
declare function workbookHistoryToggleInput(workbookId: string, editable: boolean, workbookName?: string | null): HistoryToggleInput;
|
|
31
|
+
|
|
32
|
+
export { DOCUMENT_HISTORY_KIND, type HistoryTabData, type HistoryToggleInput, WORKBOOK_HISTORY_KIND, documentHistoryToggleInput, readHistoryTab, workbookHistoryToggleInput };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A document's or a workbook's snapshot history as a canvas tab — the keys and toggle inputs the
|
|
3
|
+
* editors use, and the reader the two history views use. One tab per document (`document-history`,
|
|
4
|
+
* keyed by the document id) and per workbook (`workbook-history`, keyed by the workbook id).
|
|
5
|
+
*
|
|
6
|
+
* Pure: no React, no canvas package, no Univer. The two `defineCanvasKind` registrations stay with
|
|
7
|
+
* the host app (matrx-frontend `features/canvas/host`) and lazy-load the views, so this module never
|
|
8
|
+
* imports a view (the cycle the old `lib/univer/historyKinds.ts` closed).
|
|
9
|
+
*/
|
|
10
|
+
declare const DOCUMENT_HISTORY_KIND = "document-history";
|
|
11
|
+
declare const WORKBOOK_HISTORY_KIND = "workbook-history";
|
|
12
|
+
interface HistoryTabData {
|
|
13
|
+
id: string;
|
|
14
|
+
editable: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** Structurally the host's `ToolToggleInput` (the canvas toggle the editor's History button presses). */
|
|
17
|
+
interface HistoryToggleInput {
|
|
18
|
+
kind: string;
|
|
19
|
+
key: string;
|
|
20
|
+
title: string;
|
|
21
|
+
data: {
|
|
22
|
+
id: string;
|
|
23
|
+
editable: boolean;
|
|
24
|
+
};
|
|
25
|
+
followTitle: true;
|
|
26
|
+
}
|
|
27
|
+
/** A tab's data as a history subject, or null when it names no subject. */
|
|
28
|
+
declare function readHistoryTab(data: unknown): HistoryTabData | null;
|
|
29
|
+
declare function documentHistoryToggleInput(documentId: string, editable: boolean, documentName?: string | null): HistoryToggleInput;
|
|
30
|
+
declare function workbookHistoryToggleInput(workbookId: string, editable: boolean, workbookName?: string | null): HistoryToggleInput;
|
|
31
|
+
|
|
32
|
+
export { DOCUMENT_HISTORY_KIND, type HistoryTabData, type HistoryToggleInput, WORKBOOK_HISTORY_KIND, documentHistoryToggleInput, readHistoryTab, workbookHistoryToggleInput };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// src/univer/history.ts
|
|
2
|
+
var DOCUMENT_HISTORY_KIND = "document-history";
|
|
3
|
+
var WORKBOOK_HISTORY_KIND = "workbook-history";
|
|
4
|
+
function readHistoryTab(data) {
|
|
5
|
+
if (typeof data !== "object" || data === null || Array.isArray(data)) return null;
|
|
6
|
+
const record = data;
|
|
7
|
+
const id = typeof record.id === "string" && record.id ? record.id : null;
|
|
8
|
+
if (!id) return null;
|
|
9
|
+
return { id, editable: record.editable !== false };
|
|
10
|
+
}
|
|
11
|
+
function subjectTitle(what, subject) {
|
|
12
|
+
const name = subject?.trim();
|
|
13
|
+
return name ? `${what} \xB7 ${name}` : what;
|
|
14
|
+
}
|
|
15
|
+
function documentHistoryToggleInput(documentId, editable, documentName) {
|
|
16
|
+
return {
|
|
17
|
+
kind: DOCUMENT_HISTORY_KIND,
|
|
18
|
+
key: documentId,
|
|
19
|
+
title: subjectTitle("Document history", documentName),
|
|
20
|
+
data: { id: documentId, editable },
|
|
21
|
+
followTitle: true
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function workbookHistoryToggleInput(workbookId, editable, workbookName) {
|
|
25
|
+
return {
|
|
26
|
+
kind: WORKBOOK_HISTORY_KIND,
|
|
27
|
+
key: workbookId,
|
|
28
|
+
title: subjectTitle("Workbook history", workbookName),
|
|
29
|
+
data: { id: workbookId, editable },
|
|
30
|
+
followTitle: true
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
DOCUMENT_HISTORY_KIND,
|
|
35
|
+
WORKBOOK_HISTORY_KIND,
|
|
36
|
+
documentHistoryToggleInput,
|
|
37
|
+
readHistoryTab,
|
|
38
|
+
workbookHistoryToggleInput
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=univer-history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/univer/history.ts"],"sourcesContent":["/**\n * A document's or a workbook's snapshot history as a canvas tab — the keys and toggle inputs the\n * editors use, and the reader the two history views use. One tab per document (`document-history`,\n * keyed by the document id) and per workbook (`workbook-history`, keyed by the workbook id).\n *\n * Pure: no React, no canvas package, no Univer. The two `defineCanvasKind` registrations stay with\n * the host app (matrx-frontend `features/canvas/host`) and lazy-load the views, so this module never\n * imports a view (the cycle the old `lib/univer/historyKinds.ts` closed).\n */\n\nexport const DOCUMENT_HISTORY_KIND = \"document-history\";\nexport const WORKBOOK_HISTORY_KIND = \"workbook-history\";\n\nexport interface HistoryTabData {\n id: string;\n editable: boolean;\n}\n\n/** Structurally the host's `ToolToggleInput` (the canvas toggle the editor's History button presses). */\nexport interface HistoryToggleInput {\n kind: string;\n key: string;\n title: string;\n data: { id: string; editable: boolean };\n followTitle: true;\n}\n\n/** A tab's data as a history subject, or null when it names no subject. */\nexport function readHistoryTab(data: unknown): HistoryTabData | null {\n if (typeof data !== \"object\" || data === null || Array.isArray(data)) return null;\n const record = data as Record<string, unknown>;\n const id = typeof record.id === \"string\" && record.id ? record.id : null;\n if (!id) return null;\n return { id, editable: record.editable !== false };\n}\n\n/** \"<what> · <subject>\", or just \"<what>\" while the subject has no name. */\nfunction subjectTitle(what: string, subject: string | null | undefined): string {\n const name = subject?.trim();\n return name ? `${what} · ${name}` : what;\n}\n\n// The tab names its subject — two open history tabs never share a title, and\n// the editor that owns the toggle keeps it in step with a rename.\nexport function documentHistoryToggleInput(documentId: string, editable: boolean, documentName?: string | null): HistoryToggleInput {\n return {\n kind: DOCUMENT_HISTORY_KIND,\n key: documentId,\n title: subjectTitle(\"Document history\", documentName),\n data: { id: documentId, editable },\n followTitle: true,\n };\n}\n\nexport function workbookHistoryToggleInput(workbookId: string, editable: boolean, workbookName?: string | null): HistoryToggleInput {\n return {\n kind: WORKBOOK_HISTORY_KIND,\n key: workbookId,\n title: subjectTitle(\"Workbook history\", workbookName),\n data: { id: workbookId, editable },\n followTitle: true,\n };\n}\n"],"mappings":";AAUO,IAAM,wBAAwB;AAC9B,IAAM,wBAAwB;AAiB9B,SAAS,eAAe,MAAsC;AACnE,MAAI,OAAO,SAAS,YAAY,SAAS,QAAQ,MAAM,QAAQ,IAAI,EAAG,QAAO;AAC7E,QAAM,SAAS;AACf,QAAM,KAAK,OAAO,OAAO,OAAO,YAAY,OAAO,KAAK,OAAO,KAAK;AACpE,MAAI,CAAC,GAAI,QAAO;AAChB,SAAO,EAAE,IAAI,UAAU,OAAO,aAAa,MAAM;AACnD;AAGA,SAAS,aAAa,MAAc,SAA4C;AAC9E,QAAM,OAAO,SAAS,KAAK;AAC3B,SAAO,OAAO,GAAG,IAAI,SAAM,IAAI,KAAK;AACtC;AAIO,SAAS,2BAA2B,YAAoB,UAAmB,cAAkD;AAClI,SAAO;AAAA,IACL,MAAM;AAAA,IACN,KAAK;AAAA,IACL,OAAO,aAAa,oBAAoB,YAAY;AAAA,IACpD,MAAM,EAAE,IAAI,YAAY,SAAS;AAAA,IACjC,aAAa;AAAA,EACf;AACF;AAEO,SAAS,2BAA2B,YAAoB,UAAmB,cAAkD;AAClI,SAAO;AAAA,IACL,MAAM;AAAA,IACN,KAAK;AAAA,IACL,OAAO,aAAa,oBAAoB,YAAY;AAAA,IACpD,MAAM,EAAE,IAAI,YAAY,SAAS;AAAA,IACjC,aAAa;AAAA,EACf;AACF;","names":[]}
|