oasis-editor 0.0.133 → 0.0.134
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-DmXn9H33.js → OasisEditorApp-B2f15Gpe.js} +485 -7
- package/dist/app/controllers/EditorCommandsController.d.ts +3 -0
- package/dist/app/controllers/createCropSession.d.ts +26 -0
- package/dist/app/controllers/useEditorImageOperations.d.ts +7 -0
- package/dist/core/commands/builtinCommands.d.ts +1 -1
- package/dist/core/commands/image.d.ts +37 -1
- package/dist/core/commands/publicCommandTypes.d.ts +5 -0
- package/dist/core/pluginUiTypes.d.ts +1 -1
- package/dist/core/transactionMergeKeys.d.ts +2 -0
- package/dist/export/pdf/writer/PdfContentStream.d.ts +8 -0
- package/dist/export/pdf/writer/pdfTypes.d.ts +10 -0
- package/dist/i18n/locales/en.d.ts +13 -0
- package/dist/i18n/locales/pt-BR.d.ts +13 -0
- package/dist/{index-BOj4-NlJ.js → index-ogn0S9F3.js} +527 -308
- package/dist/oasis-editor.css +1 -1
- package/dist/oasis-editor.js +49 -49
- package/dist/oasis-editor.umd.cjs +4 -4
- package/dist/plugins/internal/essentialsCapabilities.d.ts +15 -0
- package/dist/ui/OasisEditorEditorProps.d.ts +5 -0
- package/dist/ui/app/buildEditorViewProps.d.ts +2 -0
- package/dist/ui/app/createAppCommandsController.d.ts +6 -0
- package/dist/ui/app/createEditorCommandRuntime.d.ts +3 -0
- package/dist/ui/app/createEditorInteractionRuntime.d.ts +7 -0
- package/dist/ui/app/essentials/types.d.ts +5 -0
- package/dist/ui/components/Toolbar/controls/ImageSizeControls.d.ts +16 -0
- package/dist/ui/cropGeometry.d.ts +23 -0
- package/package.json +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { EditorState } from '../../core/model.js';
|
|
2
|
+
import { ResizeHandleDirection } from '../../ui/resizeGeometry.js';
|
|
3
|
+
import { EditorHistoryState } from '../../ui/editorHistory.js';
|
|
4
|
+
import { EditorLogger } from '../../utils/logger.js';
|
|
5
|
+
|
|
6
|
+
export interface CropSessionDeps {
|
|
7
|
+
state: EditorState;
|
|
8
|
+
applyState: (next: EditorState) => void;
|
|
9
|
+
updateHistoryState: (updater: (current: EditorHistoryState) => EditorHistoryState) => void;
|
|
10
|
+
cloneState: (source: EditorState) => EditorState;
|
|
11
|
+
focusInput: () => void;
|
|
12
|
+
logger: EditorLogger;
|
|
13
|
+
/** Visual zoom factor `z`; pointer deltas (screen px) are divided by it. */
|
|
14
|
+
zoomFactor?: () => number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Drives a handle-based image crop, mirroring {@link createResizeSession}: it
|
|
18
|
+
* tracks the pointer, resolves the next crop + displayed size via
|
|
19
|
+
* {@link resolveCroppedImage} from the captured start geometry each move (so
|
|
20
|
+
* rounding never accumulates), and snapshots the pre-crop state onto the undo
|
|
21
|
+
* stack on release.
|
|
22
|
+
*/
|
|
23
|
+
export declare function createCropSession(deps: CropSessionDeps): {
|
|
24
|
+
start: (paragraphId: string, paragraphOffset: number, handleDirection: ResizeHandleDirection, event: MouseEvent, initialState: EditorState) => void;
|
|
25
|
+
stop: () => void;
|
|
26
|
+
};
|
|
@@ -39,6 +39,9 @@ export interface EditorImageOperationsDeps {
|
|
|
39
39
|
export declare function createEditorImageOperations(deps: EditorImageOperationsDeps): ReturnType<typeof createEditorImageOperationsImpl>;
|
|
40
40
|
declare function createEditorImageOperationsImpl(deps: EditorImageOperationsDeps): {
|
|
41
41
|
dragging: import('solid-js').Accessor<boolean>;
|
|
42
|
+
cropMode: import('solid-js').Accessor<boolean>;
|
|
43
|
+
setCropMode: import('solid-js').Setter<boolean>;
|
|
44
|
+
toggleCropMode: () => void;
|
|
42
45
|
draggedImageInfo: import('solid-js').Accessor<ActiveImageDrag | null>;
|
|
43
46
|
mousePos: import('solid-js').Accessor<{
|
|
44
47
|
x: number;
|
|
@@ -57,6 +60,7 @@ declare function createEditorImageOperationsImpl(deps: EditorImageOperationsDeps
|
|
|
57
60
|
stopImageDrag: () => void;
|
|
58
61
|
stopImageResize: () => void;
|
|
59
62
|
stopImageRotate: () => void;
|
|
63
|
+
stopImageCrop: () => void;
|
|
60
64
|
handleImageMouseDown: (paragraphId: string, paragraphOffset: number, event: MouseEvent & {
|
|
61
65
|
currentTarget: HTMLElement;
|
|
62
66
|
}) => void;
|
|
@@ -66,5 +70,8 @@ declare function createEditorImageOperationsImpl(deps: EditorImageOperationsDeps
|
|
|
66
70
|
handleImageRotateHandleMouseDown: (paragraphId: string, paragraphOffset: number, event: MouseEvent & {
|
|
67
71
|
currentTarget: HTMLElement;
|
|
68
72
|
}) => void;
|
|
73
|
+
handleImageCropHandleMouseDown: (paragraphId: string, paragraphOffset: number, direction: ResizeHandleDirection, event: MouseEvent & {
|
|
74
|
+
currentTarget: HTMLElement;
|
|
75
|
+
}) => void;
|
|
69
76
|
};
|
|
70
77
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const OASIS_BUILTIN_COMMANDS: readonly ["selectAll", "insertFootnote", "insertTableOfContents", "updateTableOfContents", "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", "setCharacterStyleId", "setUnderlineStyle", "documentStyles", "print", "copy", "exportDocx", "exportPdf", "importDocument", "insertImage", "editImageAlt", "insertImageCaption", "outdent", "indent", "togglePageBreakBefore", "toggleKeepWithNext", "setSpacingAfter", "setSpacingBefore", "setIndentLeft", "setIndentRight", "setIndentFirstLine", "setIndentHanging", "setSpecialIndent", "setParagraphShading", "applyParagraphBorders", "setLineHeight", "setListFormat", "setListStartAt", "toggleOrientation", "setOrientation", "sectionBreakNextPage", "sectionBreakContinuous", "setPageMargins", "tableContext", "tableMerge", "tableSplit", "tableInsertColumnBefore", "tableInsertColumnAfter", "tableDeleteColumn", "tableInsertRowBefore", "tableInsertRowAfter", "tableDeleteRow", "tableCellShading", "tableCellBorders", "tableCellNoBorders", "tableWidth100", "tableAlignLeft", "tableAlignCenter", "tableAlignRight", "tableSetCellWidth", "tableToggleHeaderRow", "tableToggleTotalRow", "tableToggleBandedRows", "tableToggleFirstColumn", "tableToggleLastColumn", "tableToggleBandedColumns", "setTableStyle", "tableToggleAutoFit", "tableDistributeColumns", "tableDistributeRows", "insertTable", "insertShape"];
|
|
1
|
+
export declare const OASIS_BUILTIN_COMMANDS: readonly ["selectAll", "insertFootnote", "insertTableOfContents", "updateTableOfContents", "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", "setCharacterStyleId", "setUnderlineStyle", "documentStyles", "print", "copy", "exportDocx", "exportPdf", "importDocument", "insertImage", "editImageAlt", "insertImageCaption", "imageContext", "imageWidthCm", "imageHeightCm", "imageCrop", "imageCropAspect", "outdent", "indent", "togglePageBreakBefore", "toggleKeepWithNext", "setSpacingAfter", "setSpacingBefore", "setIndentLeft", "setIndentRight", "setIndentFirstLine", "setIndentHanging", "setSpecialIndent", "setParagraphShading", "applyParagraphBorders", "setLineHeight", "setListFormat", "setListStartAt", "toggleOrientation", "setOrientation", "sectionBreakNextPage", "sectionBreakContinuous", "setPageMargins", "tableContext", "tableMerge", "tableSplit", "tableInsertColumnBefore", "tableInsertColumnAfter", "tableDeleteColumn", "tableInsertRowBefore", "tableInsertRowAfter", "tableDeleteRow", "tableCellShading", "tableCellBorders", "tableCellNoBorders", "tableWidth100", "tableAlignLeft", "tableAlignCenter", "tableAlignRight", "tableSetCellWidth", "tableToggleHeaderRow", "tableToggleTotalRow", "tableToggleBandedRows", "tableToggleFirstColumn", "tableToggleLastColumn", "tableToggleBandedColumns", "setTableStyle", "tableToggleAutoFit", "tableDistributeColumns", "tableDistributeRows", "insertTable", "insertShape"];
|
|
2
2
|
export type OasisBuiltinCommand = (typeof OASIS_BUILTIN_COMMANDS)[number];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EditorPosition, EditorState, EditorImageRunData } from '../model.js';
|
|
1
|
+
import { EditorPosition, EditorState, EditorImageRunData, EditorImageCrop } from '../model.js';
|
|
2
2
|
import { SelectedObjectRun } from './selectedObjectRun.js';
|
|
3
3
|
import { WrapPreset } from './floatingLayout.js';
|
|
4
4
|
|
|
@@ -6,6 +6,42 @@ export type SelectedImageRun = SelectedObjectRun;
|
|
|
6
6
|
export declare function getSelectedImageRun(state: EditorState): SelectedImageRun | null;
|
|
7
7
|
export declare function insertImageAtSelection(state: EditorState, image: EditorImageRunData): EditorState;
|
|
8
8
|
export declare function resizeSelectedImage(state: EditorState, width: number, height: number): EditorState;
|
|
9
|
+
/** Displayed size of the selected image, in centimetres, or `null`. */
|
|
10
|
+
export declare function getSelectedImageSizeCm(state: EditorState): {
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
} | null;
|
|
14
|
+
/**
|
|
15
|
+
* Sets the displayed width from a centimetre value, scaling the height by the
|
|
16
|
+
* current aspect ratio (Word locks aspect for pictures).
|
|
17
|
+
*/
|
|
18
|
+
export declare function setSelectedImageWidthCm(state: EditorState, cm: number): EditorState;
|
|
19
|
+
/** Sets the displayed height from a centimetre value, scaling width to match. */
|
|
20
|
+
export declare function setSelectedImageHeightCm(state: EditorState, cm: number): EditorState;
|
|
21
|
+
/** Crop fractions of the selected image (`a:srcRect`), or `null`. */
|
|
22
|
+
export declare function getSelectedImageCrop(state: EditorState): EditorImageCrop | null;
|
|
23
|
+
export interface ImageCropUpdate {
|
|
24
|
+
crop: EditorImageCrop | null;
|
|
25
|
+
/** Optional new displayed width (px) — used when cropping shrinks the box. */
|
|
26
|
+
width?: number;
|
|
27
|
+
/** Optional new displayed height (px). */
|
|
28
|
+
height?: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Applies a crop (and optionally a new displayed size) to the selected image.
|
|
32
|
+
* Passing `crop: null` clears the crop. Round-trips to DOCX `a:srcRect`.
|
|
33
|
+
*/
|
|
34
|
+
export declare function setSelectedImageCrop(state: EditorState, update: ImageCropUpdate): EditorState;
|
|
35
|
+
/** Aspect-ratio crop preset: a numeric `width/height` ratio, or `"reset"`. */
|
|
36
|
+
export type ImageCropAspectMode = number | "reset";
|
|
37
|
+
/**
|
|
38
|
+
* Computes a centred crop that makes the displayed box match `mode` (a
|
|
39
|
+
* `width/height` ratio), trimming the longer axis and shrinking that box
|
|
40
|
+
* dimension so the image is not distorted. `"reset"` clears the crop.
|
|
41
|
+
*/
|
|
42
|
+
export declare function computeImageAspectCrop(image: EditorImageRunData, mode: ImageCropAspectMode): ImageCropUpdate;
|
|
43
|
+
/** Applies an aspect-ratio crop preset to the selected image. */
|
|
44
|
+
export declare function applySelectedImageCropAspect(state: EditorState, mode: ImageCropAspectMode): EditorState;
|
|
9
45
|
export declare function rotateSelectedImage(state: EditorState, rotation: number): EditorState;
|
|
10
46
|
export declare function getSelectedImageWrapPreset(state: EditorState): WrapPreset | null;
|
|
11
47
|
export declare function isSelectedImageFixedPosition(state: EditorState): boolean;
|
|
@@ -67,6 +67,11 @@ export interface OasisCommandPayloads {
|
|
|
67
67
|
insertImage: undefined;
|
|
68
68
|
editImageAlt: undefined;
|
|
69
69
|
insertImageCaption: undefined;
|
|
70
|
+
imageContext: undefined;
|
|
71
|
+
imageWidthCm: number | string | null;
|
|
72
|
+
imageHeightCm: number | string | null;
|
|
73
|
+
imageCrop: undefined;
|
|
74
|
+
imageCropAspect: string;
|
|
70
75
|
outdent: undefined;
|
|
71
76
|
indent: undefined;
|
|
72
77
|
togglePageBreakBefore: undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const RIBBON_TABS: readonly ["file", "home", "insert", "draw", "layout", "references", "collaboration", "protection", "view", "tableDesign", "tableLayout", "plugins", "ai"];
|
|
1
|
+
export declare const RIBBON_TABS: readonly ["file", "home", "insert", "draw", "layout", "references", "collaboration", "protection", "view", "tableDesign", "tableLayout", "imageFormat", "plugins", "ai"];
|
|
2
2
|
export type RibbonTabId = (typeof RIBBON_TABS)[number];
|
|
3
3
|
/**
|
|
4
4
|
* Contextual tabs are hidden from the tab strip unless their gating command
|
|
@@ -7,6 +7,8 @@ export declare const MERGE_KEYS: {
|
|
|
7
7
|
readonly link: "link";
|
|
8
8
|
readonly imageAlt: "imageAlt";
|
|
9
9
|
readonly imageCaption: "imageCaption";
|
|
10
|
+
readonly imageResize: "imageResize";
|
|
11
|
+
readonly imageCrop: "imageCrop";
|
|
10
12
|
readonly layoutWrapPolygon: "layoutWrapPolygon";
|
|
11
13
|
readonly specialIndent: "specialIndent";
|
|
12
14
|
readonly paraBorders: "paraBorders";
|
|
@@ -34,4 +34,12 @@ export declare class PdfContentStream {
|
|
|
34
34
|
*/
|
|
35
35
|
private emitGradientTextBlock;
|
|
36
36
|
drawImage(options: OasisPdfImageOptions): void;
|
|
37
|
+
/**
|
|
38
|
+
* Draws a cropped image by clipping to the displayed box and scaling the full
|
|
39
|
+
* image so only the cropped sub-region fills it — mirroring the canvas/DOCX
|
|
40
|
+
* `a:srcRect` semantics. Works with rotation by mapping box-local space to the
|
|
41
|
+
* page (rotation about the box centre), clipping in that space, then drawing
|
|
42
|
+
* the enlarged image behind the clip.
|
|
43
|
+
*/
|
|
44
|
+
private drawCroppedImage;
|
|
37
45
|
}
|
|
@@ -165,6 +165,16 @@ export interface OasisPdfImageOptions {
|
|
|
165
165
|
width: number;
|
|
166
166
|
height: number;
|
|
167
167
|
rotation?: number;
|
|
168
|
+
/**
|
|
169
|
+
* Crop fractions (0..1 trimmed per edge, matching `a:srcRect`). When present,
|
|
170
|
+
* only the cropped sub-region is shown, scaled to fill the box.
|
|
171
|
+
*/
|
|
172
|
+
crop?: {
|
|
173
|
+
left?: number;
|
|
174
|
+
top?: number;
|
|
175
|
+
right?: number;
|
|
176
|
+
bottom?: number;
|
|
177
|
+
};
|
|
168
178
|
}
|
|
169
179
|
export type OasisPdfFontResource = OasisPdfBase14FontResource | OasisPdfUnicodeFontResource;
|
|
170
180
|
export interface OasisPdfBase14FontResource {
|
|
@@ -365,6 +365,7 @@ export declare const en: {
|
|
|
365
365
|
"ribbon.tab.view": string;
|
|
366
366
|
"ribbon.tab.tableDesign": string;
|
|
367
367
|
"ribbon.tab.tableLayout": string;
|
|
368
|
+
"ribbon.tab.imageFormat": string;
|
|
368
369
|
"ribbon.tab.plugins": string;
|
|
369
370
|
"ribbon.tab.ai": string;
|
|
370
371
|
"ribbon.group.clipboard": string;
|
|
@@ -387,6 +388,18 @@ export declare const en: {
|
|
|
387
388
|
"ribbon.group.merge": string;
|
|
388
389
|
"ribbon.group.cellSize": string;
|
|
389
390
|
"ribbon.group.alignment": string;
|
|
391
|
+
"ribbon.group.size": string;
|
|
392
|
+
"image.crop": string;
|
|
393
|
+
"image.height": string;
|
|
394
|
+
"image.width": string;
|
|
395
|
+
"image.cropReset": string;
|
|
396
|
+
"image.cropRatio.square": string;
|
|
397
|
+
"image.cropRatio.16x9": string;
|
|
398
|
+
"image.cropRatio.4x3": string;
|
|
399
|
+
"image.cropRatio.3x2": string;
|
|
400
|
+
"image.cropRatio.2x3": string;
|
|
401
|
+
"image.cropRatio.3x4": string;
|
|
402
|
+
"image.cropRatio.9x16": string;
|
|
390
403
|
"toolbar.exportDocx": string;
|
|
391
404
|
"toolbar.exportPdf": string;
|
|
392
405
|
"underline.style.single": string;
|
|
@@ -365,6 +365,7 @@ export declare const ptBR: {
|
|
|
365
365
|
"ribbon.tab.view": string;
|
|
366
366
|
"ribbon.tab.tableDesign": string;
|
|
367
367
|
"ribbon.tab.tableLayout": string;
|
|
368
|
+
"ribbon.tab.imageFormat": string;
|
|
368
369
|
"ribbon.tab.plugins": string;
|
|
369
370
|
"ribbon.tab.ai": string;
|
|
370
371
|
"ribbon.group.clipboard": string;
|
|
@@ -387,6 +388,18 @@ export declare const ptBR: {
|
|
|
387
388
|
"ribbon.group.merge": string;
|
|
388
389
|
"ribbon.group.cellSize": string;
|
|
389
390
|
"ribbon.group.alignment": string;
|
|
391
|
+
"ribbon.group.size": string;
|
|
392
|
+
"image.crop": string;
|
|
393
|
+
"image.height": string;
|
|
394
|
+
"image.width": string;
|
|
395
|
+
"image.cropReset": string;
|
|
396
|
+
"image.cropRatio.square": string;
|
|
397
|
+
"image.cropRatio.16x9": string;
|
|
398
|
+
"image.cropRatio.4x3": string;
|
|
399
|
+
"image.cropRatio.3x2": string;
|
|
400
|
+
"image.cropRatio.2x3": string;
|
|
401
|
+
"image.cropRatio.3x4": string;
|
|
402
|
+
"image.cropRatio.9x16": string;
|
|
390
403
|
"toolbar.exportDocx": string;
|
|
391
404
|
"toolbar.exportPdf": string;
|
|
392
405
|
"underline.style.single": string;
|