@tiptap/extension-text-align
Advanced tools
Comparing version 2.3.2 to 2.4.0
import { Extension } from '@tiptap/core'; | ||
/** | ||
* This extension allows you to align text. | ||
* @see https://www.tiptap.dev/api/extensions/text-align | ||
*/ | ||
const TextAlign = Extension.create({ | ||
@@ -37,6 +41,10 @@ name: 'textAlign', | ||
} | ||
return this.options.types.every(type => commands.updateAttributes(type, { textAlign: alignment })); | ||
return this.options.types | ||
.map(type => commands.updateAttributes(type, { textAlign: alignment })) | ||
.every(response => response); | ||
}, | ||
unsetTextAlign: () => ({ commands }) => { | ||
return this.options.types.every(type => commands.resetAttributes(type, 'textAlign')); | ||
return this.options.types | ||
.map(type => commands.resetAttributes(type, 'textAlign')) | ||
.every(response => response); | ||
}, | ||
@@ -43,0 +51,0 @@ }; |
@@ -7,2 +7,6 @@ (function (global, factory) { | ||
/** | ||
* This extension allows you to align text. | ||
* @see https://www.tiptap.dev/api/extensions/text-align | ||
*/ | ||
const TextAlign = core.Extension.create({ | ||
@@ -42,6 +46,10 @@ name: 'textAlign', | ||
} | ||
return this.options.types.every(type => commands.updateAttributes(type, { textAlign: alignment })); | ||
return this.options.types | ||
.map(type => commands.updateAttributes(type, { textAlign: alignment })) | ||
.every(response => response); | ||
}, | ||
unsetTextAlign: () => ({ commands }) => { | ||
return this.options.types.every(type => commands.resetAttributes(type, 'textAlign')); | ||
return this.options.types | ||
.map(type => commands.resetAttributes(type, 'textAlign')) | ||
.every(response => response); | ||
}, | ||
@@ -48,0 +56,0 @@ }; |
import { Extension } from '@tiptap/core'; | ||
export interface TextAlignOptions { | ||
/** | ||
* The types where the text align attribute can be applied. | ||
* @default [] | ||
* @example ['heading', 'paragraph'] | ||
*/ | ||
types: string[]; | ||
/** | ||
* The alignments which are allowed. | ||
* @default ['left', 'center', 'right', 'justify'] | ||
* @example ['left', 'right'] | ||
*/ | ||
alignments: string[]; | ||
/** | ||
* The default alignment. | ||
* @default 'left' | ||
* @example 'center' | ||
*/ | ||
defaultAlignment: string; | ||
@@ -12,2 +27,4 @@ } | ||
* Set the text align attribute | ||
* @param alignment The alignment | ||
* @example editor.commands.setTextAlign('left') | ||
*/ | ||
@@ -17,2 +34,3 @@ setTextAlign: (alignment: string) => ReturnType; | ||
* Unset the text align attribute | ||
* @example editor.commands.unsetTextAlign() | ||
*/ | ||
@@ -23,2 +41,6 @@ unsetTextAlign: () => ReturnType; | ||
} | ||
/** | ||
* This extension allows you to align text. | ||
* @see https://www.tiptap.dev/api/extensions/text-align | ||
*/ | ||
export declare const TextAlign: Extension<TextAlignOptions, any>; |
{ | ||
"name": "@tiptap/extension-text-align", | ||
"description": "text align extension for tiptap", | ||
"version": "2.3.2", | ||
"version": "2.4.0", | ||
"homepage": "https://tiptap.dev", | ||
@@ -32,3 +32,3 @@ "keywords": [ | ||
"devDependencies": { | ||
"@tiptap/core": "^2.3.2" | ||
"@tiptap/core": "^2.4.0" | ||
}, | ||
@@ -35,0 +35,0 @@ "peerDependencies": { |
import { Extension } from '@tiptap/core' | ||
export interface TextAlignOptions { | ||
/** | ||
* The types where the text align attribute can be applied. | ||
* @default [] | ||
* @example ['heading', 'paragraph'] | ||
*/ | ||
types: string[], | ||
/** | ||
* The alignments which are allowed. | ||
* @default ['left', 'center', 'right', 'justify'] | ||
* @example ['left', 'right'] | ||
*/ | ||
alignments: string[], | ||
/** | ||
* The default alignment. | ||
* @default 'left' | ||
* @example 'center' | ||
*/ | ||
defaultAlignment: string, | ||
@@ -14,2 +31,4 @@ } | ||
* Set the text align attribute | ||
* @param alignment The alignment | ||
* @example editor.commands.setTextAlign('left') | ||
*/ | ||
@@ -19,2 +38,3 @@ setTextAlign: (alignment: string) => ReturnType, | ||
* Unset the text align attribute | ||
* @example editor.commands.unsetTextAlign() | ||
*/ | ||
@@ -26,2 +46,6 @@ unsetTextAlign: () => ReturnType, | ||
/** | ||
* This extension allows you to align text. | ||
* @see https://www.tiptap.dev/api/extensions/text-align | ||
*/ | ||
export const TextAlign = Extension.create<TextAlignOptions>({ | ||
@@ -66,7 +90,11 @@ name: 'textAlign', | ||
return this.options.types.every(type => commands.updateAttributes(type, { textAlign: alignment })) | ||
return this.options.types | ||
.map(type => commands.updateAttributes(type, { textAlign: alignment })) | ||
.every(response => response) | ||
}, | ||
unsetTextAlign: () => ({ commands }) => { | ||
return this.options.types.every(type => commands.resetAttributes(type, 'textAlign')) | ||
return this.options.types | ||
.map(type => commands.resetAttributes(type, 'textAlign')) | ||
.every(response => response) | ||
}, | ||
@@ -73,0 +101,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
28255
338