Add formatting toolbars and admin-configurable default sort order #13

Merged
Copilot merged 4 commits from copilot/add-markdown-context-bar into main 2025-11-05 15:45:29 -06:00
Copilot commented 2025-11-05 15:06:32 -06:00 (Migrated from github.com)

Adds context toolbars for inserting markdown/HTML syntax and moves page sort order control to admin settings.

Changes

Formatting Toolbars

  • MarkdownToolbar.jsx / RichTextToolbar.jsx: New components with buttons for headers, bold, italic, links, lists, code blocks, and blockquotes
  • PageEditor.jsx: Integrated toolbars with cursor-aware insertion logic that wraps selected text and maintains cursor position
    const handleInsert = (prefix, suffix = '') => {
      const start = textarea.selectionStart;
      const end = textarea.selectionEnd;
      const selectedText = content.substring(start, end);
      const newText = beforeText + prefix + selectedText + suffix + afterText;
      setContent(newText);
      // Restore cursor position
      setTimeout(() => {
        textarea.setSelectionRange(newCursorPos, newCursorPos);
      }, 0);
    };
    

Admin Sort Configuration

  • SettingsPage.jsx: Added "Display" tab with dropdown to set default sort order (alphabetical, category, recent, creator, custom)
  • backend/routes/settings.js: New /settings/public/:key endpoint with whitelist for non-sensitive settings accessible to authenticated users
  • Sidebar.jsx: Fetches server-configured default on mount, falls back to localStorage if user has explicit preference
    const loadDefaultSortOrder = async () => {
      const response = await settings.getPublic('default_sort_order');
      const serverDefault = response.data.value || DEFAULT_SORT;
      const saved = localStorage.getItem('sortBy');
      setSortBy(saved || serverDefault); // User preference takes precedence
    };
    

Security

Public settings endpoint uses explicit whitelist (['default_sort_order']) to prevent exposure of sensitive configuration.

Original prompt

I would like a few changes

Can we add a Markdown Context Bar to insert things like headers, links, ordered and unordered lists, headers, etc? I would also like to do the same thing for Rich Text.

Can we move the Sorting Dropdown to be a setting within the Admin settings that persists for all users so that an Admin can define exactly how pages are organized?


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Adds context toolbars for inserting markdown/HTML syntax and moves page sort order control to admin settings. ## Changes ### Formatting Toolbars - **`MarkdownToolbar.jsx`** / **`RichTextToolbar.jsx`**: New components with buttons for headers, bold, italic, links, lists, code blocks, and blockquotes - **`PageEditor.jsx`**: Integrated toolbars with cursor-aware insertion logic that wraps selected text and maintains cursor position ```jsx const handleInsert = (prefix, suffix = '') => { const start = textarea.selectionStart; const end = textarea.selectionEnd; const selectedText = content.substring(start, end); const newText = beforeText + prefix + selectedText + suffix + afterText; setContent(newText); // Restore cursor position setTimeout(() => { textarea.setSelectionRange(newCursorPos, newCursorPos); }, 0); }; ``` ### Admin Sort Configuration - **`SettingsPage.jsx`**: Added "Display" tab with dropdown to set default sort order (alphabetical, category, recent, creator, custom) - **`backend/routes/settings.js`**: New `/settings/public/:key` endpoint with whitelist for non-sensitive settings accessible to authenticated users - **`Sidebar.jsx`**: Fetches server-configured default on mount, falls back to localStorage if user has explicit preference ```javascript const loadDefaultSortOrder = async () => { const response = await settings.getPublic('default_sort_order'); const serverDefault = response.data.value || DEFAULT_SORT; const saved = localStorage.getItem('sortBy'); setSortBy(saved || serverDefault); // User preference takes precedence }; ``` ## Security Public settings endpoint uses explicit whitelist (`['default_sort_order']`) to prevent exposure of sensitive configuration. <!-- START COPILOT CODING AGENT SUFFIX --> <details> <summary>Original prompt</summary> > I would like a few changes > > Can we add a Markdown Context Bar to insert things like headers, links, ordered and unordered lists, headers, etc? I would also like to do the same thing for Rich Text. > > Can we move the Sorting Dropdown to be a setting within the Admin settings that persists for all users so that an Admin can define exactly how pages are organized? </details> <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey).
SluberskiHomeLab (Migrated from github.com) reviewed 2025-11-05 15:06:32 -06:00
Sign in to join this conversation.
No description provided.