@tldraw/editor 5.7.0-internal.5fe8922939ec → 5.7.0-internal.d83eaf8e2d50
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 +9 -48
- package/dist-cjs/index.js +1 -3
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/TldrawEditor.js +2 -10
- package/dist-cjs/lib/TldrawEditor.js.map +2 -2
- package/dist-cjs/lib/config/createTLStore.js +1 -3
- package/dist-cjs/lib/config/createTLStore.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +8 -37
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/managers/HistoryManager/HistoryManager.js +2 -44
- package/dist-cjs/lib/editor/managers/HistoryManager/HistoryManager.js.map +2 -2
- package/dist-cjs/lib/editor/types/emit-types.js.map +1 -1
- package/dist-cjs/lib/license/LicenseManager.js +16 -8
- 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 +9 -48
- package/dist-esm/index.mjs +1 -3
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/TldrawEditor.mjs +3 -11
- package/dist-esm/lib/TldrawEditor.mjs.map +2 -2
- package/dist-esm/lib/config/createTLStore.mjs +1 -3
- package/dist-esm/lib/config/createTLStore.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +8 -38
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/HistoryManager/HistoryManager.mjs +2 -44
- package/dist-esm/lib/editor/managers/HistoryManager/HistoryManager.mjs.map +2 -2
- package/dist-esm/lib/license/LicenseManager.mjs +16 -8
- 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/package.json +7 -7
- package/src/index.ts +1 -6
- package/src/lib/TldrawEditor.tsx +1 -10
- package/src/lib/config/createTLStore.ts +4 -11
- package/src/lib/editor/Editor.ts +8 -47
- package/src/lib/editor/managers/HistoryManager/HistoryManager.ts +2 -58
- package/src/lib/editor/types/emit-types.ts +2 -14
- package/src/lib/license/LicenseManager.test.ts +62 -21
- package/src/lib/license/LicenseManager.ts +25 -11
- package/src/version.ts +3 -3
- package/dist-cjs/lib/editor/managers/AuthorizeManager/AuthorizeManager.js +0 -94
- package/dist-cjs/lib/editor/managers/AuthorizeManager/AuthorizeManager.js.map +0 -7
- package/dist-cjs/lib/hooks/useStableAuthorize.js +0 -45
- package/dist-cjs/lib/hooks/useStableAuthorize.js.map +0 -7
- package/dist-esm/lib/editor/managers/AuthorizeManager/AuthorizeManager.mjs +0 -76
- package/dist-esm/lib/editor/managers/AuthorizeManager/AuthorizeManager.mjs.map +0 -7
- package/dist-esm/lib/hooks/useStableAuthorize.mjs +0 -25
- package/dist-esm/lib/hooks/useStableAuthorize.mjs.map +0 -7
- package/src/lib/editor/managers/AuthorizeManager/AuthorizeManager.ts +0 -110
- package/src/lib/hooks/useStableAuthorize.ts +0 -31
|
@@ -78,7 +78,6 @@ var import_bindingsIndex = require("./derivations/bindingsIndex");
|
|
|
78
78
|
var import_notVisibleShapes = require("./derivations/notVisibleShapes");
|
|
79
79
|
var import_parentsToChildren = require("./derivations/parentsToChildren");
|
|
80
80
|
var import_shapeIdsInCurrentPage = require("./derivations/shapeIdsInCurrentPage");
|
|
81
|
-
var import_AuthorizeManager = require("./managers/AuthorizeManager/AuthorizeManager");
|
|
82
81
|
var import_ClickManager = require("./managers/ClickManager/ClickManager");
|
|
83
82
|
var import_CollaboratorsManager = require("./managers/CollaboratorsManager/CollaboratorsManager");
|
|
84
83
|
var import_EdgeScrollManager = require("./managers/EdgeScrollManager/EdgeScrollManager");
|
|
@@ -142,8 +141,6 @@ class Editor extends import_eventemitter3.default {
|
|
|
142
141
|
}
|
|
143
142
|
});
|
|
144
143
|
this.snaps = new import_SnapManager.SnapManager(this);
|
|
145
|
-
const authorizeManager = new import_AuthorizeManager.AuthorizeManager(this);
|
|
146
|
-
this.disposables.add(() => authorizeManager.dispose());
|
|
147
144
|
this._spatialIndex = new import_SpatialIndexManager.SpatialIndexManager(this);
|
|
148
145
|
this.disposables.add(() => this._spatialIndex.dispose());
|
|
149
146
|
this.disposables.add(this.timers.dispose);
|
|
@@ -1210,34 +1207,12 @@ class Editor extends import_eventemitter3.default {
|
|
|
1210
1207
|
const previousIgnoreShapeLock = this._shouldIgnoreShapeLock;
|
|
1211
1208
|
this._shouldIgnoreShapeLock = opts?.ignoreShapeLock ?? previousIgnoreShapeLock;
|
|
1212
1209
|
try {
|
|
1213
|
-
this.
|
|
1210
|
+
this.history.batch(fn, opts);
|
|
1214
1211
|
} finally {
|
|
1215
1212
|
this._shouldIgnoreShapeLock = previousIgnoreShapeLock;
|
|
1216
1213
|
}
|
|
1217
1214
|
return this;
|
|
1218
1215
|
}
|
|
1219
|
-
/**
|
|
1220
|
-
* Whether the current user has a permission, for example `'tl:shape:edit'` for a shape. The
|
|
1221
|
-
* editor asks the store's `authorize.can` with the current user's id: the one the sync room
|
|
1222
|
-
* gave this session, or else {@link @tldraw/editor#UserPreferencesManager.getExternalId}. With
|
|
1223
|
-
* no `can`, every permission is granted. In a read-only editor, no permission is granted.
|
|
1224
|
-
*
|
|
1225
|
-
* @example
|
|
1226
|
-
* ```ts
|
|
1227
|
-
* if (editor.can('tl:shape:edit', { shape })) {
|
|
1228
|
-
* editor.updateShape({ ...shape, x: 100 })
|
|
1229
|
-
* }
|
|
1230
|
-
* ```
|
|
1231
|
-
*
|
|
1232
|
-
* @public
|
|
1233
|
-
*/
|
|
1234
|
-
can(permission, data) {
|
|
1235
|
-
if (this.getIsReadonly()) return false;
|
|
1236
|
-
const can = (0, import_tlschema.bindAuthorizeCan)(this.store.props.authorize?.can, {
|
|
1237
|
-
userId: (0, import_AuthorizeManager.getAuthorizeUserId)(this)
|
|
1238
|
-
});
|
|
1239
|
-
return can(permission, data);
|
|
1240
|
-
}
|
|
1241
1216
|
/* --------------------- Errors --------------------- */
|
|
1242
1217
|
/** @internal */
|
|
1243
1218
|
annotateError(error, {
|
|
@@ -2001,7 +1976,6 @@ class Editor extends import_eventemitter3.default {
|
|
|
2001
1976
|
const _info = info ?? { type: "unknown" };
|
|
2002
1977
|
if (!util.canEdit(_shape, _info)) return false;
|
|
2003
1978
|
if (this.getIsReadonly() && !util.canEditInReadonly(_shape)) return false;
|
|
2004
|
-
if (!this.getIsReadonly() && !this.can("tl:shape:edit", { shape: _shape })) return false;
|
|
2005
1979
|
if (this.isShapeOrAncestorLocked(_shape) && !util.canEditWhileLocked(_shape)) return false;
|
|
2006
1980
|
return true;
|
|
2007
1981
|
}
|
|
@@ -2187,7 +2161,6 @@ class Editor extends import_eventemitter3.default {
|
|
|
2187
2161
|
if (!util.canCrop(_shape)) return false;
|
|
2188
2162
|
if (this.getIsReadonly()) return false;
|
|
2189
2163
|
if (this.isShapeOrAncestorLocked(_shape)) return false;
|
|
2190
|
-
if (!this.can("tl:shape:edit", { shape: _shape })) return false;
|
|
2191
2164
|
return true;
|
|
2192
2165
|
}
|
|
2193
2166
|
/**
|
|
@@ -3211,13 +3184,11 @@ class Editor extends import_eventemitter3.default {
|
|
|
3211
3184
|
if (existing && existing.name === user.name && existing.color === user.color && existing.imageUrl === user.imageUrl && existing.meta === user.meta) {
|
|
3212
3185
|
return;
|
|
3213
3186
|
}
|
|
3214
|
-
this.
|
|
3215
|
-
() =>
|
|
3216
|
-
()
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
{ history: "ignore" }
|
|
3220
|
-
)
|
|
3187
|
+
this.run(
|
|
3188
|
+
() => {
|
|
3189
|
+
this.store.put([user]);
|
|
3190
|
+
},
|
|
3191
|
+
{ history: "ignore" }
|
|
3221
3192
|
);
|
|
3222
3193
|
}
|
|
3223
3194
|
/**
|
|
@@ -6885,7 +6856,7 @@ class Editor extends import_eventemitter3.default {
|
|
|
6885
6856
|
* @param opts - Options for handling external content, including force flag to bypass readonly checks.
|
|
6886
6857
|
*/
|
|
6887
6858
|
async putExternalContent(info, opts = {}) {
|
|
6888
|
-
if (!opts.force &&
|
|
6859
|
+
if (!opts.force && this.getIsReadonly()) return;
|
|
6889
6860
|
return this.externalContentHandlers[info.type]?.(info);
|
|
6890
6861
|
}
|
|
6891
6862
|
/**
|
|
@@ -6895,7 +6866,7 @@ class Editor extends import_eventemitter3.default {
|
|
|
6895
6866
|
* @param opts - Options for handling external content, including force flag to bypass readonly checks.
|
|
6896
6867
|
*/
|
|
6897
6868
|
async replaceExternalContent(info, opts = {}) {
|
|
6898
|
-
if (!opts.force &&
|
|
6869
|
+
if (!opts.force && this.getIsReadonly()) return;
|
|
6899
6870
|
return this.externalContentHandlers[info.type]?.(info);
|
|
6900
6871
|
}
|
|
6901
6872
|
/**
|