From b4e41afd1798e7eba4ccb0804be1ed2473c1f4d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Fri, 18 Jun 2021 12:33:18 +0200 Subject: [PATCH] fix: remove default types for textAlign extension, fix #1430 There are no default types for TextAlign extension anymore. You have to configure by yourself. Usually something like: ```js TextAlign.configure({ types: ['heading', 'paragraph'], }) ``` --- docs/src/demos/Examples/Formatting/index.vue | 4 +++- docs/src/demos/Extensions/TextAlign/index.vue | 4 +++- docs/src/docPages/api/extensions/text-align.md | 10 +++++----- packages/extension-text-align/src/text-align.ts | 6 +++--- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/docs/src/demos/Examples/Formatting/index.vue b/docs/src/demos/Examples/Formatting/index.vue index 8dd8f255..e9a35646 100644 --- a/docs/src/demos/Examples/Formatting/index.vue +++ b/docs/src/demos/Examples/Formatting/index.vue @@ -63,7 +63,9 @@ export default { this.editor = new Editor({ extensions: [ StarterKit, - TextAlign, + TextAlign.configure({ + types: ['heading', 'paragraph'], + }), Highlight, ], content: ` diff --git a/docs/src/demos/Extensions/TextAlign/index.vue b/docs/src/demos/Extensions/TextAlign/index.vue index a29c3498..f094b233 100644 --- a/docs/src/demos/Extensions/TextAlign/index.vue +++ b/docs/src/demos/Extensions/TextAlign/index.vue @@ -45,7 +45,9 @@ export default { Paragraph, Text, Heading, - TextAlign, + TextAlign.configure({ + types: ['heading', 'paragraph'], + }), ], content: `

Heading

diff --git a/docs/src/docPages/api/extensions/text-align.md b/docs/src/docPages/api/extensions/text-align.md index 546cae44..455bbe95 100644 --- a/docs/src/docPages/api/extensions/text-align.md +++ b/docs/src/docPages/api/extensions/text-align.md @@ -18,11 +18,11 @@ yarn add @tiptap/extension-text-align ``` ## Settings -| Option | Type | Default | Description | -| ---------------- | -------- | ---------------------------------------- | -------------------------------------------------------------------- | -| types | `Array` | `['heading', 'paragraph']` | A list of nodes where the text align attribute should be applied to. | -| alignments | `Array` | `['left', 'center', 'right', 'justify']` | A list of available options for the text align attribute. | -| defaultAlignment | `String` | `'left'` | The default text align. | +| Option | Type | Default | Description | +| ---------------- | -------- | ---------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | +| types | `Array` | `[]` | A list of nodes where the text align attribute should be applied to. Usually something like `['heading', 'paragraph']`.| +| alignments | `Array` | `['left', 'center', 'right', 'justify']` | A list of available options for the text align attribute. | +| defaultAlignment | `String` | `'left'` | The default text align. | ## Commands | Command | Parameters | Description | diff --git a/packages/extension-text-align/src/text-align.ts b/packages/extension-text-align/src/text-align.ts index 93730520..006a55ae 100644 --- a/packages/extension-text-align/src/text-align.ts +++ b/packages/extension-text-align/src/text-align.ts @@ -25,7 +25,7 @@ export const TextAlign = Extension.create({ name: 'textAlign', defaultOptions: { - types: ['heading', 'paragraph'], + types: [], alignments: ['left', 'center', 'right', 'justify'], defaultAlignment: 'left', }, @@ -60,10 +60,10 @@ export const TextAlign = Extension.create({ return false } - return this.options.types.some(type => commands.updateAttributes(type, { textAlign: alignment })) + return this.options.types.every(type => commands.updateAttributes(type, { textAlign: alignment })) }, unsetTextAlign: () => ({ commands }) => { - return this.options.types.some(type => commands.resetAttributes(type, 'textAlign')) + return this.options.types.every(type => commands.resetAttributes(type, 'textAlign')) }, } },