@ibodr/draw 0.1.12 → 0.1.14

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 CHANGED
@@ -2103,6 +2103,8 @@ interface ArrowShapeOptions extends ShapeOptionsWithDisplayValues<DrArrowShape,
2103
2103
  shouldIgnoreTargets(editor: Editor): boolean;
2104
2104
  /** 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. */
2105
2105
  readonly showTextOutline: boolean;
2106
+ /** Whether clicking a link inside the arrow's label opens it in a new tab. Defaults to `true`. */
2107
+ readonly openLinksOnClick: boolean;
2106
2108
  }
2107
2109
  /** @public */
2108
2110
  interface DrArrowPoint {
@@ -3096,6 +3098,8 @@ interface TextShapeOptions extends ShapeOptionsWithDisplayValues<DrTextShape, Te
3096
3098
  extraArrowHorizontalPadding: number;
3097
3099
  /** 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. */
3098
3100
  showTextOutline: boolean;
3101
+ /** Whether clicking a link inside the text opens it in a new tab. Defaults to `true`. */
3102
+ openLinksOnClick: boolean;
3099
3103
  }
3100
3104
  /** @public */
3101
3105
  declare class TextShapeUtil extends ShapeUtil<DrTextShape> {
@@ -3527,6 +3531,8 @@ interface RichTextLabelProps {
3527
3531
  padding?: number;
3528
3532
  hasCustomTabBehavior?: boolean;
3529
3533
  showTextOutline?: boolean;
3534
+ /** Whether clicking a link inside the text opens it in a new tab. Defaults to `true`. */
3535
+ openLinksOnClick?: boolean;
3530
3536
  }
3531
3537
  /**
3532
3538
  * Renders a text label that can be used inside of shapes.
package/dist/index.mjs CHANGED
@@ -24439,7 +24439,8 @@ var RichTextLabel = React4__default.memo(function RichTextLabel2({
24439
24439
  textWidth,
24440
24440
  textHeight,
24441
24441
  hasCustomTabBehavior,
24442
- showTextOutline = true
24442
+ showTextOutline = true,
24443
+ openLinksOnClick = true
24443
24444
  }) {
24444
24445
  const editor = useEditor();
24445
24446
  const isDragging = React4__default.useRef(false);
@@ -24468,7 +24469,7 @@ var RichTextLabel = React4__default.memo(function RichTextLabel2({
24468
24469
  const HTMLElementCtor = editor.getContainerWindow().HTMLElement;
24469
24470
  if (e.target instanceof HTMLElementCtor && (e.target.tagName === "A" || e.target.closest("a"))) {
24470
24471
  preventDefault(e);
24471
- if (!selectToolActive) return;
24472
+ if (!openLinksOnClick || !selectToolActive) return;
24472
24473
  const link = e.target.closest("a")?.getAttribute("href") ?? "";
24473
24474
  const handlePointerUp = (e2) => {
24474
24475
  if (e2.name !== "pointer_up" || !link) return;
@@ -24480,6 +24481,13 @@ var RichTextLabel = React4__default.memo(function RichTextLabel2({
24480
24481
  editor.on("event", handlePointerUp);
24481
24482
  }
24482
24483
  };
24484
+ const handleClick = (e) => {
24485
+ if (openLinksOnClick) return;
24486
+ const HTMLElementCtor = editor.getContainerWindow().HTMLElement;
24487
+ if (e.target instanceof HTMLElementCtor && (e.target.tagName === "A" || e.target.closest("a"))) {
24488
+ preventDefault(e);
24489
+ }
24490
+ };
24483
24491
  if (!isEditing && isEmpty) return null;
24484
24492
  const cssPrefix = classNamePrefix || "dr-text";
24485
24493
  return /* @__PURE__ */ jsx(
@@ -24523,6 +24531,7 @@ var RichTextLabel = React4__default.memo(function RichTextLabel2({
24523
24531
  "data-is-select-tool-active": selectToolActive,
24524
24532
  dangerouslySetInnerHTML: { __html: html || "" },
24525
24533
  onPointerDown: handlePointerDown,
24534
+ onClick: handleClick,
24526
24535
  "data-is-ready-for-editing": isReadyForEditing
24527
24536
  }
24528
24537
  ) }),
@@ -25310,6 +25319,7 @@ var ArrowShapeUtil = class extends ShapeUtil {
25310
25319
  return editor.inputs.getCtrlKey();
25311
25320
  },
25312
25321
  showTextOutline: true,
25322
+ openLinksOnClick: true,
25313
25323
  getDefaultDisplayValues(_editor, shape, theme, colorMode) {
25314
25324
  const { color, fill, labelColor, size, font } = shape.props;
25315
25325
  const colors = theme.colors[colorMode];
@@ -25860,6 +25870,7 @@ var ArrowShapeUtil = class extends ShapeUtil {
25860
25870
  isSelected,
25861
25871
  padding: 0,
25862
25872
  showTextOutline: this.options.showTextOutline,
25873
+ openLinksOnClick: this.options.openLinksOnClick,
25863
25874
  style: {
25864
25875
  transform: `translate(${labelPosition.box.center.x}px, ${labelPosition.box.center.y}px)${shape.props.scale !== 1 ? ` scale(${shape.props.scale})` : ""}`
25865
25876
  }
@@ -30126,6 +30137,7 @@ var TextShapeUtil = class extends ShapeUtil {
30126
30137
  options = {
30127
30138
  extraArrowHorizontalPadding: 10,
30128
30139
  showTextOutline: true,
30140
+ openLinksOnClick: true,
30129
30141
  getDefaultDisplayValues(_editor, shape, theme, colorMode) {
30130
30142
  const { color, font, size } = shape.props;
30131
30143
  return {
@@ -30215,6 +30227,7 @@ var TextShapeUtil = class extends ShapeUtil {
30215
30227
  textWidth: width,
30216
30228
  textHeight: height,
30217
30229
  showTextOutline: this.options.showTextOutline,
30230
+ openLinksOnClick: this.options.openLinksOnClick,
30218
30231
  style: {
30219
30232
  transform: `scale(${scale})`,
30220
30233
  transformOrigin: "top left"
@@ -37230,7 +37243,7 @@ async function extractAssets(editor, snapshot, msg, addToast) {
37230
37243
  // src/index.ts
37231
37244
  registerDrawLibraryVersion(
37232
37245
  "@ibodr/draw",
37233
- "0.1.12",
37246
+ "0.1.14",
37234
37247
  "esm"
37235
37248
  );
37236
37249
  /*!