@tldraw/editor 5.3.0-next.299378752aaf → 5.3.0-next.4123e97459a9
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 +23 -0
- package/dist-cjs/index.js +1 -1
- package/dist-cjs/lib/editor/Editor.js +7 -2
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/managers/TextManager/TextManager.js +3 -0
- package/dist-cjs/lib/editor/managers/TextManager/TextManager.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
- package/dist-cjs/lib/license/LicenseManager.js +14 -5
- package/dist-cjs/lib/license/LicenseManager.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 +23 -0
- package/dist-esm/index.mjs +1 -1
- package/dist-esm/lib/editor/Editor.mjs +7 -2
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs +3 -0
- package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/license/LicenseManager.mjs +14 -5
- package/dist-esm/lib/license/LicenseManager.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/editor.css +10 -0
- package/package.json +7 -7
- package/src/lib/editor/Editor.ts +14 -2
- package/src/lib/editor/managers/TextManager/TextManager.ts +3 -0
- package/src/lib/editor/shapes/ShapeUtil.ts +24 -0
- package/src/lib/license/LicenseManager.test.ts +99 -29
- package/src/lib/license/LicenseManager.ts +16 -4
- package/src/version.ts +3 -3
package/dist-cjs/index.d.ts
CHANGED
|
@@ -6793,6 +6793,29 @@ export declare abstract class ShapeUtil<Shape extends TLShape = TLShape> {
|
|
|
6793
6793
|
* @public
|
|
6794
6794
|
*/
|
|
6795
6795
|
onBeforeCreate?(next: Shape): Shape | void;
|
|
6796
|
+
/**
|
|
6797
|
+
* A callback called when a shape is reproduced from an existing shape, either by duplicating
|
|
6798
|
+
* ({@link Editor.duplicateShapes}) or by pasting/putting content onto the page
|
|
6799
|
+
* ({@link Editor.putContentOntoCurrentPage}). This provides a last chance to modify the copy
|
|
6800
|
+
* before it's created — for example, to re-stamp attribution so the copy is credited to the
|
|
6801
|
+
* current user rather than the original author. It is not called when content is put with
|
|
6802
|
+
* `preserveIds` (e.g. {@link Editor.moveShapesToPage}), since the shape keeps its identity
|
|
6803
|
+
* and no copy is made.
|
|
6804
|
+
*
|
|
6805
|
+
* @example
|
|
6806
|
+
*
|
|
6807
|
+
* ```ts
|
|
6808
|
+
* onBeforeDuplicate = (source, duplicate) => {
|
|
6809
|
+
* return { ...duplicate, props: { ...duplicate.props, editedBy: this.editor.getAttributionUserId() } }
|
|
6810
|
+
* }
|
|
6811
|
+
* ```
|
|
6812
|
+
*
|
|
6813
|
+
* @param source - The shape being copied from.
|
|
6814
|
+
* @param duplicate - The new copy (with its own id), before it's created.
|
|
6815
|
+
* @returns The next shape or void.
|
|
6816
|
+
* @public
|
|
6817
|
+
*/
|
|
6818
|
+
onBeforeDuplicate?(source: Shape, duplicate: Shape): Shape | void;
|
|
6796
6819
|
/**
|
|
6797
6820
|
* A callback called just before a shape is updated. This method provides a last chance to modify
|
|
6798
6821
|
* the updated shape.
|
package/dist-cjs/index.js
CHANGED
|
@@ -379,7 +379,7 @@ var import_uniq = require("./lib/utils/uniq");
|
|
|
379
379
|
var import_defaultThemes2 = require("./lib/editor/managers/ThemeManager/defaultThemes");
|
|
380
380
|
(0, import_utils.registerTldrawLibraryVersion)(
|
|
381
381
|
"@tldraw/editor",
|
|
382
|
-
"5.3.0-next.
|
|
382
|
+
"5.3.0-next.4123e97459a9",
|
|
383
383
|
"cjs"
|
|
384
384
|
);
|
|
385
385
|
//# sourceMappingURL=index.js.map
|
|
@@ -5171,7 +5171,9 @@ class Editor extends import_eventemitter3.default {
|
|
|
5171
5171
|
const index = (0, import_utils.getIndexBetween)(originalShape.index, siblingAbove?.index);
|
|
5172
5172
|
shape.index = index;
|
|
5173
5173
|
});
|
|
5174
|
-
const shapesToCreate = shapesToCreateWithOriginals.map(({ shape }) =>
|
|
5174
|
+
const shapesToCreate = shapesToCreateWithOriginals.map(({ shape, originalShape }) => {
|
|
5175
|
+
return this.getShapeUtil(shape).onBeforeDuplicate?.(originalShape, shape) ?? shape;
|
|
5176
|
+
});
|
|
5175
5177
|
if (!this.canCreateShapes(shapesToCreate)) {
|
|
5176
5178
|
alertMaxShapes(this);
|
|
5177
5179
|
return;
|
|
@@ -7197,7 +7199,10 @@ class Editor extends import_eventemitter3.default {
|
|
|
7197
7199
|
const rootShapes = [];
|
|
7198
7200
|
const newShapes = shapes.map((oldShape) => {
|
|
7199
7201
|
const newId = shapeIdMap.get(oldShape.id);
|
|
7200
|
-
|
|
7202
|
+
let newShape = { ...oldShape, id: newId };
|
|
7203
|
+
if (!preserveIds) {
|
|
7204
|
+
newShape = this.getShapeUtil(newShape).onBeforeDuplicate?.(oldShape, newShape) ?? newShape;
|
|
7205
|
+
}
|
|
7201
7206
|
if (rootShapeIds.includes(oldShape.id)) {
|
|
7202
7207
|
newShape.parentId = currentPageId;
|
|
7203
7208
|
rootShapes.push(newShape);
|