TipTap-powered rich text editing library with WYSIWYG editor, markdown editor, template editor, collaboration support (Yjs), mentions, track changes, comments, code blocks, and table insertion. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
26 lines
575 B
TypeScript
26 lines
575 B
TypeScript
import { Injectable } from '@angular/core';
|
|
import type { Editor } from '@tiptap/core';
|
|
|
|
@Injectable()
|
|
export class HistoryService {
|
|
/** Undo the last action */
|
|
undo(editor: Editor): void {
|
|
editor.chain().focus().undo().run();
|
|
}
|
|
|
|
/** Redo the last undone action */
|
|
redo(editor: Editor): void {
|
|
editor.chain().focus().redo().run();
|
|
}
|
|
|
|
/** Check if undo is available */
|
|
canUndo(editor: Editor): boolean {
|
|
return editor.can().undo();
|
|
}
|
|
|
|
/** Check if redo is available */
|
|
canRedo(editor: Editor): boolean {
|
|
return editor.can().redo();
|
|
}
|
|
}
|