oasis-editor 0.0.24 → 0.0.26

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.
@@ -14,6 +14,9 @@ export interface OasisEditorEditorLayoutProps {
14
14
  style?: JSX.CSSProperties;
15
15
  readOnly?: boolean;
16
16
  showHorizontalRuler?: boolean;
17
+ zoomPercent?: Accessor<number>;
18
+ setZoomPercent?: (value: number) => void;
19
+ zoomFactor?: Accessor<number>;
17
20
  }
18
21
  export interface OasisEditorEditorOverlayProps {
19
22
  selectionBoxes: Accessor<SelectionBox[]>;
@@ -19,6 +19,9 @@ export interface EditorViewPropsContext {
19
19
  viewportHeight: number | string | undefined;
20
20
  className: string | undefined;
21
21
  style: JSX.CSSProperties | undefined;
22
+ zoomPercent: Accessor<number>;
23
+ setZoomPercent: (value: number) => void;
24
+ zoomFactor: Accessor<number>;
22
25
  selectionBoxes: Accessor<SelectionBox[]>;
23
26
  commentHighlights: Accessor<CommentHighlightBox[]>;
24
27
  selectedImageBox: Accessor<SelectedImageBox | null>;
@@ -0,0 +1,25 @@
1
+ import { Accessor } from 'solid-js';
2
+
3
+ export declare const ZOOM_MIN = 50;
4
+ export declare const ZOOM_MAX = 200;
5
+ export declare const ZOOM_STEP = 10;
6
+ export declare const ZOOM_DEFAULT = 100;
7
+ export declare function clampZoom(value: number): number;
8
+ export interface EditorZoomController {
9
+ /** Current zoom level as a percentage (clamped to [ZOOM_MIN, ZOOM_MAX]). */
10
+ zoomPercent: Accessor<number>;
11
+ /** Set the zoom level (input is clamped). */
12
+ setZoomPercent: (value: number) => void;
13
+ /** Nudge the zoom level by `delta` percent (result is clamped). */
14
+ adjustZoom: (delta: number) => void;
15
+ /** Visual scale factor `z = zoomPercent / 100` applied to the document layer. */
16
+ zoomFactor: Accessor<number>;
17
+ }
18
+ /**
19
+ * Single source of truth for the document zoom. The factor `z` is the CSS
20
+ * `transform: scale(z)` applied to the shared `.oasis-editor-editor-scroll-content`
21
+ * layer (canvas + every overlay). Geometry consumers divide screen-space pointer
22
+ * coordinates by `z` to map back into the unscaled layout space the canvas draws
23
+ * in — see the coordinate contract in CanvasLayoutSnapshot.ts.
24
+ */
25
+ export declare function createEditorZoom(initial?: number): EditorZoomController;
@@ -8,6 +8,7 @@ export declare function createCanvasSurfaceHitResolver(deps: {
8
8
  viewportRef: Accessor<HTMLElement | null>;
9
9
  measuredBlockHeights: Accessor<Record<string, number>>;
10
10
  measuredParagraphLayouts: Accessor<Record<string, EditorLayoutParagraph>>;
11
+ zoomFactor: Accessor<number>;
11
12
  }): {
12
13
  resolveSurfaceHitAtPoint: (clientX: number, clientY: number, context?: {
13
14
  forDrag?: boolean;
@@ -38,6 +38,7 @@ export interface EditorInteractionWiringContext {
38
38
  caretBox: NavigationParams["caretBox"];
39
39
  preferredColumnX: NavigationParams["preferredColumnX"];
40
40
  setPreferredColumnX: NavigationParams["setPreferredColumnX"];
41
+ zoomFactor: NavigationParams["zoomFactor"];
41
42
  resolveSurfaceHitAtPoint: TextDragParams["resolveSurfaceHitAtPoint"];
42
43
  resolvePositionAtSurfacePoint: TableDragParams["resolvePositionAtSurfacePoint"];
43
44
  tableOps: ReturnType<typeof createEditorTableOperations>;
@@ -66,6 +66,8 @@ export interface CanvasDebugLayoutSnapshot {
66
66
  width: number;
67
67
  height: number;
68
68
  };
69
+ /** Set when the paragraph/cell is painted with a vertical-text transform. */
70
+ verticalMode?: CanvasSnapshotParagraph["verticalMode"];
69
71
  }>;
70
72
  inlineImages: Array<{
71
73
  paragraphId: string;
@@ -79,6 +81,19 @@ export interface CanvasDebugLayoutSnapshot {
79
81
  width: number;
80
82
  height: number;
81
83
  }>;
84
+ inlineTextBoxes: Array<{
85
+ paragraphId: string;
86
+ paragraphIndex: number;
87
+ zone: EditorEditingZone;
88
+ pageIndex: number;
89
+ startOffset: number;
90
+ endOffset: number;
91
+ left: number;
92
+ top: number;
93
+ width: number;
94
+ height: number;
95
+ rotation?: number;
96
+ }>;
82
97
  unsupportedRegions: Array<{
83
98
  pageIndex: number;
84
99
  zone: EditorEditingZone;
@@ -44,6 +44,12 @@ export interface ResolveCanvasHitOptions {
44
44
  state: EditorState;
45
45
  clientX: number;
46
46
  clientY: number;
47
+ /**
48
+ * Visual zoom factor (CSS `transform: scale(z)`). Screen-space pointer coords
49
+ * are mapped into the snapshot's unscaled space by dividing the distance from
50
+ * the surface origin by `z`. Defaults to 1 (no zoom).
51
+ */
52
+ zoomFactor?: number;
47
53
  /**
48
54
  * "Pierce" mode (Alt+click): select the floating object directly under the
49
55
  * cursor even when it is painted behind the text (behindDoc). When false,
@@ -145,5 +145,34 @@ export interface BuildCanvasLayoutSnapshotOptions {
145
145
  state: EditorState;
146
146
  measuredBlockHeights?: Record<string, number>;
147
147
  measuredParagraphLayouts?: Record<string, EditorLayoutParagraph>;
148
+ /**
149
+ * Visual zoom factor (CSS `transform: scale(z)`) applied to the surface. The
150
+ * snapshot is built in "screen-anchored local" space so it is invariant under
151
+ * zoom — see the coordinate contract documented on buildCanvasLayoutSnapshot.
152
+ * Defaults to 1 (no zoom).
153
+ */
154
+ zoomFactor?: number;
148
155
  }
156
+ /**
157
+ * Coordinate contract ("screen-anchored local" space)
158
+ * ----------------------------------------------------
159
+ * The document layer (`.oasis-editor-editor-scroll-content`) is scaled with a
160
+ * CSS `transform: scale(z)` and `transform-origin: top left`, so the layer's
161
+ * local origin (0,0) maps to `surfaceRect.{left,top}` on screen and a child at
162
+ * screen distance `d` from that origin sits at local `d / z`.
163
+ *
164
+ * Every coordinate in this snapshot is emitted as `surfaceRect.origin +
165
+ * offsetLocal`, where `offsetLocal` is in unscaled (pre-transform) CSS px — the
166
+ * same units the canvas draws in and the same units overlays use inside the
167
+ * scaled layer. To achieve this we divide the only zoom-affected input (the page
168
+ * element's `getBoundingClientRect`, which already reflects the transform) by
169
+ * `z` relative to the surface origin; the model offsets added on top are already
170
+ * unscaled. The result is invariant under zoom.
171
+ *
172
+ * Consumers:
173
+ * - Overlays (children of the scaled layer) use `value - surfaceRect` to get
174
+ * `offsetLocal` and let the transform do the visual scaling — no change.
175
+ * - Hit-testing receives screen-space pointer coords and converts them into
176
+ * this space at the single entry point (resolveCanvasSurfaceHitAtPoint).
177
+ */
149
178
  export declare function buildCanvasLayoutSnapshot(options: BuildCanvasLayoutSnapshotOptions): CanvasLayoutSnapshot | null;
@@ -7,5 +7,12 @@ export interface HorizontalRulerProps {
7
7
  toolbarHost: () => ToolbarHost;
8
8
  viewportRef: Accessor<HTMLDivElement | undefined>;
9
9
  readOnly: Accessor<boolean>;
10
+ /**
11
+ * Visual zoom factor `z`. The ruler lives *outside* the scaled document
12
+ * layer, so model-derived positions/sizes are rendered in screen px (× z) and
13
+ * pointer coordinates are mapped back to document px (÷ z). `pageLeft` is
14
+ * already measured in screen px from the scaled paper, so it is not scaled.
15
+ */
16
+ zoomFactor: Accessor<number>;
10
17
  }
11
18
  export declare function HorizontalRuler(props: HorizontalRulerProps): import("solid-js").JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oasis-editor",
3
- "version": "0.0.24",
3
+ "version": "0.0.26",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",