@unhingged/vizu-core 0.1.15 → 0.1.17

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/auto.cjs CHANGED
@@ -112,6 +112,9 @@ function renderAttachmentsHtml(attachments) {
112
112
  function migrateComment(raw) {
113
113
  if (!raw || typeof raw !== "object") return raw;
114
114
  const next = { ...raw };
115
+ if (next.id == null && next._id != null) {
116
+ next.id = next._id;
117
+ }
115
118
  if (!Array.isArray(next.fingerprints) || next.fingerprints.length === 0) {
116
119
  if (next.fingerprint) {
117
120
  next.fingerprints = [next.fingerprint];
@@ -3368,6 +3371,10 @@ var STYLES = `
3368
3371
  pointer-events: none;
3369
3372
  z-index: 1;
3370
3373
  }
3374
+ /* Opt-in only during an active dragover. The explicit display:flex
3375
+ * above out-specifics the browser default for [hidden], so we restate
3376
+ * the hide rule here to make the attribute toggle effective. */
3377
+ .vz-attachment-drop-hint[hidden] { display: none; }
3371
3378
 
3372
3379
  /* Pending attachments (uploaded but not yet saved) */
3373
3380
  .vz-attachment-list {
@@ -3764,10 +3771,25 @@ var Vizu = class {
3764
3771
  /**
3765
3772
  * Fetch the list of users who can be @-mentioned on the current
3766
3773
  * workspace. Used by the popover's mention dropdown; hosts can also
3767
- * call this directly to build their own picker. Returns [] for
3768
- * non-cloud adapters (no workspace, no member list to fetch from).
3774
+ * call this directly to build their own picker.
3775
+ *
3776
+ * Resolution order:
3777
+ * 1. `options.mentionable` if provided — host-supplied static or
3778
+ * custom resolver. Wins over everything else.
3779
+ * 2. Cloud adapter's API call if running cloud mode.
3780
+ * 3. Empty array (non-cloud, no override).
3769
3781
  */
3770
3782
  async searchMentionable() {
3783
+ if (this.opts.mentionable) {
3784
+ try {
3785
+ return await this.opts.mentionable();
3786
+ } catch (err) {
3787
+ if (typeof console !== "undefined") {
3788
+ console.warn("[vizu] options.mentionable threw", err);
3789
+ }
3790
+ return [];
3791
+ }
3792
+ }
3771
3793
  if (this.storage instanceof CloudStorageAdapter) {
3772
3794
  return this.storage.searchMentionable();
3773
3795
  }
@@ -4288,10 +4310,26 @@ var Vizu = class {
4288
4310
  this.refreshUi();
4289
4311
  }
4290
4312
  async removeComment(id) {
4291
- const comment = this.comments.find((c) => c.id === id);
4292
- if (!comment) return;
4313
+ const idx = this.comments.findIndex((c) => c.id === id);
4314
+ if (idx === -1) return;
4315
+ const comment = this.comments[idx];
4293
4316
  this.comments = this.comments.filter((c) => c.id !== id);
4294
- await this.storage.removeComment(this.opts.namespace, id);
4317
+ try {
4318
+ await this.storage.removeComment(this.opts.namespace, id);
4319
+ } catch (err) {
4320
+ this.comments.splice(idx, 0, comment);
4321
+ const status = err?.status;
4322
+ const code = err?.code ?? "";
4323
+ const msg = status === 403 || code === "forbidden" ? "Delete failed \u2014 you don't have permission." : status === 401 || code === "auth_required" ? "Delete failed \u2014 please sign in again." : "Delete failed. Please try again.";
4324
+ this.pill?.toast(msg);
4325
+ if (this.popover?.isOpen()) {
4326
+ const anchors = this.popover.getAnchors();
4327
+ if (anchors[0]) this.popover.update(this.commentsForElement(anchors[0]));
4328
+ }
4329
+ this.refreshUi();
4330
+ if (typeof console !== "undefined") console.warn("[vizu] removeComment failed", err);
4331
+ return;
4332
+ }
4295
4333
  this.bus.emit("comment:removed", { id, comment });
4296
4334
  if (this.popover?.isOpen()) {
4297
4335
  const anchors = this.popover.getAnchors();