@tldraw/editor 3.16.0-canary.c7d3f7d5729d → 3.16.0-canary.ca33603d9bda
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 +3 -101
- package/dist-cjs/index.js +1 -5
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/TldrawEditor.js +0 -4
- package/dist-cjs/lib/TldrawEditor.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +3 -99
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/types/misc-types.js.map +1 -1
- 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 +3 -101
- package/dist-esm/index.mjs +1 -5
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/TldrawEditor.mjs +0 -4
- package/dist-esm/lib/TldrawEditor.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +3 -99
- package/dist-esm/lib/editor/Editor.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/package.json +7 -7
- package/src/index.ts +0 -9
- package/src/lib/TldrawEditor.tsx +0 -11
- package/src/lib/editor/Editor.ts +1 -125
- package/src/lib/editor/types/misc-types.ts +0 -6
- 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
|
@@ -88,7 +88,6 @@ var import_defaultShapes = require("../config/defaultShapes");
|
|
|
88
88
|
var import_constants = require("../constants");
|
|
89
89
|
var import_exportToSvg = require("../exports/exportToSvg");
|
|
90
90
|
var import_getSvgAsImage = require("../exports/getSvgAsImage");
|
|
91
|
-
var import_environment = require("../globals/environment");
|
|
92
91
|
var import_menus = require("../globals/menus");
|
|
93
92
|
var import_time = require("../globals/time");
|
|
94
93
|
var import_options = require("../options");
|
|
@@ -123,8 +122,8 @@ var import_TextManager = require("./managers/TextManager/TextManager");
|
|
|
123
122
|
var import_TickManager = require("./managers/TickManager/TickManager");
|
|
124
123
|
var import_UserPreferencesManager = require("./managers/UserPreferencesManager/UserPreferencesManager");
|
|
125
124
|
var import_RootState = require("./tools/RootState");
|
|
126
|
-
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,
|
|
127
|
-
class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_dec = [import_state.computed], _getCanUndo_dec = [import_state.computed], _getCanRedo_dec = [import_state.computed], _getPath_dec = [import_state.computed], _getCurrentTool_dec = [import_state.computed], _getCurrentToolId_dec = [import_state.computed], _getDocumentSettings_dec = [import_state.computed], _getInstanceState_dec = [import_state.computed],
|
|
125
|
+
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;
|
|
126
|
+
class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_dec = [import_state.computed], _getCanUndo_dec = [import_state.computed], _getCanRedo_dec = [import_state.computed], _getPath_dec = [import_state.computed], _getCurrentTool_dec = [import_state.computed], _getCurrentToolId_dec = [import_state.computed], _getDocumentSettings_dec = [import_state.computed], _getInstanceState_dec = [import_state.computed], _getPageStates_dec = [import_state.computed], __getPageStatesQuery_dec = [import_state.computed], _getCurrentPageState_dec = [import_state.computed], __getCurrentPageStateId_dec = [import_state.computed], _getSelectedShapeIds_dec = [import_state.computed], _getSelectedShapes_dec = [import_state.computed], _getCurrentPageShapesInReadingOrder_dec = [import_state.computed], _getOnlySelectedShapeId_dec = [import_state.computed], _getOnlySelectedShape_dec = [import_state.computed], _getSelectionPageBounds_dec = [import_state.computed], _getSelectionRotation_dec = [import_state.computed], _getSelectionRotatedPageBounds_dec = [import_state.computed], _getSelectionRotatedScreenBounds_dec = [import_state.computed], _getFocusedGroupId_dec = [import_state.computed], _getFocusedGroup_dec = [import_state.computed], _getEditingShapeId_dec = [import_state.computed], _getEditingShape_dec = [import_state.computed], _getRichTextEditor_dec = [import_state.computed], _getHoveredShapeId_dec = [import_state.computed], _getHoveredShape_dec = [import_state.computed], _getHintingShapeIds_dec = [import_state.computed], _getHintingShape_dec = [import_state.computed], _getErasingShapeIds_dec = [import_state.computed], _getErasingShapes_dec = [import_state.computed], __unsafe_getCameraId_dec = [import_state.computed], _getCamera_dec = [import_state.computed], _getViewportPageBoundsForFollowing_dec = [import_state.computed], _getCameraForFollowing_dec = [import_state.computed], _getZoomLevel_dec = [import_state.computed], _getViewportScreenBounds_dec = [import_state.computed], _getViewportScreenCenter_dec = [import_state.computed], _getViewportPageBounds_dec = [import_state.computed], __getCollaboratorsQuery_dec = [import_state.computed], _getCollaborators_dec = [import_state.computed], _getCollaboratorsOnCurrentPage_dec = [import_state.computed], _getRenderingShapes_dec = [import_state.computed], __getAllPagesQuery_dec = [import_state.computed], _getPages_dec = [import_state.computed], _getCurrentPageId_dec = [import_state.computed], _getCurrentPageShapeIdsSorted_dec = [import_state.computed], __getAllAssetsQuery_dec = [import_state.computed], __getShapeHandlesCache_dec = [import_state.computed], __getShapePageTransformCache_dec = [import_state.computed], __getShapePageBoundsCache_dec = [import_state.computed], __getShapeClipPathCache_dec = [import_state.computed], __getShapeMaskCache_dec = [import_state.computed], __getShapeMaskedPageBoundsCache_dec = [import_state.computed], _getNotVisibleShapes_dec = [import_state.computed], _getCulledShapes_dec = [import_state.computed], _getCurrentPageBounds_dec = [import_state.computed], _getCurrentPageShapes_dec = [import_state.computed], _getCurrentPageShapesSorted_dec = [import_state.computed], _getCurrentPageRenderingShapesSorted_dec = [import_state.computed], __getBindingsIndexCache_dec = [import_state.computed], __getSelectionSharedStyles_dec = [import_state.computed], _getSharedStyles_dec = [(0, import_state.computed)({ isEqual: (a, b) => a.equals(b) })], _getSharedOpacity_dec = [import_state.computed], _getIsFocused_dec = [import_state.computed], _getIsReadonly_dec = [import_state.computed], __setShiftKeyTimeout_dec = [import_utils.bind], __setAltKeyTimeout_dec = [import_utils.bind], __setCtrlKeyTimeout_dec = [import_utils.bind], __setMetaKeyTimeout_dec = [import_utils.bind], _a) {
|
|
128
127
|
constructor({
|
|
129
128
|
store,
|
|
130
129
|
user,
|
|
@@ -138,8 +137,6 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
138
137
|
autoFocus,
|
|
139
138
|
inferDarkMode,
|
|
140
139
|
options,
|
|
141
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
142
|
-
isShapeHidden,
|
|
143
140
|
getShapeVisibility,
|
|
144
141
|
fontAssetUrls
|
|
145
142
|
}) {
|
|
@@ -206,13 +203,6 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
206
203
|
* @public
|
|
207
204
|
*/
|
|
208
205
|
__publicField(this, "fonts");
|
|
209
|
-
/**
|
|
210
|
-
* A manager for the editor's environment.
|
|
211
|
-
*
|
|
212
|
-
* @deprecated This is deprecated and will be removed in a future version. Use the `tlenv` global export instead.
|
|
213
|
-
* @public
|
|
214
|
-
*/
|
|
215
|
-
__publicField(this, "environment", import_environment.tlenv);
|
|
216
206
|
/**
|
|
217
207
|
* A manager for the editor's scribbles.
|
|
218
208
|
*
|
|
@@ -415,14 +405,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
415
405
|
/** @internal */
|
|
416
406
|
__publicField(this, "performanceTrackerTimeout", -1);
|
|
417
407
|
__publicField(this, "_pendingEventsForNextTick", []);
|
|
418
|
-
|
|
419
|
-
!(isShapeHidden && getShapeVisibility),
|
|
420
|
-
"Cannot use both isShapeHidden and getShapeVisibility"
|
|
421
|
-
);
|
|
422
|
-
this._getShapeVisibility = isShapeHidden ? (
|
|
423
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
424
|
-
(shape, editor) => isShapeHidden(shape, editor) ? "hidden" : "inherit"
|
|
425
|
-
) : getShapeVisibility;
|
|
408
|
+
this._getShapeVisibility = getShapeVisibility;
|
|
426
409
|
this.options = { ...import_options.defaultTldrawOptions, ...options };
|
|
427
410
|
this.store = store;
|
|
428
411
|
this.history = new import_HistoryManager.HistoryManager({
|
|
@@ -902,34 +885,6 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
902
885
|
getCanRedo() {
|
|
903
886
|
return this.history.getNumRedos() > 0;
|
|
904
887
|
}
|
|
905
|
-
/**
|
|
906
|
-
* Create a new "mark", or stopping point, in the undo redo history. Creating a mark will clear
|
|
907
|
-
* any redos.
|
|
908
|
-
*
|
|
909
|
-
* @example
|
|
910
|
-
* ```ts
|
|
911
|
-
* editor.mark()
|
|
912
|
-
* editor.mark('flip shapes')
|
|
913
|
-
* ```
|
|
914
|
-
*
|
|
915
|
-
* @param markId - The mark's id, usually the reason for adding the mark.
|
|
916
|
-
*
|
|
917
|
-
* @public
|
|
918
|
-
* @deprecated use {@link Editor.markHistoryStoppingPoint} instead
|
|
919
|
-
*/
|
|
920
|
-
mark(markId) {
|
|
921
|
-
if (typeof markId === "string") {
|
|
922
|
-
console.warn(
|
|
923
|
-
`[tldraw] \`editor.history.mark("${markId}")\` is deprecated. Please use \`const myMarkId = editor.markHistoryStoppingPoint()\` instead.`
|
|
924
|
-
);
|
|
925
|
-
} else {
|
|
926
|
-
console.warn(
|
|
927
|
-
"[tldraw] `editor.mark()` is deprecated. Use `editor.markHistoryStoppingPoint()` instead."
|
|
928
|
-
);
|
|
929
|
-
}
|
|
930
|
-
this.history._mark(markId ?? (0, import_utils.uniqueId)());
|
|
931
|
-
return this;
|
|
932
|
-
}
|
|
933
888
|
/**
|
|
934
889
|
* Create a new "mark", or stopping point, in the undo redo history. Creating a mark will clear
|
|
935
890
|
* any redos. You typically want to do this just before a user interaction begins or is handled.
|
|
@@ -1045,12 +1000,6 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
1045
1000
|
}
|
|
1046
1001
|
return this;
|
|
1047
1002
|
}
|
|
1048
|
-
/**
|
|
1049
|
-
* @deprecated Use `Editor.run` instead.
|
|
1050
|
-
*/
|
|
1051
|
-
batch(fn, opts) {
|
|
1052
|
-
return this.run(fn, opts);
|
|
1053
|
-
}
|
|
1054
1003
|
/* --------------------- Errors --------------------- */
|
|
1055
1004
|
/** @internal */
|
|
1056
1005
|
annotateError(error, {
|
|
@@ -1272,39 +1221,6 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
1272
1221
|
]);
|
|
1273
1222
|
}, opts);
|
|
1274
1223
|
}
|
|
1275
|
-
getOpenMenus() {
|
|
1276
|
-
return this.menus.getOpenMenus();
|
|
1277
|
-
}
|
|
1278
|
-
/**
|
|
1279
|
-
* @deprecated Use `editor.menus.addOpenMenu` instead.
|
|
1280
|
-
*
|
|
1281
|
-
* @public
|
|
1282
|
-
*/
|
|
1283
|
-
addOpenMenu(id) {
|
|
1284
|
-
this.menus.addOpenMenu(id);
|
|
1285
|
-
return this;
|
|
1286
|
-
}
|
|
1287
|
-
/**
|
|
1288
|
-
* @deprecated Use `editor.menus.deleteOpenMenu` instead.
|
|
1289
|
-
*
|
|
1290
|
-
* @public
|
|
1291
|
-
*/
|
|
1292
|
-
deleteOpenMenu(id) {
|
|
1293
|
-
this.menus.deleteOpenMenu(id);
|
|
1294
|
-
return this;
|
|
1295
|
-
}
|
|
1296
|
-
/**
|
|
1297
|
-
* @deprecated Use `editor.menus.clearOpenMenus` instead.
|
|
1298
|
-
*
|
|
1299
|
-
* @public
|
|
1300
|
-
*/
|
|
1301
|
-
clearOpenMenus() {
|
|
1302
|
-
this.menus.clearOpenMenus();
|
|
1303
|
-
return this;
|
|
1304
|
-
}
|
|
1305
|
-
getIsMenuOpen() {
|
|
1306
|
-
return this.menus.hasAnyOpenMenus();
|
|
1307
|
-
}
|
|
1308
1224
|
/* --------------------- Cursor --------------------- */
|
|
1309
1225
|
/**
|
|
1310
1226
|
* Set the cursor.
|
|
@@ -4374,10 +4290,6 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
4374
4290
|
}
|
|
4375
4291
|
return shapeIds;
|
|
4376
4292
|
}
|
|
4377
|
-
/** @deprecated Use {@link Editor.getDraggingOverShape} instead */
|
|
4378
|
-
getDroppingOverShape(point, droppingShapes) {
|
|
4379
|
-
return this.getDraggingOverShape(point, droppingShapes);
|
|
4380
|
-
}
|
|
4381
4293
|
/**
|
|
4382
4294
|
* Get the shape that some shapes should be dropped on at a given point.
|
|
4383
4295
|
*
|
|
@@ -6888,12 +6800,6 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
6888
6800
|
height: result.height
|
|
6889
6801
|
};
|
|
6890
6802
|
}
|
|
6891
|
-
/** @deprecated Use {@link Editor.getSvgString} or {@link Editor.getSvgElement} instead. */
|
|
6892
|
-
async getSvg(shapes, opts = {}) {
|
|
6893
|
-
const result = await this.getSvgElement(shapes, opts);
|
|
6894
|
-
if (!result) return void 0;
|
|
6895
|
-
return result.svg;
|
|
6896
|
-
}
|
|
6897
6803
|
/**
|
|
6898
6804
|
* Get an exported image of the given shapes.
|
|
6899
6805
|
*
|
|
@@ -7874,8 +7780,6 @@ __decorateElement(_init, 1, "getCurrentTool", _getCurrentTool_dec, Editor);
|
|
|
7874
7780
|
__decorateElement(_init, 1, "getCurrentToolId", _getCurrentToolId_dec, Editor);
|
|
7875
7781
|
__decorateElement(_init, 1, "getDocumentSettings", _getDocumentSettings_dec, Editor);
|
|
7876
7782
|
__decorateElement(_init, 1, "getInstanceState", _getInstanceState_dec, Editor);
|
|
7877
|
-
__decorateElement(_init, 1, "getOpenMenus", _getOpenMenus_dec, Editor);
|
|
7878
|
-
__decorateElement(_init, 1, "getIsMenuOpen", _getIsMenuOpen_dec, Editor);
|
|
7879
7783
|
__decorateElement(_init, 1, "getPageStates", _getPageStates_dec, Editor);
|
|
7880
7784
|
__decorateElement(_init, 1, "_getPageStatesQuery", __getPageStatesQuery_dec, Editor);
|
|
7881
7785
|
__decorateElement(_init, 1, "getCurrentPageState", _getCurrentPageState_dec, Editor);
|