@unhingged/vizu-core 0.1.14 → 0.1.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.
package/dist/auto.cjs CHANGED
@@ -3262,7 +3262,9 @@ var STYLES = `
3262
3262
  .vz-ref:hover { background: color-mix(in srgb, var(--vz-accent) 30%, var(--vz-bg-hover)); transform: translateY(-1px); }
3263
3263
  .vz-ref::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--vz-accent); flex-shrink: 0; }
3264
3264
 
3265
- /* Inline @mention chip (rendered inside displayed comments) */
3265
+ /* Inline @mention chip (rendered inside displayed comments). user-select
3266
+ * prevents the user from selecting the chip's text and editing it; the
3267
+ * displayed comment is intentionally read-only after save. */
3266
3268
  .vz-mention {
3267
3269
  display: inline-flex; align-items: center;
3268
3270
  padding: 1px 8px 1px 8px;
@@ -3272,13 +3274,21 @@ var STYLES = `
3272
3274
  font-size: 12px; font-weight: 600;
3273
3275
  vertical-align: baseline;
3274
3276
  margin: 0 1px;
3277
+ user-select: none;
3278
+ -webkit-user-select: none;
3279
+ cursor: default;
3275
3280
  }
3276
3281
 
3277
- /* Mention chip inside the editor (contenteditable=false token) */
3282
+ /* Mention chip inside the editor (contenteditable=false token). Same
3283
+ * non-selection rules as .vz-mention so the chip stays atomic even
3284
+ * inside the editable surface \u2014 caret can land before/after but not
3285
+ * inside, no partial-text edit. */
3278
3286
  .vz-chip-mention {
3279
3287
  background: color-mix(in srgb, var(--vz-accent) 16%, var(--vz-bg-hover));
3280
3288
  color: var(--vz-accent);
3281
3289
  font-weight: 600;
3290
+ user-select: none;
3291
+ -webkit-user-select: none;
3282
3292
  }
3283
3293
  .vz-chip-mention::before { display: none; }
3284
3294
 
@@ -3358,6 +3368,10 @@ var STYLES = `
3358
3368
  pointer-events: none;
3359
3369
  z-index: 1;
3360
3370
  }
3371
+ /* Opt-in only during an active dragover. The explicit display:flex
3372
+ * above out-specifics the browser default for [hidden], so we restate
3373
+ * the hide rule here to make the attribute toggle effective. */
3374
+ .vz-attachment-drop-hint[hidden] { display: none; }
3361
3375
 
3362
3376
  /* Pending attachments (uploaded but not yet saved) */
3363
3377
  .vz-attachment-list {
@@ -3754,10 +3768,25 @@ var Vizu = class {
3754
3768
  /**
3755
3769
  * Fetch the list of users who can be @-mentioned on the current
3756
3770
  * workspace. Used by the popover's mention dropdown; hosts can also
3757
- * call this directly to build their own picker. Returns [] for
3758
- * non-cloud adapters (no workspace, no member list to fetch from).
3771
+ * call this directly to build their own picker.
3772
+ *
3773
+ * Resolution order:
3774
+ * 1. `options.mentionable` if provided — host-supplied static or
3775
+ * custom resolver. Wins over everything else.
3776
+ * 2. Cloud adapter's API call if running cloud mode.
3777
+ * 3. Empty array (non-cloud, no override).
3759
3778
  */
3760
3779
  async searchMentionable() {
3780
+ if (this.opts.mentionable) {
3781
+ try {
3782
+ return await this.opts.mentionable();
3783
+ } catch (err) {
3784
+ if (typeof console !== "undefined") {
3785
+ console.warn("[vizu] options.mentionable threw", err);
3786
+ }
3787
+ return [];
3788
+ }
3789
+ }
3761
3790
  if (this.storage instanceof CloudStorageAdapter) {
3762
3791
  return this.storage.searchMentionable();
3763
3792
  }
@@ -3972,10 +4001,29 @@ var Vizu = class {
3972
4001
  replies: [...this.comments[idx].replies ?? [], reply]
3973
4002
  };
3974
4003
  this.comments[idx] = updated;
3975
- if (this.storage.addReply) {
3976
- await this.storage.addReply(this.opts.namespace, commentId, reply);
3977
- } else {
3978
- await this.storage.updateComment(this.opts.namespace, commentId, { replies: updated.replies });
4004
+ try {
4005
+ if (this.storage.addReply) {
4006
+ await this.storage.addReply(this.opts.namespace, commentId, reply);
4007
+ } else {
4008
+ await this.storage.updateComment(this.opts.namespace, commentId, { replies: updated.replies });
4009
+ }
4010
+ } catch (err) {
4011
+ const cur = this.comments[idx];
4012
+ this.comments[idx] = {
4013
+ ...cur,
4014
+ replies: (cur.replies ?? []).filter((r) => r.id !== reply.id)
4015
+ };
4016
+ const code = err?.code ?? "";
4017
+ const status = err?.status;
4018
+ const msg = status === 403 || code === "forbidden" ? "Reply failed \u2014 you don't have permission." : status === 401 || code === "auth_required" ? "Reply failed \u2014 please sign in again." : "Reply failed. Please try again.";
4019
+ this.pill?.toast(msg);
4020
+ this.refreshUi();
4021
+ if (this.popover?.isOpen()) {
4022
+ const anchors = this.popover.getAnchors();
4023
+ if (anchors[0]) this.popover.update(this.commentsForElement(anchors[0]));
4024
+ }
4025
+ if (typeof console !== "undefined") console.warn("[vizu] addReply failed", err);
4026
+ return null;
3979
4027
  }
3980
4028
  this.bus.emit("comment:updated", { comment: updated });
3981
4029
  this.refreshUi();