@tldraw/editor 3.16.0-canary.d98fc0b9bd6a → 3.16.0-canary.da558c1dc67d
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-cjs/index.d.ts +45 -0
- package/dist-cjs/index.js +1 -1
- package/dist-cjs/lib/TldrawEditor.js +5 -1
- package/dist-cjs/lib/TldrawEditor.js.map +2 -2
- package/dist-cjs/lib/components/Shape.js +7 -10
- package/dist-cjs/lib/components/Shape.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js +4 -23
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +28 -10
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js +13 -0
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
- package/dist-cjs/lib/exports/getSvgJsx.js +34 -14
- package/dist-cjs/lib/exports/getSvgJsx.js.map +2 -2
- package/dist-cjs/lib/hooks/useCanvasEvents.js +7 -5
- package/dist-cjs/lib/hooks/useCanvasEvents.js.map +2 -2
- package/dist-cjs/lib/hooks/usePassThroughWheelEvents.js +4 -1
- package/dist-cjs/lib/hooks/usePassThroughWheelEvents.js.map +2 -2
- package/dist-cjs/lib/primitives/Box.js +3 -0
- package/dist-cjs/lib/primitives/Box.js.map +2 -2
- package/dist-cjs/version.js +3 -3
- package/dist-cjs/version.js.map +1 -1
- package/dist-esm/index.d.mts +45 -0
- package/dist-esm/index.mjs +1 -1
- package/dist-esm/lib/TldrawEditor.mjs +5 -1
- package/dist-esm/lib/TldrawEditor.mjs.map +2 -2
- package/dist-esm/lib/components/Shape.mjs +7 -10
- package/dist-esm/lib/components/Shape.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs +4 -23
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +28 -10
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs +13 -0
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/exports/getSvgJsx.mjs +34 -14
- package/dist-esm/lib/exports/getSvgJsx.mjs.map +2 -2
- package/dist-esm/lib/hooks/useCanvasEvents.mjs +7 -5
- package/dist-esm/lib/hooks/useCanvasEvents.mjs.map +2 -2
- package/dist-esm/lib/hooks/usePassThroughWheelEvents.mjs +4 -1
- package/dist-esm/lib/hooks/usePassThroughWheelEvents.mjs.map +2 -2
- package/dist-esm/lib/primitives/Box.mjs +4 -1
- package/dist-esm/lib/primitives/Box.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/editor.css +8 -0
- package/package.json +7 -7
- package/src/lib/TldrawEditor.tsx +6 -1
- package/src/lib/components/Shape.tsx +6 -12
- package/src/lib/components/default-components/DefaultCanvas.tsx +5 -22
- package/src/lib/editor/Editor.ts +37 -21
- package/src/lib/editor/shapes/ShapeUtil.ts +35 -0
- package/src/lib/exports/getSvgJsx.test.ts +868 -0
- package/src/lib/exports/getSvgJsx.tsx +76 -19
- package/src/lib/hooks/useCanvasEvents.ts +6 -6
- package/src/lib/hooks/usePassThroughWheelEvents.ts +6 -1
- package/src/lib/primitives/Box.test.ts +126 -0
- package/src/lib/primitives/Box.ts +10 -1
- package/src/version.ts +3 -3
- package/dist-cjs/lib/utils/nearestMultiple.js +0 -34
- package/dist-cjs/lib/utils/nearestMultiple.js.map +0 -7
- package/dist-esm/lib/utils/nearestMultiple.mjs +0 -14
- package/dist-esm/lib/utils/nearestMultiple.mjs.map +0 -7
- package/src/lib/utils/nearestMultiple.ts +0 -13
|
@@ -3666,16 +3666,17 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
3666
3666
|
_getShapeMaskCache() {
|
|
3667
3667
|
return this.store.createComputedCache("pageMaskCache", (shape) => {
|
|
3668
3668
|
if ((0, import_tlschema.isPageId)(shape.parentId)) return void 0;
|
|
3669
|
-
const
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
const pageTransform = this.getShapePageTransform(
|
|
3676
|
-
|
|
3677
|
-
}
|
|
3678
|
-
|
|
3669
|
+
const clipPaths = [];
|
|
3670
|
+
for (const ancestor of this.getShapeAncestors(shape.id)) {
|
|
3671
|
+
const util = this.getShapeUtil(ancestor);
|
|
3672
|
+
const clipPath = util.getClipPath?.(ancestor);
|
|
3673
|
+
if (!clipPath) continue;
|
|
3674
|
+
if (util.shouldClipChild?.(shape) === false) continue;
|
|
3675
|
+
const pageTransform = this.getShapePageTransform(ancestor.id);
|
|
3676
|
+
clipPaths.push(pageTransform.applyToPoints(clipPath));
|
|
3677
|
+
}
|
|
3678
|
+
if (clipPaths.length === 0) return void 0;
|
|
3679
|
+
const pageMask = clipPaths.reduce((acc, b) => {
|
|
3679
3680
|
const intersection = (0, import_intersect.intersectPolygonPolygon)(acc, b);
|
|
3680
3681
|
if (intersection) {
|
|
3681
3682
|
return intersection.map(import_Vec.Vec.Cast);
|
|
@@ -6942,6 +6943,23 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
6942
6943
|
}
|
|
6943
6944
|
}
|
|
6944
6945
|
}
|
|
6946
|
+
/**
|
|
6947
|
+
* Get an exported image of the given shapes as a data URL.
|
|
6948
|
+
*
|
|
6949
|
+
* @param shapes - The shapes (or shape ids) to export.
|
|
6950
|
+
* @param opts - Options for the export.
|
|
6951
|
+
*
|
|
6952
|
+
* @returns A data URL of the image.
|
|
6953
|
+
* @public
|
|
6954
|
+
*/
|
|
6955
|
+
async toImageDataUrl(shapes, opts = {}) {
|
|
6956
|
+
const { blob, width, height } = await this.toImage(shapes, opts);
|
|
6957
|
+
return {
|
|
6958
|
+
url: await import_utils.FileHelpers.blobToDataUrl(blob),
|
|
6959
|
+
width,
|
|
6960
|
+
height
|
|
6961
|
+
};
|
|
6962
|
+
}
|
|
6945
6963
|
/**
|
|
6946
6964
|
* Update the input points from a pointer, pinch, or wheel event.
|
|
6947
6965
|
*
|