@threadlabs/looma 0.16.2 → 0.16.4

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.
@@ -495,6 +495,7 @@ var LoomaEditor = defineComponent({
495
495
  });
496
496
  const imageDelivery = createLoomaImageDeliveryController({ resolveAttributes: () => props.resolveImageAttributes });
497
497
  let lastFocusedSelection = null;
498
+ let linkPressedSelection = null;
498
499
  const rememberSelection = (instance) => {
499
500
  if (!instance.isFocused) return;
500
501
  const selection = instance.view.state.selection;
@@ -541,8 +542,10 @@ var LoomaEditor = defineComponent({
541
542
  if (!instance || !props.editable) return;
542
543
  const current = instance.state.selection;
543
544
  const preserved = lastFocusedSelection?.text && lastFocusedSelection.from !== lastFocusedSelection.to ? lastFocusedSelection : null;
544
- const from = current.empty && preserved ? preserved.from : current.from;
545
- const to = current.empty && preserved ? preserved.to : current.to;
545
+ const selection = linkPressedSelection ?? (current.empty ? preserved : null);
546
+ linkPressedSelection = null;
547
+ const from = selection?.from ?? current.from;
548
+ const to = selection?.to ?? current.to;
546
549
  const empty = from === to;
547
550
  const existing = instance.isActive("link");
548
551
  linkSelection = {
@@ -1084,6 +1087,13 @@ var LoomaEditor = defineComponent({
1084
1087
  "data-active": instance.isActive("link") ? "true" : "false",
1085
1088
  onPointerenter: () => showTool(linkAnchorId, "Link", false),
1086
1089
  onPointerleave: hideTool,
1090
+ onPointerdown: () => {
1091
+ const selection = instance.state.selection;
1092
+ linkPressedSelection = selection.empty ? null : {
1093
+ from: selection.from,
1094
+ to: selection.to
1095
+ };
1096
+ },
1087
1097
  onFocusin: () => showTool(linkAnchorId, "Link", true),
1088
1098
  onFocusout: hideTool
1089
1099
  }, () => loomaIcon("link")),
@@ -1282,7 +1292,7 @@ var LoomaEditor = defineComponent({
1282
1292
  class: "looma-editor__chip-popover",
1283
1293
  open: chipOpen.value,
1284
1294
  for: chipAnchorId,
1285
- placement: mobile.value ? "top-start" : "bottom-start",
1295
+ placement: "bottom-start",
1286
1296
  onClose: () => {
1287
1297
  chipOpen.value = false;
1288
1298
  }
@@ -1334,6 +1344,7 @@ var LoomaEditor = defineComponent({
1334
1344
  onOpen: openLinkEditor,
1335
1345
  onClose: () => {
1336
1346
  linkOpen.value = false;
1347
+ linkPressedSelection = null;
1337
1348
  }
1338
1349
  }, () => h("form", {
1339
1350
  class: "looma-editor__link-form",