oasis-editor 0.0.107 → 0.0.109
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/{OasisEditorApp-BFNqDc07.js → OasisEditorApp-vuSkxc37.js} +1336 -494
- package/dist/assets/{importDocxWorker-thqRCD9m.js → importDocxWorker-BF8VtQ9h.js} +1 -1
- package/dist/core/color.d.ts +9 -0
- package/dist/core/units.d.ts +8 -0
- package/dist/export/pdf/OasisPdfWriter.d.ts +23 -2
- package/dist/export/pdf/draw/drawBlockList.d.ts +1 -1
- package/dist/export/pdf/units.d.ts +2 -1
- package/dist/export/pdf/writer/PdfDocumentSerializer.d.ts +2 -2
- package/dist/export/pdf/writer/pdfTypes.d.ts +55 -3
- package/dist/i18n/locales/en.d.ts +10 -0
- package/dist/i18n/locales/pt-BR.d.ts +10 -0
- package/dist/import/docx/units.d.ts +6 -2
- package/dist/{index-4uLtMJwI.js → index-9yDGAODt.js} +1555 -927
- package/dist/oasis-editor.css +1 -1
- package/dist/oasis-editor.js +50 -50
- package/dist/oasis-editor.umd.cjs +4 -4
- package/dist/ui/components/Toolbar/ShapeGallery.d.ts +11 -0
- package/dist/ui/components/Toolbar/recentShapes.d.ts +8 -0
- package/dist/ui/components/Toolbar/shapeCatalog.d.ts +23 -0
- package/dist/ui/components/Toolbar/shapePreview.d.ts +16 -0
- package/dist/ui/textMeasurement/constants.d.ts +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Strips an optional leading `#` and surrounding whitespace. */
|
|
2
|
+
export declare function stripHashPrefix(color: string): string;
|
|
3
|
+
/**
|
|
4
|
+
* Parses a `#RRGGBB` (or `RRGGBB`) hex color into 0–255 integer RGB channels.
|
|
5
|
+
* Returns `null` when the input is not a valid 6-digit hex color.
|
|
6
|
+
*/
|
|
7
|
+
export declare function parseHexColorToRgb255(color: string | null | undefined): [number, number, number] | null;
|
|
8
|
+
/** Formats 0–255 integer RGB channels as a lowercase `#rrggbb` string. */
|
|
9
|
+
export declare function rgb255ToHex(r: number, g: number, b: number): string;
|
package/dist/core/units.d.ts
CHANGED
|
@@ -16,3 +16,11 @@ export declare const EMU_PER_PT = 12700;
|
|
|
16
16
|
export declare const TWIPS_PER_INCH = 1440;
|
|
17
17
|
/** Twentieths of a point ("twips") per typographic point. */
|
|
18
18
|
export declare const TWIPS_PER_POINT = 20;
|
|
19
|
+
/**
|
|
20
|
+
* Default document font size in CSS pixels: 11pt (the Calibri default used by
|
|
21
|
+
* Word) expressed as `11 * 96 / 72 ≈ 14.6667`. Single source of truth for the
|
|
22
|
+
* value that was previously redefined across the core, layout, canvas, import,
|
|
23
|
+
* export and testing layers (audit #1). Kept as the historical rounded literal
|
|
24
|
+
* `14.6667` so layout measurements remain byte-identical.
|
|
25
|
+
*/
|
|
26
|
+
export declare const DEFAULT_FONT_SIZE_PX = 14.6667;
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import { OasisPdfAxialGradient, OasisPdfFontResource, OasisPdfImageOptions, OasisPdfImageResource, OasisPdfLineOptions, OasisPdfPageSize, OasisPdfPathOptions, OasisPdfRectOptions, OasisPdfTextOptions } from './writer/pdfTypes.js';
|
|
1
|
+
import { OasisPdfAxialGradient, OasisPdfLinkAnnotation, OasisPdfNamedDestination, OasisPdfOutlineItem, OasisPdfDocumentInfo, OasisPdfFontResource, OasisPdfImageOptions, OasisPdfImageResource, OasisPdfLineOptions, OasisPdfPageSize, OasisPdfPathOptions, OasisPdfRectOptions, OasisPdfTextOptions } from './writer/pdfTypes.js';
|
|
2
2
|
|
|
3
|
-
export type { OasisPdfPageSize, OasisPdfPage, OasisPdfRectOptions, OasisPdfLineOptions, OasisPdfPathSegment, OasisPdfPathOptions, OasisPdfTextOptions, OasisPdfImageResource, OasisPdfImageOptions, OasisPdfFontResource, OasisPdfBase14FontResource, OasisPdfUnicodeFontResource, } from './writer/pdfTypes.js';
|
|
3
|
+
export type { OasisPdfPageSize, OasisPdfPage, OasisPdfRectOptions, OasisPdfLineOptions, OasisPdfPathSegment, OasisPdfPathOptions, OasisPdfTextOptions, OasisPdfImageResource, OasisPdfImageOptions, OasisPdfFontResource, OasisPdfBase14FontResource, OasisPdfUnicodeFontResource, OasisPdfLinkAnnotation, OasisPdfAnnotation, OasisPdfNamedDestination, OasisPdfOutlineItem, OasisPdfDocumentInfo, } from './writer/pdfTypes.js';
|
|
4
4
|
export declare class OasisPdfWriter {
|
|
5
5
|
private readonly pages;
|
|
6
6
|
private readonly streams;
|
|
7
7
|
private readonly fonts;
|
|
8
8
|
private readonly images;
|
|
9
9
|
private readonly shadings;
|
|
10
|
+
private readonly namedDestinations;
|
|
11
|
+
private readonly outlineItems;
|
|
12
|
+
private documentInfo;
|
|
10
13
|
constructor(fontResources?: OasisPdfFontResource[]);
|
|
11
14
|
registerFontResource(resource: OasisPdfFontResource): void;
|
|
12
15
|
addPage(size: OasisPdfPageSize): number;
|
|
@@ -29,6 +32,24 @@ export declare class OasisPdfWriter {
|
|
|
29
32
|
resourceName?: string;
|
|
30
33
|
}): string;
|
|
31
34
|
drawImage(pageIndex: number, options: OasisPdfImageOptions): void;
|
|
35
|
+
/**
|
|
36
|
+
* Attaches a clickable external link annotation to a page. The rect is in the
|
|
37
|
+
* writer's top-left point space; the serializer flips it to PDF space.
|
|
38
|
+
*/
|
|
39
|
+
addLinkAnnotation(pageIndex: number, annotation: OasisPdfLinkAnnotation): void;
|
|
40
|
+
/**
|
|
41
|
+
* Registers a named destination (jump target). Position is in the writer's
|
|
42
|
+
* top-left point space. The first registration of a given name wins; later
|
|
43
|
+
* duplicates are ignored so destinations stay unique in the names tree.
|
|
44
|
+
*/
|
|
45
|
+
addNamedDestination(destination: OasisPdfNamedDestination): void;
|
|
46
|
+
/**
|
|
47
|
+
* Appends an outline (bookmarks-panel) entry. Call in document order; the
|
|
48
|
+
* serializer nests entries by `level`.
|
|
49
|
+
*/
|
|
50
|
+
addOutlineItem(item: OasisPdfOutlineItem): void;
|
|
51
|
+
/** Sets the document information dictionary (`/Info`). */
|
|
52
|
+
setDocumentInfo(info: OasisPdfDocumentInfo): void;
|
|
32
53
|
toArrayBuffer(): ArrayBuffer;
|
|
33
54
|
toBlob(): Blob;
|
|
34
55
|
private toUint8Array;
|
|
@@ -2,4 +2,4 @@ import { EditorDocument, EditorLayoutBlock, EditorPageSettings } from '../../../
|
|
|
2
2
|
import { PdfFontRegistry } from '../fonts/PdfFontRegistry.js';
|
|
3
3
|
import { OasisPdfWriter } from '../OasisPdfWriter.js';
|
|
4
4
|
|
|
5
|
-
export declare function drawBlockList(writer: OasisPdfWriter, pageIndex: number, blocks: EditorLayoutBlock[] | undefined, document: EditorDocument, originX: number, originY: number, contentWidth: number, fontRegistry: PdfFontRegistry, listOrdinals: Map<string, string>, pageSettings?: EditorPageSettings): Promise<void>;
|
|
5
|
+
export declare function drawBlockList(writer: OasisPdfWriter, pageIndex: number, blocks: EditorLayoutBlock[] | undefined, document: EditorDocument, originX: number, originY: number, contentWidth: number, fontRegistry: PdfFontRegistry, listOrdinals: Map<string, string>, pageSettings?: EditorPageSettings, onParagraphDrawn?: (paragraphId: string, topPx: number) => void): Promise<void>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { EditorTextStyle } from '../../core/model.js';
|
|
2
|
+
import { DEFAULT_FONT_SIZE_PX } from '../../core/units.js';
|
|
2
3
|
|
|
3
4
|
/** Points per pixel (72 / 96). Named PX_TO_PT for historical call sites. */
|
|
4
5
|
export declare const PX_TO_PT: number;
|
|
5
|
-
export
|
|
6
|
+
export { DEFAULT_FONT_SIZE_PX };
|
|
6
7
|
export declare function pxToPt(value: number): number;
|
|
7
8
|
export declare function ptToPx(value: number): number;
|
|
8
9
|
export declare function textStyleToFontSizePt(style: Required<EditorTextStyle>): number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { OasisPdfPage } from './pdfTypes.js';
|
|
1
|
+
import { OasisPdfDocumentInfo, OasisPdfNamedDestination, OasisPdfOutlineItem, OasisPdfPage } from './pdfTypes.js';
|
|
2
2
|
import { PdfFontTable } from './PdfFontTable.js';
|
|
3
3
|
import { PdfImageTable } from './PdfImageTable.js';
|
|
4
4
|
import { PdfShadingTable } from './PdfShadingTable.js';
|
|
5
5
|
|
|
6
|
-
export declare function serializePdfDocument(pages: OasisPdfPage[], fonts: PdfFontTable, images: PdfImageTable, shadings: PdfShadingTable): Uint8Array;
|
|
6
|
+
export declare function serializePdfDocument(pages: OasisPdfPage[], fonts: PdfFontTable, images: PdfImageTable, shadings: PdfShadingTable, namedDestinations?: OasisPdfNamedDestination[], outlineItems?: OasisPdfOutlineItem[], documentInfo?: OasisPdfDocumentInfo): Uint8Array;
|
|
@@ -13,6 +13,54 @@ export interface OasisPdfPage {
|
|
|
13
13
|
commands: string[];
|
|
14
14
|
imageResourceNames: Set<string>;
|
|
15
15
|
shadingResourceNames: Set<string>;
|
|
16
|
+
annotations: OasisPdfAnnotation[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A clickable link annotation. The rect is given in the writer's top-left point
|
|
20
|
+
* space (same convention as drawing); the serializer flips y to PDF bottom-left
|
|
21
|
+
* space and emits the `[x1 y1 x2 y2]` `/Rect`. Exactly one of `uri` (external)
|
|
22
|
+
* or `destName` (internal named destination) is set.
|
|
23
|
+
*/
|
|
24
|
+
export interface OasisPdfLinkAnnotation {
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
width: number;
|
|
28
|
+
height: number;
|
|
29
|
+
/** External target (`/URI` action). */
|
|
30
|
+
uri?: string;
|
|
31
|
+
/** Internal target: a named destination resolved via the `/Dests` name tree. */
|
|
32
|
+
destName?: string;
|
|
33
|
+
}
|
|
34
|
+
export type OasisPdfAnnotation = OasisPdfLinkAnnotation;
|
|
35
|
+
/**
|
|
36
|
+
* A named destination (a jump target for internal links / the outline). Position
|
|
37
|
+
* is in the writer's top-left point space; the serializer flips y and binds it to
|
|
38
|
+
* the page object as a `/XYZ` destination.
|
|
39
|
+
*/
|
|
40
|
+
export interface OasisPdfNamedDestination {
|
|
41
|
+
name: string;
|
|
42
|
+
pageIndex: number;
|
|
43
|
+
x: number;
|
|
44
|
+
y: number;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* One entry in the document outline (bookmarks panel). Items are supplied in
|
|
48
|
+
* document order; the serializer folds them into a nested tree by `level` (1 =
|
|
49
|
+
* top level). `destName` references a registered named destination.
|
|
50
|
+
*/
|
|
51
|
+
export interface OasisPdfOutlineItem {
|
|
52
|
+
title: string;
|
|
53
|
+
level: number;
|
|
54
|
+
destName: string;
|
|
55
|
+
}
|
|
56
|
+
/** Document information dictionary (`/Info`). All fields optional. */
|
|
57
|
+
export interface OasisPdfDocumentInfo {
|
|
58
|
+
title?: string;
|
|
59
|
+
author?: string;
|
|
60
|
+
subject?: string;
|
|
61
|
+
keywords?: string;
|
|
62
|
+
producer?: string;
|
|
63
|
+
creationDate?: Date;
|
|
16
64
|
}
|
|
17
65
|
/** One color stop of an axial gradient. `offset` is 0–1; `color` is a hex string. */
|
|
18
66
|
export interface OasisPdfGradientStop {
|
|
@@ -131,10 +179,14 @@ export interface OasisPdfUnicodeFontResource {
|
|
|
131
179
|
fontData: Uint8Array;
|
|
132
180
|
postscriptName?: string;
|
|
133
181
|
}
|
|
134
|
-
/**
|
|
182
|
+
/**
|
|
183
|
+
* A serialized indirect PDF object: its 1-based id and dictionary/stream body.
|
|
184
|
+
* The body is a string for text objects, or raw bytes when it embeds a binary
|
|
185
|
+
* (e.g. FlateDecode-compressed) stream that must not pass through UTF-8 encoding.
|
|
186
|
+
*/
|
|
135
187
|
export interface PdfObject {
|
|
136
188
|
id: number;
|
|
137
|
-
body: string;
|
|
189
|
+
body: string | Uint8Array;
|
|
138
190
|
}
|
|
139
191
|
/** Signature of the object-appending closure used during serialization. */
|
|
140
|
-
export type AddPdfObject = (body: string) => number;
|
|
192
|
+
export type AddPdfObject = (body: string | Uint8Array) => number;
|
|
@@ -14,6 +14,16 @@ export declare const en: {
|
|
|
14
14
|
"toolbar.shape.triangle": string;
|
|
15
15
|
"toolbar.shape.rtTriangle": string;
|
|
16
16
|
"toolbar.shape.diamond": string;
|
|
17
|
+
"toolbar.shapes.recentlyUsed": string;
|
|
18
|
+
"toolbar.shapes.lines": string;
|
|
19
|
+
"toolbar.shapes.rectangles": string;
|
|
20
|
+
"toolbar.shapes.basicShapes": string;
|
|
21
|
+
"toolbar.shapes.blockArrows": string;
|
|
22
|
+
"toolbar.shapes.equation": string;
|
|
23
|
+
"toolbar.shapes.flowchart": string;
|
|
24
|
+
"toolbar.shapes.starsAndBanners": string;
|
|
25
|
+
"toolbar.shapes.callouts": string;
|
|
26
|
+
"locale.id": string;
|
|
17
27
|
"toolbar.table": string;
|
|
18
28
|
"toolbar.pageNumber": string;
|
|
19
29
|
"toolbar.totalPages": string;
|
|
@@ -14,6 +14,16 @@ export declare const ptBR: {
|
|
|
14
14
|
"toolbar.shape.triangle": string;
|
|
15
15
|
"toolbar.shape.rtTriangle": string;
|
|
16
16
|
"toolbar.shape.diamond": string;
|
|
17
|
+
"toolbar.shapes.recentlyUsed": string;
|
|
18
|
+
"toolbar.shapes.lines": string;
|
|
19
|
+
"toolbar.shapes.rectangles": string;
|
|
20
|
+
"toolbar.shapes.basicShapes": string;
|
|
21
|
+
"toolbar.shapes.blockArrows": string;
|
|
22
|
+
"toolbar.shapes.equation": string;
|
|
23
|
+
"toolbar.shapes.flowchart": string;
|
|
24
|
+
"toolbar.shapes.starsAndBanners": string;
|
|
25
|
+
"toolbar.shapes.callouts": string;
|
|
26
|
+
"locale.id": string;
|
|
17
27
|
"toolbar.table": string;
|
|
18
28
|
"toolbar.pageNumber": string;
|
|
19
29
|
"toolbar.totalPages": string;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { TWIPS_PER_INCH, PX_PER_INCH } from '../../core/units.js';
|
|
1
|
+
import { TWIPS_PER_INCH, PX_PER_INCH, EMU_PER_PT } from '../../core/units.js';
|
|
2
2
|
|
|
3
|
-
export { TWIPS_PER_INCH, PX_PER_INCH };
|
|
3
|
+
export { TWIPS_PER_INCH, PX_PER_INCH, EMU_PER_PT };
|
|
4
|
+
/** OOXML thousandths-of-a-percent denominator (`100000` == 100%). */
|
|
5
|
+
export declare const OOXML_PERCENT_DENOMINATOR = 100000;
|
|
6
|
+
/** OOXML angle units (60000ths of a degree). */
|
|
7
|
+
export declare const OOXML_ROTATION_UNITS = 60000;
|
|
4
8
|
export declare const PAGE_BREAK_MARKER = "\f";
|
|
5
9
|
export declare const DOCX_IMPLICIT_SINGLE_LINE_HEIGHT = 1.1;
|
|
6
10
|
export declare function twipsToPx(value: string | null | undefined, fallback: number): number;
|