@rr0/cms
Version:
RR0 Content Management System (CMS)
23 lines (22 loc) • 761 B
JavaScript
export class NoteRenderer {
constructor(counter) {
this.counter = counter;
}
render(context, html) {
const noteId = this.counter.next(context);
const doc = context.file.document;
const replacement = doc.createElement("span");
replacement.className = "note-id";
replacement.ariaLabel = "Note";
replacement.textContent = noteId;
const contents = doc.createElement("span");
contents.className = "note-contents";
contents.innerHTML = html;
const anchor = doc.createElement("span");
anchor.id = noteId;
anchor.className = "anchor";
anchor.ariaHidden = "true";
replacement.append(anchor, contents);
return replacement;
}
}