@harbour-enterprises/superdoc 1.0.0-alpha.15 → 1.0.0-alpha.16

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.
@@ -37436,10 +37436,11 @@ const _sfc_main$b = {
37436
37436
  };
37437
37437
  const setFloatingCommentOffset = (conversation, e) => {
37438
37438
  const floatingConvo = visibleConversations.value.find((c2) => c2.id === conversation.conversationId);
37439
- const parentTop = props.parent.getBoundingClientRect().top;
37440
- const top = floatingConvo.position.top;
37441
- const eTop = e.target.getBoundingClientRect().top;
37442
- floatingCommentsOffset.value = top - eTop + parentTop;
37439
+ conversation.selection.getContainerLocation(props.parent).top;
37440
+ props.parent.getBoundingClientRect().top;
37441
+ floatingConvo.position.top;
37442
+ e.target.getBoundingClientRect().top;
37443
+ floatingCommentsOffset.value = conversation.selection.selectionBounds.top;
37443
37444
  };
37444
37445
  const handleHighlightClick = (conversation, e) => {
37445
37446
  conversation.isFocused = true;
@@ -37471,7 +37472,7 @@ const _sfc_main$b = {
37471
37472
  };
37472
37473
  }
37473
37474
  };
37474
- const CommentsLayer = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["__scopeId", "data-v-13d89078"]]);
37475
+ const CommentsLayer = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["__scopeId", "data-v-df7ef0d6"]]);
37475
37476
  function OrderedMap(content) {
37476
37477
  this.content = content;
37477
37478
  }
@@ -48515,6 +48516,19 @@ const _sfc_main$8 = {
48515
48516
  });
48516
48517
  if (pendingComment.value && pendingComment.value.conversationId === props.data.conversationId) {
48517
48518
  const newConversation = { ...pendingComment.value };
48519
+ const selection = pendingComment.value.selection.getValues();
48520
+ const bounds = selection.selectionBounds;
48521
+ if (bounds.top > bounds.bottom) {
48522
+ const temp = bounds.top;
48523
+ bounds.top = bounds.bottom;
48524
+ bounds.bottom = temp;
48525
+ }
48526
+ if (bounds.left > bounds.right) {
48527
+ const temp = bounds.left;
48528
+ bounds.left = bounds.right;
48529
+ bounds.right = temp;
48530
+ }
48531
+ newConversation.selection = useSelection(selection);
48518
48532
  pendingComment.value = null;
48519
48533
  selectionPosition.value = null;
48520
48534
  newConversation.comments.push(comment);
@@ -48561,6 +48575,8 @@ const _sfc_main$8 = {
48561
48575
  const cleanConversations = () => {
48562
48576
  if (props.data.comments.length)
48563
48577
  return;
48578
+ if (pendingComment.value)
48579
+ selectionPosition.value = null;
48564
48580
  const id = props.data.conversationId;
48565
48581
  pendingComment.value = null;
48566
48582
  props.currentDocument.removeConversation(id);
@@ -48670,7 +48686,7 @@ const _sfc_main$8 = {
48670
48686
  };
48671
48687
  }
48672
48688
  };
48673
- const CommentDialog = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["__scopeId", "data-v-25f7474c"]]);
48689
+ const CommentDialog = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["__scopeId", "data-v-01544401"]]);
48674
48690
  function useFloatingConveration(params) {
48675
48691
  const id = params.conversationId;
48676
48692
  const conversation = ref(params);
@@ -48753,6 +48769,9 @@ const _sfc_main$7 = {
48753
48769
  }
48754
48770
  if (currentItem.id === activeComment.value) {
48755
48771
  floatingCommentsOffset.value += currentItem.offset;
48772
+ updatedPosition.top;
48773
+ const diff = updatedPosition.top - proposedPosition.top;
48774
+ floatingCommentsOffset.value += diff;
48756
48775
  }
48757
48776
  return updatedPosition;
48758
48777
  };
@@ -48792,6 +48811,14 @@ const _sfc_main$7 = {
48792
48811
  };
48793
48812
  });
48794
48813
  watch(documentsWithConverations, (newVal) => newVal.length && initialize());
48814
+ watch(activeComment, (newVal) => {
48815
+ setTimeout(() => {
48816
+ if (!activeComment.value) {
48817
+ floatingCommentsOffset.value = 0;
48818
+ initialize();
48819
+ }
48820
+ });
48821
+ });
48795
48822
  onMounted(() => {
48796
48823
  initialize();
48797
48824
  });
@@ -48824,7 +48851,7 @@ const _sfc_main$7 = {
48824
48851
  };
48825
48852
  }
48826
48853
  };
48827
- const FloatingComments = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["__scopeId", "data-v-858cd0cf"]]);
48854
+ const FloatingComments = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["__scopeId", "data-v-2284c669"]]);
48828
48855
  const _sfc_main$6 = {
48829
48856
  __name: "TextField",
48830
48857
  props: {
@@ -52080,9 +52107,8 @@ const _sfc_main = {
52080
52107
  zIndex: 10
52081
52108
  };
52082
52109
  };
52083
- const handleSelectionDrag = (selection, e) => {
52084
- if (!selection.selectionBounds)
52085
- return;
52110
+ const setSelectionPosition = (selection) => {
52111
+ activeSelection.value = selection;
52086
52112
  const containerBounds = selection.getContainerLocation(layers.value);
52087
52113
  let left = selection.selectionBounds.left;
52088
52114
  let top = selection.selectionBounds.top + containerBounds.top;
@@ -52101,7 +52127,11 @@ const _sfc_main = {
52101
52127
  height: Math.abs(selection.selectionBounds.bottom - selection.selectionBounds.top) + "px",
52102
52128
  borderRadius: "4px"
52103
52129
  };
52104
- activeSelection.value = selection;
52130
+ };
52131
+ const handleSelectionDrag = (selection, e) => {
52132
+ if (!selection.selectionBounds)
52133
+ return;
52134
+ setSelectionPosition(selection);
52105
52135
  };
52106
52136
  const handleSelectionDragEnd = () => {
52107
52137
  if (!selectionPosition.value)
@@ -52113,18 +52143,23 @@ const _sfc_main = {
52113
52143
  comments: showAddComment
52114
52144
  };
52115
52145
  if (tool in toolOptions) {
52146
+ setSelectionPosition(activeSelection.value);
52116
52147
  toolOptions[tool](activeSelection.value, selectionPosition.value);
52117
52148
  }
52118
52149
  activeSelection.value = null;
52119
52150
  toolsMenuPosition.value = null;
52120
52151
  };
52121
52152
  const handleDocumentMouseDown = (e) => {
52153
+ if (pendingComment.value)
52154
+ return;
52122
52155
  selectionPosition.value = null;
52123
- document.removeEventListener("mousedown", handleDocumentMouseDown);
52124
52156
  };
52125
52157
  const handleHighlightClick = () => {
52126
52158
  toolsMenuPosition.value = null;
52127
52159
  };
52160
+ const cancelPendingComment = () => {
52161
+ selectionPosition.value = null;
52162
+ };
52128
52163
  onMounted(() => {
52129
52164
  if ("comments" in modules && !modules.comments.readOnly) {
52130
52165
  document.addEventListener("mousedown", handleDocumentMouseDown);
@@ -52134,6 +52169,7 @@ const _sfc_main = {
52134
52169
  document.removeEventListener("mousedown", handleDocumentMouseDown);
52135
52170
  });
52136
52171
  return (_ctx, _cache) => {
52172
+ const _directive_click_outside = resolveDirective("click-outside");
52137
52173
  return openBlock(), createElementBlock("div", _hoisted_1, [
52138
52174
  createBaseVNode("div", {
52139
52175
  class: "layers",
@@ -52201,13 +52237,15 @@ const _sfc_main = {
52201
52237
  ])
52202
52238
  ], 512),
52203
52239
  (unref(pendingComment) || unref(documentsWithConverations).length) && layers.value && unref(isReady) ? (openBlock(), createElementBlock("div", _hoisted_3, [
52204
- unref(pendingComment) ? (openBlock(), createBlock(CommentDialog, {
52240
+ unref(pendingComment) ? withDirectives((openBlock(), createBlock(CommentDialog, {
52205
52241
  key: 0,
52206
52242
  data: unref(pendingComment),
52207
52243
  "current-document": unref(getDocument2)(unref(pendingComment).documentId),
52208
52244
  user: unref(user),
52209
52245
  parent: layers.value
52210
- }, null, 8, ["data", "current-document", "user", "parent"])) : createCommentVNode("", true),
52246
+ }, null, 8, ["data", "current-document", "user", "parent"])), [
52247
+ [_directive_click_outside, cancelPendingComment]
52248
+ ]) : createCommentVNode("", true),
52211
52249
  (openBlock(true), createElementBlock(Fragment$1, null, renderList(unref(documentsWithConverations), (doc2) => {
52212
52250
  return openBlock(), createBlock(FloatingComments, {
52213
52251
  parent: layers.value,
@@ -52219,7 +52257,7 @@ const _sfc_main = {
52219
52257
  };
52220
52258
  }
52221
52259
  };
52222
- const App = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-49e265f8"]]);
52260
+ const App = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-f1f5c2b0"]]);
52223
52261
  const createMyApp = () => {
52224
52262
  const app = createApp(App);
52225
52263
  const pinia = createPinia();