@excalidraw/common 0.18.0-2b0e4c9 → 0.18.0-2b1c2a9
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 +130 -85
- package/dist/dev/index.js.map +3 -3
- package/dist/prod/index.js +3 -3
- package/dist/types/common/src/colors.d.ts +20 -1
- package/dist/types/common/src/constants.d.ts +12 -7
- package/dist/types/common/src/keys.d.ts +2 -0
- package/dist/types/common/src/points.d.ts +1 -1
- package/dist/types/common/src/utils.d.ts +1 -43
- package/dist/types/element/src/Scene.d.ts +6 -4
- package/dist/types/element/src/align.d.ts +2 -2
- package/dist/types/element/src/arrowEndpointText.d.ts +49 -0
- package/dist/types/element/src/arrows/focus.d.ts +5 -2
- package/dist/types/element/src/binding.d.ts +17 -8
- package/dist/types/element/src/bounds.d.ts +22 -7
- package/dist/types/element/src/bucketFill.d.ts +110 -0
- package/dist/types/element/src/collision.d.ts +1 -1
- package/dist/types/element/src/comparisons.d.ts +5 -4
- package/dist/types/element/src/convertToShape.d.ts +23 -0
- package/dist/types/element/src/distribute.d.ts +2 -2
- package/dist/types/element/src/dragElements.d.ts +27 -0
- package/dist/types/element/src/duplicate.d.ts +4 -3
- package/dist/types/element/src/embeddable.d.ts +2 -2
- package/dist/types/element/src/flowchart.d.ts +7 -7
- package/dist/types/element/src/fractionalIndex.d.ts +2 -2
- package/dist/types/element/src/frame.d.ts +9 -8
- package/dist/types/element/src/groups.d.ts +9 -9
- package/dist/types/element/src/index.d.ts +4 -1
- package/dist/types/element/src/linearElementEditor.d.ts +27 -10
- package/dist/types/element/src/newElement.d.ts +15 -0
- package/dist/types/element/src/renderElement.d.ts +0 -3
- package/dist/types/element/src/resizeElements.d.ts +2 -2
- package/dist/types/element/src/selection.d.ts +11 -7
- package/dist/types/element/src/shape.d.ts +13 -1
- package/dist/types/element/src/sortElements.d.ts +10 -0
- package/dist/types/element/src/textElement.d.ts +14 -10
- package/dist/types/element/src/textWrapping.d.ts +26 -0
- package/dist/types/element/src/transform.d.ts +2 -2
- package/dist/types/element/src/typeChecks.d.ts +26 -25
- package/dist/types/element/src/types.d.ts +15 -1
- package/dist/types/element/src/utils.d.ts +7 -3
- package/dist/types/element/src/zindex.d.ts +2 -2
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +48 -21
- package/dist/types/excalidraw/actions/actionAlign.d.ts +6 -6
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +33 -15
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +174 -947
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +32 -14
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +16 -7
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +50 -22
- package/dist/types/excalidraw/actions/{actionEmbeddable.d.ts → actionDeselect.d.ts} +30 -36
- package/dist/types/excalidraw/actions/actionDistribute.d.ts +2 -3
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +16 -7
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +33 -15
- package/dist/types/excalidraw/actions/actionExport.d.ts +37 -19
- package/dist/types/excalidraw/actions/actionFinalize.d.ts +1 -0
- package/dist/types/excalidraw/actions/actionFrame.d.ts +61 -205
- package/dist/types/excalidraw/actions/actionGroup.d.ts +48 -30
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +21 -9
- package/dist/types/excalidraw/actions/actionLink.d.ts +17 -8
- package/dist/types/excalidraw/actions/actionMenu.d.ts +16 -7
- package/dist/types/excalidraw/actions/actionProperties.d.ts +62 -32
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +21 -12
- package/dist/types/excalidraw/actions/actionStyles.d.ts +17 -7
- package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +3 -3
- package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +17 -8
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +20 -12
- package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +17 -8
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +17 -8
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +20 -12
- package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +17 -8
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +18 -9
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +17 -8
- package/dist/types/excalidraw/actions/index.d.ts +2 -2
- package/dist/types/excalidraw/actions/manager.d.ts +1 -0
- package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -1
- package/dist/types/excalidraw/actions/types.d.ts +8 -4
- package/dist/types/excalidraw/{animated-trail.d.ts → animatedTrail.d.ts} +4 -3
- package/dist/types/excalidraw/appState.d.ts +13 -6
- package/dist/types/excalidraw/components/Actions.d.ts +17 -12
- package/dist/types/excalidraw/components/ActiveConfirmDialog.d.ts +1 -1
- package/dist/types/excalidraw/components/App.arrowText.d.ts +104 -0
- package/dist/types/excalidraw/components/App.bucketFill.d.ts +48 -0
- package/dist/types/excalidraw/components/App.cursor.d.ts +38 -0
- package/dist/types/excalidraw/components/App.d.ts +391 -68
- package/dist/types/excalidraw/components/App.drawshape.d.ts +55 -0
- package/dist/types/excalidraw/components/App.flowchart.d.ts +21 -0
- package/dist/types/excalidraw/components/App.viewport.d.ts +73 -0
- package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +9 -3
- package/dist/types/excalidraw/components/ColorPicker/CustomColorList.d.ts +3 -1
- package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +3 -1
- package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +9 -2
- package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +4 -2
- package/dist/types/excalidraw/components/ColorPicker/TopPicks.d.ts +8 -1
- package/dist/types/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +1 -1
- package/dist/types/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +2 -1
- package/dist/types/excalidraw/components/ColorPicker/topPicksDnD.d.ts +31 -0
- package/dist/types/excalidraw/components/CommandPalette/defaultCommandPaletteItems.d.ts +1 -2
- package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +2 -2
- package/dist/types/excalidraw/components/CursorHint.d.ts +46 -0
- package/dist/types/excalidraw/components/EyeDropper.d.ts +1 -1
- package/dist/types/excalidraw/components/{ToolButton.d.ts → IconButton.d.ts} +16 -19
- package/dist/types/excalidraw/components/Island.d.ts +7 -0
- package/dist/types/excalidraw/components/LaserPointerButton.d.ts +2 -4
- package/dist/types/excalidraw/components/LayerUI.d.ts +5 -2
- package/dist/types/excalidraw/components/LibraryMenu.d.ts +1 -1
- package/dist/types/excalidraw/components/LockButton.d.ts +3 -4
- package/dist/types/excalidraw/components/MagicButton.d.ts +0 -2
- package/dist/types/excalidraw/components/MobileMenu.d.ts +4 -4
- package/dist/types/excalidraw/components/MobileToolbar.d.ts +9 -0
- package/dist/types/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.d.ts +1 -1
- package/dist/types/excalidraw/components/PenModeButton.d.ts +2 -5
- package/dist/types/excalidraw/components/Popover.d.ts +1 -3
- package/dist/types/excalidraw/components/{ButtonIcon.d.ts → RadioButton.d.ts} +2 -5
- package/dist/types/excalidraw/components/Range.d.ts +10 -4
- package/dist/types/excalidraw/components/SVGLayer.d.ts +1 -1
- package/dist/types/excalidraw/components/SearchMenu.d.ts +1 -1
- package/dist/types/excalidraw/components/Sidebar/Sidebar.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/Angle.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/Dimension.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/DragInput.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/MultiAngle.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/MultiDimension.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/MultiPosition.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/Position.d.ts +3 -3
- package/dist/types/excalidraw/components/Stats/utils.d.ts +1 -1
- package/dist/types/excalidraw/components/TTDDialog/TTDContext.d.ts +4 -4
- package/dist/types/excalidraw/components/TTDDialog/useTTDChatStorage.d.ts +3 -3
- package/dist/types/excalidraw/components/ToolPopover.d.ts +3 -6
- package/dist/types/excalidraw/components/Toolbar.d.ts +11 -0
- package/dist/types/excalidraw/components/Tools.d.ts +146 -0
- package/dist/types/excalidraw/components/UserList.d.ts +3 -2
- package/dist/types/excalidraw/components/ViewportStatusFrame/ViewportStatusFrame.d.ts +11 -0
- package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +4 -1
- package/dist/types/excalidraw/components/canvases/NewElementCanvas.d.ts +1 -0
- package/dist/types/excalidraw/components/canvases/StaticCanvas.d.ts +1 -1
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemContentRadio.d.ts +2 -1
- package/dist/types/excalidraw/components/footer/Footer.d.ts +3 -1
- package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +2 -2
- package/dist/types/excalidraw/components/icons.d.ts +6 -1
- package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +8 -4
- package/dist/types/excalidraw/components/positionElementBesideCursor.d.ts +26 -0
- package/dist/types/excalidraw/components/shapeActionPredicates.d.ts +39 -0
- package/dist/types/excalidraw/data/blob.d.ts +42 -24
- package/dist/types/excalidraw/data/index.d.ts +4 -4
- package/dist/types/excalidraw/data/json.d.ts +27 -18
- package/dist/types/excalidraw/data/library.d.ts +1 -1
- package/dist/types/excalidraw/drawShapeTrail.d.ts +16 -0
- package/dist/types/excalidraw/eraser/index.d.ts +2 -3
- package/dist/types/excalidraw/fonts/Fonts.d.ts +3 -2
- package/dist/types/excalidraw/hooks/useAppStateValue.d.ts +29 -0
- package/dist/types/excalidraw/hooks/useLibraryItemSvg.d.ts +1 -1
- package/dist/types/excalidraw/hooks/useTextEditorFocus.d.ts +5 -5
- package/dist/types/excalidraw/{laser-trails.d.ts → laserTrails.d.ts} +5 -7
- package/dist/types/excalidraw/lasso/index.d.ts +2 -3
- package/dist/types/excalidraw/lasso/utils.d.ts +2 -0
- package/dist/types/excalidraw/renderer/animation.d.ts +5 -1
- package/dist/types/excalidraw/renderer/helpers.d.ts +7 -0
- package/dist/types/excalidraw/renderer/interactiveScene.d.ts +1 -3
- package/dist/types/excalidraw/scene/Renderer.d.ts +427 -19
- package/dist/types/excalidraw/scene/export.d.ts +3 -3
- package/dist/types/excalidraw/scene/index.d.ts +2 -2
- package/dist/types/excalidraw/scene/types.d.ts +4 -3
- package/dist/types/excalidraw/snapping.d.ts +7 -7
- package/dist/types/excalidraw/textAutoResizeHandle.d.ts +15 -0
- package/dist/types/excalidraw/types.d.ts +436 -24
- package/dist/types/excalidraw/viewport.d.ts +275 -0
- package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +6 -3
- package/dist/types/fractional-indexing/src/index.d.ts +29 -0
- package/dist/types/laser-pointer/src/index.d.ts +2 -0
- package/dist/types/laser-pointer/src/math.d.ts +16 -0
- package/dist/types/laser-pointer/src/simplify.d.ts +2 -0
- package/dist/types/laser-pointer/src/state.d.ts +36 -0
- package/dist/types/math/src/constants.d.ts +0 -1
- package/dist/types/math/src/curve.d.ts +23 -13
- package/dist/types/math/src/index.d.ts +1 -0
- package/dist/types/math/src/pca.d.ts +79 -0
- package/dist/types/math/src/point.d.ts +2 -1
- package/dist/types/math/src/polygon.d.ts +25 -1
- package/dist/types/math/src/segment.d.ts +6 -0
- package/dist/types/utils/src/export.d.ts +3 -3
- package/dist/types/utils/src/index.d.ts +1 -2
- package/package.json +1 -1
- package/dist/types/excalidraw/animation-frame-handler.d.ts +0 -16
- package/dist/types/excalidraw/components/FollowMode/FollowMode.d.ts +0 -10
- package/dist/types/excalidraw/components/HandButton.d.ts +0 -10
- package/dist/types/excalidraw/components/MobileToolBar.d.ts +0 -10
- package/dist/types/excalidraw/components/shapes.d.ts +0 -263
- package/dist/types/excalidraw/cursor.d.ts +0 -5
- package/dist/types/excalidraw/scene/scroll.d.ts +0 -18
- package/dist/types/excalidraw/scene/zoom.d.ts +0 -12
- package/dist/types/utils/src/bbox.d.ts +0 -9
- package/dist/types/utils/src/withinBounds.d.ts +0 -19
package/dist/dev/index.js
CHANGED
|
@@ -1356,6 +1356,8 @@ function validateWCAG2Parms(parms) {
|
|
|
1356
1356
|
import { clamp } from "@excalidraw/math";
|
|
1357
1357
|
import { degreesToRadians } from "@excalidraw/math";
|
|
1358
1358
|
var DARK_MODE_COLORS_CACHE = typeof window !== "undefined" ? /* @__PURE__ */ new Map() : null;
|
|
1359
|
+
var DARK_MODE_FILTER_INVERT_PERCENT = 93;
|
|
1360
|
+
var DARK_MODE_FILTER_HUE_ROTATE_DEGREES = 180;
|
|
1359
1361
|
function cssHueRotate(red, green, blue, degrees) {
|
|
1360
1362
|
const r = red / 255;
|
|
1361
1363
|
const g = green / 255;
|
|
@@ -1394,7 +1396,10 @@ var cssInvert = (r, g, b, percent) => {
|
|
|
1394
1396
|
const invertedB = invertComponent(b);
|
|
1395
1397
|
return { r: invertedR, g: invertedG, b: invertedB };
|
|
1396
1398
|
};
|
|
1397
|
-
var applyDarkModeFilter = (color) => {
|
|
1399
|
+
var applyDarkModeFilter = (color, enable = true) => {
|
|
1400
|
+
if (!enable) {
|
|
1401
|
+
return color;
|
|
1402
|
+
}
|
|
1398
1403
|
const cached = DARK_MODE_COLORS_CACHE?.get(color);
|
|
1399
1404
|
if (cached) {
|
|
1400
1405
|
return cached;
|
|
@@ -1402,12 +1407,17 @@ var applyDarkModeFilter = (color) => {
|
|
|
1402
1407
|
const tc = tinycolor(color);
|
|
1403
1408
|
const alpha = tc.getAlpha();
|
|
1404
1409
|
const rgb = tc.toRgb();
|
|
1405
|
-
const inverted = cssInvert(
|
|
1410
|
+
const inverted = cssInvert(
|
|
1411
|
+
rgb.r,
|
|
1412
|
+
rgb.g,
|
|
1413
|
+
rgb.b,
|
|
1414
|
+
DARK_MODE_FILTER_INVERT_PERCENT
|
|
1415
|
+
);
|
|
1406
1416
|
const rotated = cssHueRotate(
|
|
1407
1417
|
inverted.r,
|
|
1408
1418
|
inverted.g,
|
|
1409
1419
|
inverted.b,
|
|
1410
|
-
|
|
1420
|
+
DARK_MODE_FILTER_HUE_ROTATE_DEGREES
|
|
1411
1421
|
);
|
|
1412
1422
|
const result = rgbToHex2(rotated.r, rotated.g, rotated.b, alpha);
|
|
1413
1423
|
if (DARK_MODE_COLORS_CACHE) {
|
|
@@ -1415,6 +1425,33 @@ var applyDarkModeFilter = (color) => {
|
|
|
1415
1425
|
}
|
|
1416
1426
|
return result;
|
|
1417
1427
|
};
|
|
1428
|
+
var _reverseDarkModeInvert = (r, g, b) => {
|
|
1429
|
+
const p = DARK_MODE_FILTER_INVERT_PERCENT / 100;
|
|
1430
|
+
const denominator = 1 - 2 * p;
|
|
1431
|
+
const restore = (color) => Math.round(clamp((color - 255 * p) / denominator, 0, 255));
|
|
1432
|
+
return {
|
|
1433
|
+
r: restore(r),
|
|
1434
|
+
g: restore(g),
|
|
1435
|
+
b: restore(b)
|
|
1436
|
+
};
|
|
1437
|
+
};
|
|
1438
|
+
var removeDarkModeFilter = (color) => {
|
|
1439
|
+
const tc = tinycolor(color);
|
|
1440
|
+
const alpha = tc.getAlpha();
|
|
1441
|
+
const rgb = tc.toRgb();
|
|
1442
|
+
const rotatedBack = cssHueRotate(
|
|
1443
|
+
rgb.r,
|
|
1444
|
+
rgb.g,
|
|
1445
|
+
rgb.b,
|
|
1446
|
+
DARK_MODE_FILTER_HUE_ROTATE_DEGREES
|
|
1447
|
+
);
|
|
1448
|
+
const restored = _reverseDarkModeInvert(
|
|
1449
|
+
rotatedBack.r,
|
|
1450
|
+
rotatedBack.g,
|
|
1451
|
+
rotatedBack.b
|
|
1452
|
+
);
|
|
1453
|
+
return rgbToHex2(restored.r, restored.g, restored.b, alpha);
|
|
1454
|
+
};
|
|
1418
1455
|
var pick = (source, keys) => {
|
|
1419
1456
|
return keys.reduce((acc, key) => {
|
|
1420
1457
|
if (key in source) {
|
|
@@ -1460,6 +1497,7 @@ var COMMON_ELEMENT_SHADES = pick(COLOR_PALETTE, [
|
|
|
1460
1497
|
"orange",
|
|
1461
1498
|
"red"
|
|
1462
1499
|
]);
|
|
1500
|
+
var COLOR_TOP_PICKS_SLOTS = 5;
|
|
1463
1501
|
var DEFAULT_ELEMENT_STROKE_PICKS = [
|
|
1464
1502
|
COLOR_PALETTE.black,
|
|
1465
1503
|
COLOR_PALETTE.red[DEFAULT_ELEMENT_STROKE_COLOR_INDEX],
|
|
@@ -1474,6 +1512,13 @@ var DEFAULT_ELEMENT_BACKGROUND_PICKS = [
|
|
|
1474
1512
|
COLOR_PALETTE.blue[DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX],
|
|
1475
1513
|
COLOR_PALETTE.yellow[DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX]
|
|
1476
1514
|
];
|
|
1515
|
+
var BUCKET_FILL_BACKGROUND_PICKS = [
|
|
1516
|
+
COLOR_PALETTE.white,
|
|
1517
|
+
COLOR_PALETTE.red[DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX],
|
|
1518
|
+
COLOR_PALETTE.green[DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX],
|
|
1519
|
+
COLOR_PALETTE.blue[DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX],
|
|
1520
|
+
COLOR_PALETTE.yellow[DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX]
|
|
1521
|
+
];
|
|
1477
1522
|
var DEFAULT_CANVAS_BACKGROUND_PICKS = [
|
|
1478
1523
|
COLOR_PALETTE.white,
|
|
1479
1524
|
// radix slate2
|
|
@@ -1525,6 +1570,14 @@ var rgbToHex2 = (r, g, b, a) => {
|
|
|
1525
1570
|
}
|
|
1526
1571
|
return hex6;
|
|
1527
1572
|
};
|
|
1573
|
+
var setColorAlpha = (color, alpha) => {
|
|
1574
|
+
const tc = tinycolor(color);
|
|
1575
|
+
if (!tc.isValid()) {
|
|
1576
|
+
return color;
|
|
1577
|
+
}
|
|
1578
|
+
const { r, g, b } = tc.toRgb();
|
|
1579
|
+
return rgbToHex2(r, g, b, alpha);
|
|
1580
|
+
};
|
|
1528
1581
|
var colorToHex = (color) => {
|
|
1529
1582
|
const tc = tinycolor(color);
|
|
1530
1583
|
if (!tc.isValid()) {
|
|
@@ -1536,6 +1589,9 @@ var colorToHex = (color) => {
|
|
|
1536
1589
|
var isTransparent = (color) => {
|
|
1537
1590
|
return tinycolor(color).getAlpha() === 0;
|
|
1538
1591
|
};
|
|
1592
|
+
var isOpaqueColor = (color) => {
|
|
1593
|
+
return tinycolor(color).getAlpha() === 1;
|
|
1594
|
+
};
|
|
1539
1595
|
var COLOR_OUTLINE_CONTRAST_THRESHOLD = 240;
|
|
1540
1596
|
var calculateContrast = (r, g, b) => {
|
|
1541
1597
|
const yiq = (r * 299 + g * 587 + b * 114) / 1e3;
|
|
@@ -1836,8 +1892,10 @@ var DEFAULT_UI_OPTIONS = {
|
|
|
1836
1892
|
var MAX_DECIMALS_FOR_SVG_EXPORT = 2;
|
|
1837
1893
|
var EXPORT_SCALES = [1, 2, 3];
|
|
1838
1894
|
var DEFAULT_EXPORT_PADDING = 10;
|
|
1839
|
-
var
|
|
1840
|
-
|
|
1895
|
+
var DEFAULT_IMAGE_OPTIONS = {
|
|
1896
|
+
maxWidthOrHeight: 1440,
|
|
1897
|
+
maxFileSizeBytes: 4 * 1024 * 1024
|
|
1898
|
+
};
|
|
1841
1899
|
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
1842
1900
|
var SVG_DOCUMENT_PREAMBLE = `<?xml version="1.0" standalone="no"?>
|
|
1843
1901
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
@@ -1861,6 +1919,7 @@ var TEXT_ALIGN = {
|
|
|
1861
1919
|
RIGHT: "right"
|
|
1862
1920
|
};
|
|
1863
1921
|
var ELEMENT_READY_TO_ERASE_OPACITY = 20;
|
|
1922
|
+
var ELEMENT_PENDING_DRAW_SHAPE_OPACITY = 70;
|
|
1864
1923
|
var DEFAULT_PROPORTIONAL_RADIUS = 0.25;
|
|
1865
1924
|
var DEFAULT_ADAPTIVE_RADIUS = 32;
|
|
1866
1925
|
var ROUNDNESS = {
|
|
@@ -1884,16 +1943,34 @@ var ROUGHNESS = {
|
|
|
1884
1943
|
artist: 1,
|
|
1885
1944
|
cartoonist: 2
|
|
1886
1945
|
};
|
|
1946
|
+
var STROKE_WIDTH_KEYS = [
|
|
1947
|
+
"thin",
|
|
1948
|
+
"medium",
|
|
1949
|
+
"bold"
|
|
1950
|
+
];
|
|
1887
1951
|
var STROKE_WIDTH = {
|
|
1888
1952
|
thin: 1,
|
|
1953
|
+
medium: 2,
|
|
1954
|
+
bold: 4,
|
|
1955
|
+
extraBold: 8
|
|
1956
|
+
// unused (may be introduced in the future)
|
|
1957
|
+
};
|
|
1958
|
+
var FREEDRAW_STROKE_WIDTH = {
|
|
1959
|
+
thin: 0.5,
|
|
1960
|
+
medium: 1,
|
|
1889
1961
|
bold: 2,
|
|
1890
1962
|
extraBold: 4
|
|
1963
|
+
// legacy (may be used again in the future)
|
|
1964
|
+
};
|
|
1965
|
+
var getStrokeWidthByKey = (elementType, strokeWidthKey) => {
|
|
1966
|
+
return elementType === "freedraw" ? FREEDRAW_STROKE_WIDTH[strokeWidthKey] : STROKE_WIDTH[strokeWidthKey];
|
|
1891
1967
|
};
|
|
1968
|
+
var DEFAULT_ELEMENT_STROKE_WIDTH_KEY = "medium";
|
|
1892
1969
|
var DEFAULT_ELEMENT_PROPS = {
|
|
1893
1970
|
strokeColor: COLOR_PALETTE.black,
|
|
1894
1971
|
backgroundColor: COLOR_PALETTE.transparent,
|
|
1895
1972
|
fillStyle: "solid",
|
|
1896
|
-
strokeWidth:
|
|
1973
|
+
strokeWidth: STROKE_WIDTH[DEFAULT_ELEMENT_STROKE_WIDTH_KEY],
|
|
1897
1974
|
strokeStyle: "solid",
|
|
1898
1975
|
roughness: ROUGHNESS.artist,
|
|
1899
1976
|
opacity: 100,
|
|
@@ -1926,7 +2003,9 @@ var TOOL_TYPE = {
|
|
|
1926
2003
|
frame: "frame",
|
|
1927
2004
|
magicframe: "magicframe",
|
|
1928
2005
|
embeddable: "embeddable",
|
|
1929
|
-
laser: "laser"
|
|
2006
|
+
laser: "laser",
|
|
2007
|
+
autoshape: "autoshape",
|
|
2008
|
+
bucketfill: "bucketfill"
|
|
1930
2009
|
};
|
|
1931
2010
|
var EDITOR_LS_KEYS = {
|
|
1932
2011
|
OAI_API_KEY: "excalidraw-oai-api-key",
|
|
@@ -1957,6 +2036,8 @@ var BIND_MODE_TIMEOUT = 700;
|
|
|
1957
2036
|
var MOBILE_ACTION_BUTTON_BG = {
|
|
1958
2037
|
background: "var(--mobile-action-button-bg)"
|
|
1959
2038
|
};
|
|
2039
|
+
var DEFAULT_STROKE_STREAMLINE = 0.5;
|
|
2040
|
+
var DEFAULT_STROKE_STREAMLINE_PRECISE = 0.2;
|
|
1960
2041
|
|
|
1961
2042
|
// src/font-metadata.ts
|
|
1962
2043
|
init_define_import_meta_env();
|
|
@@ -2286,6 +2367,7 @@ var KEYS = {
|
|
|
2286
2367
|
SUBTRACT: "-",
|
|
2287
2368
|
SLASH: "/",
|
|
2288
2369
|
A: "a",
|
|
2370
|
+
B: "b",
|
|
2289
2371
|
C: "c",
|
|
2290
2372
|
D: "d",
|
|
2291
2373
|
E: "e",
|
|
@@ -2337,6 +2419,7 @@ var shouldRotateWithDiscreteAngle = (event) => event.shiftKey;
|
|
|
2337
2419
|
// src/points.ts
|
|
2338
2420
|
init_define_import_meta_env();
|
|
2339
2421
|
import {
|
|
2422
|
+
pointFrom,
|
|
2340
2423
|
pointFromPair
|
|
2341
2424
|
} from "@excalidraw/math";
|
|
2342
2425
|
var getSizeFromPoints = (points) => {
|
|
@@ -2381,12 +2464,12 @@ var rescalePoints = (dimension, newSize, points, normalize) => {
|
|
|
2381
2464
|
};
|
|
2382
2465
|
var getGridPoint = (x, y, gridSize) => {
|
|
2383
2466
|
if (gridSize) {
|
|
2384
|
-
return
|
|
2467
|
+
return pointFrom(
|
|
2385
2468
|
Math.round(x / gridSize) * gridSize,
|
|
2386
2469
|
Math.round(y / gridSize) * gridSize
|
|
2387
|
-
|
|
2470
|
+
);
|
|
2388
2471
|
}
|
|
2389
|
-
return
|
|
2472
|
+
return pointFrom(x, y);
|
|
2390
2473
|
};
|
|
2391
2474
|
|
|
2392
2475
|
// src/promise-pool.ts
|
|
@@ -2477,14 +2560,25 @@ var getDateTime = () => {
|
|
|
2477
2560
|
return `${year}-${month}-${day}-${hr}${min}`;
|
|
2478
2561
|
};
|
|
2479
2562
|
var capitalizeString = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
2480
|
-
var
|
|
2481
|
-
var
|
|
2482
|
-
|
|
2563
|
+
var getTargetWindow = (target) => target?.ownerDocument?.defaultView ?? (typeof window === "undefined" ? null : window);
|
|
2564
|
+
var isToolIcon = (target) => {
|
|
2565
|
+
const targetWindow = getTargetWindow(target);
|
|
2566
|
+
return !!targetWindow && target instanceof targetWindow.HTMLElement && target.className.includes("ToolIcon");
|
|
2567
|
+
};
|
|
2568
|
+
var isInputLike = (target) => {
|
|
2569
|
+
const targetWindow = getTargetWindow(target);
|
|
2570
|
+
return !!targetWindow && (target instanceof targetWindow.HTMLElement && target.dataset.type === "wysiwyg" || target instanceof targetWindow.HTMLBRElement || // newline in wysiwyg
|
|
2571
|
+
target instanceof targetWindow.HTMLInputElement || target instanceof targetWindow.HTMLTextAreaElement || target instanceof targetWindow.HTMLSelectElement);
|
|
2572
|
+
};
|
|
2483
2573
|
var isInteractive = (target) => {
|
|
2484
|
-
|
|
2574
|
+
const targetWindow = getTargetWindow(target);
|
|
2575
|
+
return isInputLike(target) || !!targetWindow && target instanceof targetWindow.Element && !!target.closest("label, button");
|
|
2576
|
+
};
|
|
2577
|
+
var isWritableElement = (target) => {
|
|
2578
|
+
const targetWindow = getTargetWindow(target);
|
|
2579
|
+
return !!targetWindow && (target instanceof targetWindow.HTMLElement && target.dataset.type === "wysiwyg" || target instanceof targetWindow.HTMLBRElement || // newline in wysiwyg
|
|
2580
|
+
target instanceof targetWindow.HTMLTextAreaElement || target instanceof targetWindow.HTMLInputElement && (target.type === "text" || target.type === "number" || target.type === "password" || target.type === "search") || target instanceof targetWindow.HTMLElement && target.closest(".cm-editor") !== null);
|
|
2485
2581
|
};
|
|
2486
|
-
var isWritableElement = (target) => target instanceof HTMLElement && target.dataset.type === "wysiwyg" || target instanceof HTMLBRElement || // newline in wysiwyg
|
|
2487
|
-
target instanceof HTMLTextAreaElement || target instanceof HTMLInputElement && (target.type === "text" || target.type === "number" || target.type === "password" || target.type === "search") || target instanceof HTMLElement && target.closest(".cm-editor") !== null;
|
|
2488
2582
|
var getFontFamilyString = ({
|
|
2489
2583
|
fontFamily
|
|
2490
2584
|
}) => {
|
|
@@ -2570,67 +2664,6 @@ var throttleRAF = (fn) => {
|
|
|
2570
2664
|
var easeOut = (k) => {
|
|
2571
2665
|
return 1 - Math.pow(1 - k, 4);
|
|
2572
2666
|
};
|
|
2573
|
-
var easeOutInterpolate = (from, to, progress) => {
|
|
2574
|
-
return (to - from) * easeOut(progress) + from;
|
|
2575
|
-
};
|
|
2576
|
-
var easeToValuesRAF = ({
|
|
2577
|
-
fromValues,
|
|
2578
|
-
toValues,
|
|
2579
|
-
onStep,
|
|
2580
|
-
duration = 250,
|
|
2581
|
-
interpolateValue,
|
|
2582
|
-
onStart,
|
|
2583
|
-
onEnd,
|
|
2584
|
-
onCancel
|
|
2585
|
-
}) => {
|
|
2586
|
-
let canceled = false;
|
|
2587
|
-
let frameId = 0;
|
|
2588
|
-
let startTime;
|
|
2589
|
-
function step(timestamp) {
|
|
2590
|
-
if (canceled) {
|
|
2591
|
-
return;
|
|
2592
|
-
}
|
|
2593
|
-
if (startTime === void 0) {
|
|
2594
|
-
startTime = timestamp;
|
|
2595
|
-
onStart?.();
|
|
2596
|
-
}
|
|
2597
|
-
const elapsed = Math.min(timestamp - startTime, duration);
|
|
2598
|
-
const factor = easeOut(elapsed / duration);
|
|
2599
|
-
const newValues = {};
|
|
2600
|
-
Object.keys(fromValues).forEach((key) => {
|
|
2601
|
-
const _key = key;
|
|
2602
|
-
const result = (toValues[_key] - fromValues[_key]) * factor + fromValues[_key];
|
|
2603
|
-
newValues[_key] = result;
|
|
2604
|
-
});
|
|
2605
|
-
onStep(newValues);
|
|
2606
|
-
if (elapsed < duration) {
|
|
2607
|
-
const progress = elapsed / duration;
|
|
2608
|
-
const newValues2 = {};
|
|
2609
|
-
Object.keys(fromValues).forEach((key) => {
|
|
2610
|
-
const _key = key;
|
|
2611
|
-
const startValue = fromValues[_key];
|
|
2612
|
-
const endValue = toValues[_key];
|
|
2613
|
-
let result;
|
|
2614
|
-
result = interpolateValue ? interpolateValue(startValue, endValue, progress, _key) : easeOutInterpolate(startValue, endValue, progress);
|
|
2615
|
-
if (result == null) {
|
|
2616
|
-
result = easeOutInterpolate(startValue, endValue, progress);
|
|
2617
|
-
}
|
|
2618
|
-
newValues2[_key] = result;
|
|
2619
|
-
});
|
|
2620
|
-
onStep(newValues2);
|
|
2621
|
-
frameId = window.requestAnimationFrame(step);
|
|
2622
|
-
} else {
|
|
2623
|
-
onStep(toValues);
|
|
2624
|
-
onEnd?.();
|
|
2625
|
-
}
|
|
2626
|
-
}
|
|
2627
|
-
frameId = window.requestAnimationFrame(step);
|
|
2628
|
-
return () => {
|
|
2629
|
-
onCancel?.();
|
|
2630
|
-
canceled = true;
|
|
2631
|
-
window.cancelAnimationFrame(frameId);
|
|
2632
|
-
};
|
|
2633
|
-
};
|
|
2634
2667
|
var chunk = (array, size) => {
|
|
2635
2668
|
if (!array.length || size < 1) {
|
|
2636
2669
|
return [];
|
|
@@ -2673,7 +2706,7 @@ var updateActiveTool = (appState, data) => {
|
|
|
2673
2706
|
}
|
|
2674
2707
|
return {
|
|
2675
2708
|
...appState.activeTool,
|
|
2676
|
-
lastActiveTool: data.
|
|
2709
|
+
lastActiveTool: data.lastActiveTool === void 0 ? appState.activeTool.lastActiveTool : data.lastActiveTool,
|
|
2677
2710
|
type: data.type,
|
|
2678
2711
|
customType: null,
|
|
2679
2712
|
locked: data.locked ?? appState.activeTool.locked,
|
|
@@ -2800,19 +2833,21 @@ var supportsEmoji = () => {
|
|
|
2800
2833
|
return ctx.getImageData(offset, offset, 1, 1).data[0] !== 0;
|
|
2801
2834
|
};
|
|
2802
2835
|
var getNearestScrollableContainer = (element) => {
|
|
2836
|
+
const ownerDocument = element.ownerDocument;
|
|
2837
|
+
const ownerWindow = ownerDocument.defaultView ?? window;
|
|
2803
2838
|
let parent = element.parentElement;
|
|
2804
2839
|
while (parent) {
|
|
2805
|
-
if (parent ===
|
|
2806
|
-
return
|
|
2840
|
+
if (parent === ownerDocument.body) {
|
|
2841
|
+
return ownerDocument;
|
|
2807
2842
|
}
|
|
2808
|
-
const { overflowY } =
|
|
2843
|
+
const { overflowY } = ownerWindow.getComputedStyle(parent);
|
|
2809
2844
|
const hasScrollableContent = parent.scrollHeight > parent.clientHeight;
|
|
2810
2845
|
if (hasScrollableContent && (overflowY === "auto" || overflowY === "scroll" || overflowY === "overlay")) {
|
|
2811
2846
|
return parent;
|
|
2812
2847
|
}
|
|
2813
2848
|
parent = parent.parentElement;
|
|
2814
2849
|
}
|
|
2815
|
-
return
|
|
2850
|
+
return ownerDocument;
|
|
2816
2851
|
};
|
|
2817
2852
|
var focusNearestParent = (element) => {
|
|
2818
2853
|
let parent = element.parentElement;
|
|
@@ -3528,6 +3563,7 @@ export {
|
|
|
3528
3563
|
AppEventBus,
|
|
3529
3564
|
BIND_MODE_TIMEOUT,
|
|
3530
3565
|
BOUND_TEXT_PADDING,
|
|
3566
|
+
BUCKET_FILL_BACKGROUND_PICKS,
|
|
3531
3567
|
BinaryHeap,
|
|
3532
3568
|
CANVAS_ONLY_ACTIONS,
|
|
3533
3569
|
CANVAS_SEARCH_TAB,
|
|
@@ -3538,6 +3574,7 @@ export {
|
|
|
3538
3574
|
COLOR_CHARCOAL_BLACK,
|
|
3539
3575
|
COLOR_OUTLINE_CONTRAST_THRESHOLD,
|
|
3540
3576
|
COLOR_PALETTE,
|
|
3577
|
+
COLOR_TOP_PICKS_SLOTS,
|
|
3541
3578
|
COLOR_VOICE_CALL,
|
|
3542
3579
|
COLOR_WHITE,
|
|
3543
3580
|
CURSOR_TYPE,
|
|
@@ -3553,17 +3590,20 @@ export {
|
|
|
3553
3590
|
DEFAULT_ELEMENT_STROKE_COLOR_INDEX,
|
|
3554
3591
|
DEFAULT_ELEMENT_STROKE_COLOR_PALETTE,
|
|
3555
3592
|
DEFAULT_ELEMENT_STROKE_PICKS,
|
|
3593
|
+
DEFAULT_ELEMENT_STROKE_WIDTH_KEY,
|
|
3556
3594
|
DEFAULT_EXPORT_PADDING,
|
|
3557
3595
|
DEFAULT_FILENAME,
|
|
3558
3596
|
DEFAULT_FONT_FAMILY,
|
|
3559
3597
|
DEFAULT_FONT_SIZE,
|
|
3560
3598
|
DEFAULT_GRID_SIZE,
|
|
3561
3599
|
DEFAULT_GRID_STEP,
|
|
3600
|
+
DEFAULT_IMAGE_OPTIONS,
|
|
3562
3601
|
DEFAULT_LASER_COLOR,
|
|
3563
|
-
DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT,
|
|
3564
3602
|
DEFAULT_PROPORTIONAL_RADIUS,
|
|
3565
3603
|
DEFAULT_REDUCED_GLOBAL_ALPHA,
|
|
3566
3604
|
DEFAULT_SIDEBAR,
|
|
3605
|
+
DEFAULT_STROKE_STREAMLINE,
|
|
3606
|
+
DEFAULT_STROKE_STREAMLINE_PRECISE,
|
|
3567
3607
|
DEFAULT_TEXT_ALIGN,
|
|
3568
3608
|
DEFAULT_TRANSFORM_HANDLE_SPACING,
|
|
3569
3609
|
DEFAULT_UI_OPTIONS,
|
|
@@ -3574,6 +3614,7 @@ export {
|
|
|
3574
3614
|
Debug,
|
|
3575
3615
|
EDITOR_LS_KEYS,
|
|
3576
3616
|
ELEMENT_LINK_KEY,
|
|
3617
|
+
ELEMENT_PENDING_DRAW_SHAPE_OPACITY,
|
|
3577
3618
|
ELEMENT_READY_TO_ERASE_OPACITY,
|
|
3578
3619
|
ELEMENT_SHIFT_TRANSLATE_AMOUNT,
|
|
3579
3620
|
ELEMENT_TRANSLATE_AMOUNT,
|
|
@@ -3591,6 +3632,7 @@ export {
|
|
|
3591
3632
|
FONT_METADATA,
|
|
3592
3633
|
FONT_SIZES,
|
|
3593
3634
|
FRAME_STYLE,
|
|
3635
|
+
FREEDRAW_STROKE_WIDTH,
|
|
3594
3636
|
GOOGLE_FONTS_RANGES,
|
|
3595
3637
|
HYPERLINK_TOOLTIP_DELAY,
|
|
3596
3638
|
IDLE_THRESHOLD,
|
|
@@ -3603,7 +3645,6 @@ export {
|
|
|
3603
3645
|
LINE_CONFIRM_THRESHOLD,
|
|
3604
3646
|
LINE_POLYGON_POINT_MERGE_DISTANCE,
|
|
3605
3647
|
LOCAL_FONT_PROTOCOL,
|
|
3606
|
-
MAX_ALLOWED_FILE_BYTES,
|
|
3607
3648
|
MAX_CUSTOM_COLORS_USED_IN_CANVAS,
|
|
3608
3649
|
MAX_DECIMALS_FOR_SVG_EXPORT,
|
|
3609
3650
|
MAX_ZOOM,
|
|
@@ -3635,6 +3676,7 @@ export {
|
|
|
3635
3676
|
STATS_PANELS,
|
|
3636
3677
|
STRING_MIME_TYPES,
|
|
3637
3678
|
STROKE_WIDTH,
|
|
3679
|
+
STROKE_WIDTH_KEYS,
|
|
3638
3680
|
SVG_DOCUMENT_PREAMBLE,
|
|
3639
3681
|
SVG_NS,
|
|
3640
3682
|
TAP_TWICE_TIMEOUT,
|
|
@@ -3675,7 +3717,6 @@ export {
|
|
|
3675
3717
|
deriveStylesPanelMode,
|
|
3676
3718
|
distance,
|
|
3677
3719
|
easeOut,
|
|
3678
|
-
easeToValuesRAF,
|
|
3679
3720
|
escapeDoubleQuotes,
|
|
3680
3721
|
exitFullScreen,
|
|
3681
3722
|
findIndex,
|
|
@@ -3696,6 +3737,7 @@ export {
|
|
|
3696
3737
|
getLineHeight,
|
|
3697
3738
|
getNearestScrollableContainer,
|
|
3698
3739
|
getSizeFromPoints,
|
|
3740
|
+
getStrokeWidthByKey,
|
|
3699
3741
|
getSvgPathFromStroke,
|
|
3700
3742
|
getUpdatedTimestamp,
|
|
3701
3743
|
getVersion,
|
|
@@ -3719,6 +3761,7 @@ export {
|
|
|
3719
3761
|
isLocalLink,
|
|
3720
3762
|
isMemberOf,
|
|
3721
3763
|
isMobileBreakpoint,
|
|
3764
|
+
isOpaqueColor,
|
|
3722
3765
|
isPrimitive,
|
|
3723
3766
|
isProdEnv,
|
|
3724
3767
|
isPromiseLike,
|
|
@@ -3752,6 +3795,7 @@ export {
|
|
|
3752
3795
|
randomId,
|
|
3753
3796
|
randomInteger,
|
|
3754
3797
|
reduceToCommonValue,
|
|
3798
|
+
removeDarkModeFilter,
|
|
3755
3799
|
removeSelection,
|
|
3756
3800
|
rescalePoints,
|
|
3757
3801
|
reseed,
|
|
@@ -3760,6 +3804,7 @@ export {
|
|
|
3760
3804
|
safelyParseJSON,
|
|
3761
3805
|
sceneCoordsToViewportCoords,
|
|
3762
3806
|
selectNode,
|
|
3807
|
+
setColorAlpha,
|
|
3763
3808
|
setDateTimeForTests,
|
|
3764
3809
|
setDesktopUIMode,
|
|
3765
3810
|
setFeatureFlag,
|