@ibodr/editor 0.2.7 → 0.2.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 +38 -1
- package/dist/index.mjs +393 -3
- package/dist/index.mjs.map +1 -1
- package/editor.css +9 -0
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -1682,6 +1682,16 @@ declare abstract class ShapeUtil<Shape extends DrShape = DrShape> {
|
|
|
1682
1682
|
* @param shape - The shape.
|
|
1683
1683
|
*/
|
|
1684
1684
|
canCull(shape: Shape): boolean;
|
|
1685
|
+
/**
|
|
1686
|
+
* Cheap canvas stand-in used when this shape is zoomed out or far outside the viewport.
|
|
1687
|
+
* Return null to keep the regular DOM node (media, in-progress strokes, anything stateful).
|
|
1688
|
+
* Selected and edited shapes always stay in the DOM.
|
|
1689
|
+
*
|
|
1690
|
+
* Coordinates consumed by the canvas are the shape's local geometry.
|
|
1691
|
+
*
|
|
1692
|
+
* @param shape - The shape.
|
|
1693
|
+
*/
|
|
1694
|
+
getLodStyle(_shape: Shape): DrLodStyle | null;
|
|
1685
1695
|
/**
|
|
1686
1696
|
* Does this shape provide a background for its children? If this is true,
|
|
1687
1697
|
* then any children with a `renderBackground` method will have their
|
|
@@ -2260,6 +2270,26 @@ declare abstract class ShapeUtil<Shape extends DrShape = DrShape> {
|
|
|
2260
2270
|
* @param initialShape - The shape at the start of the resize.
|
|
2261
2271
|
* @public
|
|
2262
2272
|
*/
|
|
2273
|
+
/**
|
|
2274
|
+
* How to paint a shape into the shared low-detail canvas.
|
|
2275
|
+
* `fill` with no `stroke` paints the geometry bounds.
|
|
2276
|
+
* `stroke` paints a decimated polyline of the geometry vertices.
|
|
2277
|
+
*
|
|
2278
|
+
* @public
|
|
2279
|
+
*/
|
|
2280
|
+
interface DrLodStyle {
|
|
2281
|
+
fill: string | null;
|
|
2282
|
+
stroke: string | null;
|
|
2283
|
+
strokeWidth: number;
|
|
2284
|
+
/** Multiplied by the shape's own opacity. Defaults to 1. */
|
|
2285
|
+
opacity?: number;
|
|
2286
|
+
/**
|
|
2287
|
+
* Unmount the shape when it is far outside the viewport, but keep the real DOM
|
|
2288
|
+
* whenever it is on screen. Used for images so a pan back does not replace the
|
|
2289
|
+
* picture with a flat stand-in.
|
|
2290
|
+
*/
|
|
2291
|
+
unmountWhenCulled?: boolean;
|
|
2292
|
+
}
|
|
2263
2293
|
interface DrCropInfo<T extends DrShape> {
|
|
2264
2294
|
handle: SelectionHandle;
|
|
2265
2295
|
change: Vec;
|
|
@@ -3032,6 +3062,12 @@ interface DrawOptions {
|
|
|
3032
3062
|
* Defaults to 500 shapes.
|
|
3033
3063
|
*/
|
|
3034
3064
|
readonly debouncedZoomThreshold: number;
|
|
3065
|
+
/**
|
|
3066
|
+
* Zoom level below which shapes that implement {@link ShapeUtil.getLodStyle} are painted into
|
|
3067
|
+
* one canvas instead of a DOM node each. Shapes whose on-screen size is still large stay in
|
|
3068
|
+
* the DOM. Defaults to 0.6.
|
|
3069
|
+
*/
|
|
3070
|
+
readonly lodZoom: number;
|
|
3035
3071
|
/**
|
|
3036
3072
|
* Whether to allow spacebar panning. When true, the spacebar will pan the camera when held down.
|
|
3037
3073
|
* When false, the spacebar will not pan the camera.
|
|
@@ -3231,6 +3267,7 @@ declare const defaultDrawOptions: {
|
|
|
3231
3267
|
readonly nonce: undefined;
|
|
3232
3268
|
readonly debouncedZoom: true;
|
|
3233
3269
|
readonly debouncedZoomThreshold: 500;
|
|
3270
|
+
readonly lodZoom: 0.6;
|
|
3234
3271
|
readonly spacebarPanning: true;
|
|
3235
3272
|
readonly rightClickPanning: true;
|
|
3236
3273
|
readonly zoomToFitPadding: 128;
|
|
@@ -10881,4 +10918,4 @@ declare function uniq<T>(array: {
|
|
|
10881
10918
|
readonly [n: number]: T;
|
|
10882
10919
|
} | null | undefined): T[];
|
|
10883
10920
|
|
|
10884
|
-
export { Arc2d, AssetUtil, BaseBoxShapeTool, BaseBoxShapeUtil, BaseFrameLikeShapeUtil, type BatchMeasurementRequest, type BindingOnChangeOptions, type BindingOnCreateOptions, type BindingOnDeleteOptions, type BindingOnShapeChangeOptions, type BindingOnShapeDeleteOptions, type BindingOnShapeIsolateOptions, BindingUtil, type BoundsSnapGeometry, type BoundsSnapPoint, BoundsSnaps, Box, type BoxLike, type CanvasMaxSize, Circle2d, ClickManager, CollaboratorsManager, ContainerProvider, type ContainerProviderProps, CubicBezier2d, CubicSpline2d, DEFAULT_ANIMATION_OPTIONS, DEFAULT_CAMERA_OPTIONS, DEFAULT_THEME, type DebugFlag, type DebugFlagDef, type DebugFlagDefaults, DefaultBackground, DefaultCanvas, DefaultCursor, DefaultErrorFallback, DefaultGrid, DefaultShapeWrapper, DefaultSpinner, DefaultSvgDefs, type DrAdjacentDirection, type DrAnyAssetUtilConstructor, type DrAnyBindingUtilConstructor, type DrAnyOverlayUtilConstructor, type DrAnyShapeUtilConstructor, type DrAssetUtilConstructor, type DrBackgroundProps, type DrBaseBoxShape, type DrBaseEventInfo, type DrBaseExternalContent, type DrBindingUtilConstructor, type DrCLickEventName, type DrCameraConstraints, type DrCameraEndPerfEvent, type DrCameraMoveOptions, type DrCameraOptions, type DrCameraStartPerfEvent, type DrCancelEvent, type DrCancelEventInfo, type DrCanvasComponentProps, type DrClickEvent, type DrClickEventInfo, type DrClickState, type DrClipboardPasteRawInfo, type DrClipboardWriteInfo, type DrCollaboratorCursorLayout, type DrCollaboratorCursorProps, type DrCompleteEvent, type DrCompleteEventInfo, type DrContent, type DrCropInfo, type DrCurrentUser, type DrCursorProps, type DrDeepLink, type DrDeepLinkOptions, type DrDragShapesInInfo, type DrDragShapesOutInfo, type DrDragShapesOverInfo, type DrDrawExternalContent, type DrDrawExternalContentSource, type DrDropShapesOverInfo, type DrEditStartInfo, type DrEditorComponents, type DrEditorOptions, type DrEditorRunOptions, type DrEditorSnapshot, type DrEmbedExternalContent, type DrEnterEventHandler, type DrErrorBoundaryProps, type DrErrorExternalContentSource, type DrErrorFallbackComponent, type DrErrorFallbackProps, type DrEventHandlers, type DrEventInfo, type DrEventMap, type DrEventMapHandler, type DrEventName, type DrExcalidrawExternalContent, type DrExcalidrawExternalContentSource, type DrExitEventHandler, type DrExportType, type DrExternalAsset, type DrExternalContent, type DrExternalContentSource, type DrFileExternalAsset, type DrFileReplaceExternalContent, type DrFilesExternalContent, type DrFramePerfEvent, type DrGeometryOpts, type DrGetShapeAtPointOptions, type DrGridProps, type DrHandleDragInfo, type DrHistoryBatchOptions, type DrHistoryDiff, type DrHistoryEntry, type DrHistoryMark, type DrImageExportOptions, type DrIndicatorPath, type DrInteractionEndPerfEvent, type DrInteractionStartPerfEvent, type DrInterruptEvent, type DrInterruptEventInfo, type DrKeyboardEvent, type DrKeyboardEventInfo, type DrKeyboardEventName, type DrLoadSessionStateSnapshotOptions, type DrLoadSnapshotOptions, type DrMeasureTextOpts, type DrMeasureTextSpanOpts, type DrMeasuredTextSize, type DrMiroExternalContent, type DrMiroExternalContentSource, type DrOnMountHandler, type DrOverlay, type DrOverlayEntry, type DrOverlayUtilConstructor, type DrPerfEventMap, type DrPerfFrameTimeStats, type DrPerfLongAnimationFrame, type DrPerfLongAnimationFrameScript, type DrPinchEvent, type DrPinchEventInfo, type DrPinchEventName, type DrPointerEvent, type DrPointerEventInfo, type DrPointerEventName, type DrPointerEventTarget, type DrRenderingShape, type DrResizeHandle, type DrResizeInfo, type DrResizeMode, type DrResizeShapeOptions, type DrRotationSnapshot, type DrSelectionHandle, type DrSessionStateSnapshot, type DrShapeErrorFallbackComponent, type DrShapeOperationPerfEvent, type DrShapeUtilCanBeLaidOutOpts, type DrShapeUtilCanBindOpts, type DrShapeUtilCanvasSvgDef, type DrShapeUtilConstructor, type DrShapeWrapperProps, type DrSpinnerProps, type DrStateNodeConstructor, type DrStoreBaseOptions, type DrStoreEventInfo, type DrStoreOptions, type DrStoreSchemaOptions, type DrStoreWithStatus, type DrSvgExportOptions, type DrSvgTextExternalContent, type DrTextExternalContent, type DrTextExternalContentSource, type DrTextOptions, type DrTickEvent, type DrTickEventInfo, type DrUndoRedoPerfEvent, type DrUpdatePointerOptions, type DrUrlExternalAsset, type DrUrlExternalContent, type DrUserPreferences, type DrWheelEvent, type DrWheelEventInfo, DrawEditor, type DrawEditorBaseProps, type DrawEditorProps, type DrawEditorStoreProps, type DrawEditorWithStoreProps, type DrawEditorWithoutStoreProps, type DrawOptions, EASINGS, EVENT_NAME_MAP, Edge2d, EdgeScrollManager, Editor, EditorAtom, EditorContext, EditorManager, EditorPortal, type EditorPortalProps, EditorProvider, type EditorProviderProps, Ellipse2d, ErrorBoundary, ErrorScreen, FontManager, type GapsSnapIndicator, Geometry2d, Geometry2dFilters, type Geometry2dOptions, Group2d, GroupShapeUtil, HALF_PI, HTMLContainer, type HTMLContainerProps, type HandleSnapGeometry, HandleSnaps, HistoryManager, InputsManager, LoadingScreen, type LoadingScreenProps, LocalIndexedDb, Mat, type MatLike, type MatModel, MenuClickCapture, OptionalErrorBoundary, type OptionalKeys, OverlayManager, type OverlayOptionsWithDisplayValues, OverlayUtil, PI, PI2, type PerfectDashTerminal, PerformanceApiAdapter, PerformanceManager, Point2d, type PointsSnapIndicator, Polygon2d, Polyline2d, ROTATE_CORNER_TO_SELECTION_CORNER, ReadonlySharedStyleMap, Rectangle2d, type RequiredKeys, type ResizeBoxOptions, type RichTextFontVisitor, type RichTextFontVisitorState, type RotateCorner, SIDES, SIN, SVGContainer, type SVGContainerProps, type SafeId, type ScribbleItem, ScribbleManager, type ScribbleSessionOptions, type SelectionCorner, type SelectionEdge, type SelectionHandle, ShapeUtil, type SharedStyle, SharedStyleMap, type SnapData, type SnapIndicator, SnapManager, SpatialIndexManager, Stadium2d, StateNode, type StoreName, type SvgExportContext, type SvgExportDef, TAB_ID, Table, TextManager, ThemeManager, TickManager, type TiptapEditor, type TiptapNode, TransformedGeometry2d, type TransformedGeometry2dOptions, USER_COLORS, type UiEvent, type UiEventType, UserPreferencesManager, Vec, type VecLike, activeElementShouldCaptureKeys, angleDistance, applyRotationToSnapshotShapes, approximately, areAnglesCompatible, average, canonicalizeRotation, centerOfCircleFromThreePoints, clamp, clampRadians, clampToBrowserMaxCanvasSize, clockwiseAngleDist, coreShapes, counterClockwiseAngleDist, createDebugValue, createDeepLinkString, createDrCurrentUser, createDrSchemaFromUtils, createDrStore, createSessionStateSnapshotSignal, dataUrlToFile, debugFlags, defaultDrawOptions, defaultUserPreferences, defaultUserStore, degreesToRadians, elementShouldCaptureKeys, extractSessionStateFromLegacySnapshot, featureFlags, getArcMeasure, getColorValue, getCursor, getDefaultCdnBaseUrl, getDroppedShapesToNewParents, getFontsFromRichText, getFreshUserPreferences, getGlobalDocument, getGlobalWindow, getIncrementedName, getOverlayDisplayValues, getOwnerDocument, getOwnerWindow, getPerfectDashProps, getPointInArcT, getPointOnCircle, getPointerInfo, getPointsOnArc, getPolygonVertices, getRotationSnapshot, getSnapshot, getSvgAsImage, getSvgPathFromPoints, getUserPreferences, getVerticesCountForArcLength, hardReset, hardResetEditor, inlineBase64AssetStore, intersectCircleCircle, intersectCirclePolygon, intersectCirclePolyline, intersectLineSegmentCircle, intersectLineSegmentLineSegment, intersectLineSegmentPolygon, intersectLineSegmentPolyline, intersectPolygonBounds, intersectPolygonPolygon, isAccelKey, isCursorInViewport, isSafeFloat, kickoutOccludedShapes, linesIntersect, loadSessionStateSnapshotIntoStore, loadSnapshot, loopToHtmlElement, maybeSnapToGrid, moveElementInto, normalizeWheel, openWindow, parseDeepLinkString, perimeterOfEllipse, pointInPolygon, polygonIntersectsPolyline, polygonsIntersect, precise, preventDefault, radiansToDegrees, rangeIntersection, refreshPage, releasePointerCapture, resizeBox, resizeScaled, resolveLineHeightPx, resolveThemes, rotateSelectionHandle, runtime, sanitizeId, setPointerCapture, setRuntimeOverrides, setUserPreferences, shortAngleDist, snapAngle, stopEventPropagation, strokeShapeIndicators, suffixSafeId, tleditors, tlenv, tlenvReactive, tlmenus, tltime, toDomPrecision, toFixed, toPrecision, uniq, useColorMode, useContainer, useContainerIfExists, useDelaySvgExport, useDrSchemaFromUtils, useDrStore, useDrawCurrentUser, useEditor, useEditorComponents, useEditorPortalHost, useEvent, useGlobalMenuIsOpen, useIsCropping, useIsEditing, useLocalStore, useMaybeEditor, useOnMount, usePassThroughWheelEvents, usePeerIds, usePresence, useReactiveEvent, useRefState, useShallowArrayIdentity, useShallowObjectIdentity, useSharedSafeId, useSvgExportContext, useTransform, useUniqueSafeId, useViewportHeight, userTypeValidator };
|
|
10921
|
+
export { Arc2d, AssetUtil, BaseBoxShapeTool, BaseBoxShapeUtil, BaseFrameLikeShapeUtil, type BatchMeasurementRequest, type BindingOnChangeOptions, type BindingOnCreateOptions, type BindingOnDeleteOptions, type BindingOnShapeChangeOptions, type BindingOnShapeDeleteOptions, type BindingOnShapeIsolateOptions, BindingUtil, type BoundsSnapGeometry, type BoundsSnapPoint, BoundsSnaps, Box, type BoxLike, type CanvasMaxSize, Circle2d, ClickManager, CollaboratorsManager, ContainerProvider, type ContainerProviderProps, CubicBezier2d, CubicSpline2d, DEFAULT_ANIMATION_OPTIONS, DEFAULT_CAMERA_OPTIONS, DEFAULT_THEME, type DebugFlag, type DebugFlagDef, type DebugFlagDefaults, DefaultBackground, DefaultCanvas, DefaultCursor, DefaultErrorFallback, DefaultGrid, DefaultShapeWrapper, DefaultSpinner, DefaultSvgDefs, type DrAdjacentDirection, type DrAnyAssetUtilConstructor, type DrAnyBindingUtilConstructor, type DrAnyOverlayUtilConstructor, type DrAnyShapeUtilConstructor, type DrAssetUtilConstructor, type DrBackgroundProps, type DrBaseBoxShape, type DrBaseEventInfo, type DrBaseExternalContent, type DrBindingUtilConstructor, type DrCLickEventName, type DrCameraConstraints, type DrCameraEndPerfEvent, type DrCameraMoveOptions, type DrCameraOptions, type DrCameraStartPerfEvent, type DrCancelEvent, type DrCancelEventInfo, type DrCanvasComponentProps, type DrClickEvent, type DrClickEventInfo, type DrClickState, type DrClipboardPasteRawInfo, type DrClipboardWriteInfo, type DrCollaboratorCursorLayout, type DrCollaboratorCursorProps, type DrCompleteEvent, type DrCompleteEventInfo, type DrContent, type DrCropInfo, type DrCurrentUser, type DrCursorProps, type DrDeepLink, type DrDeepLinkOptions, type DrDragShapesInInfo, type DrDragShapesOutInfo, type DrDragShapesOverInfo, type DrDrawExternalContent, type DrDrawExternalContentSource, type DrDropShapesOverInfo, type DrEditStartInfo, type DrEditorComponents, type DrEditorOptions, type DrEditorRunOptions, type DrEditorSnapshot, type DrEmbedExternalContent, type DrEnterEventHandler, type DrErrorBoundaryProps, type DrErrorExternalContentSource, type DrErrorFallbackComponent, type DrErrorFallbackProps, type DrEventHandlers, type DrEventInfo, type DrEventMap, type DrEventMapHandler, type DrEventName, type DrExcalidrawExternalContent, type DrExcalidrawExternalContentSource, type DrExitEventHandler, type DrExportType, type DrExternalAsset, type DrExternalContent, type DrExternalContentSource, type DrFileExternalAsset, type DrFileReplaceExternalContent, type DrFilesExternalContent, type DrFramePerfEvent, type DrGeometryOpts, type DrGetShapeAtPointOptions, type DrGridProps, type DrHandleDragInfo, type DrHistoryBatchOptions, type DrHistoryDiff, type DrHistoryEntry, type DrHistoryMark, type DrImageExportOptions, type DrIndicatorPath, type DrInteractionEndPerfEvent, type DrInteractionStartPerfEvent, type DrInterruptEvent, type DrInterruptEventInfo, type DrKeyboardEvent, type DrKeyboardEventInfo, type DrKeyboardEventName, type DrLoadSessionStateSnapshotOptions, type DrLoadSnapshotOptions, type DrLodStyle, type DrMeasureTextOpts, type DrMeasureTextSpanOpts, type DrMeasuredTextSize, type DrMiroExternalContent, type DrMiroExternalContentSource, type DrOnMountHandler, type DrOverlay, type DrOverlayEntry, type DrOverlayUtilConstructor, type DrPerfEventMap, type DrPerfFrameTimeStats, type DrPerfLongAnimationFrame, type DrPerfLongAnimationFrameScript, type DrPinchEvent, type DrPinchEventInfo, type DrPinchEventName, type DrPointerEvent, type DrPointerEventInfo, type DrPointerEventName, type DrPointerEventTarget, type DrRenderingShape, type DrResizeHandle, type DrResizeInfo, type DrResizeMode, type DrResizeShapeOptions, type DrRotationSnapshot, type DrSelectionHandle, type DrSessionStateSnapshot, type DrShapeErrorFallbackComponent, type DrShapeOperationPerfEvent, type DrShapeUtilCanBeLaidOutOpts, type DrShapeUtilCanBindOpts, type DrShapeUtilCanvasSvgDef, type DrShapeUtilConstructor, type DrShapeWrapperProps, type DrSpinnerProps, type DrStateNodeConstructor, type DrStoreBaseOptions, type DrStoreEventInfo, type DrStoreOptions, type DrStoreSchemaOptions, type DrStoreWithStatus, type DrSvgExportOptions, type DrSvgTextExternalContent, type DrTextExternalContent, type DrTextExternalContentSource, type DrTextOptions, type DrTickEvent, type DrTickEventInfo, type DrUndoRedoPerfEvent, type DrUpdatePointerOptions, type DrUrlExternalAsset, type DrUrlExternalContent, type DrUserPreferences, type DrWheelEvent, type DrWheelEventInfo, DrawEditor, type DrawEditorBaseProps, type DrawEditorProps, type DrawEditorStoreProps, type DrawEditorWithStoreProps, type DrawEditorWithoutStoreProps, type DrawOptions, EASINGS, EVENT_NAME_MAP, Edge2d, EdgeScrollManager, Editor, EditorAtom, EditorContext, EditorManager, EditorPortal, type EditorPortalProps, EditorProvider, type EditorProviderProps, Ellipse2d, ErrorBoundary, ErrorScreen, FontManager, type GapsSnapIndicator, Geometry2d, Geometry2dFilters, type Geometry2dOptions, Group2d, GroupShapeUtil, HALF_PI, HTMLContainer, type HTMLContainerProps, type HandleSnapGeometry, HandleSnaps, HistoryManager, InputsManager, LoadingScreen, type LoadingScreenProps, LocalIndexedDb, Mat, type MatLike, type MatModel, MenuClickCapture, OptionalErrorBoundary, type OptionalKeys, OverlayManager, type OverlayOptionsWithDisplayValues, OverlayUtil, PI, PI2, type PerfectDashTerminal, PerformanceApiAdapter, PerformanceManager, Point2d, type PointsSnapIndicator, Polygon2d, Polyline2d, ROTATE_CORNER_TO_SELECTION_CORNER, ReadonlySharedStyleMap, Rectangle2d, type RequiredKeys, type ResizeBoxOptions, type RichTextFontVisitor, type RichTextFontVisitorState, type RotateCorner, SIDES, SIN, SVGContainer, type SVGContainerProps, type SafeId, type ScribbleItem, ScribbleManager, type ScribbleSessionOptions, type SelectionCorner, type SelectionEdge, type SelectionHandle, ShapeUtil, type SharedStyle, SharedStyleMap, type SnapData, type SnapIndicator, SnapManager, SpatialIndexManager, Stadium2d, StateNode, type StoreName, type SvgExportContext, type SvgExportDef, TAB_ID, Table, TextManager, ThemeManager, TickManager, type TiptapEditor, type TiptapNode, TransformedGeometry2d, type TransformedGeometry2dOptions, USER_COLORS, type UiEvent, type UiEventType, UserPreferencesManager, Vec, type VecLike, activeElementShouldCaptureKeys, angleDistance, applyRotationToSnapshotShapes, approximately, areAnglesCompatible, average, canonicalizeRotation, centerOfCircleFromThreePoints, clamp, clampRadians, clampToBrowserMaxCanvasSize, clockwiseAngleDist, coreShapes, counterClockwiseAngleDist, createDebugValue, createDeepLinkString, createDrCurrentUser, createDrSchemaFromUtils, createDrStore, createSessionStateSnapshotSignal, dataUrlToFile, debugFlags, defaultDrawOptions, defaultUserPreferences, defaultUserStore, degreesToRadians, elementShouldCaptureKeys, extractSessionStateFromLegacySnapshot, featureFlags, getArcMeasure, getColorValue, getCursor, getDefaultCdnBaseUrl, getDroppedShapesToNewParents, getFontsFromRichText, getFreshUserPreferences, getGlobalDocument, getGlobalWindow, getIncrementedName, getOverlayDisplayValues, getOwnerDocument, getOwnerWindow, getPerfectDashProps, getPointInArcT, getPointOnCircle, getPointerInfo, getPointsOnArc, getPolygonVertices, getRotationSnapshot, getSnapshot, getSvgAsImage, getSvgPathFromPoints, getUserPreferences, getVerticesCountForArcLength, hardReset, hardResetEditor, inlineBase64AssetStore, intersectCircleCircle, intersectCirclePolygon, intersectCirclePolyline, intersectLineSegmentCircle, intersectLineSegmentLineSegment, intersectLineSegmentPolygon, intersectLineSegmentPolyline, intersectPolygonBounds, intersectPolygonPolygon, isAccelKey, isCursorInViewport, isSafeFloat, kickoutOccludedShapes, linesIntersect, loadSessionStateSnapshotIntoStore, loadSnapshot, loopToHtmlElement, maybeSnapToGrid, moveElementInto, normalizeWheel, openWindow, parseDeepLinkString, perimeterOfEllipse, pointInPolygon, polygonIntersectsPolyline, polygonsIntersect, precise, preventDefault, radiansToDegrees, rangeIntersection, refreshPage, releasePointerCapture, resizeBox, resizeScaled, resolveLineHeightPx, resolveThemes, rotateSelectionHandle, runtime, sanitizeId, setPointerCapture, setRuntimeOverrides, setUserPreferences, shortAngleDist, snapAngle, stopEventPropagation, strokeShapeIndicators, suffixSafeId, tleditors, tlenv, tlenvReactive, tlmenus, tltime, toDomPrecision, toFixed, toPrecision, uniq, useColorMode, useContainer, useContainerIfExists, useDelaySvgExport, useDrSchemaFromUtils, useDrStore, useDrawCurrentUser, useEditor, useEditorComponents, useEditorPortalHost, useEvent, useGlobalMenuIsOpen, useIsCropping, useIsEditing, useLocalStore, useMaybeEditor, useOnMount, usePassThroughWheelEvents, usePeerIds, usePresence, useReactiveEvent, useRefState, useShallowArrayIdentity, useShallowObjectIdentity, useSharedSafeId, useSvgExportContext, useTransform, useUniqueSafeId, useViewportHeight, userTypeValidator };
|
package/dist/index.mjs
CHANGED
|
@@ -4457,6 +4457,382 @@ function drawGeometryStroke(ctx, geometry) {
|
|
|
4457
4457
|
if (geometry.isClosed) ctx.closePath();
|
|
4458
4458
|
ctx.stroke();
|
|
4459
4459
|
}
|
|
4460
|
+
|
|
4461
|
+
// src/lib/editor/lod/shapeRenderMode.ts
|
|
4462
|
+
var LOD_SMALL_SCREEN_PX = 80;
|
|
4463
|
+
var LOD_CULL_MARGIN = 0.75;
|
|
4464
|
+
function getShapeRenderMode(input) {
|
|
4465
|
+
if (!input.hasLodStyle || input.interactive) return "dom";
|
|
4466
|
+
if (input.outsideViewport) return "unmounted";
|
|
4467
|
+
if (input.unmountWhenCulled) return "dom";
|
|
4468
|
+
const maxSide = Math.max(input.pageWidth, input.pageHeight) * input.zoom;
|
|
4469
|
+
if (input.zoom < input.lodZoom || maxSide < LOD_SMALL_SCREEN_PX) return "canvas";
|
|
4470
|
+
return "dom";
|
|
4471
|
+
}
|
|
4472
|
+
var MAX_LOD_POINTS = 48;
|
|
4473
|
+
var meshCache = /* @__PURE__ */ new WeakMap();
|
|
4474
|
+
var styleCache = /* @__PURE__ */ new WeakMap();
|
|
4475
|
+
var retainedOutside = /* @__PURE__ */ new WeakMap();
|
|
4476
|
+
function lodStyleFor(editor, shape) {
|
|
4477
|
+
const theme = editor.getCurrentTheme();
|
|
4478
|
+
const colorMode = editor.getColorMode();
|
|
4479
|
+
const cached = styleCache.get(shape);
|
|
4480
|
+
if (cached && cached.theme === theme && cached.colorMode === colorMode) return cached.style;
|
|
4481
|
+
let style = null;
|
|
4482
|
+
try {
|
|
4483
|
+
style = editor.getShapeUtil(shape).getLodStyle(shape);
|
|
4484
|
+
} catch {
|
|
4485
|
+
style = null;
|
|
4486
|
+
}
|
|
4487
|
+
styleCache.set(shape, { theme, colorMode, style });
|
|
4488
|
+
return style;
|
|
4489
|
+
}
|
|
4490
|
+
function decimate(vertices) {
|
|
4491
|
+
const count = vertices.length;
|
|
4492
|
+
if (count === 0) return new Float32Array(0);
|
|
4493
|
+
const step = count <= MAX_LOD_POINTS ? 1 : Math.ceil((count - 1) / (MAX_LOD_POINTS - 1));
|
|
4494
|
+
const indexes = [];
|
|
4495
|
+
for (let i = 0; i < count - 1; i += step) indexes.push(i);
|
|
4496
|
+
indexes.push(count - 1);
|
|
4497
|
+
const points = new Float32Array(indexes.length * 2);
|
|
4498
|
+
for (let i = 0; i < indexes.length; i++) {
|
|
4499
|
+
const vertex = vertices[indexes[i]];
|
|
4500
|
+
points[i * 2] = vertex.x;
|
|
4501
|
+
points[i * 2 + 1] = vertex.y;
|
|
4502
|
+
}
|
|
4503
|
+
return points;
|
|
4504
|
+
}
|
|
4505
|
+
function meshFor(editor, shape, style) {
|
|
4506
|
+
const cached = meshCache.get(shape);
|
|
4507
|
+
if (cached && cached.style === style) return cached.mesh;
|
|
4508
|
+
let mesh = null;
|
|
4509
|
+
try {
|
|
4510
|
+
const geometry = editor.getShapeGeometry(shape);
|
|
4511
|
+
const bounds = geometry.bounds;
|
|
4512
|
+
const stroke = style.stroke;
|
|
4513
|
+
const needsPath = Boolean(stroke) || Boolean(style.fill) && geometry.vertices.length > 1;
|
|
4514
|
+
const fillOnly = Boolean(style.fill) && !stroke;
|
|
4515
|
+
mesh = {
|
|
4516
|
+
fill: style.fill,
|
|
4517
|
+
stroke,
|
|
4518
|
+
strokeWidth: style.strokeWidth,
|
|
4519
|
+
opacity: (shape.opacity ?? 1) * (style.opacity ?? 1),
|
|
4520
|
+
x: bounds.x,
|
|
4521
|
+
y: bounds.y,
|
|
4522
|
+
w: bounds.w,
|
|
4523
|
+
h: bounds.h,
|
|
4524
|
+
points: fillOnly || !needsPath ? null : decimate(geometry.vertices),
|
|
4525
|
+
closed: geometry.isClosed
|
|
4526
|
+
};
|
|
4527
|
+
} catch {
|
|
4528
|
+
mesh = null;
|
|
4529
|
+
}
|
|
4530
|
+
meshCache.set(shape, { style, mesh });
|
|
4531
|
+
return mesh;
|
|
4532
|
+
}
|
|
4533
|
+
function transformedBounds(matrix, mesh) {
|
|
4534
|
+
const x0 = mesh.x;
|
|
4535
|
+
const y0 = mesh.y;
|
|
4536
|
+
const x1 = mesh.x + mesh.w;
|
|
4537
|
+
const y1 = mesh.y + mesh.h;
|
|
4538
|
+
return Box.FromPoints([
|
|
4539
|
+
matrix.applyToPoint({ x: x0, y: y0 }),
|
|
4540
|
+
matrix.applyToPoint({ x: x1, y: y0 }),
|
|
4541
|
+
matrix.applyToPoint({ x: x1, y: y1 }),
|
|
4542
|
+
matrix.applyToPoint({ x: x0, y: y1 })
|
|
4543
|
+
]);
|
|
4544
|
+
}
|
|
4545
|
+
function isInteractive(editor, shape, selected, editingId) {
|
|
4546
|
+
const soleId = selected.size === 1 ? selected.values().next().value : void 0;
|
|
4547
|
+
let current = shape;
|
|
4548
|
+
for (let depth = 0; depth < 32 && current; depth++) {
|
|
4549
|
+
if (current.id === editingId || soleId !== void 0 && current.id === soleId) return true;
|
|
4550
|
+
const parentId = current.parentId;
|
|
4551
|
+
if (!editor.store.has(parentId)) return false;
|
|
4552
|
+
const parent = editor.store.unsafeGetWithoutCapture(parentId);
|
|
4553
|
+
if (!parent || parent.typeName !== "shape") return false;
|
|
4554
|
+
current = parent;
|
|
4555
|
+
}
|
|
4556
|
+
return false;
|
|
4557
|
+
}
|
|
4558
|
+
function readFrame(editor) {
|
|
4559
|
+
const viewport = editor.getViewportPageBounds();
|
|
4560
|
+
const pad = Math.max(viewport.w, viewport.h) * LOD_CULL_MARGIN;
|
|
4561
|
+
const selectedIds = editor.getSelectedShapeIds();
|
|
4562
|
+
return {
|
|
4563
|
+
zoom: editor.getZoomLevel(),
|
|
4564
|
+
lodZoom: editor.options.lodZoom,
|
|
4565
|
+
debug: debugFlags.debugSvg.get() && editor.getInstanceState().isDebugMode,
|
|
4566
|
+
moving: editor.getCameraState() === "moving",
|
|
4567
|
+
selectedIds,
|
|
4568
|
+
selected: new Set(selectedIds),
|
|
4569
|
+
editingId: editor.getEditingShapeId(),
|
|
4570
|
+
viewport,
|
|
4571
|
+
expanded: viewport.clone().expandBy(pad)
|
|
4572
|
+
};
|
|
4573
|
+
}
|
|
4574
|
+
function outsideSet(editor, frame, shapes) {
|
|
4575
|
+
const live = /* @__PURE__ */ new Set();
|
|
4576
|
+
if (!frame.debug) {
|
|
4577
|
+
for (const shape of shapes) {
|
|
4578
|
+
if (editor.isShapeHidden(shape)) continue;
|
|
4579
|
+
const style = lodStyleFor(editor, shape);
|
|
4580
|
+
if (!style) continue;
|
|
4581
|
+
if (style.unmountWhenCulled) {
|
|
4582
|
+
const bounds = editor.getShapePageBounds(shape);
|
|
4583
|
+
if (bounds && !frame.expanded.collides(bounds)) live.add(shape.id);
|
|
4584
|
+
continue;
|
|
4585
|
+
}
|
|
4586
|
+
const mesh = meshFor(editor, shape, style);
|
|
4587
|
+
if (!mesh) continue;
|
|
4588
|
+
const matrix = editor.getShapePageTransform(shape);
|
|
4589
|
+
if (!frame.expanded.collides(transformedBounds(matrix, mesh))) live.add(shape.id);
|
|
4590
|
+
}
|
|
4591
|
+
}
|
|
4592
|
+
if (!frame.moving) {
|
|
4593
|
+
retainedOutside.set(editor, live);
|
|
4594
|
+
return live;
|
|
4595
|
+
}
|
|
4596
|
+
const retained = retainedOutside.get(editor);
|
|
4597
|
+
if (!retained) {
|
|
4598
|
+
retainedOutside.set(editor, live);
|
|
4599
|
+
return live;
|
|
4600
|
+
}
|
|
4601
|
+
for (const id of retained) {
|
|
4602
|
+
if (!live.has(id)) retained.delete(id);
|
|
4603
|
+
}
|
|
4604
|
+
return retained;
|
|
4605
|
+
}
|
|
4606
|
+
function modeFor(editor, shape, frame, outside) {
|
|
4607
|
+
if (frame.debug || editor.isShapeHidden(shape)) return "dom";
|
|
4608
|
+
const style = lodStyleFor(editor, shape);
|
|
4609
|
+
const mesh = style ? meshFor(editor, shape, style) : null;
|
|
4610
|
+
return getShapeRenderMode({
|
|
4611
|
+
zoom: frame.zoom,
|
|
4612
|
+
lodZoom: frame.lodZoom,
|
|
4613
|
+
hasLodStyle: Boolean(style && (mesh || style.unmountWhenCulled)),
|
|
4614
|
+
interactive: isInteractive(editor, shape, frame.selected, frame.editingId),
|
|
4615
|
+
outsideViewport: outside.has(shape.id),
|
|
4616
|
+
unmountWhenCulled: Boolean(style?.unmountWhenCulled),
|
|
4617
|
+
pageWidth: mesh?.w ?? 0,
|
|
4618
|
+
pageHeight: mesh?.h ?? 0
|
|
4619
|
+
});
|
|
4620
|
+
}
|
|
4621
|
+
function trace(ctx, points) {
|
|
4622
|
+
ctx.beginPath();
|
|
4623
|
+
ctx.moveTo(points[0], points[1]);
|
|
4624
|
+
for (let i = 2; i < points.length; i += 2) {
|
|
4625
|
+
ctx.lineTo(points[i], points[i + 1]);
|
|
4626
|
+
}
|
|
4627
|
+
}
|
|
4628
|
+
function paintShape(ctx, camera, dpr, matrix, mesh, padPx = 0) {
|
|
4629
|
+
if (mesh.opacity <= 0) return;
|
|
4630
|
+
const z = camera.z || 1;
|
|
4631
|
+
ctx.globalAlpha = mesh.opacity;
|
|
4632
|
+
ctx.setTransform(
|
|
4633
|
+
dpr * z * matrix.a,
|
|
4634
|
+
dpr * z * matrix.b,
|
|
4635
|
+
dpr * z * matrix.c,
|
|
4636
|
+
dpr * z * matrix.d,
|
|
4637
|
+
dpr * z * (matrix.e + camera.x) + padPx,
|
|
4638
|
+
dpr * z * (matrix.f + camera.y) + padPx
|
|
4639
|
+
);
|
|
4640
|
+
if (mesh.fill && !mesh.points) {
|
|
4641
|
+
ctx.fillStyle = mesh.fill;
|
|
4642
|
+
ctx.fillRect(mesh.x, mesh.y, Math.max(mesh.w, 1), Math.max(mesh.h, 1));
|
|
4643
|
+
} else if (mesh.points && mesh.points.length >= 4) {
|
|
4644
|
+
if (mesh.fill) {
|
|
4645
|
+
ctx.fillStyle = mesh.fill;
|
|
4646
|
+
trace(ctx, mesh.points);
|
|
4647
|
+
if (mesh.closed) ctx.closePath();
|
|
4648
|
+
ctx.fill();
|
|
4649
|
+
}
|
|
4650
|
+
if (mesh.stroke) {
|
|
4651
|
+
ctx.strokeStyle = mesh.stroke;
|
|
4652
|
+
ctx.lineWidth = Math.max(mesh.strokeWidth, 1 / z);
|
|
4653
|
+
ctx.lineCap = "round";
|
|
4654
|
+
ctx.lineJoin = "round";
|
|
4655
|
+
trace(ctx, mesh.points);
|
|
4656
|
+
ctx.stroke();
|
|
4657
|
+
}
|
|
4658
|
+
} else if (mesh.fill) {
|
|
4659
|
+
ctx.fillStyle = mesh.fill;
|
|
4660
|
+
ctx.beginPath();
|
|
4661
|
+
ctx.arc(
|
|
4662
|
+
mesh.x + mesh.w / 2,
|
|
4663
|
+
mesh.y + mesh.h / 2,
|
|
4664
|
+
Math.max(mesh.w, mesh.h, mesh.strokeWidth) / 2,
|
|
4665
|
+
0,
|
|
4666
|
+
Math.PI * 2
|
|
4667
|
+
);
|
|
4668
|
+
ctx.fill();
|
|
4669
|
+
}
|
|
4670
|
+
}
|
|
4671
|
+
var LOD_OVERSCAN_SCREEN_PX = 192;
|
|
4672
|
+
var LOD_BITMAP_MAX_PX = 8192;
|
|
4673
|
+
function lodBitmapCovers(bitmap, camera, viewport, dpr, shapes, frame, theme, colorMode) {
|
|
4674
|
+
if (bitmap.zoom !== camera.z || bitmap.dpr !== dpr) return false;
|
|
4675
|
+
if (bitmap.shapes !== shapes || bitmap.selectedIds !== frame.selectedIds) return false;
|
|
4676
|
+
if (bitmap.editingId !== frame.editingId || bitmap.theme !== theme || bitmap.colorMode !== colorMode) {
|
|
4677
|
+
return false;
|
|
4678
|
+
}
|
|
4679
|
+
if (Math.abs(bitmap.viewW - viewport.w) > 0.5 || Math.abs(bitmap.viewH - viewport.h) > 0.5) {
|
|
4680
|
+
return false;
|
|
4681
|
+
}
|
|
4682
|
+
const inset = 8 / (camera.z || 1);
|
|
4683
|
+
const covered = new Box(
|
|
4684
|
+
-bitmap.cameraX - bitmap.pad + inset,
|
|
4685
|
+
-bitmap.cameraY - bitmap.pad + inset,
|
|
4686
|
+
bitmap.viewW + bitmap.pad * 2 - inset * 2,
|
|
4687
|
+
bitmap.viewH + bitmap.pad * 2 - inset * 2
|
|
4688
|
+
);
|
|
4689
|
+
return covered.contains(viewport);
|
|
4690
|
+
}
|
|
4691
|
+
function blitLodBitmap(ctx, width, height, bitmap, camera) {
|
|
4692
|
+
const z = camera.z || 1;
|
|
4693
|
+
const padPx = bitmap.pad * z * bitmap.dpr;
|
|
4694
|
+
ctx.globalAlpha = 1;
|
|
4695
|
+
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
4696
|
+
ctx.clearRect(0, 0, width, height);
|
|
4697
|
+
ctx.drawImage(
|
|
4698
|
+
bitmap.canvas,
|
|
4699
|
+
(camera.x - bitmap.cameraX) * z * bitmap.dpr - padPx,
|
|
4700
|
+
(camera.y - bitmap.cameraY) * z * bitmap.dpr - padPx
|
|
4701
|
+
);
|
|
4702
|
+
}
|
|
4703
|
+
function paintVisibleLodShapes(ctx, editor, camera, dpr, shapes, frame, paintBounds, padPx) {
|
|
4704
|
+
for (const shape of shapes) {
|
|
4705
|
+
if (editor.isShapeHidden(shape)) continue;
|
|
4706
|
+
const style = lodStyleFor(editor, shape);
|
|
4707
|
+
if (!style || style.unmountWhenCulled) continue;
|
|
4708
|
+
const mesh = meshFor(editor, shape, style);
|
|
4709
|
+
if (!mesh) continue;
|
|
4710
|
+
const mode = getShapeRenderMode({
|
|
4711
|
+
zoom: frame.zoom,
|
|
4712
|
+
lodZoom: frame.lodZoom,
|
|
4713
|
+
hasLodStyle: true,
|
|
4714
|
+
interactive: isInteractive(editor, shape, frame.selected, frame.editingId),
|
|
4715
|
+
outsideViewport: false,
|
|
4716
|
+
pageWidth: mesh.w,
|
|
4717
|
+
pageHeight: mesh.h
|
|
4718
|
+
});
|
|
4719
|
+
if (mode !== "canvas" || frame.debug) continue;
|
|
4720
|
+
const matrix = editor.getShapePageTransform(shape);
|
|
4721
|
+
if (!paintBounds.collides(transformedBounds(matrix, mesh))) continue;
|
|
4722
|
+
paintShape(ctx, camera, dpr, matrix, mesh, padPx);
|
|
4723
|
+
}
|
|
4724
|
+
}
|
|
4725
|
+
function useMountedRenderingShapes() {
|
|
4726
|
+
const editor = useEditor();
|
|
4727
|
+
const mountedRef = useRef([]);
|
|
4728
|
+
return useValue(
|
|
4729
|
+
"mounted rendering shapes",
|
|
4730
|
+
() => {
|
|
4731
|
+
const rendering = editor.getRenderingShapes();
|
|
4732
|
+
const shapes = editor.getCurrentPageShapesSorted();
|
|
4733
|
+
editor.getCurrentTheme();
|
|
4734
|
+
editor.getColorMode();
|
|
4735
|
+
const frame = readFrame(editor);
|
|
4736
|
+
const outside = unsafe__withoutCapture(() => outsideSet(editor, frame, shapes));
|
|
4737
|
+
const next = [];
|
|
4738
|
+
for (const renderingShape of rendering) {
|
|
4739
|
+
const mode = unsafe__withoutCapture(
|
|
4740
|
+
() => modeFor(editor, renderingShape.shape, frame, outside)
|
|
4741
|
+
);
|
|
4742
|
+
if (mode === "dom") next.push(renderingShape);
|
|
4743
|
+
}
|
|
4744
|
+
const prev = mountedRef.current;
|
|
4745
|
+
if (prev.length === next.length && prev.every((entry, index) => {
|
|
4746
|
+
const other = next[index];
|
|
4747
|
+
return entry.id === other.id && entry.shape === other.shape && entry.index === other.index && entry.backgroundIndex === other.backgroundIndex && entry.opacity === other.opacity;
|
|
4748
|
+
})) {
|
|
4749
|
+
return prev;
|
|
4750
|
+
}
|
|
4751
|
+
mountedRef.current = next;
|
|
4752
|
+
return next;
|
|
4753
|
+
},
|
|
4754
|
+
[editor]
|
|
4755
|
+
);
|
|
4756
|
+
}
|
|
4757
|
+
function LodCanvas() {
|
|
4758
|
+
const editor = useEditor();
|
|
4759
|
+
const canvasRef = useRef(null);
|
|
4760
|
+
const bitmapRef = useRef(null);
|
|
4761
|
+
useQuickReactor(
|
|
4762
|
+
"lod canvas",
|
|
4763
|
+
() => {
|
|
4764
|
+
const canvas = canvasRef.current;
|
|
4765
|
+
if (!canvas) return;
|
|
4766
|
+
const camera = editor.getCamera();
|
|
4767
|
+
const screen = editor.getViewportScreenBounds();
|
|
4768
|
+
const shapes = editor.getCurrentPageShapesSorted();
|
|
4769
|
+
const theme = editor.getCurrentTheme();
|
|
4770
|
+
const colorMode = editor.getColorMode();
|
|
4771
|
+
const frame = readFrame(editor);
|
|
4772
|
+
const dpr = window.devicePixelRatio || 1;
|
|
4773
|
+
const width = Math.max(1, Math.round((screen.w || canvas.clientWidth) * dpr));
|
|
4774
|
+
const height = Math.max(1, Math.round((screen.h || canvas.clientHeight) * dpr));
|
|
4775
|
+
if (canvas.width !== width || canvas.height !== height) {
|
|
4776
|
+
canvas.width = width;
|
|
4777
|
+
canvas.height = height;
|
|
4778
|
+
}
|
|
4779
|
+
const ctx = canvas.getContext("2d");
|
|
4780
|
+
if (!ctx) return;
|
|
4781
|
+
unsafe__withoutCapture(() => {
|
|
4782
|
+
const cached = bitmapRef.current;
|
|
4783
|
+
if (!frame.debug && cached && lodBitmapCovers(cached, camera, frame.viewport, dpr, shapes, frame, theme, colorMode)) {
|
|
4784
|
+
blitLodBitmap(ctx, width, height, cached, camera);
|
|
4785
|
+
return;
|
|
4786
|
+
}
|
|
4787
|
+
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
4788
|
+
ctx.clearRect(0, 0, width, height);
|
|
4789
|
+
if (frame.debug) {
|
|
4790
|
+
bitmapRef.current = null;
|
|
4791
|
+
return;
|
|
4792
|
+
}
|
|
4793
|
+
const pad = LOD_OVERSCAN_SCREEN_PX / (camera.z || 1);
|
|
4794
|
+
const paintBounds = frame.viewport.clone().expandBy(pad);
|
|
4795
|
+
const cacheW = Math.round((frame.viewport.w + pad * 2) * (camera.z || 1) * dpr);
|
|
4796
|
+
const cacheH = Math.round((frame.viewport.h + pad * 2) * (camera.z || 1) * dpr);
|
|
4797
|
+
const canCache = cacheW > 0 && cacheH > 0 && cacheW <= LOD_BITMAP_MAX_PX && cacheH <= LOD_BITMAP_MAX_PX;
|
|
4798
|
+
const target = canCache ? cached?.canvas ?? document.createElement("canvas") : null;
|
|
4799
|
+
if (target && (target.width !== cacheW || target.height !== cacheH)) {
|
|
4800
|
+
target.width = cacheW;
|
|
4801
|
+
target.height = cacheH;
|
|
4802
|
+
}
|
|
4803
|
+
const padPx = canCache ? pad * (camera.z || 1) * dpr : 0;
|
|
4804
|
+
const paintCtx = target?.getContext("2d") ?? ctx;
|
|
4805
|
+
if (target) {
|
|
4806
|
+
paintCtx.globalAlpha = 1;
|
|
4807
|
+
paintCtx.setTransform(1, 0, 0, 1, 0, 0);
|
|
4808
|
+
paintCtx.clearRect(0, 0, cacheW, cacheH);
|
|
4809
|
+
}
|
|
4810
|
+
paintVisibleLodShapes(paintCtx, editor, camera, dpr, shapes, frame, paintBounds, padPx);
|
|
4811
|
+
if (target) {
|
|
4812
|
+
const bitmap = {
|
|
4813
|
+
zoom: camera.z,
|
|
4814
|
+
dpr,
|
|
4815
|
+
cameraX: camera.x,
|
|
4816
|
+
cameraY: camera.y,
|
|
4817
|
+
pad,
|
|
4818
|
+
viewW: frame.viewport.w,
|
|
4819
|
+
viewH: frame.viewport.h,
|
|
4820
|
+
shapes,
|
|
4821
|
+
selectedIds: frame.selectedIds,
|
|
4822
|
+
editingId: frame.editingId,
|
|
4823
|
+
theme,
|
|
4824
|
+
colorMode,
|
|
4825
|
+
canvas: target
|
|
4826
|
+
};
|
|
4827
|
+
bitmapRef.current = bitmap;
|
|
4828
|
+
blitLodBitmap(ctx, width, height, bitmap, camera);
|
|
4829
|
+
}
|
|
4830
|
+
});
|
|
4831
|
+
},
|
|
4832
|
+
[editor]
|
|
4833
|
+
);
|
|
4834
|
+
return /* @__PURE__ */ jsx("canvas", { ref: canvasRef, className: "dr-lod-canvas", "aria-hidden": "true" });
|
|
4835
|
+
}
|
|
4460
4836
|
function DefaultCanvas({ className }) {
|
|
4461
4837
|
const editor = useEditor();
|
|
4462
4838
|
const { Background, SvgDefs } = useEditorComponents();
|
|
@@ -4559,6 +4935,7 @@ function DefaultCanvas({ className }) {
|
|
|
4559
4935
|
] }) }),
|
|
4560
4936
|
Background && /* @__PURE__ */ jsx("div", { className: "dr-background__wrapper", children: /* @__PURE__ */ jsx(BackgroundWrapper, {}) }),
|
|
4561
4937
|
isGridMode && backgroundType === "none" && Grid && /* @__PURE__ */ jsx(GridWrapper, {}),
|
|
4938
|
+
hideShapes ? null : /* @__PURE__ */ jsx(LodCanvas, {}),
|
|
4562
4939
|
/* @__PURE__ */ jsxs("div", { ref: rHtmlLayer, className: "dr-html-layer dr-shapes", draggable: false, children: [
|
|
4563
4940
|
/* @__PURE__ */ jsx(OnTheCanvasWrapper, {}),
|
|
4564
4941
|
hideShapes ? null : /* @__PURE__ */ jsx(ShapesLayer, { canvasRef: rCanvas })
|
|
@@ -4605,9 +4982,9 @@ function BackgroundWrapper() {
|
|
|
4605
4982
|
return /* @__PURE__ */ jsx(Background, { x, y, z });
|
|
4606
4983
|
}
|
|
4607
4984
|
function ShapesLayer({ canvasRef }) {
|
|
4608
|
-
|
|
4985
|
+
useEditor();
|
|
4609
4986
|
const debugSvg = useValue("debug svg", () => debugFlags.debugSvg.get(), [debugFlags]);
|
|
4610
|
-
const renderingShapes =
|
|
4987
|
+
const renderingShapes = useMountedRenderingShapes();
|
|
4611
4988
|
return /* @__PURE__ */ jsxs(ShapeCullingProvider, { children: [
|
|
4612
4989
|
renderingShapes.map(
|
|
4613
4990
|
(result) => debugSvg ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
@@ -6025,6 +6402,18 @@ var ShapeUtil = class {
|
|
|
6025
6402
|
canCull(shape) {
|
|
6026
6403
|
return true;
|
|
6027
6404
|
}
|
|
6405
|
+
/**
|
|
6406
|
+
* Cheap canvas stand-in used when this shape is zoomed out or far outside the viewport.
|
|
6407
|
+
* Return null to keep the regular DOM node (media, in-progress strokes, anything stateful).
|
|
6408
|
+
* Selected and edited shapes always stay in the DOM.
|
|
6409
|
+
*
|
|
6410
|
+
* Coordinates consumed by the canvas are the shape's local geometry.
|
|
6411
|
+
*
|
|
6412
|
+
* @param shape - The shape.
|
|
6413
|
+
*/
|
|
6414
|
+
getLodStyle(_shape) {
|
|
6415
|
+
return null;
|
|
6416
|
+
}
|
|
6028
6417
|
/**
|
|
6029
6418
|
* Does this shape provide a background for its children? If this is true,
|
|
6030
6419
|
* then any children with a `renderBackground` method will have their
|
|
@@ -9110,6 +9499,7 @@ var defaultDrawOptions = {
|
|
|
9110
9499
|
nonce: void 0,
|
|
9111
9500
|
debouncedZoom: true,
|
|
9112
9501
|
debouncedZoomThreshold: 500,
|
|
9502
|
+
lodZoom: 0.6,
|
|
9113
9503
|
spacebarPanning: true,
|
|
9114
9504
|
rightClickPanning: true,
|
|
9115
9505
|
zoomToFitPadding: 128,
|
|
@@ -25869,7 +26259,7 @@ function getFontsFromRichText(editor, richText, initialState2) {
|
|
|
25869
26259
|
// src/index.ts
|
|
25870
26260
|
registerDrawLibraryVersion(
|
|
25871
26261
|
"@ibodr/editor",
|
|
25872
|
-
"0.2.
|
|
26262
|
+
"0.2.9",
|
|
25873
26263
|
"esm"
|
|
25874
26264
|
);
|
|
25875
26265
|
/*!
|