@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/index.js CHANGED
@@ -3236,7 +3236,9 @@ var STYLES = `
3236
3236
  .vz-ref:hover { background: color-mix(in srgb, var(--vz-accent) 30%, var(--vz-bg-hover)); transform: translateY(-1px); }
3237
3237
  .vz-ref::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--vz-accent); flex-shrink: 0; }
3238
3238
 
3239
- /* Inline @mention chip (rendered inside displayed comments) */
3239
+ /* Inline @mention chip (rendered inside displayed comments). user-select
3240
+ * prevents the user from selecting the chip's text and editing it; the
3241
+ * displayed comment is intentionally read-only after save. */
3240
3242
  .vz-mention {
3241
3243
  display: inline-flex; align-items: center;
3242
3244
  padding: 1px 8px 1px 8px;
@@ -3246,13 +3248,21 @@ var STYLES = `
3246
3248
  font-size: 12px; font-weight: 600;
3247
3249
  vertical-align: baseline;
3248
3250
  margin: 0 1px;
3251
+ user-select: none;
3252
+ -webkit-user-select: none;
3253
+ cursor: default;
3249
3254
  }
3250
3255
 
3251
- /* Mention chip inside the editor (contenteditable=false token) */
3256
+ /* Mention chip inside the editor (contenteditable=false token). Same
3257
+ * non-selection rules as .vz-mention so the chip stays atomic even
3258
+ * inside the editable surface \u2014 caret can land before/after but not
3259
+ * inside, no partial-text edit. */
3252
3260
  .vz-chip-mention {
3253
3261
  background: color-mix(in srgb, var(--vz-accent) 16%, var(--vz-bg-hover));
3254
3262
  color: var(--vz-accent);
3255
3263
  font-weight: 600;
3264
+ user-select: none;
3265
+ -webkit-user-select: none;
3256
3266
  }
3257
3267
  .vz-chip-mention::before { display: none; }
3258
3268
 
@@ -3946,10 +3956,29 @@ var Vizu = class {
3946
3956
  replies: [...this.comments[idx].replies ?? [], reply]
3947
3957
  };
3948
3958
  this.comments[idx] = updated;
3949
- if (this.storage.addReply) {
3950
- await this.storage.addReply(this.opts.namespace, commentId, reply);
3951
- } else {
3952
- await this.storage.updateComment(this.opts.namespace, commentId, { replies: updated.replies });
3959
+ try {
3960
+ if (this.storage.addReply) {
3961
+ await this.storage.addReply(this.opts.namespace, commentId, reply);
3962
+ } else {
3963
+ await this.storage.updateComment(this.opts.namespace, commentId, { replies: updated.replies });
3964
+ }
3965
+ } catch (err) {
3966
+ const cur = this.comments[idx];
3967
+ this.comments[idx] = {
3968
+ ...cur,
3969
+ replies: (cur.replies ?? []).filter((r) => r.id !== reply.id)
3970
+ };
3971
+ const code = err?.code ?? "";
3972
+ const status = err?.status;
3973
+ 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.";
3974
+ this.pill?.toast(msg);
3975
+ this.refreshUi();
3976
+ if (this.popover?.isOpen()) {
3977
+ const anchors = this.popover.getAnchors();
3978
+ if (anchors[0]) this.popover.update(this.commentsForElement(anchors[0]));
3979
+ }
3980
+ if (typeof console !== "undefined") console.warn("[vizu] addReply failed", err);
3981
+ return null;
3953
3982
  }
3954
3983
  this.bus.emit("comment:updated", { comment: updated });
3955
3984
  this.refreshUi();