oasis-editor 0.0.9 → 0.0.11

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,4 +1,5 @@
1
1
  import { EditorParagraphListStyle, EditorParagraphStyle, EditorSection, EditorState, EditorTextStyle } from '../../../../core/model.js';
2
+ import { TextCaseMode } from '../../../../core/commands/text.js';
2
3
  import { EditorTransactionOptions } from '../../../../ui/editorHistory.js';
3
4
  import { BooleanStyleKey, ParagraphStyleKey, ToolbarStyleState } from '../../../../ui/toolbarStyleState.js';
4
5
  import { EditorLogger } from '../../../../utils/logger.js';
@@ -24,6 +25,8 @@ export interface EditorCommandsControllerDeps {
24
25
  export declare function createEditorCommandsController(deps: EditorCommandsControllerDeps): {
25
26
  applyBooleanStyleCommand: (key: BooleanStyleKey) => void;
26
27
  applyValueStyleCommand: <K extends "fontFamily" | "fontSize" | "color" | "highlight" | "shading" | "language" | "textEffect" | "link" | "underlineStyle">(key: K, value: EditorTextStyle[K] | null) => void;
28
+ applyChangeTextCaseCommand: (mode: TextCaseMode) => void;
29
+ applyClearFormattingCommand: () => void;
27
30
  applyParagraphStyleCommand: <K extends ParagraphStyleKey>(key: K, value: EditorParagraphStyle[K] | null) => void;
28
31
  toggleParagraphFlagCommand: (key: "pageBreakBefore" | "keepWithNext") => void;
29
32
  applyParagraphListCommand: (kind: NonNullable<EditorParagraphListStyle["kind"]>) => void;
@@ -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", "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", "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];
@@ -1,5 +1,6 @@
1
1
  import { CommandRef } from '../../CommandRef.js';
2
2
  import { EditorPageMargins } from '../../../model.js';
3
+ import { TextCaseMode } from '../../text.js';
3
4
 
4
5
  export interface InsertTablePayload {
5
6
  rows: number;
@@ -43,6 +44,10 @@ export interface OasisCommandPayloads {
43
44
  splitBlock: undefined;
44
45
  setFontFamily: string | null;
45
46
  setFontSize: SetFontSizePayload | number | string | null;
47
+ increaseFontSize: undefined;
48
+ decreaseFontSize: undefined;
49
+ changeTextCase: TextCaseMode;
50
+ clearFormatting: undefined;
46
51
  setColor: string | null;
47
52
  setHighlight: string | null;
48
53
  setTextShading: string | null;
@@ -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;
@@ -9,4 +9,19 @@ export declare function insertPlainTextAtSelection(state: EditorState, text: str
9
9
  export declare function deleteBackward(state: EditorState): EditorState;
10
10
  export declare function deleteForward(state: EditorState): EditorState;
11
11
  export declare function toggleTextStyle(state: EditorState, key: ToggleableTextStyleKey): EditorState;
12
+ export type TextCaseMode = "sentence" | "lower" | "upper" | "capitalize" | "toggle";
13
+ /**
14
+ * Transforms the text of the selected runs in place. The transform must return
15
+ * a string of the same length so per-run boundaries (and thus styles) are
16
+ * preserved. The transform is applied to each paragraph's selected text
17
+ * independently so sentence/word boundaries reset at paragraph breaks.
18
+ */
19
+ export declare function transformSelectedText(state: EditorState, transform: (text: string) => string): EditorState;
20
+ /** Change the letter case of the selected text, preserving runs and styles. */
21
+ export declare function changeSelectedTextCase(state: EditorState, mode: TextCaseMode): EditorState;
22
+ /**
23
+ * Remove direct (local) text formatting from the selected runs, preserving the
24
+ * text content, revisions, and links.
25
+ */
26
+ export declare function clearSelectedTextFormatting(state: EditorState): EditorState;
12
27
  export declare function setTextStyleValue<K extends ValueTextStyleKey>(state: EditorState, key: K, value: EditorTextStyle[K] | null): EditorState;
@@ -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,13 @@ export declare const en: {
6
6
  "toolbar.redo": string;
7
7
  "toolbar.insert": string;
8
8
  "toolbar.image": string;
9
+ "toolbar.shapes": string;
10
+ "toolbar.shape.rect": string;
11
+ "toolbar.shape.roundRect": string;
12
+ "toolbar.shape.ellipse": string;
13
+ "toolbar.shape.triangle": string;
14
+ "toolbar.shape.rtTriangle": string;
15
+ "toolbar.shape.diamond": string;
9
16
  "toolbar.table": string;
10
17
  "toolbar.pageNumber": string;
11
18
  "toolbar.totalPages": string;
@@ -46,6 +53,15 @@ export declare const en: {
46
53
  "toolbar.font": string;
47
54
  "toolbar.fontSize": string;
48
55
  "toolbar.size": string;
56
+ "toolbar.increaseFontSize": string;
57
+ "toolbar.decreaseFontSize": string;
58
+ "toolbar.changeCase": string;
59
+ "toolbar.clearFormatting": string;
60
+ "toolbar.caseSentence": string;
61
+ "toolbar.caseLower": string;
62
+ "toolbar.caseUpper": string;
63
+ "toolbar.caseCapitalize": string;
64
+ "toolbar.caseToggle": string;
49
65
  "toolbar.color": string;
50
66
  "toolbar.highlight": string;
51
67
  "toolbar.textShading": string;
@@ -6,6 +6,13 @@ export declare const ptBR: {
6
6
  "toolbar.redo": string;
7
7
  "toolbar.insert": string;
8
8
  "toolbar.image": string;
9
+ "toolbar.shapes": string;
10
+ "toolbar.shape.rect": string;
11
+ "toolbar.shape.roundRect": string;
12
+ "toolbar.shape.ellipse": string;
13
+ "toolbar.shape.triangle": string;
14
+ "toolbar.shape.rtTriangle": string;
15
+ "toolbar.shape.diamond": string;
9
16
  "toolbar.table": string;
10
17
  "toolbar.pageNumber": string;
11
18
  "toolbar.totalPages": string;
@@ -46,6 +53,15 @@ export declare const ptBR: {
46
53
  "toolbar.font": string;
47
54
  "toolbar.fontSize": string;
48
55
  "toolbar.size": string;
56
+ "toolbar.increaseFontSize": string;
57
+ "toolbar.decreaseFontSize": string;
58
+ "toolbar.changeCase": string;
59
+ "toolbar.clearFormatting": string;
60
+ "toolbar.caseSentence": string;
61
+ "toolbar.caseLower": string;
62
+ "toolbar.caseUpper": string;
63
+ "toolbar.caseCapitalize": string;
64
+ "toolbar.caseToggle": string;
49
65
  "toolbar.color": string;
50
66
  "toolbar.highlight": string;
51
67
  "toolbar.textShading": string;