@blocksandarrows/element 0.18.1 → 0.18.2
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 +61 -33
- package/dist/dev/index.js.map +3 -3
- package/dist/prod/index.js +9 -9
- package/dist/types/common/src/constants.d.ts +2 -0
- package/dist/types/element/src/comparisons.d.ts +1 -1
- package/dist/types/excalidraw/components/TTDDialog/common.d.ts +2 -1
- package/package.json +3 -3
package/dist/dev/index.js
CHANGED
|
@@ -2454,7 +2454,7 @@ import {
|
|
|
2454
2454
|
} from "@excalidraw/math";
|
|
2455
2455
|
import {
|
|
2456
2456
|
ROUGHNESS,
|
|
2457
|
-
isTransparent as
|
|
2457
|
+
isTransparent as isTransparent4,
|
|
2458
2458
|
assertNever as assertNever2,
|
|
2459
2459
|
COLOR_PALETTE,
|
|
2460
2460
|
LINE_POLYGON_POINT_MERGE_DISTANCE
|
|
@@ -2522,7 +2522,8 @@ var pe = 0.275;
|
|
|
2522
2522
|
var V = xe + 1e-4;
|
|
2523
2523
|
function ce(e, t = {}) {
|
|
2524
2524
|
let { size: u = 16, smoothing: x = 0.5, thinning: h = 0.5, simulatePressure: y = true, easing: n = (r) => r, start: f = {}, end: d = {}, last: D = false } = t, { cap: S = true, easing: j = (r) => r * (2 - r) } = f, { cap: q = true, easing: c = (r) => --r * r * r + 1 } = d;
|
|
2525
|
-
if (e.length === 0 || u <= 0)
|
|
2525
|
+
if (e.length === 0 || u <= 0)
|
|
2526
|
+
return [];
|
|
2526
2527
|
let p = e[e.length - 1].runningLength, g = f.taper === false ? 0 : f.taper === true ? Math.max(u, p) : f.taper, T = d.taper === false ? 0 : d.taper === true ? Math.max(u, p) : d.taper, te = Math.pow(u * x, 2), _ = [], M = [], H = e.slice(0, 10).reduce((r, i) => {
|
|
2527
2528
|
let o = i.pressure;
|
|
2528
2529
|
if (y) {
|
|
@@ -2533,21 +2534,24 @@ function ce(e, t = {}) {
|
|
|
2533
2534
|
}, e[0].pressure), m = $(u, h, e[e.length - 1].pressure, n), U, X = e[0].vector, z = e[0].point, F = z, O = z, E = F, J = false;
|
|
2534
2535
|
for (let r = 0; r < e.length; r++) {
|
|
2535
2536
|
let { pressure: i } = e[r], { point: o, vector: s, distance: W, runningLength: I } = e[r];
|
|
2536
|
-
if (r < e.length - 1 && p - I < 3)
|
|
2537
|
+
if (r < e.length - 1 && p - I < 3)
|
|
2538
|
+
continue;
|
|
2537
2539
|
if (h) {
|
|
2538
2540
|
if (y) {
|
|
2539
2541
|
let v = C(1, W / u), Z = C(1, 1 - v);
|
|
2540
2542
|
i = C(1, H + (Z - H) * (v * pe));
|
|
2541
2543
|
}
|
|
2542
2544
|
m = $(u, h, i, n);
|
|
2543
|
-
} else
|
|
2545
|
+
} else
|
|
2546
|
+
m = u / 2;
|
|
2544
2547
|
U === void 0 && (U = m);
|
|
2545
2548
|
let le = I < g ? j(I / g) : 1, fe = p - I < T ? c((p - I) / T) : 1;
|
|
2546
2549
|
m = Math.max(0.01, m * Math.min(le, fe));
|
|
2547
2550
|
let re = (r < e.length - 1 ? e[r + 1] : e[r]).vector, Y = r < e.length - 1 ? B(s, re) : 1, be = B(s, X) < 0 && !J, ne = Y !== null && Y < 0;
|
|
2548
2551
|
if (be || ne) {
|
|
2549
2552
|
let v = b(R(X), m);
|
|
2550
|
-
for (let Z = 1 / 13, w = 0; w <= 1; w += Z)
|
|
2553
|
+
for (let Z = 1 / 13, w = 0; w <= 1; w += Z)
|
|
2554
|
+
O = L(a(o, v), o, V * w), _.push(O), E = L(l(o, v), o, V * -w), M.push(E);
|
|
2551
2555
|
z = O, F = E, ne && (J = true);
|
|
2552
2556
|
continue;
|
|
2553
2557
|
}
|
|
@@ -2563,45 +2567,55 @@ function ce(e, t = {}) {
|
|
|
2563
2567
|
if (e.length === 1) {
|
|
2564
2568
|
if (!(g || T) || D) {
|
|
2565
2569
|
let r = ee(P, G(R(a(P, k))), -(U || m)), i = [];
|
|
2566
|
-
for (let o = 1 / 13, s = o; s <= 1; s += o)
|
|
2570
|
+
for (let o = 1 / 13, s = o; s <= 1; s += o)
|
|
2571
|
+
i.push(L(r, P, V * 2 * s));
|
|
2567
2572
|
return i;
|
|
2568
2573
|
}
|
|
2569
2574
|
} else {
|
|
2570
|
-
if (!(g || T && e.length === 1))
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2575
|
+
if (!(g || T && e.length === 1))
|
|
2576
|
+
if (S)
|
|
2577
|
+
for (let i = 1 / 13, o = i; o <= 1; o += i) {
|
|
2578
|
+
let s = L(M[0], P, V * o);
|
|
2579
|
+
Q.push(s);
|
|
2580
|
+
}
|
|
2581
|
+
else {
|
|
2582
|
+
let i = a(_[0], M[0]), o = b(i, 0.5), s = b(i, 0.51);
|
|
2583
|
+
Q.push(a(P, o), a(P, s), l(P, s), l(P, o));
|
|
2584
|
+
}
|
|
2578
2585
|
let r = R(se(e[e.length - 1].vector));
|
|
2579
|
-
if (T || g && e.length === 1)
|
|
2586
|
+
if (T || g && e.length === 1)
|
|
2587
|
+
N.push(k);
|
|
2580
2588
|
else if (q) {
|
|
2581
2589
|
let i = ee(k, r, m);
|
|
2582
|
-
for (let o = 1 / 29, s = o; s < 1; s += o)
|
|
2583
|
-
|
|
2590
|
+
for (let o = 1 / 29, s = o; s < 1; s += o)
|
|
2591
|
+
N.push(L(i, k, V * 3 * s));
|
|
2592
|
+
} else
|
|
2593
|
+
N.push(l(k, b(r, m)), l(k, b(r, m * 0.99)), a(k, b(r, m * 0.99)), a(k, b(r, m)));
|
|
2584
2594
|
}
|
|
2585
2595
|
return _.concat(N, M.reverse(), Q);
|
|
2586
2596
|
}
|
|
2587
2597
|
function me(e, t = {}) {
|
|
2588
2598
|
var q;
|
|
2589
2599
|
let { streamline: u = 0.5, size: x = 16, last: h = false } = t;
|
|
2590
|
-
if (e.length === 0)
|
|
2600
|
+
if (e.length === 0)
|
|
2601
|
+
return [];
|
|
2591
2602
|
let y = 0.15 + (1 - u) * 0.85, n = Array.isArray(e[0]) ? e : e.map(({ x: c, y: p, pressure: g = 0.5 }) => [c, p, g]);
|
|
2592
2603
|
if (n.length === 2) {
|
|
2593
2604
|
let c = n[1];
|
|
2594
2605
|
n = n.slice(0, -1);
|
|
2595
|
-
for (let p = 1; p < 5; p++)
|
|
2606
|
+
for (let p = 1; p < 5; p++)
|
|
2607
|
+
n.push(K(n[0], c, p / 4));
|
|
2596
2608
|
}
|
|
2597
2609
|
n.length === 1 && (n = [...n, [...l(n[0], [1, 1]), ...n[0].slice(2)]]);
|
|
2598
2610
|
let f = [{ point: [n[0][0], n[0][1]], pressure: n[0][2] >= 0 ? n[0][2] : 0.25, vector: [1, 1], distance: 0, runningLength: 0 }], d = false, D = 0, S = f[0], j = n.length - 1;
|
|
2599
2611
|
for (let c = 1; c < n.length; c++) {
|
|
2600
2612
|
let p = h && c === j ? n[c].slice(0, 2) : K(S.point, n[c], y);
|
|
2601
|
-
if (ue(S.point, p))
|
|
2613
|
+
if (ue(S.point, p))
|
|
2614
|
+
continue;
|
|
2602
2615
|
let g = ie(p, S.point);
|
|
2603
2616
|
if (D += g, c < j && !d) {
|
|
2604
|
-
if (D < x)
|
|
2617
|
+
if (D < x)
|
|
2618
|
+
continue;
|
|
2605
2619
|
d = true;
|
|
2606
2620
|
}
|
|
2607
2621
|
S = { point: p, pressure: n[c][2] >= 0 ? n[c][2] : 0.5, vector: G(a(S.point, p)), distance: g, runningLength: D }, f.push(S);
|
|
@@ -2626,9 +2640,11 @@ import {
|
|
|
2626
2640
|
FRAME_STYLE,
|
|
2627
2641
|
MIME_TYPES,
|
|
2628
2642
|
THEME,
|
|
2643
|
+
TEXT_BACKGROUND_PADDING_X,
|
|
2629
2644
|
distance as distance2,
|
|
2630
2645
|
getFontString as getFontString3,
|
|
2631
2646
|
isRTL,
|
|
2647
|
+
isTransparent as isTransparent3,
|
|
2632
2648
|
getVerticalOffset,
|
|
2633
2649
|
invariant as invariant9
|
|
2634
2650
|
} from "@excalidraw/common";
|
|
@@ -10088,7 +10104,7 @@ var selectGroup = (groupId, appState, elements) => {
|
|
|
10088
10104
|
}
|
|
10089
10105
|
};
|
|
10090
10106
|
};
|
|
10091
|
-
var selectGroupsForSelectedElements =
|
|
10107
|
+
var selectGroupsForSelectedElements = function() {
|
|
10092
10108
|
let lastSelectedElements = null;
|
|
10093
10109
|
let lastElements = null;
|
|
10094
10110
|
let lastReturnValue = null;
|
|
@@ -10175,7 +10191,7 @@ var selectGroupsForSelectedElements = (function() {
|
|
|
10175
10191
|
lastReturnValue = null;
|
|
10176
10192
|
};
|
|
10177
10193
|
return selectGroupsForSelectedElements2;
|
|
10178
|
-
}
|
|
10194
|
+
}();
|
|
10179
10195
|
var isSelectedViaGroup = (appState, element) => getSelectedGroupForElement(appState, element) != null;
|
|
10180
10196
|
var getSelectedGroupForElement = (appState, element) => element.groupIds.filter((groupId) => groupId !== appState.editingGroupId).find((groupId) => appState.selectedGroupIds[groupId]);
|
|
10181
10197
|
var getSelectedGroupIds = (appState) => Object.entries(appState.selectedGroupIds).filter(([groupId, isSelected]) => isSelected).map(([groupId, isSelected]) => groupId);
|
|
@@ -10390,7 +10406,7 @@ var getVisibleAndNonSelectedElements = (elements, selectedElements, appState, el
|
|
|
10390
10406
|
return !selectedElementsSet.has(element.id) && isVisible;
|
|
10391
10407
|
});
|
|
10392
10408
|
};
|
|
10393
|
-
var isSomeElementSelected =
|
|
10409
|
+
var isSomeElementSelected = function() {
|
|
10394
10410
|
let lastElements = null;
|
|
10395
10411
|
let lastSelectedElementIds = null;
|
|
10396
10412
|
let isSelected = null;
|
|
@@ -10411,7 +10427,7 @@ var isSomeElementSelected = (function() {
|
|
|
10411
10427
|
isSelected = null;
|
|
10412
10428
|
};
|
|
10413
10429
|
return ret;
|
|
10414
|
-
}
|
|
10430
|
+
}();
|
|
10415
10431
|
var getSelectedElements = (elements, appState, opts) => {
|
|
10416
10432
|
const addedElements = /* @__PURE__ */ new Set();
|
|
10417
10433
|
const selectedElements = [];
|
|
@@ -11242,6 +11258,21 @@ var drawElementOnCanvas = (element, rc, context, renderConfig) => {
|
|
|
11242
11258
|
}
|
|
11243
11259
|
context.canvas.setAttribute("dir", rtl ? "rtl" : "ltr");
|
|
11244
11260
|
context.save();
|
|
11261
|
+
if (!isTransparent3(element.backgroundColor)) {
|
|
11262
|
+
const padX = TEXT_BACKGROUND_PADDING_X;
|
|
11263
|
+
context.save();
|
|
11264
|
+
context.translate(-padX, 0);
|
|
11265
|
+
context.fillStyle = element.backgroundColor;
|
|
11266
|
+
if (context.roundRect) {
|
|
11267
|
+
const radius = Math.min(4, element.width / 8, element.height / 8);
|
|
11268
|
+
context.beginPath();
|
|
11269
|
+
context.roundRect(0, 0, element.width + padX * 2, element.height, radius);
|
|
11270
|
+
context.fill();
|
|
11271
|
+
} else {
|
|
11272
|
+
context.fillRect(0, 0, element.width + padX * 2, element.height);
|
|
11273
|
+
}
|
|
11274
|
+
context.restore();
|
|
11275
|
+
}
|
|
11245
11276
|
context.font = getFontString3(element);
|
|
11246
11277
|
context.fillStyle = element.strokeColor;
|
|
11247
11278
|
context.textAlign = element.textAlign;
|
|
@@ -11691,7 +11722,7 @@ function getSvgPathFromStroke(points) {
|
|
|
11691
11722
|
|
|
11692
11723
|
// src/comparisons.ts
|
|
11693
11724
|
init_define_import_meta_env();
|
|
11694
|
-
var hasBackground = (type) => type === "rectangle" || type === "iframe" || type === "embeddable" || type === "ellipse" || type === "diamond" || type === "line" || type === "freedraw";
|
|
11725
|
+
var hasBackground = (type) => type === "rectangle" || type === "iframe" || type === "embeddable" || type === "ellipse" || type === "diamond" || type === "line" || type === "freedraw" || type === "text";
|
|
11695
11726
|
var hasStrokeColor = (type) => type === "rectangle" || type === "ellipse" || type === "diamond" || type === "freedraw" || type === "arrow" || type === "line" || type === "text";
|
|
11696
11727
|
var hasStrokeWidth = (type) => type === "rectangle" || type === "iframe" || type === "embeddable" || type === "ellipse" || type === "diamond" || type === "freedraw" || type === "arrow" || type === "line";
|
|
11697
11728
|
var hasStrokeStyle = (type) => type === "rectangle" || type === "iframe" || type === "embeddable" || type === "ellipse" || type === "diamond" || type === "arrow" || type === "line";
|
|
@@ -11782,7 +11813,7 @@ var generateRoughOptions = (element, continuousPath = false) => {
|
|
|
11782
11813
|
case "diamond":
|
|
11783
11814
|
case "ellipse": {
|
|
11784
11815
|
options.fillStyle = element.fillStyle;
|
|
11785
|
-
options.fill =
|
|
11816
|
+
options.fill = isTransparent4(element.backgroundColor) ? void 0 : element.backgroundColor;
|
|
11786
11817
|
if (element.type === "ellipse") {
|
|
11787
11818
|
options.curveFitting = 1;
|
|
11788
11819
|
}
|
|
@@ -11804,7 +11835,7 @@ var generateRoughOptions = (element, continuousPath = false) => {
|
|
|
11804
11835
|
}
|
|
11805
11836
|
};
|
|
11806
11837
|
var modifyIframeLikeForRoughOptions = (element, isExporting, embedsValidationStatus) => {
|
|
11807
|
-
if (isIframeLikeElement(element) && (isExporting || isEmbeddableElement(element) && embedsValidationStatus?.get(element.id) !== true) &&
|
|
11838
|
+
if (isIframeLikeElement(element) && (isExporting || isEmbeddableElement(element) && embedsValidationStatus?.get(element.id) !== true) && isTransparent4(element.backgroundColor) && isTransparent4(element.strokeColor)) {
|
|
11808
11839
|
return {
|
|
11809
11840
|
...element,
|
|
11810
11841
|
roughness: 0,
|
|
@@ -11814,8 +11845,8 @@ var modifyIframeLikeForRoughOptions = (element, isExporting, embedsValidationSta
|
|
|
11814
11845
|
} else if (isIframeElement(element)) {
|
|
11815
11846
|
return {
|
|
11816
11847
|
...element,
|
|
11817
|
-
strokeColor:
|
|
11818
|
-
backgroundColor:
|
|
11848
|
+
strokeColor: isTransparent4(element.strokeColor) ? "#000000" : element.strokeColor,
|
|
11849
|
+
backgroundColor: isTransparent4(element.backgroundColor) ? "#f4f4f6" : element.backgroundColor
|
|
11819
11850
|
};
|
|
11820
11851
|
}
|
|
11821
11852
|
return element;
|
|
@@ -13932,11 +13963,9 @@ var Store = class {
|
|
|
13932
13963
|
const delta = "delta" in params ? params.delta : void 0;
|
|
13933
13964
|
try {
|
|
13934
13965
|
switch (action) {
|
|
13935
|
-
// only immediately emits a durable increment
|
|
13936
13966
|
case CaptureUpdateAction.IMMEDIATELY:
|
|
13937
13967
|
this.emitDurableIncrement(nextSnapshot, change, delta);
|
|
13938
13968
|
break;
|
|
13939
|
-
// both never and eventually emit an ephemeral increment
|
|
13940
13969
|
case CaptureUpdateAction.NEVER:
|
|
13941
13970
|
case CaptureUpdateAction.EVENTUALLY:
|
|
13942
13971
|
this.emitEphemeralIncrement(nextSnapshot, change);
|
|
@@ -13946,7 +13975,6 @@ var Store = class {
|
|
|
13946
13975
|
}
|
|
13947
13976
|
} finally {
|
|
13948
13977
|
switch (action) {
|
|
13949
|
-
// both immediately and never update the snapshot, unlike eventually
|
|
13950
13978
|
case CaptureUpdateAction.IMMEDIATELY:
|
|
13951
13979
|
case CaptureUpdateAction.NEVER:
|
|
13952
13980
|
this.snapshot = nextSnapshot;
|