@ibodr/draw 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +6 -0
- package/dist/index.mjs +16 -3
- package/dist/index.mjs.map +1 -1
- package/draw.css +1 -0
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -2187,6 +2187,8 @@ interface ArrowShapeOptions extends ShapeOptionsWithDisplayValues<DrArrowShape,
|
|
|
2187
2187
|
shouldIgnoreTargets(editor: Editor): boolean;
|
|
2188
2188
|
/** Whether to show the outline of the arrow shape's label (using the same color as the canvas). This helps with overlapping shapes. It does not show up on Safari, where text outline is a performance issues. */
|
|
2189
2189
|
readonly showTextOutline: boolean;
|
|
2190
|
+
/** Whether clicking a link inside the arrow's label opens it in a new tab. Defaults to `true`. */
|
|
2191
|
+
readonly openLinksOnClick: boolean;
|
|
2190
2192
|
}
|
|
2191
2193
|
/** @public */
|
|
2192
2194
|
interface DrArrowPoint {
|
|
@@ -3180,6 +3182,8 @@ interface TextShapeOptions extends ShapeOptionsWithDisplayValues<DrTextShape, Te
|
|
|
3180
3182
|
extraArrowHorizontalPadding: number;
|
|
3181
3183
|
/** Whether to show the outline of the text shape (using the same color as the canvas). This helps with overlapping shapes. It does not show up on Safari, where text outline is a performance issues. */
|
|
3182
3184
|
showTextOutline: boolean;
|
|
3185
|
+
/** Whether clicking a link inside the text opens it in a new tab. Defaults to `true`. */
|
|
3186
|
+
openLinksOnClick: boolean;
|
|
3183
3187
|
}
|
|
3184
3188
|
/** @public */
|
|
3185
3189
|
declare class TextShapeUtil extends ShapeUtil<DrTextShape> {
|
|
@@ -3611,6 +3615,8 @@ interface RichTextLabelProps {
|
|
|
3611
3615
|
padding?: number;
|
|
3612
3616
|
hasCustomTabBehavior?: boolean;
|
|
3613
3617
|
showTextOutline?: boolean;
|
|
3618
|
+
/** Whether clicking a link inside the text opens it in a new tab. Defaults to `true`. */
|
|
3619
|
+
openLinksOnClick?: boolean;
|
|
3614
3620
|
}
|
|
3615
3621
|
/**
|
|
3616
3622
|
* Renders a text label that can be used inside of shapes.
|
package/dist/index.mjs
CHANGED
|
@@ -25656,7 +25656,8 @@ var RichTextLabel = React4__default.memo(function RichTextLabel2({
|
|
|
25656
25656
|
textWidth,
|
|
25657
25657
|
textHeight,
|
|
25658
25658
|
hasCustomTabBehavior,
|
|
25659
|
-
showTextOutline = true
|
|
25659
|
+
showTextOutline = true,
|
|
25660
|
+
openLinksOnClick = true
|
|
25660
25661
|
}) {
|
|
25661
25662
|
const editor = useEditor();
|
|
25662
25663
|
const isDragging = React4__default.useRef(false);
|
|
@@ -25685,7 +25686,7 @@ var RichTextLabel = React4__default.memo(function RichTextLabel2({
|
|
|
25685
25686
|
const HTMLElementCtor = editor.getContainerWindow().HTMLElement;
|
|
25686
25687
|
if (e.target instanceof HTMLElementCtor && (e.target.tagName === "A" || e.target.closest("a"))) {
|
|
25687
25688
|
preventDefault(e);
|
|
25688
|
-
if (!selectToolActive) return;
|
|
25689
|
+
if (!openLinksOnClick || !selectToolActive) return;
|
|
25689
25690
|
const link = e.target.closest("a")?.getAttribute("href") ?? "";
|
|
25690
25691
|
const handlePointerUp = (e2) => {
|
|
25691
25692
|
if (e2.name !== "pointer_up" || !link) return;
|
|
@@ -25697,6 +25698,13 @@ var RichTextLabel = React4__default.memo(function RichTextLabel2({
|
|
|
25697
25698
|
editor.on("event", handlePointerUp);
|
|
25698
25699
|
}
|
|
25699
25700
|
};
|
|
25701
|
+
const handleClick = (e) => {
|
|
25702
|
+
if (openLinksOnClick) return;
|
|
25703
|
+
const HTMLElementCtor = editor.getContainerWindow().HTMLElement;
|
|
25704
|
+
if (e.target instanceof HTMLElementCtor && (e.target.tagName === "A" || e.target.closest("a"))) {
|
|
25705
|
+
preventDefault(e);
|
|
25706
|
+
}
|
|
25707
|
+
};
|
|
25700
25708
|
if (!isEditing && isEmpty) return null;
|
|
25701
25709
|
const cssPrefix = classNamePrefix || "dr-text";
|
|
25702
25710
|
return /* @__PURE__ */ jsx(
|
|
@@ -25740,6 +25748,7 @@ var RichTextLabel = React4__default.memo(function RichTextLabel2({
|
|
|
25740
25748
|
"data-is-select-tool-active": selectToolActive,
|
|
25741
25749
|
dangerouslySetInnerHTML: { __html: html || "" },
|
|
25742
25750
|
onPointerDown: handlePointerDown,
|
|
25751
|
+
onClick: handleClick,
|
|
25743
25752
|
"data-is-ready-for-editing": isReadyForEditing
|
|
25744
25753
|
}
|
|
25745
25754
|
) }),
|
|
@@ -26527,6 +26536,7 @@ var ArrowShapeUtil = class extends ShapeUtil {
|
|
|
26527
26536
|
return editor.inputs.getCtrlKey();
|
|
26528
26537
|
},
|
|
26529
26538
|
showTextOutline: true,
|
|
26539
|
+
openLinksOnClick: true,
|
|
26530
26540
|
getDefaultDisplayValues(_editor, shape, theme, colorMode) {
|
|
26531
26541
|
const { color, fill, labelColor, size, font } = shape.props;
|
|
26532
26542
|
const colors = theme.colors[colorMode];
|
|
@@ -27077,6 +27087,7 @@ var ArrowShapeUtil = class extends ShapeUtil {
|
|
|
27077
27087
|
isSelected,
|
|
27078
27088
|
padding: 0,
|
|
27079
27089
|
showTextOutline: this.options.showTextOutline,
|
|
27090
|
+
openLinksOnClick: this.options.openLinksOnClick,
|
|
27080
27091
|
style: {
|
|
27081
27092
|
transform: `translate(${labelPosition.box.center.x}px, ${labelPosition.box.center.y}px)${shape.props.scale !== 1 ? ` scale(${shape.props.scale})` : ""}`
|
|
27082
27093
|
}
|
|
@@ -31343,6 +31354,7 @@ var TextShapeUtil = class extends ShapeUtil {
|
|
|
31343
31354
|
options = {
|
|
31344
31355
|
extraArrowHorizontalPadding: 10,
|
|
31345
31356
|
showTextOutline: true,
|
|
31357
|
+
openLinksOnClick: true,
|
|
31346
31358
|
getDefaultDisplayValues(_editor, shape, theme, colorMode) {
|
|
31347
31359
|
const { color, font, size } = shape.props;
|
|
31348
31360
|
return {
|
|
@@ -31432,6 +31444,7 @@ var TextShapeUtil = class extends ShapeUtil {
|
|
|
31432
31444
|
textWidth: width,
|
|
31433
31445
|
textHeight: height,
|
|
31434
31446
|
showTextOutline: this.options.showTextOutline,
|
|
31447
|
+
openLinksOnClick: this.options.openLinksOnClick,
|
|
31435
31448
|
style: {
|
|
31436
31449
|
transform: `scale(${scale})`,
|
|
31437
31450
|
transformOrigin: "top left"
|
|
@@ -38447,7 +38460,7 @@ async function extractAssets(editor, snapshot, msg, addToast) {
|
|
|
38447
38460
|
// src/index.ts
|
|
38448
38461
|
registerDrawLibraryVersion(
|
|
38449
38462
|
"@ibodr/draw",
|
|
38450
|
-
"0.2.
|
|
38463
|
+
"0.2.2",
|
|
38451
38464
|
"esm"
|
|
38452
38465
|
);
|
|
38453
38466
|
/*!
|