js.documents 7.12.3 → 7.14.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/cell-BK7EyvRu.d.cts +34 -0
- package/dist/cell-BK7EyvRu.d.ts +34 -0
- package/dist/codecs/registry.cjs +1 -1
- package/dist/codecs/registry.js +1 -1
- package/dist/convert/composition.cjs +1 -1
- package/dist/convert/composition.js +1 -1
- package/dist/edit/doc/editor.cjs +132 -0
- package/dist/edit/doc/editor.d.cts +50 -0
- package/dist/edit/doc/editor.d.ts +50 -0
- package/dist/edit/doc/editor.js +128 -0
- package/dist/edit/doc/paragraph.cjs +130 -0
- package/dist/edit/doc/paragraph.d.cts +2 -0
- package/dist/edit/doc/paragraph.d.ts +2 -0
- package/dist/edit/doc/paragraph.js +128 -0
- package/dist/edit/doc/run.cjs +98 -0
- package/dist/edit/doc/run.d.cts +2 -0
- package/dist/edit/doc/run.d.ts +2 -0
- package/dist/edit/doc/run.js +96 -0
- package/dist/edit/doc/table.cjs +110 -0
- package/dist/edit/doc/table.d.cts +41 -0
- package/dist/edit/doc/table.d.ts +41 -0
- package/dist/edit/doc/table.js +106 -0
- package/dist/edit/ppt/editor.cjs +50 -0
- package/dist/edit/ppt/editor.d.cts +21 -0
- package/dist/edit/ppt/editor.d.ts +21 -0
- package/dist/edit/ppt/editor.js +47 -0
- package/dist/edit/ppt/slide.cjs +104 -0
- package/dist/edit/ppt/slide.d.cts +39 -0
- package/dist/edit/ppt/slide.d.ts +39 -0
- package/dist/edit/ppt/slide.js +101 -0
- package/dist/edit/xls/cell.cjs +113 -0
- package/dist/edit/xls/cell.d.cts +2 -0
- package/dist/edit/xls/cell.d.ts +2 -0
- package/dist/edit/xls/cell.js +111 -0
- package/dist/edit/xls/editor.cjs +81 -0
- package/dist/edit/xls/editor.d.cts +22 -0
- package/dist/edit/xls/editor.d.ts +22 -0
- package/dist/edit/xls/editor.js +78 -0
- package/dist/edit/xls/sheet.cjs +88 -0
- package/dist/edit/xls/sheet.d.cts +27 -0
- package/dist/edit/xls/sheet.d.ts +27 -0
- package/dist/edit/xls/sheet.js +87 -0
- package/dist/index.cjs +31 -2
- package/dist/index.d.cts +17 -8
- package/dist/index.d.ts +16 -7
- package/dist/index.js +12 -3
- package/dist/paragraph-Byw2Y7xu.d.ts +43 -0
- package/dist/paragraph-DM9n9I4T.d.cts +43 -0
- package/dist/run-iYz2M-a_.d.cts +39 -0
- package/dist/run-iYz2M-a_.d.ts +39 -0
- package/package.json +1 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { t as ClockPort } from "../../clock-C7SUuYN0.js";
|
|
2
|
+
import { PptSlide } from "./slide.js";
|
|
3
|
+
import { ContentDocument, LayoutMetadata, PageSize } from "document-schema.js";
|
|
4
|
+
//#region src/edit/ppt/editor.d.ts
|
|
5
|
+
interface CreatePptOptions {
|
|
6
|
+
readonly clock?: ClockPort;
|
|
7
|
+
}
|
|
8
|
+
declare class PptEditor {
|
|
9
|
+
private readonly document;
|
|
10
|
+
constructor(document: ContentDocument);
|
|
11
|
+
get metadata(): LayoutMetadata;
|
|
12
|
+
set metadata(value: LayoutMetadata);
|
|
13
|
+
slides(): PptSlide[];
|
|
14
|
+
addSlide(size?: PageSize): PptSlide;
|
|
15
|
+
removeSlideAt(index: number): void;
|
|
16
|
+
toBytes(): Uint8Array<ArrayBuffer>;
|
|
17
|
+
}
|
|
18
|
+
declare function openPpt(bytes: Uint8Array<ArrayBuffer>): PptEditor;
|
|
19
|
+
declare function createPpt(options?: CreatePptOptions): PptEditor;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { CreatePptOptions, PptEditor, createPpt, openPpt };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { resolveMetadataTimestamps } from "../../model/metadata.js";
|
|
2
|
+
import { systemClock } from "../../ports/clock.js";
|
|
3
|
+
import { readPptContent } from "../../ppt/read.js";
|
|
4
|
+
import { writePptContent } from "../../ppt/write.js";
|
|
5
|
+
import { PptSlide, buildSlide } from "./slide.js";
|
|
6
|
+
import { SLIDE_SIZE_WIDESCREEN } from "document-schema.js";
|
|
7
|
+
//#region src/edit/ppt/editor.ts
|
|
8
|
+
var PptEditor = class {
|
|
9
|
+
document;
|
|
10
|
+
constructor(document) {
|
|
11
|
+
if (document.kind !== "presentation") throw new Error(`PptEditor requires a presentation ContentDocument, got "${document.kind}"`);
|
|
12
|
+
this.document = document;
|
|
13
|
+
}
|
|
14
|
+
get metadata() {
|
|
15
|
+
return this.document.metadata;
|
|
16
|
+
}
|
|
17
|
+
set metadata(value) {
|
|
18
|
+
this.document.metadata = value;
|
|
19
|
+
}
|
|
20
|
+
slides() {
|
|
21
|
+
return this.document.slides.map((slide) => new PptSlide(this.document.slides, slide));
|
|
22
|
+
}
|
|
23
|
+
addSlide(size = SLIDE_SIZE_WIDESCREEN) {
|
|
24
|
+
const node = buildSlide(size);
|
|
25
|
+
this.document.slides.push(node);
|
|
26
|
+
return new PptSlide(this.document.slides, node);
|
|
27
|
+
}
|
|
28
|
+
removeSlideAt(index) {
|
|
29
|
+
this.document.slides.splice(index, 1);
|
|
30
|
+
}
|
|
31
|
+
toBytes() {
|
|
32
|
+
return writePptContent(this.document);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
function openPpt(bytes) {
|
|
36
|
+
return new PptEditor(readPptContent(bytes));
|
|
37
|
+
}
|
|
38
|
+
function createPpt(options = {}) {
|
|
39
|
+
const clock = options.clock ?? systemClock;
|
|
40
|
+
return new PptEditor({
|
|
41
|
+
kind: "presentation",
|
|
42
|
+
metadata: resolveMetadataTimestamps({}, clock),
|
|
43
|
+
slides: []
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
export { PptEditor, createPpt, openPpt };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_edit_doc_paragraph = require("../doc/paragraph.cjs");
|
|
3
|
+
//#region src/edit/ppt/slide.ts
|
|
4
|
+
var PptShape = class {
|
|
5
|
+
container;
|
|
6
|
+
node;
|
|
7
|
+
removed = false;
|
|
8
|
+
constructor(container, node) {
|
|
9
|
+
this.container = container;
|
|
10
|
+
this.node = node;
|
|
11
|
+
}
|
|
12
|
+
live() {
|
|
13
|
+
if (this.removed) throw new Error("this PptShape has been removed from its slide and can no longer be used");
|
|
14
|
+
return this.node;
|
|
15
|
+
}
|
|
16
|
+
get frame() {
|
|
17
|
+
return this.live().frame;
|
|
18
|
+
}
|
|
19
|
+
set frame(value) {
|
|
20
|
+
this.live().frame = value;
|
|
21
|
+
}
|
|
22
|
+
get rotationDeg() {
|
|
23
|
+
return this.live().rotationDeg;
|
|
24
|
+
}
|
|
25
|
+
paragraphs() {
|
|
26
|
+
return this.live().blocks.filter((block) => block.kind === "paragraph").map((block) => new require_edit_doc_paragraph.DocParagraph(this.live().blocks, block));
|
|
27
|
+
}
|
|
28
|
+
appendParagraph(init) {
|
|
29
|
+
const node = this.live();
|
|
30
|
+
const paragraph = require_edit_doc_paragraph.buildParagraph(init);
|
|
31
|
+
node.blocks.push(paragraph);
|
|
32
|
+
return new require_edit_doc_paragraph.DocParagraph(node.blocks, paragraph);
|
|
33
|
+
}
|
|
34
|
+
get text() {
|
|
35
|
+
return this.paragraphs().map((p) => p.text).join("\n");
|
|
36
|
+
}
|
|
37
|
+
set text(value) {
|
|
38
|
+
this.live().blocks = [require_edit_doc_paragraph.buildParagraph({ text: value })];
|
|
39
|
+
}
|
|
40
|
+
remove() {
|
|
41
|
+
const node = this.live();
|
|
42
|
+
const index = this.container.indexOf(node);
|
|
43
|
+
if (index !== -1) this.container.splice(index, 1);
|
|
44
|
+
this.removed = true;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
var PptSlide = class {
|
|
48
|
+
container;
|
|
49
|
+
node;
|
|
50
|
+
removed = false;
|
|
51
|
+
constructor(container, node) {
|
|
52
|
+
this.container = container;
|
|
53
|
+
this.node = node;
|
|
54
|
+
}
|
|
55
|
+
live() {
|
|
56
|
+
if (this.removed) throw new Error("this PptSlide has been removed from its presentation and can no longer be used");
|
|
57
|
+
return this.node;
|
|
58
|
+
}
|
|
59
|
+
get size() {
|
|
60
|
+
return this.live().size;
|
|
61
|
+
}
|
|
62
|
+
set size(value) {
|
|
63
|
+
this.live().size = value;
|
|
64
|
+
}
|
|
65
|
+
get notes() {
|
|
66
|
+
return this.live().notes;
|
|
67
|
+
}
|
|
68
|
+
set notes(value) {
|
|
69
|
+
this.live().notes = value;
|
|
70
|
+
}
|
|
71
|
+
shapes() {
|
|
72
|
+
return this.live().shapes.map((shape) => new PptShape(this.live().shapes, shape));
|
|
73
|
+
}
|
|
74
|
+
addTextBox(init) {
|
|
75
|
+
const node = this.live();
|
|
76
|
+
const shape = {
|
|
77
|
+
frame: init.frame,
|
|
78
|
+
insetLeftPt: 0,
|
|
79
|
+
insetTopPt: 0,
|
|
80
|
+
insetRightPt: 0,
|
|
81
|
+
insetBottomPt: 0,
|
|
82
|
+
blocks: [require_edit_doc_paragraph.buildParagraph({ text: init.text ?? "" })]
|
|
83
|
+
};
|
|
84
|
+
node.shapes.push(shape);
|
|
85
|
+
return new PptShape(node.shapes, shape);
|
|
86
|
+
}
|
|
87
|
+
remove() {
|
|
88
|
+
const node = this.live();
|
|
89
|
+
const index = this.container.indexOf(node);
|
|
90
|
+
if (index !== -1) this.container.splice(index, 1);
|
|
91
|
+
this.removed = true;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
function buildSlide(size) {
|
|
95
|
+
return {
|
|
96
|
+
size,
|
|
97
|
+
shapes: [],
|
|
98
|
+
notes: ""
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
exports.PptShape = PptShape;
|
|
103
|
+
exports.PptSlide = PptSlide;
|
|
104
|
+
exports.buildSlide = buildSlide;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { r as buildParagraph, t as DocParagraph } from "../../paragraph-DM9n9I4T.cjs";
|
|
2
|
+
import { Box, ContentShape, ContentSlide } from "document-schema.js";
|
|
3
|
+
//#region src/edit/ppt/slide.d.ts
|
|
4
|
+
interface TextBoxInit {
|
|
5
|
+
readonly frame: Box;
|
|
6
|
+
readonly text?: string;
|
|
7
|
+
}
|
|
8
|
+
declare class PptShape {
|
|
9
|
+
private readonly container;
|
|
10
|
+
private readonly node;
|
|
11
|
+
private removed;
|
|
12
|
+
constructor(container: ContentShape[], node: ContentShape);
|
|
13
|
+
private live;
|
|
14
|
+
get frame(): Box;
|
|
15
|
+
set frame(value: Box);
|
|
16
|
+
get rotationDeg(): number | undefined;
|
|
17
|
+
paragraphs(): DocParagraph[];
|
|
18
|
+
appendParagraph(init?: Parameters<typeof buildParagraph>[0]): DocParagraph;
|
|
19
|
+
get text(): string;
|
|
20
|
+
set text(value: string);
|
|
21
|
+
remove(): void;
|
|
22
|
+
}
|
|
23
|
+
declare class PptSlide {
|
|
24
|
+
private readonly container;
|
|
25
|
+
private readonly node;
|
|
26
|
+
private removed;
|
|
27
|
+
constructor(container: ContentSlide[], node: ContentSlide);
|
|
28
|
+
private live;
|
|
29
|
+
get size(): ContentSlide["size"];
|
|
30
|
+
set size(value: ContentSlide["size"]);
|
|
31
|
+
get notes(): string;
|
|
32
|
+
set notes(value: string);
|
|
33
|
+
shapes(): PptShape[];
|
|
34
|
+
addTextBox(init: TextBoxInit): PptShape;
|
|
35
|
+
remove(): void;
|
|
36
|
+
}
|
|
37
|
+
declare function buildSlide(size: ContentSlide["size"]): ContentSlide;
|
|
38
|
+
//#endregion
|
|
39
|
+
export { PptShape, PptSlide, TextBoxInit, buildSlide };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { r as buildParagraph, t as DocParagraph } from "../../paragraph-Byw2Y7xu.js";
|
|
2
|
+
import { Box, ContentShape, ContentSlide } from "document-schema.js";
|
|
3
|
+
//#region src/edit/ppt/slide.d.ts
|
|
4
|
+
interface TextBoxInit {
|
|
5
|
+
readonly frame: Box;
|
|
6
|
+
readonly text?: string;
|
|
7
|
+
}
|
|
8
|
+
declare class PptShape {
|
|
9
|
+
private readonly container;
|
|
10
|
+
private readonly node;
|
|
11
|
+
private removed;
|
|
12
|
+
constructor(container: ContentShape[], node: ContentShape);
|
|
13
|
+
private live;
|
|
14
|
+
get frame(): Box;
|
|
15
|
+
set frame(value: Box);
|
|
16
|
+
get rotationDeg(): number | undefined;
|
|
17
|
+
paragraphs(): DocParagraph[];
|
|
18
|
+
appendParagraph(init?: Parameters<typeof buildParagraph>[0]): DocParagraph;
|
|
19
|
+
get text(): string;
|
|
20
|
+
set text(value: string);
|
|
21
|
+
remove(): void;
|
|
22
|
+
}
|
|
23
|
+
declare class PptSlide {
|
|
24
|
+
private readonly container;
|
|
25
|
+
private readonly node;
|
|
26
|
+
private removed;
|
|
27
|
+
constructor(container: ContentSlide[], node: ContentSlide);
|
|
28
|
+
private live;
|
|
29
|
+
get size(): ContentSlide["size"];
|
|
30
|
+
set size(value: ContentSlide["size"]);
|
|
31
|
+
get notes(): string;
|
|
32
|
+
set notes(value: string);
|
|
33
|
+
shapes(): PptShape[];
|
|
34
|
+
addTextBox(init: TextBoxInit): PptShape;
|
|
35
|
+
remove(): void;
|
|
36
|
+
}
|
|
37
|
+
declare function buildSlide(size: ContentSlide["size"]): ContentSlide;
|
|
38
|
+
//#endregion
|
|
39
|
+
export { PptShape, PptSlide, TextBoxInit, buildSlide };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { DocParagraph, buildParagraph } from "../doc/paragraph.js";
|
|
2
|
+
//#region src/edit/ppt/slide.ts
|
|
3
|
+
var PptShape = class {
|
|
4
|
+
container;
|
|
5
|
+
node;
|
|
6
|
+
removed = false;
|
|
7
|
+
constructor(container, node) {
|
|
8
|
+
this.container = container;
|
|
9
|
+
this.node = node;
|
|
10
|
+
}
|
|
11
|
+
live() {
|
|
12
|
+
if (this.removed) throw new Error("this PptShape has been removed from its slide and can no longer be used");
|
|
13
|
+
return this.node;
|
|
14
|
+
}
|
|
15
|
+
get frame() {
|
|
16
|
+
return this.live().frame;
|
|
17
|
+
}
|
|
18
|
+
set frame(value) {
|
|
19
|
+
this.live().frame = value;
|
|
20
|
+
}
|
|
21
|
+
get rotationDeg() {
|
|
22
|
+
return this.live().rotationDeg;
|
|
23
|
+
}
|
|
24
|
+
paragraphs() {
|
|
25
|
+
return this.live().blocks.filter((block) => block.kind === "paragraph").map((block) => new DocParagraph(this.live().blocks, block));
|
|
26
|
+
}
|
|
27
|
+
appendParagraph(init) {
|
|
28
|
+
const node = this.live();
|
|
29
|
+
const paragraph = buildParagraph(init);
|
|
30
|
+
node.blocks.push(paragraph);
|
|
31
|
+
return new DocParagraph(node.blocks, paragraph);
|
|
32
|
+
}
|
|
33
|
+
get text() {
|
|
34
|
+
return this.paragraphs().map((p) => p.text).join("\n");
|
|
35
|
+
}
|
|
36
|
+
set text(value) {
|
|
37
|
+
this.live().blocks = [buildParagraph({ text: value })];
|
|
38
|
+
}
|
|
39
|
+
remove() {
|
|
40
|
+
const node = this.live();
|
|
41
|
+
const index = this.container.indexOf(node);
|
|
42
|
+
if (index !== -1) this.container.splice(index, 1);
|
|
43
|
+
this.removed = true;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
var PptSlide = class {
|
|
47
|
+
container;
|
|
48
|
+
node;
|
|
49
|
+
removed = false;
|
|
50
|
+
constructor(container, node) {
|
|
51
|
+
this.container = container;
|
|
52
|
+
this.node = node;
|
|
53
|
+
}
|
|
54
|
+
live() {
|
|
55
|
+
if (this.removed) throw new Error("this PptSlide has been removed from its presentation and can no longer be used");
|
|
56
|
+
return this.node;
|
|
57
|
+
}
|
|
58
|
+
get size() {
|
|
59
|
+
return this.live().size;
|
|
60
|
+
}
|
|
61
|
+
set size(value) {
|
|
62
|
+
this.live().size = value;
|
|
63
|
+
}
|
|
64
|
+
get notes() {
|
|
65
|
+
return this.live().notes;
|
|
66
|
+
}
|
|
67
|
+
set notes(value) {
|
|
68
|
+
this.live().notes = value;
|
|
69
|
+
}
|
|
70
|
+
shapes() {
|
|
71
|
+
return this.live().shapes.map((shape) => new PptShape(this.live().shapes, shape));
|
|
72
|
+
}
|
|
73
|
+
addTextBox(init) {
|
|
74
|
+
const node = this.live();
|
|
75
|
+
const shape = {
|
|
76
|
+
frame: init.frame,
|
|
77
|
+
insetLeftPt: 0,
|
|
78
|
+
insetTopPt: 0,
|
|
79
|
+
insetRightPt: 0,
|
|
80
|
+
insetBottomPt: 0,
|
|
81
|
+
blocks: [buildParagraph({ text: init.text ?? "" })]
|
|
82
|
+
};
|
|
83
|
+
node.shapes.push(shape);
|
|
84
|
+
return new PptShape(node.shapes, shape);
|
|
85
|
+
}
|
|
86
|
+
remove() {
|
|
87
|
+
const node = this.live();
|
|
88
|
+
const index = this.container.indexOf(node);
|
|
89
|
+
if (index !== -1) this.container.splice(index, 1);
|
|
90
|
+
this.removed = true;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
function buildSlide(size) {
|
|
94
|
+
return {
|
|
95
|
+
size,
|
|
96
|
+
shapes: [],
|
|
97
|
+
notes: ""
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
101
|
+
export { PptShape, PptSlide, buildSlide };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/edit/xls/cell.ts
|
|
3
|
+
function displayTextOfValue(value) {
|
|
4
|
+
switch (value.kind) {
|
|
5
|
+
case "empty": return "";
|
|
6
|
+
case "boolean": return value.value ? "TRUE" : "FALSE";
|
|
7
|
+
case "number":
|
|
8
|
+
case "percentage":
|
|
9
|
+
case "currency": return String(value.value);
|
|
10
|
+
default: return value.value;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
var XlsCell = class {
|
|
14
|
+
container;
|
|
15
|
+
node;
|
|
16
|
+
removed = false;
|
|
17
|
+
constructor(container, node) {
|
|
18
|
+
this.container = container;
|
|
19
|
+
this.node = node;
|
|
20
|
+
}
|
|
21
|
+
live() {
|
|
22
|
+
if (this.removed) throw new Error("this XlsCell has been removed from its sheet and can no longer be used");
|
|
23
|
+
return this.node;
|
|
24
|
+
}
|
|
25
|
+
get row() {
|
|
26
|
+
return this.live().row;
|
|
27
|
+
}
|
|
28
|
+
get column() {
|
|
29
|
+
return this.live().column;
|
|
30
|
+
}
|
|
31
|
+
get value() {
|
|
32
|
+
return this.live().value;
|
|
33
|
+
}
|
|
34
|
+
set value(value) {
|
|
35
|
+
const node = this.live();
|
|
36
|
+
node.value = value;
|
|
37
|
+
node.displayText = displayTextOfValue(value);
|
|
38
|
+
}
|
|
39
|
+
get displayText() {
|
|
40
|
+
return this.live().displayText;
|
|
41
|
+
}
|
|
42
|
+
set displayText(text) {
|
|
43
|
+
this.live().displayText = text;
|
|
44
|
+
}
|
|
45
|
+
get numberFormatCode() {
|
|
46
|
+
return this.live().numberFormatCode;
|
|
47
|
+
}
|
|
48
|
+
set numberFormatCode(code) {
|
|
49
|
+
const node = this.live();
|
|
50
|
+
if (code === void 0) delete node.numberFormatCode;
|
|
51
|
+
else node.numberFormatCode = code;
|
|
52
|
+
}
|
|
53
|
+
get formula() {
|
|
54
|
+
return this.live().formula;
|
|
55
|
+
}
|
|
56
|
+
get colSpan() {
|
|
57
|
+
return this.live().colSpan;
|
|
58
|
+
}
|
|
59
|
+
set colSpan(value) {
|
|
60
|
+
const node = this.live();
|
|
61
|
+
if (value === void 0) delete node.colSpan;
|
|
62
|
+
else node.colSpan = value;
|
|
63
|
+
}
|
|
64
|
+
get rowSpan() {
|
|
65
|
+
return this.live().rowSpan;
|
|
66
|
+
}
|
|
67
|
+
set rowSpan(value) {
|
|
68
|
+
const node = this.live();
|
|
69
|
+
if (value === void 0) delete node.rowSpan;
|
|
70
|
+
else node.rowSpan = value;
|
|
71
|
+
}
|
|
72
|
+
get background() {
|
|
73
|
+
return this.live().background;
|
|
74
|
+
}
|
|
75
|
+
set background(fill) {
|
|
76
|
+
const node = this.live();
|
|
77
|
+
if (fill === void 0) delete node.background;
|
|
78
|
+
else node.background = fill;
|
|
79
|
+
}
|
|
80
|
+
get borders() {
|
|
81
|
+
return this.live().borders;
|
|
82
|
+
}
|
|
83
|
+
set borders(value) {
|
|
84
|
+
const node = this.live();
|
|
85
|
+
if (value === void 0) delete node.borders;
|
|
86
|
+
else node.borders = value;
|
|
87
|
+
}
|
|
88
|
+
get alignment() {
|
|
89
|
+
return this.live().alignment;
|
|
90
|
+
}
|
|
91
|
+
set alignment(value) {
|
|
92
|
+
const node = this.live();
|
|
93
|
+
if (value === void 0) delete node.alignment;
|
|
94
|
+
else node.alignment = value;
|
|
95
|
+
}
|
|
96
|
+
get comment() {
|
|
97
|
+
return this.live().comment;
|
|
98
|
+
}
|
|
99
|
+
set comment(value) {
|
|
100
|
+
const node = this.live();
|
|
101
|
+
if (value === void 0) delete node.comment;
|
|
102
|
+
else node.comment = value;
|
|
103
|
+
}
|
|
104
|
+
remove() {
|
|
105
|
+
const node = this.live();
|
|
106
|
+
const index = this.container.indexOf(node);
|
|
107
|
+
if (index !== -1) this.container.splice(index, 1);
|
|
108
|
+
this.removed = true;
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
//#endregion
|
|
112
|
+
exports.XlsCell = XlsCell;
|
|
113
|
+
exports.displayTextOfValue = displayTextOfValue;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
//#region src/edit/xls/cell.ts
|
|
2
|
+
function displayTextOfValue(value) {
|
|
3
|
+
switch (value.kind) {
|
|
4
|
+
case "empty": return "";
|
|
5
|
+
case "boolean": return value.value ? "TRUE" : "FALSE";
|
|
6
|
+
case "number":
|
|
7
|
+
case "percentage":
|
|
8
|
+
case "currency": return String(value.value);
|
|
9
|
+
default: return value.value;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
var XlsCell = class {
|
|
13
|
+
container;
|
|
14
|
+
node;
|
|
15
|
+
removed = false;
|
|
16
|
+
constructor(container, node) {
|
|
17
|
+
this.container = container;
|
|
18
|
+
this.node = node;
|
|
19
|
+
}
|
|
20
|
+
live() {
|
|
21
|
+
if (this.removed) throw new Error("this XlsCell has been removed from its sheet and can no longer be used");
|
|
22
|
+
return this.node;
|
|
23
|
+
}
|
|
24
|
+
get row() {
|
|
25
|
+
return this.live().row;
|
|
26
|
+
}
|
|
27
|
+
get column() {
|
|
28
|
+
return this.live().column;
|
|
29
|
+
}
|
|
30
|
+
get value() {
|
|
31
|
+
return this.live().value;
|
|
32
|
+
}
|
|
33
|
+
set value(value) {
|
|
34
|
+
const node = this.live();
|
|
35
|
+
node.value = value;
|
|
36
|
+
node.displayText = displayTextOfValue(value);
|
|
37
|
+
}
|
|
38
|
+
get displayText() {
|
|
39
|
+
return this.live().displayText;
|
|
40
|
+
}
|
|
41
|
+
set displayText(text) {
|
|
42
|
+
this.live().displayText = text;
|
|
43
|
+
}
|
|
44
|
+
get numberFormatCode() {
|
|
45
|
+
return this.live().numberFormatCode;
|
|
46
|
+
}
|
|
47
|
+
set numberFormatCode(code) {
|
|
48
|
+
const node = this.live();
|
|
49
|
+
if (code === void 0) delete node.numberFormatCode;
|
|
50
|
+
else node.numberFormatCode = code;
|
|
51
|
+
}
|
|
52
|
+
get formula() {
|
|
53
|
+
return this.live().formula;
|
|
54
|
+
}
|
|
55
|
+
get colSpan() {
|
|
56
|
+
return this.live().colSpan;
|
|
57
|
+
}
|
|
58
|
+
set colSpan(value) {
|
|
59
|
+
const node = this.live();
|
|
60
|
+
if (value === void 0) delete node.colSpan;
|
|
61
|
+
else node.colSpan = value;
|
|
62
|
+
}
|
|
63
|
+
get rowSpan() {
|
|
64
|
+
return this.live().rowSpan;
|
|
65
|
+
}
|
|
66
|
+
set rowSpan(value) {
|
|
67
|
+
const node = this.live();
|
|
68
|
+
if (value === void 0) delete node.rowSpan;
|
|
69
|
+
else node.rowSpan = value;
|
|
70
|
+
}
|
|
71
|
+
get background() {
|
|
72
|
+
return this.live().background;
|
|
73
|
+
}
|
|
74
|
+
set background(fill) {
|
|
75
|
+
const node = this.live();
|
|
76
|
+
if (fill === void 0) delete node.background;
|
|
77
|
+
else node.background = fill;
|
|
78
|
+
}
|
|
79
|
+
get borders() {
|
|
80
|
+
return this.live().borders;
|
|
81
|
+
}
|
|
82
|
+
set borders(value) {
|
|
83
|
+
const node = this.live();
|
|
84
|
+
if (value === void 0) delete node.borders;
|
|
85
|
+
else node.borders = value;
|
|
86
|
+
}
|
|
87
|
+
get alignment() {
|
|
88
|
+
return this.live().alignment;
|
|
89
|
+
}
|
|
90
|
+
set alignment(value) {
|
|
91
|
+
const node = this.live();
|
|
92
|
+
if (value === void 0) delete node.alignment;
|
|
93
|
+
else node.alignment = value;
|
|
94
|
+
}
|
|
95
|
+
get comment() {
|
|
96
|
+
return this.live().comment;
|
|
97
|
+
}
|
|
98
|
+
set comment(value) {
|
|
99
|
+
const node = this.live();
|
|
100
|
+
if (value === void 0) delete node.comment;
|
|
101
|
+
else node.comment = value;
|
|
102
|
+
}
|
|
103
|
+
remove() {
|
|
104
|
+
const node = this.live();
|
|
105
|
+
const index = this.container.indexOf(node);
|
|
106
|
+
if (index !== -1) this.container.splice(index, 1);
|
|
107
|
+
this.removed = true;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
//#endregion
|
|
111
|
+
export { XlsCell, displayTextOfValue };
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_model_metadata = require("../../model/metadata.cjs");
|
|
3
|
+
const require_ports_clock = require("../../ports/clock.cjs");
|
|
4
|
+
const require_edit_xls_sheet = require("./sheet.cjs");
|
|
5
|
+
let document_schema_js = require("document-schema.js");
|
|
6
|
+
let xls_codec = require("xls-codec");
|
|
7
|
+
//#region src/edit/xls/editor.ts
|
|
8
|
+
const DEFAULT_PRINT_SETTINGS = {
|
|
9
|
+
pageSize: document_schema_js.PAGE_SIZE_LETTER,
|
|
10
|
+
margins: {
|
|
11
|
+
topPt: 72,
|
|
12
|
+
rightPt: 72,
|
|
13
|
+
bottomPt: 72,
|
|
14
|
+
leftPt: 72
|
|
15
|
+
},
|
|
16
|
+
gridlines: true,
|
|
17
|
+
headers: true,
|
|
18
|
+
pageOrder: "downThenOver"
|
|
19
|
+
};
|
|
20
|
+
var XlsEditor = class {
|
|
21
|
+
document;
|
|
22
|
+
constructor(document) {
|
|
23
|
+
if (document.kind !== "spreadsheet") throw new Error(`XlsEditor requires a spreadsheet ContentDocument, got "${document.kind}"`);
|
|
24
|
+
if (document.sheets.length === 0) throw new Error("an xls workbook must carry at least one sheet");
|
|
25
|
+
this.document = document;
|
|
26
|
+
}
|
|
27
|
+
get metadata() {
|
|
28
|
+
return this.document.metadata;
|
|
29
|
+
}
|
|
30
|
+
set metadata(value) {
|
|
31
|
+
this.document.metadata = value;
|
|
32
|
+
}
|
|
33
|
+
sheets() {
|
|
34
|
+
return this.document.sheets.map((sheet) => new require_edit_xls_sheet.XlsSheet(this.document.sheets, sheet));
|
|
35
|
+
}
|
|
36
|
+
sheet(name) {
|
|
37
|
+
const found = this.document.sheets.find((sheet) => sheet.name === name);
|
|
38
|
+
return found === void 0 ? void 0 : new require_edit_xls_sheet.XlsSheet(this.document.sheets, found);
|
|
39
|
+
}
|
|
40
|
+
addSheet(name) {
|
|
41
|
+
const node = {
|
|
42
|
+
name,
|
|
43
|
+
cells: [],
|
|
44
|
+
columns: [],
|
|
45
|
+
rows: [],
|
|
46
|
+
images: [],
|
|
47
|
+
printSettings: structuredClone(DEFAULT_PRINT_SETTINGS)
|
|
48
|
+
};
|
|
49
|
+
this.document.sheets.push(node);
|
|
50
|
+
return new require_edit_xls_sheet.XlsSheet(this.document.sheets, node);
|
|
51
|
+
}
|
|
52
|
+
removeSheetAt(index) {
|
|
53
|
+
if (this.document.sheets.length === 1) throw new Error("an xls workbook must carry at least one sheet; the last one cannot be removed");
|
|
54
|
+
this.document.sheets.splice(index, 1);
|
|
55
|
+
}
|
|
56
|
+
toBytes() {
|
|
57
|
+
return (0, xls_codec.writeXlsContent)(this.document);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
function openXls(bytes, password) {
|
|
61
|
+
return new XlsEditor((0, xls_codec.readXlsContent)(bytes, password));
|
|
62
|
+
}
|
|
63
|
+
function createXls(options = {}) {
|
|
64
|
+
const clock = options.clock ?? require_ports_clock.systemClock;
|
|
65
|
+
return new XlsEditor({
|
|
66
|
+
kind: "spreadsheet",
|
|
67
|
+
metadata: require_model_metadata.resolveMetadataTimestamps({}, clock),
|
|
68
|
+
sheets: [{
|
|
69
|
+
name: "Sheet1",
|
|
70
|
+
cells: [],
|
|
71
|
+
columns: [],
|
|
72
|
+
rows: [],
|
|
73
|
+
images: [],
|
|
74
|
+
printSettings: structuredClone(DEFAULT_PRINT_SETTINGS)
|
|
75
|
+
}]
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
exports.XlsEditor = XlsEditor;
|
|
80
|
+
exports.createXls = createXls;
|
|
81
|
+
exports.openXls = openXls;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { t as ClockPort } from "../../clock-C7SUuYN0.cjs";
|
|
2
|
+
import { XlsSheet } from "./sheet.cjs";
|
|
3
|
+
import { ContentDocument, LayoutMetadata } from "document-schema.js";
|
|
4
|
+
//#region src/edit/xls/editor.d.ts
|
|
5
|
+
interface CreateXlsOptions {
|
|
6
|
+
readonly clock?: ClockPort;
|
|
7
|
+
}
|
|
8
|
+
declare class XlsEditor {
|
|
9
|
+
private readonly document;
|
|
10
|
+
constructor(document: ContentDocument);
|
|
11
|
+
get metadata(): LayoutMetadata;
|
|
12
|
+
set metadata(value: LayoutMetadata);
|
|
13
|
+
sheets(): XlsSheet[];
|
|
14
|
+
sheet(name: string): XlsSheet | undefined;
|
|
15
|
+
addSheet(name: string): XlsSheet;
|
|
16
|
+
removeSheetAt(index: number): void;
|
|
17
|
+
toBytes(): Uint8Array<ArrayBuffer>;
|
|
18
|
+
}
|
|
19
|
+
declare function openXls(bytes: Uint8Array<ArrayBuffer>, password?: string): XlsEditor;
|
|
20
|
+
declare function createXls(options?: CreateXlsOptions): XlsEditor;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { CreateXlsOptions, XlsEditor, createXls, openXls };
|