@ibodr/draw 0.1.7 → 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 +25 -4
- package/dist/index.mjs +28 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -990,8 +990,6 @@ declare class CollaboratorCursorOverlayUtil extends OverlayUtil<DrCollaboratorCu
|
|
|
990
990
|
fontSize: number;
|
|
991
991
|
nameMaxWidth: number;
|
|
992
992
|
chatMaxWidth: number;
|
|
993
|
-
minCursorScale: number;
|
|
994
|
-
maxCursorScale: number;
|
|
995
993
|
};
|
|
996
994
|
private _truncateCache;
|
|
997
995
|
isActive(): boolean;
|
|
@@ -1040,12 +1038,35 @@ declare function mergeCollaboratorCursorLayout(overrides?: Partial<DrCollaborato
|
|
|
1040
1038
|
|
|
1041
1039
|
/** @public */
|
|
1042
1040
|
interface DrCollaboratorCursorScaleOptions {
|
|
1041
|
+
/**
|
|
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.
|
|
1049
|
+
* Default: `0.5` (50%).
|
|
1050
|
+
*/
|
|
1051
|
+
maxScaleZoom?: number;
|
|
1052
|
+
/**
|
|
1053
|
+
* Page-space only. Floor scale at `1 / minScaleZoom` when zoomed in further.
|
|
1054
|
+
* Default: `3` (300%).
|
|
1055
|
+
*/
|
|
1056
|
+
minScaleZoom?: number;
|
|
1057
|
+
/** Optional absolute lower bound applied after zoom-based scaling. */
|
|
1043
1058
|
minScale?: number;
|
|
1059
|
+
/** Optional absolute upper bound applied after zoom-based scaling. */
|
|
1044
1060
|
maxScale?: number;
|
|
1045
1061
|
}
|
|
1046
1062
|
/**
|
|
1047
|
-
*
|
|
1048
|
-
*
|
|
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`).
|
|
1067
|
+
*
|
|
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.
|
|
1049
1070
|
*
|
|
1050
1071
|
* @public
|
|
1051
1072
|
*/
|
package/dist/index.mjs
CHANGED
|
@@ -20924,13 +20924,33 @@ var CollaboratorHintOverlayUtil = class extends OverlayUtil {
|
|
|
20924
20924
|
};
|
|
20925
20925
|
|
|
20926
20926
|
// src/lib/components/collaborator-cursors/getCollaboratorCursorScale.ts
|
|
20927
|
-
var
|
|
20928
|
-
var
|
|
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;
|
|
20932
|
+
const maxScale = 1 / maxScaleZoom;
|
|
20933
|
+
const minScale = 1 / minScaleZoom;
|
|
20934
|
+
let scale = 1 / zoom;
|
|
20935
|
+
if (zoom <= maxScaleZoom) {
|
|
20936
|
+
scale = Math.min(scale, maxScale);
|
|
20937
|
+
} else if (zoom >= minScaleZoom) {
|
|
20938
|
+
scale = Math.max(scale, minScale);
|
|
20939
|
+
}
|
|
20940
|
+
if (options.minScale !== void 0) {
|
|
20941
|
+
scale = Math.max(scale, options.minScale);
|
|
20942
|
+
}
|
|
20943
|
+
if (options.maxScale !== void 0) {
|
|
20944
|
+
scale = Math.min(scale, options.maxScale);
|
|
20945
|
+
}
|
|
20946
|
+
return scale;
|
|
20947
|
+
}
|
|
20929
20948
|
function getCollaboratorCursorScale(zoom, options = {}) {
|
|
20930
|
-
const minScale = options.minScale ?? DEFAULT_MIN_CURSOR_SCALE;
|
|
20931
|
-
const maxScale = options.maxScale ?? DEFAULT_MAX_CURSOR_SCALE;
|
|
20932
20949
|
if (!Number.isFinite(zoom) || zoom <= 0) return 1;
|
|
20933
|
-
|
|
20950
|
+
if (options.space === "page") {
|
|
20951
|
+
return getPageSpaceCollaboratorCursorScale(zoom, options);
|
|
20952
|
+
}
|
|
20953
|
+
return 1;
|
|
20934
20954
|
}
|
|
20935
20955
|
|
|
20936
20956
|
// src/lib/overlays/CollaboratorCursorOverlayUtil.ts
|
|
@@ -20970,9 +20990,7 @@ var CollaboratorCursorOverlayUtil = class extends OverlayUtil {
|
|
|
20970
20990
|
zIndex: 1100,
|
|
20971
20991
|
fontSize: 12,
|
|
20972
20992
|
nameMaxWidth: 120,
|
|
20973
|
-
chatMaxWidth: 200
|
|
20974
|
-
minCursorScale: 0.85,
|
|
20975
|
-
maxCursorScale: 12
|
|
20993
|
+
chatMaxWidth: 200
|
|
20976
20994
|
};
|
|
20977
20995
|
// Cache truncated text results to avoid repeated measureText loops.
|
|
20978
20996
|
// Key format: `${maxWidth}|${text}` with an upper bound on cache size.
|
|
@@ -21003,10 +21021,7 @@ var CollaboratorCursorOverlayUtil = class extends OverlayUtil {
|
|
|
21003
21021
|
}
|
|
21004
21022
|
render(ctx, overlays) {
|
|
21005
21023
|
const zoom = this.editor.getZoomLevel();
|
|
21006
|
-
const scale = getCollaboratorCursorScale(zoom, {
|
|
21007
|
-
minScale: this.options.minCursorScale,
|
|
21008
|
-
maxScale: this.options.maxCursorScale
|
|
21009
|
-
});
|
|
21024
|
+
const scale = getCollaboratorCursorScale(zoom, { space: "page" });
|
|
21010
21025
|
const viewport = this.editor.getViewportPageBounds();
|
|
21011
21026
|
const viewportMarginX = 12 / zoom;
|
|
21012
21027
|
const viewportMarginY = 16 / zoom;
|
|
@@ -37215,7 +37230,7 @@ async function extractAssets(editor, snapshot, msg, addToast) {
|
|
|
37215
37230
|
// src/index.ts
|
|
37216
37231
|
registerDrawLibraryVersion(
|
|
37217
37232
|
"@ibodr/draw",
|
|
37218
|
-
"0.1.
|
|
37233
|
+
"0.1.9",
|
|
37219
37234
|
"esm"
|
|
37220
37235
|
);
|
|
37221
37236
|
/*!
|