Skip to content

Commit

Permalink
somewhat working set highlight
Browse files Browse the repository at this point in the history
  • Loading branch information
samlhuillier committed Nov 17, 2024
1 parent 2c71e4f commit 79b5523
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
25 changes: 25 additions & 0 deletions src/components/Editor/Extensions/CustomHighlight.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// ... existing imports ...
import { Extension } from '@tiptap/core'

// Add this custom extension configuration before the EditorManager component
const CustomHighlight = Extension.create({
name: 'customHighlight',
addGlobalAttributes() {
return [
{
types: ['highlight'],
attributes: {
class: {
default: 'selection-highlight',
parseHTML: () => 'selection-highlight',
renderHTML: () => ({
class: 'selection-highlight',
}),
},
},
},
]
},
})

export default CustomHighlight
2 changes: 2 additions & 0 deletions src/contexts/FileContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import getMarkdown from '@/components/Editor/utils'
import useOrderedSet from '../lib/hooks/use-ordered-set'
import welcomeNote from '@/lib/welcome-note'
import ClearFormattingExtension from '@/components/Editor/Extensions/FormattingExtension'
import CustomHighlight from '@/components/Editor/Extensions/CustomHighlight'

type FileContextType = {
vaultFilesTree: FileInfoTree
Expand Down Expand Up @@ -169,6 +170,7 @@ export const FileProvider: React.FC<{ children: ReactNode }> = ({ children }) =>
TableHeader,
TableCell,
TextStyle,
CustomHighlight,
SearchAndReplace.configure({
searchResultClass: 'bg-yellow-400',
disableRegex: false,
Expand Down
13 changes: 12 additions & 1 deletion src/styles/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,18 @@ button {
/* Adjust day cell size */
}

/* AI Edit highlight styles */
/* Add this before the @layer base section */
.tiptap mark.selection-highlight {
background: rgba(66, 135, 245, 0.4) !important;
color: inherit !important;
border-radius: 0 !important;
padding: 0 !important;
margin: 0 !important;
-webkit-user-select: none !important;
user-select: none !important;
}

/* You can remove or comment out the existing AI edit highlight styles */
/* .tiptap .ai-edit-highlight {
background-color: pink;
border-radius: 2px;
Expand Down

0 comments on commit 79b5523

Please sign in to comment.