[editor] add text highlight action

This commit is contained in:
ilya-bkv 2023-05-09 20:31:28 +03:00
parent 2c252b8dce
commit 82430404e3
4 changed files with 22 additions and 2 deletions

View File

@ -142,7 +142,12 @@ export const Editor = (props: EditorProps) => {
Focus,
Gapcursor,
HardBreak,
Highlight,
Highlight.configure({
multicolor: true,
HTMLAttributes: {
class: 'highlight'
}
}),
CustomImage.configure({
HTMLAttributes: {
class: 'uploadedImage'

View File

@ -72,3 +72,8 @@
.horizontalRule {
border-top: 2px solid #000;
}
mark.highlight {
box-decoration-break: clone;
padding: 0.125em 0;
}

View File

@ -14,7 +14,7 @@
margin-left: 4px;
}
.colorWheel {
.toggleHighlight {
display: inline-block;
width: 20px;
height: 20px;

View File

@ -36,6 +36,7 @@ export const TextBubbleMenu = (props: BubbleMenuProps) => {
const isOrderedList = isActive('isOrderedList')
const isBulletList = isActive('isBulletList')
const isLink = isActive('link')
const isHighlight = isActive('highlight')
const toggleLinkForm = () => {
setLinkEditorOpen(true)
@ -191,6 +192,15 @@ export const TextBubbleMenu = (props: BubbleMenuProps) => {
>
<Icon name="editor-italic" />
</button>
<button
type="button"
class={clsx(styles.bubbleMenuButton, {
[styles.bubbleMenuButtonActive]: isHighlight()
})}
onClick={() => props.editor.chain().focus().toggleHighlight({ color: '#F6E3A1' }).run()}
>
<div class={styles.toggleHighlight} />
</button>
<div class={styles.delimiter} />
<button
type="button"