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