@myoc/element 0.19.535 → 0.19.537
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/dev/index.js +41 -7
- package/dist/dev/index.js.map +3 -3
- package/dist/prod/index.js +15 -15
- package/dist/types/element/src/align.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionAlign.d.ts +191 -0
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +6 -0
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +18 -0
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +6 -0
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +3 -0
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +9 -0
- package/dist/types/excalidraw/actions/actionDeselect.d.ts +3 -0
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +6 -0
- package/dist/types/excalidraw/actions/actionExport.d.ts +6 -0
- package/dist/types/excalidraw/actions/actionFrame.d.ts +9 -0
- package/dist/types/excalidraw/actions/actionGroup.d.ts +6 -0
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +3 -0
- package/dist/types/excalidraw/actions/actionLink.d.ts +3 -0
- package/dist/types/excalidraw/actions/actionMenu.d.ts +3 -0
- package/dist/types/excalidraw/actions/actionProperties.d.ts +6 -0
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +3 -0
- package/dist/types/excalidraw/actions/actionStyles.d.ts +3 -0
- package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +3 -0
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +3 -0
- package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +3 -0
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +3 -0
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +3 -0
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +3 -0
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +3 -0
- package/dist/types/excalidraw/actions/index.d.ts +1 -1
- package/dist/types/excalidraw/actions/types.d.ts +1 -1
- package/dist/types/excalidraw/appState.d.ts +3 -0
- package/dist/types/excalidraw/data/blob.d.ts +3 -0
- package/dist/types/excalidraw/data/json.d.ts +3 -0
- package/dist/types/excalidraw/editorPreferences.d.ts +5 -2
- package/dist/types/excalidraw/types.d.ts +7 -0
- package/dist/types/excalidraw/viewport.d.ts +3 -0
- package/package.json +4 -4
package/dist/dev/index.js
CHANGED
|
@@ -18320,19 +18320,22 @@ var getNormalizedDimensions = (element) => {
|
|
|
18320
18320
|
|
|
18321
18321
|
// src/align.ts
|
|
18322
18322
|
init_define_import_meta_env();
|
|
18323
|
-
var alignElements = (selectedElements, alignment, scene, appState) => {
|
|
18323
|
+
var alignElements = (selectedElements, alignment, scene, appState, options) => {
|
|
18324
18324
|
const groups = getSelectedElementsByGroup(
|
|
18325
18325
|
selectedElements,
|
|
18326
18326
|
scene.getNonDeletedElementsMap(),
|
|
18327
18327
|
appState
|
|
18328
18328
|
).map(getNonDeletedElements);
|
|
18329
18329
|
const selectionBoundingBox = getCommonBoundingBox(selectedElements);
|
|
18330
|
-
|
|
18331
|
-
|
|
18332
|
-
|
|
18333
|
-
|
|
18334
|
-
|
|
18335
|
-
)
|
|
18330
|
+
const translations = options?.stacking === false && alignment.position !== "center" ? calculateNonStackingTranslations(
|
|
18331
|
+
groups,
|
|
18332
|
+
alignment,
|
|
18333
|
+
Math.max(0, options.gap ?? 0)
|
|
18334
|
+
) : groups.map(
|
|
18335
|
+
(group) => calculateTranslation(group, selectionBoundingBox, alignment)
|
|
18336
|
+
);
|
|
18337
|
+
return groups.flatMap((group, index) => {
|
|
18338
|
+
const translation = translations[index];
|
|
18336
18339
|
return group.map((element) => {
|
|
18337
18340
|
const updatedEle = scene.mutateElement(element, {
|
|
18338
18341
|
x: element.x + translation.x,
|
|
@@ -18345,6 +18348,37 @@ var alignElements = (selectedElements, alignment, scene, appState) => {
|
|
|
18345
18348
|
});
|
|
18346
18349
|
});
|
|
18347
18350
|
};
|
|
18351
|
+
var calculateNonStackingTranslations = (groups, { axis, position }, gap) => {
|
|
18352
|
+
const [primaryMin, primaryMax, secondaryMin, secondaryMax] = axis === "x" ? ["minX", "maxX", "minY", "maxY"] : ["minY", "maxY", "minX", "maxX"];
|
|
18353
|
+
const orderedGroups = groups.map((group, index) => ({
|
|
18354
|
+
boundingBox: getCommonBoundingBox(group),
|
|
18355
|
+
index
|
|
18356
|
+
})).sort((a2, b2) => {
|
|
18357
|
+
const edgeDifference = position === "start" ? a2.boundingBox[primaryMin] - b2.boundingBox[primaryMin] : b2.boundingBox[primaryMax] - a2.boundingBox[primaryMax];
|
|
18358
|
+
return edgeDifference || a2.index - b2.index;
|
|
18359
|
+
});
|
|
18360
|
+
const translations = groups.map(() => ({ x: 0, y: 0 }));
|
|
18361
|
+
const placedBoundingBoxes = [];
|
|
18362
|
+
const anchorEdge = orderedGroups[0]?.boundingBox[position === "start" ? primaryMin : primaryMax] ?? 0;
|
|
18363
|
+
for (const { boundingBox, index } of orderedGroups) {
|
|
18364
|
+
const overlapsPerpendicularly = (placed) => boundingBox[secondaryMin] < placed[secondaryMax] && boundingBox[secondaryMax] > placed[secondaryMin];
|
|
18365
|
+
let alignedEdge = anchorEdge;
|
|
18366
|
+
for (const placed of placedBoundingBoxes) {
|
|
18367
|
+
if (!overlapsPerpendicularly(placed)) {
|
|
18368
|
+
continue;
|
|
18369
|
+
}
|
|
18370
|
+
alignedEdge = position === "start" ? Math.max(alignedEdge, placed[primaryMax] + gap) : Math.min(alignedEdge, placed[primaryMin] - gap);
|
|
18371
|
+
}
|
|
18372
|
+
const translation = alignedEdge - boundingBox[position === "start" ? primaryMin : primaryMax];
|
|
18373
|
+
translations[index][axis] = translation;
|
|
18374
|
+
placedBoundingBoxes.push({
|
|
18375
|
+
...boundingBox,
|
|
18376
|
+
[primaryMin]: boundingBox[primaryMin] + translation,
|
|
18377
|
+
[primaryMax]: boundingBox[primaryMax] + translation
|
|
18378
|
+
});
|
|
18379
|
+
}
|
|
18380
|
+
return translations;
|
|
18381
|
+
};
|
|
18348
18382
|
var calculateTranslation = (group, selectionBoundingBox, { axis, position }) => {
|
|
18349
18383
|
const groupBoundingBox = getCommonBoundingBox(group);
|
|
18350
18384
|
const [min, max] = axis === "x" ? ["minX", "maxX"] : ["minY", "maxY"];
|