@tldraw/editor 3.11.0-canary.de52f4d709d2 → 3.11.0-canary.e0e5f2c27ecc
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 +17 -9
- 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 -14
- 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/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 +5 -0
- package/dist-cjs/lib/license/Watermark.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 +17 -9
- 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 -14
- 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/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 +5 -0
- package/dist-esm/lib/license/Watermark.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 +10 -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 +20 -17
- 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/parseCss.ts +36 -2
- package/src/lib/hooks/useLocalStore.ts +3 -0
- package/src/lib/license/Watermark.tsx +5 -0
- package/src/lib/utils/sync/LocalIndexedDb.ts +9 -0
- package/src/version.ts +3 -3
|
@@ -1674,10 +1674,6 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
1674
1674
|
* @public
|
|
1675
1675
|
*/
|
|
1676
1676
|
setRichTextEditor(textEditor) {
|
|
1677
|
-
const current = this._currentRichTextEditor.__unsafe__getWithoutCapture();
|
|
1678
|
-
if (current !== textEditor) {
|
|
1679
|
-
current?.destroy();
|
|
1680
|
-
}
|
|
1681
1677
|
this._currentRichTextEditor.set(textEditor);
|
|
1682
1678
|
return this;
|
|
1683
1679
|
}
|
|
@@ -3237,7 +3233,13 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
3237
3233
|
if (this.getIsReadonly()) return this;
|
|
3238
3234
|
const ids = typeof assets[0] === "string" ? assets : assets.map((a) => a.id);
|
|
3239
3235
|
if (ids.length <= 0) return this;
|
|
3240
|
-
this.run(
|
|
3236
|
+
this.run(
|
|
3237
|
+
() => {
|
|
3238
|
+
this.store.props.assets.remove?.(ids);
|
|
3239
|
+
this.store.remove(ids);
|
|
3240
|
+
},
|
|
3241
|
+
{ history: "ignore" }
|
|
3242
|
+
);
|
|
3241
3243
|
return this;
|
|
3242
3244
|
}
|
|
3243
3245
|
/**
|
|
@@ -4803,17 +4805,18 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
4803
4805
|
*
|
|
4804
4806
|
* @example
|
|
4805
4807
|
* ```ts
|
|
4806
|
-
* editor.stackShapes([box1, box2], 'horizontal'
|
|
4807
|
-
* editor.stackShapes(editor.getSelectedShapeIds(), 'horizontal'
|
|
4808
|
+
* editor.stackShapes([box1, box2], 'horizontal')
|
|
4809
|
+
* editor.stackShapes(editor.getSelectedShapeIds(), 'horizontal')
|
|
4808
4810
|
* ```
|
|
4809
4811
|
*
|
|
4810
4812
|
* @param shapes - The shapes (or shape ids) to stack.
|
|
4811
4813
|
* @param operation - Whether to stack horizontally or vertically.
|
|
4812
|
-
* @param gap - The gap to leave between shapes.
|
|
4814
|
+
* @param gap - The gap to leave between shapes. By default, uses the editor's `adjacentShapeMargin` option.
|
|
4813
4815
|
*
|
|
4814
4816
|
* @public
|
|
4815
4817
|
*/
|
|
4816
4818
|
stackShapes(shapes, operation, gap) {
|
|
4819
|
+
const _gap = gap ?? this.options.adjacentShapeMargin;
|
|
4817
4820
|
const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id);
|
|
4818
4821
|
if (this.getIsReadonly()) return this;
|
|
4819
4822
|
const shapesToStackFirstPass = compact(ids.map((id) => this.getShape(id)));
|
|
@@ -4849,7 +4852,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
4849
4852
|
allBounds.push(commonPageBounds);
|
|
4850
4853
|
}
|
|
4851
4854
|
const len = shapeClustersToStack.length;
|
|
4852
|
-
if (
|
|
4855
|
+
if (_gap === 0 && len < 3 || len < 2) return this;
|
|
4853
4856
|
let val;
|
|
4854
4857
|
let min;
|
|
4855
4858
|
let max;
|
|
@@ -4866,7 +4869,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
4866
4869
|
dim = "height";
|
|
4867
4870
|
}
|
|
4868
4871
|
let shapeGap = 0;
|
|
4869
|
-
if (
|
|
4872
|
+
if (_gap === 0) {
|
|
4870
4873
|
const gaps = {};
|
|
4871
4874
|
shapeClustersToStack.sort((a, b) => a.pageBounds[min] - b.pageBounds[min]);
|
|
4872
4875
|
for (let i = 0; i < len - 1; i++) {
|
|
@@ -4894,7 +4897,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
4894
4897
|
shapeGap /= totalCount;
|
|
4895
4898
|
}
|
|
4896
4899
|
} else {
|
|
4897
|
-
shapeGap =
|
|
4900
|
+
shapeGap = _gap;
|
|
4898
4901
|
}
|
|
4899
4902
|
const changes = [];
|
|
4900
4903
|
let v = shapeClustersToStack[0].pageBounds[max];
|
|
@@ -4922,16 +4925,17 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
4922
4925
|
*
|
|
4923
4926
|
* @example
|
|
4924
4927
|
* ```ts
|
|
4925
|
-
* editor.packShapes([box1, box2]
|
|
4928
|
+
* editor.packShapes([box1, box2])
|
|
4926
4929
|
* editor.packShapes(editor.getSelectedShapeIds(), 32)
|
|
4927
4930
|
* ```
|
|
4928
4931
|
*
|
|
4929
4932
|
*
|
|
4930
4933
|
* @param shapes - The shapes (or shape ids) to pack.
|
|
4931
|
-
* @param gap - The padding to apply to the packed shapes. Defaults to
|
|
4934
|
+
* @param gap - The padding to apply to the packed shapes. Defaults to the editor's `adjacentShapeMargin` option.
|
|
4932
4935
|
*/
|
|
4933
|
-
packShapes(shapes,
|
|
4936
|
+
packShapes(shapes, _gap) {
|
|
4934
4937
|
if (this.getIsReadonly()) return this;
|
|
4938
|
+
const gap = _gap ?? this.options.adjacentShapeMargin;
|
|
4935
4939
|
const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id);
|
|
4936
4940
|
const shapesToPackFirstPass = compact(ids.map((id) => this.getShape(id)));
|
|
4937
4941
|
const shapeClustersToPack = [];
|