@tldraw/editor 3.10.2 → 3.11.0-canary.03a8f07c67a3
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/CHANGELOG.md +2 -2
- package/dist-cjs/index.d.ts +24 -10
- package/dist-cjs/index.js +1 -1
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultShapeIndicator.js +4 -4
- package/dist-cjs/lib/components/default-components/DefaultShapeIndicator.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultShapeIndicators.js +34 -26
- package/dist-cjs/lib/components/default-components/DefaultShapeIndicators.js.map +2 -2
- package/dist-cjs/lib/config/TLUserPreferences.js +1 -1
- package/dist-cjs/lib/config/TLUserPreferences.js.map +1 -1
- package/dist-cjs/lib/config/createTLStore.js +2 -1
- package/dist-cjs/lib/config/createTLStore.js.map +2 -2
- package/dist-cjs/lib/constants.js +1 -1
- package/dist-cjs/lib/constants.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +18 -10
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/managers/FocusManager.js +15 -0
- package/dist-cjs/lib/editor/managers/FocusManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/UserPreferencesManager.js +1 -1
- package/dist-cjs/lib/editor/managers/UserPreferencesManager.js.map +2 -2
- package/dist-cjs/lib/exports/StyleEmbedder.js +16 -1
- package/dist-cjs/lib/exports/StyleEmbedder.js.map +2 -2
- package/dist-cjs/lib/exports/exportToSvg.js.map +1 -1
- package/dist-cjs/lib/exports/getSvgJsx.js +1 -1
- package/dist-cjs/lib/exports/getSvgJsx.js.map +2 -2
- package/dist-cjs/lib/exports/parseCss.js +27 -2
- package/dist-cjs/lib/exports/parseCss.js.map +2 -2
- package/dist-cjs/lib/hooks/useLocalStore.js +3 -0
- package/dist-cjs/lib/hooks/useLocalStore.js.map +2 -2
- package/dist-cjs/lib/license/Watermark.js +7 -1
- package/dist-cjs/lib/license/Watermark.js.map +2 -2
- package/dist-cjs/lib/options.js +2 -1
- package/dist-cjs/lib/options.js.map +2 -2
- package/dist-cjs/lib/utils/sync/LocalIndexedDb.js +8 -0
- package/dist-cjs/lib/utils/sync/LocalIndexedDb.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 +24 -10
- package/dist-esm/index.mjs +4 -2
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultShapeIndicator.mjs +4 -4
- package/dist-esm/lib/components/default-components/DefaultShapeIndicator.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultShapeIndicators.mjs +34 -26
- package/dist-esm/lib/components/default-components/DefaultShapeIndicators.mjs.map +2 -2
- package/dist-esm/lib/config/TLUserPreferences.mjs +1 -1
- package/dist-esm/lib/config/TLUserPreferences.mjs.map +1 -1
- package/dist-esm/lib/config/createTLStore.mjs +2 -1
- package/dist-esm/lib/config/createTLStore.mjs.map +2 -2
- package/dist-esm/lib/constants.mjs +1 -1
- package/dist-esm/lib/constants.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +18 -10
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/FocusManager.mjs +15 -0
- package/dist-esm/lib/editor/managers/FocusManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/UserPreferencesManager.mjs +1 -1
- package/dist-esm/lib/editor/managers/UserPreferencesManager.mjs.map +2 -2
- package/dist-esm/lib/exports/StyleEmbedder.mjs +22 -2
- package/dist-esm/lib/exports/StyleEmbedder.mjs.map +2 -2
- package/dist-esm/lib/exports/exportToSvg.mjs.map +1 -1
- package/dist-esm/lib/exports/getSvgJsx.mjs +1 -1
- package/dist-esm/lib/exports/getSvgJsx.mjs.map +2 -2
- package/dist-esm/lib/exports/parseCss.mjs +27 -2
- package/dist-esm/lib/exports/parseCss.mjs.map +2 -2
- package/dist-esm/lib/hooks/useLocalStore.mjs +3 -0
- package/dist-esm/lib/hooks/useLocalStore.mjs.map +2 -2
- package/dist-esm/lib/license/Watermark.mjs +7 -1
- package/dist-esm/lib/license/Watermark.mjs.map +2 -2
- package/dist-esm/lib/options.mjs +2 -1
- package/dist-esm/lib/options.mjs.map +2 -2
- package/dist-esm/lib/utils/sync/LocalIndexedDb.mjs +8 -0
- package/dist-esm/lib/utils/sync/LocalIndexedDb.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/editor.css +1 -1
- package/package.json +10 -7
- package/src/index.ts +4 -1
- package/src/lib/components/default-components/DefaultShapeIndicator.tsx +4 -4
- package/src/lib/components/default-components/DefaultShapeIndicators.tsx +52 -31
- package/src/lib/config/TLUserPreferences.ts +1 -1
- package/src/lib/config/createTLStore.ts +1 -0
- package/src/lib/constants.ts +1 -1
- package/src/lib/editor/Editor.ts +21 -12
- package/src/lib/editor/managers/FocusManager.ts +18 -0
- package/src/lib/editor/managers/UserPreferencesManager.ts +1 -1
- package/src/lib/exports/StyleEmbedder.ts +23 -4
- package/src/lib/exports/exportToSvg.tsx +1 -1
- package/src/lib/exports/getSvgJsx.tsx +1 -1
- package/src/lib/exports/parseCss.ts +36 -2
- package/src/lib/hooks/useLocalStore.ts +3 -0
- package/src/lib/license/Watermark.tsx +7 -1
- package/src/lib/options.ts +6 -0
- package/src/lib/utils/sync/LocalIndexedDb.ts +9 -0
- package/src/version.ts +3 -3
|
@@ -3204,7 +3204,13 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
3204
3204
|
if (this.getIsReadonly()) return this;
|
|
3205
3205
|
const ids = typeof assets[0] === "string" ? assets : assets.map((a) => a.id);
|
|
3206
3206
|
if (ids.length <= 0) return this;
|
|
3207
|
-
this.run(
|
|
3207
|
+
this.run(
|
|
3208
|
+
() => {
|
|
3209
|
+
this.store.props.assets.remove?.(ids);
|
|
3210
|
+
this.store.remove(ids);
|
|
3211
|
+
},
|
|
3212
|
+
{ history: "ignore" }
|
|
3213
|
+
);
|
|
3208
3214
|
return this;
|
|
3209
3215
|
}
|
|
3210
3216
|
/**
|
|
@@ -4770,17 +4776,18 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
4770
4776
|
*
|
|
4771
4777
|
* @example
|
|
4772
4778
|
* ```ts
|
|
4773
|
-
* editor.stackShapes([box1, box2], 'horizontal'
|
|
4774
|
-
* editor.stackShapes(editor.getSelectedShapeIds(), 'horizontal'
|
|
4779
|
+
* editor.stackShapes([box1, box2], 'horizontal')
|
|
4780
|
+
* editor.stackShapes(editor.getSelectedShapeIds(), 'horizontal')
|
|
4775
4781
|
* ```
|
|
4776
4782
|
*
|
|
4777
4783
|
* @param shapes - The shapes (or shape ids) to stack.
|
|
4778
4784
|
* @param operation - Whether to stack horizontally or vertically.
|
|
4779
|
-
* @param gap - The gap to leave between shapes.
|
|
4785
|
+
* @param gap - The gap to leave between shapes. By default, uses the editor's `adjacentShapeMargin` option.
|
|
4780
4786
|
*
|
|
4781
4787
|
* @public
|
|
4782
4788
|
*/
|
|
4783
4789
|
stackShapes(shapes, operation, gap) {
|
|
4790
|
+
const _gap = gap ?? this.options.adjacentShapeMargin;
|
|
4784
4791
|
const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id);
|
|
4785
4792
|
if (this.getIsReadonly()) return this;
|
|
4786
4793
|
const shapesToStackFirstPass = (0, import_utils.compact)(ids.map((id) => this.getShape(id)));
|
|
@@ -4816,7 +4823,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
4816
4823
|
allBounds.push(commonPageBounds);
|
|
4817
4824
|
}
|
|
4818
4825
|
const len = shapeClustersToStack.length;
|
|
4819
|
-
if (
|
|
4826
|
+
if (_gap === 0 && len < 3 || len < 2) return this;
|
|
4820
4827
|
let val;
|
|
4821
4828
|
let min;
|
|
4822
4829
|
let max;
|
|
@@ -4833,7 +4840,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
4833
4840
|
dim = "height";
|
|
4834
4841
|
}
|
|
4835
4842
|
let shapeGap = 0;
|
|
4836
|
-
if (
|
|
4843
|
+
if (_gap === 0) {
|
|
4837
4844
|
const gaps = {};
|
|
4838
4845
|
shapeClustersToStack.sort((a, b) => a.pageBounds[min] - b.pageBounds[min]);
|
|
4839
4846
|
for (let i = 0; i < len - 1; i++) {
|
|
@@ -4861,7 +4868,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
4861
4868
|
shapeGap /= totalCount;
|
|
4862
4869
|
}
|
|
4863
4870
|
} else {
|
|
4864
|
-
shapeGap =
|
|
4871
|
+
shapeGap = _gap;
|
|
4865
4872
|
}
|
|
4866
4873
|
const changes = [];
|
|
4867
4874
|
let v = shapeClustersToStack[0].pageBounds[max];
|
|
@@ -4889,16 +4896,17 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
4889
4896
|
*
|
|
4890
4897
|
* @example
|
|
4891
4898
|
* ```ts
|
|
4892
|
-
* editor.packShapes([box1, box2]
|
|
4899
|
+
* editor.packShapes([box1, box2])
|
|
4893
4900
|
* editor.packShapes(editor.getSelectedShapeIds(), 32)
|
|
4894
4901
|
* ```
|
|
4895
4902
|
*
|
|
4896
4903
|
*
|
|
4897
4904
|
* @param shapes - The shapes (or shape ids) to pack.
|
|
4898
|
-
* @param gap - The padding to apply to the packed shapes. Defaults to
|
|
4905
|
+
* @param gap - The padding to apply to the packed shapes. Defaults to the editor's `adjacentShapeMargin` option.
|
|
4899
4906
|
*/
|
|
4900
|
-
packShapes(shapes,
|
|
4907
|
+
packShapes(shapes, _gap) {
|
|
4901
4908
|
if (this.getIsReadonly()) return this;
|
|
4909
|
+
const gap = _gap ?? this.options.adjacentShapeMargin;
|
|
4902
4910
|
const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id);
|
|
4903
4911
|
const shapesToPackFirstPass = (0, import_utils.compact)(ids.map((id) => this.getShape(id)));
|
|
4904
4912
|
const shapeClustersToPack = [];
|