Good point to make a commit
This commit is contained in:
34
tp-rtb-underline.js
Normal file
34
tp-rtb-underline.js
Normal file
@ -0,0 +1,34 @@
|
||||
import { TpRtbBaseExtension } from './tp-rtb-base-extension.js';
|
||||
import Underline from '@tiptap/extension-underline';
|
||||
|
||||
class TpRtbUnderline extends TpRtbBaseExtension {
|
||||
constructor() {
|
||||
super();
|
||||
this.label = 'Underline';
|
||||
}
|
||||
|
||||
getExtension() {
|
||||
return Underline;
|
||||
}
|
||||
|
||||
_handleClick() {
|
||||
if (this.parentEditor && this.parentEditor.editor) {
|
||||
this.parentEditor.editor.chain().focus().toggleUnderline().run();
|
||||
}
|
||||
}
|
||||
|
||||
_setupEditorListeners() {
|
||||
const { editor } = this.parentEditor;
|
||||
|
||||
// Update button state when selection changes
|
||||
editor.on('selectionUpdate', () => {
|
||||
this.active = editor.isActive('underline');
|
||||
});
|
||||
|
||||
editor.on('focus', () => {
|
||||
this.active = editor.isActive('underline');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
customElements.define('tp-rtb-underline', TpRtbUnderline);
|
Reference in New Issue
Block a user