feat: add combined codebase

This commit is contained in:
Patrick Charrier
2026-04-15 01:23:33 +02:00
parent 4275cbd795
commit 32e39384d5
19 changed files with 3007 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
import * as Y from "yjs";
export function PollTitle(ydoc: Y.Doc, yTitle: Y.Text): HTMLElement {
const wrapper = document.createElement("div");
wrapper.className = "poll-title-wrapper";
const input = document.createElement("input");
input.type = "text";
input.id = "poll-title";
input.className = "poll-title-input";
input.placeholder = "Untitled Poll";
input.maxLength = 120;
input.setAttribute("aria-label", "Poll title");
input.value = yTitle.toString();
wrapper.appendChild(input);
// Sync from Yjs → input (only when not focused to avoid cursor jump)
yTitle.observe(() => {
if (document.activeElement !== input) {
input.value = yTitle.toString();
}
});
// Sync from input → Yjs
input.addEventListener("input", () => {
ydoc.transact(() => {
yTitle.delete(0, yTitle.length);
yTitle.insert(0, input.value);
});
});
return wrapper;
}