The parts of a document with their comments in the margin next to them
Lets a team talk about a text next to the part that the talk is about, as in a shared document. For a long talk with replies, use a thread.
Basic
Our studio sells microphones and foam panels to home recording artists across Indonesia.
This quarter we plan to open a second warehouse in Surabaya, so orders in the east arrive in two days.
The budget for the move is Rp 480 million, most of it for racks and the first three months of rent.
vue
<template> <BlessMarginComments :blocks :comments @add="add" /></template><script setup lang="ts">import { ref } from "vue";import { BlessMarginComments, type BlessMarginComment } from "blessing-ui";const blocks = [ { id: "p1", text: "Our studio sells microphones and foam panels to home recording artists across Indonesia.", }, { id: "p2", text: "This quarter we plan to open a second warehouse in Surabaya, so orders in the east arrive in two days.", }, { id: "p3", text: "The budget for the move is Rp 480 million, most of it for racks and the first three months of rent.", },];const comments = ref<BlessMarginComment[]>([ { id: "c1", block: "p2", author: "Dimas", text: "Two days is our goal. Today it is four.", time: "Mon 09:12", }, { id: "c2", block: "p3", author: "Sari", text: "Add the cost of the staff training.", time: "Mon 10:40", },]);let n = 3;const add = (block: string, text: string) => comments.value.push({ id: `c${n++}`, block, author: "You", text, time: "now" });</script>
blocks is the text in parts, each with an id and a text. A part is often a paragraph.
comments is the list of comments. Each comment has an id, the block that it is about, an author, a text, and an optional time.
A part with comments gets a bar on its edge. On a narrow screen, the margin goes below its part.
The Comment button opens a box in the margin and moves the focus into it. Send emits add with the block id and the text. Escape closes the box.
Each margin is a landmark with a name such as "Comments on part 2", so screen readers can jump to it.
Change the words with labels or a label pack. The API table lists the keys.
Margin comments
The parts of a document with their comments in the margin next to them
Lets a team talk about a text next to the part that the talk is about, as in a shared document. For a long talk with replies, use a thread.
blocksis the text in parts, each with anidand atext. A part is often a paragraph.commentsis the list of comments. Each comment has anid, theblockthat it is about, anauthor, atext, and an optionaltime.addwith the block id and the text. Escape closes the box.labelsor a label pack. The API table lists the keys.Usage
API
Props
blocks*BlessDocBlock[]commentsBlessMarginComment[]labelsPartial<{ comment: string; send: string; cancel: string; placeholder: string; on: (index: number) => string; }>Events
add[block: string, text: string]