@excalidraw/common 0.18.0-abeeaeb → 0.18.0-afa3a65
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 +91 -10
- package/dist/dev/index.js.map +2 -2
- package/dist/prod/index.js +3 -3
- package/dist/types/common/src/colors.d.ts +8 -0
- package/dist/types/common/src/constants.d.ts +44 -0
- package/dist/types/common/src/keys.d.ts +2 -0
- package/dist/types/common/src/random.d.ts +7 -0
- package/dist/types/element/src/Scene.d.ts +1 -1
- package/dist/types/element/src/comparisons.d.ts +5 -3
- package/dist/types/element/src/delta.d.ts +23 -1
- package/dist/types/element/src/flowchart.d.ts +5 -1
- package/dist/types/element/src/frame.d.ts +2 -2
- package/dist/types/element/src/index.d.ts +1 -0
- package/dist/types/element/src/linearElementEditor.d.ts +10 -0
- package/dist/types/element/src/mutateElement.d.ts +1 -1
- package/dist/types/element/src/newElement.d.ts +24 -2
- package/dist/types/element/src/sizeHelpers.d.ts +6 -0
- package/dist/types/element/src/stickyNote.d.ts +183 -0
- package/dist/types/element/src/textElement.d.ts +2 -1
- package/dist/types/element/src/transform.d.ts +25 -6
- package/dist/types/element/src/typeChecks.d.ts +3 -2
- package/dist/types/element/src/types.d.ts +35 -6
- package/dist/types/element/src/utils.d.ts +7 -3
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +12 -0
- package/dist/types/excalidraw/actions/actionAlign.d.ts +6 -6
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +8 -0
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +28 -0
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +8 -0
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +4 -0
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +13 -1
- package/dist/types/excalidraw/actions/actionDeselect.d.ts +4 -0
- package/dist/types/excalidraw/actions/actionDistribute.d.ts +2 -2
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +4 -0
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +8 -0
- package/dist/types/excalidraw/actions/actionExport.d.ts +8 -0
- package/dist/types/excalidraw/actions/actionFinalize.d.ts +1 -0
- package/dist/types/excalidraw/actions/actionFrame.d.ts +63 -1
- package/dist/types/excalidraw/actions/actionGroup.d.ts +8 -0
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +55 -1
- package/dist/types/excalidraw/actions/actionLink.d.ts +4 -0
- package/dist/types/excalidraw/actions/actionMenu.d.ts +4 -0
- package/dist/types/excalidraw/actions/actionProperties.d.ts +18 -6
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +4 -0
- package/dist/types/excalidraw/actions/actionStyles.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +4 -0
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +4 -0
- package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +4 -0
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +4 -0
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +4 -0
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +4 -0
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +4 -0
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +4 -0
- package/dist/types/excalidraw/actions/colorTargets.d.ts +39 -0
- package/dist/types/excalidraw/appState.d.ts +4 -0
- package/dist/types/excalidraw/components/App.arrowText.d.ts +40 -8
- package/dist/types/excalidraw/components/App.cursor.d.ts +8 -0
- package/dist/types/excalidraw/components/App.d.ts +92 -6
- package/dist/types/excalidraw/components/App.toolDrag.d.ts +63 -0
- package/dist/types/excalidraw/components/IconButton.d.ts +2 -0
- package/dist/types/excalidraw/components/Tools.d.ts +7 -2
- package/dist/types/excalidraw/components/canvases/NewElementCanvas.d.ts +2 -0
- package/dist/types/excalidraw/components/icons.d.ts +1 -0
- package/dist/types/excalidraw/components/shapeActionPredicates.d.ts +2 -2
- package/dist/types/excalidraw/data/blob.d.ts +8 -0
- package/dist/types/excalidraw/data/json.d.ts +4 -0
- package/dist/types/excalidraw/fonts/Fonts.d.ts +3 -2
- package/dist/types/excalidraw/hooks/useTextEditorFocus.d.ts +5 -5
- package/dist/types/excalidraw/renderer/helpers.d.ts +25 -0
- package/dist/types/excalidraw/renderer/interactiveScene.d.ts +1 -1
- package/dist/types/excalidraw/scene/Renderer.d.ts +50 -1
- package/dist/types/excalidraw/scene/index.d.ts +1 -1
- package/dist/types/excalidraw/scene/types.d.ts +1 -0
- package/dist/types/excalidraw/types.d.ts +30 -2
- package/dist/types/excalidraw/viewport.d.ts +4 -0
- package/dist/types/math/src/curve.d.ts +19 -12
- package/dist/types/math/src/segment.d.ts +6 -0
- package/dist/types/utils/src/export.d.ts +1 -0
- package/dist/types/utils/src/shape.d.ts +2 -2
- package/package.json +1 -1
package/dist/dev/index.js
CHANGED
|
@@ -1519,6 +1519,15 @@ var BUCKET_FILL_BACKGROUND_PICKS = [
|
|
|
1519
1519
|
COLOR_PALETTE.blue[DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX],
|
|
1520
1520
|
COLOR_PALETTE.yellow[DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX]
|
|
1521
1521
|
];
|
|
1522
|
+
var DEFAULT_STICKY_NOTE_BG = "#ffdf6b";
|
|
1523
|
+
var STICKY_NOTE_STROKE_PICKS = DEFAULT_ELEMENT_STROKE_PICKS;
|
|
1524
|
+
var STICKY_NOTE_BACKGROUND_PICKS = [
|
|
1525
|
+
DEFAULT_STICKY_NOTE_BG,
|
|
1526
|
+
COLOR_PALETTE.pink[1],
|
|
1527
|
+
COLOR_PALETTE.green[1],
|
|
1528
|
+
COLOR_PALETTE.blue[1],
|
|
1529
|
+
COLOR_PALETTE.orange[1]
|
|
1530
|
+
];
|
|
1522
1531
|
var DEFAULT_CANVAS_BACKGROUND_PICKS = [
|
|
1523
1532
|
COLOR_PALETTE.white,
|
|
1524
1533
|
// radix slate2
|
|
@@ -1570,6 +1579,14 @@ var rgbToHex2 = (r, g, b, a) => {
|
|
|
1570
1579
|
}
|
|
1571
1580
|
return hex6;
|
|
1572
1581
|
};
|
|
1582
|
+
var setColorAlpha = (color, alpha) => {
|
|
1583
|
+
const tc = tinycolor(color);
|
|
1584
|
+
if (!tc.isValid()) {
|
|
1585
|
+
return color;
|
|
1586
|
+
}
|
|
1587
|
+
const { r, g, b } = tc.toRgb();
|
|
1588
|
+
return rgbToHex2(r, g, b, alpha);
|
|
1589
|
+
};
|
|
1573
1590
|
var colorToHex = (color) => {
|
|
1574
1591
|
const tc = tinycolor(color);
|
|
1575
1592
|
if (!tc.isValid()) {
|
|
@@ -1674,6 +1691,7 @@ var EVENT = /* @__PURE__ */ ((EVENT2) => {
|
|
|
1674
1691
|
EVENT2["POINTER_MOVE"] = "pointermove";
|
|
1675
1692
|
EVENT2["POINTER_DOWN"] = "pointerdown";
|
|
1676
1693
|
EVENT2["POINTER_UP"] = "pointerup";
|
|
1694
|
+
EVENT2["POINTER_CANCEL"] = "pointercancel";
|
|
1677
1695
|
EVENT2["STATE_CHANGE"] = "statechange";
|
|
1678
1696
|
EVENT2["WHEEL"] = "wheel";
|
|
1679
1697
|
EVENT2["TOUCH_START"] = "touchstart";
|
|
@@ -1785,6 +1803,26 @@ var FRAME_STYLE = {
|
|
|
1785
1803
|
};
|
|
1786
1804
|
var MIN_FONT_SIZE = 1;
|
|
1787
1805
|
var DEFAULT_FONT_SIZE = 20;
|
|
1806
|
+
var STICKY_NOTE_MIN_FONT_SIZE = 16;
|
|
1807
|
+
var STICKY_NOTE_MAX_FONT_SIZE = 512;
|
|
1808
|
+
var STICKY_NOTE_FALLBACK_FONT_SIZE = 28;
|
|
1809
|
+
var STICKY_NOTE_FONT_STEP = 2;
|
|
1810
|
+
var STICKY_NOTE_PADDING = 16;
|
|
1811
|
+
var STICKY_NOTE_FOOTER = {
|
|
1812
|
+
height: 20,
|
|
1813
|
+
fontSize: 12,
|
|
1814
|
+
fontFamily: "Helvetica, Arial, sans-serif",
|
|
1815
|
+
baselineFromBottom: 14,
|
|
1816
|
+
opacity: 1,
|
|
1817
|
+
minBodyWidthForYear: 80
|
|
1818
|
+
};
|
|
1819
|
+
var STICKY_NOTE_BODY_INSET_Y = STICKY_NOTE_PADDING * 2 + STICKY_NOTE_FOOTER.height;
|
|
1820
|
+
var DEFAULT_STICKY_NOTE_SIZE = 250;
|
|
1821
|
+
var STICKY_NOTE_MIN_SIZE = 75;
|
|
1822
|
+
var STICKY_NOTE_SHADOW_OFFSET = 3;
|
|
1823
|
+
var STICKY_NOTE_SHADOW_OPACITY = 0.16;
|
|
1824
|
+
var STICKY_NOTE_EDGE_SHADOW_WIDTH = 0.5;
|
|
1825
|
+
var STICKY_NOTE_EDGE_SHADOW_OPACITY = 0.08;
|
|
1788
1826
|
var DEFAULT_FONT_FAMILY = FONT_FAMILY.Excalifont;
|
|
1789
1827
|
var DEFAULT_TEXT_ALIGN = "left";
|
|
1790
1828
|
var DEFAULT_VERTICAL_ALIGN = "top";
|
|
@@ -1994,6 +2032,7 @@ var TOOL_TYPE = {
|
|
|
1994
2032
|
hand: "hand",
|
|
1995
2033
|
frame: "frame",
|
|
1996
2034
|
magicframe: "magicframe",
|
|
2035
|
+
stickynote: "stickynote",
|
|
1997
2036
|
embeddable: "embeddable",
|
|
1998
2037
|
laser: "laser",
|
|
1999
2038
|
autoshape: "autoshape",
|
|
@@ -2368,6 +2407,7 @@ var KEYS = {
|
|
|
2368
2407
|
H: "h",
|
|
2369
2408
|
I: "i",
|
|
2370
2409
|
L: "l",
|
|
2410
|
+
N: "n",
|
|
2371
2411
|
O: "o",
|
|
2372
2412
|
P: "p",
|
|
2373
2413
|
Q: "q",
|
|
@@ -2552,14 +2592,25 @@ var getDateTime = () => {
|
|
|
2552
2592
|
return `${year}-${month}-${day}-${hr}${min}`;
|
|
2553
2593
|
};
|
|
2554
2594
|
var capitalizeString = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
2555
|
-
var
|
|
2556
|
-
var
|
|
2557
|
-
|
|
2595
|
+
var getTargetWindow = (target) => target?.ownerDocument?.defaultView ?? (typeof window === "undefined" ? null : window);
|
|
2596
|
+
var isToolIcon = (target) => {
|
|
2597
|
+
const targetWindow = getTargetWindow(target);
|
|
2598
|
+
return !!targetWindow && target instanceof targetWindow.HTMLElement && target.className.includes("ToolIcon");
|
|
2599
|
+
};
|
|
2600
|
+
var isInputLike = (target) => {
|
|
2601
|
+
const targetWindow = getTargetWindow(target);
|
|
2602
|
+
return !!targetWindow && (target instanceof targetWindow.HTMLElement && target.dataset.type === "wysiwyg" || target instanceof targetWindow.HTMLBRElement || // newline in wysiwyg
|
|
2603
|
+
target instanceof targetWindow.HTMLInputElement || target instanceof targetWindow.HTMLTextAreaElement || target instanceof targetWindow.HTMLSelectElement);
|
|
2604
|
+
};
|
|
2558
2605
|
var isInteractive = (target) => {
|
|
2559
|
-
|
|
2606
|
+
const targetWindow = getTargetWindow(target);
|
|
2607
|
+
return isInputLike(target) || !!targetWindow && target instanceof targetWindow.Element && !!target.closest("label, button");
|
|
2608
|
+
};
|
|
2609
|
+
var isWritableElement = (target) => {
|
|
2610
|
+
const targetWindow = getTargetWindow(target);
|
|
2611
|
+
return !!targetWindow && (target instanceof targetWindow.HTMLElement && target.dataset.type === "wysiwyg" || target instanceof targetWindow.HTMLBRElement || // newline in wysiwyg
|
|
2612
|
+
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);
|
|
2560
2613
|
};
|
|
2561
|
-
var isWritableElement = (target) => target instanceof HTMLElement && target.dataset.type === "wysiwyg" || target instanceof HTMLBRElement || // newline in wysiwyg
|
|
2562
|
-
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;
|
|
2563
2614
|
var getFontFamilyString = ({
|
|
2564
2615
|
fontFamily
|
|
2565
2616
|
}) => {
|
|
@@ -2814,19 +2865,21 @@ var supportsEmoji = () => {
|
|
|
2814
2865
|
return ctx.getImageData(offset, offset, 1, 1).data[0] !== 0;
|
|
2815
2866
|
};
|
|
2816
2867
|
var getNearestScrollableContainer = (element) => {
|
|
2868
|
+
const ownerDocument = element.ownerDocument;
|
|
2869
|
+
const ownerWindow = ownerDocument.defaultView ?? window;
|
|
2817
2870
|
let parent = element.parentElement;
|
|
2818
2871
|
while (parent) {
|
|
2819
|
-
if (parent ===
|
|
2820
|
-
return
|
|
2872
|
+
if (parent === ownerDocument.body) {
|
|
2873
|
+
return ownerDocument;
|
|
2821
2874
|
}
|
|
2822
|
-
const { overflowY } =
|
|
2875
|
+
const { overflowY } = ownerWindow.getComputedStyle(parent);
|
|
2823
2876
|
const hasScrollableContent = parent.scrollHeight > parent.clientHeight;
|
|
2824
2877
|
if (hasScrollableContent && (overflowY === "auto" || overflowY === "scroll" || overflowY === "overlay")) {
|
|
2825
2878
|
return parent;
|
|
2826
2879
|
}
|
|
2827
2880
|
parent = parent.parentElement;
|
|
2828
2881
|
}
|
|
2829
|
-
return
|
|
2882
|
+
return ownerDocument;
|
|
2830
2883
|
};
|
|
2831
2884
|
var focusNearestParent = (element) => {
|
|
2832
2885
|
let parent = element.parentElement;
|
|
@@ -3177,6 +3230,16 @@ var reseed = (seed) => {
|
|
|
3177
3230
|
testIdBase = 0;
|
|
3178
3231
|
};
|
|
3179
3232
|
var randomId = () => isTestEnv() ? `id${testIdBase++}` : nanoid();
|
|
3233
|
+
var seededRandom = (seed) => {
|
|
3234
|
+
let value = seed >>> 0;
|
|
3235
|
+
return () => {
|
|
3236
|
+
value += 1831565813;
|
|
3237
|
+
let next = value;
|
|
3238
|
+
next = Math.imul(next ^ next >>> 15, next | 1);
|
|
3239
|
+
next ^= next + Math.imul(next ^ next >>> 7, next | 61);
|
|
3240
|
+
return ((next ^ next >>> 14) >>> 0) / 4294967296;
|
|
3241
|
+
};
|
|
3242
|
+
};
|
|
3180
3243
|
|
|
3181
3244
|
// src/url.ts
|
|
3182
3245
|
init_define_import_meta_env();
|
|
@@ -3581,6 +3644,8 @@ export {
|
|
|
3581
3644
|
DEFAULT_PROPORTIONAL_RADIUS,
|
|
3582
3645
|
DEFAULT_REDUCED_GLOBAL_ALPHA,
|
|
3583
3646
|
DEFAULT_SIDEBAR,
|
|
3647
|
+
DEFAULT_STICKY_NOTE_BG,
|
|
3648
|
+
DEFAULT_STICKY_NOTE_SIZE,
|
|
3584
3649
|
DEFAULT_STROKE_STREAMLINE,
|
|
3585
3650
|
DEFAULT_STROKE_STREAMLINE_PRECISE,
|
|
3586
3651
|
DEFAULT_TEXT_ALIGN,
|
|
@@ -3653,6 +3718,20 @@ export {
|
|
|
3653
3718
|
SHIFT_LOCKING_ANGLE,
|
|
3654
3719
|
SIDE_RESIZING_THRESHOLD,
|
|
3655
3720
|
STATS_PANELS,
|
|
3721
|
+
STICKY_NOTE_BACKGROUND_PICKS,
|
|
3722
|
+
STICKY_NOTE_BODY_INSET_Y,
|
|
3723
|
+
STICKY_NOTE_EDGE_SHADOW_OPACITY,
|
|
3724
|
+
STICKY_NOTE_EDGE_SHADOW_WIDTH,
|
|
3725
|
+
STICKY_NOTE_FALLBACK_FONT_SIZE,
|
|
3726
|
+
STICKY_NOTE_FONT_STEP,
|
|
3727
|
+
STICKY_NOTE_FOOTER,
|
|
3728
|
+
STICKY_NOTE_MAX_FONT_SIZE,
|
|
3729
|
+
STICKY_NOTE_MIN_FONT_SIZE,
|
|
3730
|
+
STICKY_NOTE_MIN_SIZE,
|
|
3731
|
+
STICKY_NOTE_PADDING,
|
|
3732
|
+
STICKY_NOTE_SHADOW_OFFSET,
|
|
3733
|
+
STICKY_NOTE_SHADOW_OPACITY,
|
|
3734
|
+
STICKY_NOTE_STROKE_PICKS,
|
|
3656
3735
|
STRING_MIME_TYPES,
|
|
3657
3736
|
STROKE_WIDTH,
|
|
3658
3737
|
STROKE_WIDTH_KEYS,
|
|
@@ -3782,7 +3861,9 @@ export {
|
|
|
3782
3861
|
rgbToHex2 as rgbToHex,
|
|
3783
3862
|
safelyParseJSON,
|
|
3784
3863
|
sceneCoordsToViewportCoords,
|
|
3864
|
+
seededRandom,
|
|
3785
3865
|
selectNode,
|
|
3866
|
+
setColorAlpha,
|
|
3786
3867
|
setDateTimeForTests,
|
|
3787
3868
|
setDesktopUIMode,
|
|
3788
3869
|
setFeatureFlag,
|