diff --git a/modules/rnotes/components/folk-notes-app.ts b/modules/rnotes/components/folk-notes-app.ts index 350bde6..062dd70 100644 --- a/modules/rnotes/components/folk-notes-app.ts +++ b/modules/rnotes/components/folk-notes-app.ts @@ -37,7 +37,7 @@ import { ySyncPlugin, yUndoPlugin, yCursorPlugin } from '@tiptap/y-tiptap'; import { RSpaceYjsProvider } from '../yjs-ws-provider'; import { CommentMark } from './comment-mark'; import { SuggestionInsertMark, SuggestionDeleteMark } from './suggestion-marks'; -import { createSuggestionPlugin, acceptSuggestion, rejectSuggestion, acceptAllSuggestions, rejectAllSuggestions } from './suggestion-plugin'; +import { createSuggestionPlugin, acceptSuggestion, rejectSuggestion } from './suggestion-plugin'; import './comment-panel'; const lowlight = createLowlight(common); @@ -295,7 +295,16 @@ class FolkNotesApp extends HTMLElement { rightCol.appendChild(this.contentZone); rightCol.appendChild(this.metaZone); + // Sidebar reopen tab (lives on layout, outside navZone so it's visible when collapsed) + const reopenBtn = document.createElement('button'); + reopenBtn.id = 'sidebar-reopen'; + reopenBtn.className = 'sidebar-reopen'; + reopenBtn.title = 'Show sidebar'; + reopenBtn.textContent = '\u203A'; + reopenBtn.addEventListener('click', () => this.toggleSidebar(true)); + layout.appendChild(this.navZone); + layout.appendChild(reopenBtn); layout.appendChild(rightCol); this.shadow.appendChild(style); @@ -2372,25 +2381,12 @@ Gear: EUR 400 (10%)
Maya is tracking expenses in rF
bar.innerHTML = `
${this.suggestingMode ? 'Suggesting' : 'Editing'}
${ids.size > 0 ? `
- ${ids.size} suggestion${ids.size !== 1 ? 's' : ''}
-
-
+ ${ids.size} suggestion${ids.size !== 1 ? 's' : ''} — review in sidebar
` : 'Start typing to suggest changes'}
`;
- // Wire buttons
- bar.querySelector('[data-action="accept-all-suggestions"]')?.addEventListener('click', () => {
- if (this.editor) {
- acceptAllSuggestions(this.editor);
- this.updateSuggestionReviewBar();
- }
- });
- bar.querySelector('[data-action="reject-all-suggestions"]')?.addEventListener('click', () => {
- if (this.editor) {
- rejectAllSuggestions(this.editor);
- this.updateSuggestionReviewBar();
- }
- });
+ // Open sidebar to show suggestions when there are any
+ if (ids.size > 0) this.showCommentPanel();
}
/** Show an accept/reject popover near a clicked suggestion mark. */
@@ -2420,6 +2416,7 @@ Gear: EUR 400 (10%) Maya is tracking expenses in rF
if (this.editor) {
acceptSuggestion(this.editor, suggestionId);
this.updateSuggestionReviewBar();
+ this.syncSuggestionsToPanel();
}
pop.remove();
});
@@ -2427,6 +2424,7 @@ Gear: EUR 400 (10%) Maya is tracking expenses in rF
if (this.editor) {
rejectSuggestion(this.editor, suggestionId);
this.updateSuggestionReviewBar();
+ this.syncSuggestionsToPanel();
}
pop.remove();
});
@@ -2443,6 +2441,47 @@ Gear: EUR 400 (10%) Maya is tracking expenses in rF
setTimeout(() => this.shadow.addEventListener('click', close), 0);
}
+ /** Collect all pending suggestions from the editor doc. */
+ private collectSuggestions(): { id: string; type: 'insert' | 'delete'; text: string; authorId: string; authorName: string; createdAt: number }[] {
+ if (!this.editor) return [];
+ const map = new Map Maya is tracking expenses in rF
const { noteId, threads } = e.detail;
if (noteId) this._demoThreads.set(noteId, threads);
});
+ // Listen for suggestion accept/reject from comment panel
+ panel.addEventListener('suggestion-accept', (e: CustomEvent) => {
+ if (this.editor && e.detail?.suggestionId) {
+ acceptSuggestion(this.editor, e.detail.suggestionId);
+ this.updateSuggestionReviewBar();
+ this.syncSuggestionsToPanel();
+ }
+ });
+ panel.addEventListener('suggestion-reject', (e: CustomEvent) => {
+ if (this.editor && e.detail?.suggestionId) {
+ rejectSuggestion(this.editor, e.detail.suggestionId);
+ this.updateSuggestionReviewBar();
+ this.syncSuggestionsToPanel();
+ }
+ });
}
panel.noteId = this.editorNoteId;
panel.doc = this.doc;
@@ -2470,8 +2524,10 @@ Gear: EUR 400 (10%) Maya is tracking expenses in rF
} else {
panel.demoThreads = null;
}
+ // Pass suggestions
+ panel.suggestions = this.collectSuggestions();
- // Show sidebar when there are comments
+ // Show sidebar when there are comments or suggestions
sidebar.classList.add('has-comments');
}
@@ -2496,9 +2552,10 @@ Gear: EUR 400 (10%) Maya is tracking expenses in rF
}
});
- // On any change, update the suggestion review bar
+ // On any change, update the suggestion review bar + sidebar panel
this.editor.on('update', () => {
this.updateSuggestionReviewBar();
+ this.syncSuggestionsToPanel();
});
// Direct click on comment highlight or suggestion marks in the DOM
@@ -2802,6 +2859,7 @@ Gear: EUR 400 (10%) Maya is tracking expenses in rF