@ibodr/draw 0.1.8 → 0.1.9
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/index.d.ts +14 -5
- package/dist/index.mjs +14 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1039,12 +1039,18 @@ declare function mergeCollaboratorCursorLayout(overrides?: Partial<DrCollaborato
|
|
|
1039
1039
|
/** @public */
|
|
1040
1040
|
interface DrCollaboratorCursorScaleOptions {
|
|
1041
1041
|
/**
|
|
1042
|
-
*
|
|
1042
|
+
* Coordinate space for the cursor overlay.
|
|
1043
|
+
* - `screen` (default): DOM cursors positioned via `pageToScreen` — constant pixel size.
|
|
1044
|
+
* - `page`: canvas cursors drawn in page space — compensates with `1 / zoom`.
|
|
1045
|
+
*/
|
|
1046
|
+
space?: 'screen' | 'page';
|
|
1047
|
+
/**
|
|
1048
|
+
* Page-space only. Cap scale at `1 / maxScaleZoom` when zoomed out further.
|
|
1043
1049
|
* Default: `0.5` (50%).
|
|
1044
1050
|
*/
|
|
1045
1051
|
maxScaleZoom?: number;
|
|
1046
1052
|
/**
|
|
1047
|
-
*
|
|
1053
|
+
* Page-space only. Floor scale at `1 / minScaleZoom` when zoomed in further.
|
|
1048
1054
|
* Default: `3` (300%).
|
|
1049
1055
|
*/
|
|
1050
1056
|
minScaleZoom?: number;
|
|
@@ -1054,10 +1060,13 @@ interface DrCollaboratorCursorScaleOptions {
|
|
|
1054
1060
|
maxScale?: number;
|
|
1055
1061
|
}
|
|
1056
1062
|
/**
|
|
1057
|
-
*
|
|
1063
|
+
* Scale for collaborator cursors.
|
|
1064
|
+
*
|
|
1065
|
+
* DOM cursors (`space: 'screen'`) are already positioned in screen coordinates and
|
|
1066
|
+
* keep a constant pixel size (`scale = 1`).
|
|
1058
1067
|
*
|
|
1059
|
-
*
|
|
1060
|
-
*
|
|
1068
|
+
* Canvas cursors (`space: 'page'`) are drawn in page space and use `1 / zoom` with
|
|
1069
|
+
* clamps so they stay readable when zoomed out and do not shrink further when zoomed in.
|
|
1061
1070
|
*
|
|
1062
1071
|
* @public
|
|
1063
1072
|
*/
|
package/dist/index.mjs
CHANGED
|
@@ -20924,12 +20924,11 @@ var CollaboratorHintOverlayUtil = class extends OverlayUtil {
|
|
|
20924
20924
|
};
|
|
20925
20925
|
|
|
20926
20926
|
// src/lib/components/collaborator-cursors/getCollaboratorCursorScale.ts
|
|
20927
|
-
var
|
|
20928
|
-
var
|
|
20929
|
-
function
|
|
20930
|
-
|
|
20931
|
-
const
|
|
20932
|
-
const minScaleZoom = options.minScaleZoom ?? DEFAULT_MIN_SCALE_ZOOM;
|
|
20927
|
+
var DEFAULT_PAGE_MAX_SCALE_ZOOM = 0.5;
|
|
20928
|
+
var DEFAULT_PAGE_MIN_SCALE_ZOOM = 3;
|
|
20929
|
+
function getPageSpaceCollaboratorCursorScale(zoom, options) {
|
|
20930
|
+
const maxScaleZoom = options.maxScaleZoom ?? DEFAULT_PAGE_MAX_SCALE_ZOOM;
|
|
20931
|
+
const minScaleZoom = options.minScaleZoom ?? DEFAULT_PAGE_MIN_SCALE_ZOOM;
|
|
20933
20932
|
const maxScale = 1 / maxScaleZoom;
|
|
20934
20933
|
const minScale = 1 / minScaleZoom;
|
|
20935
20934
|
let scale = 1 / zoom;
|
|
@@ -20946,6 +20945,13 @@ function getCollaboratorCursorScale(zoom, options = {}) {
|
|
|
20946
20945
|
}
|
|
20947
20946
|
return scale;
|
|
20948
20947
|
}
|
|
20948
|
+
function getCollaboratorCursorScale(zoom, options = {}) {
|
|
20949
|
+
if (!Number.isFinite(zoom) || zoom <= 0) return 1;
|
|
20950
|
+
if (options.space === "page") {
|
|
20951
|
+
return getPageSpaceCollaboratorCursorScale(zoom, options);
|
|
20952
|
+
}
|
|
20953
|
+
return 1;
|
|
20954
|
+
}
|
|
20949
20955
|
|
|
20950
20956
|
// src/lib/overlays/CollaboratorCursorOverlayUtil.ts
|
|
20951
20957
|
var _shadowHead = null;
|
|
@@ -21015,7 +21021,7 @@ var CollaboratorCursorOverlayUtil = class extends OverlayUtil {
|
|
|
21015
21021
|
}
|
|
21016
21022
|
render(ctx, overlays) {
|
|
21017
21023
|
const zoom = this.editor.getZoomLevel();
|
|
21018
|
-
const scale = getCollaboratorCursorScale(zoom);
|
|
21024
|
+
const scale = getCollaboratorCursorScale(zoom, { space: "page" });
|
|
21019
21025
|
const viewport = this.editor.getViewportPageBounds();
|
|
21020
21026
|
const viewportMarginX = 12 / zoom;
|
|
21021
21027
|
const viewportMarginY = 16 / zoom;
|
|
@@ -37224,7 +37230,7 @@ async function extractAssets(editor, snapshot, msg, addToast) {
|
|
|
37224
37230
|
// src/index.ts
|
|
37225
37231
|
registerDrawLibraryVersion(
|
|
37226
37232
|
"@ibodr/draw",
|
|
37227
|
-
"0.1.
|
|
37233
|
+
"0.1.9",
|
|
37228
37234
|
"esm"
|
|
37229
37235
|
);
|
|
37230
37236
|
/*!
|