Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions nx/public/plugins/quick-edit/quick-edit.css
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,82 @@ da-palette {
da-palette .da-palette-field {
color: black;
}

.qe-comment-overlay {
--comment-highlight-bg: light-dark(#fbf198, rgb(255 200 50 / 24%));
--comment-highlight-bg-active: light-dark(#f8d904, rgb(255 220 90 / 38%));
--comment-highlight-border: light-dark(#f8d904, rgb(255 210 70 / 90%));
--comment-highlight-border-active: light-dark(#e8c600, rgb(255 238 130));

position: absolute;
top: 0;
left: 0;
pointer-events: none;
z-index: 9998;
}

.qe-comment-box {
position: absolute;
margin: 0;
padding: 0;
border: none;
pointer-events: auto;
cursor: pointer;
box-sizing: border-box;
}

.qe-comment-box-text {
--da-comment-bg: var(--comment-highlight-bg);
--da-comment-border-color: var(--comment-highlight-border);

/* Visual only: let clicks fall through to the editable text underneath. */
pointer-events: none;
background: light-dark(
color-mix(in srgb, var(--da-comment-bg) 42%, transparent),
color-mix(in srgb, var(--da-comment-bg) 55%, transparent)
);
border-bottom: 2px solid var(--da-comment-border-color);
z-index: 2;
}

.qe-comment-box.is-active {
--da-comment-bg: var(--comment-highlight-bg-active);
--da-comment-border-color: var(--comment-highlight-border-active);
}

.qe-comment-box-text.is-active {
background: light-dark(
color-mix(in srgb, var(--da-comment-bg) 55%, transparent),
color-mix(in srgb, var(--da-comment-bg) 65%, transparent)
);
border-bottom-color: var(--da-comment-border-color);
}

.qe-comment-box-anchor-block {
pointer-events: none;
z-index: 1;
background: transparent !important;
outline: 2px solid var(--comment-highlight-border-active);
outline-offset: 3px;
}

.qe-comment-marker {
position: absolute;
width: 14px;
height: 14px;
padding: 0;
border: none;
border-radius: 50% 50% 50% 2px;
background: var(--comment-highlight-border);
pointer-events: auto;
cursor: pointer;
z-index: 9999;
}

.qe-comment-marker.is-active {
background: var(--comment-highlight-border-active);
}

.qe-comment-marker:hover {
filter: brightness(0.95);
}
14 changes: 14 additions & 0 deletions nx/public/plugins/quick-edit/quick-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ import { setupContentEditableListeners, setupImageDropListeners, updateImageSrc,
import { setEditorState } from './src/prose.js';
import { setCursors } from './src/cursors.js';
import { pollConnection, setupActions } from './src/utils.js';
import {
scrollToProseIndex,
setCommentMarkers,
applyCommentMarkers,
setupCommentShortcut,
restoreBlockIndices,
} from './src/comments.js';

import { loadStyle } from '../../../scripts/nexter.js';

Expand All @@ -20,6 +27,8 @@ async function setBody(body, ctx) {
const doc = new DOMParser().parseFromString(body, 'text/html');
document.body.innerHTML = doc.body.innerHTML;
await ctx.loadPage();
restoreBlockIndices(doc, document);
applyCommentMarkers(ctx);
setupContentEditableListeners(ctx);
setupImageDropListeners(ctx, document.body.querySelector('main'));
if (!parentControllerPort) {
Expand All @@ -46,6 +55,10 @@ function onMessage(e, ctx) {
updateImageSrc(originalSrc, newSrc);
} else if (e.data.type === 'image-error') {
handleImageError(e.data.error);
} else if (e.data.type === 'scroll-to-pos') {
scrollToProseIndex(e.data.proseIndex);
} else if (e.data.type === 'set-comment-markers') {
setCommentMarkers(e.data, ctx);
}
}

Expand All @@ -63,6 +76,7 @@ function setupParentController(loadPage) {
};
port.onmessage = (ev) => onMessage(ev, ctx);
port.postMessage({ ready: true });
setupCommentShortcut(ctx);

window.removeEventListener('message', listener);
};
Expand Down
Loading
Loading