@tldraw/editor 3.16.0-canary.c1bcdabc9513 → 3.16.0-canary.c434355348c5
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 +52 -101
- package/dist-cjs/index.js +3 -5
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/TldrawEditor.js +5 -5
- 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 +31 -109
- 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/editor/types/misc-types.js.map +1 -1
- 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/usePassThroughMouseOverEvents.js +4 -1
- package/dist-cjs/lib/hooks/usePassThroughMouseOverEvents.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/license/LicenseManager.js +120 -50
- package/dist-cjs/lib/license/LicenseManager.js.map +2 -2
- package/dist-cjs/lib/license/LicenseProvider.js +22 -0
- package/dist-cjs/lib/license/LicenseProvider.js.map +2 -2
- package/dist-cjs/lib/license/Watermark.js +68 -6
- package/dist-cjs/lib/license/Watermark.js.map +3 -3
- package/dist-cjs/lib/license/useLicenseManagerState.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/lib/primitives/Vec.js +0 -4
- package/dist-cjs/lib/primitives/Vec.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Geometry2d.js +26 -18
- package/dist-cjs/lib/primitives/geometry/Geometry2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Group2d.js +3 -0
- package/dist-cjs/lib/primitives/geometry/Group2d.js.map +2 -2
- package/dist-cjs/lib/utils/reparenting.js +2 -35
- package/dist-cjs/lib/utils/reparenting.js.map +3 -3
- package/dist-cjs/version.js +3 -3
- package/dist-cjs/version.js.map +1 -1
- package/dist-esm/index.d.mts +52 -101
- package/dist-esm/index.mjs +3 -5
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/TldrawEditor.mjs +5 -5
- 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 +31 -109
- 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/usePassThroughMouseOverEvents.mjs +4 -1
- package/dist-esm/lib/hooks/usePassThroughMouseOverEvents.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/license/LicenseManager.mjs +121 -51
- package/dist-esm/lib/license/LicenseManager.mjs.map +2 -2
- package/dist-esm/lib/license/LicenseProvider.mjs +23 -1
- package/dist-esm/lib/license/LicenseProvider.mjs.map +2 -2
- package/dist-esm/lib/license/Watermark.mjs +68 -6
- package/dist-esm/lib/license/Watermark.mjs.map +3 -3
- package/dist-esm/lib/license/useLicenseManagerState.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/lib/primitives/Vec.mjs +0 -4
- package/dist-esm/lib/primitives/Vec.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Geometry2d.mjs +29 -19
- package/dist-esm/lib/primitives/geometry/Geometry2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Group2d.mjs +3 -0
- package/dist-esm/lib/primitives/geometry/Group2d.mjs.map +2 -2
- package/dist-esm/lib/utils/reparenting.mjs +3 -40
- package/dist-esm/lib/utils/reparenting.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/index.ts +2 -9
- package/src/lib/TldrawEditor.tsx +6 -12
- package/src/lib/components/Shape.tsx +6 -12
- package/src/lib/components/default-components/DefaultCanvas.tsx +5 -22
- package/src/lib/editor/Editor.ts +38 -146
- package/src/lib/editor/shapes/ShapeUtil.ts +35 -0
- package/src/lib/editor/types/misc-types.ts +0 -6
- 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/usePassThroughMouseOverEvents.ts +4 -1
- package/src/lib/hooks/usePassThroughWheelEvents.ts +6 -1
- package/src/lib/license/LicenseManager.test.ts +645 -382
- package/src/lib/license/LicenseManager.ts +173 -53
- package/src/lib/license/LicenseProvider.tsx +34 -1
- package/src/lib/license/Watermark.tsx +73 -6
- package/src/lib/license/useLicenseManagerState.ts +2 -2
- package/src/lib/primitives/Box.test.ts +126 -0
- package/src/lib/primitives/Box.ts +10 -1
- package/src/lib/primitives/Vec.ts +0 -5
- package/src/lib/primitives/geometry/Geometry2d.ts +49 -19
- package/src/lib/primitives/geometry/Group2d.ts +4 -0
- package/src/lib/utils/reparenting.ts +3 -69
- 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
|
@@ -46,7 +46,7 @@ var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use
|
|
|
46
46
|
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
47
47
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
48
48
|
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
49
|
-
var __setMetaKeyTimeout_dec, __setCtrlKeyTimeout_dec, __setAltKeyTimeout_dec, __setShiftKeyTimeout_dec, _getIsReadonly_dec, _getIsFocused_dec, _getSharedOpacity_dec, _getSharedStyles_dec, __getSelectionSharedStyles_dec, __getBindingsIndexCache_dec, _getCurrentPageRenderingShapesSorted_dec, _getCurrentPageShapesSorted_dec, _getCurrentPageShapes_dec, _getCurrentPageBounds_dec, _getCulledShapes_dec, _getNotVisibleShapes_dec, __getShapeMaskedPageBoundsCache_dec, __getShapeMaskCache_dec, __getShapeClipPathCache_dec, __getShapePageBoundsCache_dec, __getShapePageTransformCache_dec, __getShapeHandlesCache_dec, __getAllAssetsQuery_dec, _getCurrentPageShapeIdsSorted_dec, _getCurrentPageId_dec, _getPages_dec, __getAllPagesQuery_dec, _getRenderingShapes_dec, _getCollaboratorsOnCurrentPage_dec, _getCollaborators_dec, __getCollaboratorsQuery_dec, _getViewportPageBounds_dec, _getViewportScreenCenter_dec, _getViewportScreenBounds_dec, _getZoomLevel_dec, _getCameraForFollowing_dec, _getViewportPageBoundsForFollowing_dec, _getCamera_dec, __unsafe_getCameraId_dec, _getErasingShapes_dec, _getErasingShapeIds_dec, _getHintingShape_dec, _getHintingShapeIds_dec, _getHoveredShape_dec, _getHoveredShapeId_dec, _getRichTextEditor_dec, _getEditingShape_dec, _getEditingShapeId_dec, _getFocusedGroup_dec, _getFocusedGroupId_dec, _getSelectionRotatedScreenBounds_dec, _getSelectionRotatedPageBounds_dec, _getSelectionRotation_dec, _getSelectionPageBounds_dec, _getOnlySelectedShape_dec, _getOnlySelectedShapeId_dec, _getCurrentPageShapesInReadingOrder_dec, _getSelectedShapes_dec, _getSelectedShapeIds_dec, __getCurrentPageStateId_dec, _getCurrentPageState_dec, __getPageStatesQuery_dec, _getPageStates_dec,
|
|
49
|
+
var __setMetaKeyTimeout_dec, __setCtrlKeyTimeout_dec, __setAltKeyTimeout_dec, __setShiftKeyTimeout_dec, _getIsReadonly_dec, _getIsFocused_dec, _getSharedOpacity_dec, _getSharedStyles_dec, __getSelectionSharedStyles_dec, __getBindingsIndexCache_dec, _getCurrentPageRenderingShapesSorted_dec, _getCurrentPageShapesSorted_dec, _getCurrentPageShapes_dec, _getCurrentPageBounds_dec, _getCulledShapes_dec, _getNotVisibleShapes_dec, __getShapeMaskedPageBoundsCache_dec, __getShapeMaskCache_dec, __getShapeClipPathCache_dec, __getShapePageBoundsCache_dec, __getShapePageTransformCache_dec, __getShapeHandlesCache_dec, __getAllAssetsQuery_dec, _getCurrentPageShapeIdsSorted_dec, _getCurrentPageId_dec, _getPages_dec, __getAllPagesQuery_dec, _getRenderingShapes_dec, _getCollaboratorsOnCurrentPage_dec, _getCollaborators_dec, __getCollaboratorsQuery_dec, _getViewportPageBounds_dec, _getViewportScreenCenter_dec, _getViewportScreenBounds_dec, _getZoomLevel_dec, _getCameraForFollowing_dec, _getViewportPageBoundsForFollowing_dec, _getCamera_dec, __unsafe_getCameraId_dec, _getErasingShapes_dec, _getErasingShapeIds_dec, _getHintingShape_dec, _getHintingShapeIds_dec, _getHoveredShape_dec, _getHoveredShapeId_dec, _getRichTextEditor_dec, _getEditingShape_dec, _getEditingShapeId_dec, _getFocusedGroup_dec, _getFocusedGroupId_dec, _getSelectionRotatedScreenBounds_dec, _getSelectionRotatedPageBounds_dec, _getSelectionRotation_dec, _getSelectionPageBounds_dec, _getOnlySelectedShape_dec, _getOnlySelectedShapeId_dec, _getCurrentPageShapesInReadingOrder_dec, _getSelectedShapes_dec, _getSelectedShapeIds_dec, __getCurrentPageStateId_dec, _getCurrentPageState_dec, __getPageStatesQuery_dec, _getPageStates_dec, _getInstanceState_dec, _getDocumentSettings_dec, _getCurrentToolId_dec, _getCurrentTool_dec, _getPath_dec, _getCanRedo_dec, _getCanUndo_dec, _getIsShapeHiddenCache_dec, _a, _init;
|
|
50
50
|
import {
|
|
51
51
|
EMPTY_ARRAY,
|
|
52
52
|
atom,
|
|
@@ -120,7 +120,6 @@ import {
|
|
|
120
120
|
} from "../constants.mjs";
|
|
121
121
|
import { exportToSvg } from "../exports/exportToSvg.mjs";
|
|
122
122
|
import { getSvgAsImage } from "../exports/getSvgAsImage.mjs";
|
|
123
|
-
import { tlenv } from "../globals/environment.mjs";
|
|
124
123
|
import { tlmenus } from "../globals/menus.mjs";
|
|
125
124
|
import { tltime } from "../globals/time.mjs";
|
|
126
125
|
import { defaultTldrawOptions } from "../options.mjs";
|
|
@@ -158,7 +157,7 @@ import { TextManager } from "./managers/TextManager/TextManager.mjs";
|
|
|
158
157
|
import { TickManager } from "./managers/TickManager/TickManager.mjs";
|
|
159
158
|
import { UserPreferencesManager } from "./managers/UserPreferencesManager/UserPreferencesManager.mjs";
|
|
160
159
|
import { RootState } from "./tools/RootState.mjs";
|
|
161
|
-
class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed], _getCanUndo_dec = [computed], _getCanRedo_dec = [computed], _getPath_dec = [computed], _getCurrentTool_dec = [computed], _getCurrentToolId_dec = [computed], _getDocumentSettings_dec = [computed], _getInstanceState_dec = [computed],
|
|
160
|
+
class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed], _getCanUndo_dec = [computed], _getCanRedo_dec = [computed], _getPath_dec = [computed], _getCurrentTool_dec = [computed], _getCurrentToolId_dec = [computed], _getDocumentSettings_dec = [computed], _getInstanceState_dec = [computed], _getPageStates_dec = [computed], __getPageStatesQuery_dec = [computed], _getCurrentPageState_dec = [computed], __getCurrentPageStateId_dec = [computed], _getSelectedShapeIds_dec = [computed], _getSelectedShapes_dec = [computed], _getCurrentPageShapesInReadingOrder_dec = [computed], _getOnlySelectedShapeId_dec = [computed], _getOnlySelectedShape_dec = [computed], _getSelectionPageBounds_dec = [computed], _getSelectionRotation_dec = [computed], _getSelectionRotatedPageBounds_dec = [computed], _getSelectionRotatedScreenBounds_dec = [computed], _getFocusedGroupId_dec = [computed], _getFocusedGroup_dec = [computed], _getEditingShapeId_dec = [computed], _getEditingShape_dec = [computed], _getRichTextEditor_dec = [computed], _getHoveredShapeId_dec = [computed], _getHoveredShape_dec = [computed], _getHintingShapeIds_dec = [computed], _getHintingShape_dec = [computed], _getErasingShapeIds_dec = [computed], _getErasingShapes_dec = [computed], __unsafe_getCameraId_dec = [computed], _getCamera_dec = [computed], _getViewportPageBoundsForFollowing_dec = [computed], _getCameraForFollowing_dec = [computed], _getZoomLevel_dec = [computed], _getViewportScreenBounds_dec = [computed], _getViewportScreenCenter_dec = [computed], _getViewportPageBounds_dec = [computed], __getCollaboratorsQuery_dec = [computed], _getCollaborators_dec = [computed], _getCollaboratorsOnCurrentPage_dec = [computed], _getRenderingShapes_dec = [computed], __getAllPagesQuery_dec = [computed], _getPages_dec = [computed], _getCurrentPageId_dec = [computed], _getCurrentPageShapeIdsSorted_dec = [computed], __getAllAssetsQuery_dec = [computed], __getShapeHandlesCache_dec = [computed], __getShapePageTransformCache_dec = [computed], __getShapePageBoundsCache_dec = [computed], __getShapeClipPathCache_dec = [computed], __getShapeMaskCache_dec = [computed], __getShapeMaskedPageBoundsCache_dec = [computed], _getNotVisibleShapes_dec = [computed], _getCulledShapes_dec = [computed], _getCurrentPageBounds_dec = [computed], _getCurrentPageShapes_dec = [computed], _getCurrentPageShapesSorted_dec = [computed], _getCurrentPageRenderingShapesSorted_dec = [computed], __getBindingsIndexCache_dec = [computed], __getSelectionSharedStyles_dec = [computed], _getSharedStyles_dec = [computed({ isEqual: (a, b) => a.equals(b) })], _getSharedOpacity_dec = [computed], _getIsFocused_dec = [computed], _getIsReadonly_dec = [computed], __setShiftKeyTimeout_dec = [bind], __setAltKeyTimeout_dec = [bind], __setCtrlKeyTimeout_dec = [bind], __setMetaKeyTimeout_dec = [bind], _a) {
|
|
162
161
|
constructor({
|
|
163
162
|
store,
|
|
164
163
|
user,
|
|
@@ -172,8 +171,6 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
172
171
|
autoFocus,
|
|
173
172
|
inferDarkMode,
|
|
174
173
|
options,
|
|
175
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
176
|
-
isShapeHidden,
|
|
177
174
|
getShapeVisibility,
|
|
178
175
|
fontAssetUrls
|
|
179
176
|
}) {
|
|
@@ -240,13 +237,6 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
240
237
|
* @public
|
|
241
238
|
*/
|
|
242
239
|
__publicField(this, "fonts");
|
|
243
|
-
/**
|
|
244
|
-
* A manager for the editor's environment.
|
|
245
|
-
*
|
|
246
|
-
* @deprecated This is deprecated and will be removed in a future version. Use the `tlenv` global export instead.
|
|
247
|
-
* @public
|
|
248
|
-
*/
|
|
249
|
-
__publicField(this, "environment", tlenv);
|
|
250
240
|
/**
|
|
251
241
|
* A manager for the editor's scribbles.
|
|
252
242
|
*
|
|
@@ -449,14 +439,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
449
439
|
/** @internal */
|
|
450
440
|
__publicField(this, "performanceTrackerTimeout", -1);
|
|
451
441
|
__publicField(this, "_pendingEventsForNextTick", []);
|
|
452
|
-
|
|
453
|
-
!(isShapeHidden && getShapeVisibility),
|
|
454
|
-
"Cannot use both isShapeHidden and getShapeVisibility"
|
|
455
|
-
);
|
|
456
|
-
this._getShapeVisibility = isShapeHidden ? (
|
|
457
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
458
|
-
((shape, editor) => isShapeHidden(shape, editor) ? "hidden" : "inherit")
|
|
459
|
-
) : getShapeVisibility;
|
|
442
|
+
this._getShapeVisibility = getShapeVisibility;
|
|
460
443
|
this.options = { ...defaultTldrawOptions, ...options };
|
|
461
444
|
this.store = store;
|
|
462
445
|
this.history = new HistoryManager({
|
|
@@ -936,34 +919,6 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
936
919
|
getCanRedo() {
|
|
937
920
|
return this.history.getNumRedos() > 0;
|
|
938
921
|
}
|
|
939
|
-
/**
|
|
940
|
-
* Create a new "mark", or stopping point, in the undo redo history. Creating a mark will clear
|
|
941
|
-
* any redos.
|
|
942
|
-
*
|
|
943
|
-
* @example
|
|
944
|
-
* ```ts
|
|
945
|
-
* editor.mark()
|
|
946
|
-
* editor.mark('flip shapes')
|
|
947
|
-
* ```
|
|
948
|
-
*
|
|
949
|
-
* @param markId - The mark's id, usually the reason for adding the mark.
|
|
950
|
-
*
|
|
951
|
-
* @public
|
|
952
|
-
* @deprecated use {@link Editor.markHistoryStoppingPoint} instead
|
|
953
|
-
*/
|
|
954
|
-
mark(markId) {
|
|
955
|
-
if (typeof markId === "string") {
|
|
956
|
-
console.warn(
|
|
957
|
-
`[tldraw] \`editor.history.mark("${markId}")\` is deprecated. Please use \`const myMarkId = editor.markHistoryStoppingPoint()\` instead.`
|
|
958
|
-
);
|
|
959
|
-
} else {
|
|
960
|
-
console.warn(
|
|
961
|
-
"[tldraw] `editor.mark()` is deprecated. Use `editor.markHistoryStoppingPoint()` instead."
|
|
962
|
-
);
|
|
963
|
-
}
|
|
964
|
-
this.history._mark(markId ?? uniqueId());
|
|
965
|
-
return this;
|
|
966
|
-
}
|
|
967
922
|
/**
|
|
968
923
|
* Create a new "mark", or stopping point, in the undo redo history. Creating a mark will clear
|
|
969
924
|
* any redos. You typically want to do this just before a user interaction begins or is handled.
|
|
@@ -1079,12 +1034,6 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
1079
1034
|
}
|
|
1080
1035
|
return this;
|
|
1081
1036
|
}
|
|
1082
|
-
/**
|
|
1083
|
-
* @deprecated Use `Editor.run` instead.
|
|
1084
|
-
*/
|
|
1085
|
-
batch(fn, opts) {
|
|
1086
|
-
return this.run(fn, opts);
|
|
1087
|
-
}
|
|
1088
1037
|
/* --------------------- Errors --------------------- */
|
|
1089
1038
|
/** @internal */
|
|
1090
1039
|
annotateError(error, {
|
|
@@ -1306,39 +1255,6 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
1306
1255
|
]);
|
|
1307
1256
|
}, opts);
|
|
1308
1257
|
}
|
|
1309
|
-
getOpenMenus() {
|
|
1310
|
-
return this.menus.getOpenMenus();
|
|
1311
|
-
}
|
|
1312
|
-
/**
|
|
1313
|
-
* @deprecated Use `editor.menus.addOpenMenu` instead.
|
|
1314
|
-
*
|
|
1315
|
-
* @public
|
|
1316
|
-
*/
|
|
1317
|
-
addOpenMenu(id) {
|
|
1318
|
-
this.menus.addOpenMenu(id);
|
|
1319
|
-
return this;
|
|
1320
|
-
}
|
|
1321
|
-
/**
|
|
1322
|
-
* @deprecated Use `editor.menus.deleteOpenMenu` instead.
|
|
1323
|
-
*
|
|
1324
|
-
* @public
|
|
1325
|
-
*/
|
|
1326
|
-
deleteOpenMenu(id) {
|
|
1327
|
-
this.menus.deleteOpenMenu(id);
|
|
1328
|
-
return this;
|
|
1329
|
-
}
|
|
1330
|
-
/**
|
|
1331
|
-
* @deprecated Use `editor.menus.clearOpenMenus` instead.
|
|
1332
|
-
*
|
|
1333
|
-
* @public
|
|
1334
|
-
*/
|
|
1335
|
-
clearOpenMenus() {
|
|
1336
|
-
this.menus.clearOpenMenus();
|
|
1337
|
-
return this;
|
|
1338
|
-
}
|
|
1339
|
-
getIsMenuOpen() {
|
|
1340
|
-
return this.menus.hasAnyOpenMenus();
|
|
1341
|
-
}
|
|
1342
1258
|
/* --------------------- Cursor --------------------- */
|
|
1343
1259
|
/**
|
|
1344
1260
|
* Set the cursor.
|
|
@@ -3700,16 +3616,17 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
3700
3616
|
_getShapeMaskCache() {
|
|
3701
3617
|
return this.store.createComputedCache("pageMaskCache", (shape) => {
|
|
3702
3618
|
if (isPageId(shape.parentId)) return void 0;
|
|
3703
|
-
const
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
const pageTransform = this.getShapePageTransform(
|
|
3710
|
-
|
|
3711
|
-
}
|
|
3712
|
-
|
|
3619
|
+
const clipPaths = [];
|
|
3620
|
+
for (const ancestor of this.getShapeAncestors(shape.id)) {
|
|
3621
|
+
const util = this.getShapeUtil(ancestor);
|
|
3622
|
+
const clipPath = util.getClipPath?.(ancestor);
|
|
3623
|
+
if (!clipPath) continue;
|
|
3624
|
+
if (util.shouldClipChild?.(shape) === false) continue;
|
|
3625
|
+
const pageTransform = this.getShapePageTransform(ancestor.id);
|
|
3626
|
+
clipPaths.push(pageTransform.applyToPoints(clipPath));
|
|
3627
|
+
}
|
|
3628
|
+
if (clipPaths.length === 0) return void 0;
|
|
3629
|
+
const pageMask = clipPaths.reduce((acc, b) => {
|
|
3713
3630
|
const intersection = intersectPolygonPolygon(acc, b);
|
|
3714
3631
|
if (intersection) {
|
|
3715
3632
|
return intersection.map(Vec.Cast);
|
|
@@ -4407,10 +4324,6 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
4407
4324
|
}
|
|
4408
4325
|
return shapeIds;
|
|
4409
4326
|
}
|
|
4410
|
-
/** @deprecated Use {@link Editor.getDraggingOverShape} instead */
|
|
4411
|
-
getDroppingOverShape(point, droppingShapes) {
|
|
4412
|
-
return this.getDraggingOverShape(point, droppingShapes);
|
|
4413
|
-
}
|
|
4414
4327
|
/**
|
|
4415
4328
|
* Get the shape that some shapes should be dropped on at a given point.
|
|
4416
4329
|
*
|
|
@@ -6921,12 +6834,6 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
6921
6834
|
height: result.height
|
|
6922
6835
|
};
|
|
6923
6836
|
}
|
|
6924
|
-
/** @deprecated Use {@link Editor.getSvgString} or {@link Editor.getSvgElement} instead. */
|
|
6925
|
-
async getSvg(shapes, opts = {}) {
|
|
6926
|
-
const result = await this.getSvgElement(shapes, opts);
|
|
6927
|
-
if (!result) return void 0;
|
|
6928
|
-
return result.svg;
|
|
6929
|
-
}
|
|
6930
6837
|
/**
|
|
6931
6838
|
* Get an exported image of the given shapes.
|
|
6932
6839
|
*
|
|
@@ -6976,6 +6883,23 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
6976
6883
|
}
|
|
6977
6884
|
}
|
|
6978
6885
|
}
|
|
6886
|
+
/**
|
|
6887
|
+
* Get an exported image of the given shapes as a data URL.
|
|
6888
|
+
*
|
|
6889
|
+
* @param shapes - The shapes (or shape ids) to export.
|
|
6890
|
+
* @param opts - Options for the export.
|
|
6891
|
+
*
|
|
6892
|
+
* @returns A data URL of the image.
|
|
6893
|
+
* @public
|
|
6894
|
+
*/
|
|
6895
|
+
async toImageDataUrl(shapes, opts = {}) {
|
|
6896
|
+
const { blob, width, height } = await this.toImage(shapes, opts);
|
|
6897
|
+
return {
|
|
6898
|
+
url: await FileHelpers.blobToDataUrl(blob),
|
|
6899
|
+
width,
|
|
6900
|
+
height
|
|
6901
|
+
};
|
|
6902
|
+
}
|
|
6979
6903
|
/**
|
|
6980
6904
|
* Update the input points from a pointer, pinch, or wheel event.
|
|
6981
6905
|
*
|
|
@@ -7890,8 +7814,6 @@ __decorateElement(_init, 1, "getCurrentTool", _getCurrentTool_dec, Editor);
|
|
|
7890
7814
|
__decorateElement(_init, 1, "getCurrentToolId", _getCurrentToolId_dec, Editor);
|
|
7891
7815
|
__decorateElement(_init, 1, "getDocumentSettings", _getDocumentSettings_dec, Editor);
|
|
7892
7816
|
__decorateElement(_init, 1, "getInstanceState", _getInstanceState_dec, Editor);
|
|
7893
|
-
__decorateElement(_init, 1, "getOpenMenus", _getOpenMenus_dec, Editor);
|
|
7894
|
-
__decorateElement(_init, 1, "getIsMenuOpen", _getIsMenuOpen_dec, Editor);
|
|
7895
7817
|
__decorateElement(_init, 1, "getPageStates", _getPageStates_dec, Editor);
|
|
7896
7818
|
__decorateElement(_init, 1, "_getPageStatesQuery", __getPageStatesQuery_dec, Editor);
|
|
7897
7819
|
__decorateElement(_init, 1, "getCurrentPageState", _getCurrentPageState_dec, Editor);
|