oasis-editor 0.0.133 → 0.0.135

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.
Files changed (40) hide show
  1. package/dist/{OasisEditorApp-DmXn9H33.js → OasisEditorApp-207_qEC4.js} +602 -30
  2. package/dist/app/controllers/EditorCommandsController.d.ts +5 -0
  3. package/dist/app/controllers/createCropSession.d.ts +26 -0
  4. package/dist/app/controllers/useEditorImageOperations.d.ts +7 -0
  5. package/dist/assets/{importDocxWorker-CCwhxVSR.js → importDocxWorker-B0cSSI12.js} +1 -1
  6. package/dist/core/commands/builtinCommands.d.ts +1 -1
  7. package/dist/core/commands/image.d.ts +51 -1
  8. package/dist/core/commands/publicCommandTypes.d.ts +5 -0
  9. package/dist/core/lineDash.d.ts +16 -0
  10. package/dist/core/model/index.d.ts +1 -1
  11. package/dist/core/model/types/primitives.d.ts +19 -0
  12. package/dist/core/pluginUiTypes.d.ts +1 -1
  13. package/dist/core/transactionMergeKeys.d.ts +2 -0
  14. package/dist/export/docx/docxTypes.d.ts +2 -1
  15. package/dist/export/docx/text/drawingContainerXml.d.ts +7 -1
  16. package/dist/export/pdf/draw/drawImageObject.d.ts +14 -0
  17. package/dist/export/pdf/writer/PdfContentStream.d.ts +8 -0
  18. package/dist/export/pdf/writer/pdfTypes.d.ts +12 -0
  19. package/dist/i18n/locales/en.d.ts +28 -0
  20. package/dist/i18n/locales/pt-BR.d.ts +28 -0
  21. package/dist/{index-BOj4-NlJ.js → index-CaKZARyM.js} +1217 -468
  22. package/dist/oasis-editor.css +1 -1
  23. package/dist/oasis-editor.js +49 -49
  24. package/dist/oasis-editor.umd.cjs +4 -4
  25. package/dist/plugins/internal/essentialsCapabilities.d.ts +21 -1
  26. package/dist/ui/OasisEditorEditorProps.d.ts +5 -0
  27. package/dist/ui/app/buildEditorViewProps.d.ts +2 -0
  28. package/dist/ui/app/createAppCommandsController.d.ts +8 -0
  29. package/dist/ui/app/createEditorCommandRuntime.d.ts +4 -0
  30. package/dist/ui/app/createEditorInteractionRuntime.d.ts +7 -0
  31. package/dist/ui/app/essentials/types.d.ts +5 -0
  32. package/dist/ui/canvas/paragraph/canvasInlineImage.d.ts +1 -1
  33. package/dist/ui/components/Toolbar/controls/ImageSizeControls.d.ts +16 -0
  34. package/dist/ui/components/Toolbar/pictureBorderPresets.d.ts +19 -0
  35. package/dist/ui/components/Toolbar/primitives/ColorGrids.d.ts +20 -0
  36. package/dist/ui/components/Toolbar/primitives/PictureBorderPicker.d.ts +37 -0
  37. package/dist/ui/components/Toolbar/primitives/WideMenuButton.d.ts +27 -0
  38. package/dist/ui/components/Toolbar/schema/items.d.ts +15 -1
  39. package/dist/ui/cropGeometry.d.ts +23 -0
  40. package/package.json +1 -1
@@ -1,4 +1,5 @@
1
- import { EditorPageMargins } from '../../core/model.js';
1
+ import { EditorImageBorder, EditorPageMargins } from '../../core/model.js';
2
+ import { ImageBorderPatch } from '../../core/commands/image.js';
2
3
  import { TextCaseMode } from '../../core/commands/text.js';
3
4
  import { ToolbarStyleState } from '../../ui/toolbarStyleState.js';
4
5
  import { OasisBuiltinCommand } from '../../core/commands/builtinCommands.js';
@@ -90,6 +91,25 @@ export interface EssentialsImageCapability {
90
91
  promptAlt: () => void;
91
92
  promptCaption: () => void;
92
93
  isSelected: () => boolean;
94
+ /** Displayed size of the selected image in centimetres, or `null`. */
95
+ getSizeCm: () => {
96
+ width: number;
97
+ height: number;
98
+ } | null;
99
+ /** Set the displayed width (cm), scaling height to keep the aspect ratio. */
100
+ setWidthCm: (cm: number) => void;
101
+ /** Set the displayed height (cm), scaling width to keep the aspect ratio. */
102
+ setHeightCm: (cm: number) => void;
103
+ /** Whether interactive crop mode is currently active. */
104
+ isCropActive: () => boolean;
105
+ /** Toggle interactive crop mode for the selected image. */
106
+ toggleCrop: () => void;
107
+ /** Apply an aspect-ratio crop preset (e.g. "16:9", "1:1", "reset"). */
108
+ applyCropAspect: (preset: string) => void;
109
+ /** Outline of the selected image (`pic:spPr/a:ln`), or `null`. */
110
+ getBorder: () => EditorImageBorder | null;
111
+ /** Merge a partial outline edit; `{ color: null }` removes the outline. */
112
+ setBorder: (patch: ImageBorderPatch) => void;
93
113
  }
94
114
  export interface EssentialsBrowserCapability {
95
115
  print: () => void;
@@ -31,6 +31,8 @@ export interface OasisEditorEditorOverlayProps {
31
31
  focused: Accessor<boolean>;
32
32
  showCaret: Accessor<boolean>;
33
33
  importProgress?: Accessor<ImportProgress | null>;
34
+ /** Whether interactive image crop mode is active (shows crop handles). */
35
+ imageCropMode?: Accessor<boolean>;
34
36
  toolbarHost?: () => ToolbarHost;
35
37
  persistenceStatus?: () => string;
36
38
  showFloatingTableToolbar?: Accessor<boolean>;
@@ -66,6 +68,9 @@ export interface OasisEditorEditorSurfaceHandlers {
66
68
  onImageRotateHandleMouseDown: (paragraphId: string, paragraphOffset: number, event: MouseEvent & {
67
69
  currentTarget: HTMLElement;
68
70
  }) => void;
71
+ onImageCropHandleMouseDown?: (paragraphId: string, paragraphOffset: number, direction: ResizeHandleDirection, event: MouseEvent & {
72
+ currentTarget: HTMLElement;
73
+ }) => void;
69
74
  onTextBoxRotateHandleMouseDown: (paragraphId: string, paragraphOffset: number, event: MouseEvent & {
70
75
  currentTarget: HTMLElement;
71
76
  }) => void;
@@ -35,6 +35,7 @@ export interface EditorViewOverlayInput {
35
35
  focused: Accessor<boolean>;
36
36
  showCaret: Accessor<boolean>;
37
37
  importProgress: Accessor<ImportProgress | null>;
38
+ imageCropMode: Accessor<boolean>;
38
39
  }
39
40
  /** Owner of the editor element refs. */
40
41
  export interface EditorViewRefsInput {
@@ -58,6 +59,7 @@ export interface EditorViewSurfaceInput {
58
59
  handleImageResizeHandleMouseDown: OasisEditorEditorSurfaceHandlers["onImageResizeHandleMouseDown"];
59
60
  handleTextBoxResizeHandleMouseDown: OasisEditorEditorSurfaceHandlers["onTextBoxResizeHandleMouseDown"];
60
61
  handleImageRotateHandleMouseDown: OasisEditorEditorSurfaceHandlers["onImageRotateHandleMouseDown"];
62
+ handleImageCropHandleMouseDown: NonNullable<OasisEditorEditorSurfaceHandlers["onImageCropHandleMouseDown"]>;
61
63
  handleTextBoxRotateHandleMouseDown: OasisEditorEditorSurfaceHandlers["onTextBoxRotateHandleMouseDown"];
62
64
  handleEditorContextMenu: (event: MouseEvent) => void;
63
65
  }
@@ -69,6 +69,10 @@ declare function createAppCommandsControllerImpl(deps: AppCommandsControllerDeps
69
69
  promptForImageAlt: () => void;
70
70
  applyImageCaptionCommand: (caption: string) => void;
71
71
  promptForImageCaption: () => void;
72
+ applyImageWidthCmCommand: (cm: number) => void;
73
+ applyImageHeightCmCommand: (cm: number) => void;
74
+ applyImageCropAspectCommand: (preset: string) => void;
75
+ applyImageBorderCommand: (patch: import('../../core/commands/image.js').ImageBorderPatch) => void;
72
76
  handleListTab: (direction: "indent" | "outdent") => boolean;
73
77
  handleListEnter: () => boolean;
74
78
  handleListBoundaryBackspace: (event: KeyboardEvent & {
@@ -103,6 +107,10 @@ declare function createAppCommandsControllerImpl(deps: AppCommandsControllerDeps
103
107
  promptForImageAlt: () => void;
104
108
  applyImageCaptionCommand: (caption: string) => void;
105
109
  promptForImageCaption: () => void;
110
+ applyImageWidthCmCommand: (cm: number) => void;
111
+ applyImageHeightCmCommand: (cm: number) => void;
112
+ applyImageCropAspectCommand: (preset: string) => void;
113
+ applyImageBorderCommand: (patch: import('../../core/commands/image.js').ImageBorderPatch) => void;
106
114
  handleListTab: (direction: "indent" | "outdent") => boolean;
107
115
  handleListEnter: () => boolean;
108
116
  handleListBoundaryBackspace: (event: KeyboardEvent & {
@@ -84,6 +84,10 @@ declare function createEditorCommandRuntimeImpl(deps: EditorCommandRuntimeDeps):
84
84
  promptForImageAlt: () => void;
85
85
  applyImageCaptionCommand: (caption: string) => void;
86
86
  promptForImageCaption: () => void;
87
+ applyImageWidthCmCommand: (cm: number) => void;
88
+ applyImageHeightCmCommand: (cm: number) => void;
89
+ applyImageCropAspectCommand: (preset: string) => void;
90
+ applyImageBorderCommand: (patch: import('../../core/commands/image.js').ImageBorderPatch) => void;
87
91
  handleListTab: (direction: "indent" | "outdent") => boolean;
88
92
  handleListEnter: () => boolean;
89
93
  handleListBoundaryBackspace: (event: KeyboardEvent & {
@@ -89,6 +89,9 @@ declare function createEditorInteractionRuntimeImpl(deps: EditorInteractionRunti
89
89
  };
90
90
  imageOps: {
91
91
  dragging: import('solid-js').Accessor<boolean>;
92
+ cropMode: import('solid-js').Accessor<boolean>;
93
+ setCropMode: import('solid-js').Setter<boolean>;
94
+ toggleCropMode: () => void;
92
95
  draggedImageInfo: import('solid-js').Accessor<import('../../app/controllers/useEditorImageOperations.js').ActiveImageDrag | null>;
93
96
  mousePos: import('solid-js').Accessor<{
94
97
  x: number;
@@ -107,6 +110,7 @@ declare function createEditorInteractionRuntimeImpl(deps: EditorInteractionRunti
107
110
  stopImageDrag: () => void;
108
111
  stopImageResize: () => void;
109
112
  stopImageRotate: () => void;
113
+ stopImageCrop: () => void;
110
114
  handleImageMouseDown: (paragraphId: string, paragraphOffset: number, event: MouseEvent & {
111
115
  currentTarget: HTMLElement;
112
116
  }) => void;
@@ -116,6 +120,9 @@ declare function createEditorInteractionRuntimeImpl(deps: EditorInteractionRunti
116
120
  handleImageRotateHandleMouseDown: (paragraphId: string, paragraphOffset: number, event: MouseEvent & {
117
121
  currentTarget: HTMLElement;
118
122
  }) => void;
123
+ handleImageCropHandleMouseDown: (paragraphId: string, paragraphOffset: number, direction: import('../resizeGeometry.js').ResizeHandleDirection, event: MouseEvent & {
124
+ currentTarget: HTMLElement;
125
+ }) => void;
119
126
  };
120
127
  textBoxOps: {
121
128
  handleTextBoxResizeHandleMouseDown: (paragraphId: string, paragraphOffset: number, direction: import('../resizeGeometry.js').ResizeHandleDirection, event: MouseEvent & {
@@ -29,6 +29,11 @@ export interface CreateEditorEssentialsPluginOptions {
29
29
  importInputRef: () => HTMLInputElement | undefined;
30
30
  imageInputRef: () => HTMLInputElement | undefined;
31
31
  selectedImageRun: () => SelectedImageRun | null;
32
+ /** Interactive image crop-mode signal (owned by the image operations). */
33
+ imageCropMode: {
34
+ isActive: () => boolean;
35
+ toggle: () => void;
36
+ };
32
37
  selectionBoxes: () => Array<unknown>;
33
38
  focusInput: () => void;
34
39
  applyState: (nextState: EditorState) => void;
@@ -2,7 +2,7 @@ import { EditorImageRunData, EditorLayoutLine, EditorPageSettings, EditorState }
2
2
 
3
3
  /**
4
4
  * Draw an inline image fragment, honoring crop (`a:srcRect`), rotation
5
- * (`a:xfrm/@rot`) and horizontal/vertical flips.
5
+ * (`a:xfrm/@rot`), horizontal/vertical flips and the picture outline.
6
6
  */
7
7
  export declare function drawImageFragment(ctx: CanvasRenderingContext2D, img: CanvasImageSource & {
8
8
  naturalWidth: number;
@@ -0,0 +1,16 @@
1
+ import { JSX } from 'solid-js';
2
+ import { ToolbarActionApi } from '../schema/items.js';
3
+
4
+ /**
5
+ * A labelled centimetre field for the image Size group (height or width). Reads
6
+ * the current size from the `imageHeightCm`/`imageWidthCm` command and writes it
7
+ * back on change; the core keeps the aspect ratio locked.
8
+ */
9
+ export declare function ImageSizeField(props: {
10
+ api: ToolbarActionApi;
11
+ dimension: "height" | "width";
12
+ }): JSX.Element;
13
+ /** The Cortar chevron menu: toggle crop mode + aspect-ratio presets. */
14
+ export declare function ImageCropMenu(props: {
15
+ api: ToolbarActionApi;
16
+ }): JSX.Element;
@@ -0,0 +1,19 @@
1
+ import { EditorLineDash } from '../../../core/model.js';
2
+ import { TranslationKey } from '../../../i18n/index.js';
3
+
4
+ /** Border weights offered by Word's Picture Border ▸ Weight submenu, in points. */
5
+ export declare const PICTURE_BORDER_WEIGHTS_PT: number[];
6
+ /** `0.25` → `"¼"`, `1.5` → `"1½"`, `3` → `"3"`. */
7
+ export declare function formatBorderWeight(widthPt: number): string;
8
+ export interface PictureBorderDashOption {
9
+ value: EditorLineDash;
10
+ labelKey: TranslationKey;
11
+ }
12
+ /** Ordered as Word's Dashes flyout: shortest pattern first. */
13
+ export declare const PICTURE_BORDER_DASH_OPTIONS: PictureBorderDashOption[];
14
+ /**
15
+ * `stroke-dasharray` for a menu preview stroke, derived from the same point
16
+ * table the canvas and PDF renderers use — so a preview can never disagree with
17
+ * what gets painted. Solid yields `undefined` (no attribute).
18
+ */
19
+ export declare function dashPreviewArray(dash: EditorLineDash): string | undefined;
@@ -0,0 +1,20 @@
1
+ import { JSX } from 'solid-js';
2
+ import { ColorPalette } from '../schema/palette.js';
3
+
4
+ export interface ColorGridsProps {
5
+ palette: ColorPalette;
6
+ themeColorsLabel: string;
7
+ standardColorsLabel: string;
8
+ /** Lowercased hex of the currently applied colour, for the active ring. */
9
+ activeColor: string;
10
+ testId: string;
11
+ onPreview: (color: string | null) => void;
12
+ onPick: (color: string) => void;
13
+ }
14
+ /**
15
+ * The theme-colour columns and standard-colour row shared by every colour popup
16
+ * (font colour, highlight, shading, picture border). Owns only the swatches —
17
+ * the surrounding "automatic"/"no colour" and "more colours" actions differ per
18
+ * consumer and stay with them.
19
+ */
20
+ export declare function ColorGrids(props: ColorGridsProps): JSX.Element;
@@ -0,0 +1,37 @@
1
+ import { JSX } from 'solid-js';
2
+ import { ColorPalette } from '../schema/palette.js';
3
+ import { EditorImageBorder, EditorLineDash } from '../../../../core/model.js';
4
+ import { ImageBorderPatch } from '../../../../core/commands/image.js';
5
+
6
+ export interface PictureBorderPickerProps {
7
+ /** The outline currently on the selected picture, or `null`. */
8
+ border: EditorImageBorder | null;
9
+ palette: ColorPalette;
10
+ disabled?: boolean;
11
+ testId: string;
12
+ label: string;
13
+ noOutlineLabel: string;
14
+ moreColorsLabel: string;
15
+ weightLabel: string;
16
+ dashesLabel: string;
17
+ themeColorsLabel: string;
18
+ standardColorsLabel: string;
19
+ /** Ordered dash presets with their translated names. */
20
+ dashOptions: Array<{
21
+ value: EditorLineDash;
22
+ label: string;
23
+ }>;
24
+ onApply: (patch: ImageBorderPatch) => void;
25
+ }
26
+ /**
27
+ * Word's Picture Border popup: theme/standard colour grids, "No Outline",
28
+ * "More Outline Colors…", and Weight/Dashes flyouts. Purely presentational —
29
+ * every action reports a partial patch, so a colour pick keeps the current
30
+ * weight and vice-versa.
31
+ *
32
+ * The flyouts render *inside* the popover panel rather than in their own
33
+ * portal: `Popover`'s dismiss watcher only knows about the trigger and the
34
+ * panel, so a portalled child would read as an outside click and close its own
35
+ * parent.
36
+ */
37
+ export declare function PictureBorderPicker(props: PictureBorderPickerProps): JSX.Element;
@@ -0,0 +1,27 @@
1
+ import { JSX } from 'solid-js';
2
+
3
+ export interface WideMenuButtonProps {
4
+ open: boolean;
5
+ onOpenChange: (open: boolean) => void;
6
+ icon?: string;
7
+ label: string;
8
+ tooltip?: string;
9
+ testId?: string;
10
+ active?: boolean;
11
+ disabled?: boolean;
12
+ /** A swatch strip under the icon, e.g. the current border colour. */
13
+ indicatorColor?: string | null;
14
+ panelClass?: string;
15
+ children: JSX.Element;
16
+ }
17
+ /**
18
+ * A dropdown whose trigger lays icon, label and chevron out on a single
19
+ * horizontal line, sized to span a ribbon group's full height. This is the
20
+ * shape Word gives its Picture Border / Picture Effects / Picture Layout
21
+ * buttons, and it is the third trigger geometry in the toolbar — distinct from
22
+ * the icon-only (`normal`) and icon-above-label (`large`) `Button`s.
23
+ *
24
+ * Unlike `Menu`, no click inside the panel is intercepted: consumers own when
25
+ * the popup closes, which nested flyouts need.
26
+ */
27
+ export declare function WideMenuButton(props: WideMenuButtonProps): JSX.Element;
@@ -143,6 +143,20 @@ export interface ColorPickerItem extends ToolbarItemBase {
143
143
  labelKey?: TranslationKey;
144
144
  label?: string;
145
145
  }
146
+ /**
147
+ * Word's Picture Border control: a wide horizontal trigger over a popup that
148
+ * carries colour grids plus Weight/Dashes flyouts. Its own item type (rather
149
+ * than a `colorPicker` variant) because a border is three facets — colour,
150
+ * weight, dash — dispatched as partial patches of one command.
151
+ */
152
+ export interface PictureBorderItem extends ToolbarItemBase {
153
+ type: "pictureBorder";
154
+ /** Command dispatched with an `ImageBorderPatch` payload. */
155
+ command: CommandRef;
156
+ palette?: ColorPalette;
157
+ labelKey?: TranslationKey;
158
+ label?: string;
159
+ }
146
160
  export interface GridPickerItem extends ToolbarItemBase {
147
161
  type: "gridPicker";
148
162
  /** Command dispatched with `{ rows, cols }` as payload. */
@@ -171,5 +185,5 @@ export interface CustomItem extends ToolbarItemBase {
171
185
  type: "custom";
172
186
  render: (api: ToolbarActionApi) => JSX.Element;
173
187
  }
174
- export type ToolbarItem = ButtonItem | ToggleItem | SplitItem | MenuItem | SelectItem | StyleGalleryItem | ColorPickerItem | GridPickerItem | SeparatorItem | GroupItem | CustomItem;
188
+ export type ToolbarItem = ButtonItem | ToggleItem | SplitItem | MenuItem | SelectItem | StyleGalleryItem | ColorPickerItem | PictureBorderItem | GridPickerItem | SeparatorItem | GroupItem | CustomItem;
175
189
  export type ToolbarItemType = ToolbarItem["type"];
@@ -0,0 +1,23 @@
1
+ import { ResizeHandleDirection } from './resizeGeometry.js';
2
+ import { EditorImageCrop } from '../core/model.js';
3
+
4
+ export interface CropSessionGeometry {
5
+ handleDirection: ResizeHandleDirection;
6
+ /** Displayed box size (px) captured when the handle was grabbed. */
7
+ startWidth: number;
8
+ startHeight: number;
9
+ /** Crop fractions captured when the handle was grabbed. */
10
+ startCrop: EditorImageCrop;
11
+ }
12
+ export interface CropResult {
13
+ crop: EditorImageCrop;
14
+ width: number;
15
+ height: number;
16
+ }
17
+ /**
18
+ * Resolves the next crop + displayed size for a crop-handle drag. `deltaX`/
19
+ * `deltaY` are pointer deltas in document px (already divided by zoom). Growing
20
+ * a side is bounded by that side's original crop (you cannot un-crop past the
21
+ * source image).
22
+ */
23
+ export declare function resolveCroppedImage(geometry: CropSessionGeometry, deltaX: number, deltaY: number): CropResult;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oasis-editor",
3
- "version": "0.0.133",
3
+ "version": "0.0.135",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",