oasis-editor 0.0.10 → 0.0.12

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.
@@ -1,2 +1,2 @@
1
- export declare const OASIS_BUILTIN_COMMANDS: readonly ["selectAll", "insertFootnote", "pastePlainText", "bold", "italic", "underline", "strike", "superscript", "subscript", "link", "unlink", "alignLeft", "alignCenter", "alignRight", "alignJustify", "orderedList", "bulletList", "find", "replace", "toggleTrackChanges", "acceptRevisions", "rejectRevisions", "toggleShowMargins", "toggleShowParagraphMarks", "togglePreciseFonts", "undo", "redo", "pageBreak", "lineBreak", "splitBlock", "setFontFamily", "setFontSize", "increaseFontSize", "decreaseFontSize", "changeTextCase", "clearFormatting", "setColor", "setHighlight", "setTextShading", "setStyleId", "setUnderlineStyle", "documentStyles", "print", "copy", "exportDocx", "exportPdf", "importDocument", "insertImage", "editImageAlt", "outdent", "indent", "togglePageBreakBefore", "toggleKeepWithNext", "setSpacingAfter", "setSpacingBefore", "setIndentLeft", "setIndentRight", "setIndentFirstLine", "setIndentHanging", "setParagraphShading", "applyParagraphBorders", "setLineHeight", "setListFormat", "setListStartAt", "toggleOrientation", "sectionBreakNextPage", "sectionBreakContinuous", "setPageMargins", "tableContext", "tableMerge", "tableSplit", "tableInsertColumnBefore", "tableInsertColumnAfter", "tableDeleteColumn", "tableInsertRowBefore", "tableInsertRowAfter", "tableDeleteRow", "tableCellShading", "tableCellBorders", "tableCellNoBorders", "tableWidth100", "tableAlignLeft", "tableAlignCenter", "tableAlignRight", "tableSetCellWidth", "insertTable"];
1
+ export declare const OASIS_BUILTIN_COMMANDS: readonly ["selectAll", "insertFootnote", "pastePlainText", "bold", "italic", "underline", "strike", "superscript", "subscript", "link", "unlink", "alignLeft", "alignCenter", "alignRight", "alignJustify", "orderedList", "bulletList", "find", "replace", "toggleTrackChanges", "acceptRevisions", "rejectRevisions", "toggleShowMargins", "toggleShowParagraphMarks", "togglePreciseFonts", "undo", "redo", "pageBreak", "lineBreak", "splitBlock", "setFontFamily", "setFontSize", "increaseFontSize", "decreaseFontSize", "changeTextCase", "clearFormatting", "setColor", "setHighlight", "setTextShading", "setStyleId", "setUnderlineStyle", "documentStyles", "print", "copy", "exportDocx", "exportPdf", "importDocument", "insertImage", "editImageAlt", "insertImageCaption", "outdent", "indent", "togglePageBreakBefore", "toggleKeepWithNext", "setSpacingAfter", "setSpacingBefore", "setIndentLeft", "setIndentRight", "setIndentFirstLine", "setIndentHanging", "setParagraphShading", "applyParagraphBorders", "setLineHeight", "setListFormat", "setListStartAt", "toggleOrientation", "sectionBreakNextPage", "sectionBreakContinuous", "setPageMargins", "tableContext", "tableMerge", "tableSplit", "tableInsertColumnBefore", "tableInsertColumnAfter", "tableDeleteColumn", "tableInsertRowBefore", "tableInsertRowAfter", "tableDeleteRow", "tableCellShading", "tableCellBorders", "tableCellNoBorders", "tableWidth100", "tableAlignLeft", "tableAlignCenter", "tableAlignRight", "tableSetCellWidth", "insertTable"];
2
2
  export type OasisBuiltinCommand = (typeof OASIS_BUILTIN_COMMANDS)[number];
@@ -20,4 +20,6 @@ export declare function setSelectedImageFixedPosition(state: EditorState, fixed:
20
20
  export declare function setImageWrapPolygon(state: EditorState, runId: string, polygon: EditorImageRunData["wrapPolygon"]): EditorState;
21
21
  export declare function getSelectedImageAlt(state: EditorState): string | null;
22
22
  export declare function setSelectedImageAlt(state: EditorState, alt: string | null): EditorState;
23
+ export declare function getSelectedImageCaption(state: EditorState): string | null;
24
+ export declare function setSelectedImageCaption(state: EditorState, captionText: string, label: string): EditorState;
23
25
  export declare function moveSelectedImageToPosition(state: EditorState, targetPosition: EditorPosition): EditorState;
@@ -61,6 +61,7 @@ export interface OasisCommandPayloads {
61
61
  importDocument: undefined;
62
62
  insertImage: undefined;
63
63
  editImageAlt: undefined;
64
+ insertImageCaption: undefined;
64
65
  outdent: undefined;
65
66
  indent: undefined;
66
67
  togglePageBreakBefore: undefined;
@@ -0,0 +1,9 @@
1
+ import { EditorState } from '../../../model.js';
2
+
3
+ /**
4
+ * Inserts a basic shape (`wps:wsp` with preset geometry) at the current
5
+ * selection. Modeled as an inline run carrying an {@link EditorTextBoxData}
6
+ * with an empty paragraph body, floating "in front of text" by default — the
7
+ * same anchoring Word applies to a freshly inserted shape.
8
+ */
9
+ export declare function insertShapeAtSelection(state: EditorState, preset: string): EditorState;
@@ -0,0 +1,13 @@
1
+ import { EditorDocument, EditorParagraphNode } from '../../../model.js';
2
+
3
+ export declare const IMAGE_CAPTION_STYLE_ID = "Caption";
4
+ export declare const IMAGE_CAPTION_FIELD_IDENTIFIER = "Figure";
5
+ export declare const IMAGE_CAPTION_FIELD_INSTRUCTION = " SEQ Figure \\* ARABIC ";
6
+ export declare function createImageCaptionParagraph(captionText: string, label: string, sequenceNumber: number): EditorParagraphNode;
7
+ export declare function isImageCaptionParagraph(paragraph: EditorParagraphNode | undefined): paragraph is EditorParagraphNode;
8
+ export declare function getImageCaptionText(paragraph: EditorParagraphNode | undefined): string;
9
+ export declare function updateImageCaptionParagraph(paragraph: EditorParagraphNode, captionText: string, label: string): EditorParagraphNode;
10
+ export declare function renumberImageCaptionParagraphs(paragraphs: EditorParagraphNode[]): EditorParagraphNode[];
11
+ export declare function renumberImageCaptionsInDocument(document: EditorDocument): EditorDocument;
12
+ export declare function getCaptionSelectionOffset(paragraph: EditorParagraphNode): number;
13
+ export declare function cloneParagraphsWithRenumberedCaptions(paragraphs: EditorParagraphNode[]): EditorParagraphNode[];
@@ -3,6 +3,7 @@
3
3
  */
4
4
  export * from '../commands/image.js';
5
5
  export * from '../commands/textBox.js';
6
+ export * from '../commands/shape.js';
6
7
  export * from '../commands/floatingLayout.js';
7
8
  export * from '../commands/text.js';
8
9
  export * from '../commands/block.js';
@@ -26,6 +26,31 @@ export interface OasisPdfLineOptions {
26
26
  lineWidth?: number;
27
27
  dashArray?: number[];
28
28
  }
29
+ export type OasisPdfPathSegment = {
30
+ type: "move";
31
+ x: number;
32
+ y: number;
33
+ } | {
34
+ type: "line";
35
+ x: number;
36
+ y: number;
37
+ } | {
38
+ type: "cubic";
39
+ x1: number;
40
+ y1: number;
41
+ x2: number;
42
+ y2: number;
43
+ x: number;
44
+ y: number;
45
+ } | {
46
+ type: "close";
47
+ };
48
+ export interface OasisPdfPathOptions {
49
+ segments: OasisPdfPathSegment[];
50
+ fill?: string;
51
+ stroke?: string;
52
+ lineWidth?: number;
53
+ }
29
54
  export interface OasisPdfTextOptions {
30
55
  x: number;
31
56
  y: number;
@@ -78,6 +103,11 @@ export declare class OasisPdfWriter {
78
103
  getPageCount(): number;
79
104
  drawRect(pageIndex: number, options: OasisPdfRectOptions): void;
80
105
  drawLine(pageIndex: number, options: OasisPdfLineOptions): void;
106
+ drawPath(pageIndex: number, options: OasisPdfPathOptions): void;
107
+ saveGraphicsState(pageIndex: number): void;
108
+ restoreGraphicsState(pageIndex: number): void;
109
+ rotateAbout(pageIndex: number, centerX: number, centerY: number, degrees: number): void;
110
+ clipRect(pageIndex: number, x: number, y: number, width: number, height: number): void;
81
111
  drawText(pageIndex: number, options: OasisPdfTextOptions): void;
82
112
  registerImageResource(resource: Omit<OasisPdfImageResource, "resourceName"> & {
83
113
  resourceName?: string;
@@ -1,5 +1,5 @@
1
- import { EditorDocument, EditorLayoutBlock } from '../../../../../../core/model.js';
1
+ import { EditorDocument, EditorLayoutBlock, EditorPageSettings } from '../../../../../../core/model.js';
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, number>): 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, number>, pageSettings?: EditorPageSettings): Promise<void>;
@@ -0,0 +1,34 @@
1
+ import { EditorDocument, EditorLayoutLine, EditorPageSettings, EditorTextBoxData } from '../../../../../../core/model.js';
2
+ import { PdfFontRegistry } from '../../../../fonts/PdfFontRegistry.js';
3
+ import { OasisPdfWriter } from '../../../../OasisPdfWriter.js';
4
+
5
+ interface TextBoxPaintContext {
6
+ document: EditorDocument;
7
+ fontRegistry: PdfFontRegistry;
8
+ pageIndex: number;
9
+ }
10
+ /**
11
+ * Paints a text box / shape (geometry + inner content) at the given box,
12
+ * honoring `textBox.rotation` by rotating about the box center — mirroring the
13
+ * canvas `paintTextBox`. Shared by inline and floating text box rendering.
14
+ */
15
+ export declare function paintTextBox(writer: OasisPdfWriter, textBox: EditorTextBoxData, ctx: TextBoxPaintContext, xPx: number, yPx: number, widthPx: number, heightPx: number): Promise<void>;
16
+ /**
17
+ * Paints the floating (anchored) text boxes / shapes of a single paragraph,
18
+ * mirroring the canvas `drawFloatingTextBoxesForParagraph`: positions are
19
+ * resolved with {@link resolveFloatingObjectRect} into absolute page
20
+ * coordinates. Inline (non-floating) boxes are handled in the fragment loop.
21
+ */
22
+ export declare function drawFloatingTextBoxesForParagraph(options: {
23
+ writer: OasisPdfWriter;
24
+ document: EditorDocument;
25
+ fontRegistry: PdfFontRegistry;
26
+ pageIndex: number;
27
+ lines: EditorLayoutLine[];
28
+ pageSettings: EditorPageSettings;
29
+ contentLeft: number;
30
+ contentTop: number;
31
+ contentWidth: number;
32
+ paragraphTop: number;
33
+ }): Promise<void>;
34
+ export {};
@@ -6,6 +6,14 @@ export declare const en: {
6
6
  "toolbar.redo": string;
7
7
  "toolbar.insert": string;
8
8
  "toolbar.image": string;
9
+ "toolbar.imageCaption": string;
10
+ "toolbar.shapes": string;
11
+ "toolbar.shape.rect": string;
12
+ "toolbar.shape.roundRect": string;
13
+ "toolbar.shape.ellipse": string;
14
+ "toolbar.shape.triangle": string;
15
+ "toolbar.shape.rtTriangle": string;
16
+ "toolbar.shape.diamond": string;
9
17
  "toolbar.table": string;
10
18
  "toolbar.pageNumber": string;
11
19
  "toolbar.totalPages": string;
@@ -222,6 +230,9 @@ export declare const en: {
222
230
  "dialog.imageAlt.title": string;
223
231
  "dialog.imageAlt.label": string;
224
232
  "dialog.imageAlt.placeholder": string;
233
+ "dialog.imageCaption.title": string;
234
+ "dialog.imageCaption.label": string;
235
+ "dialog.imageCaption.placeholder": string;
225
236
  "dialog.link.title": string;
226
237
  "dialog.link.label": string;
227
238
  "dialog.link.placeholder": string;
@@ -6,6 +6,14 @@ export declare const ptBR: {
6
6
  "toolbar.redo": string;
7
7
  "toolbar.insert": string;
8
8
  "toolbar.image": string;
9
+ "toolbar.imageCaption": string;
10
+ "toolbar.shapes": string;
11
+ "toolbar.shape.rect": string;
12
+ "toolbar.shape.roundRect": string;
13
+ "toolbar.shape.ellipse": string;
14
+ "toolbar.shape.triangle": string;
15
+ "toolbar.shape.rtTriangle": string;
16
+ "toolbar.shape.diamond": string;
9
17
  "toolbar.table": string;
10
18
  "toolbar.pageNumber": string;
11
19
  "toolbar.totalPages": string;
@@ -222,6 +230,9 @@ export declare const ptBR: {
222
230
  "dialog.imageAlt.title": string;
223
231
  "dialog.imageAlt.label": string;
224
232
  "dialog.imageAlt.placeholder": string;
233
+ "dialog.imageCaption.title": string;
234
+ "dialog.imageCaption.label": string;
235
+ "dialog.imageCaption.placeholder": string;
225
236
  "dialog.link.title": string;
226
237
  "dialog.link.label": string;
227
238
  "dialog.link.placeholder": string;