@dwelle/excalidraw 0.5.0-2aec728 → 0.5.0-2dbdd6f
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/{chunk-M4JV7MPJ.js → chunk-EWKWI3K7.js} +12 -4
- package/dist/dev/chunk-EWKWI3K7.js.map +7 -0
- package/dist/dev/{chunk-K532CM3P.js → chunk-JBODKHIT.js} +420 -153
- package/dist/dev/chunk-JBODKHIT.js.map +7 -0
- package/dist/dev/{chunk-M2XQF7GS.js → chunk-NYLL7DNJ.js} +2 -2
- package/dist/dev/components/TTDDialog/CodeMirrorEditor-PY5ZVWKQ.js +259 -0
- package/dist/dev/components/TTDDialog/CodeMirrorEditor-PY5ZVWKQ.js.map +7 -0
- package/dist/dev/data/{image-2KXEDCIH.js → image-WSL7K3G4.js} +3 -3
- package/dist/dev/index.css +99 -22
- package/dist/dev/index.css.map +2 -2
- package/dist/dev/index.js +1469 -408
- package/dist/dev/index.js.map +4 -4
- package/dist/dev/locales/{en-RZ6RNZOE.js → en-A3UOWEYW.js} +2 -2
- package/dist/dev/subset-shared.chunk.js +1 -1
- package/dist/dev/subset-worker.chunk.js +1 -1
- package/dist/prod/chunk-33L4EPXN.js +34 -0
- package/dist/prod/{chunk-GYMRTBHM.js → chunk-DF5Y7EC7.js} +5 -5
- package/dist/prod/{chunk-V7CARC7D.js → chunk-ZV7TQH6J.js} +1 -1
- package/dist/prod/components/TTDDialog/CodeMirrorEditor-M5ZUJBXD.js +1 -0
- package/dist/prod/data/image-57VVPCM3.js +1 -0
- package/dist/prod/index.css +1 -1
- package/dist/prod/index.js +32 -24
- package/dist/prod/locales/{en-XBJ4S4YK.js → en-QI57FMQH.js} +1 -1
- package/dist/prod/subset-shared.chunk.js +1 -1
- package/dist/prod/subset-worker.chunk.js +1 -1
- package/dist/types/element/src/arrowheads.d.ts +3 -0
- package/dist/types/element/src/bounds.d.ts +1 -1
- package/dist/types/element/src/index.d.ts +1 -0
- package/dist/types/element/src/linearElementEditor.d.ts +2 -2
- package/dist/types/element/src/selection.d.ts +5 -1
- package/dist/types/element/src/shape.d.ts +1 -1
- package/dist/types/element/src/textElement.d.ts +1 -1
- package/dist/types/element/src/textWrapping.d.ts +26 -0
- package/dist/types/element/src/types.d.ts +4 -1
- package/dist/types/element/src/utils.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +3 -3
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +3 -3
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +10 -10
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +2 -2
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +3 -3
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +2 -2
- package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionExport.d.ts +5 -4
- package/dist/types/excalidraw/actions/actionFrame.d.ts +4 -4
- package/dist/types/excalidraw/actions/actionGroup.d.ts +3 -3
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionLink.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionMenu.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionProperties.d.ts +4 -4
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionStyles.d.ts +2 -1
- package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +3 -3
- package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +1 -1
- package/dist/types/excalidraw/components/App.d.ts +11 -0
- package/dist/types/excalidraw/components/IconPicker.d.ts +14 -9
- package/dist/types/excalidraw/components/Range.d.ts +10 -4
- package/dist/types/excalidraw/components/TTDDialog/CodeMirrorEditor.d.ts +11 -0
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogInput.d.ts +3 -3
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +4 -1
- package/dist/types/excalidraw/components/TTDDialog/mermaid-lang-lite.d.ts +2 -0
- package/dist/types/excalidraw/components/TTDDialog/utils/mermaidAutoFix.d.ts +1 -0
- package/dist/types/excalidraw/components/TTDDialog/utils/mermaidError.d.ts +10 -0
- package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +1 -0
- package/dist/types/excalidraw/components/icons.d.ts +17 -8
- package/dist/types/excalidraw/data/blob.d.ts +2 -2
- package/dist/types/excalidraw/data/json.d.ts +1 -1
- package/dist/types/excalidraw/textAutoResizeHandle.d.ts +15 -0
- package/dist/types/excalidraw/types.d.ts +3 -2
- package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +5 -1
- package/dist/types/math/src/point.d.ts +1 -1
- package/package.json +7 -2
- package/dist/dev/chunk-K532CM3P.js.map +0 -7
- package/dist/dev/chunk-M4JV7MPJ.js.map +0 -7
- package/dist/prod/chunk-FARSR7T2.js +0 -33
- package/dist/prod/data/image-P4TPEGR7.js +0 -1
- /package/dist/dev/{chunk-M2XQF7GS.js.map → chunk-NYLL7DNJ.js.map} +0 -0
- /package/dist/dev/data/{image-2KXEDCIH.js.map → image-WSL7K3G4.js.map} +0 -0
- /package/dist/dev/locales/{en-RZ6RNZOE.js.map → en-A3UOWEYW.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
define_import_meta_env_default
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-NYLL7DNJ.js";
|
|
4
4
|
import {
|
|
5
5
|
__publicField
|
|
6
6
|
} from "./chunk-XDFCUUT6.js";
|
|
@@ -212,7 +212,12 @@ function pointsEqual(a, b, tolerance = PRECISION) {
|
|
|
212
212
|
const abs = Math.abs;
|
|
213
213
|
return abs(a[0] - b[0]) < tolerance && abs(a[1] - b[1]) < tolerance;
|
|
214
214
|
}
|
|
215
|
-
function pointRotateRads(
|
|
215
|
+
function pointRotateRads(point, center, angle) {
|
|
216
|
+
if (!angle) {
|
|
217
|
+
return point;
|
|
218
|
+
}
|
|
219
|
+
const [x, y] = point;
|
|
220
|
+
const [cx, cy] = center;
|
|
216
221
|
return pointFrom(
|
|
217
222
|
(x - cx) * Math.cos(angle) - (y - cy) * Math.sin(angle) + cx,
|
|
218
223
|
(x - cx) * Math.sin(angle) + (y - cy) * Math.cos(angle) + cy
|
|
@@ -1796,7 +1801,7 @@ var isInteractive = (target) => {
|
|
|
1796
1801
|
return isInputLike(target) || target instanceof Element && !!target.closest("label, button");
|
|
1797
1802
|
};
|
|
1798
1803
|
var isWritableElement = (target) => target instanceof HTMLElement && target.dataset.type === "wysiwyg" || target instanceof HTMLBRElement || // newline in wysiwyg
|
|
1799
|
-
target instanceof HTMLTextAreaElement || target instanceof HTMLInputElement && (target.type === "text" || target.type === "number" || target.type === "password" || target.type === "search");
|
|
1804
|
+
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;
|
|
1800
1805
|
var getFontFamilyString = ({
|
|
1801
1806
|
fontFamily
|
|
1802
1807
|
}) => {
|
|
@@ -3753,12 +3758,12 @@ var setElementShapesCacheEntry = (element, shape, offset) => {
|
|
|
3753
3758
|
}
|
|
3754
3759
|
shapes.set(offset, shape);
|
|
3755
3760
|
};
|
|
3756
|
-
function deconstructLinearOrFreeDrawElement(element) {
|
|
3761
|
+
function deconstructLinearOrFreeDrawElement(element, elementsMap) {
|
|
3757
3762
|
const cachedShape = getElementShapesCacheEntry(element, 0);
|
|
3758
3763
|
if (cachedShape) {
|
|
3759
3764
|
return cachedShape;
|
|
3760
3765
|
}
|
|
3761
|
-
const ops = generateLinearCollisionShape(element);
|
|
3766
|
+
const ops = generateLinearCollisionShape(element, elementsMap);
|
|
3762
3767
|
const lines = [];
|
|
3763
3768
|
const curves = [];
|
|
3764
3769
|
for (let idx = 0; idx < ops.length; idx += 1) {
|
|
@@ -4626,91 +4631,168 @@ var parseTokens = (line2) => {
|
|
|
4626
4631
|
return line2.normalize("NFC").split(breakLineRegex).filter(Boolean);
|
|
4627
4632
|
};
|
|
4628
4633
|
var wrapText = (text, font, maxWidth) => {
|
|
4634
|
+
return getWrappedTextLines(text, font, maxWidth).map((line2) => line2.text).join("\n");
|
|
4635
|
+
};
|
|
4636
|
+
var getHardLineBreaks = (text) => {
|
|
4637
|
+
let offset = 0;
|
|
4638
|
+
return text.split("\n").map((line2) => {
|
|
4639
|
+
const start = offset;
|
|
4640
|
+
const end = start + line2.length;
|
|
4641
|
+
offset = end + 1;
|
|
4642
|
+
return {
|
|
4643
|
+
text: line2,
|
|
4644
|
+
start,
|
|
4645
|
+
end
|
|
4646
|
+
};
|
|
4647
|
+
});
|
|
4648
|
+
};
|
|
4649
|
+
var getWrappedTextLines = (text, font, maxWidth) => {
|
|
4629
4650
|
if (!Number.isFinite(maxWidth) || maxWidth < 0) {
|
|
4630
|
-
return text;
|
|
4651
|
+
return getHardLineBreaks(text);
|
|
4631
4652
|
}
|
|
4632
4653
|
const lines = [];
|
|
4633
|
-
|
|
4634
|
-
for (const originalLine of
|
|
4635
|
-
const
|
|
4636
|
-
if (
|
|
4637
|
-
lines.push(
|
|
4638
|
-
|
|
4654
|
+
let offset = 0;
|
|
4655
|
+
for (const originalLine of text.split("\n")) {
|
|
4656
|
+
const originalLineWidth = getLineWidth(originalLine, font);
|
|
4657
|
+
if (originalLineWidth <= maxWidth) {
|
|
4658
|
+
lines.push({
|
|
4659
|
+
text: originalLine,
|
|
4660
|
+
start: offset,
|
|
4661
|
+
end: offset + originalLine.length
|
|
4662
|
+
});
|
|
4663
|
+
} else {
|
|
4664
|
+
lines.push(...wrapLine(originalLine, font, maxWidth, offset));
|
|
4639
4665
|
}
|
|
4640
|
-
|
|
4641
|
-
lines.push(...wrappedLine);
|
|
4666
|
+
offset += originalLine.length + 1;
|
|
4642
4667
|
}
|
|
4643
|
-
return lines
|
|
4668
|
+
return lines;
|
|
4644
4669
|
};
|
|
4645
|
-
var wrapLine = (line2, font, maxWidth) => {
|
|
4670
|
+
var wrapLine = (line2, font, maxWidth, lineStart) => {
|
|
4646
4671
|
const lines = [];
|
|
4647
4672
|
const tokens = parseTokens(line2);
|
|
4648
|
-
const tokenIterator = tokens[Symbol.iterator]();
|
|
4649
4673
|
let currentLine = "";
|
|
4674
|
+
let currentLineStart = lineStart;
|
|
4675
|
+
let currentLineEnd = lineStart;
|
|
4650
4676
|
let currentLineWidth = 0;
|
|
4651
|
-
let
|
|
4652
|
-
|
|
4653
|
-
|
|
4677
|
+
let tokenOffset = lineStart;
|
|
4678
|
+
let tokenIndex = 0;
|
|
4679
|
+
while (tokenIndex < tokens.length) {
|
|
4680
|
+
const token = tokens[tokenIndex];
|
|
4681
|
+
const tokenStart = tokenOffset;
|
|
4682
|
+
const tokenEnd = tokenStart + token.length;
|
|
4654
4683
|
const testLine = currentLine + token;
|
|
4655
4684
|
const testLineWidth = isSingleCharacter(token) ? currentLineWidth + charWidth.calculate(token, font) : getLineWidth(testLine, font);
|
|
4656
4685
|
if (/\s/.test(token) || testLineWidth <= maxWidth) {
|
|
4686
|
+
if (!currentLine) {
|
|
4687
|
+
currentLineStart = tokenStart;
|
|
4688
|
+
}
|
|
4657
4689
|
currentLine = testLine;
|
|
4690
|
+
currentLineEnd = tokenEnd;
|
|
4658
4691
|
currentLineWidth = testLineWidth;
|
|
4659
|
-
|
|
4692
|
+
tokenOffset = tokenEnd;
|
|
4693
|
+
tokenIndex++;
|
|
4660
4694
|
continue;
|
|
4661
4695
|
}
|
|
4662
4696
|
if (!currentLine) {
|
|
4663
|
-
const wrappedWord = wrapWord(token, font, maxWidth);
|
|
4664
|
-
const trailingLine = wrappedWord[wrappedWord.length - 1] ??
|
|
4697
|
+
const wrappedWord = wrapWord(token, font, maxWidth, tokenStart);
|
|
4698
|
+
const trailingLine = wrappedWord[wrappedWord.length - 1] ?? {
|
|
4699
|
+
text: "",
|
|
4700
|
+
start: tokenStart,
|
|
4701
|
+
end: tokenStart
|
|
4702
|
+
};
|
|
4665
4703
|
const precedingLines = wrappedWord.slice(0, -1);
|
|
4666
4704
|
lines.push(...precedingLines);
|
|
4667
|
-
currentLine = trailingLine;
|
|
4668
|
-
|
|
4669
|
-
|
|
4705
|
+
currentLine = trailingLine.text;
|
|
4706
|
+
currentLineStart = trailingLine.start;
|
|
4707
|
+
currentLineEnd = trailingLine.end;
|
|
4708
|
+
currentLineWidth = getLineWidth(trailingLine.text, font);
|
|
4709
|
+
tokenOffset = tokenEnd;
|
|
4710
|
+
tokenIndex++;
|
|
4670
4711
|
} else {
|
|
4671
|
-
lines.push(
|
|
4712
|
+
lines.push(
|
|
4713
|
+
trimLineEndAtSoftBreak(currentLine, currentLineStart, currentLineEnd)
|
|
4714
|
+
);
|
|
4672
4715
|
currentLine = "";
|
|
4716
|
+
currentLineStart = tokenStart;
|
|
4717
|
+
currentLineEnd = tokenStart;
|
|
4673
4718
|
currentLineWidth = 0;
|
|
4674
4719
|
}
|
|
4675
4720
|
}
|
|
4676
4721
|
if (currentLine) {
|
|
4677
|
-
const trailingLine = trimLine(
|
|
4722
|
+
const trailingLine = trimLine(
|
|
4723
|
+
currentLine,
|
|
4724
|
+
currentLineStart,
|
|
4725
|
+
currentLineEnd,
|
|
4726
|
+
font,
|
|
4727
|
+
maxWidth
|
|
4728
|
+
);
|
|
4678
4729
|
lines.push(trailingLine);
|
|
4679
4730
|
}
|
|
4680
4731
|
return lines;
|
|
4681
4732
|
};
|
|
4682
|
-
var wrapWord = (word, font, maxWidth) => {
|
|
4733
|
+
var wrapWord = (word, font, maxWidth, wordStart) => {
|
|
4683
4734
|
if (getEmojiRegex().test(word)) {
|
|
4684
|
-
return [
|
|
4735
|
+
return [
|
|
4736
|
+
{
|
|
4737
|
+
text: word,
|
|
4738
|
+
start: wordStart,
|
|
4739
|
+
end: wordStart + word.length
|
|
4740
|
+
}
|
|
4741
|
+
];
|
|
4685
4742
|
}
|
|
4686
4743
|
satisfiesWordInvariant(word);
|
|
4687
4744
|
const lines = [];
|
|
4688
4745
|
const chars = Array.from(word);
|
|
4689
4746
|
let currentLine = "";
|
|
4747
|
+
let currentLineStart = wordStart;
|
|
4748
|
+
let currentLineEnd = wordStart;
|
|
4690
4749
|
let currentLineWidth = 0;
|
|
4750
|
+
let offset = wordStart;
|
|
4691
4751
|
for (const char of chars) {
|
|
4752
|
+
const charStart = offset;
|
|
4753
|
+
const charEnd = charStart + char.length;
|
|
4692
4754
|
const _charWidth = charWidth.calculate(char, font);
|
|
4693
4755
|
const testLineWidth = currentLineWidth + _charWidth;
|
|
4694
4756
|
if (testLineWidth <= maxWidth) {
|
|
4757
|
+
if (!currentLine) {
|
|
4758
|
+
currentLineStart = charStart;
|
|
4759
|
+
}
|
|
4695
4760
|
currentLine = currentLine + char;
|
|
4761
|
+
currentLineEnd = charEnd;
|
|
4696
4762
|
currentLineWidth = testLineWidth;
|
|
4763
|
+
offset = charEnd;
|
|
4697
4764
|
continue;
|
|
4698
4765
|
}
|
|
4699
4766
|
if (currentLine) {
|
|
4700
|
-
lines.push(
|
|
4767
|
+
lines.push({
|
|
4768
|
+
text: currentLine,
|
|
4769
|
+
start: currentLineStart,
|
|
4770
|
+
end: currentLineEnd
|
|
4771
|
+
});
|
|
4701
4772
|
}
|
|
4702
4773
|
currentLine = char;
|
|
4774
|
+
currentLineStart = charStart;
|
|
4775
|
+
currentLineEnd = charEnd;
|
|
4703
4776
|
currentLineWidth = _charWidth;
|
|
4777
|
+
offset = charEnd;
|
|
4704
4778
|
}
|
|
4705
4779
|
if (currentLine) {
|
|
4706
|
-
lines.push(
|
|
4780
|
+
lines.push({
|
|
4781
|
+
text: currentLine,
|
|
4782
|
+
start: currentLineStart,
|
|
4783
|
+
end: currentLineEnd
|
|
4784
|
+
});
|
|
4707
4785
|
}
|
|
4708
4786
|
return lines;
|
|
4709
4787
|
};
|
|
4710
|
-
var trimLine = (line2, font, maxWidth) => {
|
|
4788
|
+
var trimLine = (line2, start, end, font, maxWidth) => {
|
|
4711
4789
|
const shouldTrimWhitespaces = getLineWidth(line2, font) > maxWidth;
|
|
4712
4790
|
if (!shouldTrimWhitespaces) {
|
|
4713
|
-
return
|
|
4791
|
+
return {
|
|
4792
|
+
text: line2,
|
|
4793
|
+
start,
|
|
4794
|
+
end
|
|
4795
|
+
};
|
|
4714
4796
|
}
|
|
4715
4797
|
let [, trimmedLine, whitespaces] = line2.match(/^(.+?)(\s+)$/) ?? [
|
|
4716
4798
|
line2,
|
|
@@ -4727,7 +4809,19 @@ var trimLine = (line2, font, maxWidth) => {
|
|
|
4727
4809
|
trimmedLine = trimmedLine + whitespace;
|
|
4728
4810
|
trimmedLineWidth = testLineWidth;
|
|
4729
4811
|
}
|
|
4730
|
-
return
|
|
4812
|
+
return {
|
|
4813
|
+
text: trimmedLine,
|
|
4814
|
+
start,
|
|
4815
|
+
end: end - (line2.length - trimmedLine.length)
|
|
4816
|
+
};
|
|
4817
|
+
};
|
|
4818
|
+
var trimLineEndAtSoftBreak = (line2, start, end) => {
|
|
4819
|
+
const trimmedLine = line2.trimEnd();
|
|
4820
|
+
return {
|
|
4821
|
+
text: trimmedLine,
|
|
4822
|
+
start,
|
|
4823
|
+
end: end - (line2.length - trimmedLine.length)
|
|
4824
|
+
};
|
|
4731
4825
|
};
|
|
4732
4826
|
var isSingleCharacter = (maybeSingleCharacter) => {
|
|
4733
4827
|
return maybeSingleCharacter.codePointAt(0) !== void 0 && maybeSingleCharacter.codePointAt(1) === void 0;
|
|
@@ -4966,7 +5060,8 @@ var getContainerCenter = (container, appState, elementsMap) => {
|
|
|
4966
5060
|
if (!midSegmentMidpoint) {
|
|
4967
5061
|
midSegmentMidpoint = LinearElementEditor.getSegmentMidPoint(
|
|
4968
5062
|
container,
|
|
4969
|
-
index + 1
|
|
5063
|
+
index + 1,
|
|
5064
|
+
elementsMap
|
|
4970
5065
|
);
|
|
4971
5066
|
}
|
|
4972
5067
|
return { x: midSegmentMidpoint[0], y: midSegmentMidpoint[1] };
|
|
@@ -5101,7 +5196,7 @@ var distanceToElement = (element, elementsMap, p) => {
|
|
|
5101
5196
|
case "line":
|
|
5102
5197
|
case "arrow":
|
|
5103
5198
|
case "freedraw":
|
|
5104
|
-
return distanceToLinearOrFreeDraElement(element, p);
|
|
5199
|
+
return distanceToLinearOrFreeDraElement(element, elementsMap, p);
|
|
5105
5200
|
}
|
|
5106
5201
|
};
|
|
5107
5202
|
var distanceToRectanguloidElement = (element, elementsMap, p) => {
|
|
@@ -5130,8 +5225,11 @@ var distanceToEllipseElement = (element, elementsMap, p) => {
|
|
|
5130
5225
|
ellipse(center, element.width / 2, element.height / 2)
|
|
5131
5226
|
);
|
|
5132
5227
|
};
|
|
5133
|
-
var distanceToLinearOrFreeDraElement = (element, p) => {
|
|
5134
|
-
const [lines, curves] = deconstructLinearOrFreeDrawElement(
|
|
5228
|
+
var distanceToLinearOrFreeDraElement = (element, elementsMap, p) => {
|
|
5229
|
+
const [lines, curves] = deconstructLinearOrFreeDrawElement(
|
|
5230
|
+
element,
|
|
5231
|
+
elementsMap
|
|
5232
|
+
);
|
|
5135
5233
|
return Math.min(
|
|
5136
5234
|
...lines.map((s) => distanceToLineSegment(p, s)),
|
|
5137
5235
|
...curves.map((a) => curvePointDistance(a, p))
|
|
@@ -5370,7 +5468,12 @@ var intersectElementWithLineSegment = (element, elementsMap, line2, offset = 0,
|
|
|
5370
5468
|
case "line":
|
|
5371
5469
|
case "freedraw":
|
|
5372
5470
|
case "arrow":
|
|
5373
|
-
return intersectLinearOrFreeDrawWithLineSegment(
|
|
5471
|
+
return intersectLinearOrFreeDrawWithLineSegment(
|
|
5472
|
+
element,
|
|
5473
|
+
line2,
|
|
5474
|
+
elementsMap,
|
|
5475
|
+
onlyFirst
|
|
5476
|
+
);
|
|
5374
5477
|
}
|
|
5375
5478
|
};
|
|
5376
5479
|
var curveIntersections = (curves, segment, intersections, center, angle, onlyFirst = false) => {
|
|
@@ -5409,8 +5512,11 @@ var lineIntersections = (lines, segment, intersections, center, angle, onlyFirst
|
|
|
5409
5512
|
}
|
|
5410
5513
|
return intersections;
|
|
5411
5514
|
};
|
|
5412
|
-
var intersectLinearOrFreeDrawWithLineSegment = (element, segment, onlyFirst = false) => {
|
|
5413
|
-
const [lines, curves] = deconstructLinearOrFreeDrawElement(
|
|
5515
|
+
var intersectLinearOrFreeDrawWithLineSegment = (element, segment, elementsMap, onlyFirst = false) => {
|
|
5516
|
+
const [lines, curves] = deconstructLinearOrFreeDrawElement(
|
|
5517
|
+
element,
|
|
5518
|
+
elementsMap
|
|
5519
|
+
);
|
|
5414
5520
|
const intersections = [];
|
|
5415
5521
|
for (const l of lines) {
|
|
5416
5522
|
const intersection = lineSegmentIntersectionPoints(l, segment);
|
|
@@ -9324,7 +9430,7 @@ var _LinearElementEditor = class _LinearElementEditor {
|
|
|
9324
9430
|
}
|
|
9325
9431
|
};
|
|
9326
9432
|
}
|
|
9327
|
-
static isSegmentTooShort(element, startPoint, endPoint, index, zoom) {
|
|
9433
|
+
static isSegmentTooShort(element, startPoint, endPoint, index, zoom, elementsMap) {
|
|
9328
9434
|
if (isElbowArrow(element)) {
|
|
9329
9435
|
if (index >= 0 && index < element.points.length) {
|
|
9330
9436
|
return pointDistance(startPoint, endPoint) * zoom.value < _LinearElementEditor.POINT_HANDLE_SIZE / 2;
|
|
@@ -9333,7 +9439,10 @@ var _LinearElementEditor = class _LinearElementEditor {
|
|
|
9333
9439
|
}
|
|
9334
9440
|
let distance2 = pointDistance(startPoint, endPoint);
|
|
9335
9441
|
if (element.points.length > 2 && element.roundness) {
|
|
9336
|
-
const [lines, curves] = deconstructLinearOrFreeDrawElement(
|
|
9442
|
+
const [lines, curves] = deconstructLinearOrFreeDrawElement(
|
|
9443
|
+
element,
|
|
9444
|
+
elementsMap
|
|
9445
|
+
);
|
|
9337
9446
|
invariant(
|
|
9338
9447
|
lines.length === 0 && curves.length > 0,
|
|
9339
9448
|
"Only linears built out of curves are supported"
|
|
@@ -9346,7 +9455,7 @@ var _LinearElementEditor = class _LinearElementEditor {
|
|
|
9346
9455
|
}
|
|
9347
9456
|
return distance2 * zoom.value < _LinearElementEditor.POINT_HANDLE_SIZE * 4;
|
|
9348
9457
|
}
|
|
9349
|
-
static getSegmentMidPoint(element, index) {
|
|
9458
|
+
static getSegmentMidPoint(element, index, elementsMap) {
|
|
9350
9459
|
if (isElbowArrow(element)) {
|
|
9351
9460
|
invariant(
|
|
9352
9461
|
element.points.length >= index,
|
|
@@ -9355,7 +9464,10 @@ var _LinearElementEditor = class _LinearElementEditor {
|
|
|
9355
9464
|
const p = pointCenter(element.points[index - 1], element.points[index]);
|
|
9356
9465
|
return pointFrom(element.x + p[0], element.y + p[1]);
|
|
9357
9466
|
}
|
|
9358
|
-
const [lines, curves] = deconstructLinearOrFreeDrawElement(
|
|
9467
|
+
const [lines, curves] = deconstructLinearOrFreeDrawElement(
|
|
9468
|
+
element,
|
|
9469
|
+
elementsMap
|
|
9470
|
+
);
|
|
9359
9471
|
invariant(
|
|
9360
9472
|
lines.length === 0 && curves.length > 0 || lines.length > 0 && curves.length === 0,
|
|
9361
9473
|
"Only linears built out of either segments or curves are supported"
|
|
@@ -10055,7 +10167,8 @@ __publicField(_LinearElementEditor, "getEditorMidPoints", (element, elementsMap,
|
|
|
10055
10167
|
element.points[index],
|
|
10056
10168
|
element.points[index + 1],
|
|
10057
10169
|
index,
|
|
10058
|
-
appState.zoom
|
|
10170
|
+
appState.zoom,
|
|
10171
|
+
elementsMap
|
|
10059
10172
|
)) {
|
|
10060
10173
|
midpoints.push(null);
|
|
10061
10174
|
index++;
|
|
@@ -10063,7 +10176,8 @@ __publicField(_LinearElementEditor, "getEditorMidPoints", (element, elementsMap,
|
|
|
10063
10176
|
}
|
|
10064
10177
|
const segmentMidPoint = _LinearElementEditor.getSegmentMidPoint(
|
|
10065
10178
|
element,
|
|
10066
|
-
index + 1
|
|
10179
|
+
index + 1,
|
|
10180
|
+
elementsMap
|
|
10067
10181
|
);
|
|
10068
10182
|
midpoints.push(segmentMidPoint);
|
|
10069
10183
|
index++;
|
|
@@ -10150,7 +10264,8 @@ __publicField(_LinearElementEditor, "getBoundTextElementPosition", (element, bou
|
|
|
10150
10264
|
const index = element.points.length / 2 - 1;
|
|
10151
10265
|
const midSegmentMidpoint = _LinearElementEditor.getSegmentMidPoint(
|
|
10152
10266
|
element,
|
|
10153
|
-
index + 1
|
|
10267
|
+
index + 1,
|
|
10268
|
+
elementsMap
|
|
10154
10269
|
);
|
|
10155
10270
|
x = midSegmentMidpoint[0] - boundTextElement.width / 2;
|
|
10156
10271
|
y = midSegmentMidpoint[1] - boundTextElement.height / 2;
|
|
@@ -10465,7 +10580,7 @@ var pointDraggingUpdates = (selectedPointsIndices, deltaX, deltaY, scenePointerX
|
|
|
10465
10580
|
nextArrow.endBinding.elementId
|
|
10466
10581
|
) : null;
|
|
10467
10582
|
const endLocalPoint = startIsDraggingOverEndElement ? nextArrow.points[nextArrow.points.length - 1] : endIsDraggingOverStartElement && app.state.bindMode !== "inside" && getFeatureFlag("COMPLEX_BINDINGS") ? nextArrow.points[0] : endBindable ? updateBoundPoint(
|
|
10468
|
-
|
|
10583
|
+
nextArrow,
|
|
10469
10584
|
"endBinding",
|
|
10470
10585
|
nextArrow.endBinding,
|
|
10471
10586
|
endBindable,
|
|
@@ -10477,7 +10592,7 @@ var pointDraggingUpdates = (selectedPointsIndices, deltaX, deltaY, scenePointerX
|
|
|
10477
10592
|
nextArrow.startBinding.elementId
|
|
10478
10593
|
) : null;
|
|
10479
10594
|
const startLocalPoint = endIsDraggingOverStartElement && getFeatureFlag("COMPLEX_BINDINGS") ? nextArrow.points[0] : startIsDraggingOverEndElement && app.state.bindMode !== "inside" && getFeatureFlag("COMPLEX_BINDINGS") ? endLocalPoint : startBindable ? updateBoundPoint(
|
|
10480
|
-
|
|
10595
|
+
nextArrow,
|
|
10481
10596
|
"startBinding",
|
|
10482
10597
|
nextArrow.startBinding,
|
|
10483
10598
|
startBindable,
|
|
@@ -11097,6 +11212,10 @@ var getSelectionStateForElements = (targetElements, allElements, appState) => {
|
|
|
11097
11212
|
)
|
|
11098
11213
|
};
|
|
11099
11214
|
};
|
|
11215
|
+
var getActiveTextElement = (selectedElements, appState) => {
|
|
11216
|
+
const activeTextElement = appState.editingTextElement || selectedElements.length === 1 && isTextElement(selectedElements[0]) && selectedElements[0];
|
|
11217
|
+
return activeTextElement || null;
|
|
11218
|
+
};
|
|
11100
11219
|
|
|
11101
11220
|
// ../element/src/frame.ts
|
|
11102
11221
|
var bindElementsToFramesAfterDuplication = (nextElements, origElements, origIdToDuplicateId) => {
|
|
@@ -12410,45 +12529,88 @@ var modifyIframeLikeForRoughOptions = (element, isExporting, embedsValidationSta
|
|
|
12410
12529
|
}
|
|
12411
12530
|
return element;
|
|
12412
12531
|
};
|
|
12413
|
-
var
|
|
12414
|
-
canvasBackgroundColor = canvasBackgroundColor || "transparent";
|
|
12415
|
-
const arrowheadPoints = getArrowheadPoints(
|
|
12416
|
-
element,
|
|
12417
|
-
shape,
|
|
12418
|
-
position,
|
|
12419
|
-
arrowhead
|
|
12420
|
-
);
|
|
12532
|
+
var generateArrowheadCardinalityOne = (generator, arrowheadPoints, lineOptions) => {
|
|
12421
12533
|
if (arrowheadPoints === null) {
|
|
12422
12534
|
return [];
|
|
12423
12535
|
}
|
|
12424
|
-
const
|
|
12425
|
-
|
|
12426
|
-
|
|
12427
|
-
|
|
12428
|
-
|
|
12429
|
-
return [
|
|
12536
|
+
const [, , x3, y3, x4, y4] = arrowheadPoints;
|
|
12537
|
+
return [generator.line(x3, y3, x4, y4, lineOptions)];
|
|
12538
|
+
};
|
|
12539
|
+
var generateArrowheadLinesToTip = (generator, arrowheadPoints, lineOptions) => {
|
|
12540
|
+
if (arrowheadPoints === null) {
|
|
12541
|
+
return [];
|
|
12542
|
+
}
|
|
12543
|
+
const [x2, y2, x3, y3, x4, y4] = arrowheadPoints;
|
|
12544
|
+
return [
|
|
12545
|
+
generator.line(x3, y3, x2, y2, lineOptions),
|
|
12546
|
+
generator.line(x4, y4, x2, y2, lineOptions)
|
|
12547
|
+
];
|
|
12548
|
+
};
|
|
12549
|
+
var getArrowheadLineOptions = (element, options) => {
|
|
12550
|
+
const lineOptions = { ...options };
|
|
12551
|
+
if (element.strokeStyle === "dotted") {
|
|
12552
|
+
const dash = getDashArrayDotted(element.strokeWidth - 1);
|
|
12553
|
+
lineOptions.strokeLineDash = [dash[0], dash[1] - 1];
|
|
12554
|
+
} else {
|
|
12555
|
+
delete lineOptions.strokeLineDash;
|
|
12556
|
+
}
|
|
12557
|
+
lineOptions.roughness = Math.min(1, lineOptions.roughness || 0);
|
|
12558
|
+
return lineOptions;
|
|
12559
|
+
};
|
|
12560
|
+
var generateArrowheadOutlineCircle = (generator, options, strokeColor, arrowheadPoints, fill, diameterScale = 1) => {
|
|
12561
|
+
if (arrowheadPoints === null) {
|
|
12562
|
+
return [];
|
|
12563
|
+
}
|
|
12564
|
+
const [x, y, diameter] = arrowheadPoints;
|
|
12565
|
+
const circleOptions = {
|
|
12566
|
+
...options,
|
|
12567
|
+
fill,
|
|
12568
|
+
fillStyle: "solid",
|
|
12569
|
+
stroke: strokeColor,
|
|
12570
|
+
roughness: Math.min(0.5, options.roughness || 0)
|
|
12430
12571
|
};
|
|
12572
|
+
delete circleOptions.strokeLineDash;
|
|
12573
|
+
return [generator.circle(x, y, diameter * diameterScale, circleOptions)];
|
|
12574
|
+
};
|
|
12575
|
+
var getArrowheadShapes = (element, shape, position, arrowhead, generator, options, canvasBackgroundColor, isDarkMode) => {
|
|
12576
|
+
canvasBackgroundColor = canvasBackgroundColor || "transparent";
|
|
12577
|
+
if (arrowhead === null) {
|
|
12578
|
+
return [];
|
|
12579
|
+
}
|
|
12431
12580
|
const strokeColor = isDarkMode ? applyDarkModeFilter(element.strokeColor) : element.strokeColor;
|
|
12581
|
+
const backgroundFillColor = isDarkMode ? applyDarkModeFilter(canvasBackgroundColor) : canvasBackgroundColor;
|
|
12582
|
+
const cardinalityOneOrManyOffset = -0.25;
|
|
12583
|
+
const cardinalityZeroCircleScale = 0.8;
|
|
12432
12584
|
switch (arrowhead) {
|
|
12433
|
-
case "dot":
|
|
12434
12585
|
case "circle":
|
|
12435
12586
|
case "circle_outline": {
|
|
12436
|
-
|
|
12437
|
-
|
|
12438
|
-
|
|
12439
|
-
|
|
12440
|
-
|
|
12441
|
-
|
|
12442
|
-
|
|
12443
|
-
stroke: strokeColor,
|
|
12444
|
-
roughness: Math.min(0.5, options.roughness || 0)
|
|
12445
|
-
})
|
|
12446
|
-
];
|
|
12587
|
+
return generateArrowheadOutlineCircle(
|
|
12588
|
+
generator,
|
|
12589
|
+
options,
|
|
12590
|
+
strokeColor,
|
|
12591
|
+
getArrowheadPoints(element, shape, position, arrowhead),
|
|
12592
|
+
arrowhead === "circle_outline" ? backgroundFillColor : strokeColor
|
|
12593
|
+
);
|
|
12447
12594
|
}
|
|
12448
12595
|
case "triangle":
|
|
12449
12596
|
case "triangle_outline": {
|
|
12597
|
+
const arrowheadPoints = getArrowheadPoints(
|
|
12598
|
+
element,
|
|
12599
|
+
shape,
|
|
12600
|
+
position,
|
|
12601
|
+
arrowhead
|
|
12602
|
+
);
|
|
12603
|
+
if (arrowheadPoints === null) {
|
|
12604
|
+
return [];
|
|
12605
|
+
}
|
|
12450
12606
|
const [x, y, x2, y2, x3, y3] = arrowheadPoints;
|
|
12451
|
-
|
|
12607
|
+
const triangleOptions = {
|
|
12608
|
+
...options,
|
|
12609
|
+
fill: arrowhead === "triangle_outline" ? backgroundFillColor : strokeColor,
|
|
12610
|
+
fillStyle: "solid",
|
|
12611
|
+
roughness: Math.min(1, options.roughness || 0)
|
|
12612
|
+
};
|
|
12613
|
+
delete triangleOptions.strokeLineDash;
|
|
12452
12614
|
return [
|
|
12453
12615
|
generator.polygon(
|
|
12454
12616
|
[
|
|
@@ -12457,19 +12619,29 @@ var getArrowheadShapes = (element, shape, position, arrowhead, generator, option
|
|
|
12457
12619
|
[x3, y3],
|
|
12458
12620
|
[x, y]
|
|
12459
12621
|
],
|
|
12460
|
-
|
|
12461
|
-
...options,
|
|
12462
|
-
fill: arrowhead === "triangle_outline" ? canvasBackgroundColor : strokeColor,
|
|
12463
|
-
fillStyle: "solid",
|
|
12464
|
-
roughness: Math.min(1, options.roughness || 0)
|
|
12465
|
-
}
|
|
12622
|
+
triangleOptions
|
|
12466
12623
|
)
|
|
12467
12624
|
];
|
|
12468
12625
|
}
|
|
12469
12626
|
case "diamond":
|
|
12470
12627
|
case "diamond_outline": {
|
|
12628
|
+
const arrowheadPoints = getArrowheadPoints(
|
|
12629
|
+
element,
|
|
12630
|
+
shape,
|
|
12631
|
+
position,
|
|
12632
|
+
arrowhead
|
|
12633
|
+
);
|
|
12634
|
+
if (arrowheadPoints === null) {
|
|
12635
|
+
return [];
|
|
12636
|
+
}
|
|
12471
12637
|
const [x, y, x2, y2, x3, y3, x4, y4] = arrowheadPoints;
|
|
12472
|
-
|
|
12638
|
+
const diamondOptions = {
|
|
12639
|
+
...options,
|
|
12640
|
+
fill: arrowhead === "diamond_outline" ? backgroundFillColor : strokeColor,
|
|
12641
|
+
fillStyle: "solid",
|
|
12642
|
+
roughness: Math.min(1, options.roughness || 0)
|
|
12643
|
+
};
|
|
12644
|
+
delete diamondOptions.strokeLineDash;
|
|
12473
12645
|
return [
|
|
12474
12646
|
generator.polygon(
|
|
12475
12647
|
[
|
|
@@ -12479,42 +12651,106 @@ var getArrowheadShapes = (element, shape, position, arrowhead, generator, option
|
|
|
12479
12651
|
[x4, y4],
|
|
12480
12652
|
[x, y]
|
|
12481
12653
|
],
|
|
12482
|
-
|
|
12483
|
-
|
|
12484
|
-
|
|
12485
|
-
|
|
12486
|
-
|
|
12487
|
-
|
|
12654
|
+
diamondOptions
|
|
12655
|
+
)
|
|
12656
|
+
];
|
|
12657
|
+
}
|
|
12658
|
+
case "cardinality_one":
|
|
12659
|
+
return generateArrowheadCardinalityOne(
|
|
12660
|
+
generator,
|
|
12661
|
+
getArrowheadPoints(element, shape, position, arrowhead),
|
|
12662
|
+
getArrowheadLineOptions(element, options)
|
|
12663
|
+
);
|
|
12664
|
+
case "cardinality_many":
|
|
12665
|
+
return generateArrowheadLinesToTip(
|
|
12666
|
+
generator,
|
|
12667
|
+
getArrowheadPoints(element, shape, position, arrowhead),
|
|
12668
|
+
getArrowheadLineOptions(element, options)
|
|
12669
|
+
);
|
|
12670
|
+
case "cardinality_one_or_many": {
|
|
12671
|
+
const lineOptions = getArrowheadLineOptions(element, options);
|
|
12672
|
+
return [
|
|
12673
|
+
...generateArrowheadLinesToTip(
|
|
12674
|
+
generator,
|
|
12675
|
+
getArrowheadPoints(element, shape, position, "cardinality_many"),
|
|
12676
|
+
lineOptions
|
|
12677
|
+
),
|
|
12678
|
+
...generateArrowheadCardinalityOne(
|
|
12679
|
+
generator,
|
|
12680
|
+
getArrowheadPoints(
|
|
12681
|
+
element,
|
|
12682
|
+
shape,
|
|
12683
|
+
position,
|
|
12684
|
+
"cardinality_one",
|
|
12685
|
+
cardinalityOneOrManyOffset
|
|
12686
|
+
),
|
|
12687
|
+
lineOptions
|
|
12688
|
+
)
|
|
12689
|
+
];
|
|
12690
|
+
}
|
|
12691
|
+
case "cardinality_exactly_one": {
|
|
12692
|
+
const lineOptions = getArrowheadLineOptions(element, options);
|
|
12693
|
+
return [
|
|
12694
|
+
...generateArrowheadCardinalityOne(
|
|
12695
|
+
generator,
|
|
12696
|
+
getArrowheadPoints(element, shape, position, "cardinality_one", -0.5),
|
|
12697
|
+
lineOptions
|
|
12698
|
+
),
|
|
12699
|
+
...generateArrowheadCardinalityOne(
|
|
12700
|
+
generator,
|
|
12701
|
+
getArrowheadPoints(element, shape, position, "cardinality_one"),
|
|
12702
|
+
lineOptions
|
|
12703
|
+
)
|
|
12704
|
+
];
|
|
12705
|
+
}
|
|
12706
|
+
case "cardinality_zero_or_one": {
|
|
12707
|
+
const lineOptions = getArrowheadLineOptions(element, options);
|
|
12708
|
+
return [
|
|
12709
|
+
...generateArrowheadOutlineCircle(
|
|
12710
|
+
generator,
|
|
12711
|
+
options,
|
|
12712
|
+
strokeColor,
|
|
12713
|
+
getArrowheadPoints(element, shape, position, "circle_outline", 1.5),
|
|
12714
|
+
backgroundFillColor,
|
|
12715
|
+
cardinalityZeroCircleScale
|
|
12716
|
+
),
|
|
12717
|
+
...generateArrowheadCardinalityOne(
|
|
12718
|
+
generator,
|
|
12719
|
+
getArrowheadPoints(element, shape, position, "cardinality_one", -0.5),
|
|
12720
|
+
lineOptions
|
|
12721
|
+
)
|
|
12722
|
+
];
|
|
12723
|
+
}
|
|
12724
|
+
case "cardinality_zero_or_many": {
|
|
12725
|
+
const lineOptions = getArrowheadLineOptions(element, options);
|
|
12726
|
+
return [
|
|
12727
|
+
...generateArrowheadLinesToTip(
|
|
12728
|
+
generator,
|
|
12729
|
+
getArrowheadPoints(element, shape, position, "cardinality_many"),
|
|
12730
|
+
lineOptions
|
|
12731
|
+
),
|
|
12732
|
+
...generateArrowheadOutlineCircle(
|
|
12733
|
+
generator,
|
|
12734
|
+
options,
|
|
12735
|
+
strokeColor,
|
|
12736
|
+
getArrowheadPoints(element, shape, position, "circle_outline", 1.5),
|
|
12737
|
+
backgroundFillColor,
|
|
12738
|
+
cardinalityZeroCircleScale
|
|
12488
12739
|
)
|
|
12489
12740
|
];
|
|
12490
12741
|
}
|
|
12491
|
-
case "crowfoot_one":
|
|
12492
|
-
return generateCrowfootOne(arrowheadPoints, options);
|
|
12493
12742
|
case "bar":
|
|
12494
12743
|
case "arrow":
|
|
12495
|
-
case "crowfoot_many":
|
|
12496
|
-
case "crowfoot_one_or_many":
|
|
12497
12744
|
default: {
|
|
12498
|
-
|
|
12499
|
-
|
|
12500
|
-
|
|
12501
|
-
|
|
12502
|
-
|
|
12503
|
-
delete options.strokeLineDash;
|
|
12504
|
-
}
|
|
12505
|
-
options.roughness = Math.min(1, options.roughness || 0);
|
|
12506
|
-
return [
|
|
12507
|
-
generator.line(x3, y3, x2, y2, options),
|
|
12508
|
-
generator.line(x4, y4, x2, y2, options),
|
|
12509
|
-
...arrowhead === "crowfoot_one_or_many" ? generateCrowfootOne(
|
|
12510
|
-
getArrowheadPoints(element, shape, position, "crowfoot_one"),
|
|
12511
|
-
options
|
|
12512
|
-
) : []
|
|
12513
|
-
];
|
|
12745
|
+
return generateArrowheadLinesToTip(
|
|
12746
|
+
generator,
|
|
12747
|
+
getArrowheadPoints(element, shape, position, arrowhead),
|
|
12748
|
+
getArrowheadLineOptions(element, options)
|
|
12749
|
+
);
|
|
12514
12750
|
}
|
|
12515
12751
|
}
|
|
12516
12752
|
};
|
|
12517
|
-
var generateLinearCollisionShape = (element) => {
|
|
12753
|
+
var generateLinearCollisionShape = (element, elementsMap) => {
|
|
12518
12754
|
const generator = new RoughGenerator();
|
|
12519
12755
|
const options = {
|
|
12520
12756
|
seed: element.seed,
|
|
@@ -12523,20 +12759,7 @@ var generateLinearCollisionShape = (element) => {
|
|
|
12523
12759
|
roughness: 0,
|
|
12524
12760
|
preserveVertices: true
|
|
12525
12761
|
};
|
|
12526
|
-
const center =
|
|
12527
|
-
// Need a non-rotated center point
|
|
12528
|
-
element.points.reduce(
|
|
12529
|
-
(acc, point) => {
|
|
12530
|
-
return [
|
|
12531
|
-
Math.min(element.x + point[0], acc[0]),
|
|
12532
|
-
Math.min(element.y + point[1], acc[1]),
|
|
12533
|
-
Math.max(element.x + point[0], acc[2]),
|
|
12534
|
-
Math.max(element.y + point[1], acc[3])
|
|
12535
|
-
];
|
|
12536
|
-
},
|
|
12537
|
-
[Infinity, Infinity, -Infinity, -Infinity]
|
|
12538
|
-
)
|
|
12539
|
-
);
|
|
12762
|
+
const center = elementCenterPoint(element, elementsMap);
|
|
12540
12763
|
switch (element.type) {
|
|
12541
12764
|
case "line":
|
|
12542
12765
|
case "arrow": {
|
|
@@ -13439,6 +13662,8 @@ var getFreeDrawElementAbsoluteCoords = (element) => {
|
|
|
13439
13662
|
const y2 = maxY + element.y;
|
|
13440
13663
|
return [x1, y1, x2, y2, (x1 + x2) / 2, (y1 + y2) / 2];
|
|
13441
13664
|
};
|
|
13665
|
+
var CARDINALITY_MARKER_SIZE = 20;
|
|
13666
|
+
var CROWFOOT_ARROWHEAD_SIZE = 15;
|
|
13442
13667
|
var getArrowheadSize = (arrowhead) => {
|
|
13443
13668
|
switch (arrowhead) {
|
|
13444
13669
|
case "arrow":
|
|
@@ -13446,10 +13671,14 @@ var getArrowheadSize = (arrowhead) => {
|
|
|
13446
13671
|
case "diamond":
|
|
13447
13672
|
case "diamond_outline":
|
|
13448
13673
|
return 12;
|
|
13449
|
-
case "
|
|
13450
|
-
case "
|
|
13451
|
-
case "
|
|
13452
|
-
return
|
|
13674
|
+
case "cardinality_many":
|
|
13675
|
+
case "cardinality_one_or_many":
|
|
13676
|
+
case "cardinality_zero_or_many":
|
|
13677
|
+
return CROWFOOT_ARROWHEAD_SIZE;
|
|
13678
|
+
case "cardinality_one":
|
|
13679
|
+
case "cardinality_exactly_one":
|
|
13680
|
+
case "cardinality_zero_or_one":
|
|
13681
|
+
return CARDINALITY_MARKER_SIZE;
|
|
13453
13682
|
default:
|
|
13454
13683
|
return 15;
|
|
13455
13684
|
}
|
|
@@ -13464,7 +13693,10 @@ var getArrowheadAngle = (arrowhead) => {
|
|
|
13464
13693
|
return 25;
|
|
13465
13694
|
}
|
|
13466
13695
|
};
|
|
13467
|
-
var getArrowheadPoints = (element, shape, position, arrowhead) => {
|
|
13696
|
+
var getArrowheadPoints = (element, shape, position, arrowhead, offsetMultiplier = 0) => {
|
|
13697
|
+
if (arrowhead === null) {
|
|
13698
|
+
return null;
|
|
13699
|
+
}
|
|
13468
13700
|
if (shape.length < 1) {
|
|
13469
13701
|
return null;
|
|
13470
13702
|
}
|
|
@@ -13502,21 +13734,23 @@ var getArrowheadPoints = (element, shape, position, arrowhead) => {
|
|
|
13502
13734
|
}
|
|
13503
13735
|
const lengthMultiplier = arrowhead === "diamond" || arrowhead === "diamond_outline" ? 0.25 : 0.5;
|
|
13504
13736
|
const minSize = Math.min(size, length * lengthMultiplier);
|
|
13505
|
-
const
|
|
13506
|
-
const
|
|
13507
|
-
|
|
13508
|
-
|
|
13509
|
-
|
|
13737
|
+
const tx = x2 - nx * minSize * offsetMultiplier;
|
|
13738
|
+
const ty = y2 - ny * minSize * offsetMultiplier;
|
|
13739
|
+
const xs = tx - nx * minSize;
|
|
13740
|
+
const ys = ty - ny * minSize;
|
|
13741
|
+
if (arrowhead === "circle" || arrowhead === "circle_outline") {
|
|
13742
|
+
const diameter = Math.hypot(ys - ty, xs - tx) + element.strokeWidth - 2;
|
|
13743
|
+
return [tx, ty, diameter];
|
|
13510
13744
|
}
|
|
13511
13745
|
const angle = getArrowheadAngle(arrowhead);
|
|
13512
|
-
if (arrowhead === "
|
|
13746
|
+
if (arrowhead === "cardinality_many" || arrowhead === "cardinality_one_or_many") {
|
|
13513
13747
|
const [x32, y32] = pointRotateRads(
|
|
13514
|
-
pointFrom(
|
|
13748
|
+
pointFrom(tx, ty),
|
|
13515
13749
|
pointFrom(xs, ys),
|
|
13516
13750
|
degreesToRadians(-angle)
|
|
13517
13751
|
);
|
|
13518
13752
|
const [x42, y42] = pointRotateRads(
|
|
13519
|
-
pointFrom(
|
|
13753
|
+
pointFrom(tx, ty),
|
|
13520
13754
|
pointFrom(xs, ys),
|
|
13521
13755
|
degreesToRadians(angle)
|
|
13522
13756
|
);
|
|
@@ -13524,12 +13758,12 @@ var getArrowheadPoints = (element, shape, position, arrowhead) => {
|
|
|
13524
13758
|
}
|
|
13525
13759
|
const [x3, y3] = pointRotateRads(
|
|
13526
13760
|
pointFrom(xs, ys),
|
|
13527
|
-
pointFrom(
|
|
13761
|
+
pointFrom(tx, ty),
|
|
13528
13762
|
-angle * Math.PI / 180
|
|
13529
13763
|
);
|
|
13530
13764
|
const [x4, y4] = pointRotateRads(
|
|
13531
13765
|
pointFrom(xs, ys),
|
|
13532
|
-
pointFrom(
|
|
13766
|
+
pointFrom(tx, ty),
|
|
13533
13767
|
degreesToRadians(angle)
|
|
13534
13768
|
);
|
|
13535
13769
|
if (arrowhead === "diamond" || arrowhead === "diamond_outline") {
|
|
@@ -13538,21 +13772,21 @@ var getArrowheadPoints = (element, shape, position, arrowhead) => {
|
|
|
13538
13772
|
if (position === "start") {
|
|
13539
13773
|
const [px, py] = element.points.length > 1 ? element.points[1] : [0, 0];
|
|
13540
13774
|
[ox, oy] = pointRotateRads(
|
|
13541
|
-
pointFrom(
|
|
13542
|
-
pointFrom(
|
|
13543
|
-
Math.atan2(py -
|
|
13775
|
+
pointFrom(tx + minSize * 2, ty),
|
|
13776
|
+
pointFrom(tx, ty),
|
|
13777
|
+
Math.atan2(py - ty, px - tx)
|
|
13544
13778
|
);
|
|
13545
13779
|
} else {
|
|
13546
13780
|
const [px, py] = element.points.length > 1 ? element.points[element.points.length - 2] : [0, 0];
|
|
13547
13781
|
[ox, oy] = pointRotateRads(
|
|
13548
|
-
pointFrom(
|
|
13549
|
-
pointFrom(
|
|
13550
|
-
Math.atan2(
|
|
13782
|
+
pointFrom(tx - minSize * 2, ty),
|
|
13783
|
+
pointFrom(tx, ty),
|
|
13784
|
+
Math.atan2(ty - py, tx - px)
|
|
13551
13785
|
);
|
|
13552
13786
|
}
|
|
13553
|
-
return [
|
|
13787
|
+
return [tx, ty, x3, y3, ox, oy, x4, y4];
|
|
13554
13788
|
}
|
|
13555
|
-
return [
|
|
13789
|
+
return [tx, ty, x3, y3, x4, y4];
|
|
13556
13790
|
};
|
|
13557
13791
|
var generateLinearElementShape = (element) => {
|
|
13558
13792
|
const generator = rough2.generator();
|
|
@@ -21071,6 +21305,32 @@ var maybeHandleArrowPointlikeDrag = ({
|
|
|
21071
21305
|
return false;
|
|
21072
21306
|
};
|
|
21073
21307
|
|
|
21308
|
+
// ../element/src/arrowheads.ts
|
|
21309
|
+
var normalizeArrowhead = (arrowhead) => {
|
|
21310
|
+
switch (arrowhead) {
|
|
21311
|
+
case void 0:
|
|
21312
|
+
case null:
|
|
21313
|
+
return null;
|
|
21314
|
+
case "dot":
|
|
21315
|
+
return "circle";
|
|
21316
|
+
case "crowfoot_one":
|
|
21317
|
+
return "cardinality_one";
|
|
21318
|
+
case "crowfoot_many":
|
|
21319
|
+
return "cardinality_many";
|
|
21320
|
+
case "crowfoot_one_or_many":
|
|
21321
|
+
return "cardinality_one_or_many";
|
|
21322
|
+
default:
|
|
21323
|
+
return arrowhead;
|
|
21324
|
+
}
|
|
21325
|
+
};
|
|
21326
|
+
var getArrowheadForPicker = (arrowhead) => {
|
|
21327
|
+
const normalizedArrowhead = normalizeArrowhead(arrowhead);
|
|
21328
|
+
if (normalizedArrowhead === null) {
|
|
21329
|
+
return null;
|
|
21330
|
+
}
|
|
21331
|
+
return normalizedArrowhead;
|
|
21332
|
+
};
|
|
21333
|
+
|
|
21074
21334
|
// ../element/src/index.ts
|
|
21075
21335
|
var getSceneVersion = (elements) => elements.reduce((acc, el) => acc + el.version, 0);
|
|
21076
21336
|
var hashElementsVersion = (elements) => {
|
|
@@ -24942,7 +25202,8 @@ var restoreElement = (element, targetElementsMap, existingElementsMap, opts) =>
|
|
|
24942
25202
|
});
|
|
24943
25203
|
case "line":
|
|
24944
25204
|
case "draw":
|
|
24945
|
-
const
|
|
25205
|
+
const startArrowhead = normalizeArrowhead(element.startArrowhead);
|
|
25206
|
+
const endArrowhead = normalizeArrowhead(element.endArrowhead);
|
|
24946
25207
|
let x = element.x;
|
|
24947
25208
|
let y = element.y;
|
|
24948
25209
|
let points = (
|
|
@@ -24967,7 +25228,8 @@ var restoreElement = (element, targetElementsMap, existingElementsMap, opts) =>
|
|
|
24967
25228
|
...getSizeFromPoints(points)
|
|
24968
25229
|
});
|
|
24969
25230
|
case "arrow": {
|
|
24970
|
-
const
|
|
25231
|
+
const startArrowhead2 = normalizeArrowhead(element.startArrowhead);
|
|
25232
|
+
const endArrowhead2 = element.endArrowhead === void 0 ? "arrow" : normalizeArrowhead(element.endArrowhead);
|
|
24971
25233
|
const x2 = element.x;
|
|
24972
25234
|
const y2 = element.y;
|
|
24973
25235
|
const points2 = (
|
|
@@ -25764,7 +26026,7 @@ var parseFileContents = async (blob) => {
|
|
|
25764
26026
|
let contents;
|
|
25765
26027
|
if (blob.type === MIME_TYPES.png) {
|
|
25766
26028
|
try {
|
|
25767
|
-
return await (await import("./data/image-
|
|
26029
|
+
return await (await import("./data/image-WSL7K3G4.js")).decodePngMetadata(blob);
|
|
25768
26030
|
} catch (error) {
|
|
25769
26031
|
if (error.message === "INVALID") {
|
|
25770
26032
|
throw new ImageSceneDataError(
|
|
@@ -26287,6 +26549,7 @@ export {
|
|
|
26287
26549
|
viewportCoordsToSceneCoords,
|
|
26288
26550
|
sceneCoordsToViewportCoords,
|
|
26289
26551
|
getGlobalCSSVariable,
|
|
26552
|
+
isRTL,
|
|
26290
26553
|
tupleToCoors,
|
|
26291
26554
|
muteFSAbortError,
|
|
26292
26555
|
findLastIndex,
|
|
@@ -26379,8 +26642,10 @@ export {
|
|
|
26379
26642
|
getLineHeightInPx,
|
|
26380
26643
|
getApproxMinLineHeight,
|
|
26381
26644
|
setCustomTextMetricsProvider,
|
|
26645
|
+
getLineWidth,
|
|
26382
26646
|
getTextWidth,
|
|
26383
26647
|
wrapText,
|
|
26648
|
+
getWrappedTextLines,
|
|
26384
26649
|
redrawTextBoundingBox,
|
|
26385
26650
|
handleBindTextResize,
|
|
26386
26651
|
computeBoundTextPosition,
|
|
@@ -26448,6 +26713,7 @@ export {
|
|
|
26448
26713
|
getTargetElements,
|
|
26449
26714
|
makeNextSelectedElementIds,
|
|
26450
26715
|
getSelectionStateForElements,
|
|
26716
|
+
getActiveTextElement,
|
|
26451
26717
|
elementOverlapsWithFrame,
|
|
26452
26718
|
isCursorInFrame,
|
|
26453
26719
|
groupByFrameLikes,
|
|
@@ -26569,6 +26835,7 @@ export {
|
|
|
26569
26835
|
showSelectedShapeActions,
|
|
26570
26836
|
convertToExcalidrawElements,
|
|
26571
26837
|
maybeHandleArrowPointlikeDrag,
|
|
26838
|
+
getArrowheadForPicker,
|
|
26572
26839
|
getSceneVersion,
|
|
26573
26840
|
hashElementsVersion,
|
|
26574
26841
|
hashString,
|
|
@@ -26637,4 +26904,4 @@ export {
|
|
|
26637
26904
|
createFile,
|
|
26638
26905
|
normalizeFile
|
|
26639
26906
|
};
|
|
26640
|
-
//# sourceMappingURL=chunk-
|
|
26907
|
+
//# sourceMappingURL=chunk-JBODKHIT.js.map
|