@ibodr/draw 0.1.11 → 0.1.13

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
@@ -3096,6 +3096,8 @@ interface TextShapeOptions extends ShapeOptionsWithDisplayValues<DrTextShape, Te
3096
3096
  extraArrowHorizontalPadding: number;
3097
3097
  /** 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
3098
  showTextOutline: boolean;
3099
+ /** Whether clicking a link inside the text opens it in a new tab. Defaults to `true`. */
3100
+ openLinksOnClick: boolean;
3099
3101
  }
3100
3102
  /** @public */
3101
3103
  declare class TextShapeUtil extends ShapeUtil<DrTextShape> {
@@ -3527,6 +3529,8 @@ interface RichTextLabelProps {
3527
3529
  padding?: number;
3528
3530
  hasCustomTabBehavior?: boolean;
3529
3531
  showTextOutline?: boolean;
3532
+ /** Whether clicking a link inside the text opens it in a new tab. Defaults to `true`. */
3533
+ openLinksOnClick?: boolean;
3530
3534
  }
3531
3535
  /**
3532
3536
  * 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
  ) }),
@@ -30126,6 +30135,7 @@ var TextShapeUtil = class extends ShapeUtil {
30126
30135
  options = {
30127
30136
  extraArrowHorizontalPadding: 10,
30128
30137
  showTextOutline: true,
30138
+ openLinksOnClick: true,
30129
30139
  getDefaultDisplayValues(_editor, shape, theme, colorMode) {
30130
30140
  const { color, font, size } = shape.props;
30131
30141
  return {
@@ -30215,6 +30225,7 @@ var TextShapeUtil = class extends ShapeUtil {
30215
30225
  textWidth: width,
30216
30226
  textHeight: height,
30217
30227
  showTextOutline: this.options.showTextOutline,
30228
+ openLinksOnClick: this.options.openLinksOnClick,
30218
30229
  style: {
30219
30230
  transform: `scale(${scale})`,
30220
30231
  transformOrigin: "top left"
@@ -37230,7 +37241,7 @@ async function extractAssets(editor, snapshot, msg, addToast) {
37230
37241
  // src/index.ts
37231
37242
  registerDrawLibraryVersion(
37232
37243
  "@ibodr/draw",
37233
- "0.1.11",
37244
+ "0.1.13",
37234
37245
  "esm"
37235
37246
  );
37236
37247
  /*!