-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathtext-align.ts
More file actions
40 lines (35 loc) · 1.18 KB
/
Copy pathtext-align.ts
File metadata and controls
40 lines (35 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import type { TextAlignOptions as TiptapTextAlignOptions } from '@tiptap/extension-text-align'
import type { GeneralOptions } from '@/type'
import { TextAlign as TiptapTextAlign } from '@tiptap/extension-text-align'
import { TextAlignActionMenuButton } from './components/ActionMenuButton'
/** Represents the type for text alignments */
export type Alignments = 'left' | 'center' | 'right' | 'justify'
/**
* Represents the interface for text align options, extending TiptapTextAlignOptions and GeneralOptions.
*/
export interface TextAlignOptions extends TiptapTextAlignOptions, GeneralOptions<TextAlignOptions> {
/**
* List of available alignment options
*
* @default ['left', 'center', 'right', 'justify']
*/
alignment?: Alignments[]
}
export const TextAlign = /* @__PURE__ */ TiptapTextAlign.extend<TextAlignOptions>({
addOptions() {
return {
...this.parent?.() as TiptapTextAlignOptions,
types: ['heading', 'paragraph'],
button: ({ editor, extension, t }) => {
return {
component: TextAlignActionMenuButton,
componentProps: {
editor,
extension,
t,
},
}
},
}
},
})