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
10 changes: 8 additions & 2 deletions packages/super-editor/src/extensions/comment/comments-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -644,13 +644,19 @@ export const translateFormatChangesToEnglish = (attrs = {}) => {
* @param {String} param0.activeThreadId The active comment ID
* @param {String} param0.threadId The current thread ID
* @param {Boolean} param0.isInternal Whether the comment is internal or external
* @param {Boolean} [param0.isResolved] Whether the comment is resolved
* @param {EditorView} param0.editor The current editor view
* @returns {String} The color to use for the highlight
*/
export const getHighlightColor = ({ activeThreadId, threadId, isInternal, editor }) => {
export const getHighlightColor = ({ activeThreadId, threadId, isInternal, isResolved, editor }) => {
if (!editor.options.isInternal && isInternal) return 'transparent';
const pluginState = CommentsPluginKey.getState(editor.state);
const color = isInternal ? pluginState.internalColor : pluginState.externalColor;
let color;
if (isResolved) {
color = pluginState.resolvedColor;
} else {
color = isInternal ? pluginState.internalColor : pluginState.externalColor;
}
const alpha = activeThreadId == threadId ? '44' : '22';
return `${color}${alpha}`;
};
11 changes: 9 additions & 2 deletions packages/super-editor/src/extensions/comment/comments-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,15 +309,22 @@ export const CommentsPlugin = Extension.create({

if (editor.options.isHeadless) return [];

// Read custom highlight colors from editor options, with defaults
const highlightColors = editor.options.commentsHighlightColors || {};
const externalColor = highlightColors.external || '#B1124B';
const internalColor = highlightColors.internal || '#078383';
const resolvedColor = highlightColors.resolved || '#808080';
Comment on lines +312 to +316

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Validate custom highlight colors before use

Custom colors are now accepted verbatim here, but getHighlightColor later appends an alpha suffix ('22'/'44') via string concatenation. That only produces valid CSS when the base color is a 6‑digit hex value; if a caller supplies a common CSS color like rgb(255,0,0) or #RRGGBBAA, the concatenation yields an invalid color string (e.g. rgb(255,0,0)22), so highlights won’t render. This only affects configurations that use non‑6‑digit hex strings; consider validating/normalizing to hex or converting to rgba(...) before appending alpha.

Useful? React with 👍 / 👎.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattConnHarbour can you fix this?


const commentsPlugin = new Plugin({
key: CommentsPluginKey,

state: {
init() {
return {
activeThreadId: null,
externalColor: '#B1124B',
internalColor: '#078383',
externalColor,
internalColor,
resolvedColor,
decorations: DecorationSet.empty,
allCommentPositions: {},
allCommentIds: [],
Expand Down
1 change: 1 addition & 0 deletions packages/superdoc/src/SuperDoc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ const editorOptions = (doc) => {
isInternal: proxy.$superdoc.config.isInternal,
annotations: proxy.$superdoc.config.annotations,
isCommentsEnabled: Boolean(commentsModuleConfig.value),
commentsHighlightColors: commentsModuleConfig.value?.highlightColors || null,
isAiEnabled: proxy.$superdoc.config.modules?.ai,
slashMenuConfig: proxy.$superdoc.config.modules?.slashMenu,
editorCtor: useLayoutEngine ? PresentationEditor : undefined,
Expand Down
8 changes: 8 additions & 0 deletions packages/superdoc/src/core/types/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@
* @property {Object} [params] Additional params for internal provider (deprecated)
*/

/**
* @typedef {Object} CommentsHighlightColors
* @property {string} [external] Highlight color for external comments (default: '#B1124B')
* @property {string} [internal] Highlight color for internal comments (default: '#078383')
* @property {string} [resolved] Highlight color for resolved comments (default: '#808080')
*/

/**
* @typedef {Object} Modules
* @property {Object | false} [comments] Comments module configuration (false to disable)
Expand All @@ -51,6 +58,7 @@
* currentUser?: User | null,
* superdoc?: SuperDoc | null,
* }) => boolean | undefined} [comments.permissionResolver] Custom permission resolver for comment actions
* @property {CommentsHighlightColors} [comments.highlightColors] Custom colors for comment highlights
* @property {Object} [ai] AI module configuration
* @property {string} [ai.apiKey] Harbour API key for AI features
* @property {string} [ai.endpoint] Custom endpoint URL for AI services
Expand Down