Files
rich-text-elements-ui/src/services/history.service.ts
Giuliano Silvestro 30775d5a01 feat: initial rich-text-elements-ui library implementation
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>
2026-02-15 23:33:25 +10:00

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();
}
}