oasis-editor 0.0.24 → 0.0.25
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-Ckv1Glbw.js → OasisEditorApp-y3iUL8-k.js} +38 -16
- package/dist/app/controllers/useEditorLayout.d.ts +2 -0
- package/dist/app/controllers/useEditorNavigation.d.ts +6 -0
- package/dist/{index-WKT6eKMj.js → index-Df7Ob0Ek.js} +84 -53
- package/dist/oasis-editor.js +43 -43
- package/dist/oasis-editor.umd.cjs +4 -4
- package/dist/ui/OasisEditorEditor.d.ts +3 -0
- package/dist/ui/app/buildEditorViewProps.d.ts +3 -0
- package/dist/ui/app/editorZoom.d.ts +25 -0
- package/dist/ui/app/useCanvasSurfaceHitResolver.d.ts +1 -0
- package/dist/ui/app/useEditorInteractionWiring.d.ts +1 -0
- package/dist/ui/canvas/CanvasHitTestService.d.ts +6 -0
- package/dist/ui/canvas/CanvasLayoutSnapshot.d.ts +29 -0
- package/package.json +1 -1
|
@@ -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>;
|
|
@@ -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;
|