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