@unhingged/vizu-core 0.1.14 → 0.1.15

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
 
@@ -3972,10 +3982,29 @@ var Vizu = class {
3972
3982
  replies: [...this.comments[idx].replies ?? [], reply]
3973
3983
  };
3974
3984
  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 });
3985
+ try {
3986
+ if (this.storage.addReply) {
3987
+ await this.storage.addReply(this.opts.namespace, commentId, reply);
3988
+ } else {
3989
+ await this.storage.updateComment(this.opts.namespace, commentId, { replies: updated.replies });
3990
+ }
3991
+ } catch (err) {
3992
+ const cur = this.comments[idx];
3993
+ this.comments[idx] = {
3994
+ ...cur,
3995
+ replies: (cur.replies ?? []).filter((r) => r.id !== reply.id)
3996
+ };
3997
+ const code = err?.code ?? "";
3998
+ const status = err?.status;
3999
+ 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.";
4000
+ this.pill?.toast(msg);
4001
+ this.refreshUi();
4002
+ if (this.popover?.isOpen()) {
4003
+ const anchors = this.popover.getAnchors();
4004
+ if (anchors[0]) this.popover.update(this.commentsForElement(anchors[0]));
4005
+ }
4006
+ if (typeof console !== "undefined") console.warn("[vizu] addReply failed", err);
4007
+ return null;
3979
4008
  }
3980
4009
  this.bus.emit("comment:updated", { comment: updated });
3981
4010
  this.refreshUi();