line multi authors
This commit is contained in:
+14
-2
@@ -15,7 +15,7 @@ import { askConfirm } from "@rustpad/modal";
|
||||
import { currentShareUrl, readEditorState, writeEditorState } from "@rustpad/url-state";
|
||||
|
||||
const parts = location.pathname.split("/").filter(Boolean), workspaceSlug = parts[1], noteSlug = parts[3];
|
||||
const editor = document.querySelector("#editor"), preview = document.querySelector("#preview"), editorWorkspace = document.querySelector("#editor-workspace"), gutter = document.querySelector("#line-gutter"), ownerLabels = document.querySelector("#owner-labels"), authorshipLayer = document.querySelector("#authorship-layer");
|
||||
const editor = document.querySelector("#editor"), preview = document.querySelector("#preview"), editorWorkspace = document.querySelector("#editor-workspace"), gutter = document.querySelector("#line-gutter"), ownerLabels = document.querySelector("#owner-labels"), authorshipLayer = document.querySelector("#authorship-layer"), documentOwnerBadge = document.querySelector("#document-owner-badge");
|
||||
const modeToggle = document.querySelector("#mode-toggle"), passwordDialog = document.querySelector("#password-dialog"), identityDialog = document.querySelector("#identity-dialog");
|
||||
const roomDetails = document.querySelector("#room-details"), roomUsers = document.querySelector("#room-users"), roomCount = document.querySelector("#room-count"), socketLatency = document.querySelector("#socket-latency"), chatMessages = document.querySelector("#chat-messages"), chatForm = document.querySelector("#chat-form"), chatInput = document.querySelector("#chat-input"), chatUnread = document.querySelector("#chat-unread");
|
||||
let unreadChat = 0;
|
||||
@@ -52,8 +52,20 @@ async function renderCodeHighlight() { const nodes = preview.querySelectorAll('p
|
||||
function renderGutter() {
|
||||
const lineCount = Math.max(1, (editor.value.match(/\n/g) || []).length + 1);
|
||||
const lines = Array.from({ length: lineCount });
|
||||
const showAuthorship = authorshipOwners(authorship).length > 1;
|
||||
const owners = authorshipOwners(authorship);
|
||||
const showSingleOwner = owners.length === 1;
|
||||
const showAuthorship = owners.length > 1;
|
||||
const authorsByLine = showAuthorship ? lineAuthors(editor.value, authorship) : [];
|
||||
if (documentOwnerBadge) {
|
||||
documentOwnerBadge.hidden = !showSingleOwner;
|
||||
if (showSingleOwner) {
|
||||
documentOwnerBadge.textContent = ownerName(owners[0]);
|
||||
documentOwnerBadge.style.setProperty("--owner", colorFor(owners[0]));
|
||||
} else {
|
||||
documentOwnerBadge.textContent = "";
|
||||
documentOwnerBadge.style.removeProperty("--owner");
|
||||
}
|
||||
}
|
||||
authorshipLayer.hidden = !showAuthorship;
|
||||
ownerLabels.hidden = !showAuthorship;
|
||||
const style = getComputedStyle(editor), lineHeight = parseFloat(style.lineHeight) || 29, paddingTop = parseFloat(style.paddingTop) || 24, paddingBottom = parseFloat(style.paddingBottom) || 24;
|
||||
|
||||
Reference in New Issue
Block a user